diff --git a/.gitignore b/.gitignore index ec0bf1a9e..a4327b775 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ resources/3rdparty/log4cplus-1.1.3-rc1/ resources/3rdparty/gtest-1.7.0/ resources/3rdparty/eigen/ resources/3rdparty/gmm-4.2/ -resources/3rdparty/cudd-2.5.0/ +resources/3rdparty/cudd-3.0.0/ resources/3rdparty/xercesc-3.1.2/ #Visual Studio files *.[Oo]bj @@ -45,8 +45,10 @@ build//CMakeLists.txt *.orig *.*~ # CMake generated/configured files -src/utility/storm-version.cpp +src/storm/utility/storm-version.cpp nbproject/ .DS_Store .idea -*.out \ No newline at end of file +*.out +# Python config +stormpy/setup.cfg diff --git a/CMakeLists.txt b/CMakeLists.txt index c96ea8d79..bc5d1696e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,44 +1,46 @@ -cmake_minimum_required (VERSION 2.8.6) +cmake_minimum_required (VERSION 3.2) cmake_policy(VERSION 3.2) + # Set project name project (storm CXX C) # Add base folder for better inclusion paths -include_directories("${PROJECT_SOURCE_DIR}") include_directories("${PROJECT_SOURCE_DIR}/src") - +include_directories("${PROJECT_SOURCE_DIR}/src/storm") # Add the resources/cmake folder to Module Search Path for FindTBB.cmake set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/resources/cmake/find_modules" "${PROJECT_SOURCE_DIR}/resources/cmake/macros") include(ExternalProject) +include(RegisterSourceGroup) +include(imported) -include(RegisterSourceGroup) ############################################################# ## -## CMake options of StoRM +## CMake options of Storm ## ############################################################# -option(STORM_DEVELOPER "Sets whether the development mode is used" OFF) +option(STORM_DEVELOPER "Sets whether the development mode is used." OFF) +option(STORM_ALLWARNINGS "Compile with even more warnings" OFF) +option(STORM_PORTABLE_RELEASE "Sets whether a release build needs to be portable to another machine. This is only effective for release builds in non-development mode." OFF) +MARK_AS_ADVANCED(STORM_PORTABLE_RELEASE) option(STORM_USE_POPCNT "Sets whether the popcnt instruction is going to be used." ON) MARK_AS_ADVANCED(STORM_USE_POPCNT) -option(USE_BOOST_STATIC_LIBRARIES "Sets whether the Boost libraries should be linked statically." ON) +option(USE_BOOST_STATIC_LIBRARIES "Sets whether the Boost libraries should be linked statically." OFF) option(STORM_USE_INTELTBB "Sets whether the Intel TBB libraries should be used." OFF) option(STORM_USE_GUROBI "Sets whether Gurobi should be used." OFF) -option(STORM_USE_COTIRE "Sets whether Cotire should be used (for building precompiled headers)." OFF) -option(LINK_LIBCXXABI "Sets whether libc++abi should be linked." OFF) -option(USE_LIBCXX "Sets whether the standard library is libc++." OFF) option(USE_CARL "Sets whether carl should be included." ON) option(USE_SMTRAT "Sets whether SMT-RAT should be included." OFF) option(USE_HYPRO "Sets whether HyPro should be included." OFF) -option(USE_XERCES "Sets whether xerces should be used." OFF) +option(XML_SUPPORT "Sets whether xml based format parsing should be included." ON) option(FORCE_COLOR "Force color output" OFF) mark_as_advanced(FORCE_COLOR) -option(STORM_PYTHON "Builds the API for Python" OFF) option(STORM_COMPILE_WITH_CCACHE "Compile using CCache [if found]" ON) mark_as_advanced(STORM_COMPILE_WITH_CCACHE) option(STORM_LOG_DISABLE_DEBUG "Disable log and trace message support" OFF) +option(STORM_USE_CLN_NUMBERS "Sets whether CLN or GMP numbers should be used" ON) +option(BUILD_SHARED_LIBS "Build the Storm library dynamically" OFF) set(BOOST_ROOT "" CACHE STRING "A hint to the root directory of Boost (optional).") set(GUROBI_ROOT "" CACHE STRING "A hint to the root directory of Gurobi (optional).") set(Z3_ROOT "" CACHE STRING "A hint to the root directory of Z3 (optional).") @@ -46,38 +48,52 @@ set(CUDA_ROOT "" CACHE STRING "The hint to the root directory of CUDA (optional) set(MSAT_ROOT "" CACHE STRING "The hint to the root directory of MathSAT (optional).") set(ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "Additional directories added to the include directories.") set(ADDITIONAL_LINK_DIRS "" CACHE STRING "Additional directories added to the link directories.") - +set(USE_XERCESC ${XML_SUPPORT}) +mark_as_advanced(USE_XERCESC) # Set some CMAKE Variables as advanced mark_as_advanced(CMAKE_OSX_ARCHITECTURES) mark_as_advanced(CMAKE_OSX_SYSROOT) mark_as_advanced(CMAKE_OSX_DEPLOYMENT_TARGET) -# If the STORM_DEVELOPER option was turned on, we will target a debug version. +# Offer the user the choice of overriding the installation directories +set(INCLUDE_INSTALL_DIR include/ CACHE PATH "Installation directory for header files" ) +set(LIB_INSTALL_DIR lib/ CACHE PATH "Installation directory for libraries") +#set(SYSCONFIG_INSTALL_DIR etc/carl/ CACHE PATH "Installation for system configuration files) +set(BIN_INSTALL_DIR lib/ CACHE PATH "Installation directory for executables") + + +# By default, we build a release version. +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "RELEASE") +endif() +# Install dir for cmake files (info for other libraries that include storm) +set(DEF_INSTALL_CMAKE_DIR "lib/CMake/storm") +set(CMAKE_INSTALL_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files") + +message("CMAKE_INSTALL_DIR: ${CMAKE_INSTALL_DIR}") + +# If the STORM_DEVELOPER option was turned on, we target a debug version. if (STORM_DEVELOPER) - message(STATUS "StoRM - Using development mode") - set(CMAKE_BUILD_TYPE "DEBUG" CACHE STRING "Set the build type" FORCE) + set(CMAKE_BUILD_TYPE "DEBUG") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTORM_DEV") endif() -message(STATUS "StoRM - Building ${CMAKE_BUILD_TYPE} version.") +message(STATUS "Storm - Building ${CMAKE_BUILD_TYPE} version.") if(STORM_COMPILE_WITH_CCACHE) find_program(CCACHE_FOUND ccache) mark_as_advanced(CCACHE_FOUND) if(CCACHE_FOUND) - message(STATUS "StoRM - Using ccache") + message(STATUS "Storm - Using ccache") set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) else() - message(STATUS "Could not find ccache") + message(STATUS "Storm - Could not find ccache.") endif() endif() -# Base path for test files -set(STORM_CPP_TESTS_BASE_PATH "${PROJECT_SOURCE_DIR}/test") - -set(STORMPY_OUTPUT_DIR "${PROJECT_BINARY_DIR}/stormpy") -set(STORMPY_SOURCE_DIR "${PROJECT_SOURCE_DIR}/stormpy") +# Directory for test resources. +set(STORM_TEST_RESOURCES_DIR "${PROJECT_SOURCE_DIR}/resources/examples/testfiles") # Auto-detect operating system. set(MACOSX 0) @@ -98,176 +114,186 @@ else() set(OPERATING_SYSTEM "Linux") set(LINUX 1) ENDIF() -message(STATUS "Operating system: ${OPERATING_SYSTEM}") - +message(STATUS "Storm - Detected operating system ${OPERATING_SYSTEM}.") set(DYNAMIC_EXT ".so") set(STATIC_EXT ".a") +set(LIB_PREFIX "lib") if(MACOSX) set(DYNAMIC_EXT ".dylib") set(STATIC_EXT ".a") + set(LIB_PREFIX "lib") elseif (WIN32) set(DYNAMIC_EXT ".dll") set(STATIC_EXT ".lib") + set(LIB_PREFIX "") endif() message(STATUS "Assuming extension for shared libraries: ${DYNAMIC_EXT}") message(STATUS "Assuming extension for static libraries: ${STATIC_EXT}") +if(BUILD_SHARED_LIBS) + set(LIB_EXT ${DYNAMIC_EXT}) + message(STATUS "Build dynamic libraries.") +else() + set(LIB_EXT ${STATIC_EXT}) + message(STATUS "Build static libraries.") +endif() ############################################################# ## -## Compiler specific settings and definitions +## Compiler detection and initial configuration ## ############################################################# -# Path to the no-strict-aliasing target -set(CONVERSIONHELPER_TARGET "${PROJECT_SOURCE_DIR}/src/utility/ConversionHelper.cpp") - -if(CMAKE_COMPILER_IS_GNUCC) - set(STORM_COMPILED_BY "GCC") - # Set standard flags for GCC - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -funroll-loops") - - # TODO: remove forcing the old version of optional as soon as the related Spirit bug is fixed: - # https://svn.boost.org/trac/boost/ticket/12349 - # Fix thanks to: https://github.com/freeorion/freeorion/issues/777 - add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE -DBOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL) - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -pedantic -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unknown-pragmas") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-deprecated-declarations") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) - message(FATAL_ERROR "GCC version must be at least 5.0!") - endif() - # Turn on popcnt instruction if desired (yes by default) - if (STORM_USE_POPCNT) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt") - endif(STORM_USE_POPCNT) - - # Set the no-strict-aliasing target for GCC - set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing") -elseif(MSVC) - set(STORM_COMPILED_BY "MSVC") - # required for GMM to compile, ugly error directive in their code - add_definitions(/D_SCL_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS) - # required as the PRCTL Parser bloats object files (COFF) beyond their maximum size (see http://msdn.microsoft.com/en-us/library/8578y171(v=vs.110).aspx) - add_definitions(/bigobj) - # required by GTest and PrismGrammar::createIntegerVariable - add_definitions(/D_VARIADIC_MAX=10) - # Windows.h breaks GMM in gmm_except.h because of its macro definition for min and max - add_definitions(/DNOMINMAX) - # Boost Defs, required for using boost's transform iterator - add_definitions(/DBOOST_RESULT_OF_USE_DECLTYPE) - - # since nobody cares at the moment - add_definitions(/wd4250) - - # MSVC does not do strict-aliasing, so no option needed -else(CLANG) - set(STORM_COMPILED_BY "Clang (LLVM)") - # As CLANG is not set as a variable, we need to set it in case we have not matched another compiler. - set (CLANG ON) - # Set standard flags for clang - set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops -O3") - - if(UNIX AND NOT APPLE) - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2) - message(FATAL_ERROR "Clang version must be at least 3.2!") - endif() +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # using Clang + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2) + message(FATAL_ERROR "Clang version must be at least 3.2.") endif() - if(UNIX AND APPLE) - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3) - message(FATAL_ERROR "Clang version must be at least 7.3!") - endif() + set(STORM_COMPILER_CLANG ON) + set(CLANG ON) + set(STORM_COMPILER_ID "clang") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + # using AppleClang + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3) + message(FATAL_ERROR "AppleClang version must be at least 7.3.") endif() - if(UNIX AND NOT APPLE AND NOT USE_LIBCXX) - set(CLANG_STDLIB libstdc++) - message(STATUS "StoRM - Linking against libstdc++") - else() - set(CLANG_STDLIB libc++) - message(STATUS "StoRM - Linking against libc++") - # Disable Cotire - set(STORM_USE_COTIRE OFF) - # Set up some Xcode specific settings - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - endif() - - # TODO: remove forcing the old version of optional as soon as the related Spirit bug is fixed: - # https://svn.boost.org/trac/boost/ticket/12349 - # Fix thanks to: https://github.com/freeorion/freeorion/issues/777 - add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE -DBOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -stdlib=${CLANG_STDLIB} -Wall -pedantic -Wno-newline-eof -Wno-mismatched-tags -Wno-unused-local-typedefs -ftemplate-depth=1024 -Wno-parentheses-equality") - - if(FORCE_COLOR) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics") - endif() - - # Turn on popcnt instruction if desired (yes by default) - if (STORM_USE_POPCNT) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt") - endif(STORM_USE_POPCNT) + set(STORM_COMPILER_APPLECLANG ON) + set(CLANG ON) + set(STORM_COMPILER_ID "AppleClang") + set(CMAKE_MACOSX_RPATH ON) +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # using GCC + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + message(FATAL_ERROR "gcc version must be at least 5.0.") + endif() - # Set the no-strict-aliasing target for Clang - set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing ") + set(STORM_COMPILER_GCC ON) + set(STORM_COMPILER_ID "gcc") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + message(FATAL_ERROR "Intel compiler is currently not supported.") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + message(FATAL_ERROR "Visual Studio compiler is currently not supported.") endif() - +set(STORM_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION}) if(CCACHE_FOUND) - set(STORM_COMPILED_BY "${STORM_COMPILED_BY} (ccache)") + set(STORM_COMPILER_ID "${STORM_COMPILER_ID} (ccache)") endif() -message(STATUS "StoRM - Using Compiler Configuration: ${STORM_COMPILED_BY}") - -############################################################# ############################################################# ## -## Inclusion of required libraries +## Compiler independent settings ## ############################################################# -############################################################# +if (STORM_USE_POPCNT) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt") +endif() + +# TODO: remove forcing the old version of optional as soon as the related Spirit bug is fixed: +# https://svn.boost.org/trac/boost/ticket/12349 +# Fix thanks to: https://github.com/freeorion/freeorion/issues/777 +add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE -DBOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL) ############################################################# ## -## Include the targets for non-system resources +## Compiler specific settings ## ############################################################# +if (STORM_COMPILER_CLANG OR STORM_COMPILER_APPLECLANG) + if(FORCE_COLOR) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics") + endif() + + if (LINUX) + set(CLANG_STDLIB libstdc++) + else() + set(CLANG_STDLIB libc++) + endif() + + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -stdlib=${CLANG_STDLIB} -ftemplate-depth=1024") + set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto -ffast-math -fno-finite-math-only") + set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-export_dynamic") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-export_dynamic") +elseif (STORM_COMPILER_GCC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto -fprefetch-loop-arrays -ffast-math -fno-finite-math-only") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic") +endif () + +# In release mode, we turn on even more optimizations if we do not have to provide a portable binary. +if (NOT STORM_PORTABLE_RELEASE) + set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native") +endif () -# In 3rdparty, targets are being defined that can be used -# in the the system does not have a library -include(resources/3rdparty/CMakeLists.txt) - +if (STORM_DEVELOPER) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") + if (STORM_ALLWARNINGS) + if (CLANG) + # Enable strictly every warning and then disable selected ones. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat -Wno-c++98-compat-pedantic") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reserved-id-macro") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-newline-eof") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-documentation") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-exit-time-destructors") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-covered-switch-default") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-padded") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-equal") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedef") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-variable-declarations") + endif () + else () + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs") + endif () +else() + set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer") +endif() ############################################################# ## -## Cotire +## Generator specific settings ## ############################################################# -message (STATUS "StoRM - Using Cotire: ${STORM_USE_COTIRE}") - -if (STORM_USE_COTIRE) - # Include Cotire for PCH Generation - set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/resources/cmake") - include(cotire) +if ("${CMAKE_GENERATOR}" STREQUAL "Xcode") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") +endif() - cotire(storm) - target_link_libraries(storm_unity ${Boost_LIBRARIES}) - #cotire(storm-functional-tests) - #cotire(storm-performance-tests) +# Display information about build configuration. +message(STATUS "Storm - Using compiler configuration ${STORM_COMPILER_ID} ${STORM_COMPILER_VERSION}.") +if (STORM_DEVELOPER) + message(STATUS "Storm - CXX Flags: ${CMAKE_CXX_FLAGS}") + message(STATUS "Storm - CXX Debug Flags: ${CMAKE_CXX_FLAGS_DEBUG}") + message(STATUS "Storm - CXX Release Flags: ${CMAKE_CXX_FLAGS_RELEASE}") + message(STATUS "Storm - Build type: ${CMAKE_BUILD_TYPE}") endif() +############################################################# +############################################################# +## +## Inclusion of required libraries +## +############################################################# +############################################################# + ############################################################# ## -## libc++abi +## Include the targets for non-system resources ## ############################################################# -# Link against libc++abi if requested. May be needed to build on Linux systems using clang. -if (LINK_LIBCXXABI) - message (STATUS "StoRM - Linking against libc++abi.") - target_link_libraries(storm "c++abi") -endif(LINK_LIBCXXABI) +# In 3rdparty, targets are being defined that can be used +# in the the system does not have a library +include(resources/3rdparty/CMakeLists.txt) ############################################################# ## @@ -288,16 +314,14 @@ endif(DOXYGEN_FOUND) ############################################################# ## -## CMake-generated Config File for StoRM +## CMake-generated Config File for Storm ## ############################################################# -# # Make a version file containing the current version from git. -# include(GetGitRevisionDescription) git_describe_checkout(STORM_GIT_VERSION_STRING) -message(STATUS "STORM_GIT_VERSION_STRING: ${STORM_GIT_VERSION_STRING}") +message(STATUS "Storm -- Git version string is ${STORM_GIT_VERSION_STRING}.") # Parse the git Tag into variables string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CPP_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}") string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_MINOR "${STORM_GIT_VERSION_STRING}") @@ -310,7 +334,7 @@ if ("${STORM_CPP_VERSION_APPENDIX}" MATCHES "^.*dirty.*$") else() set(STORM_CPP_VERSION_DIRTY 0) endif() -message(STATUS "StoRM - Version information: ${STORM_CPP_VERSION_MAJOR}.${STORM_CPP_VERSION_MINOR}.${STORM_CPP_VERSION_PATCH} (${STORM_CPP_VERSION_COMMITS_AHEAD} commits ahead of Tag) build from ${STORM_CPP_VERSION_HASH} (Dirty: ${STORM_CPP_VERSION_DIRTY})") +message(STATUS "Storm - Version is ${STORM_CPP_VERSION_MAJOR}.${STORM_CPP_VERSION_MINOR}.${STORM_CPP_VERSION_PATCH} (${STORM_CPP_VERSION_COMMITS_AHEAD} commits ahead of Tag) build from ${STORM_CPP_VERSION_HASH} (Dirty: ${STORM_CPP_VERSION_DIRTY}).") # Configure a header file to pass some of the CMake settings to the source code configure_file ( @@ -318,32 +342,30 @@ configure_file ( "${PROJECT_BINARY_DIR}/include/storm-config.h" ) -# Configure a header file to pass the storm version to the source code +# Configure a source file to pass the storm version to the source code configure_file ( "${PROJECT_SOURCE_DIR}/storm-version.cpp.in" - "${PROJECT_SOURCE_DIR}/src/utility/storm-version.cpp" + "${PROJECT_SOURCE_DIR}/src/storm/utility/storm-version.cpp" ) -set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/utility/storm-version.cpp") +set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/storm/utility/storm-version.cpp") # Add the binary dir include directory for storm-config.h include_directories("${PROJECT_BINARY_DIR}/include") +include(CTest) +# Compiles all tests +add_custom_target(tests) +# Compiles and runs all tests +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) +set(CMAKE_CTEST_COMMAND_VERBOSE ${CMAKE_CTEST_COMMAND} -V) +add_custom_target(check-verbose COMMAND ${CMAKE_CTEST_COMMAND_VERBOSE}) +add_dependencies(check tests) +add_dependencies(check-verbose tests) + +set(STORM_TARGETS "") add_subdirectory(src) -add_subdirectory(test) - - - -############################################################# -## -## memcheck targets -## -############################################################# -add_custom_target(memcheck valgrind --leak-check=full --show-reachable=yes ${PROJECT_BINARY_DIR}/storm -v --fix-deadlocks ${PROJECT_SOURCE_DIR}/examples/dtmc/crowds/crowds5_5.tra examples/dtmc/crowds/crowds5_5.lab DEPENDS storm) -add_custom_target(memcheck-functional-tests valgrind --leak-check=full --show-reachable=yes ${PROJECT_BINARY_DIR}/storm-functional-tests -v --fix-deadlocks DEPENDS storm-functional-tests) -add_custom_target(memcheck-performance-tests valgrind --leak-check=full --show-reachable=yes ${PROJECT_BINARY_DIR}/storm-performance-tests -v --fix-deadlocks DEPENDS storm-performance-tests) -set(CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams) -add_custom_target(style python resources/3rdparty/cpplint/cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp" `) +include(export) include(StormCPackConfig.cmake) diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..d7a7f5377 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,43 @@ +node { + def cmakeTool + stage('Preparation') { + // Get some code from a GitHub repository + checkout scm + + cmakeTool = tool name: 'InSearchPath', type: 'hudson.plugins.cmake.CmakeTool' + + sh "rm -rf build" + sh "mkdir -p build" + } + stage('Configure') { + dir("build") { + sh "${cmakeTool} .." + } + + } + + stage('Build') { + dir("build") { + sh "make storm" + } + + } + + stage('Build Tests') { + dir("build") { + sh "make -j 4 tests" + } + + } + + stage('Test') { + dir("build") + sh "make check" + } + + stage('Archive') { + archiveArtifacts artifacts: 'build/bin/*', onlyIfSuccessful: true + archiveArtifacts artifacts: 'build/lib/*', onlyIfSuccessful: true + archiveArtifacts artifacts: 'build/include/*', onlyIfSuccessful: true + } +} diff --git a/README b/README new file mode 100644 index 000000000..bef720bdf --- /dev/null +++ b/README @@ -0,0 +1,24 @@ +# Create build directory for storm +mkdir build + +# Go to build directory +cd build + +# Configure the project +cmake .. +# If you want an interactive configuration, try "ccmake ..". Then you can press "c" to initially configure the project, change your values and then press "g" to generate the Makefile + +# After generating the Makefile you can build the resources we need for the project +make resources + +# Now we build the main project for DFTs +make storm-dft-main + +# Last you can run an example +./src/storm-dft -dft ../examples/dft/and.dft -mttf + +# To get a list of all available arguments run +./src/storm-dft --help + +# Example for DFT to Petri net translation +./src/storm-dft -dft ../examples/dft/and.dft --gspn diff --git a/README.md b/README.md index 4a76de895..54db5bddb 100644 --- a/README.md +++ b/README.md @@ -1 +1,52 @@ +Storm +============================== + For more instructions, check out the documentation found in [Getting Started](doc/getting-started.md) + + +Benchmarks +---------------------------- + +Example input files for storm can be obtained from +https://github.com/moves-rwth/storm-examples. +Running make example-files automatically obtains these files. + +Further examples and benchmarks found in the following repositories: + +* **Prism files** (DTMC, MDP, CTMC): +http://www.prismmodelchecker.org/benchmarks/ +* **Jani files** (DTMC, MDP, CTMC, MA): +http://jani-spec.org/ +* **GSPN**s: +(private, contact: sebastian.junges@cs.rwth-aachen.de) +* **DFT**s: +https://github.com/moves-rwth/dft-examples +* **PGCL**: +(private, contact: sebastian.junges@cs.rwth-aachen.de) + + +Authors +----------------------------- +Storm has been developed at RWTH Aachen University. + +###### Principal developers +* Christian Dehnert +* Joost-Pieter Katoen +* Sebastian Junges +* Matthias Volk + +###### Developers (lexicographical order) +* Philipp Berger +* David Korzeniewski +* Tim Quatmann + +###### Contributors (lexicographical order) +* Dimitri Bohlender +* Harold Bruintjes +* Michael Deutschen +* Thomas Heinemann +* Thomas Henn +* Tom Janson +* Gereon Kremer +* Manuel Sascha Weiand +* Lukas Westhofen diff --git a/cuda/CMakeAlignmentCheck.cpp b/cuda/CMakeAlignmentCheck.cpp index 1dc9b470b..49c9a6a18 100644 --- a/cuda/CMakeAlignmentCheck.cpp +++ b/cuda/CMakeAlignmentCheck.cpp @@ -61,4 +61,4 @@ } return 0; - } \ No newline at end of file + } diff --git a/cuda/CMakeFloatAlignmentCheck.cpp b/cuda/CMakeFloatAlignmentCheck.cpp index 7b3b7a8b1..9313fe929 100644 --- a/cuda/CMakeFloatAlignmentCheck.cpp +++ b/cuda/CMakeFloatAlignmentCheck.cpp @@ -28,4 +28,4 @@ int main(int argc, char* argv[]) { } return result; - } \ No newline at end of file + } diff --git a/doc/build.md b/doc/build.md index 03c0ff3dc..725794034 100644 --- a/doc/build.md +++ b/doc/build.md @@ -2,7 +2,7 @@ ## Requirements -CMake >= 2.8.11 +CMake >= 3.2 CMake is required as it is used to generate the Makefiles or Projects/Solutions required to build StoRM. ### Compiler: @@ -17,15 +17,17 @@ CMake >= 2.8.11 - GCC versions 4.9.1 and older. Prerequisites: - Boost >= 1.60 + Boost >= 1.61 Build using the Boost Build system, for x64 use "bjam address-model=64" or "bjam.exe address-model=64 --build-type=complete" ## Instructions ### General - -> mkdir build +```bash +mkdir build +cd build +``` It is recommended to make an out-of-source build, meaning that the folder in which CMake generates its Cache, Makefiles and output files should not be the Project Root nor its Source Directory. A typical build layout is to create a folder "build" in the project root alongside the CMakeLists.txt file, change into this folder and execute "cmake .." as this will leave all source files untouched diff --git a/examples/benchmarkRegions.sh b/examples/benchmarkRegions.sh deleted file mode 100755 index 6006f0bbe..000000000 --- a/examples/benchmarkRegions.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -if [ "$#" != 1 ]; -then - echo "Wrong number of arguments! Provide a filename for the results!" -elif [ -a $1 ]; then - echo "File for results already exists!" -else - - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -executable=$DIR/../build/src/storm - -timeout="timeout 3600" - -declare -a modeltypes=("pdtmc" "pmdp") - -for modeltype in "${modeltypes[@]}" -do -if [ "$modeltype" == "pdtmc" ]; -then - declare -a models=("crowds" "nand" "brp_rewards2" "brp_rewards4" "brp") - dobisim="-bisim" -else - declare -a models=("brp" "coin2" "coin4" "zeroconf" "reporter2" "reporter4") - dobisim="" -fi - for model in "${models[@]}" - do - modelfolder="$DIR/$modeltype/$model" - suffix="-" - while read instance; - do - suffix="1$suffix" - echo "Working on $modelfolder/$instance" - echo "___WORKING ON $modeltype: $instance""____________" >>$1$suffix - echo "_________________________________________________________________________________" >> $1$suffix - $timeout "$executable" -s $modelfolder/$instance $dobisim --prop $modelfolder/$model.prctl --parametric --parametricRegion --region:regionfile $modelfolder/$model"_regions.txt" >> $1$suffix & - done < "$modelfolder/models" - wait - # write logs into result file - suffix="-" - while read instance; - do - suffix="1$suffix" - cat $1$suffix >> $1 - rm $1$suffix - done < "$modelfolder/models" - done -done -fi diff --git a/examples/benchmarkRegionsRefinement.sh b/examples/benchmarkRegionsRefinement.sh deleted file mode 100755 index b6861050c..000000000 --- a/examples/benchmarkRegionsRefinement.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -if [ "$#" != 1 ]; -then - echo "Wrong number of arguments! Provide a filename for the results!" -elif [ -a $1 ]; then - echo "File for results already exists!" -else - - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -executable=$DIR/../build/src/storm - -timeout="timeout 3600" - -declare -a modeltypes=("pdtmc" "pmdp") - -for modeltype in "${modeltypes[@]}" -do -if [ "$modeltype" == "pdtmc" ]; -then - declare -a models=("crowds" "nand" "brp_rewards2" "brp_rewards4" "brp") - dobisim="-bisim" -else - declare -a models=("brp" "coin2" "coin4" "zeroconf" "reporter2" "reporter4") - dobisim="" -fi - for model in "${models[@]}" - do - modelfolder="$DIR/$modeltype/$model" - suffix="-" - while read instance; - do - suffix="1$suffix" - echo "Working on $modelfolder/$instance" - echo "___WORKING ON $modeltype: $instance""____________" >>$1$suffix - echo "_________________________________________________________________________________" >> $1$suffix - $timeout "$executable" -s $modelfolder/$instance $dobisim --prop $modelfolder/$model.prctl --parametric --parametricRegion --region:regionfile $modelfolder/$model"_space.txt" --region:refinement 0.05 --region:samplemode off >> "$1$suffix" & - done < "$modelfolder/models" - wait - # write logs into result file - suffix="-" - while read instance; - do - suffix="1$suffix" - cat $1$suffix >> $1 - rm $1$suffix - done < "$modelfolder/models" - done -done -fi diff --git a/examples/ctmc/cluster/cluster.sm b/examples/ctmc/cluster/cluster.sm deleted file mode 100644 index 2bad30ef1..000000000 --- a/examples/ctmc/cluster/cluster.sm +++ /dev/null @@ -1,116 +0,0 @@ -// Workstation cluster [HHK00] -// dxp/gxn 11/01/00 - -ctmc - -const int N; // Number of workstations in each cluster -const int left_mx = N; // Number of work stations in left cluster -const int right_mx = N; // Number of work stations in right cluster - -// Failure rates -const double ws_fail = 1/500; // Single workstation: average time to fail = 500 hrs -const double switch_fail = 1/4000; // Switch: average time to fail = 4000 hrs -const double line_fail = 1/5000; // Backbone: average time to fail = 5000 hrs - -// Left cluster -module Left - - left_n : [0..left_mx] init left_mx; // Number of workstations operational - left : bool; // Being repaired? - - [startLeft] !left & (left_n 1 : (left'=true); - [repairLeft] left & (left_n 1 : (left'=false) & (left_n'=left_n+1); - [] (left_n>0) -> ws_fail*left_n : (left_n'=left_n-1); - -endmodule - -// Right cluster -module Right = Left[left_n=right_n, - left=right, - left_mx=right_mx, - startLeft=startRight, - repairLeft=repairRight ] -endmodule - -// Repair unit -module Repairman - - r : bool; // Repairing? - - [startLeft] !r -> 10 : (r'=true); // Inspect Left - [startRight] !r -> 10 : (r'=true); // Inspect Right - [startToLeft] !r -> 10 : (r'=true); // Inspect ToLeft - [startToRight] !r -> 10 : (r'=true); // Inspect ToRight - [startLine] !r -> 10 : (r'=true); // Inspect Line - - [repairLeft] r -> 2 : (r'=false); // Repair Left - [repairRight] r -> 2 : (r'=false); // Repair Right - [repairToLeft] r -> 0.25 : (r'=false); // Repair ToLeft - [repairToRight] r -> 0.25 : (r'=false); // Repair ToRight - [repairLine] r -> 0.125 : (r'=false); // Repair Line - -endmodule - -// Line/backbone -module Line - - line : bool; // Being repaired? - line_n : bool init true; // Working? - - [startLine] !line & !line_n -> 1 : (line'=true); - [repairLine] line & !line_n -> 1 : (line'=false) & (line_n'=true); - [] line_n -> line_fail : (line_n'=false); - -endmodule - -// Left switch -module ToLeft = Line[line=toleft, - line_n=toleft_n, - line_fail=switch_fail, - startLine=startToLeft, - repairLine=repairToLeft ] -endmodule - -// Right switch -module ToRight = Line[line=toright, - line_n=toright_n, - line_fail=switch_fail, - startLine=startToRight, - repairLine=repairToRight ] -endmodule - -// Formulas + labels - -// Minimum QoS requires 3/4 connected workstations operational -const int k = floor(0.75*N); -// left_operational_i : left_n>=i & toleft_n -// right_operational_i : right_n>=i & toright_n -// operational_i : (left_n+right_n)>=i & toleft_n & line_n & toright_n -// minimum_k : left_operational_k | right_operational_k | operational_k -formula minimum = (left_n>=k & toleft_n) | - (right_n>=k & toright_n) | - ((left_n+right_n)>=k & toleft_n & line_n & toright_n); -label "minimum" = (left_n>=k & toleft_n) | (right_n>=k & toright_n) | ((left_n+right_n)>=k & toleft_n & line_n & toright_n); -// premium = minimum_N -label "premium" = (left_n>=left_mx & toleft_n) | (right_n>=right_mx & toright_n) | ((left_n+right_n)>=left_mx & toleft_n & line_n & toright_n); - -// Reward structures - -// Percentage of operational workstations stations -rewards "percent_op" - true : 100*(left_n+right_n)/(2*N); -endrewards - -// Time that the system is not delivering at least minimum QoS -rewards "time_not_min" - !minimum : 1; -endrewards - -// Number of repairs -rewards "num_repairs" - [repairLeft] true : 1; - [repairRight] true : 1; - [repairToLeft] true : 1; - [repairToRight] true : 1; - [repairLine] true : 1; -endrewards \ No newline at end of file diff --git a/examples/ctmc/embedded/embedded.sm b/examples/ctmc/embedded/embedded.sm deleted file mode 100644 index a10540597..000000000 --- a/examples/ctmc/embedded/embedded.sm +++ /dev/null @@ -1,151 +0,0 @@ -ctmc - -// constants -const int MAX_COUNT; -const int MIN_SENSORS = 2; -const int MIN_ACTUATORS = 1; - -// rates -const double lambda_p = 1/(365*24*60*60); // 1 year -const double lambda_s = 1/(30*24*60*60); // 1 month -const double lambda_a = 1/(2*30*24*60*60); // 2 months -const double tau = 1/60; // 1 min -const double delta_f = 1/(24*60*60); // 1 day -const double delta_r = 1/30; // 30 secs - -// sensors -module sensors - - s : [0..3] init 3; // number of sensors working - - [] s>1 -> s*lambda_s : (s'=s-1); // failure of a single sensor - -endmodule - -// input processor -// (takes data from sensors and passes onto main processor) -module proci - - i : [0..2] init 2; // 2=ok, 1=transient fault, 0=failed - - [] i>0 & s>=MIN_SENSORS -> lambda_p : (i'=0); // failure of processor - [] i=2 & s>=MIN_SENSORS -> delta_f : (i'=1); // transient fault - [input_reboot] i=1 & s>=MIN_SENSORS -> delta_r : (i'=2); // reboot after transient fault - -endmodule - -// actuators -module actuators - - a : [0..2] init 2; // number of actuators working - - [] a>0 -> a*lambda_a : (a'=a-1); // failure of a single actuator - -endmodule - -// output processor -// (receives instructions from main processor and passes onto actuators) -module proco = proci [ i=o, s=a, input_reboot=output_reboot, MIN_SENSORS=MIN_ACTUATORS ] endmodule - -// main processor -// (takes data from proci, processes it, and passes instructions to proco) -module procm - - m : [0..1] init 1; // 1=ok, 0=failed - count : [0..MAX_COUNT+1] init 0; // number of consecutive skipped cycles - - // failure of processor - [] m=1 -> lambda_p : (m'=0); - // processing completed before timer expires - reset skipped cycle counter - [timeout] comp -> tau : (count'=0); - // processing not completed before timer expires - increment skipped cycle counter - [timeout] !comp -> tau : (count'=min(count+1, MAX_COUNT+1)); - -endmodule - -// connecting bus -module bus - - // flags - // main processor has processed data from input processor - // and sent corresponding instructions to output processor (since last timeout) - comp : bool init true; - // input processor has data ready to send - reqi : bool init true; - // output processor has instructions ready to be processed - reqo : bool init false; - - // input processor reboots - [input_reboot] true -> 1 : - // performs a computation if has already done so or - // it is up and ouput clear (i.e. nothing waiting) - (comp'=(comp | (m=1 & !reqo))) - // up therefore something to process - & (reqi'=true) - // something to process if not functioning and either - // there is something already pending - // or the main processor sends a request - & (reqo'=!(o=2 & a>=1) & (reqo | m=1)); - - // output processor reboots - [output_reboot] true -> 1 : - // performs a computation if it has already or - // something waiting and is up - // (can be processes as the output has come up and cleared pending requests) - (comp'=(comp | (reqi & m=1))) - // something to process it they are up or - // there was already something and the main processor acts - // (output now up must be due to main processor being down) - & (reqi'=(i=2 & s>=2) | (reqi & m=0)) - // output and actuators up therefore nothing can be pending - & (reqo'=false); - - // main processor times out - [timeout] true -> 1 : - // performs a computation if it is up something was pending - // and nothing is waiting for the output - (comp'=(reqi & !reqo & m=1)) - // something to process if up or - // already something and main process cannot act - // (down or outputs pending) - & (reqi'=(i=2 & s>=2) | (reqi & (reqo | m=0))) - // something to process if they are not functioning and - // either something is already pending - // or the main processor acts - & (reqo'=!(o=2 & a>=1) & (reqo | (reqi & m=1))); - -endmodule - - -// the system is down -formula down = (i=2&s0) & (M1>0) & (P1M1<3) -> P1*min(1,np/r) : (P1'=P1-1) & (P1M1'=P1M1+1) & (M1'=M1-1); - [t1] (P1>0) & (M1=0) & (P1wM1 P1*min(1,np/r) : (P1'=P1-1) & (P1wM1'=P1wM1+1); - - [] (P1M1>0) & (P1wM1=0) & (M1<3) & (P1s 0.2*P1M1 : (P1M1'=P1M1-1) & (M1'=M1+1) & (P1s'=P1s+1); - [] (P1M1>0) & (P1wM1>0) & (P1s 0.2*P1M1 : (P1wM1'=P1wM1-1) & (P1s'=P1s+1); - - [] (P1M1>0) & (P2wP1=0) & (P1wM1=0) & (M1<3) & (P1wP2 0.05*P1M1 : (P1M1'=P1M1-1) & (M1'=M1+1) & (P1wP2'=P1wP2+1); - [] (P1M1>0) & (P2wP1=0) & (P1wM1>0) & (P1wP2 0.05*P1M1 : (P1wM1'=P1wM1-1) & (P1wP2'=P1wP2+1); - - [p1p2] (P1M1>0) & (P2wP1>0) & (P1wM1=0) & (M1<3) -> 0.05*P1M1 : (P1M1'=P1M1-1) & (M1'=M1+1); - [p1p2] (P1M1>0) & (P2wP1>0) & (P1wM1>0) -> 0.05*P1M1 : (P1wM1'=P1wM1-1); - - [p1p2] (P1wP2>0) -> 1: (P1wP2'=P1wP2-1); - [] (P1s>0) & (P1+P1s<=n) -> 1/60 : (P1s'=0) & (P1'=P1+P1s); - [fp12] (P1+P12s<=n) -> 1: (P1'=P1+P12s); - -endmodule - -module machine2 - - P2 : [0..n] init n; - P2wM2 : [0..n]; - P2M2 : [0..1]; - P2s : [0..n]; - P2wP1 : [0..n]; - M2 : [0..1] init 1; - - [t2] (P2>0) & (M2>0) & (P2M2<1) -> P2*min(1,np/r) : (P2'=P2-1) & (P2M2'=P2M2+1) & (M2'=M2-1); - [t2] (P2>0) & (M2=0) & (P2wM2 P2*min(1,np/r) : (P2'=P2-1) & (P2wM2'=P2wM2+1); - - [] (P2M2>0) & (P2wM2=0) & (M2<1) & (P2s 0.1 : (P2M2'=P2M2-1) & (M2'=M2+1) & (P2s'=P2s+1); - [] (P2M2>0) & (P2wM2>0) & (P2s 0.1 : (P2wM2'=P2wM2-1) & (P2s'=P2s+1); - - [] (P2M2>0) & (P1wP2=0) & (P2wM2=0) & (M2<1) & (P2wP1 1/15: (P2M2'=P2M2-1) & (M2'=M2+1) & (P2wP1'=P2wP1+1); - [] (P2M2>0) & (P1wP2=0) & (P2wM2>0) & (P2wP1 1/15: (P2wM2'=P2wM2-1) & (P2wP1'=P2wP1+1); - - [p1p2] (P2M2>0) & (P1wP2>0) & (P2wM2=0) & (M2<1) -> 1/15: (P2M2'=P2M2-1) & (M2'=M2+1); - [p1p2] (P2M2>0) & (P1wP2>0) & (P2wM2>0) -> 1/15: (P2wM2'=P2wM2-1); - - [p1p2] (P2wP1>0) -> 1 : (P2wP1'=P2wP1-1); - [] (P2s>0) & (P2+P2s<=n) -> 1/60 : (P2s'=0) & (P2'=P2+P2s); - [fp12] (P2+P12s<=n) -> 1 : (P2'=P2+P12s); - [p2p3] (M2>0) -> 1 : (M2'=M2); - -endmodule - -module machine3 - - P3 : [0..n] init n; - P3M2 : [0..n]; - P3s : [0..n]; - - [t3] (P3>0) & (P3M2 P3*min(1,np/r) : (P3'=P3-1) & (P3M2'=P3M2+1); - - [p2p3] (P3M2>0) & (P3s 1/2 : (P3M2'=P3M2-1) & (P3s'=P3s+1); - [] (P3s>0) & (P3+P3s<=n) -> 1/60 : (P3s'=0) & (P3'=P3+P3s); - -endmodule - -module machine12 - - P12 : [0..n]; - P12wM3 : [0..n]; - P12M3 : [0..2]; - P12s : [0..n]; - M3 : [0..2] init 2; - - [p1p2] (P12 1: (P12'=P12+1); - - [t12] (P12>0) & (M3>0) & (P12M3<2) -> P12*min(1,np/r) : (P12'=P12-1) & (P12M3'=P12M3+1) & (M3'=M3-1); - [t12] (P12>0) & (M3=0) & (P12wM3 P12*min(1,np/r) : (P12'=P12-1) & (P12wM3'=P12wM3+1); - - [] (P12M3>0) & (P12wM3=0) & (P12s P12M3 : (P12M3'=P12M3-1) & (P12s'=P12s+1) & (M3'=M3+1); - [] (P12M3>0) & (P12wM3>0) & (P12s P12M3 : (P12wM3'=P12wM3-1) & (P12s'=P12s+1); - - [fp12] (P12s>0) -> 1/60 : (P12s'=0); - -endmodule - -// reward structures - -// throughput of machine1 -rewards "throughput_m1" - [t1] true : 1; -endrewards -// throughput of machine2 -rewards "throughput_m2" - [t2] true : 1; -endrewards -// throughput of machine3 -rewards "throughput_m3" - [t3] true : 1; -endrewards -// throughput of machine12 -rewards "throughput_m12" - [t12] true : 1; -endrewards -// productivity of the system -rewards "productivity" - [t1] true : 400; - [t2] true : 600; - [t3] true : 100; - [t12] true : 1100; -endrewards diff --git a/examples/ctmc/polling/polling2.sm b/examples/ctmc/polling/polling2.sm deleted file mode 100644 index e36a8fee0..000000000 --- a/examples/ctmc/polling/polling2.sm +++ /dev/null @@ -1,51 +0,0 @@ -// polling example [IT90] -// gxn/dxp 26/01/00 - -ctmc - -const int N = 2; - -const double mu = 1; -const double gamma = 200; -const double lambda = mu/N; - -module server - - s : [1..2]; // station - a : [0..1]; // action: 0=polling, 1=serving - - [loop1a] (s=1)&(a=0) -> gamma : (s'=s+1); - [loop1b] (s=1)&(a=0) -> gamma : (a'=1); - [serve1] (s=1)&(a=1) -> mu : (s'=s+1)&(a'=0); - - [loop2a] (s=2)&(a=0) -> gamma : (s'=1); - [loop2b] (s=2)&(a=0) -> gamma : (a'=1); - [serve2] (s=2)&(a=1) -> mu : (s'=1)&(a'=0); - -endmodule - -module station1 - - s1 : [0..1]; // state of station: 0=empty, 1=full - - [loop1a] (s1=0) -> 1 : (s1'=0); - [] (s1=0) -> lambda : (s1'=1); - [loop1b] (s1=1) -> 1 : (s1'=1); - [serve1] (s1=1) -> 1 : (s1'=0); - -endmodule - -// construct further stations through renaming - -module station2 = station1 [ s1=s2, loop1a=loop2a, loop1b=loop2b, serve1=serve2 ] endmodule -// (cumulative) rewards - -// expected time station 1 is waiting to be served -rewards "waiting" - s1=1 & !(s=1 & a=1) : 1; -endrewards - -// expected number of times station 1 is served -rewards "served" - [serve1] true : 1; -endrewards \ No newline at end of file diff --git a/examples/ctmc/polling/polling5.sm b/examples/ctmc/polling/polling5.sm deleted file mode 100644 index 931569ad5..000000000 --- a/examples/ctmc/polling/polling5.sm +++ /dev/null @@ -1,66 +0,0 @@ -// polling example [IT90] -// gxn/dxp 26/01/00 - -ctmc - -const int N = 5; - -const double mu = 1; -const double gamma = 200; -const double lambda = mu/N; - -module server - - s : [1..5]; // station - a : [0..1]; // action: 0=polling, 1=serving - - [loop1a] (s=1)&(a=0) -> gamma : (s'=s+1); - [loop1b] (s=1)&(a=0) -> gamma : (a'=1); - [serve1] (s=1)&(a=1) -> mu : (s'=s+1)&(a'=0); - - [loop2a] (s=2)&(a=0) -> gamma : (s'=s+1); - [loop2b] (s=2)&(a=0) -> gamma : (a'=1); - [serve2] (s=2)&(a=1) -> mu : (s'=s+1)&(a'=0); - - [loop3a] (s=3)&(a=0) -> gamma : (s'=s+1); - [loop3b] (s=3)&(a=0) -> gamma : (a'=1); - [serve3] (s=3)&(a=1) -> mu : (s'=s+1)&(a'=0); - - [loop4a] (s=4)&(a=0) -> gamma : (s'=s+1); - [loop4b] (s=4)&(a=0) -> gamma : (a'=1); - [serve4] (s=4)&(a=1) -> mu : (s'=s+1)&(a'=0); - - [loop5a] (s=5)&(a=0) -> gamma : (s'=1); - [loop5b] (s=5)&(a=0) -> gamma : (a'=1); - [serve5] (s=5)&(a=1) -> mu : (s'=1)&(a'=0); - -endmodule - -module station1 - - s1 : [0..1]; // state of station: 0=empty, 1=full - - [loop1a] (s1=0) -> 1 : (s1'=0); - [] (s1=0) -> lambda : (s1'=1); - [loop1b] (s1=1) -> 1 : (s1'=1); - [serve1] (s1=1) -> 1 : (s1'=0); - -endmodule - -// construct further stations through renaming - -module station2 = station1 [ s1=s2, loop1a=loop2a, loop1b=loop2b, serve1=serve2 ] endmodule -module station3 = station1 [ s1=s3, loop1a=loop3a, loop1b=loop3b, serve1=serve3 ] endmodule -module station4 = station1 [ s1=s4, loop1a=loop4a, loop1b=loop4b, serve1=serve4 ] endmodule -module station5 = station1 [ s1=s5, loop1a=loop5a, loop1b=loop5b, serve1=serve5 ] endmodule -// (cumulative) rewards - -// expected time station 1 is waiting to be served -rewards "waiting" - s1=1 & !(s=1 & a=1) : 1; -endrewards - -// expected number of times station 1 is served -rewards "served" - [serve1] true : 1; -endrewards \ No newline at end of file diff --git a/examples/ctmc/tandem/tandem.sm b/examples/ctmc/tandem/tandem.sm deleted file mode 100644 index c35246e1a..000000000 --- a/examples/ctmc/tandem/tandem.sm +++ /dev/null @@ -1,42 +0,0 @@ -// tandem queueing network [HKMKS99] -// gxn/dxp 25/01/00 - -ctmc - -const int c; // queue capacity - -const double lambda = 4*c; -const double mu1a = 0.1*2; -const double mu1b = 0.9*2; -const double mu2 = 2; -const double kappa = 4; - -module serverC - - sc : [0..c]; - ph : [1..2]; - - [] (sc lambda: (sc'=sc+1); - [route] (sc>0) & (ph=1) -> mu1b: (sc'=sc-1); - [] (sc>0) & (ph=1) -> mu1a: (ph'=2); - [route] (sc>0) & (ph=2) -> mu2: (ph'=1) & (sc'=sc-1); - -endmodule - -module serverM - - sm : [0..c]; - - [route] (sm 1: (sm'=sm+1); - [] (sm>0) -> kappa: (sm'=sm-1); - -endmodule - -// reward - number of customers in network -rewards "customers" - true : sc + sm; -endrewards - -label "network_full" = sc=c&sm=c&ph=2; -label "first_queue_full" = sc=c; -label "second_queue_full" = sm=c; diff --git a/examples/ctmc/tiny/tiny.sm b/examples/ctmc/tiny/tiny.sm deleted file mode 100644 index df193c827..000000000 --- a/examples/ctmc/tiny/tiny.sm +++ /dev/null @@ -1,11 +0,0 @@ -ctmc - -module one - s : [0 .. 3] init 0; - - [] s<3 -> 3/2 : (s'=s+1); - [] s>0 -> 3 : (s'=s-1); -endmodule - -label "empty" = s=0; -label "full" = s=3; diff --git a/examples/dft/and.dft b/examples/dft/and.dft deleted file mode 100644 index 2b06cbe95..000000000 --- a/examples/dft/and.dft +++ /dev/null @@ -1,4 +0,0 @@ -toplevel "A"; -"A" and "B" "C"; -"B" lambda=0.5 dorm=0.3; -"C" lambda=0.5 dorm=0.3; diff --git a/examples/dft/and_param.dft b/examples/dft/and_param.dft deleted file mode 100644 index 8c95a0f2a..000000000 --- a/examples/dft/and_param.dft +++ /dev/null @@ -1,5 +0,0 @@ -param x; -toplevel "A"; -"A" and "B" "C"; -"B" lambda=0.5 dorm=0.3; -"C" lambda=x dorm=0.3; diff --git a/examples/dft/be_nonfail.dft b/examples/dft/be_nonfail.dft deleted file mode 100644 index d53dca551..000000000 --- a/examples/dft/be_nonfail.dft +++ /dev/null @@ -1,4 +0,0 @@ -toplevel "A"; -"A" and "B" "C"; -"B" lambda=0 dorm=0.3; -"C" lambda=0.5 dorm=0.3; diff --git a/examples/dft/cardiac.dft b/examples/dft/cardiac.dft deleted file mode 100644 index 505f002b1..000000000 --- a/examples/dft/cardiac.dft +++ /dev/null @@ -1,21 +0,0 @@ -toplevel "SYSTEM"; -"SYSTEM" or "FDEP" "CPU" "MOTOR" "PUMPS"; -"FDEP" fdep "TRIGGER" "P" "B"; -"TRIGGER" or "CS" "SS"; -"CPU" wsp "P" "B"; -"MOTOR" or "SWITCH" "MOTORS"; -"SWITCH" pand "MS" "MA"; -"MOTORS" csp "MA" "MB"; -"PUMPS" and "PUMP1" "PUMP2"; -"PUMP1" csp "PA" "PS"; -"PUMP2" csp "PB" "PS"; -"P" lambda=5.0e-5 dorm=0; -"B" lambda=5.0e-5 dorm=0.5; -"CS" lambda=2.0e-5 dorm=0; -"SS" lambda=2.0e-5 dorm=0; -"MS" lambda=1.0e-6 dorm=0; -"MA" lambda=1.0e-4 dorm=0; -"MB" lambda=1.0e-4 dorm=0; -"PA" lambda=1.0e-4 dorm=0; -"PB" lambda=1.0e-4 dorm=0; -"PS" lambda=1.0e-4 dorm=0; diff --git a/examples/dft/cas.dft b/examples/dft/cas.dft deleted file mode 100644 index 812a3f30a..000000000 --- a/examples/dft/cas.dft +++ /dev/null @@ -1,24 +0,0 @@ -toplevel "System"; -"System" or "CPUfdep" "CPUunit" "Motorunit" "Pumpunit"; - -"CPUfdep" fdep "trigger" "P" "B"; -"trigger" or "CS" "SS"; -"CS" lambda=0.2 dorm=0; -"SS" lambda=0.2 dorm=0; -"CPUunit" wsp "P" "B"; -"P" lambda=0.5 dorm=0; -"B" lambda=0.5 dorm=0.5; - -"Motorunit" or "MP" "Motors"; -"MP" pand "MS" "MA"; -"Motors" csp "MA" "MB"; -"MS" lambda=0.01 dorm=0; -"MA" lambda=1 dorm=0; -"MB" lambda=1 dorm=0; - -"Pumpunit" and "PumpA" "PumpB"; -"PumpA" csp "PA" "PS"; -"PumpB" csp "PB" "PS"; -"PA" lambda=1 dorm=0; -"PB" lambda=1 dorm=0; -"PS" lambda=1 dorm=0; diff --git a/examples/dft/cm2.dft b/examples/dft/cm2.dft deleted file mode 100644 index 89a1a8eba..000000000 --- a/examples/dft/cm2.dft +++ /dev/null @@ -1,22 +0,0 @@ -toplevel "System"; -"System" or "BUS" "CM"; -"CM" and "CM1" "CM2"; -"CM1" or "DISK1" "POWER1" "MEMORY1"; -"CM2" or "DISK2" "POWER2" "MEMORY2"; -"DISK1" wsp "D11" "D12"; -"DISK2" wsp "D21" "D22"; -"POWER1" or "P1" "PS"; -"POWER2" or "P2" "PS"; -"MEMORY1" wsp "M1" "M3"; -"MEMORY2" wsp "M2" "M3"; -"BUS" lambda=0.0002 dorm=0; -"P1" lambda=0.05 dorm=0; -"P2" lambda=0.05 dorm=0; -"PS" lambda=0.6 dorm=0; -"D11" lambda=8.0 dorm=0; -"D12" lambda=8.0 dorm=0.5; -"D21" lambda=8.0 dorm=0; -"D22" lambda=8.0 dorm=0.5; -"M1" lambda=0.003 dorm=0; -"M2" lambda=0.003 dorm=0; -"M3" lambda=0.003 dorm=0.5; diff --git a/examples/dft/cm4.dft b/examples/dft/cm4.dft deleted file mode 100644 index deb8a7fb7..000000000 --- a/examples/dft/cm4.dft +++ /dev/null @@ -1,41 +0,0 @@ -toplevel "System"; -"System" or "BUS" "CM"; -"CM" and "CM1" "CM2" "CM3" "CM4"; -"CM1" or "DISK1" "POWER1" "MEMORY1"; -"CM2" or "DISK2" "POWER2" "MEMORY2"; -"CM3" or "DISK3" "POWER3" "MEMORY3"; -"CM4" or "DISK4" "POWER4" "MEMORY4"; -"DISK1" wsp "D11" "D12"; -"DISK2" wsp "D21" "D22"; -"DISK3" wsp "D31" "D32"; -"DISK4" wsp "D41" "D42"; -"POWER1" or "P1" "PS"; -"POWER2" or "P2" "PS"; -"POWER3" or "P3" "PS2"; -"POWER4" or "P4" "PS2"; -"MEMORY1" wsp "M1" "M3" "M4"; -"MEMORY2" wsp "M2" "M3" "M4"; -"MEMORY3" wsp "M31" "M3"; -"MEMORY4" wsp "M41" "M4"; -"BUS" lambda=0.0002 dorm=0; -"P1" lambda=0.05 dorm=0; -"P2" lambda=0.05 dorm=0; -"P3" lambda=0.05 dorm=0; -"P4" lambda=0.05 dorm=0; -"PS" lambda=0.6 dorm=0; -"PS2" lambda=0.6 dorm=0; -"D11" lambda=8.0 dorm=0; -"D12" lambda=8.0 dorm=0.5; -"D21" lambda=8.0 dorm=0; -"D22" lambda=8.0 dorm=0.5; -"D31" lambda=8.0 dorm=0; -"D32" lambda=8.0 dorm=0.5; -"D41" lambda=8.0 dorm=0; -"D42" lambda=8.0 dorm=0.5; -"M1" lambda=0.003 dorm=0; -"M2" lambda=0.003 dorm=0; -"M31" lambda=0.003 dorm=0; -"M41" lambda=0.003 dorm=0; -"M3" lambda=0.003 dorm=0.5; -"M4" lambda=0.003 dorm=0.5; - diff --git a/examples/dft/cps.dft b/examples/dft/cps.dft deleted file mode 100644 index 9ee386740..000000000 --- a/examples/dft/cps.dft +++ /dev/null @@ -1,26 +0,0 @@ -toplevel "System"; - -"System" pand "A" "B"; - -"A" and "AA" "AB" "AC" "AD"; - -"B" pand "C" "D"; - -"C" and "CA" "CB" "CC" "CD"; - -"D" and "DA" "DB" "DC" "DD"; - -"AA" lambda=1 dorm=0; -"AB" lambda=1 dorm=0; -"AC" lambda=1 dorm=0; -"AD" lambda=1 dorm=0; - -"CA" lambda=1 dorm=0; -"CB" lambda=1 dorm=0; -"CC" lambda=1 dorm=0; -"CD" lambda=1 dorm=0; - -"DA" lambda=1 dorm=0; -"DB" lambda=1 dorm=0; -"DC" lambda=1 dorm=0; -"DD" lambda=1 dorm=0; diff --git a/examples/dft/deathegg.dft b/examples/dft/deathegg.dft deleted file mode 100644 index 618684c4e..000000000 --- a/examples/dft/deathegg.dft +++ /dev/null @@ -1,16 +0,0 @@ -toplevel "DeathEgg"; -"DeathEgg" or "DeathEggProxy" "DeathEggServer" "CampusPowerDependency" "ProxyPowerDependency"; -"DeathEggServer" or "CampusNET" "DES_Disks"; -"DES_Disks" and "DES_Disks_RAID1" "DES_Disks_RAID2"; -"DES_Disks_RAID1" and "DES_Disk_1" "DES_Disk_2"; -"DES_Disks_RAID2" and "DES_Disk_3" "DES_Disk_4"; -"DeathEggProxy" lambda=0.01 dorm=0; -"DES_Disk_1" lambda=0.01 dorm=0; -"DES_Disk_2" lambda=0.01 dorm=0; -"DES_Disk_3" lambda=0.01 dorm=0; -"DES_Disk_4" lambda=0.01 dorm=0; -"CampusPowerDependency" fdep "CampusPower" "DeathEggServer"; -"ProxyPowerDependency" fdep "ProxyPower" "DeathEggProxy"; -"CampusPower" lambda=0.01 dorm=0; -"CampusNET" lambda=0.01 dorm=0; -"ProxyPower" lambda=0.01 dorm=0; \ No newline at end of file diff --git a/examples/dft/fdep.dft b/examples/dft/fdep.dft deleted file mode 100644 index e597c46ce..000000000 --- a/examples/dft/fdep.dft +++ /dev/null @@ -1,8 +0,0 @@ -toplevel "System"; -"System" or "Power" "Machine"; -"Power" fdep "B_Power" "P" "B"; -"Machine" or "P" "B"; - -"B_Power" lambda=0.5 dorm=0; -"P" lambda=0.5 dorm=0; -"B" lambda=0.5 dorm=0.5; diff --git a/examples/dft/fdep2.dft b/examples/dft/fdep2.dft deleted file mode 100644 index a444ed4be..000000000 --- a/examples/dft/fdep2.dft +++ /dev/null @@ -1,5 +0,0 @@ -toplevel "A"; -"A" and "B" "C"; -"F" fdep "B" "C"; -"B" lambda=0.5 dorm=0; -"C" lambda=0.5 dorm=0; diff --git a/examples/dft/fdep3.dft b/examples/dft/fdep3.dft deleted file mode 100644 index 3815c9973..000000000 --- a/examples/dft/fdep3.dft +++ /dev/null @@ -1,5 +0,0 @@ -toplevel "A"; -"A" and "B" "C" "F"; -"F" fdep "B" "C"; -"B" lambda=0.4 dorm=0; -"C" lambda=0.8 dorm=0; diff --git a/examples/dft/ftpp_complex.dft b/examples/dft/ftpp_complex.dft deleted file mode 100644 index 1b836ee6b..000000000 --- a/examples/dft/ftpp_complex.dft +++ /dev/null @@ -1,129 +0,0 @@ -toplevel "System"; -"System" or "triadA" "triadB" "triadC" "triadD" "fA" "fB" "fC" "fD"; - -"triadA" 2of3 "aA" "bA" "cA"; -"aA" csp "TAA" "TAS"; -"bA" csp "TAB" "TAS"; -"cA" csp "TAC" "TAS"; - -"triadB" 2of3 "aB" "bB" "cB"; -"aB" csp "TBA" "TBS"; -"bB" csp "TBB" "TBS"; -"cB" csp "TBC" "TBS"; - -"triadC" 2of3 "aC" "bC" "cC"; -"aC" csp "TCA" "TCS"; -"bC" csp "TCB" "TCS"; -"cC" csp "TCC" "TCS"; - -"triadD" 2of3 "aD" "bD" "cD"; -"aD" csp "TDA" "TDS"; -"bD" csp "TDB" "TDS"; -"cD" csp "TDC" "TDS"; - -"fA" fdep "NEA" "TAA" "TBA" "TCA" "TDA"; -"fB" fdep "NEB" "TAB" "TBB" "TCB" "TDB"; -"fC" fdep "NEC" "TAC" "TBC" "TCC" "TDC"; -"fD" fdep "NED" "TAS" "TBS" "TCS" "TDS"; - - -"NEA" lambda=0.017 dorm=1; -"NEB" lambda=0.017 dorm=1; -"NEC" lambda=0.017 dorm=1; -"NED" lambda=0.017 dorm=1; - -"TAA" or "cpuAA" "memAA"; -"memAA" csp "memAA1" "memAA2"; -"cpuAA" lambda=0.11 dorm=0; -"memAA1" lambda=0.11 dorm=0; -"memAA2" lambda=0.11 dorm=0; - -"TAB" or "cpuAB" "memAB"; -"memAB" csp "memAB1" "memAB2"; -"cpuAB" lambda=0.11 dorm=0; -"memAB1" lambda=0.11 dorm=0; -"memAB2" lambda=0.11 dorm=0; - -"TAC" or "cpuAC" "memAC"; -"memAC" csp "memAC1" "memAC2"; -"cpuAC" lambda=0.11 dorm=0; -"memAC1" lambda=0.11 dorm=0; -"memAC2" lambda=0.11 dorm=0; - -"TAS" or "cpuAS" "memAS"; -"memAS" csp "memAS1" "memAS2"; -"cpuAS" lambda=0.11 dorm=0; -"memAS1" lambda=0.11 dorm=0; -"memAS2" lambda=0.11 dorm=0; - -"TBA" or "cpuBA" "memBA"; -"memBA" csp "memBA1" "memBA2"; -"cpuBA" lambda=0.11 dorm=0; -"memBA1" lambda=0.11 dorm=0; -"memBA2" lambda=0.11 dorm=0; - -"TBB" or "cpuBB" "memBB"; -"memBB" csp "memBB1" "memBB2"; -"cpuBB" lambda=0.11 dorm=0; -"memBB1" lambda=0.11 dorm=0; -"memBB2" lambda=0.11 dorm=0; - -"TBC" or "cpuBC" "memBC"; -"memBC" csp "memBC1" "memBC2"; -"cpuBC" lambda=0.11 dorm=0; -"memBC1" lambda=0.11 dorm=0; -"memBC2" lambda=0.11 dorm=0; - -"TBS" or "cpuBS" "memBS"; -"memBS" csp "memBS1" "memBS2"; -"cpuBS" lambda=0.11 dorm=0; -"memBS1" lambda=0.11 dorm=0; -"memBS2" lambda=0.11 dorm=0; - -"TCA" or "cpuCA" "memCA"; -"memCA" csp "memCA1" "memCA2"; -"cpuCA" lambda=0.11 dorm=0; -"memCA1" lambda=0.11 dorm=0; -"memCA2" lambda=0.11 dorm=0; - -"TCB" or "cpuCB" "memCB"; -"memCB" csp "memCB1" "memCB2"; -"cpuCB" lambda=0.11 dorm=0; -"memCB1" lambda=0.11 dorm=0; -"memCB2" lambda=0.11 dorm=0; - -"TCC" or "cpuCC" "memCC"; -"memCC" csp "memCC1" "memCC2"; -"cpuCC" lambda=0.11 dorm=0; -"memCC1" lambda=0.11 dorm=0; -"memCC2" lambda=0.11 dorm=0; - -"TCS" or "cpuCS" "memCS"; -"memCS" csp "memCS1" "memCS2"; -"cpuCS" lambda=0.11 dorm=0; -"memCS1" lambda=0.11 dorm=0; -"memCS2" lambda=0.11 dorm=0; - -"TDA" or "cpuDA" "memDA"; -"memDA" csp "memDA1" "memDA2"; -"cpuDA" lambda=0.11 dorm=0; -"memDA1" lambda=0.11 dorm=0; -"memDA2" lambda=0.11 dorm=0; - -"TDB" or "cpuDB" "memDB"; -"memDB" csp "memDB1" "memDB2"; -"cpuDB" lambda=0.11 dorm=0; -"memDB1" lambda=0.11 dorm=0; -"memDB2" lambda=0.11 dorm=0; - -"TDC" or "cpuDC" "memDC"; -"memDC" csp "memDC1" "memDC2"; -"cpuDC" lambda=0.11 dorm=0; -"memDC1" lambda=0.11 dorm=0; -"memDC2" lambda=0.11 dorm=0; - -"TDS" or "cpuDS" "memDS"; -"memDS" csp "memDS1" "memDS2"; -"cpuDS" lambda=0.11 dorm=0; -"memDS1" lambda=0.11 dorm=0; -"memDS2" lambda=0.11 dorm=0; diff --git a/examples/dft/ftpp_large.dft b/examples/dft/ftpp_large.dft deleted file mode 100644 index cdc8032e7..000000000 --- a/examples/dft/ftpp_large.dft +++ /dev/null @@ -1,63 +0,0 @@ -toplevel "System"; -"System" or "triadA" "triadB" "triadC" "triadD" "fA" "fB" "fC" "fD" "fE"; - -"triadA" 3of4 "aA" "bA" "cA" "dA"; -"aA" csp "TAA" "TAS"; -"bA" csp "TAB" "TAS"; -"cA" csp "TAC" "TAS"; -"dA" csp "TAD" "TAS"; - -"triadB" 3of4 "aB" "bB" "cB" "dB"; -"aB" csp "TBA" "TBS"; -"bB" csp "TBB" "TBS"; -"cB" csp "TBC" "TBS"; -"dB" csp "TBD" "TBS"; - -"triadC" 3of4 "aC" "bC" "cC" "dC"; -"aC" csp "TCA" "TCS"; -"bC" csp "TCB" "TCS"; -"cC" csp "TCC" "TCS"; -"dC" csp "TCD" "TCS"; - -"triadD" 3of4 "aD" "bD" "cD" "dD"; -"aD" csp "TDA" "TDS"; -"bD" csp "TDB" "TDS"; -"cD" csp "TDC" "TDS"; -"dD" csp "TDD" "TDS"; - -"fA" fdep "NEA" "TAA" "TBA" "TCA" "TDA"; -"fB" fdep "NEB" "TAB" "TBB" "TCB" "TDB"; -"fC" fdep "NEC" "TAC" "TBC" "TCC" "TDC"; -"fD" fdep "NED" "TAD" "TBD" "TCD" "TDD"; -"fE" fdep "NEE" "TAS" "TBS" "TCS" "TDS"; - - -"NEA" lambda=0.017 dorm=1; -"NEB" lambda=0.017 dorm=1; -"NEC" lambda=0.017 dorm=1; -"NED" lambda=0.017 dorm=1; -"NEE" lambda=0.017 dorm=1; - -"TAA" lambda=0.11 dorm=0; -"TAB" lambda=0.11 dorm=0; -"TAC" lambda=0.11 dorm=0; -"TAD" lambda=0.11 dorm=0; -"TAS" lambda=0.11 dorm=0; - -"TBA" lambda=0.11 dorm=0; -"TBB" lambda=0.11 dorm=0; -"TBC" lambda=0.11 dorm=0; -"TBD" lambda=0.11 dorm=0; -"TBS" lambda=0.11 dorm=0; - -"TCA" lambda=0.11 dorm=0; -"TCB" lambda=0.11 dorm=0; -"TCC" lambda=0.11 dorm=0; -"TCD" lambda=0.11 dorm=0; -"TCS" lambda=0.11 dorm=0; - -"TDA" lambda=0.11 dorm=0; -"TDB" lambda=0.11 dorm=0; -"TDC" lambda=0.11 dorm=0; -"TDD" lambda=0.11 dorm=0; -"TDS" lambda=0.11 dorm=0; diff --git a/examples/dft/ftpp_standard.dft b/examples/dft/ftpp_standard.dft deleted file mode 100644 index 9eaa7720e..000000000 --- a/examples/dft/ftpp_standard.dft +++ /dev/null @@ -1,53 +0,0 @@ -toplevel "System"; -"System" or "triadA" "triadB" "triadC" "triadD" "fA" "fB" "fC" "fD"; - -"triadA" 2of3 "aA" "bA" "cA"; -"aA" csp "TAA" "TAS"; -"bA" csp "TAB" "TAS"; -"cA" csp "TAC" "TAS"; - -"triadB" 2of3 "aB" "bB" "cB"; -"aB" csp "TBA" "TBS"; -"bB" csp "TBB" "TBS"; -"cB" csp "TBC" "TBS"; - -"triadC" 2of3 "aC" "bC" "cC"; -"aC" csp "TCA" "TCS"; -"bC" csp "TCB" "TCS"; -"cC" csp "TCC" "TCS"; - -"triadD" 2of3 "aD" "bD" "cD"; -"aD" csp "TDA" "TDS"; -"bD" csp "TDB" "TDS"; -"cD" csp "TDC" "TDS"; - -"fA" fdep "NEA" "TAA" "TBA" "TCA" "TDA"; -"fB" fdep "NEB" "TAB" "TBB" "TCB" "TDB"; -"fC" fdep "NEC" "TAC" "TBC" "TCC" "TDC"; -"fD" fdep "NED" "TAS" "TBS" "TCS" "TDS"; - - -"NEA" lambda=0.017 dorm=1; -"NEB" lambda=0.017 dorm=1; -"NEC" lambda=0.017 dorm=1; -"NED" lambda=0.017 dorm=1; - -"TAA" lambda=0.11 dorm=0; -"TAB" lambda=0.11 dorm=0; -"TAC" lambda=0.11 dorm=0; -"TAS" lambda=0.11 dorm=0; - -"TBA" lambda=0.11 dorm=0; -"TBB" lambda=0.11 dorm=0; -"TBC" lambda=0.11 dorm=0; -"TBS" lambda=0.11 dorm=0; - -"TCA" lambda=0.11 dorm=0; -"TCB" lambda=0.11 dorm=0; -"TCC" lambda=0.11 dorm=0; -"TCS" lambda=0.11 dorm=0; - -"TDA" lambda=0.11 dorm=0; -"TDB" lambda=0.11 dorm=0; -"TDC" lambda=0.11 dorm=0; -"TDS" lambda=0.11 dorm=0; diff --git a/examples/dft/mcs.dft b/examples/dft/mcs.dft deleted file mode 100644 index 733a7a599..000000000 --- a/examples/dft/mcs.dft +++ /dev/null @@ -1,22 +0,0 @@ -toplevel "n12"; -"n12" or "n1" "n103" "n7"; -"n103" wsp "n106" "n14"; -"n7" and "n18" "n26"; -"n26" or "n28" "n19" "n23"; -"n19" wsp "n16" "n13"; -"n23" wsp "n0" "n17"; -"n18" or "n15" "n9" "n3"; -"n3" wsp "n2" "n17"; -"n9" wsp "n8" "n27"; -"n16" lambda=8.0 dorm=0.0; -"n0" lambda=0.003 dorm=0.0; -"n13" lambda=8.0 dorm=0.5; -"n2" lambda=0.003 dorm=0.0; -"n17" lambda=0.003 dorm=0.5; -"n15" lambda=0.05 dorm=0.0; -"n106" lambda=1.2 dorm=0.0; -"n14" lambda=0.6 dorm=0.0; -"n1" lambda=2.0E-4 dorm=0.0; -"n27" lambda=8.0 dorm=0.5; -"n8" lambda=8.0 dorm=0.0; -"n28" lambda=0.05 dorm=0.0; diff --git a/examples/dft/mdcs.dft b/examples/dft/mdcs.dft deleted file mode 100644 index 450217a4c..000000000 --- a/examples/dft/mdcs.dft +++ /dev/null @@ -1,26 +0,0 @@ -toplevel "System"; - -"System" or "S" "N"; - -"N" lambda=2e-5 dorm=0; - -"S" and "CMA" "CMB"; - -"CMA" or "DiskA" "PA" "MemA"; -"DiskA" wsp "DAA" "DAB"; -"PA" lambda=500e-5 dorm=0; -"MemA" wsp "MA" "MC"; -"DAA" lambda=80000e-5 dorm=0.5; -"DAB" lambda=80000e-5 dorm=0.5; -"MA" lambda=30e-5 dorm=0; - -"CMB" or "DiskB" "PB" "MemB"; -"DiskB" wsp "DBA" "DBB"; -"PB" lambda=500e-5 dorm=0; -"MemB" wsp "MB" "MC"; -"DBA" lambda=80000e-5 dorm=0.5; -"DBB" lambda=80000e-5 dorm=0.5; -"MB" lambda=30e-5 dorm=0; - -"MC" lambda=30e-5 dorm=0.5; - diff --git a/examples/dft/mdcs2.dft b/examples/dft/mdcs2.dft deleted file mode 100644 index 5a376a7b8..000000000 --- a/examples/dft/mdcs2.dft +++ /dev/null @@ -1,19 +0,0 @@ -toplevel "System"; -"System" or "S" "N"; -"N" lambda=0.0000200000 dorm=0.0000000000; -"S" and "CMA" "CMB"; -"CMA" or "DiskA" "PA" "MemA"; -"DiskA" wsp "DAA" "DAB"; -"PA" lambda=0.0049999999 dorm=0.0000000000; -"MemA" wsp "MA" "MC"; -"DAA" lambda=0.8000000119 dorm=0.5000000000; -"DAB" lambda=0.8000000119 dorm=0.5000000000; -"MA" lambda=0.0003000000 dorm=0.0000000000; -"CMB" or "DiskB" "PB" "MemB"; -"DiskB" wsp "DBA" "DBB"; -"PB" lambda=0.0049999999 dorm=0.0000000000; -"MemB" wsp "MB" "MC"; -"DBA" lambda=0.8000000119 dorm=0.5000000000; -"DBB" lambda=0.8000000119 dorm=0.5000000000; -"MB" lambda=0.0003000000 dorm=0.0000000000; -"MC" lambda=0.0003000000 dorm=0.5000000000; diff --git a/examples/dft/mp.dft b/examples/dft/mp.dft deleted file mode 100644 index a2e769420..000000000 --- a/examples/dft/mp.dft +++ /dev/null @@ -1,7 +0,0 @@ -toplevel "A"; -"A" or "B" "C"; -"B" or "D" "E"; -"C" or "F" "E"; -"D" lambda=0.1 dorm=0; -"E" lambda=0.2 dorm=0; -"F" lambda=0.3 dorm=0; diff --git a/examples/dft/nonmonoton_param.dft b/examples/dft/nonmonoton_param.dft deleted file mode 100644 index e83f3b012..000000000 --- a/examples/dft/nonmonoton_param.dft +++ /dev/null @@ -1,8 +0,0 @@ -param x; -param y; -toplevel "A"; -"A" or "B" "Z"; -"B" pand "D" "S"; -"Z" lambda=y dorm=0; -"D" lambda=100 dorm=0; -"S" lambda=100*x dorm=0; diff --git a/examples/dft/or.dft b/examples/dft/or.dft deleted file mode 100644 index b1003da11..000000000 --- a/examples/dft/or.dft +++ /dev/null @@ -1,4 +0,0 @@ -toplevel "A"; -"A" or "B" "C"; -"B" lambda=0.5 dorm=0.3; -"C" lambda=0.5 dorm=0.3; diff --git a/examples/dft/pand.dft b/examples/dft/pand.dft deleted file mode 100644 index d752517b4..000000000 --- a/examples/dft/pand.dft +++ /dev/null @@ -1,4 +0,0 @@ -toplevel "A"; -"A" pand "B" "C"; -"B" lambda=0.4 dorm=0.3; -"C" lambda=0.2 dorm=0.3; diff --git a/examples/dft/pand_param.dft b/examples/dft/pand_param.dft deleted file mode 100644 index 9a0b3d211..000000000 --- a/examples/dft/pand_param.dft +++ /dev/null @@ -1,6 +0,0 @@ -param x; -param y; -toplevel "A"; -"A" pand "B" "C"; -"B" lambda=x dorm=0.3; -"C" lambda=y dorm=0.3; diff --git a/examples/dft/pdep.dft b/examples/dft/pdep.dft deleted file mode 100644 index f8cb0382b..000000000 --- a/examples/dft/pdep.dft +++ /dev/null @@ -1,12 +0,0 @@ -// From Junges2015 -// Example 3.19 - -toplevel "SF"; -"SF" or "A" "B" "PDEP"; -"A" pand "S" "MA"; -"B" and "MA" "MB"; -"PDEP" pdep=0.2 "MA" "S"; - -"S" lambda=0.5 dorm=0; -"MA" lambda=0.5 dorm=0; -"MB" lambda=0.5 dorm=0; diff --git a/examples/dft/pdep2.dft b/examples/dft/pdep2.dft deleted file mode 100644 index ab1c7a9b8..000000000 --- a/examples/dft/pdep2.dft +++ /dev/null @@ -1,9 +0,0 @@ -toplevel "SF"; -"SF" or "A" "B" "PDEP"; -"A" pand "S" "MA"; -"B" and "MA" "MB"; -"PDEP" pdep=0.2 "MA" "S" "MB"; - -"S" lambda=0.5 dorm=0; -"MA" lambda=0.5 dorm=0; -"MB" lambda=0.5 dorm=0; diff --git a/examples/dft/pdep3.dft b/examples/dft/pdep3.dft deleted file mode 100644 index a9a73f472..000000000 --- a/examples/dft/pdep3.dft +++ /dev/null @@ -1,5 +0,0 @@ -toplevel "A"; -"A" and "B" "C" "F"; -"F" pdep=0.3 "B" "C"; -"B" lambda=0.4 dorm=0; -"C" lambda=0.8 dorm=0; diff --git a/examples/dft/pdep4.dft b/examples/dft/pdep4.dft deleted file mode 100644 index eace91847..000000000 --- a/examples/dft/pdep4.dft +++ /dev/null @@ -1,7 +0,0 @@ -toplevel "SF"; -"SF" pand "S" "A" "B"; -"PDEP" pdep=0.2 "S" "A" "B"; - -"S" lambda=0.5 dorm=0; -"A" lambda=0.5 dorm=0; -"B" lambda=0.5 dorm=0; diff --git a/examples/dft/pdep_symmetry.dft b/examples/dft/pdep_symmetry.dft deleted file mode 100644 index 5c9254aa5..000000000 --- a/examples/dft/pdep_symmetry.dft +++ /dev/null @@ -1,11 +0,0 @@ -toplevel "A"; -"A" and "B" "B'"; -"B" and "C" "D" "PDEP"; -"B'" and "C'" "D'" "PDEP'"; -"PDEP" pdep=0.6 "C" "D"; -"PDEP'" pdep=0.6 "C'" "D'"; -"C" lambda=0.5 dorm=0; -"D" lambda=0.5 dorm=0; -"C'" lambda=0.5 dorm=0; -"D'" lambda=0.5 dorm=0; - diff --git a/examples/dft/por.dft b/examples/dft/por.dft deleted file mode 100644 index 020687f62..000000000 --- a/examples/dft/por.dft +++ /dev/null @@ -1,5 +0,0 @@ -toplevel "A"; -"A" por "B" "C" "D"; -"B" lambda=0.4 dorm=0.0; -"C" lambda=0.2 dorm=0.0; -"D" lambda=0.2 dorm=0.0; diff --git a/examples/dft/seq.dft b/examples/dft/seq.dft deleted file mode 100644 index 6fd99bc3b..000000000 --- a/examples/dft/seq.dft +++ /dev/null @@ -1,5 +0,0 @@ -toplevel "A"; -"A" and "B" "C"; -"X" seq "B" "C" -"B" lambda=0.5 dorm=0.3; -"C" lambda=0.5 dorm=0.3; diff --git a/examples/dft/seq2.dft b/examples/dft/seq2.dft deleted file mode 100644 index 408d4c26d..000000000 --- a/examples/dft/seq2.dft +++ /dev/null @@ -1,6 +0,0 @@ -toplevel "A"; -"A" and "B" "C" "D"; -"X" seq "B" "C" "D"; -"B" lambda=0.5 dorm=0.3; -"C" lambda=0.5 dorm=0.3; -"D" lambda=0.5 dorm=0.3; diff --git a/examples/dft/seq3.dft b/examples/dft/seq3.dft deleted file mode 100644 index b22b9e8b6..000000000 --- a/examples/dft/seq3.dft +++ /dev/null @@ -1,6 +0,0 @@ -toplevel "A"; -"A" and "C" "D"; -"X" seq "B" "C" "D"; -"B" lambda=0.5 dorm=0.3; -"C" lambda=0.5 dorm=0.3; -"D" lambda=0.5 dorm=0.3; diff --git a/examples/dft/seq4.dft b/examples/dft/seq4.dft deleted file mode 100644 index 60bf149af..000000000 --- a/examples/dft/seq4.dft +++ /dev/null @@ -1,7 +0,0 @@ -toplevel "A"; -"A" and "T1" "B3"; -"T1" or "B1" "B2"; -"X" seq "B1" "B2" "B3"; -"B1" lambda=0.5 dorm=0.3; -"B2" lambda=0.5 dorm=0.3; -"B3" lambda=0.5 dorm=0.3; diff --git a/examples/dft/seq5.dft b/examples/dft/seq5.dft deleted file mode 100644 index 77b13ddeb..000000000 --- a/examples/dft/seq5.dft +++ /dev/null @@ -1,9 +0,0 @@ -toplevel "A"; -"A" and "T1" "T2"; -"T1" pand "B1" "B2"; -"T2" pand "B3" "B4"; -"X" seq "B4" "B3"; -"B1" lambda=0.7 dorm=0.3; -"B2" lambda=0.5 dorm=0.3; -"B3" lambda=0.5 dorm=0.3; -"B4" lambda=0.7 dorm=0.3; diff --git a/examples/dft/spare.dft b/examples/dft/spare.dft deleted file mode 100644 index 4c5d44ff4..000000000 --- a/examples/dft/spare.dft +++ /dev/null @@ -1,5 +0,0 @@ -toplevel "A"; -"A" wsp "I" "M"; -"I" lambda=0.5 dorm=0.3; -"M" lambda=0.5 dorm=0.3; - diff --git a/examples/dft/spare2.dft b/examples/dft/spare2.dft deleted file mode 100644 index 21b40cf73..000000000 --- a/examples/dft/spare2.dft +++ /dev/null @@ -1,8 +0,0 @@ -toplevel "A"; -"A" or "B" "C"; -"B" wsp "I" "J"; -"C" wsp "M" "J"; -"I" lambda=0.5 dorm=0.3; -"J" lambda=0.5 dorm=0.3; -"M" lambda=0.5 dorm=0.3; - diff --git a/examples/dft/spare3.dft b/examples/dft/spare3.dft deleted file mode 100644 index ba0ac01d4..000000000 --- a/examples/dft/spare3.dft +++ /dev/null @@ -1,10 +0,0 @@ -toplevel "A"; -"A" or "B" "C" "D"; -"B" wsp "I" "M"; -"C" wsp "J" "M"; -"D" wsp "K" "M"; -"I" lambda=0.5 dorm=0.3; -"J" lambda=0.5 dorm=0.3; -"K" lambda=0.5 dorm=0.3; -"M" lambda=0.5 dorm=0.3; - diff --git a/examples/dft/spare4.dft b/examples/dft/spare4.dft deleted file mode 100644 index a217c6e43..000000000 --- a/examples/dft/spare4.dft +++ /dev/null @@ -1,9 +0,0 @@ -toplevel "A"; -"A" and "B" "C"; -"B" wsp "I" "J" "K"; -"C" wsp "M" "J"; -"I" lambda=0.5 dorm=0.3; -"J" lambda=0.5 dorm=0.3; -"K" lambda=0.5 dorm=0.3; -"M" lambda=0.5 dorm=0.3; - diff --git a/examples/dft/spare5.dft b/examples/dft/spare5.dft deleted file mode 100644 index 0cd15bf0e..000000000 --- a/examples/dft/spare5.dft +++ /dev/null @@ -1,9 +0,0 @@ -toplevel "A"; -"A" wsp "I" "B"; -"B" or "C" "J"; -"C" or "K" "L"; -"I" lambda=0.5 dorm=0; -"J" lambda=0.5 dorm=0; -"K" lambda=0.5 dorm=0; -"L" lambda=0.5 dorm=0; - diff --git a/examples/dft/spare6.dft b/examples/dft/spare6.dft deleted file mode 100644 index d5f2b270b..000000000 --- a/examples/dft/spare6.dft +++ /dev/null @@ -1,7 +0,0 @@ -toplevel "A"; -"A" or "I" "B"; -"B" wsp "J" "M"; -"I" lambda=0.5 dorm=0.5; -"J" lambda=0.5 dorm=0.5; -"M" lambda=0.5 dorm=0.5; - diff --git a/examples/dft/spare7.dft b/examples/dft/spare7.dft deleted file mode 100644 index a16429e6f..000000000 --- a/examples/dft/spare7.dft +++ /dev/null @@ -1,5 +0,0 @@ -toplevel "A"; -"A" wsp "K" "J" "I"; -"I" lambda=0.5 dorm=0.5; -"J" lambda=1 dorm=0.5; -"K" lambda=0.5 dorm=0.5; diff --git a/examples/dft/spare8.dft b/examples/dft/spare8.dft deleted file mode 100644 index c67eaf022..000000000 --- a/examples/dft/spare8.dft +++ /dev/null @@ -1,7 +0,0 @@ -toplevel "A"; -"A" wsp "I" "B"; -"B" wsp "J" "K"; -"I" lambda=0.5 dorm=0.3; -"J" lambda=0.5 dorm=0.3; -"K" lambda=0.5 dorm=0.3; - diff --git a/examples/dft/spare_cold.dft b/examples/dft/spare_cold.dft deleted file mode 100644 index d01174bd5..000000000 --- a/examples/dft/spare_cold.dft +++ /dev/null @@ -1,5 +0,0 @@ -toplevel "A"; -"A" wsp "I" "M"; -"I" lambda=0.5 dorm=0.0; -"M" lambda=0.5 dorm=0.0; - diff --git a/examples/dft/spare_param.dft b/examples/dft/spare_param.dft deleted file mode 100644 index 5378b13d2..000000000 --- a/examples/dft/spare_param.dft +++ /dev/null @@ -1,9 +0,0 @@ -param x; -param y; -toplevel "SF"; -"SF" or "FW" "BW"; -"FW" wsp "W1" "WS"; -"BW" wsp "W2" "WS"; -"W1" lambda=x dorm=0; -"W2" lambda=1 dorm=0; -"WS" lambda=y dorm=0; diff --git a/examples/dft/spare_symmetry.dft b/examples/dft/spare_symmetry.dft deleted file mode 100644 index 04b5c253b..000000000 --- a/examples/dft/spare_symmetry.dft +++ /dev/null @@ -1,9 +0,0 @@ -toplevel "A"; -"A" and "B" "C"; -"B" wsp "I" "J"; -"C" wsp "K" "L"; -"I" lambda=0.5 dorm=0.3; -"J" lambda=0.5 dorm=0.3; -"K" lambda=0.5 dorm=0.3; -"L" lambda=0.5 dorm=0.3; - diff --git a/examples/dft/symmetry.dft b/examples/dft/symmetry.dft deleted file mode 100644 index 6f4031d0b..000000000 --- a/examples/dft/symmetry.dft +++ /dev/null @@ -1,8 +0,0 @@ -toplevel "A"; -"A" and "B" "B'"; -"B" and "C" "D"; -"B'" and "C'" "D'"; -"C" lambda=0.5 dorm=0; -"D" lambda=0.5 dorm=0; -"C'" lambda=0.5 dorm=0; -"D'" lambda=0.5 dorm=0; diff --git a/examples/dft/symmetry2.dft b/examples/dft/symmetry2.dft deleted file mode 100644 index 6d04021bb..000000000 --- a/examples/dft/symmetry2.dft +++ /dev/null @@ -1,8 +0,0 @@ -toplevel "A"; -"A" and "B" "B'"; -"B" and "C" "D"; -"B'" and "C'" "D'"; -"C" lambda=0.5 dorm=0; -"D" lambda=2 dorm=0; -"C'" lambda=0.5 dorm=0; -"D'" lambda=2 dorm=0; diff --git a/examples/dft/symmetry3.dft b/examples/dft/symmetry3.dft deleted file mode 100644 index edda963f9..000000000 --- a/examples/dft/symmetry3.dft +++ /dev/null @@ -1,12 +0,0 @@ -toplevel "A"; -"A" and "B" "B'" "B''"; -"B" and "C" "D"; -"B'" and "C'" "D'"; -"B''" and "C''" "D''"; -"C" lambda=0.5 dorm=0; -"D" lambda=0.5 dorm=0; -"C'" lambda=0.5 dorm=0; -"D'" lambda=0.5 dorm=0; -"C''" lambda=0.5 dorm=0; -"D''" lambda=0.5 dorm=0; - diff --git a/examples/dft/symmetry4.dft b/examples/dft/symmetry4.dft deleted file mode 100644 index f401fc241..000000000 --- a/examples/dft/symmetry4.dft +++ /dev/null @@ -1,12 +0,0 @@ -toplevel "A"; -"A" and "B" "B'" "C" "C'"; -"B" and "D" "E"; -"B'" and "D'" "E'"; -"C" or "F"; -"C'" or "F'"; -"D" lambda=0.5 dorm=0; -"E" lambda=0.5 dorm=0; -"D'" lambda=0.5 dorm=0; -"E'" lambda=0.5 dorm=0; -"F" lambda=0.5 dorm=0; -"F'" lambda=0.5 dorm=0; diff --git a/examples/dft/symmetry5.dft b/examples/dft/symmetry5.dft deleted file mode 100644 index 18f700bb2..000000000 --- a/examples/dft/symmetry5.dft +++ /dev/null @@ -1,21 +0,0 @@ -toplevel "A"; -"A" and "BA" "BB" "BC" "BD" "BE" "BF"; -"BA" and "CA" "DA"; -"BB" and "CB" "DB"; -"BC" and "CC" "DC"; -"BD" and "CD" "DD"; -"BE" and "CE" "DE"; -"BF" and "CF" "DF"; -"CA" lambda=0.5 dorm=0; -"DA" lambda=0.5 dorm=0; -"CB" lambda=0.5 dorm=0; -"DB" lambda=0.5 dorm=0; -"CC" lambda=0.5 dorm=0; -"DC" lambda=0.5 dorm=0; -"CD" lambda=0.5 dorm=0; -"DD" lambda=0.5 dorm=0; -"CE" lambda=0.5 dorm=0; -"DE" lambda=0.5 dorm=0; -"CF" lambda=0.5 dorm=0; -"DF" lambda=0.5 dorm=0; - diff --git a/examples/dft/symmetry_param.dft b/examples/dft/symmetry_param.dft deleted file mode 100644 index 412968c80..000000000 --- a/examples/dft/symmetry_param.dft +++ /dev/null @@ -1,10 +0,0 @@ -param x; -param y; -toplevel "A"; -"A" and "B" "B'"; -"B" and "C" "D"; -"B'" and "C'" "D'"; -"C" lambda=x dorm=0; -"D" lambda=y dorm=0; -"C'" lambda=x dorm=0; -"D'" lambda=y dorm=0; diff --git a/examples/dft/symmetry_shared.dft b/examples/dft/symmetry_shared.dft deleted file mode 100644 index 73ebed519..000000000 --- a/examples/dft/symmetry_shared.dft +++ /dev/null @@ -1,7 +0,0 @@ -toplevel "A"; -"A" and "B" "B'"; -"B" wsp "C" "D"; -"B'" wsp "C'" "D"; -"C" lambda=0.5 dorm=0; -"D" lambda=0.5 dorm=0; -"C'" lambda=0.5 dorm=0; diff --git a/examples/dft/tripple_and1.dft b/examples/dft/tripple_and1.dft deleted file mode 100644 index b6f1c04b2..000000000 --- a/examples/dft/tripple_and1.dft +++ /dev/null @@ -1,8 +0,0 @@ -toplevel "A"; -"A" and "B" "C"; -"B" and "BE1" "BE2"; -"C" and "BE3" "BE4"; -"BE1" lambda=0.5 dorm=0.3; -"BE2" lambda=0.5 dorm=0.3; -"BE3" lambda=0.5 dorm=0.3; -"BE4" lambda=0.5 dorm=0.3; diff --git a/examples/dft/tripple_and2.dft b/examples/dft/tripple_and2.dft deleted file mode 100644 index 382c1657d..000000000 --- a/examples/dft/tripple_and2.dft +++ /dev/null @@ -1,8 +0,0 @@ -toplevel "A"; -"A" and "B" "C"; -"B" and "BE1" "BE2"; -"C" and "BE2" "BE3"; -"BE1" lambda=0.5 dorm=0.3; -"BE2" lambda=0.5 dorm=0.3; -"BE3" lambda=0.5 dorm=0.3; - diff --git a/examples/dft/tripple_and2_c.dft b/examples/dft/tripple_and2_c.dft deleted file mode 100644 index edfde4144..000000000 --- a/examples/dft/tripple_and2_c.dft +++ /dev/null @@ -1,6 +0,0 @@ -toplevel "A"; -"A" and "BE1" "BE2" "BE3"; -"BE1" lambda=0.5 dorm=3; -"BE2" lambda=0.5 dorm=3; -"BE3" lambda=0.5 dorm=3; - diff --git a/examples/dft/tripple_and_c.dft b/examples/dft/tripple_and_c.dft deleted file mode 100644 index 72b384c98..000000000 --- a/examples/dft/tripple_and_c.dft +++ /dev/null @@ -1,7 +0,0 @@ -toplevel "A"; -"A" and "BE1" "BE2" "BE3" "BE4"; -"BE1" lambda=0.5 dorm=3; -"BE2" lambda=0.5 dorm=3; -"BE3" lambda=0.5 dorm=3; -"BE4" lambda=0.5 dorm=3; - diff --git a/examples/dft/tripple_or.dft b/examples/dft/tripple_or.dft deleted file mode 100644 index 9dbd0e377..000000000 --- a/examples/dft/tripple_or.dft +++ /dev/null @@ -1,9 +0,0 @@ -toplevel "A"; -"A" or "B" "C"; -"B" or "BE1" "BE2"; -"C" or "BE3" "BE4"; -"BE1" lambda=0.5 dorm=3; -"BE2" lambda=0.5 dorm=3; -"BE3" lambda=0.5 dorm=3; -"BE4" lambda=0.5 dorm=3; - diff --git a/examples/dft/tripple_or2.dft b/examples/dft/tripple_or2.dft deleted file mode 100644 index 32bc0ff8f..000000000 --- a/examples/dft/tripple_or2.dft +++ /dev/null @@ -1,8 +0,0 @@ -toplevel "A"; -"A" or "B" "C"; -"B" or "BE1" "BE2"; -"C" or "BE2" "BE3"; -"BE1" lambda=0.5 dorm=3; -"BE2" lambda=0.5 dorm=3; -"BE3" lambda=0.5 dorm=3; - diff --git a/examples/dft/tripple_or2_c.dft b/examples/dft/tripple_or2_c.dft deleted file mode 100644 index 40747fbc8..000000000 --- a/examples/dft/tripple_or2_c.dft +++ /dev/null @@ -1,6 +0,0 @@ -toplevel "A"; -"A" or "BE1" "BE2" "BE3"; -"BE1" lambda=0.5 dorm=3; -"BE2" lambda=0.5 dorm=3; -"BE3" lambda=0.5 dorm=3; - diff --git a/examples/dft/tripple_or_c.dft b/examples/dft/tripple_or_c.dft deleted file mode 100644 index 378b29630..000000000 --- a/examples/dft/tripple_or_c.dft +++ /dev/null @@ -1,7 +0,0 @@ -toplevel "A"; -"A" or "BE1" "BE2" "BE3" "BE4"; -"BE1" lambda=0.5 dorm=3; -"BE2" lambda=0.5 dorm=3; -"BE3" lambda=0.5 dorm=3; -"BE4" lambda=0.5 dorm=3; - diff --git a/examples/dft/tripple_pand.dft b/examples/dft/tripple_pand.dft deleted file mode 100644 index 7b38cf0f1..000000000 --- a/examples/dft/tripple_pand.dft +++ /dev/null @@ -1,9 +0,0 @@ -toplevel "A"; -"A" pand "B" "BE4"; -"B" pand "C" "BE3"; -"C" pand "BE1" "BE2"; -"BE1" lambda=0.5 dorm=3; -"BE2" lambda=0.5 dorm=3; -"BE3" lambda=0.5 dorm=3; -"BE4" lambda=0.5 dorm=3; - diff --git a/examples/dft/tripple_pand2.dft b/examples/dft/tripple_pand2.dft deleted file mode 100644 index 4e6ef460f..000000000 --- a/examples/dft/tripple_pand2.dft +++ /dev/null @@ -1,8 +0,0 @@ -toplevel "A"; -"A" pand "B" "C"; -"B" pand "BE1" "BE2"; -"C" pand "BE2" "BE3"; -"BE1" lambda=0.5 dorm=3; -"BE2" lambda=0.5 dorm=3; -"BE3" lambda=0.5 dorm=3; - diff --git a/examples/dft/tripple_pand2_c.dft b/examples/dft/tripple_pand2_c.dft deleted file mode 100644 index 1c6001ea4..000000000 --- a/examples/dft/tripple_pand2_c.dft +++ /dev/null @@ -1,6 +0,0 @@ -toplevel "A"; -"A" pand "BE1" "BE2" "BE3"; -"BE1" lambda=0.5 dorm=3; -"BE2" lambda=0.5 dorm=3; -"BE3" lambda=0.5 dorm=3; - diff --git a/examples/dft/tripple_pand_c.dft b/examples/dft/tripple_pand_c.dft deleted file mode 100644 index bfb8daa1c..000000000 --- a/examples/dft/tripple_pand_c.dft +++ /dev/null @@ -1,7 +0,0 @@ -toplevel "A"; -"A" pand "BE1" "BE2" "BE3" "BE4"; -"BE1" lambda=0.5 dorm=3; -"BE2" lambda=0.5 dorm=3; -"BE3" lambda=0.5 dorm=3; -"BE4" lambda=0.5 dorm=3; - diff --git a/examples/dft/voting.dft b/examples/dft/voting.dft deleted file mode 100644 index 5c648d424..000000000 --- a/examples/dft/voting.dft +++ /dev/null @@ -1,5 +0,0 @@ -toplevel "A"; -"A" 1of3 "B" "C" "D"; -"B" lambda=0.1 dorm=0; -"C" lambda=0.2 dorm=0; -"D" lambda=0.3 dorm=0; diff --git a/examples/dft/voting2.dft b/examples/dft/voting2.dft deleted file mode 100644 index 9cdf299f3..000000000 --- a/examples/dft/voting2.dft +++ /dev/null @@ -1,5 +0,0 @@ -toplevel "A"; -"A" 1of3 "B" "C" "D"; -"B" lambda=0.3 dorm=0; -"C" lambda=0.4 dorm=0; -"D" lambda=1 dorm=0; diff --git a/examples/dtmc/brp/brp.pm b/examples/dtmc/brp/brp.pm deleted file mode 100644 index e09ed3e2c..000000000 --- a/examples/dtmc/brp/brp.pm +++ /dev/null @@ -1,136 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N; -// maximum number of retransmissions -const int MAX; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -module checker // prevents more than one frame being set - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> 0.98 : (k'=1) + 0.02 : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> 0.99 : (l'=1) + 0.01 : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -rewards - [aF] i=1 : 1; -endrewards - -label "target" = s=5; diff --git a/examples/dtmc/brp/brp_2_16.pm b/examples/dtmc/brp/brp_2_16.pm deleted file mode 100644 index 525b40deb..000000000 --- a/examples/dtmc/brp/brp_2_16.pm +++ /dev/null @@ -1,139 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - - -// reliability of channels -const double pL; -const double pK; - - -// number of chunks -const int N = 16; -// maximum number of retransmissions -const int MAX = 2; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -label "error" = s=5; diff --git a/examples/dtmc/crowds/crowds.pctl b/examples/dtmc/crowds/crowds.pctl deleted file mode 100644 index 653da5713..000000000 --- a/examples/dtmc/crowds/crowds.pctl +++ /dev/null @@ -1,3 +0,0 @@ -P=? [ F observe0Greater1 ] -P=? [ F observeIGreater1 ] -P=? [ F observeOnlyTrueSender ] diff --git a/examples/dtmc/crowds/crowds.res b/examples/dtmc/crowds/crowds.res deleted file mode 100644 index 8e41056f7..000000000 --- a/examples/dtmc/crowds/crowds.res +++ /dev/null @@ -1,19 +0,0 @@ -// 5/5 -P=? [ F "observe0Greater1" ] // 0.3328777473921436 -P=? [ F "observeIGreater1" ] // 0.15221847380560186 -P=? [ F "observeOnlyTrueSender" ] // 0.3215351607995943 - -// 10/5 -P=? [ F "observe0Greater1" ] // 0.26345583706046355 -P=? [ F "observeIGreater1" ] // 0.09236405558901994 -P=? [ F "observeOnlyTrueSender" ] // 0.25849872034453947 - -// 15/5 -P=? [ F "observe0Greater1" ] // 0.2408422942249347 -P=? [ F "observeIGreater1" ] // 0.0655686905854717 -P=? [ F "observeOnlyTrueSender" ] // 0.2377298605519743 - -// 20/5 -P=? [ F "observe0Greater1" ] // 0.22967858575985317 -P=? [ F "observeIGreater1" ] // 0.05073192927314383 -P=? [ F "observeOnlyTrueSender" ] // 0.22742031678667812 diff --git a/examples/dtmc/crowds/crowds10_5.pm b/examples/dtmc/crowds/crowds10_5.pm deleted file mode 100644 index 2dfdfdc3a..000000000 --- a/examples/dtmc/crowds/crowds10_5.pm +++ /dev/null @@ -1,80 +0,0 @@ -dtmc - -// probability of forwarding -const double PF = 4/5; -const double notPF = 1/5; // must be 1-PF -// probability that a crowd member is bad -const double badC = 167/1000; - // probability that a crowd member is good -const double goodC = 833/1000; -// Total number of protocol runs to analyze -const int TotalRuns = 5; -// size of the crowd -const int CrowdSize = 10; - -module crowds - // protocol phase - phase: [0..4] init 0; - - // crowd member good (or bad) - good: bool init false; - - // number of protocol runs - runCount: [0..TotalRuns] init 0; - - // observe_i is the number of times the attacker observed crowd member i - observe0: [0..TotalRuns] init 0; - - observe1: [0..TotalRuns] init 0; - - observe2: [0..TotalRuns] init 0; - - observe3: [0..TotalRuns] init 0; - - observe4: [0..TotalRuns] init 0; - - observe5: [0..TotalRuns] init 0; - - observe6: [0..TotalRuns] init 0; - - observe7: [0..TotalRuns] init 0; - - observe8: [0..TotalRuns] init 0; - - observe9: [0..TotalRuns] init 0; - - // the last seen crowd member - lastSeen: [0..CrowdSize - 1] init 0; - - // get the protocol started - [] phase=0 & runCount (phase'=1) & (runCount'=runCount+1) & (lastSeen'=0); - - // decide whether crowd member is good or bad according to given probabilities - [] phase=1 -> goodC : (phase'=2) & (good'=true) + badC : (phase'=2) & (good'=false); - - // if the current member is a good member, update the last seen index (chosen uniformly) - [] phase=2 & good -> 1/10 : (lastSeen'=0) & (phase'=3) + 1/10 : (lastSeen'=1) & (phase'=3) + 1/10 : (lastSeen'=2) & (phase'=3) + 1/10 : (lastSeen'=3) & (phase'=3) + 1/10 : (lastSeen'=4) & (phase'=3) + 1/10 : (lastSeen'=5) & (phase'=3) + 1/10 : (lastSeen'=6) & (phase'=3) + 1/10 : (lastSeen'=7) & (phase'=3) + 1/10 : (lastSeen'=8) & (phase'=3) + 1/10 : (lastSeen'=9) & (phase'=3); - - // if the current member is a bad member, record the most recently seen index - [] phase=2 & !good & lastSeen=0 & observe0 < TotalRuns -> (observe0'=observe0+1) & (phase'=4); - [] phase=2 & !good & lastSeen=1 & observe1 < TotalRuns -> (observe1'=observe1+1) & (phase'=4); - [] phase=2 & !good & lastSeen=2 & observe2 < TotalRuns -> (observe2'=observe2+1) & (phase'=4); - [] phase=2 & !good & lastSeen=3 & observe3 < TotalRuns -> (observe3'=observe3+1) & (phase'=4); - [] phase=2 & !good & lastSeen=4 & observe4 < TotalRuns -> (observe4'=observe4+1) & (phase'=4); - [] phase=2 & !good & lastSeen=5 & observe5 < TotalRuns -> (observe5'=observe5+1) & (phase'=4); - [] phase=2 & !good & lastSeen=6 & observe6 < TotalRuns -> (observe6'=observe6+1) & (phase'=4); - [] phase=2 & !good & lastSeen=7 & observe7 < TotalRuns -> (observe7'=observe7+1) & (phase'=4); - [] phase=2 & !good & lastSeen=8 & observe8 < TotalRuns -> (observe8'=observe8+1) & (phase'=4); - [] phase=2 & !good & lastSeen=9 & observe9 < TotalRuns -> (observe9'=observe9+1) & (phase'=4); - - // good crowd members forward with probability PF and deliver otherwise - [] phase=3 -> PF : (phase'=1) + notPF : (phase'=4); - - // deliver the message and start over - [] phase=4 -> (phase'=0); - -endmodule - -label "observe0Greater1" = observe0 > 1; -label "observeIGreater1" = observe1 > 1 | observe2 > 1 | observe3 > 1 | observe4 > 1 | observe5 > 1 | observe6 > 1 | observe7 > 1 | observe8 > 1 | observe9 > 1; -label "observeOnlyTrueSender" = observe0 > 1 & observe1 <= 1 & observe2 <= 1 & observe3 <= 1 & observe4 <= 1 & observe5 <= 1 & observe6 <= 1 & observe7 <= 1 & observe8 <= 1 & observe9 <= 1; diff --git a/examples/dtmc/crowds/crowds15_5.pm b/examples/dtmc/crowds/crowds15_5.pm deleted file mode 100644 index 31ffefc0f..000000000 --- a/examples/dtmc/crowds/crowds15_5.pm +++ /dev/null @@ -1,95 +0,0 @@ -dtmc - -// probability of forwarding -const double PF = 4/5; -const double notPF = 1/5; // must be 1-PF -// probability that a crowd member is bad -const double badC = 167/1000; - // probability that a crowd member is good -const double goodC = 833/1000; -// Total number of protocol runs to analyze -const int TotalRuns = 5; -// size of the crowd -const int CrowdSize = 15; - -module crowds - // protocol phase - phase: [0..4] init 0; - - // crowd member good (or bad) - good: bool init false; - - // number of protocol runs - runCount: [0..TotalRuns] init 0; - - // observe_i is the number of times the attacker observed crowd member i - observe0: [0..TotalRuns] init 0; - - observe1: [0..TotalRuns] init 0; - - observe2: [0..TotalRuns] init 0; - - observe3: [0..TotalRuns] init 0; - - observe4: [0..TotalRuns] init 0; - - observe5: [0..TotalRuns] init 0; - - observe6: [0..TotalRuns] init 0; - - observe7: [0..TotalRuns] init 0; - - observe8: [0..TotalRuns] init 0; - - observe9: [0..TotalRuns] init 0; - - observe10: [0..TotalRuns] init 0; - - observe11: [0..TotalRuns] init 0; - - observe12: [0..TotalRuns] init 0; - - observe13: [0..TotalRuns] init 0; - - observe14: [0..TotalRuns] init 0; - - // the last seen crowd member - lastSeen: [0..CrowdSize - 1] init 0; - - // get the protocol started - [] phase=0 & runCount 1: (phase'=1) & (runCount'=runCount+1) & (lastSeen'=0); - - // decide whether crowd member is good or bad according to given probabilities - [] phase=1 -> goodC : (phase'=2) & (good'=true) + badC : (phase'=2) & (good'=false); - - // if the current member is a good member, update the last seen index (chosen uniformly) - [] phase=2 & good -> 1/15 : (lastSeen'=0) & (phase'=3) + 1/15 : (lastSeen'=1) & (phase'=3) + 1/15 : (lastSeen'=2) & (phase'=3) + 1/15 : (lastSeen'=3) & (phase'=3) + 1/15 : (lastSeen'=4) & (phase'=3) + 1/15 : (lastSeen'=5) & (phase'=3) + 1/15 : (lastSeen'=6) & (phase'=3) + 1/15 : (lastSeen'=7) & (phase'=3) + 1/15 : (lastSeen'=8) & (phase'=3) + 1/15 : (lastSeen'=9) & (phase'=3) + 1/15 : (lastSeen'=10) & (phase'=3) + 1/15 : (lastSeen'=11) & (phase'=3) + 1/15 : (lastSeen'=12) & (phase'=3) + 1/15 : (lastSeen'=13) & (phase'=3) + 1/15 : (lastSeen'=14) & (phase'=3); - - // if the current member is a bad member, record the most recently seen index - [] phase=2 & !good & lastSeen=0 & observe0 < TotalRuns -> 1: (observe0'=observe0+1) & (phase'=4); - [] phase=2 & !good & lastSeen=1 & observe1 < TotalRuns -> 1: (observe1'=observe1+1) & (phase'=4); - [] phase=2 & !good & lastSeen=2 & observe2 < TotalRuns -> 1: (observe2'=observe2+1) & (phase'=4); - [] phase=2 & !good & lastSeen=3 & observe3 < TotalRuns -> 1: (observe3'=observe3+1) & (phase'=4); - [] phase=2 & !good & lastSeen=4 & observe4 < TotalRuns -> 1: (observe4'=observe4+1) & (phase'=4); - [] phase=2 & !good & lastSeen=5 & observe5 < TotalRuns -> 1: (observe5'=observe5+1) & (phase'=4); - [] phase=2 & !good & lastSeen=6 & observe6 < TotalRuns -> 1: (observe6'=observe6+1) & (phase'=4); - [] phase=2 & !good & lastSeen=7 & observe7 < TotalRuns -> 1: (observe7'=observe7+1) & (phase'=4); - [] phase=2 & !good & lastSeen=8 & observe8 < TotalRuns -> 1: (observe8'=observe8+1) & (phase'=4); - [] phase=2 & !good & lastSeen=9 & observe9 < TotalRuns -> 1: (observe9'=observe9+1) & (phase'=4); - [] phase=2 & !good & lastSeen=10 & observe10 < TotalRuns -> 1: (observe10'=observe10+1) & (phase'=4); - [] phase=2 & !good & lastSeen=11 & observe11 < TotalRuns -> 1: (observe11'=observe11+1) & (phase'=4); - [] phase=2 & !good & lastSeen=12 & observe12 < TotalRuns -> 1: (observe12'=observe12+1) & (phase'=4); - [] phase=2 & !good & lastSeen=13 & observe13 < TotalRuns -> 1: (observe13'=observe13+1) & (phase'=4); - [] phase=2 & !good & lastSeen=14 & observe14 < TotalRuns -> 1: (observe14'=observe14+1) & (phase'=4); - - // good crowd members forward with probability PF and deliver otherwise - [] phase=3 -> PF : (phase'=1) + notPF : (phase'=4); - - // deliver the message and start over - [] phase=4 -> 1: (phase'=0); - -endmodule - -label "observe0Greater1" = observe0 > 1; -label "observeIGreater1" = observe1 > 1 | observe2 > 1 | observe3 > 1 | observe4 > 1 | observe5 > 1 | observe6 > 1 | observe7 > 1 | observe8 > 1 | observe9 > 1 | observe10 > 1 | observe11 > 1 | observe12 > 1 | observe13 > 1 | observe14 > 1; -label "observeOnlyTrueSender" = observe0 > 1 & observe1 <= 1 & observe2 <= 1 & observe3 <= 1 & observe4 <= 1 & observe5 <= 1 & observe6 <= 1 & observe7 <= 1 & observe8 <= 1 & observe9 <= 1 & observe10 <= 1 & observe11 <= 1 & observe12 <= 1 & observe13 <= 1 & observe14 <= 1; diff --git a/examples/dtmc/crowds/crowds20_5.pm b/examples/dtmc/crowds/crowds20_5.pm deleted file mode 100644 index ffe4c9a4f..000000000 --- a/examples/dtmc/crowds/crowds20_5.pm +++ /dev/null @@ -1,111 +0,0 @@ -dtmc - -// probability of forwarding -const double PF = 4/5; -const double notPF = 1/5; // must be 1-PF -// probability that a crowd member is bad -const double badC = 167/1000; - // probability that a crowd member is good -const double goodC = 833/1000; -// Total number of protocol runs to analyze -const int TotalRuns = 5; -// size of the crowd -const int CrowdSize = 20; - -module crowds - // protocol phase - phase: [0..4] init 0; - - // crowd member good (or bad) - good: bool init false; - - // number of protocol runs - runCount: [0..TotalRuns] init 0; - - // observe_i is the number of times the attacker observed crowd member i - observe0: [0..TotalRuns] init 0; - - observe1: [0..TotalRuns] init 0; - - observe2: [0..TotalRuns] init 0; - - observe3: [0..TotalRuns] init 0; - - observe4: [0..TotalRuns] init 0; - - observe5: [0..TotalRuns] init 0; - - observe6: [0..TotalRuns] init 0; - - observe7: [0..TotalRuns] init 0; - - observe8: [0..TotalRuns] init 0; - - observe9: [0..TotalRuns] init 0; - - observe10: [0..TotalRuns] init 0; - - observe11: [0..TotalRuns] init 0; - - observe12: [0..TotalRuns] init 0; - - observe13: [0..TotalRuns] init 0; - - observe14: [0..TotalRuns] init 0; - - observe15: [0..TotalRuns] init 0; - - observe16: [0..TotalRuns] init 0; - - observe17: [0..TotalRuns] init 0; - - observe18: [0..TotalRuns] init 0; - - observe19: [0..TotalRuns] init 0; - - // the last seen crowd member - lastSeen: [0..CrowdSize - 1] init 0; - - // get the protocol started - [] phase=0 & runCount 1:(phase'=1) & (runCount'=runCount+1) & (lastSeen'=0); - - // decide whether crowd member is good or bad according to given probabilities - [] phase=1 -> goodC : (phase'=2) & (good'=true) + badC : (phase'=2) & (good'=false); - - // if the current member is a good member, update the last seen index (chosen uniformly) - [] phase=2 & good -> 1/20 : (lastSeen'=0) & (phase'=3) + 1/20 : (lastSeen'=1) & (phase'=3) + 1/20 : (lastSeen'=2) & (phase'=3) + 1/20 : (lastSeen'=3) & (phase'=3) + 1/20 : (lastSeen'=4) & (phase'=3) + 1/20 : (lastSeen'=5) & (phase'=3) + 1/20 : (lastSeen'=6) & (phase'=3) + 1/20 : (lastSeen'=7) & (phase'=3) + 1/20 : (lastSeen'=8) & (phase'=3) + 1/20 : (lastSeen'=9) & (phase'=3) + 1/20 : (lastSeen'=10) & (phase'=3) + 1/20 : (lastSeen'=11) & (phase'=3) + 1/20 : (lastSeen'=12) & (phase'=3) + 1/20 : (lastSeen'=13) & (phase'=3) + 1/20 : (lastSeen'=14) & (phase'=3) + 1/20 : (lastSeen'=15) & (phase'=3) + 1/20 : (lastSeen'=16) & (phase'=3) + 1/20 : (lastSeen'=17) & (phase'=3) + 1/20 : (lastSeen'=18) & (phase'=3) + 1/20 : (lastSeen'=19) & (phase'=3); - - // if the current member is a bad member, record the most recently seen index - [] phase=2 & !good & lastSeen=0 & observe0 < TotalRuns -> 1:(observe0'=observe0+1) & (phase'=4); - [] phase=2 & !good & lastSeen=1 & observe1 < TotalRuns -> 1:(observe1'=observe1+1) & (phase'=4); - [] phase=2 & !good & lastSeen=2 & observe2 < TotalRuns -> 1:(observe2'=observe2+1) & (phase'=4); - [] phase=2 & !good & lastSeen=3 & observe3 < TotalRuns -> 1:(observe3'=observe3+1) & (phase'=4); - [] phase=2 & !good & lastSeen=4 & observe4 < TotalRuns -> 1:(observe4'=observe4+1) & (phase'=4); - [] phase=2 & !good & lastSeen=5 & observe5 < TotalRuns -> 1:(observe5'=observe5+1) & (phase'=4); - [] phase=2 & !good & lastSeen=6 & observe6 < TotalRuns -> 1:(observe6'=observe6+1) & (phase'=4); - [] phase=2 & !good & lastSeen=7 & observe7 < TotalRuns -> 1:(observe7'=observe7+1) & (phase'=4); - [] phase=2 & !good & lastSeen=8 & observe8 < TotalRuns -> 1:(observe8'=observe8+1) & (phase'=4); - [] phase=2 & !good & lastSeen=9 & observe9 < TotalRuns -> 1:(observe9'=observe9+1) & (phase'=4); - [] phase=2 & !good & lastSeen=10 & observe10 < TotalRuns -> 1:(observe10'=observe10+1) & (phase'=4); - [] phase=2 & !good & lastSeen=11 & observe11 < TotalRuns -> 1:(observe11'=observe11+1) & (phase'=4); - [] phase=2 & !good & lastSeen=12 & observe12 < TotalRuns -> 1:(observe12'=observe12+1) & (phase'=4); - [] phase=2 & !good & lastSeen=13 & observe13 < TotalRuns -> 1:(observe13'=observe13+1) & (phase'=4); - [] phase=2 & !good & lastSeen=14 & observe14 < TotalRuns -> 1:(observe14'=observe14+1) & (phase'=4); - [] phase=2 & !good & lastSeen=15 & observe15 < TotalRuns -> 1:(observe15'=observe15+1) & (phase'=4); - [] phase=2 & !good & lastSeen=16 & observe16 < TotalRuns -> 1:(observe16'=observe16+1) & (phase'=4); - [] phase=2 & !good & lastSeen=17 & observe17 < TotalRuns -> 1:(observe17'=observe17+1) & (phase'=4); - [] phase=2 & !good & lastSeen=18 & observe18 < TotalRuns -> 1:(observe18'=observe18+1) & (phase'=4); - [] phase=2 & !good & lastSeen=19 & observe19 < TotalRuns -> 1:(observe19'=observe19+1) & (phase'=4); - - // good crowd members forward with probability PF and deliver otherwise - [] phase=3 -> PF : (phase'=1) + notPF : (phase'=4); - - // deliver the message and start over - [] phase=4 -> 1:(phase'=0); - -endmodule - -label "observe0Greater1" = observe0 > 1; -label "observeIGreater1" = observe1 > 1 | observe2 > 1 | observe3 > 1 | observe4 > 1 | observe5 > 1 | observe6 > 1 | observe7 > 1 | observe8 > 1 | observe9 > 1 | observe10 > 1 | observe11 > 1 | observe12 > 1 | observe13 > 1 | observe14 > 1 | observe15 > 1 | observe16 > 1 | observe17 > 1 | observe18 > 1 | observe19 > 1; -label "observeOnlyTrueSender" = observe0 > 1 & observe1 <= 1 & observe2 <= 1 & observe3 <= 1 & observe4 <= 1 & observe5 <= 1 & observe6 <= 1 & observe7 <= 1 & observe8 <= 1 & observe9 <= 1 & observe10 <= 1 & observe11 <= 1 & observe12 <= 1 & observe13 <= 1 & observe14 <= 1 & observe15 <= 1 & observe16 <= 1 & observe17 <= 1 & observe18 <= 1 & observe19 <= 1; - diff --git a/examples/dtmc/die/die.pctl b/examples/dtmc/die/die.pctl deleted file mode 100644 index 8deea6c43..000000000 --- a/examples/dtmc/die/die.pctl +++ /dev/null @@ -1,4 +0,0 @@ -P=? [ F one ] -P=? [ F two ] -P=? [ F three ] -R=? [ F done ] diff --git a/examples/dtmc/die/die.pm b/examples/dtmc/die/die.pm deleted file mode 100644 index dacde8a79..000000000 --- a/examples/dtmc/die/die.pm +++ /dev/null @@ -1,31 +0,0 @@ -// Knuth's model of a fair die using only fair coins -dtmc - -module die - - // local state - s : [0..7] init 0; - // value of the dice - d : [0..6] init 0; - - [] s=0 -> 0.5 : (s'=1) + 0.5 : (s'=2); - [] s=1 -> 0.5 : (s'=3) + 0.5 : (s'=4); - [] s=2 -> 0.5 : (s'=5) + 0.5 : (s'=6); - [] s=3 -> 0.5 : (s'=1) + 0.5 : (s'=7) & (d'=1); - [] s=4 -> 0.5 : (s'=7) & (d'=2) + 0.5 : (s'=7) & (d'=3); - [] s=5 -> 0.5 : (s'=7) & (d'=4) + 0.5 : (s'=7) & (d'=5); - [] s=6 -> 0.5 : (s'=2) + 0.5 : (s'=7) & (d'=6); - [] s=7 -> 1: (s'=7); - -endmodule - -rewards "coin_flips" - [] s<7 : 1; -endrewards - -label "one" = s=7&d=1; -label "two" = s=7&d=2; -label "three" = s=7&d=3; -label "four" = s=7&d=4; -label "five" = s=7&d=5; -label "six" = s=7&d=6; diff --git a/examples/dtmc/die/die.res b/examples/dtmc/die/die.res deleted file mode 100644 index 003af5dbd..000000000 --- a/examples/dtmc/die/die.res +++ /dev/null @@ -1,4 +0,0 @@ -P=? [ F "one" ] // 0.16666650772094727 -P=? [ F "two" ] // 0.16666650772094727 -P=? [ F "three" ] // 0.16666650772094727 -R=? [ F "done" ] // 3.6666650772094727 diff --git a/examples/dtmc/nand/nand.pm b/examples/dtmc/nand/nand.pm deleted file mode 100644 index 9753f1552..000000000 --- a/examples/dtmc/nand/nand.pm +++ /dev/null @@ -1,76 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N; // number of inputs in each bundle -const int K; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr = 0.02; // probability nand works correctly -const double prob1 = 0.9; // probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -// rewards: final value of gate -rewards - // [] s=0 & (c=N) & (u=M) : z/N; - s=0 & (c=N) & (u=M) : z/N; -endrewards - -label "target" = s=4 & z/N<0.1; -label "end" = s=4; diff --git a/examples/dtmc/sync/sync.pm b/examples/dtmc/sync/sync.pm deleted file mode 100644 index 8bc7f94ce..000000000 --- a/examples/dtmc/sync/sync.pm +++ /dev/null @@ -1,22 +0,0 @@ -// A simple model using synchronization -dtmc - -module generator - - s : [0..2] init 0; - - [] s=0 -> 0.2 : (s'=1) + 0.8 : (s'=0); - [yield] s=1 -> 1 : (s'=2); - [] s=2 -> 0.5 : (s'=0) + 0.5 : (s'=2); - -endmodule - -module consumer - - t : [0..2] init 0; - - [] t=0 -> 0.8 : (t'=1) + 0.2 : (t'=0); - [yield] t=1 -> 1 : (t'=2); - [] t=2 -> 0.2 : (t'=0) + 0.8 : (t'=2); - -endmodule diff --git a/examples/dtmc/synchronous_leader/leader.pctl b/examples/dtmc/synchronous_leader/leader.pctl deleted file mode 100644 index c4eb53408..000000000 --- a/examples/dtmc/synchronous_leader/leader.pctl +++ /dev/null @@ -1,4 +0,0 @@ -P=? [ F elected ] -// P=? [ F<=(4*(N+1)) elected ] -P=? [ F<=28 elected ] -R=? [ F elected ] diff --git a/examples/dtmc/synchronous_leader/leader.res b/examples/dtmc/synchronous_leader/leader.res deleted file mode 100644 index 26451a894..000000000 --- a/examples/dtmc/synchronous_leader/leader.res +++ /dev/null @@ -1,14 +0,0 @@ -// 3/5 -P=? [ F "elected" ] // 1.0 -P=? [ F<=(4*(N+1)) "elected" ] // 0.999997440000001 -R=? [ F "elected" ] // 1.0416666623999995 - -// 4/8 -P=? [ F "elected" ] // 1.0 -P=? [ F<=(4*(N+1)) "elected" ] // 0.9999965911265463 -R=? [ F "elected" ] // 1.0448979526072435 - -// 5/8 -P=? [ F "elected" ] // 1.0 -P=? [ F<=(4*(N+1)) "elected" ] // 0.9999999097195733 -R=? [ F "elected" ] // 1.0176397499602707 \ No newline at end of file diff --git a/examples/dtmc/synchronous_leader/leader4_8.pm b/examples/dtmc/synchronous_leader/leader4_8.pm deleted file mode 100644 index 188039cf3..000000000 --- a/examples/dtmc/synchronous_leader/leader4_8.pm +++ /dev/null @@ -1,89 +0,0 @@ -// synchronous leader election protocol (itai & Rodeh) -// dxp/gxn 25/01/01 - -dtmc - -// CONSTANTS -const int N = 4; // number of processes -const int K = 8; // range of probabilistic choice - -// counter module used to count the number of processes that have been read -// and to know when a process has decided -module counter - - // counter (c=i means process j reading process (i-1)+j next) - c : [1..N-1]; - - // reading - [read] c (c'=c+1); - // finished reading - [read] c=N-1 -> (c'=c); - //decide - [done] u1|u2|u3|u4 -> (c'=c); - // pick again reset counter - [retry] !(u1|u2|u3|u4) -> (c'=1); - // loop (when finished to avoid deadlocks) - [loop] s1=3 -> (c'=c); - -endmodule - -// processes form a ring and suppose: -// process 1 reads process 2 -// process 2 reads process 3 -// process 3 reads process 1 -module process1 - - // local state - s1 : [0..3]; - // s1=0 make random choice - // s1=1 reading - // s1=2 deciding - // s1=3 finished - - // has a unique id so far (initially true) - u1 : bool; - - // value to be sent to next process in the ring (initially sets this to its own value) - v1 : [0..K-1]; - - // random choice - p1 : [0..K-1]; - - // pick value - [pick] s1=0 -> 1/K : (s1'=1) & (p1'=0) & (v1'=0) & (u1'=true) - + 1/K : (s1'=1) & (p1'=1) & (v1'=1) & (u1'=true) - + 1/K : (s1'=1) & (p1'=2) & (v1'=2) & (u1'=true) - + 1/K : (s1'=1) & (p1'=3) & (v1'=3) & (u1'=true) - + 1/K : (s1'=1) & (p1'=4) & (v1'=4) & (u1'=true) - + 1/K : (s1'=1) & (p1'=5) & (v1'=5) & (u1'=true) - + 1/K : (s1'=1) & (p1'=6) & (v1'=6) & (u1'=true) - + 1/K : (s1'=1) & (p1'=7) & (v1'=7) & (u1'=true); - // read - [read] s1=1 & u1 & c (u1'=(p1!=v2)) & (v1'=v2); - [read] s1=1 & !u1 & c (u1'=false) & (v1'=v2) & (p1'=0); - // read and move to decide - [read] s1=1 & u1 & c=N-1 -> (s1'=2) & (u1'=(p1!=v2)) & (v1'=0) & (p1'=0); - [read] s1=1 & !u1 & c=N-1 -> (s1'=2) & (u1'=false) & (v1'=0); - // deciding - // done - [done] s1=2 -> (s1'=3) & (u1'=false) & (v1'=0) & (p1'=0); - //retry - [retry] s1=2 -> (s1'=0) & (u1'=false) & (v1'=0) & (p1'=0); - // loop (when finished to avoid deadlocks) - [loop] s1=3 -> (s1'=3); - -endmodule - -// construct remaining processes through renaming -module process2 = process1 [ s1=s2,p1=p2,v1=v2,u1=u2,v2=v3 ] endmodule -module process3 = process1 [ s1=s3,p1=p3,v1=v3,u1=u3,v2=v4 ] endmodule -module process4 = process1 [ s1=s4,p1=p4,v1=v4,u1=u4,v2=v1 ] endmodule - -// expected number of rounds -rewards "num_rounds" - [pick] true : 1; -endrewards - -// labels -label "elected" = s1=3&s2=3&s3=3&s4=3; - diff --git a/examples/dtmc/synchronous_leader/leader5_8.pm b/examples/dtmc/synchronous_leader/leader5_8.pm deleted file mode 100644 index 4723ed5b0..000000000 --- a/examples/dtmc/synchronous_leader/leader5_8.pm +++ /dev/null @@ -1,90 +0,0 @@ -// synchronous leader election protocol (itai & Rodeh) -// dxp/gxn 25/01/01 - -dtmc - -// CONSTANTS -const int N = 5; // number of processes -const int K = 8; // range of probabilistic choice - -// counter module used to count the number of processes that have been read -// and to know when a process has decided -module counter - - // counter (c=i means process j reading process (i-1)+j next) - c : [1..N-1]; - - // reading - [read] c (c'=c+1); - // finished reading - [read] c=N-1 -> (c'=c); - //decide - [done] u1|u2|u3|u4|u5 -> (c'=c); - // pick again reset counter - [retry] !(u1|u2|u3|u4|u5) -> (c'=1); - // loop (when finished to avoid deadlocks) - [loop] s1=3 -> (c'=c); - -endmodule - -// processes form a ring and suppose: -// process 1 reads process 2 -// process 2 reads process 3 -// process 3 reads process 1 -module process1 - - // local state - s1 : [0..3]; - // s1=0 make random choice - // s1=1 reading - // s1=2 deciding - // s1=3 finished - - // has a unique id so far (initially true) - u1 : bool; - - // value to be sent to next process in the ring (initially sets this to its own value) - v1 : [0..K-1]; - - // random choice - p1 : [0..K-1]; - - // pick value - [pick] s1=0 -> 1/K : (s1'=1) & (p1'=0) & (v1'=0) & (u1'=true) - + 1/K : (s1'=1) & (p1'=1) & (v1'=1) & (u1'=true) - + 1/K : (s1'=1) & (p1'=2) & (v1'=2) & (u1'=true) - + 1/K : (s1'=1) & (p1'=3) & (v1'=3) & (u1'=true) - + 1/K : (s1'=1) & (p1'=4) & (v1'=4) & (u1'=true) - + 1/K : (s1'=1) & (p1'=5) & (v1'=5) & (u1'=true) - + 1/K : (s1'=1) & (p1'=6) & (v1'=6) & (u1'=true) - + 1/K : (s1'=1) & (p1'=7) & (v1'=7) & (u1'=true); - // read - [read] s1=1 & u1 & c (u1'=(p1!=v2)) & (v1'=v2); - [read] s1=1 & !u1 & c (u1'=false) & (v1'=v2) & (p1'=0); - // read and move to decide - [read] s1=1 & u1 & c=N-1 -> (s1'=2) & (u1'=(p1!=v2)) & (v1'=0) & (p1'=0); - [read] s1=1 & !u1 & c=N-1 -> (s1'=2) & (u1'=false) & (v1'=0); - // deciding - // done - [done] s1=2 -> (s1'=3) & (u1'=false) & (v1'=0) & (p1'=0); - //retry - [retry] s1=2 -> (s1'=0) & (u1'=false) & (v1'=0) & (p1'=0); - // loop (when finished to avoid deadlocks) - [loop] s1=3 -> (s1'=3); - -endmodule - -// construct remaining processes through renaming -module process2 = process1 [ s1=s2,p1=p2,v1=v2,u1=u2,v2=v3 ] endmodule -module process3 = process1 [ s1=s3,p1=p3,v1=v3,u1=u3,v2=v4 ] endmodule -module process4 = process1 [ s1=s4,p1=p4,v1=v4,u1=u4,v2=v5 ] endmodule -module process5 = process1 [ s1=s5,p1=p5,v1=v5,u1=u5,v2=v1 ] endmodule - -// expected number of rounds -rewards "num_rounds" - [pick] true : 1; -endrewards - -// labels -label "elected" = s1=3&s2=3&s3=3&s4=3&s5=3; - diff --git a/examples/dtmc/synchronous_leader/leader6_8.pm b/examples/dtmc/synchronous_leader/leader6_8.pm deleted file mode 100644 index a31773b1d..000000000 --- a/examples/dtmc/synchronous_leader/leader6_8.pm +++ /dev/null @@ -1,91 +0,0 @@ -// synchronous leader election protocol (itai & Rodeh) -// dxp/gxn 25/01/01 - -dtmc - -// CONSTANTS -const int N = 6; // number of processes -const int K = 8; // range of probabilistic choice - -// counter module used to count the number of processes that have been read -// and to know when a process has decided -module counter - - // counter (c=i means process j reading process (i-1)+j next) - c : [1..N-1]; - - // reading - [read] c (c'=c+1); - // finished reading - [read] c=N-1 -> (c'=c); - //decide - [done] u1|u2|u3|u4|u5|u6 -> (c'=c); - // pick again reset counter - [retry] !(u1|u2|u3|u4|u5|u6) -> (c'=1); - // loop (when finished to avoid deadlocks) - [loop] s1=3 -> (c'=c); - -endmodule - -// processes form a ring and suppose: -// process 1 reads process 2 -// process 2 reads process 3 -// process 3 reads process 1 -module process1 - - // local state - s1 : [0..3]; - // s1=0 make random choice - // s1=1 reading - // s1=2 deciding - // s1=3 finished - - // has a unique id so far (initially true) - u1 : bool; - - // value to be sent to next process in the ring (initially sets this to its own value) - v1 : [0..K-1]; - - // random choice - p1 : [0..K-1]; - - // pick value - [pick] s1=0 -> 1/K : (s1'=1) & (p1'=0) & (v1'=0) & (u1'=true) - + 1/K : (s1'=1) & (p1'=1) & (v1'=1) & (u1'=true) - + 1/K : (s1'=1) & (p1'=2) & (v1'=2) & (u1'=true) - + 1/K : (s1'=1) & (p1'=3) & (v1'=3) & (u1'=true) - + 1/K : (s1'=1) & (p1'=4) & (v1'=4) & (u1'=true) - + 1/K : (s1'=1) & (p1'=5) & (v1'=5) & (u1'=true) - + 1/K : (s1'=1) & (p1'=6) & (v1'=6) & (u1'=true) - + 1/K : (s1'=1) & (p1'=7) & (v1'=7) & (u1'=true); - // read - [read] s1=1 & u1 & c (u1'=(p1!=v2)) & (v1'=v2); - [read] s1=1 & !u1 & c (u1'=false) & (v1'=v2) & (p1'=0); - // read and move to decide - [read] s1=1 & u1 & c=N-1 -> (s1'=2) & (u1'=(p1!=v2)) & (v1'=0) & (p1'=0); - [read] s1=1 & !u1 & c=N-1 -> (s1'=2) & (u1'=false) & (v1'=0); - // deciding - // done - [done] s1=2 -> (s1'=3) & (u1'=false) & (v1'=0) & (p1'=0); - //retry - [retry] s1=2 -> (s1'=0) & (u1'=false) & (v1'=0) & (p1'=0); - // loop (when finished to avoid deadlocks) - [loop] s1=3 -> (s1'=3); - -endmodule - -// construct remaining processes through renaming -module process2 = process1 [ s1=s2,p1=p2,v1=v2,u1=u2,v2=v3 ] endmodule -module process3 = process1 [ s1=s3,p1=p3,v1=v3,u1=u3,v2=v4 ] endmodule -module process4 = process1 [ s1=s4,p1=p4,v1=v4,u1=u4,v2=v5 ] endmodule -module process5 = process1 [ s1=s5,p1=p5,v1=v5,u1=u5,v2=v6 ] endmodule -module process6 = process1 [ s1=s6,p1=p6,v1=v6,u1=u6,v2=v1 ] endmodule - -// expected number of rounds -rewards "num_rounds" - [pick] true : 1; -endrewards - -// labels -label "elected" = s1=3&s2=3&s3=3&s4=3&s5=3&s6=3; - diff --git a/examples/dtmc/tiny_lra/tiny_lra.pctl b/examples/dtmc/tiny_lra/tiny_lra.pctl deleted file mode 100644 index 27700ade2..000000000 --- a/examples/dtmc/tiny_lra/tiny_lra.pctl +++ /dev/null @@ -1 +0,0 @@ -LRA=? [ "a" ] \ No newline at end of file diff --git a/examples/dtmc/tiny_lra/tiny_lra.pm b/examples/dtmc/tiny_lra/tiny_lra.pm deleted file mode 100644 index 0d49f8d3c..000000000 --- a/examples/dtmc/tiny_lra/tiny_lra.pm +++ /dev/null @@ -1,16 +0,0 @@ -// tiny LRA example - -dtmc - -module main - - s : [0..2] init 0; - - [] s=0 -> 1:(s'=1); - [] s=1 -> 0.5:(s'=1) + 0.5:(s'=2); - [] s=2 -> 0.5:(s'=1) + 0.5:(s'=2); - -endmodule - -label "a" = s=1; - diff --git a/examples/jani-examples/beb.jani b/examples/jani-examples/beb.jani deleted file mode 100755 index df2d43c66..000000000 --- a/examples/jani-examples/beb.jani +++ /dev/null @@ -1,2604 +0,0 @@ -{ - "jani-version": 1, - "name": "modelName", - "type": "mdp", - "actions": [ - { - "name": "tick" - }, - { - "name": "tack" - }, - { - "name": "tock" - } - ], - "variables": [ - { - "name": "cr", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 2 - }, - "initial-value": 0 - }, - { - "name": "line_seized", - "type": "bool", - "initial-value": false - }, - { - "name": "gave_up", - "type": "bool", - "initial-value": false - } - ], - "properties": [ - { - "name": "LineSeized", - "reach": "line_seized", - "type": "probability-max-query" - }, - { - "name": "GaveUp", - "reach": "gave_up", - "type": "probability-max-query" - } - ], - "automata": [ - { - "name": "Clock", - "variables": [], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_1" - } - ] - }, - { - "location": "l_1", - "action": "tack", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_2" - } - ] - }, - { - "location": "l_2", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "cr", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "tock", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0" - } - ] - } - ] - }, - { - "name": "Host", - "variables": [ - { - "name": "na", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 3 - }, - "initial-value": 0 - }, - { - "name": "ev", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 4 - }, - "initial-value": 2 - }, - { - "name": "wt", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 4 - }, - "initial-value": 0 - } - ], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - }, - { - "name": "l_4" - }, - { - "name": "l_5" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "action": "tick", - "guard": { - "op": ">", - "args": [ - "wt", - 0 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "wt", - "value": { - "op": "-", - "args": [ - "wt", - 1 - ] - } - } - ] - } - ] - }, - { - "location": "l_0", - "guard": { - "op": "≤", - "args": [ - "wt", - 0 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "cr", - "value": { - "op": "min", - "args": [ - 2, - { - "op": "+", - "args": [ - "cr", - 1 - ] - } - ] - } - } - ] - } - ] - }, - { - "location": "l_1", - "action": "tack", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3" - } - ] - }, - { - "location": "l_2", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_4" - } - ] - }, - { - "location": "l_3", - "action": "tock", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0" - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "=", - "args": [ - "cr", - 1 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_5", - "assignments": [ - { - "ref": "line_seized", - "value": true - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "≥", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_5", - "assignments": [ - { - "ref": "gave_up", - "value": true - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 0 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 1 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 1 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 2 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 3 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 3 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 1 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 3 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 2 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 3 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 1 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 2 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 3 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - } - ] - }, - { - "name": "Host_1", - "variables": [ - { - "name": "na", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 3 - }, - "initial-value": 0 - }, - { - "name": "ev", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 4 - }, - "initial-value": 2 - }, - { - "name": "wt", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 4 - }, - "initial-value": 0 - } - ], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - }, - { - "name": "l_4" - }, - { - "name": "l_5" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "action": "tick", - "guard": { - "op": ">", - "args": [ - "wt", - 0 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "wt", - "value": { - "op": "-", - "args": [ - "wt", - 1 - ] - } - } - ] - } - ] - }, - { - "location": "l_0", - "guard": { - "op": "≤", - "args": [ - "wt", - 0 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "cr", - "value": { - "op": "min", - "args": [ - 2, - { - "op": "+", - "args": [ - "cr", - 1 - ] - } - ] - } - } - ] - } - ] - }, - { - "location": "l_1", - "action": "tack", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3" - } - ] - }, - { - "location": "l_2", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_4" - } - ] - }, - { - "location": "l_3", - "action": "tock", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0" - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "=", - "args": [ - "cr", - 1 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_5", - "assignments": [ - { - "ref": "line_seized", - "value": true - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "≥", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_5", - "assignments": [ - { - "ref": "gave_up", - "value": true - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 0 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 1 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 1 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 2 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 3 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 3 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 1 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 3 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 2 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 3 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 1 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 2 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 3 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - } - ] - }, - { - "name": "Host_2", - "variables": [ - { - "name": "na", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 3 - }, - "initial-value": 0 - }, - { - "name": "ev", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 4 - }, - "initial-value": 2 - }, - { - "name": "wt", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 4 - }, - "initial-value": 0 - } - ], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - }, - { - "name": "l_4" - }, - { - "name": "l_5" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "action": "tick", - "guard": { - "op": ">", - "args": [ - "wt", - 0 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "wt", - "value": { - "op": "-", - "args": [ - "wt", - 1 - ] - } - } - ] - } - ] - }, - { - "location": "l_0", - "guard": { - "op": "≤", - "args": [ - "wt", - 0 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "cr", - "value": { - "op": "min", - "args": [ - 2, - { - "op": "+", - "args": [ - "cr", - 1 - ] - } - ] - } - } - ] - } - ] - }, - { - "location": "l_1", - "action": "tack", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3" - } - ] - }, - { - "location": "l_2", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_4" - } - ] - }, - { - "location": "l_3", - "action": "tock", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0" - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "=", - "args": [ - "cr", - 1 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_5", - "assignments": [ - { - "ref": "line_seized", - "value": true - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "≥", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_5", - "assignments": [ - { - "ref": "gave_up", - "value": true - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 0 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 1 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 1 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 2 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 3 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 3 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 1 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 3 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 2 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - }, - { - "location": "l_4", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "na", - 3 - ] - }, - { - "op": "≠", - "args": [ - "cr", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - { - "op": "max", - "args": [ - 0, - { - "op": "-", - "args": [ - "ev", - 1 - ] - } - ] - }, - 3 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 0 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 1 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 2 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 4 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "na", - "value": { - "op": "+", - "args": [ - "na", - 1 - ] - } - }, - { - "ref": "wt", - "value": 3 - }, - { - "ref": "ev", - "value": { - "op": "min", - "args": [ - { - "op": "*", - "args": [ - 2, - "ev" - ] - }, - 4 - ] - } - } - ] - } - ] - } - ] - } - ], - "system": { - "composition": "parallel", - "elements": [ - { - "composition": "parallel", - "elements": [ - { - "composition": "parallel", - "elements": [ - "Clock", - "Host" - ], - "alphabet": [ - "tick", - "tack", - "tock" - ] - }, - "Host_1" - ], - "alphabet": [ - "tick", - "tack", - "tock" - ] - }, - "Host_2" - ], - "alphabet": [ - "tick", - "tack", - "tock" - ] - } -} \ No newline at end of file diff --git a/examples/jani-examples/beb.jani.txt b/examples/jani-examples/beb.jani.txt deleted file mode 100755 index ca4a540d1..000000000 --- a/examples/jani-examples/beb.jani.txt +++ /dev/null @@ -1,27 +0,0 @@ -Peak memory usage: 38 MB -Analysis results for beb.jani - -+ State space exploration - States: 4528 - Transitions: 4874 - Branches: 6899 - Time: 0.0 s - Rate: 92408 states/s - -+ LineSeized - Probability: 0.9166259765625 - Time: 0.1 s - - + Value iteration - Final error: 0 - Iterations: 8 - Time: 0.0 s - -+ GaveUp - Probability: 0.0833740234375 - Time: 0.0 s - - + Value iteration - Final error: 0 - Iterations: 9 - Time: 0.0 s diff --git a/examples/jani-examples/beb.modest b/examples/jani-examples/beb.modest deleted file mode 100755 index 44f06b30e..000000000 --- a/examples/jani-examples/beb.modest +++ /dev/null @@ -1,64 +0,0 @@ -// Modest MDP model of the bounded exponential backoff procedure (BEB) -// [BFHH11] -action tick, tack, tock; - -const int K = 4; // maximum value for backoff -const int N = 3; // number of tries before giving up -const int H = 3; // number of hosts (must correspond to the number of Host() instantiations in the global composition) - -int(0..2) cr; // count how many hosts attempt to seize the line in a slot (zero, one, many) -bool line_seized; -bool gave_up; - -property LineSeized = Pmax(<> line_seized); // some host managed to seize the line before any other gave up -property GaveUp = Pmax(<> gave_up); // some host gave up before any other managed to seize the line (does not work with POR) - -process Clock() -{ - tick; tack; tau {= cr = 0 =}; tock; Clock() -} - -process Host() -{ - int(0..N) na; // nr_attempts 0..N - int(0..K) ev = 2; // exp_val 0..K - int(0..K) wt; // slots_to_wait 0..K - - do - { - if(wt > 0) - { - // wait this slot - tick {= wt-- =} - } - else - { - tau {= cr = min(2, cr + 1) =}; // attempt to seize the line - tick; - if(cr == 1) - { - // someone managed to seize the line - tau {= line_seized = true =}; stop - } - else if(na >= N) - { - // maximum number of attempts exceeded - tau {= gave_up = true =}; stop - } - else - { - // backoff - tau {= na++, wt = DiscreteUniform(0, max(0, ev - 1)), ev = min(2 * ev, K) =} - } - }; - tack; tock - } -} - -par -{ -:: Clock() -:: Host() -:: Host() -:: Host() -} diff --git a/examples/jani-examples/beb.modest.txt b/examples/jani-examples/beb.modest.txt deleted file mode 100755 index cbaee0f3d..000000000 --- a/examples/jani-examples/beb.modest.txt +++ /dev/null @@ -1,27 +0,0 @@ -Peak memory usage: 39 MB -Analysis results for beb.modest - -+ State space exploration - States: 4528 - Transitions: 4874 - Branches: 6899 - Time: 0.0 s - Rate: 94333 states/s - -+ LineSeized - Probability: 0.9166259765625 - Time: 0.1 s - - + Value iteration - Final error: 0 - Iterations: 8 - Time: 0.0 s - -+ GaveUp - Probability: 0.0833740234375 - Time: 0.0 s - - + Value iteration - Final error: 0 - Iterations: 9 - Time: 0.0 s diff --git a/examples/jani-examples/brp.jani b/examples/jani-examples/brp.jani deleted file mode 100755 index bd5d91a38..000000000 --- a/examples/jani-examples/brp.jani +++ /dev/null @@ -1,2092 +0,0 @@ -{ - "jani-version": 1, - "name": "modelName", - "type": "mdp", - "actions": [ - { - "name": "put" - }, - { - "name": "get" - }, - { - "name": "put_k" - }, - { - "name": "get_k" - }, - { - "name": "put_l" - }, - { - "name": "get_l" - }, - { - "name": "new_file" - }, - { - "name": "s_ok" - }, - { - "name": "s_dk" - }, - { - "name": "s_nok" - }, - { - "name": "s_restart" - }, - { - "name": "r_ok" - }, - { - "name": "r_inc" - }, - { - "name": "r_fst" - }, - { - "name": "r_nok" - }, - { - "name": "r_timeout" - }, - { - "name": "error" - }, - { - "name": "tick" - } - ], - "variables": [ - { - "name": "ff", - "type": "bool", - "initial-value": false - }, - { - "name": "lf", - "type": "bool", - "initial-value": false - }, - { - "name": "ab", - "type": "bool", - "initial-value": false - }, - { - "name": "i", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 16 - }, - "initial-value": 0 - }, - { - "name": "inTransitK", - "type": "bool", - "initial-value": false - }, - { - "name": "inTransitL", - "type": "bool", - "initial-value": false - }, - { - "name": "first_file_done", - "type": "bool", - "initial-value": false - }, - { - "name": "get_k_seen", - "type": "bool", - "initial-value": false - }, - { - "name": "s_ok_seen", - "type": "bool", - "initial-value": false - }, - { - "name": "s_nok_seen", - "type": "bool", - "initial-value": false - }, - { - "name": "s_dk_seen", - "type": "bool", - "initial-value": false - }, - { - "name": "s_restart_seen", - "type": "bool", - "initial-value": false - }, - { - "name": "r_ok_seen", - "type": "bool", - "initial-value": false - }, - { - "name": "r_timeout_seen", - "type": "bool", - "initial-value": false - }, - { - "name": "premature_timeout", - "type": "bool", - "initial-value": false - }, - { - "name": "channel_k_overflow", - "type": "bool", - "initial-value": false - }, - { - "name": "channel_l_overflow", - "type": "bool", - "initial-value": false - }, - { - "name": "Sender_location", - "type": "int", - "initial-value": 0 - }, - { - "name": "Receiver_location", - "type": "int", - "initial-value": 0 - }, - { - "name": "ChannelK_location", - "type": "int", - "initial-value": 0 - }, - { - "name": "ChannelL_location", - "type": "int", - "initial-value": 0 - }, - { - "name": "Observer_location", - "type": "int", - "initial-value": 0 - } - ], - "properties": [ - { - "name": "P_A", - "reach": { - "op": "∧", - "args": [ - "s_nok_seen", - "r_ok_seen" - ] - }, - "type": "probability-max-query" - }, - { - "name": "P_B", - "reach": { - "op": "∧", - "args": [ - "s_ok_seen", - { - "op": "!", - "args": [ - "r_ok_seen" - ] - } - ] - }, - "type": "probability-max-query" - }, - { - "name": "P_1", - "reach": { - "op": "∨", - "args": [ - "s_nok_seen", - "s_dk_seen" - ] - }, - "type": "probability-max-query" - }, - { - "name": "P_2", - "reach": "s_dk_seen", - "type": "probability-max-query" - }, - { - "name": "P_3", - "reach": { - "op": "∧", - "args": [ - "s_nok_seen", - { - "op": ">", - "args": [ - "i", - 8 - ] - } - ] - }, - "type": "probability-max-query" - }, - { - "name": "P_4", - "reach": { - "op": "∧", - "args": [ - { - "op": "∨", - "args": [ - { - "op": "∨", - "args": [ - "s_ok_seen", - "s_nok_seen" - ] - }, - "s_dk_seen" - ] - }, - { - "op": "!", - "args": [ - "get_k_seen" - ] - } - ] - }, - "type": "probability-max-query" - } - ], - "automata": [ - { - "name": "Sender", - "variables": [ - { - "name": "bit", - "type": "bool", - "initial-value": false - }, - { - "name": "rc", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 2 - }, - "initial-value": 0 - }, - { - "name": "c", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 16 - }, - "initial-value": 0 - } - ], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - }, - { - "name": "l_4" - }, - { - "name": "l_5" - }, - { - "name": "l_6" - }, - { - "name": "l_7" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "guard": { - "op": "<", - "args": [ - "i", - 16 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "i", - "value": { - "op": "+", - "args": [ - "i", - 1 - ] - } - }, - { - "ref": "Sender_location", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "s_ok", - "guard": { - "op": "=", - "args": [ - "i", - 16 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "first_file_done", - "value": true - }, - { - "ref": "Sender_location", - "value": 2 - }, - { - "ref": "c", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "tick", - "guard": { - "op": "∧", - "args": [ - { - "op": "≥", - "args": [ - "i", - 16 - ] - }, - { - "op": "<", - "args": [ - "c", - 0 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "c", - "value": { - "op": "min", - "args": [ - { - "op": "+", - "args": [ - "c", - 1 - ] - }, - 16 - ] - } - } - ] - } - ] - }, - { - "location": "l_1", - "action": "put_k", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "ff", - "value": { - "op": "=", - "args": [ - "i", - 1 - ] - } - }, - { - "ref": "lf", - "value": { - "op": "=", - "args": [ - "i", - 16 - ] - } - }, - { - "ref": "ab", - "value": "bit" - }, - { - "ref": "c", - "value": 0 - }, - { - "ref": "Sender_location", - "value": 3 - } - ] - } - ] - }, - { - "location": "l_1", - "action": "tick", - "guard": { - "op": "<", - "args": [ - "c", - 0 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "c", - "value": { - "op": "min", - "args": [ - { - "op": "+", - "args": [ - "c", - 1 - ] - }, - 16 - ] - } - } - ] - } - ] - }, - { - "location": "l_2", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_4", - "assignments": [ - { - "ref": "Sender_location", - "value": 4 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "get_l", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_5", - "assignments": [ - { - "ref": "bit", - "value": { - "op": "!", - "args": [ - "bit" - ] - } - }, - { - "ref": "rc", - "value": 0 - }, - { - "ref": "c", - "value": 0 - }, - { - "ref": "Sender_location", - "value": 5 - } - ] - } - ] - }, - { - "location": "l_3", - "guard": { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "rc", - 2 - ] - }, - { - "op": "≥", - "args": [ - "c", - 3 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "rc", - "value": { - "op": "+", - "args": [ - "rc", - 1 - ] - } - }, - { - "ref": "c", - "value": 0 - }, - { - "ref": "Sender_location", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "s_nok", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "<", - "args": [ - "i", - 16 - ] - }, - { - "op": "≥", - "args": [ - "rc", - 2 - ] - } - ] - }, - { - "op": "≥", - "args": [ - "c", - 3 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_6", - "assignments": [ - { - "ref": "rc", - "value": 0 - }, - { - "ref": "c", - "value": 0 - }, - { - "ref": "Sender_location", - "value": 6 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "s_dk", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "≥", - "args": [ - "i", - 16 - ] - }, - { - "op": "≥", - "args": [ - "rc", - 2 - ] - } - ] - }, - { - "op": "≥", - "args": [ - "c", - 3 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_6", - "assignments": [ - { - "ref": "rc", - "value": 0 - }, - { - "ref": "c", - "value": 0 - }, - { - "ref": "Sender_location", - "value": 6 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "tick", - "guard": { - "op": "<", - "args": [ - "c", - 3 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "c", - "value": { - "op": "min", - "args": [ - { - "op": "+", - "args": [ - "c", - 1 - ] - }, - 16 - ] - } - } - ] - } - ] - }, - { - "location": "l_4", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_4" - } - ] - }, - { - "location": "l_5", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "Sender_location", - "value": 7 - } - ] - } - ] - }, - { - "location": "l_6", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_7", - "assignments": [ - { - "ref": "Sender_location", - "value": 8 - } - ] - } - ] - }, - { - "location": "l_7", - "action": "s_restart", - "guard": { - "op": "≥", - "args": [ - "c", - 15 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_4", - "assignments": [ - { - "ref": "bit", - "value": false - }, - { - "ref": "first_file_done", - "value": true - }, - { - "ref": "Sender_location", - "value": 4 - }, - { - "ref": "c", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_7", - "action": "tick", - "guard": { - "op": "<", - "args": [ - "c", - 15 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_7", - "assignments": [ - { - "ref": "c", - "value": { - "op": "min", - "args": [ - { - "op": "+", - "args": [ - "c", - 1 - ] - }, - 16 - ] - } - } - ] - } - ] - } - ] - }, - { - "name": "Receiver", - "variables": [ - { - "name": "r_ff", - "type": "bool", - "initial-value": false - }, - { - "name": "r_lf", - "type": "bool", - "initial-value": false - }, - { - "name": "r_ab", - "type": "bool", - "initial-value": false - }, - { - "name": "bit", - "type": "bool", - "initial-value": false - }, - { - "name": "c", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 16 - }, - "initial-value": 0 - } - ], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - }, - { - "name": "l_4" - }, - { - "name": "l_5" - }, - { - "name": "l_6" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "action": "get_k", - "guard": "ff", - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "c", - "value": 0 - }, - { - "ref": "bit", - "value": "ab" - }, - { - "ref": "r_ff", - "value": "ff" - }, - { - "ref": "r_lf", - "value": "lf" - }, - { - "ref": "r_ab", - "value": "ab" - }, - { - "ref": "Receiver_location", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "get_k", - "guard": { - "op": "!", - "args": [ - "ff" - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "premature_timeout", - "value": true - }, - { - "ref": "Receiver_location", - "value": 2 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0" - } - ] - }, - { - "location": "l_1", - "action": "put_l", - "guard": { - "op": "≠", - "args": [ - "r_ab", - "bit" - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "Receiver_location", - "value": 3 - } - ] - } - ] - }, - { - "location": "l_1", - "action": "r_ok", - "guard": { - "op": "∧", - "args": [ - "r_lf", - { - "op": "=", - "args": [ - "r_ab", - "bit" - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_4", - "assignments": [ - { - "ref": "Receiver_location", - "value": 4 - } - ] - } - ] - }, - { - "location": "l_1", - "action": "r_fst", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - "r_ff", - { - "op": "!", - "args": [ - "r_lf" - ] - } - ] - }, - { - "op": "=", - "args": [ - "r_ab", - "bit" - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_4", - "assignments": [ - { - "ref": "Receiver_location", - "value": 4 - } - ] - } - ] - }, - { - "location": "l_1", - "action": "r_inc", - "guard": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "!", - "args": [ - "r_ff" - ] - }, - { - "op": "!", - "args": [ - "r_lf" - ] - } - ] - }, - { - "op": "=", - "args": [ - "r_ab", - "bit" - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_4", - "assignments": [ - { - "ref": "Receiver_location", - "value": 4 - } - ] - } - ] - }, - { - "location": "l_1", - "action": "tick", - "guard": { - "op": "<", - "args": [ - "c", - 0 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "c", - "value": { - "op": "min", - "args": [ - { - "op": "+", - "args": [ - "c", - 1 - ] - }, - 16 - ] - } - } - ] - } - ] - }, - { - "location": "l_2", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_2" - } - ] - }, - { - "location": "l_3", - "action": "get_k", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "c", - "value": 0 - }, - { - "ref": "r_ff", - "value": "ff" - }, - { - "ref": "r_lf", - "value": "lf" - }, - { - "ref": "r_ab", - "value": "ab" - }, - { - "ref": "Receiver_location", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "r_timeout", - "guard": { - "op": "∧", - "args": [ - "r_lf", - { - "op": "=", - "args": [ - "c", - 15 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_5", - "assignments": [ - { - "ref": "Receiver_location", - "value": 5 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "r_nok", - "guard": { - "op": "∧", - "args": [ - { - "op": "!", - "args": [ - "r_lf" - ] - }, - { - "op": "=", - "args": [ - "c", - 15 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_6", - "assignments": [ - { - "ref": "Receiver_location", - "value": 6 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "tick", - "guard": { - "op": "<", - "args": [ - "c", - 15 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "c", - "value": { - "op": "min", - "args": [ - { - "op": "+", - "args": [ - "c", - 1 - ] - }, - 16 - ] - } - } - ] - } - ] - }, - { - "location": "l_4", - "action": "put_l", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "bit", - "value": { - "op": "!", - "args": [ - "bit" - ] - } - }, - { - "ref": "Receiver_location", - "value": 3 - } - ] - } - ] - }, - { - "location": "l_4", - "action": "tick", - "guard": { - "op": "<", - "args": [ - "c", - 0 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_4", - "assignments": [ - { - "ref": "c", - "value": { - "op": "min", - "args": [ - { - "op": "+", - "args": [ - "c", - 1 - ] - }, - 16 - ] - } - } - ] - } - ] - }, - { - "location": "l_5", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "r_ff", - "value": false - }, - { - "ref": "r_lf", - "value": false - }, - { - "ref": "r_ab", - "value": false - }, - { - "ref": "bit", - "value": false - }, - { - "ref": "c", - "value": 0 - }, - { - "ref": "Receiver_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_5", - "action": "tick", - "guard": { - "op": "<", - "args": [ - "c", - 15 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_5", - "assignments": [ - { - "ref": "c", - "value": { - "op": "min", - "args": [ - { - "op": "+", - "args": [ - "c", - 1 - ] - }, - 16 - ] - } - } - ] - } - ] - }, - { - "location": "l_6", - "action": "r_timeout", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_5", - "assignments": [ - { - "ref": "Receiver_location", - "value": 5 - } - ] - } - ] - }, - { - "location": "l_6", - "action": "tick", - "guard": { - "op": "<", - "args": [ - "c", - 15 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_6", - "assignments": [ - { - "ref": "c", - "value": { - "op": "min", - "args": [ - { - "op": "+", - "args": [ - "c", - 1 - ] - }, - 16 - ] - } - } - ] - } - ] - } - ] - }, - { - "name": "ChannelK", - "variables": [ - { - "name": "c", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 2 - }, - "initial-value": 0 - } - ], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "action": "put_k", - "guard": true, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 49, - 50 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "c", - "value": 0 - }, - { - "ref": "inTransitK", - "value": true - }, - { - "ref": "ChannelK_location", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 50 - ] - }, - "location": "l_0", - "assignments": [ - { - "ref": "ChannelK_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0" - } - ] - }, - { - "location": "l_1", - "action": "get_k", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "inTransitK", - "value": false - }, - { - "ref": "c", - "value": 0 - }, - { - "ref": "ChannelK_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_1", - "action": "put_k", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "channel_k_overflow", - "value": true - }, - { - "ref": "ChannelK_location", - "value": 2 - }, - { - "ref": "c", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_1", - "action": "tick", - "guard": { - "op": "<", - "args": [ - "c", - 1 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "c", - "value": { - "op": "min", - "args": [ - { - "op": "+", - "args": [ - "c", - 1 - ] - }, - 2 - ] - } - } - ] - } - ] - }, - { - "location": "l_2", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_2" - } - ] - } - ] - }, - { - "name": "ChannelL", - "variables": [ - { - "name": "c", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 2 - }, - "initial-value": 0 - } - ], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "action": "put_l", - "guard": true, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 99, - 100 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "c", - "value": 0 - }, - { - "ref": "inTransitL", - "value": true - }, - { - "ref": "ChannelL_location", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 100 - ] - }, - "location": "l_0", - "assignments": [ - { - "ref": "ChannelL_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0" - } - ] - }, - { - "location": "l_1", - "action": "get_l", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "inTransitL", - "value": false - }, - { - "ref": "c", - "value": 0 - }, - { - "ref": "ChannelL_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_1", - "action": "put_l", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "channel_l_overflow", - "value": true - }, - { - "ref": "ChannelL_location", - "value": 2 - }, - { - "ref": "c", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_1", - "action": "tick", - "guard": { - "op": "<", - "args": [ - "c", - 1 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_1", - "assignments": [ - { - "ref": "c", - "value": { - "op": "min", - "args": [ - { - "op": "+", - "args": [ - "c", - 1 - ] - }, - 2 - ] - } - } - ] - } - ] - }, - { - "location": "l_2", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_2" - } - ] - } - ] - }, - { - "name": "Observer", - "variables": [], - "locations": [ - { - "name": "l_0" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "action": "get_k", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "get_k_seen", - "value": true - }, - { - "ref": "Observer_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "s_ok", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "s_ok_seen", - "value": true - }, - { - "ref": "Observer_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "s_nok", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "s_nok_seen", - "value": true - }, - { - "ref": "Observer_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "s_dk", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "s_dk_seen", - "value": true - }, - { - "ref": "Observer_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "s_restart", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "s_restart_seen", - "value": true - }, - { - "ref": "Observer_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "r_ok", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "r_ok_seen", - "value": true - }, - { - "ref": "Observer_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "r_timeout", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0", - "assignments": [ - { - "ref": "r_timeout_seen", - "value": true - }, - { - "ref": "Observer_location", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_0", - "action": "tick", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_0" - } - ] - } - ] - } - ], - "system": { - "composition": "parallel", - "elements": [ - { - "composition": "parallel", - "elements": [ - { - "composition": "parallel", - "elements": [ - { - "composition": "parallel", - "elements": [ - "Sender", - "Receiver" - ], - "alphabet": [ - "tick" - ] - }, - "ChannelK" - ], - "alphabet": [ - "put_k", - "get_k", - "tick" - ] - }, - "ChannelL" - ], - "alphabet": [ - "get_l", - "put_l", - "tick" - ] - }, - "Observer" - ], - "alphabet": [ - "s_nok", - "s_dk", - "s_ok", - "s_restart", - "get_k", - "r_ok", - "r_timeout", - "tick" - ] - } -} \ No newline at end of file diff --git a/examples/jani-examples/brp.jani.txt b/examples/jani-examples/brp.jani.txt deleted file mode 100755 index 9c0fcd322..000000000 --- a/examples/jani-examples/brp.jani.txt +++ /dev/null @@ -1,63 +0,0 @@ -Peak memory usage: 39 MB -Analysis results for brp.jani - -+ State space exploration - States: 3959 - Transitions: 4244 - Branches: 4593 - Time: 0.1 s - Rate: 74698 states/s - -+ P_A - Probability: 0 - Time: 0.0 s - - + Value iteration - Final error: 0 - Iterations: 1 - Time: 0.0 s - -+ P_B - Probability: 0 - Time: 0.0 s - - + Value iteration - Final error: 0 - Iterations: 1 - Time: 0.0 s - -+ P_1 - Probability: 0.000423333443357766 - Time: 0.0 s - - + Value iteration - Final error: 2.35005704803786E-07 - Iterations: 13 - Time: 0.0 s - -+ P_2 - Probability: 2.64530890961023E-05 - Time: 0.0 s - - + Value iteration - Final error: 2.05561452068843E-07 - Iterations: 14 - Time: 0.0 s - -+ P_3 - Probability: 0.000185191226393368 - Time: 0.0 s - - + Value iteration - Final error: 3.32462409056221E-07 - Iterations: 13 - Time: 0.0 s - -+ P_4 - Probability: 8E-06 - Time: 0.0 s - - + Value iteration - Final error: 0 - Iterations: 2 - Time: 0.0 s diff --git a/examples/jani-examples/brp.modest b/examples/jani-examples/brp.modest deleted file mode 100755 index 64743232f..000000000 --- a/examples/jani-examples/brp.modest +++ /dev/null @@ -1,213 +0,0 @@ -// Modest PTA model of the bounded retransmission protocol (BRP) -// [HH09], http://www.modestchecker.net/CaseStudies/BRP/ -action put, get, put_k, get_k, put_l, get_l; -action new_file; -action s_ok, s_dk, s_nok, s_restart; -action r_ok, r_inc, r_fst, r_nok, r_timeout; -exception error; - -const int N = 16; // number of frames per file -const int MAX = 2; // maximum number of retransmissions per frame -const int TD = 1; // transmission delay -const int TS = 2 * TD + 1; // sender timeout -const int TR = 2 * MAX * TS + 3 * TD; // receiver timeout -const int SYNC = TR; - -bool ff, lf, ab; // channel data: first/last frame, alternating bit -int(0..N) i; // sender chunk counter -bool inTransitK = false; -bool inTransitL = false; - -bool first_file_done = false; -bool get_k_seen, s_ok_seen, s_nok_seen, s_dk_seen, s_restart_seen, r_ok_seen, r_timeout_seen; - -// Invariant (timed) properties (from [BrpOnTime], the TA model) -bool premature_timeout, channel_k_overflow, channel_l_overflow; -// "there is at most one message in transit for each channel" -property T_1 = A[] (!(channel_k_overflow || channel_l_overflow)); -// "there is at most one message in transit in total" -property T_2 = A[] (!(inTransitK && inTransitL)); -// Assumption (A1): "no premature timeouts" -property T_A1 = A[] (!premature_timeout); -// Assumption (A2): "sender starts new file only after receiver reacted to failure" -// Note that receiver can only notice failure if it received at least one chunk, i.e. get_k_seen -property T_A2 = A[] (!s_restart_seen || !get_k_seen || r_timeout_seen); - -// Probabilistic reachability properties (from [D'AJJL01], the RAPTURE/PRISM model) -// property A of [D'AJJL01]: "the maximum probability that eventually the sender reports -// a certain unsuccessful transmission but the receiver got the complete file" -property P_A = Pmax(<>(s_nok_seen && r_ok_seen)); -// property B of [D'AJJL01]: "the maximum probability that eventually the sender reports -// a certain successful transmission but the receiver did not get the complete file" -property P_B = Pmax(<>(s_ok_seen && !r_ok_seen)); -// property 1 of [D'AJJL01]: "the maximum probability that eventually the sender -// does not report a successful transmission" -property P_1 = Pmax(<>(s_nok_seen || s_dk_seen)); -// property 2 of [D'AJJL01]: "the maximum probability that eventually the sender -// reports an uncertainty on the success of the transmission" -property P_2 = Pmax(<>(s_dk_seen)); -// property 3 of [D'AJJL01]: "the maximum probability that eventually the sender -// reports an unsuccessful transmission after more than 8 chunks have been sent successfully" -property P_3 = Pmax(<>(s_nok_seen && i > 8)); -// property 4 of [D'AJJL01]: "the maximum probability that eventually the receiver -// does not receive any chunk and the sender tried to send a chunk" -property P_4 = Pmax(<>((s_ok_seen || s_nok_seen || s_dk_seen) && !get_k_seen)); - - -process Sender() -{ - bool bit; - int(0..MAX) rc; - clock c; - - try - { - do { - :: when urgent(i < N) {= i++ =}; - do - { - // send frame - invariant(c <= 0) put_k {= ff = (i == 1), lf = (i == N), ab = bit, c = 0 =}; - invariant(c <= TS) alt { - :: // receive ack - get_l {= bit = !bit, rc = 0, c = 0 =}; - urgent break - :: // timeout - when(c >= TS) - if(rc < MAX) - { - // retry - {= rc++, c = 0 =} - } - else if(i < N) - { - // no retries left - s_nok {= rc = 0, c = 0 =}; - urgent throw(error) - } - else - { - // no retries left - s_dk {= rc = 0, c = 0 =}; - urgent throw(error) - } - } - } - :: when(i == N) - // file transmission successfully completed - invariant(c <= 0) s_ok {= first_file_done = true =}; - urgent break - } - } - catch error - { - // File transfer did not succeed: wait, then restart with next file - invariant(c <= SYNC) when(c >= SYNC) - s_restart {= bit = false, first_file_done = true =} - } -} - -process Receiver() -{ - bool r_ff, r_lf, r_ab; - bool bit; - clock c; - - // receive first frame - if(ff) { get_k {= c = 0, bit = ab, r_ff = ff, r_lf = lf, r_ab = ab =} } - else { get_k {= c = 0, premature_timeout = true =}; stop }; - do - { - invariant(c <= 0) - { - if(r_ab != bit) - { - // repetition, re-ack - put_l - } - else - { - // report frame - if(r_lf) { r_ok } - else if(r_ff) { r_fst } - else { r_inc }; - put_l {= bit = !bit =} - } - }; - invariant(c <= TR) - { - alt { - :: // receive next frame - get_k {= c = 0, r_ff = ff, r_lf = lf, r_ab = ab =} - :: // timeout - when(c == TR) - if(r_lf) - { - // we just got the last frame, though - r_timeout; break - } - else - { - r_nok; - // abort transfer - r_timeout; break - } - } - } - }; - Receiver() -} - -process ChannelK() -{ - clock c; - - put_k palt - { - :98: {= c = 0, inTransitK = true =}; - invariant(c <= TD) alt { - :: get_k {= inTransitK = false =} - :: put_k {= channel_k_overflow = true =}; stop - } - : 2: {==} - }; - ChannelK() -} - -process ChannelL() -{ - clock c; - - put_l palt - { - :99: {= c = 0, inTransitL = true =}; - invariant(c <= TD) alt { - :: get_l {= inTransitL = false =} - :: put_l {= channel_l_overflow = true =}; stop - } - : 1: {==} - }; - ChannelL() -} - -process Observer() -{ - alt { - :: get_k {= get_k_seen = true =} - :: s_ok {= s_ok_seen = true =} - :: s_nok {= s_nok_seen = true =} - :: s_dk {= s_dk_seen = true =} - :: s_restart {= s_restart_seen = true =} - :: r_ok {= r_ok_seen = true =} - :: r_timeout {= r_timeout_seen = true =} - }; - Observer() -} - -par { -:: Sender() -:: Receiver() -:: ChannelK() -:: ChannelL() -:: Observer() -} diff --git a/examples/jani-examples/brp.modest.txt b/examples/jani-examples/brp.modest.txt deleted file mode 100755 index 6ec6b0c5e..000000000 --- a/examples/jani-examples/brp.modest.txt +++ /dev/null @@ -1,63 +0,0 @@ -Peak memory usage: 40 MB -Analysis results for brp.modest - -+ State space exploration - States: 3959 - Transitions: 4244 - Branches: 4593 - Time: 0.1 s - Rate: 73315 states/s - -+ P_A - Probability: 0 - Time: 0.1 s - - + Value iteration - Final error: 0 - Iterations: 1 - Time: 0.0 s - -+ P_B - Probability: 0 - Time: 0.0 s - - + Value iteration - Final error: 0 - Iterations: 1 - Time: 0.0 s - -+ P_1 - Probability: 0.000423333443357766 - Time: 0.0 s - - + Value iteration - Final error: 2.35005704803786E-07 - Iterations: 13 - Time: 0.0 s - -+ P_2 - Probability: 2.64530890961023E-05 - Time: 0.0 s - - + Value iteration - Final error: 2.05561452068843E-07 - Iterations: 14 - Time: 0.0 s - -+ P_3 - Probability: 0.000185191226393368 - Time: 0.0 s - - + Value iteration - Final error: 3.32462409056221E-07 - Iterations: 13 - Time: 0.0 s - -+ P_4 - Probability: 8E-06 - Time: 0.0 s - - + Value iteration - Final error: 0 - Iterations: 2 - Time: 0.0 s diff --git a/examples/jani-examples/consensus-6.jani b/examples/jani-examples/consensus-6.jani deleted file mode 100755 index 58acabfef..000000000 --- a/examples/jani-examples/consensus-6.jani +++ /dev/null @@ -1,2129 +0,0 @@ -{ - "jani-version": 1, - "name": "modelName", - "type": "mdp", - "actions": [ - { - "name": "done" - } - ], - "variables": [ - { - "name": "counter", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 60 - }, - "initial-value": 30 - }, - { - "name": "fin1", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - }, - { - "name": "fin2", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - }, - { - "name": "fin3", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - }, - { - "name": "fin4", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - }, - { - "name": "fin5", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - }, - { - "name": "fin6", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - }, - { - "name": "coin1", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - }, - { - "name": "coin2", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - }, - { - "name": "coin3", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - }, - { - "name": "coin4", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - }, - { - "name": "coin5", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - }, - { - "name": "coin6", - "type": { - "kind": "bounded", - "base": "int", - "lower-bound": 0, - "upper-bound": 1 - }, - "initial-value": 0 - } - ], - "rewards": [ - { - "name": "coin_flips" - } - ], - "properties": [ - { - "name": "C1", - "bound": 1, - "op": "≥", - "reach": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "fin1", - 1 - ] - }, - { - "op": "=", - "args": [ - "fin2", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "fin3", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "fin4", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "fin5", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "fin6", - 1 - ] - } - ] - }, - "type": "probability-comparison" - }, - { - "name": "C2", - "reach": { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "fin1", - 1 - ] - }, - { - "op": "=", - "args": [ - "fin2", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "fin3", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "fin4", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "fin5", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "fin6", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "coin1", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "coin2", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "coin3", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "coin4", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "coin5", - 1 - ] - } - ] - }, - { - "op": "=", - "args": [ - "coin6", - 1 - ] - } - ] - }, - "type": "probability-min-query" - } - ], - "automata": [ - { - "name": "Tourist1", - "variables": [], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "guard": true, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin1", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin1", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin1", - 0 - ] - }, - { - "op": ">", - "args": [ - "counter", - 0 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "-", - "args": [ - "counter", - 1 - ] - } - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin1", - 1 - ] - }, - { - "op": "<", - "args": [ - "counter", - 60 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "+", - "args": [ - "counter", - 1 - ] - } - }, - { - "ref": "coin1", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≤", - "args": [ - "counter", - 6 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin1", - "value": 0 - }, - { - "ref": "fin1", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≥", - "args": [ - "counter", - 54 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin1", - "value": 1 - }, - { - "ref": "fin1", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "∧", - "args": [ - { - "op": ">", - "args": [ - "counter", - 6 - ] - }, - { - "op": "<", - "args": [ - "counter", - 54 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin1", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin1", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "done", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3" - } - ] - } - ] - }, - { - "name": "Tourist2", - "variables": [], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "guard": true, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin2", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin2", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin2", - 0 - ] - }, - { - "op": ">", - "args": [ - "counter", - 0 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "-", - "args": [ - "counter", - 1 - ] - } - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin2", - 1 - ] - }, - { - "op": "<", - "args": [ - "counter", - 60 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "+", - "args": [ - "counter", - 1 - ] - } - }, - { - "ref": "coin2", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≤", - "args": [ - "counter", - 6 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin2", - "value": 0 - }, - { - "ref": "fin2", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≥", - "args": [ - "counter", - 54 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin2", - "value": 1 - }, - { - "ref": "fin2", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "∧", - "args": [ - { - "op": ">", - "args": [ - "counter", - 6 - ] - }, - { - "op": "<", - "args": [ - "counter", - 54 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin2", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin2", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "done", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3" - } - ] - } - ] - }, - { - "name": "Tourist3", - "variables": [], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "guard": true, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin3", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin3", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin3", - 0 - ] - }, - { - "op": ">", - "args": [ - "counter", - 0 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "-", - "args": [ - "counter", - 1 - ] - } - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin3", - 1 - ] - }, - { - "op": "<", - "args": [ - "counter", - 60 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "+", - "args": [ - "counter", - 1 - ] - } - }, - { - "ref": "coin3", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≤", - "args": [ - "counter", - 6 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin3", - "value": 0 - }, - { - "ref": "fin3", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≥", - "args": [ - "counter", - 54 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin3", - "value": 1 - }, - { - "ref": "fin3", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "∧", - "args": [ - { - "op": ">", - "args": [ - "counter", - 6 - ] - }, - { - "op": "<", - "args": [ - "counter", - 54 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin3", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin3", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "done", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3" - } - ] - } - ] - }, - { - "name": "Tourist4", - "variables": [], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "guard": true, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin4", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin4", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin4", - 0 - ] - }, - { - "op": ">", - "args": [ - "counter", - 0 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "-", - "args": [ - "counter", - 1 - ] - } - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin4", - 1 - ] - }, - { - "op": "<", - "args": [ - "counter", - 60 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "+", - "args": [ - "counter", - 1 - ] - } - }, - { - "ref": "coin4", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≤", - "args": [ - "counter", - 6 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin4", - "value": 0 - }, - { - "ref": "fin4", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≥", - "args": [ - "counter", - 54 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin4", - "value": 1 - }, - { - "ref": "fin4", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "∧", - "args": [ - { - "op": ">", - "args": [ - "counter", - 6 - ] - }, - { - "op": "<", - "args": [ - "counter", - 54 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin4", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin4", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "done", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3" - } - ] - } - ] - }, - { - "name": "Tourist5", - "variables": [], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "guard": true, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin5", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin5", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin5", - 0 - ] - }, - { - "op": ">", - "args": [ - "counter", - 0 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "-", - "args": [ - "counter", - 1 - ] - } - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin5", - 1 - ] - }, - { - "op": "<", - "args": [ - "counter", - 60 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "+", - "args": [ - "counter", - 1 - ] - } - }, - { - "ref": "coin5", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≤", - "args": [ - "counter", - 6 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin5", - "value": 0 - }, - { - "ref": "fin5", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≥", - "args": [ - "counter", - 54 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin5", - "value": 1 - }, - { - "ref": "fin5", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "∧", - "args": [ - { - "op": ">", - "args": [ - "counter", - 6 - ] - }, - { - "op": "<", - "args": [ - "counter", - 54 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin5", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin5", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "done", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3" - } - ] - } - ] - }, - { - "name": "Tourist6", - "variables": [], - "locations": [ - { - "name": "l_0" - }, - { - "name": "l_1" - }, - { - "name": "l_2" - }, - { - "name": "l_3" - } - ], - "initial-location": "l_0", - "edges": [ - { - "location": "l_0", - "guard": true, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin6", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin6", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin6", - 0 - ] - }, - { - "op": ">", - "args": [ - "counter", - 0 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "-", - "args": [ - "counter", - 1 - ] - } - } - ] - } - ] - }, - { - "location": "l_1", - "guard": { - "op": "∧", - "args": [ - { - "op": "=", - "args": [ - "coin6", - 1 - ] - }, - { - "op": "<", - "args": [ - "counter", - 60 - ] - } - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_2", - "assignments": [ - { - "ref": "counter", - "value": { - "op": "+", - "args": [ - "counter", - 1 - ] - } - }, - { - "ref": "coin6", - "value": 0 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≤", - "args": [ - "counter", - 6 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin6", - "value": 0 - }, - { - "ref": "fin6", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "≥", - "args": [ - "counter", - 54 - ] - }, - "destinations": [ - { - "probability": 1, - "location": "l_3", - "assignments": [ - { - "ref": "coin6", - "value": 1 - }, - { - "ref": "fin6", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_2", - "guard": { - "op": "∧", - "args": [ - { - "op": ">", - "args": [ - "counter", - 6 - ] - }, - { - "op": "<", - "args": [ - "counter", - 54 - ] - } - ] - }, - "destinations": [ - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin6", - "value": 0 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - }, - { - "probability": { - "op": "/", - "args": [ - 1, - 2 - ] - }, - "location": "l_1", - "assignments": [ - { - "ref": "coin6", - "value": 1 - } - ], - "reward": [ - { - "ref": "coin_flips", - "value": 1 - } - ] - } - ] - }, - { - "location": "l_3", - "action": "done", - "guard": true, - "destinations": [ - { - "probability": 1, - "location": "l_3" - } - ] - } - ] - } - ], - "system": { - "composition": "parallel", - "elements": [ - { - "composition": "parallel", - "elements": [ - { - "composition": "parallel", - "elements": [ - { - "composition": "parallel", - "elements": [ - { - "composition": "parallel", - "elements": [ - "Tourist1", - "Tourist2" - ], - "alphabet": [ - "done" - ] - }, - "Tourist3" - ], - "alphabet": [ - "done" - ] - }, - "Tourist4" - ], - "alphabet": [ - "done" - ] - }, - "Tourist5" - ], - "alphabet": [ - "done" - ] - }, - "Tourist6" - ], - "alphabet": [ - "done" - ] - } -} \ No newline at end of file diff --git a/examples/jani-examples/consensus-6.jani.txt b/examples/jani-examples/consensus-6.jani.txt deleted file mode 100755 index 17509db20..000000000 --- a/examples/jani-examples/consensus-6.jani.txt +++ /dev/null @@ -1,27 +0,0 @@ -Peak memory usage: 530 MB -Analysis results for consensus-6.jani - -+ State space exploration - States: 2345194 - Transitions: 9418584 - Branches: 13891248 - Time: 8.7 s - Rate: 270964 states/s - -+ C1 - Result: True - Time for min. prob. 0 states: 1.6 s - Time for min. prob. 1 states: 0.1 s - Time: 1.7 s - Min. probability: 1 - -+ C2 - Probability: 0.395776147642961 - Time for min. prob. 0 states: 2.0 s - Time for min. prob. 1 states: 0.1 s - Time: 125.8 s - - + Value iteration - Final error: 9.96634356860147E-07 - Iterations: 2137 - Time: 123.8 s diff --git a/examples/jani-examples/consensus-6.modest b/examples/jani-examples/consensus-6.modest deleted file mode 100755 index 6b129af06..000000000 --- a/examples/jani-examples/consensus-6.modest +++ /dev/null @@ -1,157 +0,0 @@ -// Modest version of http://www.prismmodelchecker.org/casestudies/consensus_prism.php -// Command line: mcsta.exe consensus-6.modest -S Memory --nochainopt --bounded-alg StateElimination -E "K=2" - -action done; - -// constants -const int N = 6; -const int K = 4; -const int range = 2 * (K + 1) * N; -const int counter_init = (K + 1) * N; -const int left = N; -const int right = 2 * (K + 1) * N - N; - -// shared coin -int(0..range) counter = counter_init; -reward coin_flips; - -property C1 = P(<> (fin1 == 1 && fin2 == 1 && fin3 == 1 && fin4 == 1 && fin5 == 1 && fin6 == 1)) >= 1; -property C2 = Pmin(<> (fin1 == 1 && fin2 == 1 && fin3 == 1 && fin4 == 1 && fin5 == 1 && fin6 == 1 && coin1 == 1 && coin2 == 1 && coin3 == 1 && coin4 == 1 && coin5 == 1 && coin6 == 1)); - -int(0..1) fin1, fin2, fin3, fin4, fin5, fin6; -int(0..1) coin1, coin2, coin3, coin4, coin5, coin6; - -process Tourist1() -{ - process Flip() { palt { :1: {= coin1 = 0, coin_flips++ =} :1: {= coin1 = 1, coin_flips++ =} }; Write() } - process Write() { - alt { - :: when(coin1 == 0 && counter > 0) {= counter-- =}; Check() - :: when(coin1 == 1 && counter < range) {= counter++, coin1 = 0 =}; Check() - } - } - process Check() { - alt { - :: when(counter <= left) {= coin1 = 0, fin1 = 1 =}; Finished() - :: when(counter >= right) {= coin1 = 1, fin1 = 1 =}; Finished() - :: when(counter > left && counter < right) Tourist1() - } - } - process Finished() { done; Finished() } - - Flip() -} - -process Tourist2() -{ - process Flip() { palt { :1: {= coin2 = 0, coin_flips++ =} :1: {= coin2 = 1, coin_flips++ =} }; Write() } - process Write() { - alt { - :: when(coin2 == 0 && counter > 0) {= counter-- =}; Check() - :: when(coin2 == 1 && counter < range) {= counter++, coin2 = 0 =}; Check() - } - } - process Check() { - alt { - :: when(counter <= left) {= coin2 = 0, fin2 = 1 =}; Finished() - :: when(counter >= right) {= coin2 = 1, fin2 = 1 =}; Finished() - :: when(counter > left && counter < right) Tourist2() - } - } - process Finished() { done; Finished() } - - Flip() -} - -process Tourist3() -{ - process Flip() { palt { :1: {= coin3 = 0, coin_flips++ =} :1: {= coin3 = 1, coin_flips++ =} }; Write() } - process Write() { - alt { - :: when(coin3 == 0 && counter > 0) {= counter-- =}; Check() - :: when(coin3 == 1 && counter < range) {= counter++, coin3 = 0 =}; Check() - } - } - process Check() { - alt { - :: when(counter <= left) {= coin3 = 0, fin3 = 1 =}; Finished() - :: when(counter >= right) {= coin3 = 1, fin3 = 1 =}; Finished() - :: when(counter > left && counter < right) Tourist3() - } - } - process Finished() { done; Finished() } - - Flip() -} - -process Tourist4() -{ - process Flip() { palt { :1: {= coin4 = 0, coin_flips++ =} :1: {= coin4 = 1, coin_flips++ =} }; Write() } - process Write() { - alt { - :: when(coin4 == 0 && counter > 0) {= counter-- =}; Check() - :: when(coin4 == 1 && counter < range) {= counter++, coin4 = 0 =}; Check() - } - } - process Check() { - alt { - :: when(counter <= left) {= coin4 = 0, fin4 = 1 =}; Finished() - :: when(counter >= right) {= coin4 = 1, fin4 = 1 =}; Finished() - :: when(counter > left && counter < right) Tourist4() - } - } - process Finished() { done; Finished() } - - Flip() -} - -process Tourist5() -{ - process Flip() { palt { :1: {= coin5 = 0, coin_flips++ =} :1: {= coin5 = 1, coin_flips++ =} }; Write() } - process Write() { - alt { - :: when(coin5 == 0 && counter > 0) {= counter-- =}; Check() - :: when(coin5 == 1 && counter < range) {= counter++, coin5 = 0 =}; Check() - } - } - process Check() { - alt { - :: when(counter <= left) {= coin5 = 0, fin5 = 1 =}; Finished() - :: when(counter >= right) {= coin5 = 1, fin5 = 1 =}; Finished() - :: when(counter > left && counter < right) Tourist5() - } - } - process Finished() { done; Finished() } - - Flip() -} - -process Tourist6() -{ - process Flip() { palt { :1: {= coin6 = 0, coin_flips++ =} :1: {= coin6 = 1, coin_flips++ =} }; Write() } - process Write() { - alt { - :: when(coin6 == 0 && counter > 0) {= counter-- =}; Check() - :: when(coin6 == 1 && counter < range) {= counter++, coin6 = 0 =}; Check() - } - } - process Check() { - alt { - :: when(counter <= left) {= coin6 = 0, fin6 = 1 =}; Finished() - :: when(counter >= right) {= coin6 = 1, fin6 = 1 =}; Finished() - :: when(counter > left && counter < right) Tourist6() - } - } - process Finished() { done; Finished() } - - Flip() -} - -par { -:: Tourist1() -:: Tourist2() -:: Tourist3() -:: Tourist4() -:: Tourist5() -:: Tourist6() -} diff --git a/examples/jani-examples/consensus-6.modest.txt b/examples/jani-examples/consensus-6.modest.txt deleted file mode 100755 index 3ff5c0821..000000000 --- a/examples/jani-examples/consensus-6.modest.txt +++ /dev/null @@ -1,27 +0,0 @@ -Peak memory usage: 531 MB -Analysis results for consensus-6.modest - -+ State space exploration - States: 2345194 - Transitions: 9418584 - Branches: 13891248 - Time: 8.2 s - Rate: 287507 states/s - -+ C1 - Result: True - Time for min. prob. 0 states: 1.5 s - Time for min. prob. 1 states: 0.2 s - Time: 1.7 s - Min. probability: 1 - -+ C2 - Probability: 0.395776147642961 - Time for min. prob. 0 states: 2.0 s - Time for min. prob. 1 states: 0.1 s - Time: 126.8 s - - + Value iteration - Final error: 9.96634356860147E-07 - Iterations: 2137 - Time: 124.7 s diff --git a/examples/jani-examples/dice.jani b/examples/jani-examples/dice.jani deleted file mode 100755 index e9e377e15..000000000 --- a/examples/jani-examples/dice.jani +++ /dev/null @@ -1,354 +0,0 @@ -{ - "jani-version": 1, - "name": "dice", - "type" : "mdp", - "actions" : [], - "variables" : [ - { - "name": "thrownSix", - "type": "bool", - "initial-value": false - }, - { - "name": "terminated", - "type": "bool", - "initial-value": false - } - ], - "rewards" : [ - { - "name" : "step" - } - ], - "properties" : [ - { - "name" : "ProbThrowSix", - "reach" : "thrownSix", - "type": "probability-max-query" - }, - { - "name" : "StepsUntilReach", - "reach" : "terminated", - "reward": "step", - "type": "expected-reachability-reward-max-query" - } - ], - "automata" : [ - { - "name" : "dice", - "variables" : [ - { - "name" : "d", - "type" : { - "kind": "bounded", - "base": "int", - "lower-bound" : 0, - "upper-bound" : 6 - }, - "initial-value" : 0 - } - ], - "locations" : [ - { - "name" : "s0" - }, - { - "name" : "s1" - }, - { - "name" : "s2" - }, - { - "name" : "s3" - }, - { - "name" : "s4" - }, - { - "name" : "s5" - }, - { - "name" : "s6" - }, - { - "name" : "s7" - } - ], - "initial-location" : "s0", - "edges" : [ - { - "location" : "s0", - "guard" : true, - "destinations" : [ - { - "probability" : 0.5, - "location" : "s1", - "assignments" : [], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - }, - { - "probability" : 0.5, - "location" : "s2", - "assignments" : [], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - } - ] - }, - { - "location" : "s1", - "guard" : true, - "destinations" : [ - { - "probability" : 0.5, - "location" : "s3", - "assignments" : [], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - }, - { - "probability" : 0.5, - "location" : "s4", - "assignments" : [], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - } - ] - }, - { - "location" : "s2", - "guard" : true, - "destinations" : [ - { - "probability" : 0.5, - "location" : "s5", - "assignments" : [], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - }, - { - "probability" : 0.5, - "location" : "s6", - "assignments" : [], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - } - ] - }, - { - "location" : "s3", - "guard" : true, - "destinations" : [ - { - "probability" : 0.5, - "location" : "s1", - "assignments" : [], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - }, - { - "probability" : 0.5, - "location" : "s7", - "assignments" : [ - { - "ref" : "d", - "value" : 1 - }, - { - "ref" : "terminated", - "value" : true - } - ], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - } - ] - }, - { - "location" : "s4", - "guard" : true, - "destinations" : [ - { - "probability" : 0.5, - "location" : "s7", - "assignments" : [ - { - "ref" : "d", - "value" : 2 - }, - { - "ref" : "terminated", - "value" : true - } - ], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - }, - { - "probability" : 0.5, - "location" : "s7", - "assignments" : [ - { - "ref" : "d", - "value" : 3 - }, - { - "ref" : "terminated", - "value" : true - } - ], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - } - ] - }, - { - "location" : "s5", - "guard" : true, - "destinations" : [ - { - "probability" : 0.5, - "location" : "s7", - "assignments" : [ - { - "ref" : "d", - "value" : 4 - }, - { - "ref" : "terminated", - "value" : true - } - ], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - }, - { - "probability" : 0.5, - "location" : "s7", - "assignments" : [ - { - "ref" : "d", - "value" : 5 - }, - { - "ref" : "terminated", - "value" : true - } - ], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - } - ] - }, - { - "location" : "s6", - "guard" : true, - "destinations" : [ - { - "probability" : 0.5, - "location" : "s2", - "assignments" : [], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - }, - { - "probability" : 0.5, - "location" : "s7", - "assignments" : [ - { - "ref" : "d", - "value" : 6 - }, - { - "ref" : "thrownSix", - "value" : true - }, - { - "ref" : "terminated", - "value" : true - } - ], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - } - ] - }, - { - "location" : "s7", - "guard" : true, - "destinations" : [ - { - "probability" : 1, - "location" : "s7", - "assignments" : [], - "rewards" : [ - { - "ref" : "step", - "value" : 1 - } - ] - } - ] - } - ] - } - ], - "system" : "dice" -} diff --git a/examples/jani-examples/dice.jani.txt b/examples/jani-examples/dice.jani.txt deleted file mode 100755 index 2cf07a5ed..000000000 --- a/examples/jani-examples/dice.jani.txt +++ /dev/null @@ -1,29 +0,0 @@ -Peak memory usage: 36 MB -Analysis results for dice.jani - -+ State space exploration - States: 8 - Transitions: 8 - Branches: 14 - Time: 0.0 s - Rate: 190 states/s - -+ ProbThrowSix - Probability: 0.166666626930237 - Time: 0.0 s - - + Value iteration - Final error: 7.15255907834985E-07 - Iterations: 11 - Time: 0.0 s - -+ StepsUntilReach - Value: 3.66666650772095 - Time for min. prob. 0 states: 0.0 s - Time for min. prob. 1 states: 0.0 s - Time: 0.0 s - - + Value iteration - Final error: 4.08717619857464E-07 - Iterations: 12 - Time: 0.0 s diff --git a/examples/mdp/asynchronous_leader/leader.pctl b/examples/mdp/asynchronous_leader/leader.pctl deleted file mode 100644 index 2c87c7f27..000000000 --- a/examples/mdp/asynchronous_leader/leader.pctl +++ /dev/null @@ -1,8 +0,0 @@ -Pmin=? [ F elected ] - -// const int K = 25; -Pmin=? [ F<=25 elected ] -Pmax=? [ F<=25 elected ] - -Rmin=? [ F elected ] -Rmax=? [ F elected ] diff --git a/examples/mdp/asynchronous_leader/leader.res b/examples/mdp/asynchronous_leader/leader.res deleted file mode 100644 index 447403e11..000000000 --- a/examples/mdp/asynchronous_leader/leader.res +++ /dev/null @@ -1,49 +0,0 @@ -// 3 -Pmin=? [ F "elected" ] // 1.0 - -const int K = 25; -Pmin=? [ F<=K "elected" ] // 0.5625 -Pmax=? [ F<=K "elected" ] // 0.5625 - -Rmin=? [ F "elected" ] // 3.3333212586585432 -Rmax=? [ F "elected" ] // 3.3333206579554826 - -// 4 -Pmin=? [ F "elected" ] // 1.0 - -const int K = 25; -Pmin=? [ F<=K "elected" ] // 0.0625 -Pmax=? [ F<=K "elected" ] // 0.0625 - -Rmin=? [ F "elected" ] // 4.2856896106114934 -Rmax=? [ F "elected" ] // 4.28569043544414 - -// 5 -Pmin=? [ F "elected" ] // 1.0 - -const int K = 25; -Pmin=? [ F<=K "elected" ] // 0.0 -Pmax=? [ F<=K "elected" ] // 0.0 - -Rmin=? [ F "elected" ] // 5.034886386278894 -Rmax=? [ F "elected" ] // 5.034881859133309 - -// 6 -Pmin=? [ F "elected" ] // 1.0 - -const int K = 25; -Pmin=? [ F<=K "elected" ] // 0.0 -Pmax=? [ F<=K "elected" ] // 0.0 - -Rmin=? [ F "elected" ] // 5.649720120334257 -Rmax=? [ F "elected" ] // 5.649719114527437 - -// 7 -Pmin=? [ F "elected" ] // 1.0 - -const int K = 25; -Pmin=? [ F<=K "elected" ] // 0.0 -Pmax=? [ F<=K "elected" ] // 0.0 - -Rmin=? [ F "elected" ] // 6.172433512043686 -Rmax=? [ F "elected" ] // 6.172434400085756 \ No newline at end of file diff --git a/examples/mdp/asynchronous_leader/leader3.nm b/examples/mdp/asynchronous_leader/leader3.nm deleted file mode 100644 index 9f093cc13..000000000 --- a/examples/mdp/asynchronous_leader/leader3.nm +++ /dev/null @@ -1,96 +0,0 @@ -// asynchronous leader election -// 4 processes -// gxn/dxp 29/01/01 - -mdp - -const int N = 3; // number of processes - -//---------------------------------------------------------------------------------------------------------------------------- -module process1 - - // COUNTER - c1 : [0..3-1]; - - // STATES - s1 : [0..4]; - // 0 make choice - // 1 have not received neighbours choice - // 2 active - // 3 inactive - // 4 leader - - // PREFERENCE - p1 : [0..1]; - - // VARIABLES FOR SENDING AND RECEIVING - receive1 : [0..2]; - // not received anything - // received choice - // received counter - sent1 : [0..2]; - // not send anything - // sent choice - // sent counter - - // pick value - [] (s1=0) -> 0.5 : (s1'=1) & (p1'=0) + 0.5 : (s1'=1) & (p1'=1); - - // send preference - [p12] (s1=1) & (sent1=0) -> (sent1'=1); - // receive preference - // stay active - [p31] (s1=1) & (receive1=0) & !( (p1=0) & (p3=1) ) -> (s1'=2) & (receive1'=1); - // become inactive - [p31] (s1=1) & (receive1=0) & (p1=0) & (p3=1) -> (s1'=3) & (receive1'=1); - - // send preference (can now reset preference) - [p12] (s1=2) & (sent1=0) -> (sent1'=1) & (p1'=0); - // send counter (already sent preference) - // not received counter yet - [c12] (s1=2) & (sent1=1) & (receive1=1) -> (sent1'=2); - // received counter (pick again) - [c12] (s1=2) & (sent1=1) & (receive1=2) -> (s1'=0) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // receive counter and not sent yet (note in this case do not pass it on as will send own counter) - [c31] (s1=2) & (receive1=1) & (sent1<2) -> (receive1'=2); - // receive counter and sent counter - // only active process (decide) - [c31] (s1=2) & (receive1=1) & (sent1=2) & (c3=N-1) -> (s1'=4) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - // other active process (pick again) - [c31] (s1=2) & (receive1=1) & (sent1=2) & (c3 (s1'=0) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // send preference (must have received preference) and can now reset - [p12] (s1=3) & (receive1>0) & (sent1=0) -> (sent1'=1) & (p1'=0); - // send counter (must have received counter first) and can now reset - [c12] (s1=3) & (receive1=2) & (sent1=1) -> (s1'=3) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // receive preference - [p31] (s1=3) & (receive1=0) -> (p1'=p3) & (receive1'=1); - // receive counter - [c31] (s1=3) & (receive1=1) & (c3 (c1'=c3+1) & (receive1'=2); - - // done - [done] (s1=4) -> (s1'=s1); - // add loop for processes who are inactive - [done] (s1=3) -> (s1'=s1); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module process2=process1[s1=s2,p1=p2,c1=c2,sent1=sent2,receive1=receive2,p12=p23,p31=p12,c12=c23,c31=c12,p3=p1,c3=c1] endmodule -module process3=process1[s1=s3,p1=p3,c1=c3,sent1=sent3,receive1=receive3,p12=p31,p31=p23,c12=c31,c31=c23,p3=p2,c3=c2] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward - expected number of rounds (equals the number of times a process receives a counter) -rewards - [c12] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- -formula leaders = (s1=4?1:0)+(s2=4?1:0)+(s3=4?1:0); -label "elected" = s1=4|s2=4|s3=4; - diff --git a/examples/mdp/asynchronous_leader/leader4.nm b/examples/mdp/asynchronous_leader/leader4.nm deleted file mode 100644 index ce7ef878c..000000000 --- a/examples/mdp/asynchronous_leader/leader4.nm +++ /dev/null @@ -1,97 +0,0 @@ -// asynchronous leader election -// 4 processes -// gxn/dxp 29/01/01 - -mdp - -const int N= 4; // number of processes - -//---------------------------------------------------------------------------------------------------------------------------- -module process1 - - // COUNTER - c1 : [0..4-1]; - - // STATES - s1 : [0..4]; - // 0 make choice - // 1 have not received neighbours choice - // 2 active - // 3 inactive - // 4 leader - - // PREFERENCE - p1 : [0..1]; - - // VARIABLES FOR SENDING AND RECEIVING - receive1 : [0..2]; - // not received anything - // received choice - // received counter - sent1 : [0..2]; - // not send anything - // sent choice - // sent counter - - // pick value - [] (s1=0) -> 0.5 : (s1'=1) & (p1'=0) + 0.5 : (s1'=1) & (p1'=1); - - // send preference - [p12] (s1=1) & (sent1=0) -> (sent1'=1); - // receive preference - // stay active - [p41] (s1=1) & (receive1=0) & !( (p1=0) & (p4=1) ) -> (s1'=2) & (receive1'=1); - // become inactive - [p41] (s1=1) & (receive1=0) & (p1=0) & (p4=1) -> (s1'=3) & (receive1'=1); - - // send preference (can now reset preference) - [p12] (s1=2) & (sent1=0) -> (sent1'=1) & (p1'=0); - // send counter (already sent preference) - // not received counter yet - [c12] (s1=2) & (sent1=1) & (receive1=1) -> (sent1'=2); - // received counter (pick again) - [c12] (s1=2) & (sent1=1) & (receive1=2) -> (s1'=0) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // receive counter and not sent yet (note in this case do not pass it on as will send own counter) - [c41] (s1=2) & (receive1=1) & (sent1<2) -> (receive1'=2); - // receive counter and sent counter - // only active process (decide) - [c41] (s1=2) & (receive1=1) & (sent1=2) & (c4=N-1) -> (s1'=4) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - // other active process (pick again) - [c41] (s1=2) & (receive1=1) & (sent1=2) & (c4 (s1'=0) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // send preference (must have received preference) and can now reset - [p12] (s1=3) & (receive1>0) & (sent1=0) -> (sent1'=1) & (p1'=0); - // send counter (must have received counter first) and can now reset - [c12] (s1=3) & (receive1=2) & (sent1=1) -> (s1'=3) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // receive preference - [p41] (s1=3) & (receive1=0) -> (p1'=p4) & (receive1'=1); - // receive counter - [c41] (s1=3) & (receive1=1) & (c4 (c1'=c4+1) & (receive1'=2); - - // done - [done] (s1=4) -> (s1'=s1); - // add loop for processes who are inactive - [done] (s1=3) -> (s1'=s1); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module process2=process1[s1=s2,p1=p2,c1=c2,sent1=sent2,receive1=receive2,p12=p23,p41=p12,c12=c23,c41=c12,p4=p1,c4=c1] endmodule -module process3=process1[s1=s3,p1=p3,c1=c3,sent1=sent3,receive1=receive3,p12=p34,p41=p23,c12=c34,c41=c23,p4=p2,c4=c2] endmodule -module process4=process1[s1=s4,p1=p4,c1=c4,sent1=sent4,receive1=receive4,p12=p41,p41=p34,c12=c41,c41=c34,p4=p3,c4=c3] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward - expected number of rounds (equals the number of times a process receives a counter) -rewards - [c12] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- -formula leaders = (s1=4?1:0)+(s2=4?1:0)+(s3=4?1:0)+(s4=4?1:0); -label "elected" = s1=4|s2=4|s3=4|s4=4; - diff --git a/examples/mdp/asynchronous_leader/leader5.nm b/examples/mdp/asynchronous_leader/leader5.nm deleted file mode 100644 index 8b5c477b8..000000000 --- a/examples/mdp/asynchronous_leader/leader5.nm +++ /dev/null @@ -1,98 +0,0 @@ -// asynchronous leader election -// 4 processes -// gxn/dxp 29/01/01 - -mdp - -const int N= 5; // number of processes - -//---------------------------------------------------------------------------------------------------------------------------- -module process1 - - // COUNTER - c1 : [0..5-1]; - - // STATES - s1 : [0..4]; - // 0 make choice - // 1 have not received neighbours choice - // 2 active - // 3 inactive - // 4 leader - - // PREFERENCE - p1 : [0..1]; - - // VARIABLES FOR SENDING AND RECEIVING - receive1 : [0..2]; - // not received anything - // received choice - // received counter - sent1 : [0..2]; - // not send anything - // sent choice - // sent counter - - // pick value - [] (s1=0) -> 0.5 : (s1'=1) & (p1'=0) + 0.5 : (s1'=1) & (p1'=1); - - // send preference - [p12] (s1=1) & (sent1=0) -> (sent1'=1); - // receive preference - // stay active - [p51] (s1=1) & (receive1=0) & !( (p1=0) & (p5=1) ) -> (s1'=2) & (receive1'=1); - // become inactive - [p51] (s1=1) & (receive1=0) & (p1=0) & (p5=1) -> (s1'=3) & (receive1'=1); - - // send preference (can now reset preference) - [p12] (s1=2) & (sent1=0) -> (sent1'=1) & (p1'=0); - // send counter (already sent preference) - // not received counter yet - [c12] (s1=2) & (sent1=1) & (receive1=1) -> (sent1'=2); - // received counter (pick again) - [c12] (s1=2) & (sent1=1) & (receive1=2) -> (s1'=0) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // receive counter and not sent yet (note in this case do not pass it on as will send own counter) - [c51] (s1=2) & (receive1=1) & (sent1<2) -> (receive1'=2); - // receive counter and sent counter - // only active process (decide) - [c51] (s1=2) & (receive1=1) & (sent1=2) & (c5=N-1) -> (s1'=4) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - // other active process (pick again) - [c51] (s1=2) & (receive1=1) & (sent1=2) & (c5 (s1'=0) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // send preference (must have received preference) and can now reset - [p12] (s1=3) & (receive1>0) & (sent1=0) -> (sent1'=1) & (p1'=0); - // send counter (must have received counter first) and can now reset - [c12] (s1=3) & (receive1=2) & (sent1=1) -> (s1'=3) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // receive preference - [p51] (s1=3) & (receive1=0) -> (p1'=p5) & (receive1'=1); - // receive counter - [c51] (s1=3) & (receive1=1) & (c5 (c1'=c5+1) & (receive1'=2); - - // done - [done] (s1=4) -> (s1'=s1); - // add loop for processes who are inactive - [done] (s1=3) -> (s1'=s1); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module process2=process1[s1=s2,p1=p2,c1=c2,sent1=sent2,receive1=receive2,p12=p23,p51=p12,c12=c23,c51=c12,p5=p1,c5=c1] endmodule -module process3=process1[s1=s3,p1=p3,c1=c3,sent1=sent3,receive1=receive3,p12=p34,p51=p23,c12=c34,c51=c23,p5=p2,c5=c2] endmodule -module process4=process1[s1=s4,p1=p4,c1=c4,sent1=sent4,receive1=receive4,p12=p45,p51=p34,c12=c45,c51=c34,p5=p3,c5=c3] endmodule -module process5=process1[s1=s5,p1=p5,c1=c5,sent1=sent5,receive1=receive5,p12=p51,p51=p45,c12=c51,c51=c45,p5=p4,c5=c4] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward - expected number of rounds (equals the number of times a process receives a counter) -rewards - [c12] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- -formula leaders = (s1=4?1:0)+(s2=4?1:0)+(s3=4?1:0)+(s4=4?1:0)+(s5=4?1:0); -label "elected" = s1=4|s2=4|s3=4|s4=4|s5=4; - diff --git a/examples/mdp/asynchronous_leader/leader6.nm b/examples/mdp/asynchronous_leader/leader6.nm deleted file mode 100644 index c1c909baf..000000000 --- a/examples/mdp/asynchronous_leader/leader6.nm +++ /dev/null @@ -1,99 +0,0 @@ -// asynchronous leader election -// 4 processes -// gxn/dxp 29/01/01 - -mdp - -const int N= 6; // number of processes - -//---------------------------------------------------------------------------------------------------------------------------- -module process1 - - // COUNTER - c1 : [0..6-1]; - - // STATES - s1 : [0..4]; - // 0 make choice - // 1 have not received neighbours choice - // 2 active - // 3 inactive - // 4 leader - - // PREFERENCE - p1 : [0..1]; - - // VARIABLES FOR SENDING AND RECEIVING - receive1 : [0..2]; - // not received anything - // received choice - // received counter - sent1 : [0..2]; - // not send anything - // sent choice - // sent counter - - // pick value - [] (s1=0) -> 0.5 : (s1'=1) & (p1'=0) + 0.5 : (s1'=1) & (p1'=1); - - // send preference - [p12] (s1=1) & (sent1=0) -> (sent1'=1); - // receive preference - // stay active - [p61] (s1=1) & (receive1=0) & !( (p1=0) & (p6=1) ) -> (s1'=2) & (receive1'=1); - // become inactive - [p61] (s1=1) & (receive1=0) & (p1=0) & (p6=1) -> (s1'=3) & (receive1'=1); - - // send preference (can now reset preference) - [p12] (s1=2) & (sent1=0) -> (sent1'=1) & (p1'=0); - // send counter (already sent preference) - // not received counter yet - [c12] (s1=2) & (sent1=1) & (receive1=1) -> (sent1'=2); - // received counter (pick again) - [c12] (s1=2) & (sent1=1) & (receive1=2) -> (s1'=0) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // receive counter and not sent yet (note in this case do not pass it on as will send own counter) - [c61] (s1=2) & (receive1=1) & (sent1<2) -> (receive1'=2); - // receive counter and sent counter - // only active process (decide) - [c61] (s1=2) & (receive1=1) & (sent1=2) & (c6=N-1) -> (s1'=4) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - // other active process (pick again) - [c61] (s1=2) & (receive1=1) & (sent1=2) & (c6 (s1'=0) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // send preference (must have received preference) and can now reset - [p12] (s1=3) & (receive1>0) & (sent1=0) -> (sent1'=1) & (p1'=0); - // send counter (must have received counter first) and can now reset - [c12] (s1=3) & (receive1=2) & (sent1=1) -> (s1'=3) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // receive preference - [p61] (s1=3) & (receive1=0) -> (p1'=p6) & (receive1'=1); - // receive counter - [c61] (s1=3) & (receive1=1) & (c6 (c1'=c6+1) & (receive1'=2); - - // done - [done] (s1=4) -> (s1'=s1); - // add loop for processes who are inactive - [done] (s1=3) -> (s1'=s1); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module process2=process1[s1=s2,p1=p2,c1=c2,sent1=sent2,receive1=receive2,p12=p23,p61=p12,c12=c23,c61=c12,p6=p1,c6=c1] endmodule -module process3=process1[s1=s3,p1=p3,c1=c3,sent1=sent3,receive1=receive3,p12=p34,p61=p23,c12=c34,c61=c23,p6=p2,c6=c2] endmodule -module process4=process1[s1=s4,p1=p4,c1=c4,sent1=sent4,receive1=receive4,p12=p45,p61=p34,c12=c45,c61=c34,p6=p3,c6=c3] endmodule -module process5=process1[s1=s5,p1=p5,c1=c5,sent1=sent5,receive1=receive5,p12=p56,p61=p45,c12=c56,c61=c45,p6=p4,c6=c4] endmodule -module process6=process1[s1=s6,p1=p6,c1=c6,sent1=sent6,receive1=receive6,p12=p61,p61=p56,c12=c61,c61=c56,p6=p5,c6=c5] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward - expected number of rounds (equals the number of times a process receives a counter) -rewards - [c12] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- -formula leaders = (s1=4?1:0)+(s2=4?1:0)+(s3=4?1:0)+(s4=4?1:0)+(s5=4?1:0)+(s6=4?1:0); -label "elected" = s1=4|s2=4|s3=4|s4=4|s5=4|s6=4; - diff --git a/examples/mdp/asynchronous_leader/leader7.nm b/examples/mdp/asynchronous_leader/leader7.nm deleted file mode 100644 index 11eaba4a7..000000000 --- a/examples/mdp/asynchronous_leader/leader7.nm +++ /dev/null @@ -1,100 +0,0 @@ -// asynchronous leader election -// 4 processes -// gxn/dxp 29/01/01 - -mdp - -const int N= 7; // number of processes - -//---------------------------------------------------------------------------------------------------------------------------- -module process1 - - // COUNTER - c1 : [0..7-1]; - - // STATES - s1 : [0..4]; - // 0 make choice - // 1 have not received neighbours choice - // 2 active - // 3 inactive - // 4 leader - - // PREFERENCE - p1 : [0..1]; - - // VARIABLES FOR SENDING AND RECEIVING - receive1 : [0..2]; - // not received anything - // received choice - // received counter - sent1 : [0..2]; - // not send anything - // sent choice - // sent counter - - // pick value - [] (s1=0) -> 0.5 : (s1'=1) & (p1'=0) + 0.5 : (s1'=1) & (p1'=1); - - // send preference - [p12] (s1=1) & (sent1=0) -> (sent1'=1); - // receive preference - // stay active - [p71] (s1=1) & (receive1=0) & !( (p1=0) & (p7=1) ) -> (s1'=2) & (receive1'=1); - // become inactive - [p71] (s1=1) & (receive1=0) & (p1=0) & (p7=1) -> (s1'=3) & (receive1'=1); - - // send preference (can now reset preference) - [p12] (s1=2) & (sent1=0) -> (sent1'=1) & (p1'=0); - // send counter (already sent preference) - // not received counter yet - [c12] (s1=2) & (sent1=1) & (receive1=1) -> (sent1'=2); - // received counter (pick again) - [c12] (s1=2) & (sent1=1) & (receive1=2) -> (s1'=0) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // receive counter and not sent yet (note in this case do not pass it on as will send own counter) - [c71] (s1=2) & (receive1=1) & (sent1<2) -> (receive1'=2); - // receive counter and sent counter - // only active process (decide) - [c71] (s1=2) & (receive1=1) & (sent1=2) & (c7=N-1) -> (s1'=4) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - // other active process (pick again) - [c71] (s1=2) & (receive1=1) & (sent1=2) & (c7 (s1'=0) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // send preference (must have received preference) and can now reset - [p12] (s1=3) & (receive1>0) & (sent1=0) -> (sent1'=1) & (p1'=0); - // send counter (must have received counter first) and can now reset - [c12] (s1=3) & (receive1=2) & (sent1=1) -> (s1'=3) & (p1'=0) & (c1'=0) & (sent1'=0) & (receive1'=0); - - // receive preference - [p71] (s1=3) & (receive1=0) -> (p1'=p7) & (receive1'=1); - // receive counter - [c71] (s1=3) & (receive1=1) & (c7 (c1'=c7+1) & (receive1'=2); - - // done - [done] (s1=4) -> (s1'=s1); - // add loop for processes who are inactive - [done] (s1=3) -> (s1'=s1); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module process2=process1[s1=s2,p1=p2,c1=c2,sent1=sent2,receive1=receive2,p12=p23,p71=p12,c12=c23,c71=c12,p7=p1,c7=c1] endmodule -module process3=process1[s1=s3,p1=p3,c1=c3,sent1=sent3,receive1=receive3,p12=p34,p71=p23,c12=c34,c71=c23,p7=p2,c7=c2] endmodule -module process4=process1[s1=s4,p1=p4,c1=c4,sent1=sent4,receive1=receive4,p12=p45,p71=p34,c12=c45,c71=c34,p7=p3,c7=c3] endmodule -module process5=process1[s1=s5,p1=p5,c1=c5,sent1=sent5,receive1=receive5,p12=p56,p71=p45,c12=c56,c71=c45,p7=p4,c7=c4] endmodule -module process6=process1[s1=s6,p1=p6,c1=c6,sent1=sent6,receive1=receive6,p12=p67,p71=p56,c12=c67,c71=c56,p7=p5,c7=c5] endmodule -module process7=process1[s1=s7,p1=p7,c1=c7,sent1=sent7,receive1=receive7,p12=p71,p71=p67,c12=c71,c71=c67,p7=p6,c7=c6] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward - expected number of rounds (equals the number of times a process receives a counter) -rewards - [c12] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- -formula leaders = (s1=4?1:0)+(s2=4?1:0)+(s3=4?1:0)+(s4=4?1:0)+(s5=4?1:0)+(s6=4?1:0)+(s7=4?1:0); -label "elected" = s1=4|s2=4|s3=4|s4=4|s5=4|s6=4|s7=4; - diff --git a/examples/mdp/consensus/coin.cexprop b/examples/mdp/consensus/coin.cexprop deleted file mode 100644 index bb60f986d..000000000 --- a/examples/mdp/consensus/coin.cexprop +++ /dev/null @@ -1 +0,0 @@ -P<0.4 [ F finished & all_coins_equal_1 ] diff --git a/examples/mdp/consensus/coin.pctl b/examples/mdp/consensus/coin.pctl deleted file mode 100644 index 224ffc495..000000000 --- a/examples/mdp/consensus/coin.pctl +++ /dev/null @@ -1,20 +0,0 @@ -// C1 (with probability 1, all N processes finish the protocol) -// Pmin=? [ F finished ] - -// C2 (minimum probability that the protocol finishes with all coins equal to v) (v=1,2) -// Results are same for v=1 and v=2 by symmetry -// Analytic bound is (K-1)/(2*K) -//Pmin=? [ F finished & all_coins_equal_0 ] -//Pmin=? [ F finished & all_coins_equal_1 ] - -// Max probability of finishing protocol with coins not all equal -Pmax=? [ F finished & !agree ] - -// Min/max probability of finishing within k steps -// Pmin=? [ F<=50 finished ] -// Pmax=? [ F<=50 finished ] - -// Min/max expected steps to finish -// Rmin=? [ F finished ] -// Rmax=? [ F finished ] - diff --git a/examples/mdp/consensus/coin4.nm b/examples/mdp/consensus/coin4.nm deleted file mode 100644 index fa1c5ba00..000000000 --- a/examples/mdp/consensus/coin4.nm +++ /dev/null @@ -1,62 +0,0 @@ -// COIN FLIPPING PROTOCOL FOR POLYNOMIAL RANDOMIZED CONSENSUS [AH90] -// gxn/dxp 20/11/00 - -mdp - -// constants -const int N=4; -const int K; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> 0.5 : (coin1'=0) & (pc1'=1) + 0.5 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> 1 : (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter 1 : (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> 1 : (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> 1 : (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter 1 : (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> 1 : (pc1'=3); - -endmodule - -// construct remaining processes through renaming -module process2 = process1[pc1=pc2,coin1=coin2] endmodule -module process3 = process1[pc1=pc3,coin1=coin3] endmodule -module process4 = process1[pc1=pc4,coin1=coin4] endmodule - -// labels -label "finished" = pc1=3 & pc2=3 & pc3=3 & pc4=3 ; -label "all_coins_equal_0" = coin1=0 & coin2=0 & coin3=0 & coin4=0 ; -label "all_coins_equal_1" = coin1=1 & coin2=1 & coin3=1 & coin4=1 ; -label "agree" = coin1=coin2 & coin2=coin3 & coin3=coin4 ; - -// rewards -rewards "steps" - true : 1; -endrewards - diff --git a/examples/mdp/consensus/coin6.nm b/examples/mdp/consensus/coin6.nm deleted file mode 100644 index b373c40d5..000000000 --- a/examples/mdp/consensus/coin6.nm +++ /dev/null @@ -1,64 +0,0 @@ -// COIN FLIPPING PROTOCOL FOR POLYNOMIAL RANDOMIZED CONSENSUS [AH90] -// gxn/dxp 20/11/00 - -mdp - -// constants -const int N=6; -const int K; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> 0.5 : (coin1'=0) & (pc1'=1) + 0.5 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -// construct remaining processes through renaming -module process2 = process1[pc1=pc2,coin1=coin2] endmodule -module process3 = process1[pc1=pc3,coin1=coin3] endmodule -module process4 = process1[pc1=pc4,coin1=coin4] endmodule -module process5 = process1[pc1=pc5,coin1=coin5] endmodule -module process6 = process1[pc1=pc6,coin1=coin6] endmodule - -// labels -label "finished" = pc1=3 & pc2=3 & pc3=3 & pc4=3 & pc5=3 & pc6=3 ; -label "all_coins_equal_0" = coin1=0 & coin2=0 & coin3=0 & coin4=0 & coin5=0 & coin6=0 ; -label "all_coins_equal_1" = coin1=1 & coin2=1 & coin3=1 & coin4=1 & coin5=1 & coin6=1 ; -label "agree" = coin1=coin2 & coin2=coin3 & coin3=coin4 & coin4=coin5 & coin5=coin6 ; - -// rewards -rewards "steps" - true : 1; -endrewards - diff --git a/examples/mdp/csma/csma.cexprop b/examples/mdp/csma/csma.cexprop deleted file mode 100644 index fd4346176..000000000 --- a/examples/mdp/csma/csma.cexprop +++ /dev/null @@ -1 +0,0 @@ -P<0.5 [ !collision_max_backoff U all_delivered ] diff --git a/examples/mdp/csma/csma2_4.nm b/examples/mdp/csma/csma2_4.nm deleted file mode 100644 index ddc1f3281..000000000 --- a/examples/mdp/csma/csma2_4.nm +++ /dev/null @@ -1,128 +0,0 @@ -// CSMA/CD protocol - probabilistic version of kronos model (3 stations) -// gxn/dxp 04/12/01 - -mdp - -// note made changes since cannot have strict inequalities -// in digital clocks approach and suppose a station only sends one message - -// simplified parameters scaled -const int sigma=1; // time for messages to propagate along the bus -const int lambda=30; // time to send a message - -// actual parameters -const int N = 2; // number of processes -const int K = 4; // exponential backoff limit -const int slot = 2*sigma; // length of slot -const int M = 15 ; // max number of slots to wait -//const int lambda=782; -//const int sigma=26; - - -//---------------------------------------------------------------------------------------------------------------------------- -// the bus -module bus - - b : [0..2]; - // b=0 - idle - // b=1 - active - // b=2 - collision - - // clocks of bus - y1 : [0..sigma+1]; // time since first send (used find time until channel sensed busy) - y2 : [0..sigma+1]; // time since second send (used to find time until collision detected) - - // a sender sends (ok - no other message being sent) - [send1] (b=0) -> (b'=1); - [send2] (b=0) -> (b'=1); - - // a sender sends (bus busy - collision) - [send1] (b=1|b=2) & (y1 (b'=2); - [send2] (b=1|b=2) & (y1 (b'=2); - - // finish sending - [end1] (b=1) -> (b'=0) & (y1'=0); - [end2] (b=1) -> (b'=0) & (y1'=0); - - // bus busy - [busy1] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy2] (b=1|b=2) & (y1>=sigma) -> (b'=b); - - // collision detected - [cd] (b=2) & (y2<=sigma) -> (b'=0) & (y1'=0) & (y2'=0); - - // time passage - [time] (b=0) -> (y1'=0); // value of y1/y2 does not matter in state 0 - [time] (b=1) -> (y1'=min(y1+1,sigma+1)); // no invariant in state 1 - [time] (b=2) & (y2 (y1'=min(y1+1,sigma+1)) & (y2'=min(y2+1,sigma+1)); // invariant in state 2 (time until collision detected) - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- -// model of first sender -module station1 - - // LOCAL STATE - s1 : [0..5]; - // s1=0 - initial state - // s1=1 - transmit - // s1=2 - collision (set backoff) - // s1=3 - wait (bus busy) - // s1=4 - successfully sent - - // LOCAL CLOCK - x1 : [0..max(lambda,slot)]; - - // BACKOFF COUNTER (number of slots to wait) - bc1 : [0..M]; - - // COLLISION COUNTER - cd1 : [0..K]; - - // start sending - [send1] (s1=0) -> (s1'=1) & (x1'=0); // start sending - [busy1] (s1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // detects channel is busy so go into backoff - - // transmitting - [time] (s1=1) & (x1 (x1'=min(x1+1,lambda)); // let time pass - [end1] (s1=1) & (x1=lambda) -> (s1'=4) & (x1'=0); // finished - [cd] (s1=1) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // collision detected (increment backoff counter) - [cd] !(s1=1) -> (s1'=s1); // add loop for collision detection when not important - - // set backoff (no time can pass in this state) - // probability depends on which transmission this is (cd1) - [] s1=2 & cd1=1 -> 1/2 : (s1'=3) & (bc1'=0) + 1/2 : (s1'=3) & (bc1'=1) ; - [] s1=2 & cd1=2 -> 1/4 : (s1'=3) & (bc1'=0) + 1/4 : (s1'=3) & (bc1'=1) + 1/4 : (s1'=3) & (bc1'=2) + 1/4 : (s1'=3) & (bc1'=3) ; - [] s1=2 & cd1=3 -> 1/8 : (s1'=3) & (bc1'=0) + 1/8 : (s1'=3) & (bc1'=1) + 1/8 : (s1'=3) & (bc1'=2) + 1/8 : (s1'=3) & (bc1'=3) + 1/8 : (s1'=3) & (bc1'=4) + 1/8 : (s1'=3) & (bc1'=5) + 1/8 : (s1'=3) & (bc1'=6) + 1/8 : (s1'=3) & (bc1'=7) ; - [] s1=2 & cd1=4 -> 1/16 : (s1'=3) & (bc1'=0) + 1/16 : (s1'=3) & (bc1'=1) + 1/16 : (s1'=3) & (bc1'=2) + 1/16 : (s1'=3) & (bc1'=3) + 1/16 : (s1'=3) & (bc1'=4) + 1/16 : (s1'=3) & (bc1'=5) + 1/16 : (s1'=3) & (bc1'=6) + 1/16 : (s1'=3) & (bc1'=7) + 1/16 : (s1'=3) & (bc1'=8) + 1/16 : (s1'=3) & (bc1'=9) + 1/16 : (s1'=3) & (bc1'=10) + 1/16 : (s1'=3) & (bc1'=11) + 1/16 : (s1'=3) & (bc1'=12) + 1/16 : (s1'=3) & (bc1'=13) + 1/16 : (s1'=3) & (bc1'=14) + 1/16 : (s1'=3) & (bc1'=15) ; - - // wait until backoff counter reaches 0 then send again - [time] (s1=3) & (x1 (x1'=x1+1); // let time pass (in slot) - [time] (s1=3) & (x1=slot) & (bc1>0) -> (x1'=1) & (bc1'=bc1-1); // let time pass (move slots) - [send1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=1) & (x1'=0); // finished backoff (bus appears free) - [busy1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // finished backoff (bus busy) - - // once finished nothing matters - [time] (s1>=4) -> (x1'=0); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module station2=station1[s1=s2,x1=x2,cd1=cd2,bc1=bc2,send1=send2,busy1=busy2,end1=end2] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward structure for expected time -rewards "time" - [time] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- - -// labels/formulae -label "all_delivered" = s1=4&s2=4; -label "one_delivered" = s1=4|s2=4; -label "collision_max_backoff" = (cd1=K & s1=1 & b=2)|(cd2=K & s2=1 & b=2); - diff --git a/examples/mdp/csma/csma2_6.nm b/examples/mdp/csma/csma2_6.nm deleted file mode 100644 index d48bf5509..000000000 --- a/examples/mdp/csma/csma2_6.nm +++ /dev/null @@ -1,129 +0,0 @@ -// CSMA/CD protocol - probabilistic version of kronos model (3 stations) -// gxn/dxp 04/12/01 - -mdp - -// note made changes since cannot have strict inequalities -// in digital clocks approach and suppose a station only sends one message - -// simplified parameters scaled -const int sigma=1; // time for messages to propagate along the bus -const int lambda=30; // time to send a message - -// actual parameters -const int N = 2; // number of processes -const int K = 6; // exponential backoff limit -const int slot = 2*sigma; // length of slot -const int M = 63; // max number of slots to wait -//const int lambda=782; -//const int sigma=26; - -//---------------------------------------------------------------------------------------------------------------------------- -// the bus -module bus - - b : [0..2]; - // b=0 - idle - // b=1 - active - // b=2 - collision - - // clocks of bus - y1 : [0..sigma+1]; // time since first send (used find time until channel sensed busy) - y2 : [0..sigma+1]; // time since second send (used to find time until collision detected) - - // a sender sends (ok - no other message being sent) - [send1] (b=0) -> (b'=1); - [send2] (b=0) -> (b'=1); - - // a sender sends (bus busy - collision) - [send1] (b=1|b=2) & (y1 (b'=2); - [send2] (b=1|b=2) & (y1 (b'=2); - - // finish sending - [end1] (b=1) -> (b'=0) & (y1'=0); - [end2] (b=1) -> (b'=0) & (y1'=0); - - // bus busy - [busy1] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy2] (b=1|b=2) & (y1>=sigma) -> (b'=b); - - // collision detected - [cd] (b=2) & (y2<=sigma) -> (b'=0) & (y1'=0) & (y2'=0); - - // time passage - [time] (b=0) -> (y1'=0); // value of y1/y2 does not matter in state 0 - [time] (b=1) -> (y1'=min(y1+1,sigma+1)); // no invariant in state 1 - [time] (b=2) & (y2 (y1'=min(y1+1,sigma+1)) & (y2'=min(y2+1,sigma+1)); // invariant in state 2 (time until collision detected) - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- -// model of first sender -module station1 - - // LOCAL STATE - s1 : [0..5]; - // s1=0 - initial state - // s1=1 - transmit - // s1=2 - collision (set backoff) - // s1=3 - wait (bus busy) - // s1=4 - successfully sent - - // LOCAL CLOCK - x1 : [0..max(lambda,slot)]; - - // BACKOFF COUNTER (number of slots to wait) - bc1 : [0..M]; - - // COLLISION COUNTER - cd1 : [0..K]; - - // start sending - [send1] (s1=0) -> (s1'=1) & (x1'=0); // start sending - [busy1] (s1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // detects channel is busy so go into backoff - - // transmitting - [time] (s1=1) & (x1 (x1'=min(x1+1,lambda)); // let time pass - [end1] (s1=1) & (x1=lambda) -> (s1'=4) & (x1'=0); // finished - [cd] (s1=1) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // collision detected (increment backoff counter) - [cd] !(s1=1) -> (s1'=s1); // add loop for collision detection when not important - - // set backoff (no time can pass in this state) - // probability depends on which transmission this is (cd1) - [] s1=2 & cd1=1 -> 1/2 : (s1'=3) & (bc1'=0) + 1/2 : (s1'=3) & (bc1'=1) ; - [] s1=2 & cd1=2 -> 1/4 : (s1'=3) & (bc1'=0) + 1/4 : (s1'=3) & (bc1'=1) + 1/4 : (s1'=3) & (bc1'=2) + 1/4 : (s1'=3) & (bc1'=3) ; - [] s1=2 & cd1=3 -> 1/8 : (s1'=3) & (bc1'=0) + 1/8 : (s1'=3) & (bc1'=1) + 1/8 : (s1'=3) & (bc1'=2) + 1/8 : (s1'=3) & (bc1'=3) + 1/8 : (s1'=3) & (bc1'=4) + 1/8 : (s1'=3) & (bc1'=5) + 1/8 : (s1'=3) & (bc1'=6) + 1/8 : (s1'=3) & (bc1'=7) ; - [] s1=2 & cd1=4 -> 1/16 : (s1'=3) & (bc1'=0) + 1/16 : (s1'=3) & (bc1'=1) + 1/16 : (s1'=3) & (bc1'=2) + 1/16 : (s1'=3) & (bc1'=3) + 1/16 : (s1'=3) & (bc1'=4) + 1/16 : (s1'=3) & (bc1'=5) + 1/16 : (s1'=3) & (bc1'=6) + 1/16 : (s1'=3) & (bc1'=7) + 1/16 : (s1'=3) & (bc1'=8) + 1/16 : (s1'=3) & (bc1'=9) + 1/16 : (s1'=3) & (bc1'=10) + 1/16 : (s1'=3) & (bc1'=11) + 1/16 : (s1'=3) & (bc1'=12) + 1/16 : (s1'=3) & (bc1'=13) + 1/16 : (s1'=3) & (bc1'=14) + 1/16 : (s1'=3) & (bc1'=15) ; - [] s1=2 & cd1=5 -> 1/32 : (s1'=3) & (bc1'=0) + 1/32 : (s1'=3) & (bc1'=1) + 1/32 : (s1'=3) & (bc1'=2) + 1/32 : (s1'=3) & (bc1'=3) + 1/32 : (s1'=3) & (bc1'=4) + 1/32 : (s1'=3) & (bc1'=5) + 1/32 : (s1'=3) & (bc1'=6) + 1/32 : (s1'=3) & (bc1'=7) + 1/32 : (s1'=3) & (bc1'=8) + 1/32 : (s1'=3) & (bc1'=9) + 1/32 : (s1'=3) & (bc1'=10) + 1/32 : (s1'=3) & (bc1'=11) + 1/32 : (s1'=3) & (bc1'=12) + 1/32 : (s1'=3) & (bc1'=13) + 1/32 : (s1'=3) & (bc1'=14) + 1/32 : (s1'=3) & (bc1'=15) + 1/32 : (s1'=3) & (bc1'=16) + 1/32 : (s1'=3) & (bc1'=17) + 1/32 : (s1'=3) & (bc1'=18) + 1/32 : (s1'=3) & (bc1'=19) + 1/32 : (s1'=3) & (bc1'=20) + 1/32 : (s1'=3) & (bc1'=21) + 1/32 : (s1'=3) & (bc1'=22) + 1/32 : (s1'=3) & (bc1'=23) + 1/32 : (s1'=3) & (bc1'=24) + 1/32 : (s1'=3) & (bc1'=25) + 1/32 : (s1'=3) & (bc1'=26) + 1/32 : (s1'=3) & (bc1'=27) + 1/32 : (s1'=3) & (bc1'=28) + 1/32 : (s1'=3) & (bc1'=29) + 1/32 : (s1'=3) & (bc1'=30) + 1/32 : (s1'=3) & (bc1'=31) ; - [] s1=2 & cd1=6 -> 1/64 : (s1'=3) & (bc1'=0) + 1/64 : (s1'=3) & (bc1'=1) + 1/64 : (s1'=3) & (bc1'=2) + 1/64 : (s1'=3) & (bc1'=3) + 1/64 : (s1'=3) & (bc1'=4) + 1/64 : (s1'=3) & (bc1'=5) + 1/64 : (s1'=3) & (bc1'=6) + 1/64 : (s1'=3) & (bc1'=7) + 1/64 : (s1'=3) & (bc1'=8) + 1/64 : (s1'=3) & (bc1'=9) + 1/64 : (s1'=3) & (bc1'=10) + 1/64 : (s1'=3) & (bc1'=11) + 1/64 : (s1'=3) & (bc1'=12) + 1/64 : (s1'=3) & (bc1'=13) + 1/64 : (s1'=3) & (bc1'=14) + 1/64 : (s1'=3) & (bc1'=15) + 1/64 : (s1'=3) & (bc1'=16) + 1/64 : (s1'=3) & (bc1'=17) + 1/64 : (s1'=3) & (bc1'=18) + 1/64 : (s1'=3) & (bc1'=19) + 1/64 : (s1'=3) & (bc1'=20) + 1/64 : (s1'=3) & (bc1'=21) + 1/64 : (s1'=3) & (bc1'=22) + 1/64 : (s1'=3) & (bc1'=23) + 1/64 : (s1'=3) & (bc1'=24) + 1/64 : (s1'=3) & (bc1'=25) + 1/64 : (s1'=3) & (bc1'=26) + 1/64 : (s1'=3) & (bc1'=27) + 1/64 : (s1'=3) & (bc1'=28) + 1/64 : (s1'=3) & (bc1'=29) + 1/64 : (s1'=3) & (bc1'=30) + 1/64 : (s1'=3) & (bc1'=31) + 1/64 : (s1'=3) & (bc1'=32) + 1/64 : (s1'=3) & (bc1'=33) + 1/64 : (s1'=3) & (bc1'=34) + 1/64 : (s1'=3) & (bc1'=35) + 1/64 : (s1'=3) & (bc1'=36) + 1/64 : (s1'=3) & (bc1'=37) + 1/64 : (s1'=3) & (bc1'=38) + 1/64 : (s1'=3) & (bc1'=39) + 1/64 : (s1'=3) & (bc1'=40) + 1/64 : (s1'=3) & (bc1'=41) + 1/64 : (s1'=3) & (bc1'=42) + 1/64 : (s1'=3) & (bc1'=43) + 1/64 : (s1'=3) & (bc1'=44) + 1/64 : (s1'=3) & (bc1'=45) + 1/64 : (s1'=3) & (bc1'=46) + 1/64 : (s1'=3) & (bc1'=47) + 1/64 : (s1'=3) & (bc1'=48) + 1/64 : (s1'=3) & (bc1'=49) + 1/64 : (s1'=3) & (bc1'=50) + 1/64 : (s1'=3) & (bc1'=51) + 1/64 : (s1'=3) & (bc1'=52) + 1/64 : (s1'=3) & (bc1'=53) + 1/64 : (s1'=3) & (bc1'=54) + 1/64 : (s1'=3) & (bc1'=55) + 1/64 : (s1'=3) & (bc1'=56) + 1/64 : (s1'=3) & (bc1'=57) + 1/64 : (s1'=3) & (bc1'=58) + 1/64 : (s1'=3) & (bc1'=59) + 1/64 : (s1'=3) & (bc1'=60) + 1/64 : (s1'=3) & (bc1'=61) + 1/64 : (s1'=3) & (bc1'=62) + 1/64 : (s1'=3) & (bc1'=63) ; - - // wait until backoff counter reaches 0 then send again - [time] (s1=3) & (x1 (x1'=x1+1); // let time pass (in slot) - [time] (s1=3) & (x1=slot) & (bc1>0) -> (x1'=1) & (bc1'=bc1-1); // let time pass (move slots) - [send1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=1) & (x1'=0); // finished backoff (bus appears free) - [busy1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // finished backoff (bus busy) - - // once finished nothing matters - [time] (s1>=4) -> (x1'=0); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module station2=station1[s1=s2,x1=x2,cd1=cd2,bc1=bc2,send1=send2,busy1=busy2,end1=end2] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward structure for expected time -rewards "time" - [time] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- - -// labels/formulae -label "all_delivered" = s1=4&s2=4; -label "one_delivered" = s1=4|s2=4; -label "collision_max_backoff" = (cd1=K & s1=1 & b=2)|(cd2=K & s2=1 & b=2); - diff --git a/examples/mdp/csma/csma3_2.nm b/examples/mdp/csma/csma3_2.nm deleted file mode 100644 index 347dee08f..000000000 --- a/examples/mdp/csma/csma3_2.nm +++ /dev/null @@ -1,130 +0,0 @@ -// CSMA/CD protocol - probabilistic version of kronos model (3 stations) -// gxn/dxp 04/12/01 - -mdp - -// note made changes since cannot have strict inequalities -// in digital clocks approach and suppose a station only sends one message - -// simplified parameters scaled -const int sigma=1; // time for messages to propagate along the bus -const int lambda=30; // time to send a message - -// actual parameters -const int N = 3; // number of processes -const int K = 2; // exponential backoff limit -const int slot = 2*sigma; // length of slot -const int M = 3; // max number of slots to wait -//const int lambda=782; -//const int sigma=26; - -//---------------------------------------------------------------------------------------------------------------------------- -// the bus -module bus - - b : [0..2]; - // b=0 - idle - // b=1 - active - // b=2 - collision - - // clocks of bus - y1 : [0..sigma+1]; // time since first send (used find time until channel sensed busy) - y2 : [0..sigma+1]; // time since second send (used to find time until collision detected) - - // a sender sends (ok - no other message being sent) - [send1] (b=0) -> (b'=1); - [send2] (b=0) -> (b'=1); - [send3] (b=0) -> (b'=1); - - // a sender sends (bus busy - collision) - [send1] (b=1|b=2) & (y1 (b'=2); - [send2] (b=1|b=2) & (y1 (b'=2); - [send3] (b=1|b=2) & (y1 (b'=2); - - // finish sending - [end1] (b=1) -> (b'=0) & (y1'=0); - [end2] (b=1) -> (b'=0) & (y1'=0); - [end3] (b=1) -> (b'=0) & (y1'=0); - - // bus busy - [busy1] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy2] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy3] (b=1|b=2) & (y1>=sigma) -> (b'=b); - - // collision detected - [cd] (b=2) & (y2<=sigma) -> (b'=0) & (y1'=0) & (y2'=0); - - // time passage - [time] (b=0) -> (y1'=0); // value of y1/y2 does not matter in state 0 - [time] (b=1) -> (y1'=min(y1+1,sigma+1)); // no invariant in state 1 - [time] (b=2) & (y2 (y1'=min(y1+1,sigma+1)) & (y2'=min(y2+1,sigma+1)); // invariant in state 2 (time until collision detected) - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- -// model of first sender -module station1 - - // LOCAL STATE - s1 : [0..5]; - // s1=0 - initial state - // s1=1 - transmit - // s1=2 - collision (set backoff) - // s1=3 - wait (bus busy) - // s1=4 - successfully sent - - // LOCAL CLOCK - x1 : [0..max(lambda,slot)]; - - // BACKOFF COUNTER (number of slots to wait) - bc1 : [0..M]; - - // COLLISION COUNTER - cd1 : [0..K]; - - // start sending - [send1] (s1=0) -> (s1'=1) & (x1'=0); // start sending - [busy1] (s1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // detects channel is busy so go into backoff - - // transmitting - [time] (s1=1) & (x1 (x1'=min(x1+1,lambda)); // let time pass - [end1] (s1=1) & (x1=lambda) -> (s1'=4) & (x1'=0); // finished - [cd] (s1=1) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // collision detected (increment backoff counter) - [cd] !(s1=1) -> (s1'=s1); // add loop for collision detection when not important - - // set backoff (no time can pass in this state) - // probability depends on which transmission this is (cd1) - [] s1=2 & cd1=1 -> 1/2 : (s1'=3) & (bc1'=0) + 1/2 : (s1'=3) & (bc1'=1) ; - [] s1=2 & cd1=2 -> 1/4 : (s1'=3) & (bc1'=0) + 1/4 : (s1'=3) & (bc1'=1) + 1/4 : (s1'=3) & (bc1'=2) + 1/4 : (s1'=3) & (bc1'=3) ; - - // wait until backoff counter reaches 0 then send again - [time] (s1=3) & (x1 (x1'=x1+1); // let time pass (in slot) - [time] (s1=3) & (x1=slot) & (bc1>0) -> (x1'=1) & (bc1'=bc1-1); // let time pass (move slots) - [send1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=1) & (x1'=0); // finished backoff (bus appears free) - [busy1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // finished backoff (bus busy) - - // once finished nothing matters - [time] (s1>=4) -> (x1'=0); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module station2=station1[s1=s2,x1=x2,cd1=cd2,bc1=bc2,send1=send2,busy1=busy2,end1=end2] endmodule -module station3=station1[s1=s3,x1=x3,cd1=cd3,bc1=bc3,send1=send3,busy1=busy3,end1=end3] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward structure for expected time -rewards "time" - [time] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- - -// labels/formulae -label "all_delivered" = s1=4&s2=4&s3=4; -label "one_delivered" = s1=4|s2=4|s3=4; -label "collision_max_backoff" = (cd1=K & s1=1 & b=2)|(cd2=K & s2=1 & b=2)|(cd3=K & s3=1 & b=2); - diff --git a/examples/mdp/csma/csma3_4.nm b/examples/mdp/csma/csma3_4.nm deleted file mode 100644 index 8739053e5..000000000 --- a/examples/mdp/csma/csma3_4.nm +++ /dev/null @@ -1,134 +0,0 @@ -// CSMA/CD protocol - probabilistic version of kronos model (3 stations) -// gxn/dxp 04/12/01 - -mdp - -// note made changes since cannot have strict inequalities -// in digital clocks approach and suppose a station only sends one message - -// simplified parameters scaled -const int sigma=1; // time for messages to propagate along the bus -const int lambda=30; // time to send a message - -// actual parameters -const int N = 3; // number of processes -const int K = 4; // exponential backoff limit -const int slot = 2*sigma; // length of slot -const int M = 15; // max number of slots to wait -//const int lambda=782; -//const int sigma=26; - -//---------------------------------------------------------------------------------------------------------------------------- -// the bus -module bus - - b : [0..2]; - // b=0 - idle - // b=1 - active - // b=2 - collision - - // clocks of bus - y1 : [0..sigma+1]; // time since first send (used find time until channel sensed busy) - y2 : [0..sigma+1]; // time since second send (used to find time until collision detected) - - // a sender sends (ok - no other message being sent) - [send1] (b=0) -> (b'=1); - [send2] (b=0) -> (b'=1); - [send3] (b=0) -> (b'=1); - - // a sender sends (bus busy - collision) - [send1] (b=1|b=2) & (y1 (b'=2); - [send2] (b=1|b=2) & (y1 (b'=2); - [send3] (b=1|b=2) & (y1 (b'=2); - - // finish sending - [end1] (b=1) -> (b'=0) & (y1'=0); - [end2] (b=1) -> (b'=0) & (y1'=0); - [end3] (b=1) -> (b'=0) & (y1'=0); - - // bus busy - [busy1] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy2] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy3] (b=1|b=2) & (y1>=sigma) -> (b'=b); - - // collision detected - [cd] (b=2) & (y2<=sigma) -> (b'=0) & (y1'=0) & (y2'=0); - - // time passage - [time] (b=0) -> (y1'=0); // value of y1/y2 does not matter in state 0 - [time] (b=1) -> (y1'=min(y1+1,sigma+1)); // no invariant in state 1 - [time] (b=2) & (y2 (y1'=min(y1+1,sigma+1)) & (y2'=min(y2+1,sigma+1)); // invariant in state 2 (time until collision detected) - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- -// model of first sender -module station1 - - // LOCAL STATE - s1 : [0..5]; - // s1=0 - initial state - // s1=1 - transmit - // s1=2 - collision (set backoff) - // s1=3 - wait (bus busy) - // s1=4 - successfully sent - - // LOCAL CLOCK - x1 : [0..max(lambda,slot)]; - - // BACKOFF COUNTER (number of slots to wait) - bc1 : [0..M]; - - // COLLISION COUNTER - cd1 : [0..K]; - - // start sending - [send1] (s1=0) -> (s1'=1) & (x1'=0); // start sending - [busy1] (s1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // detects channel is busy so go into backoff - - // transmitting - [time] (s1=1) & (x1 (x1'=min(x1+1,lambda)); // let time pass - [end1] (s1=1) & (x1=lambda) -> (s1'=4) & (x1'=0); // finished - [cd] (s1=1) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // collision detected (increment backoff counter) - [cd] !(s1=1) -> (s1'=s1); // add loop for collision detection when not important - - // set backoff (no time can pass in this state) - // probability depends on which transmission this is (cd1) - [] s1=2 & cd1=1 -> 1/2 : (s1'=3) & (bc1'=0) + 1/2 : (s1'=3) & (bc1'=1) ; - [] s1=2 & cd1=2 -> 1/4 : (s1'=3) & (bc1'=0) + 1/4 : (s1'=3) & (bc1'=1) + 1/4 : (s1'=3) & (bc1'=2) + 1/4 : (s1'=3) & (bc1'=3) ; - [] s1=2 & cd1=3 -> 1/8 : (s1'=3) & (bc1'=0) + 1/8 : (s1'=3) & (bc1'=1) + 1/8 : (s1'=3) & (bc1'=2) + 1/8 : (s1'=3) & (bc1'=3) + 1/8 : (s1'=3) & (bc1'=4) + 1/8 : (s1'=3) & (bc1'=5) + 1/8 : (s1'=3) & (bc1'=6) + 1/8 : (s1'=3) & (bc1'=7) ; - [] s1=2 & cd1=4 -> 1/16 : (s1'=3) & (bc1'=0) + 1/16 : (s1'=3) & (bc1'=1) + 1/16 : (s1'=3) & (bc1'=2) + 1/16 : (s1'=3) & (bc1'=3) + 1/16 : (s1'=3) & (bc1'=4) + 1/16 : (s1'=3) & (bc1'=5) + 1/16 : (s1'=3) & (bc1'=6) + 1/16 : (s1'=3) & (bc1'=7) + 1/16 : (s1'=3) & (bc1'=8) + 1/16 : (s1'=3) & (bc1'=9) + 1/16 : (s1'=3) & (bc1'=10) + 1/16 : (s1'=3) & (bc1'=11) + 1/16 : (s1'=3) & (bc1'=12) + 1/16 : (s1'=3) & (bc1'=13) + 1/16 : (s1'=3) & (bc1'=14) + 1/16 : (s1'=3) & (bc1'=15) ; - - // wait until backoff counter reaches 0 then send again - [time] (s1=3) & (x1 (x1'=x1+1); // let time pass (in slot) - [time] (s1=3) & (x1=slot) & (bc1>0) -> (x1'=1) & (bc1'=bc1-1); // let time pass (move slots) - [send1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=1) & (x1'=0); // finished backoff (bus appears free) - [busy1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // finished backoff (bus busy) - - // once finished nothing matters - [time] (s1>=4) -> (x1'=0); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module station2=station1[s1=s2,x1=x2,cd1=cd2,bc1=bc2,send1=send2,busy1=busy2,end1=end2] endmodule -module station3=station1[s1=s3,x1=x3,cd1=cd3,bc1=bc3,send1=send3,busy1=busy3,end1=end3] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward structure for expected time -rewards "time" - [time] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- - -// labels/formulae -label "all_delivered" = s1=4&s2=4&s3=4; -label "one_delivered" = s1=4|s2=4|s3=4; -label "collision_max_backoff" = (cd1=K & s1=1 & b=2)|(cd2=K & s2=1 & b=2)|(cd3=K & s3=1 & b=2); -formula min_backoff_after_success = min(s1=4?cd1:K+1,s2=4?cd2:K+1,s3=4?cd3:K+1); -formula min_collisions = min(cd1,cd2,cd3); -formula max_collisions = max(cd1,cd2,cd3); diff --git a/examples/mdp/csma/csma3_6.nm b/examples/mdp/csma/csma3_6.nm deleted file mode 100644 index 19ae5c4e0..000000000 --- a/examples/mdp/csma/csma3_6.nm +++ /dev/null @@ -1,134 +0,0 @@ -// CSMA/CD protocol - probabilistic version of kronos model (3 stations) -// gxn/dxp 04/12/01 - -mdp - -// note made changes since cannot have strict inequalities -// in digital clocks approach and suppose a station only sends one message - -// simplified parameters scaled -const int sigma=1; // time for messages to propagate along the bus -const int lambda=30; // time to send a message - -// actual parameters -const int N = 3; // number of processes -const int K = 6; // exponential backoff limit -const int slot = 2*sigma; // length of slot -const int M = 63; // max number of slots to wait -//const int lambda=782; -//const int sigma=26; - -//---------------------------------------------------------------------------------------------------------------------------- -// the bus -module bus - - b : [0..2]; - // b=0 - idle - // b=1 - active - // b=2 - collision - - // clocks of bus - y1 : [0..sigma+1]; // time since first send (used find time until channel sensed busy) - y2 : [0..sigma+1]; // time since second send (used to find time until collision detected) - - // a sender sends (ok - no other message being sent) - [send1] (b=0) -> (b'=1); - [send2] (b=0) -> (b'=1); - [send3] (b=0) -> (b'=1); - - // a sender sends (bus busy - collision) - [send1] (b=1|b=2) & (y1 (b'=2); - [send2] (b=1|b=2) & (y1 (b'=2); - [send3] (b=1|b=2) & (y1 (b'=2); - - // finish sending - [end1] (b=1) -> (b'=0) & (y1'=0); - [end2] (b=1) -> (b'=0) & (y1'=0); - [end3] (b=1) -> (b'=0) & (y1'=0); - - // bus busy - [busy1] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy2] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy3] (b=1|b=2) & (y1>=sigma) -> (b'=b); - - // collision detected - [cd] (b=2) & (y2<=sigma) -> (b'=0) & (y1'=0) & (y2'=0); - - // time passage - [time] (b=0) -> (y1'=0); // value of y1/y2 does not matter in state 0 - [time] (b=1) -> (y1'=min(y1+1,sigma+1)); // no invariant in state 1 - [time] (b=2) & (y2 (y1'=min(y1+1,sigma+1)) & (y2'=min(y2+1,sigma+1)); // invariant in state 2 (time until collision detected) - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- -// model of first sender -module station1 - - // LOCAL STATE - s1 : [0..5]; - // s1=0 - initial state - // s1=1 - transmit - // s1=2 - collision (set backoff) - // s1=3 - wait (bus busy) - // s1=4 - successfully sent - - // LOCAL CLOCK - x1 : [0..max(lambda,slot)]; - - // BACKOFF COUNTER (number of slots to wait) - bc1 : [0..M]; - - // COLLISION COUNTER - cd1 : [0..K]; - - // start sending - [send1] (s1=0) -> (s1'=1) & (x1'=0); // start sending - [busy1] (s1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // detects channel is busy so go into backoff - - // transmitting - [time] (s1=1) & (x1 (x1'=min(x1+1,lambda)); // let time pass - [end1] (s1=1) & (x1=lambda) -> (s1'=4) & (x1'=0); // finished - [cd] (s1=1) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // collision detected (increment backoff counter) - [cd] !(s1=1) -> (s1'=s1); // add loop for collision detection when not important - - // set backoff (no time can pass in this state) - // probability depends on which transmission this is (cd1) - [] s1=2 & cd1=1 -> 1/2 : (s1'=3) & (bc1'=0) + 1/2 : (s1'=3) & (bc1'=1) ; - [] s1=2 & cd1=2 -> 1/4 : (s1'=3) & (bc1'=0) + 1/4 : (s1'=3) & (bc1'=1) + 1/4 : (s1'=3) & (bc1'=2) + 1/4 : (s1'=3) & (bc1'=3) ; - [] s1=2 & cd1=3 -> 1/8 : (s1'=3) & (bc1'=0) + 1/8 : (s1'=3) & (bc1'=1) + 1/8 : (s1'=3) & (bc1'=2) + 1/8 : (s1'=3) & (bc1'=3) + 1/8 : (s1'=3) & (bc1'=4) + 1/8 : (s1'=3) & (bc1'=5) + 1/8 : (s1'=3) & (bc1'=6) + 1/8 : (s1'=3) & (bc1'=7) ; - [] s1=2 & cd1=4 -> 1/16 : (s1'=3) & (bc1'=0) + 1/16 : (s1'=3) & (bc1'=1) + 1/16 : (s1'=3) & (bc1'=2) + 1/16 : (s1'=3) & (bc1'=3) + 1/16 : (s1'=3) & (bc1'=4) + 1/16 : (s1'=3) & (bc1'=5) + 1/16 : (s1'=3) & (bc1'=6) + 1/16 : (s1'=3) & (bc1'=7) + 1/16 : (s1'=3) & (bc1'=8) + 1/16 : (s1'=3) & (bc1'=9) + 1/16 : (s1'=3) & (bc1'=10) + 1/16 : (s1'=3) & (bc1'=11) + 1/16 : (s1'=3) & (bc1'=12) + 1/16 : (s1'=3) & (bc1'=13) + 1/16 : (s1'=3) & (bc1'=14) + 1/16 : (s1'=3) & (bc1'=15) ; - [] s1=2 & cd1=5 -> 1/32 : (s1'=3) & (bc1'=0) + 1/32 : (s1'=3) & (bc1'=1) + 1/32 : (s1'=3) & (bc1'=2) + 1/32 : (s1'=3) & (bc1'=3) + 1/32 : (s1'=3) & (bc1'=4) + 1/32 : (s1'=3) & (bc1'=5) + 1/32 : (s1'=3) & (bc1'=6) + 1/32 : (s1'=3) & (bc1'=7) + 1/32 : (s1'=3) & (bc1'=8) + 1/32 : (s1'=3) & (bc1'=9) + 1/32 : (s1'=3) & (bc1'=10) + 1/32 : (s1'=3) & (bc1'=11) + 1/32 : (s1'=3) & (bc1'=12) + 1/32 : (s1'=3) & (bc1'=13) + 1/32 : (s1'=3) & (bc1'=14) + 1/32 : (s1'=3) & (bc1'=15) + 1/32 : (s1'=3) & (bc1'=16) + 1/32 : (s1'=3) & (bc1'=17) + 1/32 : (s1'=3) & (bc1'=18) + 1/32 : (s1'=3) & (bc1'=19) + 1/32 : (s1'=3) & (bc1'=20) + 1/32 : (s1'=3) & (bc1'=21) + 1/32 : (s1'=3) & (bc1'=22) + 1/32 : (s1'=3) & (bc1'=23) + 1/32 : (s1'=3) & (bc1'=24) + 1/32 : (s1'=3) & (bc1'=25) + 1/32 : (s1'=3) & (bc1'=26) + 1/32 : (s1'=3) & (bc1'=27) + 1/32 : (s1'=3) & (bc1'=28) + 1/32 : (s1'=3) & (bc1'=29) + 1/32 : (s1'=3) & (bc1'=30) + 1/32 : (s1'=3) & (bc1'=31) ; - [] s1=2 & cd1=6 -> 1/64 : (s1'=3) & (bc1'=0) + 1/64 : (s1'=3) & (bc1'=1) + 1/64 : (s1'=3) & (bc1'=2) + 1/64 : (s1'=3) & (bc1'=3) + 1/64 : (s1'=3) & (bc1'=4) + 1/64 : (s1'=3) & (bc1'=5) + 1/64 : (s1'=3) & (bc1'=6) + 1/64 : (s1'=3) & (bc1'=7) + 1/64 : (s1'=3) & (bc1'=8) + 1/64 : (s1'=3) & (bc1'=9) + 1/64 : (s1'=3) & (bc1'=10) + 1/64 : (s1'=3) & (bc1'=11) + 1/64 : (s1'=3) & (bc1'=12) + 1/64 : (s1'=3) & (bc1'=13) + 1/64 : (s1'=3) & (bc1'=14) + 1/64 : (s1'=3) & (bc1'=15) + 1/64 : (s1'=3) & (bc1'=16) + 1/64 : (s1'=3) & (bc1'=17) + 1/64 : (s1'=3) & (bc1'=18) + 1/64 : (s1'=3) & (bc1'=19) + 1/64 : (s1'=3) & (bc1'=20) + 1/64 : (s1'=3) & (bc1'=21) + 1/64 : (s1'=3) & (bc1'=22) + 1/64 : (s1'=3) & (bc1'=23) + 1/64 : (s1'=3) & (bc1'=24) + 1/64 : (s1'=3) & (bc1'=25) + 1/64 : (s1'=3) & (bc1'=26) + 1/64 : (s1'=3) & (bc1'=27) + 1/64 : (s1'=3) & (bc1'=28) + 1/64 : (s1'=3) & (bc1'=29) + 1/64 : (s1'=3) & (bc1'=30) + 1/64 : (s1'=3) & (bc1'=31) + 1/64 : (s1'=3) & (bc1'=32) + 1/64 : (s1'=3) & (bc1'=33) + 1/64 : (s1'=3) & (bc1'=34) + 1/64 : (s1'=3) & (bc1'=35) + 1/64 : (s1'=3) & (bc1'=36) + 1/64 : (s1'=3) & (bc1'=37) + 1/64 : (s1'=3) & (bc1'=38) + 1/64 : (s1'=3) & (bc1'=39) + 1/64 : (s1'=3) & (bc1'=40) + 1/64 : (s1'=3) & (bc1'=41) + 1/64 : (s1'=3) & (bc1'=42) + 1/64 : (s1'=3) & (bc1'=43) + 1/64 : (s1'=3) & (bc1'=44) + 1/64 : (s1'=3) & (bc1'=45) + 1/64 : (s1'=3) & (bc1'=46) + 1/64 : (s1'=3) & (bc1'=47) + 1/64 : (s1'=3) & (bc1'=48) + 1/64 : (s1'=3) & (bc1'=49) + 1/64 : (s1'=3) & (bc1'=50) + 1/64 : (s1'=3) & (bc1'=51) + 1/64 : (s1'=3) & (bc1'=52) + 1/64 : (s1'=3) & (bc1'=53) + 1/64 : (s1'=3) & (bc1'=54) + 1/64 : (s1'=3) & (bc1'=55) + 1/64 : (s1'=3) & (bc1'=56) + 1/64 : (s1'=3) & (bc1'=57) + 1/64 : (s1'=3) & (bc1'=58) + 1/64 : (s1'=3) & (bc1'=59) + 1/64 : (s1'=3) & (bc1'=60) + 1/64 : (s1'=3) & (bc1'=61) + 1/64 : (s1'=3) & (bc1'=62) + 1/64 : (s1'=3) & (bc1'=63) ; - - // wait until backoff counter reaches 0 then send again - [time] (s1=3) & (x1 (x1'=x1+1); // let time pass (in slot) - [time] (s1=3) & (x1=slot) & (bc1>0) -> (x1'=1) & (bc1'=bc1-1); // let time pass (move slots) - [send1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=1) & (x1'=0); // finished backoff (bus appears free) - [busy1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // finished backoff (bus busy) - - // once finished nothing matters - [time] (s1>=4) -> (x1'=0); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module station2=station1[s1=s2,x1=x2,cd1=cd2,bc1=bc2,send1=send2,busy1=busy2,end1=end2] endmodule -module station3=station1[s1=s3,x1=x3,cd1=cd3,bc1=bc3,send1=send3,busy1=busy3,end1=end3] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward structure for expected time -rewards "time" - [time] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- - -// labels/formulae -label "all_delivered" = s1=4&s2=4&s3=4; -label "one_delivered" = s1=4|s2=4|s3=4; -label "collision_max_backoff" = (cd1=K & s1=1 & b=2)|(cd2=K & s2=1 & b=2)|(cd3=K & s3=1 & b=2); - diff --git a/examples/mdp/csma/csma4_2.nm b/examples/mdp/csma/csma4_2.nm deleted file mode 100644 index d23df94ca..000000000 --- a/examples/mdp/csma/csma4_2.nm +++ /dev/null @@ -1,135 +0,0 @@ -// CSMA/CD protocol - probabilistic version of kronos model (3 stations) -// gxn/dxp 04/12/01 - -mdp - -// note made changes since cannot have strict inequalities -// in digital clocks approach and suppose a station only sends one message - -// simplified parameters scaled -const int sigma=1; // time for messages to propagate along the bus -const int lambda=30; // time to send a message - -// actual parameters -const int N = 4; // number of processes -const int K = 2; // exponential backoff limit -const int slot = 2*sigma; // length of slot -const int M = 3; // max number of slots to wait -//const int lambda=782; -//const int sigma=26; - -//---------------------------------------------------------------------------------------------------------------------------- -// the bus -module bus - - b : [0..2]; - // b=0 - idle - // b=1 - active - // b=2 - collision - - // clocks of bus - y1 : [0..sigma+1]; // time since first send (used find time until channel sensed busy) - y2 : [0..sigma+1]; // time since second send (used to find time until collision detected) - - // a sender sends (ok - no other message being sent) - [send1] (b=0) -> (b'=1); - [send2] (b=0) -> (b'=1); - [send3] (b=0) -> (b'=1); - [send4] (b=0) -> (b'=1); - - // a sender sends (bus busy - collision) - [send1] (b=1|b=2) & (y1 (b'=2); - [send2] (b=1|b=2) & (y1 (b'=2); - [send3] (b=1|b=2) & (y1 (b'=2); - [send4] (b=1|b=2) & (y1 (b'=2); - - // finish sending - [end1] (b=1) -> (b'=0) & (y1'=0); - [end2] (b=1) -> (b'=0) & (y1'=0); - [end3] (b=1) -> (b'=0) & (y1'=0); - [end4] (b=1) -> (b'=0) & (y1'=0); - - // bus busy - [busy1] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy2] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy3] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy4] (b=1|b=2) & (y1>=sigma) -> (b'=b); - - // collision detected - [cd] (b=2) & (y2<=sigma) -> (b'=0) & (y1'=0) & (y2'=0); - - // time passage - [time] (b=0) -> (y1'=0); // value of y1/y2 does not matter in state 0 - [time] (b=1) -> (y1'=min(y1+1,sigma+1)); // no invariant in state 1 - [time] (b=2) & (y2 (y1'=min(y1+1,sigma+1)) & (y2'=min(y2+1,sigma+1)); // invariant in state 2 (time until collision detected) - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- -// model of first sender -module station1 - - // LOCAL STATE - s1 : [0..5]; - // s1=0 - initial state - // s1=1 - transmit - // s1=2 - collision (set backoff) - // s1=3 - wait (bus busy) - // s1=4 - successfully sent - - // LOCAL CLOCK - x1 : [0..max(lambda,slot)]; - - // BACKOFF COUNTER (number of slots to wait) - bc1 : [0..M]; - - // COLLISION COUNTER - cd1 : [0..K]; - - // start sending - [send1] (s1=0) -> (s1'=1) & (x1'=0); // start sending - [busy1] (s1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // detects channel is busy so go into backoff - - // transmitting - [time] (s1=1) & (x1 (x1'=min(x1+1,lambda)); // let time pass - [end1] (s1=1) & (x1=lambda) -> (s1'=4) & (x1'=0); // finished - [cd] (s1=1) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // collision detected (increment backoff counter) - [cd] !(s1=1) -> (s1'=s1); // add loop for collision detection when not important - - // set backoff (no time can pass in this state) - // probability depends on which transmission this is (cd1) - [] s1=2 & cd1=1 -> 1/2 : (s1'=3) & (bc1'=0) + 1/2 : (s1'=3) & (bc1'=1) ; - [] s1=2 & cd1=2 -> 1/4 : (s1'=3) & (bc1'=0) + 1/4 : (s1'=3) & (bc1'=1) + 1/4 : (s1'=3) & (bc1'=2) + 1/4 : (s1'=3) & (bc1'=3) ; - - // wait until backoff counter reaches 0 then send again - [time] (s1=3) & (x1 (x1'=x1+1); // let time pass (in slot) - [time] (s1=3) & (x1=slot) & (bc1>0) -> (x1'=1) & (bc1'=bc1-1); // let time pass (move slots) - [send1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=1) & (x1'=0); // finished backoff (bus appears free) - [busy1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // finished backoff (bus busy) - - // once finished nothing matters - [time] (s1>=4) -> (x1'=0); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module station2=station1[s1=s2,x1=x2,cd1=cd2,bc1=bc2,send1=send2,busy1=busy2,end1=end2] endmodule -module station3=station1[s1=s3,x1=x3,cd1=cd3,bc1=bc3,send1=send3,busy1=busy3,end1=end3] endmodule -module station4=station1[s1=s4,x1=x4,cd1=cd4,bc1=bc4,send1=send4,busy1=busy4,end1=end4] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward structure for expected time -rewards "time" - [time] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- - -// labels/formulae -label "all_delivered" = s1=4&s2=4&s3=4&s4=4; -label "one_delivered" = s1=4|s2=4|s3=4|s4=4; -label "collision_max_backoff" = (cd1=K & s1=1 & b=2)|(cd2=K & s2=1 & b=2)|(cd3=K & s3=1 & b=2)|(cd4=K & s4=1 & b=2); - diff --git a/examples/mdp/csma/csma4_4.nm b/examples/mdp/csma/csma4_4.nm deleted file mode 100644 index e1ba511f4..000000000 --- a/examples/mdp/csma/csma4_4.nm +++ /dev/null @@ -1,139 +0,0 @@ -// CSMA/CD protocol - probabilistic version of kronos model (3 stations) -// gxn/dxp 04/12/01 - -mdp - -// note made changes since cannot have strict inequalities -// in digital clocks approach and suppose a station only sends one message - -// simplified parameters scaled -const int sigma=1; // time for messages to propagate along the bus -const int lambda=30; // time to send a message - -// actual parameters -const int N = 4; // number of processes -const int K = 4; // exponential backoff limit -const int slot = 2*sigma; // length of slot -const int M = 15; // max number of slots to wait -//const int lambda=782; -//const int sigma=26; - -//---------------------------------------------------------------------------------------------------------------------------- -// the bus -module bus - - b : [0..2]; - // b=0 - idle - // b=1 - active - // b=2 - collision - - // clocks of bus - y1 : [0..sigma+1]; // time since first send (used find time until channel sensed busy) - y2 : [0..sigma+1]; // time since second send (used to find time until collision detected) - - // a sender sends (ok - no other message being sent) - [send1] (b=0) -> (b'=1); - [send2] (b=0) -> (b'=1); - [send3] (b=0) -> (b'=1); - [send4] (b=0) -> (b'=1); - - // a sender sends (bus busy - collision) - [send1] (b=1|b=2) & (y1 (b'=2); - [send2] (b=1|b=2) & (y1 (b'=2); - [send3] (b=1|b=2) & (y1 (b'=2); - [send4] (b=1|b=2) & (y1 (b'=2); - - // finish sending - [end1] (b=1) -> (b'=0) & (y1'=0); - [end2] (b=1) -> (b'=0) & (y1'=0); - [end3] (b=1) -> (b'=0) & (y1'=0); - [end4] (b=1) -> (b'=0) & (y1'=0); - - // bus busy - [busy1] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy2] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy3] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy4] (b=1|b=2) & (y1>=sigma) -> (b'=b); - - // collision detected - [cd] (b=2) & (y2<=sigma) -> (b'=0) & (y1'=0) & (y2'=0); - - // time passage - [time] (b=0) -> (y1'=0); // value of y1/y2 does not matter in state 0 - [time] (b=1) -> (y1'=min(y1+1,sigma+1)); // no invariant in state 1 - [time] (b=2) & (y2 (y1'=min(y1+1,sigma+1)) & (y2'=min(y2+1,sigma+1)); // invariant in state 2 (time until collision detected) - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- -// model of first sender -module station1 - - // LOCAL STATE - s1 : [0..5]; - // s1=0 - initial state - // s1=1 - transmit - // s1=2 - collision (set backoff) - // s1=3 - wait (bus busy) - // s1=4 - successfully sent - - // LOCAL CLOCK - x1 : [0..max(lambda,slot)]; - - // BACKOFF COUNTER (number of slots to wait) - bc1 : [0..M]; - - // COLLISION COUNTER - cd1 : [0..K]; - - // start sending - [send1] (s1=0) -> (s1'=1) & (x1'=0); // start sending - [busy1] (s1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // detects channel is busy so go into backoff - - // transmitting - [time] (s1=1) & (x1 (x1'=min(x1+1,lambda)); // let time pass - [end1] (s1=1) & (x1=lambda) -> (s1'=4) & (x1'=0); // finished - [cd] (s1=1) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // collision detected (increment backoff counter) - [cd] !(s1=1) -> (s1'=s1); // add loop for collision detection when not important - - // set backoff (no time can pass in this state) - // probability depends on which transmission this is (cd1) - [] s1=2 & cd1=1 -> 1/2 : (s1'=3) & (bc1'=0) + 1/2 : (s1'=3) & (bc1'=1) ; - [] s1=2 & cd1=2 -> 1/4 : (s1'=3) & (bc1'=0) + 1/4 : (s1'=3) & (bc1'=1) + 1/4 : (s1'=3) & (bc1'=2) + 1/4 : (s1'=3) & (bc1'=3) ; - [] s1=2 & cd1=3 -> 1/8 : (s1'=3) & (bc1'=0) + 1/8 : (s1'=3) & (bc1'=1) + 1/8 : (s1'=3) & (bc1'=2) + 1/8 : (s1'=3) & (bc1'=3) + 1/8 : (s1'=3) & (bc1'=4) + 1/8 : (s1'=3) & (bc1'=5) + 1/8 : (s1'=3) & (bc1'=6) + 1/8 : (s1'=3) & (bc1'=7) ; - [] s1=2 & cd1=4 -> 1/16 : (s1'=3) & (bc1'=0) + 1/16 : (s1'=3) & (bc1'=1) + 1/16 : (s1'=3) & (bc1'=2) + 1/16 : (s1'=3) & (bc1'=3) + 1/16 : (s1'=3) & (bc1'=4) + 1/16 : (s1'=3) & (bc1'=5) + 1/16 : (s1'=3) & (bc1'=6) + 1/16 : (s1'=3) & (bc1'=7) + 1/16 : (s1'=3) & (bc1'=8) + 1/16 : (s1'=3) & (bc1'=9) + 1/16 : (s1'=3) & (bc1'=10) + 1/16 : (s1'=3) & (bc1'=11) + 1/16 : (s1'=3) & (bc1'=12) + 1/16 : (s1'=3) & (bc1'=13) + 1/16 : (s1'=3) & (bc1'=14) + 1/16 : (s1'=3) & (bc1'=15) ; - - // wait until backoff counter reaches 0 then send again - [time] (s1=3) & (x1 (x1'=x1+1); // let time pass (in slot) - [time] (s1=3) & (x1=slot) & (bc1>0) -> (x1'=1) & (bc1'=bc1-1); // let time pass (move slots) - [send1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=1) & (x1'=0); // finished backoff (bus appears free) - [busy1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // finished backoff (bus busy) - - // once finished nothing matters - [time] (s1>=4) -> (x1'=0); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module station2=station1[s1=s2,x1=x2,cd1=cd2,bc1=bc2,send1=send2,busy1=busy2,end1=end2] endmodule -module station3=station1[s1=s3,x1=x3,cd1=cd3,bc1=bc3,send1=send3,busy1=busy3,end1=end3] endmodule -module station4=station1[s1=s4,x1=x4,cd1=cd4,bc1=bc4,send1=send4,busy1=busy4,end1=end4] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward structure for expected time -rewards "time" - [time] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- - -// labels/formulae -label "all_delivered" = s1=4&s2=4&s3=4&s4=4; -label "one_delivered" = s1=4|s2=4|s3=4|s4=4; -label "collision_max_backoff" = (cd1=K & s1=1 & b=2)|(cd2=K & s2=1 & b=2)|(cd3=K & s3=1 & b=2)|(cd4=K & s4=1 & b=2); -formula min_backoff_after_success = min(s1=4?cd1:K+1,s2=4?cd2:K+1,s3=4?cd3:K+1,s4=4?cd4:K+1); -formula min_collisions = min(cd1,cd2,cd3,cd4); -formula max_collisions = max(cd1,cd2,cd3,cd4); diff --git a/examples/mdp/csma/csma4_6.nm b/examples/mdp/csma/csma4_6.nm deleted file mode 100644 index 12e5f0152..000000000 --- a/examples/mdp/csma/csma4_6.nm +++ /dev/null @@ -1,141 +0,0 @@ -// CSMA/CD protocol - probabilistic version of kronos model (3 stations) -// gxn/dxp 04/12/01 - -mdp - -// note made changes since cannot have strict inequalities -// in digital clocks approach and suppose a station only sends one message - -// simplified parameters scaled -const int sigma=1; // time for messages to propagate along the bus -const int lambda=30; // time to send a message - -// actual parameters -const int N = 4; // number of processes -const int K = 6; // exponential backoff limit -const int slot = 2*sigma; // length of slot -const int M = 63; // max number of slots to wait -//const int lambda=782; -//const int sigma=26; - -//---------------------------------------------------------------------------------------------------------------------------- -// the bus -module bus - - b : [0..2]; - // b=0 - idle - // b=1 - active - // b=2 - collision - - // clocks of bus - y1 : [0..sigma+1]; // time since first send (used find time until channel sensed busy) - y2 : [0..sigma+1]; // time since second send (used to find time until collision detected) - - // a sender sends (ok - no other message being sent) - [send1] (b=0) -> (b'=1); - [send2] (b=0) -> (b'=1); - [send3] (b=0) -> (b'=1); - [send4] (b=0) -> (b'=1); - - // a sender sends (bus busy - collision) - [send1] (b=1|b=2) & (y1 (b'=2); - [send2] (b=1|b=2) & (y1 (b'=2); - [send3] (b=1|b=2) & (y1 (b'=2); - [send4] (b=1|b=2) & (y1 (b'=2); - - // finish sending - [end1] (b=1) -> (b'=0) & (y1'=0); - [end2] (b=1) -> (b'=0) & (y1'=0); - [end3] (b=1) -> (b'=0) & (y1'=0); - [end4] (b=1) -> (b'=0) & (y1'=0); - - // bus busy - [busy1] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy2] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy3] (b=1|b=2) & (y1>=sigma) -> (b'=b); - [busy4] (b=1|b=2) & (y1>=sigma) -> (b'=b); - - // collision detected - [cd] (b=2) & (y2<=sigma) -> (b'=0) & (y1'=0) & (y2'=0); - - // time passage - [time] (b=0) -> (y1'=0); // value of y1/y2 does not matter in state 0 - [time] (b=1) -> (y1'=min(y1+1,sigma+1)); // no invariant in state 1 - [time] (b=2) & (y2 (y1'=min(y1+1,sigma+1)) & (y2'=min(y2+1,sigma+1)); // invariant in state 2 (time until collision detected) - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- -// model of first sender -module station1 - - // LOCAL STATE - s1 : [0..5]; - // s1=0 - initial state - // s1=1 - transmit - // s1=2 - collision (set backoff) - // s1=3 - wait (bus busy) - // s1=4 - successfully sent - - // LOCAL CLOCK - x1 : [0..max(lambda,slot)]; - - // BACKOFF COUNTER (number of slots to wait) - bc1 : [0..M]; - - // COLLISION COUNTER - cd1 : [0..K]; - - // start sending - [send1] (s1=0) -> (s1'=1) & (x1'=0); // start sending - [busy1] (s1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // detects channel is busy so go into backoff - - // transmitting - [time] (s1=1) & (x1 (x1'=min(x1+1,lambda)); // let time pass - [end1] (s1=1) & (x1=lambda) -> (s1'=4) & (x1'=0); // finished - [cd] (s1=1) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // collision detected (increment backoff counter) - [cd] !(s1=1) -> (s1'=s1); // add loop for collision detection when not important - - // set backoff (no time can pass in this state) - // probability depends on which transmission this is (cd1) - [] s1=2 & cd1=1 -> 1/2 : (s1'=3) & (bc1'=0) + 1/2 : (s1'=3) & (bc1'=1) ; - [] s1=2 & cd1=2 -> 1/4 : (s1'=3) & (bc1'=0) + 1/4 : (s1'=3) & (bc1'=1) + 1/4 : (s1'=3) & (bc1'=2) + 1/4 : (s1'=3) & (bc1'=3) ; - [] s1=2 & cd1=3 -> 1/8 : (s1'=3) & (bc1'=0) + 1/8 : (s1'=3) & (bc1'=1) + 1/8 : (s1'=3) & (bc1'=2) + 1/8 : (s1'=3) & (bc1'=3) + 1/8 : (s1'=3) & (bc1'=4) + 1/8 : (s1'=3) & (bc1'=5) + 1/8 : (s1'=3) & (bc1'=6) + 1/8 : (s1'=3) & (bc1'=7) ; - [] s1=2 & cd1=4 -> 1/16 : (s1'=3) & (bc1'=0) + 1/16 : (s1'=3) & (bc1'=1) + 1/16 : (s1'=3) & (bc1'=2) + 1/16 : (s1'=3) & (bc1'=3) + 1/16 : (s1'=3) & (bc1'=4) + 1/16 : (s1'=3) & (bc1'=5) + 1/16 : (s1'=3) & (bc1'=6) + 1/16 : (s1'=3) & (bc1'=7) + 1/16 : (s1'=3) & (bc1'=8) + 1/16 : (s1'=3) & (bc1'=9) + 1/16 : (s1'=3) & (bc1'=10) + 1/16 : (s1'=3) & (bc1'=11) + 1/16 : (s1'=3) & (bc1'=12) + 1/16 : (s1'=3) & (bc1'=13) + 1/16 : (s1'=3) & (bc1'=14) + 1/16 : (s1'=3) & (bc1'=15) ; - [] s1=2 & cd1=5 -> 1/32 : (s1'=3) & (bc1'=0) + 1/32 : (s1'=3) & (bc1'=1) + 1/32 : (s1'=3) & (bc1'=2) + 1/32 : (s1'=3) & (bc1'=3) + 1/32 : (s1'=3) & (bc1'=4) + 1/32 : (s1'=3) & (bc1'=5) + 1/32 : (s1'=3) & (bc1'=6) + 1/32 : (s1'=3) & (bc1'=7) + 1/32 : (s1'=3) & (bc1'=8) + 1/32 : (s1'=3) & (bc1'=9) + 1/32 : (s1'=3) & (bc1'=10) + 1/32 : (s1'=3) & (bc1'=11) + 1/32 : (s1'=3) & (bc1'=12) + 1/32 : (s1'=3) & (bc1'=13) + 1/32 : (s1'=3) & (bc1'=14) + 1/32 : (s1'=3) & (bc1'=15) + 1/32 : (s1'=3) & (bc1'=16) + 1/32 : (s1'=3) & (bc1'=17) + 1/32 : (s1'=3) & (bc1'=18) + 1/32 : (s1'=3) & (bc1'=19) + 1/32 : (s1'=3) & (bc1'=20) + 1/32 : (s1'=3) & (bc1'=21) + 1/32 : (s1'=3) & (bc1'=22) + 1/32 : (s1'=3) & (bc1'=23) + 1/32 : (s1'=3) & (bc1'=24) + 1/32 : (s1'=3) & (bc1'=25) + 1/32 : (s1'=3) & (bc1'=26) + 1/32 : (s1'=3) & (bc1'=27) + 1/32 : (s1'=3) & (bc1'=28) + 1/32 : (s1'=3) & (bc1'=29) + 1/32 : (s1'=3) & (bc1'=30) + 1/32 : (s1'=3) & (bc1'=31) ; - [] s1=2 & cd1=6 -> 1/64 : (s1'=3) & (bc1'=0) + 1/64 : (s1'=3) & (bc1'=1) + 1/64 : (s1'=3) & (bc1'=2) + 1/64 : (s1'=3) & (bc1'=3) + 1/64 : (s1'=3) & (bc1'=4) + 1/64 : (s1'=3) & (bc1'=5) + 1/64 : (s1'=3) & (bc1'=6) + 1/64 : (s1'=3) & (bc1'=7) + 1/64 : (s1'=3) & (bc1'=8) + 1/64 : (s1'=3) & (bc1'=9) + 1/64 : (s1'=3) & (bc1'=10) + 1/64 : (s1'=3) & (bc1'=11) + 1/64 : (s1'=3) & (bc1'=12) + 1/64 : (s1'=3) & (bc1'=13) + 1/64 : (s1'=3) & (bc1'=14) + 1/64 : (s1'=3) & (bc1'=15) + 1/64 : (s1'=3) & (bc1'=16) + 1/64 : (s1'=3) & (bc1'=17) + 1/64 : (s1'=3) & (bc1'=18) + 1/64 : (s1'=3) & (bc1'=19) + 1/64 : (s1'=3) & (bc1'=20) + 1/64 : (s1'=3) & (bc1'=21) + 1/64 : (s1'=3) & (bc1'=22) + 1/64 : (s1'=3) & (bc1'=23) + 1/64 : (s1'=3) & (bc1'=24) + 1/64 : (s1'=3) & (bc1'=25) + 1/64 : (s1'=3) & (bc1'=26) + 1/64 : (s1'=3) & (bc1'=27) + 1/64 : (s1'=3) & (bc1'=28) + 1/64 : (s1'=3) & (bc1'=29) + 1/64 : (s1'=3) & (bc1'=30) + 1/64 : (s1'=3) & (bc1'=31) + 1/64 : (s1'=3) & (bc1'=32) + 1/64 : (s1'=3) & (bc1'=33) + 1/64 : (s1'=3) & (bc1'=34) + 1/64 : (s1'=3) & (bc1'=35) + 1/64 : (s1'=3) & (bc1'=36) + 1/64 : (s1'=3) & (bc1'=37) + 1/64 : (s1'=3) & (bc1'=38) + 1/64 : (s1'=3) & (bc1'=39) + 1/64 : (s1'=3) & (bc1'=40) + 1/64 : (s1'=3) & (bc1'=41) + 1/64 : (s1'=3) & (bc1'=42) + 1/64 : (s1'=3) & (bc1'=43) + 1/64 : (s1'=3) & (bc1'=44) + 1/64 : (s1'=3) & (bc1'=45) + 1/64 : (s1'=3) & (bc1'=46) + 1/64 : (s1'=3) & (bc1'=47) + 1/64 : (s1'=3) & (bc1'=48) + 1/64 : (s1'=3) & (bc1'=49) + 1/64 : (s1'=3) & (bc1'=50) + 1/64 : (s1'=3) & (bc1'=51) + 1/64 : (s1'=3) & (bc1'=52) + 1/64 : (s1'=3) & (bc1'=53) + 1/64 : (s1'=3) & (bc1'=54) + 1/64 : (s1'=3) & (bc1'=55) + 1/64 : (s1'=3) & (bc1'=56) + 1/64 : (s1'=3) & (bc1'=57) + 1/64 : (s1'=3) & (bc1'=58) + 1/64 : (s1'=3) & (bc1'=59) + 1/64 : (s1'=3) & (bc1'=60) + 1/64 : (s1'=3) & (bc1'=61) + 1/64 : (s1'=3) & (bc1'=62) + 1/64 : (s1'=3) & (bc1'=63) ; - - // wait until backoff counter reaches 0 then send again - [time] (s1=3) & (x1 (x1'=x1+1); // let time pass (in slot) - [time] (s1=3) & (x1=slot) & (bc1>0) -> (x1'=1) & (bc1'=bc1-1); // let time pass (move slots) - [send1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=1) & (x1'=0); // finished backoff (bus appears free) - [busy1] (s1=3) & (x1=slot) & (bc1=0) -> (s1'=2) & (x1'=0) & (cd1'=min(K,cd1+1)); // finished backoff (bus busy) - - // once finished nothing matters - [time] (s1>=4) -> (x1'=0); - -endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// construct further stations through renaming -module station2=station1[s1=s2,x1=x2,cd1=cd2,bc1=bc2,send1=send2,busy1=busy2,end1=end2] endmodule -module station3=station1[s1=s3,x1=x3,cd1=cd3,bc1=bc3,send1=send3,busy1=busy3,end1=end3] endmodule -module station4=station1[s1=s4,x1=x4,cd1=cd4,bc1=bc4,send1=send4,busy1=busy4,end1=end4] endmodule - -//---------------------------------------------------------------------------------------------------------------------------- - -// reward structure for expected time -rewards "time" - [time] true : 1; -endrewards - -//---------------------------------------------------------------------------------------------------------------------------- - -// labels/formulae -label "all_delivered" = s1=4&s2=4&s3=4&s4=4; -label "one_delivered" = s1=4|s2=4|s3=4|s4=4; -label "collision_max_backoff" = (cd1=K & s1=1 & b=2)|(cd2=K & s2=1 & b=2)|(cd3=K & s3=1 & b=2)|(cd4=K & s4=1 & b=2); -formula min_backoff_after_success = min(s1=4?cd1:K+1,s2=4?cd2:K+1,s3=4?cd3:K+1,s4=4?cd4:K+1); -formula min_collisions = min(cd1,cd2,cd3,cd4); -formula max_collisions = max(cd1,cd2,cd3,cd4); diff --git a/examples/mdp/firewire/impl/firewire.cexprop b/examples/mdp/firewire/impl/firewire.cexprop deleted file mode 100644 index 02d43560f..000000000 --- a/examples/mdp/firewire/impl/firewire.cexprop +++ /dev/null @@ -1 +0,0 @@ -P<0.5 [F elected] diff --git a/examples/mdp/scc/scc.pctl b/examples/mdp/scc/scc.pctl deleted file mode 100644 index 501655389..000000000 --- a/examples/mdp/scc/scc.pctl +++ /dev/null @@ -1,2 +0,0 @@ -Pmin=? [ (!statetwo) U end ] -Pmax=? [ (!statetwo) U end ] \ No newline at end of file diff --git a/examples/mdp/tiny/tiny.clab b/examples/mdp/tiny/tiny.clab deleted file mode 100644 index c23988f1a..000000000 --- a/examples/mdp/tiny/tiny.clab +++ /dev/null @@ -1,4 +0,0 @@ -0 0 3 -0 1 1 -1 0 2 -2 0 0 diff --git a/examples/mdp/tiny/tiny.pctl b/examples/mdp/tiny/tiny.pctl deleted file mode 100644 index 393670a26..000000000 --- a/examples/mdp/tiny/tiny.pctl +++ /dev/null @@ -1,2 +0,0 @@ -Pmin=? [ F a ] -Pmax=? [ F a ] \ No newline at end of file diff --git a/examples/mdp/two_dice/two_dice.pctl b/examples/mdp/two_dice/two_dice.pctl deleted file mode 100644 index 4ad376feb..000000000 --- a/examples/mdp/two_dice/two_dice.pctl +++ /dev/null @@ -1,13 +0,0 @@ -Pmin=? [ F two ] -Pmax=? [ F two ] -Pmin=? [ F three ] -Pmax=? [ F three ] -Pmin=? [ F four ] -Pmax=? [ F four ] -Pmin=? [ F five ] -Pmax=? [ F five ] -Pmin=? [ F six ] -Pmax=? [ F six ] - -Rmin=? [ F done ] -Rmax=? [ F done ] diff --git a/examples/mdp/two_dice/two_dice.res b/examples/mdp/two_dice/two_dice.res deleted file mode 100644 index 9f38b8153..000000000 --- a/examples/mdp/two_dice/two_dice.res +++ /dev/null @@ -1,13 +0,0 @@ -Pmin=? [ F "two" ] // 0.027777761220932007 -Pmax=? [ F "two" ] // 0.027777761220932007 -Pmin=? [ F "three" ] // 0.055555522441864014 -Pmax=? [ F "three" ] // 0.055555522441864014 -Pmin=? [ F "four" ] // 0.08333328366279602 -Pmax=? [ F "four" ] // 0.08333328366279602 -Pmin=? [ F "five" ] // 0.11111104488372803 -Pmax=? [ F "five" ] // 0.11111104488372803 -Pmin=? [ F "six" ] // 0.13888880610466003 -Pmax=? [ F "six" ] // 0.13888880610466003 - -Rmin=? [ F "done" ] // 7.333329498767853 -Rmax=? [ F "done" ] // 7.333329498767853 diff --git a/examples/mdp/wlan/wlan0_4.cexprop b/examples/mdp/wlan/wlan0_4.cexprop deleted file mode 100644 index 8af300d54..000000000 --- a/examples/mdp/wlan/wlan0_4.cexprop +++ /dev/null @@ -1 +0,0 @@ -P<0.003 [ F fourCollisions ] diff --git a/examples/mdp/wlan/wlan0_6.cexprop b/examples/mdp/wlan/wlan0_6.cexprop deleted file mode 100644 index d7bf09293..000000000 --- a/examples/mdp/wlan/wlan0_6.cexprop +++ /dev/null @@ -1 +0,0 @@ -P<0.0001 [ F sixCollisions ] diff --git a/examples/mdp/wlan/wlan1_collide.nm b/examples/mdp/wlan/wlan1_collide.nm deleted file mode 100644 index 7c4904cd9..000000000 --- a/examples/mdp/wlan/wlan1_collide.nm +++ /dev/null @@ -1,221 +0,0 @@ -// WLAN PROTOCOL (two stations) -// discrete time model -// gxn/jzs 20/02/02 - -mdp - -// COLLISIONS -const int COL; // maximum number of collisions - -// TIMING CONSTRAINTS -// we have used the FHSS parameters -// then scaled by the value of ASLOTTIME -const int ASLOTTIME = 1; -const int DIFS = 3; // due to scaling can be either 2 or 3 which is modelled by a non-deterministic choice -const int VULN = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -const int TRANS_TIME_MAX; // scaling up -const int TRANS_TIME_MIN = 4; // scaling down -const int ACK_TO = 6; -const int ACK = 4; // due to scaling can be either 3 or 4 which is modelled by a non-deterministic choice -const int SIFS = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -// maximum constant used in timing constraints + 1 -const int TIME_MAX = max(ACK_TO,TRANS_TIME_MAX)+1; - -// CONTENTION WINDOW -// CWMIN =15 & CWMAX =31 -// this means that MAX_BACKOFF IS 2 -const int MAX_BACKOFF = 1; - -//-----------------------------------------------------------------// -// THE MEDIUM/CHANNEL - -// FORMULAE FOR THE CHANNEL -// channel is busy -formula busy = c1>0 | c2>0; -// channel is free -formula free = c1=0 & c2=0; - -module medium - - // number of collisions - col : [0..COL]; - - // medium status - c1 : [0..2]; - c2 : [0..2]; - // ci corresponds to messages associated with station i - // 0 nothing being sent - // 1 being sent correctly - // 2 being sent garbled - - // begin sending message and nothing else currently being sent - [send1] c1=0 & c2=0 -> (c1'=1); - [send2] c2=0 & c1=0 -> (c2'=1); - - // begin sending message and something is already being sent - // in this case both messages become garbled - [send1] c1=0 & c2>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - [send2] c2=0 & c1>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - - // finish sending message - [finish1] c1>0 -> (c1'=0); - [finish2] c2>0 -> (c2'=0); - -endmodule - -//-----------------------------------------------------------------// -// STATION 1 -module station1 - // clock for station 1 - x1 : [0..TIME_MAX]; - - // local state - s1 : [1..12]; - // 1 sense - // 2 wait until free before setting backoff - // 3 wait for DIFS then set slot - // 4 set backoff - // 5 backoff - // 6 wait until free in backoff - // 7 wait for DIFS then resume backoff - // 8 vulnerable - // 9 transmit - // 11 wait for SIFS and then ACK - // 10 wait for ACT_TO - // 12 done - // BACKOFF - // separate into slots - slot1 : [0..1]; - backoff1 : [0..15]; - - // BACKOFF COUNTER - bc1 : [0..MAX_BACKOFF]; - // SENSE - // let time pass - [time] s1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // ready to transmit - [] s1=1 & (x1=DIFS | x1=DIFS-1) -> (s1'=8) & (x1'=0); - // found channel busy so wait until free - [] s1=1 & busy -> (s1'=2) & (x1'=0); - // WAIT UNTIL FREE BEFORE SETTING BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=2 & busy -> (s1'=2); - // find that channel is free so check its free for DIFS before setting backoff - [] s1=2 & free -> (s1'=3); - // WAIT FOR DIFS THEN SET BACKOFF - // let time pass - [time] s1=3 & x1 (x1'=min(x1+1,TIME_MAX)); - // found channel busy so wait until free - [] s1=3 & busy -> (s1'=2) & (x1'=0); - // start backoff first uniformly choose slot - // backoff counter 0 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=0 -> (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 1 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=1 -> 1/2 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/2 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // SET BACKOFF (no time can pass) - // chosen slot now set backoff - [] s1=4 -> 1/16 : (s1'=5) & (backoff1'=0 ) - + 1/16 : (s1'=5) & (backoff1'=1 ) - + 1/16 : (s1'=5) & (backoff1'=2 ) - + 1/16 : (s1'=5) & (backoff1'=3 ) - + 1/16 : (s1'=5) & (backoff1'=4 ) - + 1/16 : (s1'=5) & (backoff1'=5 ) - + 1/16 : (s1'=5) & (backoff1'=6 ) - + 1/16 : (s1'=5) & (backoff1'=7 ) - + 1/16 : (s1'=5) & (backoff1'=8 ) - + 1/16 : (s1'=5) & (backoff1'=9 ) - + 1/16 : (s1'=5) & (backoff1'=10) - + 1/16 : (s1'=5) & (backoff1'=11) - + 1/16 : (s1'=5) & (backoff1'=12) - + 1/16 : (s1'=5) & (backoff1'=13) - + 1/16 : (s1'=5) & (backoff1'=14) - + 1/16 : (s1'=5) & (backoff1'=15); - // BACKOFF - // let time pass - [time] s1=5 & x1 (x1'=min(x1+1,TIME_MAX)); - // decrement backoff - [] s1=5 & x1=ASLOTTIME & backoff1>0 -> (s1'=5) & (x1'=0) & (backoff1'=backoff1-1); - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1>0 -> (s1'=5) & (x1'=0) & (backoff1'=15) & (slot1'=slot1-1); - // finish backoff - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1=0 -> (s1'=8) & (x1'=0); - // found channel busy - [] s1=5 & busy -> (s1'=6) & (x1'=0); - // WAIT UNTIL FREE IN BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=6 & busy -> (s1'=6); - // find that channel is free - [] s1=6 & free -> (s1'=7); - - // WAIT FOR DIFS THEN RESUME BACKOFF - // let time pass - [time] s1=7 & x1 (x1'=min(x1+1,TIME_MAX)); - // resume backoff (start again from previous backoff) - [] s1=7 & (x1=DIFS | x1=DIFS-1) -> (s1'=5) & (x1'=0); - // found channel busy - [] s1=7 & busy -> (s1'=6) & (x1'=0); - - // VULNERABLE - // let time pass - [time] s1=8 & x1 (x1'=min(x1+1,TIME_MAX)); - // move to transmit - [send1] s1=8 & (x1=VULN | x1=VULN-1) -> (s1'=9) & (x1'=0); - // TRANSMIT - // let time pass - [time] s1=9 & x1 (x1'=min(x1+1,TIME_MAX)); - // finish transmission successful - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=1 -> (s1'=10) & (x1'=0); - // finish transmission garbled - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=2 -> (s1'=11) & (x1'=0); - // WAIT FOR SIFS THEN WAIT FOR ACK - - // WAIT FOR SIFS i.e. c1=0 - // check channel and busy: go into backoff - [] s1=10 & c1=0 & x1=0 & busy -> (s1'=2); - // chEck channel and free: let time pass - [time] s1=10 & c1=0 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - // following guard is always false as SIFS=1 - // [time] s1=10 & c1=0 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // ack is sent after SIFS (since SIFS-1=0 add condition that channel is free) - [send1] s1=10 & c1=0 & (x1=SIFS | (x1=SIFS-1 & free)) -> (s1'=10) & (x1'=0); - - // WAIT FOR ACK i.e. c1=1 - // let time pass - [time] s1=10 & c1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // get acknowledgement so packet sent correctly and move to done - [finish1] s1=10 & c1=1 & (x1=ACK | x1=ACK-1) -> (s1'=12) & (x1'=0) & (bc1'=0); - - // WAIT FOR ACK_TO - // check channel and busy: go into backoff - [] s1=11 & x1=0 & busy -> (s1'=2); - // check channel and free: let time pass - [time] s1=11 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - [time] s1=11 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // no acknowledgement (go to backoff waiting DIFS first) - [] s1=11 & x1=ACK_TO -> (s1'=3) & (x1'=0); - - // DONE - [time] s1=12 -> (s1'=12); -endmodule - -// ---------------------------------------------------------------------------- // -// STATION 2 (rename STATION 1) -module -station2=station1[x1=x2, - s1=s2, - s2=s1, - c1=c2, - c2=c1, - slot1=slot2, - backoff1=backoff2, - bc1=bc2, - send1=send2, - finish1=finish2] -endmodule -// ---------------------------------------------------------------------------- // - -label "twoCollisions" = col=2; -label "fourCollisions" = col=4; -label "sixCollisions" = col=6; \ No newline at end of file diff --git a/examples/mdp/wlan/wlan2_4.cexprop b/examples/mdp/wlan/wlan2_4.cexprop deleted file mode 100644 index aee1d6de8..000000000 --- a/examples/mdp/wlan/wlan2_4.cexprop +++ /dev/null @@ -1 +0,0 @@ -P<0.0004 [ F fourCollisions ] diff --git a/examples/mdp/wlan/wlan2_6.cexprop b/examples/mdp/wlan/wlan2_6.cexprop deleted file mode 100644 index d45360df7..000000000 --- a/examples/mdp/wlan/wlan2_6.cexprop +++ /dev/null @@ -1 +0,0 @@ -P<0.000001 [ F sixCollisions ] diff --git a/examples/mdp/wlan/wlan2_collide.nm b/examples/mdp/wlan/wlan2_collide.nm deleted file mode 100644 index a3fcccafa..000000000 --- a/examples/mdp/wlan/wlan2_collide.nm +++ /dev/null @@ -1,226 +0,0 @@ -// WLAN PROTOCOL (two stations) -// discrete time model -// gxn/jzs 20/02/02 - -mdp - -// COLLISIONS -const int COL; // maximum number of collisions - -// TIMING CONSTRAINTS -// we have used the FHSS parameters -// then scaled by the value of ASLOTTIME -const int ASLOTTIME = 1; -const int DIFS = 3; // due to scaling can be either 2 or 3 which is modelled by a non-deterministic choice -const int VULN = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -const int TRANS_TIME_MAX; // scaling up -const int TRANS_TIME_MIN = 4; // scaling down -const int ACK_TO = 6; -const int ACK = 4; // due to scaling can be either 3 or 4 which is modelled by a non-deterministic choice -const int SIFS = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -// maximum constant used in timing constraints + 1 -const int TIME_MAX = max(ACK_TO,TRANS_TIME_MAX)+1; - -// CONTENTION WINDOW -// CWMIN =15 & CWMAX =63 -// this means that MAX_BACKOFF IS 2 -const int MAX_BACKOFF = 2; - -//-----------------------------------------------------------------// -// THE MEDIUM/CHANNEL - -// FORMULAE FOR THE CHANNEL -// channel is busy -formula busy = c1>0 | c2>0; -// channel is free -formula free = c1=0 & c2=0; - -module medium - - // number of collisions - col : [0..COL]; - - // medium status - c1 : [0..2]; - c2 : [0..2]; - // ci corresponds to messages associated with station i - // 0 nothing being sent - // 1 being sent correctly - // 2 being sent garbled - - // begin sending message and nothing else currently being sent - [send1] c1=0 & c2=0 -> (c1'=1); - [send2] c2=0 & c1=0 -> (c2'=1); - - // begin sending message and something is already being sent - // in this case both messages become garbled - [send1] c1=0 & c2>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - [send2] c2=0 & c1>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - - // finish sending message - [finish1] c1>0 -> (c1'=0); - [finish2] c2>0 -> (c2'=0); - -endmodule - -//-----------------------------------------------------------------// -// STATION 1 -module station1 - // clock for station 1 - x1 : [0..TIME_MAX]; - - // local state - s1 : [1..12]; - // 1 sense - // 2 wait until free before setting backoff - // 3 wait for DIFS then set slot - // 4 set backoff - // 5 backoff - // 6 wait until free in backoff - // 7 wait for DIFS then resume backoff - // 8 vulnerable - // 9 transmit - // 11 wait for SIFS and then ACK - // 10 wait for ACT_TO - // 12 done - // BACKOFF - // separate into slots - slot1 : [0..3]; - backoff1 : [0..15]; - - // BACKOFF COUNTER - bc1 : [0..MAX_BACKOFF]; - // SENSE - // let time pass - [time] s1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // ready to transmit - [] s1=1 & (x1=DIFS | x1=DIFS-1) -> (s1'=8) & (x1'=0); - // found channel busy so wait until free - [] s1=1 & busy -> (s1'=2) & (x1'=0); - // WAIT UNTIL FREE BEFORE SETTING BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=2 & busy -> (s1'=2); - // find that channel is free so check its free for DIFS before setting backoff - [] s1=2 & free -> (s1'=3); - // WAIT FOR DIFS THEN SET BACKOFF - // let time pass - [time] s1=3 & x1 (x1'=min(x1+1,TIME_MAX)); - // found channel busy so wait until free - [] s1=3 & busy -> (s1'=2) & (x1'=0); - // start backoff first uniformly choose slot - // backoff counter 0 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=0 -> (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 1 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=1 -> 1/2 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/2 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 2 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=2 -> 1/4 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=2) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=3) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // SET BACKOFF (no time can pass) - // chosen slot now set backoff - [] s1=4 -> 1/16 : (s1'=5) & (backoff1'=0 ) - + 1/16 : (s1'=5) & (backoff1'=1 ) - + 1/16 : (s1'=5) & (backoff1'=2 ) - + 1/16 : (s1'=5) & (backoff1'=3 ) - + 1/16 : (s1'=5) & (backoff1'=4 ) - + 1/16 : (s1'=5) & (backoff1'=5 ) - + 1/16 : (s1'=5) & (backoff1'=6 ) - + 1/16 : (s1'=5) & (backoff1'=7 ) - + 1/16 : (s1'=5) & (backoff1'=8 ) - + 1/16 : (s1'=5) & (backoff1'=9 ) - + 1/16 : (s1'=5) & (backoff1'=10) - + 1/16 : (s1'=5) & (backoff1'=11) - + 1/16 : (s1'=5) & (backoff1'=12) - + 1/16 : (s1'=5) & (backoff1'=13) - + 1/16 : (s1'=5) & (backoff1'=14) - + 1/16 : (s1'=5) & (backoff1'=15); - // BACKOFF - // let time pass - [time] s1=5 & x1 (x1'=min(x1+1,TIME_MAX)); - // decrement backoff - [] s1=5 & x1=ASLOTTIME & backoff1>0 -> (s1'=5) & (x1'=0) & (backoff1'=backoff1-1); - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1>0 -> (s1'=5) & (x1'=0) & (backoff1'=15) & (slot1'=slot1-1); - // finish backoff - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1=0 -> (s1'=8) & (x1'=0); - // found channel busy - [] s1=5 & busy -> (s1'=6) & (x1'=0); - // WAIT UNTIL FREE IN BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=6 & busy -> (s1'=6); - // find that channel is free - [] s1=6 & free -> (s1'=7); - - // WAIT FOR DIFS THEN RESUME BACKOFF - // let time pass - [time] s1=7 & x1 (x1'=min(x1+1,TIME_MAX)); - // resume backoff (start again from previous backoff) - [] s1=7 & (x1=DIFS | x1=DIFS-1) -> (s1'=5) & (x1'=0); - // found channel busy - [] s1=7 & busy -> (s1'=6) & (x1'=0); - - // VULNERABLE - // let time pass - [time] s1=8 & x1 (x1'=min(x1+1,TIME_MAX)); - // move to transmit - [send1] s1=8 & (x1=VULN | x1=VULN-1) -> (s1'=9) & (x1'=0); - // TRANSMIT - // let time pass - [time] s1=9 & x1 (x1'=min(x1+1,TIME_MAX)); - // finish transmission successful - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=1 -> (s1'=10) & (x1'=0); - // finish transmission garbled - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=2 -> (s1'=11) & (x1'=0); - // WAIT FOR SIFS THEN WAIT FOR ACK - - // WAIT FOR SIFS i.e. c1=0 - // check channel and busy: go into backoff - [] s1=10 & c1=0 & x1=0 & busy -> (s1'=2); - // check channel and free: let time pass - [time] s1=10 & c1=0 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - // following guard is always false as SIFS=1 - // [time] s1=10 & c1=0 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // ack is sent after SIFS (since SIFS-1=0 add condition that channel is free) - [send1] s1=10 & c1=0 & (x1=SIFS | (x1=SIFS-1 & free)) -> (s1'=10) & (x1'=0); - - // WAIT FOR ACK i.e. c1=1 - // let time pass - [time] s1=10 & c1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // get acknowledgement so packet sent correctly and move to done - [finish1] s1=10 & c1=1 & (x1=ACK | x1=ACK-1) -> (s1'=12) & (x1'=0) & (bc1'=0); - - // WAIT FOR ACK_TO - // check channel and busy: go into backoff - [] s1=11 & x1=0 & busy -> (s1'=2); - // check channel and free: let time pass - [time] s1=11 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - [time] s1=11 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // no acknowledgement (go to backoff waiting DIFS first) - [] s1=11 & x1=ACK_TO -> (s1'=3) & (x1'=0); - - // DONE - [time] s1=12 -> (s1'=12); -endmodule - -// ---------------------------------------------------------------------------- // -// STATION 2 (rename STATION 1) -module -station2=station1[x1=x2, - s1=s2, - s2=s1, - c1=c2, - c2=c1, - slot1=slot2, - backoff1=backoff2, - bc1=bc2, - send1=send2, - finish1=finish2] -endmodule -// ---------------------------------------------------------------------------- // - -label "twoCollisions" = col=2; -label "fourCollisions" = col=4; -label "sixCollisions" = col=6; \ No newline at end of file diff --git a/examples/mdp/wlan/wlan3_collide.nm b/examples/mdp/wlan/wlan3_collide.nm deleted file mode 100644 index 1d093e6d7..000000000 --- a/examples/mdp/wlan/wlan3_collide.nm +++ /dev/null @@ -1,235 +0,0 @@ -// WLAN PROTOCOL (two stations) -// discrete time model -// gxn/jzs 20/02/02 - -mdp - -// COLLISIONS -const int COL; // maximum number of collisions - -// TIMING CONSTRAINTS -// we have used the FHSS parameters -// then scaled by the value of ASLOTTIME -const int ASLOTTIME = 1; -const int DIFS = 3; // due to scaling can be either 2 or 3 which is modelled by a non-deterministic choice -const int VULN = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -const int TRANS_TIME_MAX; // scaling up -const int TRANS_TIME_MIN = 4; // scaling down -const int ACK_TO = 6; -const int ACK = 4; // due to scaling can be either 3 or 4 which is modelled by a non-deterministic choice -const int SIFS = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -// maximum constant used in timing constraints + 1 -const int TIME_MAX = max(ACK_TO,TRANS_TIME_MAX)+1; - -// CONTENTION WINDOW -// CWMIN =15 & CWMAX =127 -// this means that MAX_BACKOFF IS 3 -const int MAX_BACKOFF = 3; - -//-----------------------------------------------------------------// -// THE MEDIUM/CHANNEL - -// FORMULAE FOR THE CHANNEL -// channel is busy -formula busy = c1>0 | c2>0; -// channel is free -formula free = c1=0 & c2=0; - -module medium - - // number of collisions - col : [0..COL]; - - // medium status - c1 : [0..2]; - c2 : [0..2]; - // ci corresponds to messages associated with station i - // 0 nothing being sent - // 1 being sent correctly - // 2 being sent garbled - - // begin sending message and nothing else currently being sent - [send1] c1=0 & c2=0 -> (c1'=1); - [send2] c2=0 & c1=0 -> (c2'=1); - - // begin sending message and something is already being sent - // in this case both messages become garbled - [send1] c1=0 & c2>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - [send2] c2=0 & c1>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - - // finish sending message - [finish1] c1>0 -> (c1'=0); - [finish2] c2>0 -> (c2'=0); - -endmodule - -//-----------------------------------------------------------------// -// STATION 1 -module station1 - // clock for station 1 - x1 : [0..TIME_MAX]; - - // local state - s1 : [1..12]; - // 1 sense - // 2 wait until free before setting backoff - // 3 wait for DIFS then set slot - // 4 set backoff - // 5 backoff - // 6 wait until free in backoff - // 7 wait for DIFS then resume backoff - // 8 vulnerable - // 9 transmit - // 11 wait for SIFS and then ACK - // 10 wait for ACT_TO - // 12 done - // BACKOFF - // separate into slots - slot1 : [0..7]; - backoff1 : [0..15]; - - // BACKOFF COUNTER - bc1 : [0..MAX_BACKOFF]; - // SENSE - // let time pass - [time] s1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // ready to transmit - [] s1=1 & (x1=DIFS | x1=DIFS-1) -> (s1'=8) & (x1'=0); - // found channel busy so wait until free - [] s1=1 & busy -> (s1'=2) & (x1'=0); - // WAIT UNTIL FREE BEFORE SETTING BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=2 & busy -> (s1'=2); - // find that channel is free so check its free for DIFS before setting backoff - [] s1=2 & free -> (s1'=3); - // WAIT FOR DIFS THEN SET BACKOFF - // let time pass - [time] s1=3 & x1 (x1'=min(x1+1,TIME_MAX)); - // found channel busy so wait until free - [] s1=3 & busy -> (s1'=2) & (x1'=0); - // start backoff first uniformly choose slot - // backoff counter 0 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=0 -> (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 1 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=1 -> 1/2 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/2 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 2 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=2 -> 1/4 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=2) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=3) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 3 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=3 -> 1/8 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=2) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=3) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=4) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=5) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=6) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=7) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // SET BACKOFF (no time can pass) - // chosen slot now set backoff - [] s1=4 -> 1/16 : (s1'=5) & (backoff1'=0 ) - + 1/16 : (s1'=5) & (backoff1'=1 ) - + 1/16 : (s1'=5) & (backoff1'=2 ) - + 1/16 : (s1'=5) & (backoff1'=3 ) - + 1/16 : (s1'=5) & (backoff1'=4 ) - + 1/16 : (s1'=5) & (backoff1'=5 ) - + 1/16 : (s1'=5) & (backoff1'=6 ) - + 1/16 : (s1'=5) & (backoff1'=7 ) - + 1/16 : (s1'=5) & (backoff1'=8 ) - + 1/16 : (s1'=5) & (backoff1'=9 ) - + 1/16 : (s1'=5) & (backoff1'=10) - + 1/16 : (s1'=5) & (backoff1'=11) - + 1/16 : (s1'=5) & (backoff1'=12) - + 1/16 : (s1'=5) & (backoff1'=13) - + 1/16 : (s1'=5) & (backoff1'=14) - + 1/16 : (s1'=5) & (backoff1'=15); - // BACKOFF - // let time pass - [time] s1=5 & x1 (x1'=min(x1+1,TIME_MAX)); - // decrement backoff - [] s1=5 & x1=ASLOTTIME & backoff1>0 -> (s1'=5) & (x1'=0) & (backoff1'=backoff1-1); - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1>0 -> (s1'=5) & (x1'=0) & (backoff1'=15) & (slot1'=slot1-1); - // finish backoff - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1=0 -> (s1'=8) & (x1'=0); - // found channel busy - [] s1=5 & busy -> (s1'=6) & (x1'=0); - // WAIT UNTIL FREE IN BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=6 & busy -> (s1'=6); - // find that channel is free - [] s1=6 & free -> (s1'=7); - - // WAIT FOR DIFS THEN RESUME BACKOFF - // let time pass - [time] s1=7 & x1 (x1'=min(x1+1,TIME_MAX)); - // resume backoff (start again from previous backoff) - [] s1=7 & (x1=DIFS | x1=DIFS-1) -> (s1'=5) & (x1'=0); - // found channel busy - [] s1=7 & busy -> (s1'=6) & (x1'=0); - - // VULNERABLE - // let time pass - [time] s1=8 & x1 (x1'=min(x1+1,TIME_MAX)); - // move to transmit - [send1] s1=8 & (x1=VULN | x1=VULN-1) -> (s1'=9) & (x1'=0); - // TRANSMIT - // let time pass - [time] s1=9 & x1 (x1'=min(x1+1,TIME_MAX)); - // finish transmission successful - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=1 -> (s1'=10) & (x1'=0); - // finish transmission garbled - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=2 -> (s1'=11) & (x1'=0); - // WAIT FOR SIFS THEN WAIT FOR ACK - - // WAIT FOR SIFS i.e. c1=0 - // check channel and busy: go into backoff - [] s1=10 & c1=0 & x1=0 & busy -> (s1'=2); - // check channel and free: let time pass - [time] s1=10 & c1=0 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - // following guard is always false as SIFS=1 - // [time] s1=10 & c1=0 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // ack is sent after SIFS (since SIFS-1=0 add condition that channel is free) - [send1] s1=10 & c1=0 & (x1=SIFS | (x1=SIFS-1 & free)) -> (s1'=10) & (x1'=0); - - // WAIT FOR ACK i.e. c1=1 - // let time pass - [time] s1=10 & c1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // get acknowledgement so packet sent correctly and move to done - [finish1] s1=10 & c1=1 & (x1=ACK | x1=ACK-1) -> (s1'=12) & (x1'=0) & (bc1'=0); - - // WAIT FOR ACK_TO - // check channel and busy: go into backoff - [] s1=11 & x1=0 & busy -> (s1'=2); - // check channel and free: let time pass - [time] s1=11 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - [time] s1=11 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // no acknowledgement (go to backoff waiting DIFS first) - [] s1=11 & x1=ACK_TO -> (s1'=3) & (x1'=0); - - // DONE - [time] s1=12 -> (s1'=12); -endmodule - -// ---------------------------------------------------------------------------- // -// STATION 2 (rename STATION 1) -module -station2=station1[x1=x2, - s1=s2, - s2=s1, - c1=c2, - c2=c1, - slot1=slot2, - backoff1=backoff2, - bc1=bc2, - send1=send2, - finish1=finish2] -endmodule -// ---------------------------------------------------------------------------- // - -label "twoCollisions" = col=2; -label "fourCollisions" = col=4; -label "sixCollisions" = col=6; \ No newline at end of file diff --git a/examples/mdp/wlan/wlan4_6.cexprop b/examples/mdp/wlan/wlan4_6.cexprop deleted file mode 100644 index ea38115ab..000000000 --- a/examples/mdp/wlan/wlan4_6.cexprop +++ /dev/null @@ -1 +0,0 @@ -P<0.0000001 [ F sixCollisions ] diff --git a/examples/mdp/wlan/wlan4_collide.nm b/examples/mdp/wlan/wlan4_collide.nm deleted file mode 100644 index 1287de1f3..000000000 --- a/examples/mdp/wlan/wlan4_collide.nm +++ /dev/null @@ -1,252 +0,0 @@ -// WLAN PROTOCOL (two stations) -// discrete time model -// gxn/jzs 20/02/02 - -mdp - -// COLLISIONS -const int COL; // maximum number of collisions - -// TIMING CONSTRAINTS -// we have used the FHSS parameters -// then scaled by the value of ASLOTTIME -const int ASLOTTIME = 1; -const int DIFS = 3; // due to scaling can be either 2 or 3 which is modelled by a non-deterministic choice -const int VULN = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -const int TRANS_TIME_MAX; // scaling up -const int TRANS_TIME_MIN = 4; // scaling down -const int ACK_TO = 6; -const int ACK = 4; // due to scaling can be either 3 or 4 which is modelled by a non-deterministic choice -const int SIFS = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -// maximum constant used in timing constraints + 1 -const int TIME_MAX = max(ACK_TO,TRANS_TIME_MAX)+1; - -// CONTENTION WINDOW -// CWMIN =15 & CWMAX =255 -// this means that MAX_BACKOFF IS 4 -const int MAX_BACKOFF = 4; - -//-----------------------------------------------------------------// -// THE MEDIUM/CHANNEL - -// FORMULAE FOR THE CHANNEL -// channel is busy -formula busy = c1>0 | c2>0; -// channel is free -formula free = c1=0 & c2=0; - -module medium - - // number of collisions - col : [0..COL]; - - // medium status - c1 : [0..2]; - c2 : [0..2]; - // ci corresponds to messages associated with station i - // 0 nothing being sent - // 1 being sent correctly - // 2 being sent garbled - - // begin sending message and nothing else currently being sent - [send1] c1=0 & c2=0 -> (c1'=1); - [send2] c2=0 & c1=0 -> (c2'=1); - - // begin sending message and something is already being sent - // in this case both messages become garbled - [send1] c1=0 & c2>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - [send2] c2=0 & c1>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - - // finish sending message - [finish1] c1>0 -> (c1'=0); - [finish2] c2>0 -> (c2'=0); - -endmodule - -//-----------------------------------------------------------------// -// STATION 1 -module station1 - // clock for station 1 - x1 : [0..TIME_MAX]; - - // local state - s1 : [1..12]; - // 1 sense - // 2 wait until free before setting backoff - // 3 wait for DIFS then set slot - // 4 set backoff - // 5 backoff - // 6 wait until free in backoff - // 7 wait for DIFS then resume backoff - // 8 vulnerable - // 9 transmit - // 11 wait for SIFS and then ACK - // 10 wait for ACT_TO - // 12 done - // BACKOFF - // separate into slots - slot1 : [0..15]; - backoff1 : [0..15]; - - // BACKOFF COUNTER - bc1 : [0..MAX_BACKOFF]; - // SENSE - // let time pass - [time] s1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // ready to transmit - [] s1=1 & (x1=DIFS | x1=DIFS-1) -> (s1'=8) & (x1'=0); - // found channel busy so wait until free - [] s1=1 & busy -> (s1'=2) & (x1'=0); - // WAIT UNTIL FREE BEFORE SETTING BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=2 & busy -> (s1'=2); - // find that channel is free so check its free for DIFS before setting backoff - [] s1=2 & free -> (s1'=3); - // WAIT FOR DIFS THEN SET BACKOFF - // let time pass - [time] s1=3 & x1 (x1'=min(x1+1,TIME_MAX)); - // found channel busy so wait until free - [] s1=3 & busy -> (s1'=2) & (x1'=0); - // start backoff first uniformly choose slot - // backoff counter 0 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=0 -> (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 1 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=1 -> 1/2 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/2 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 2 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=2 -> 1/4 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=2) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=3) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 3 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=3 -> 1/8 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=2) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=3) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=4) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=5) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=6) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=7) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 4 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=4 -> 1/16 : (s1'=4) & (x1'=0) & (slot1'=0 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=1 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=2 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=3 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=4 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=5 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=6 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=7 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=8 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=9 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=10) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=11) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=12) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=13) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=14) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=15) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // SET BACKOFF (no time can pass) - // chosen slot now set backoff - [] s1=4 -> 1/16 : (s1'=5) & (backoff1'=0 ) - + 1/16 : (s1'=5) & (backoff1'=1 ) - + 1/16 : (s1'=5) & (backoff1'=2 ) - + 1/16 : (s1'=5) & (backoff1'=3 ) - + 1/16 : (s1'=5) & (backoff1'=4 ) - + 1/16 : (s1'=5) & (backoff1'=5 ) - + 1/16 : (s1'=5) & (backoff1'=6 ) - + 1/16 : (s1'=5) & (backoff1'=7 ) - + 1/16 : (s1'=5) & (backoff1'=8 ) - + 1/16 : (s1'=5) & (backoff1'=9 ) - + 1/16 : (s1'=5) & (backoff1'=10) - + 1/16 : (s1'=5) & (backoff1'=11) - + 1/16 : (s1'=5) & (backoff1'=12) - + 1/16 : (s1'=5) & (backoff1'=13) - + 1/16 : (s1'=5) & (backoff1'=14) - + 1/16 : (s1'=5) & (backoff1'=15); - // BACKOFF - // let time pass - [time] s1=5 & x1 (x1'=min(x1+1,TIME_MAX)); - // decrement backoff - [] s1=5 & x1=ASLOTTIME & backoff1>0 -> (s1'=5) & (x1'=0) & (backoff1'=backoff1-1); - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1>0 -> (s1'=5) & (x1'=0) & (backoff1'=15) & (slot1'=slot1-1); - // finish backoff - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1=0 -> (s1'=8) & (x1'=0); - // found channel busy - [] s1=5 & busy -> (s1'=6) & (x1'=0); - // WAIT UNTIL FREE IN BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=6 & busy -> (s1'=6); - // find that channel is free - [] s1=6 & free -> (s1'=7); - - // WAIT FOR DIFS THEN RESUME BACKOFF - // let time pass - [time] s1=7 & x1 (x1'=min(x1+1,TIME_MAX)); - // resume backoff (start again from previous backoff) - [] s1=7 & (x1=DIFS | x1=DIFS-1) -> (s1'=5) & (x1'=0); - // found channel busy - [] s1=7 & busy -> (s1'=6) & (x1'=0); - - // VULNERABLE - // let time pass - [time] s1=8 & x1 (x1'=min(x1+1,TIME_MAX)); - // move to transmit - [send1] s1=8 & (x1=VULN | x1=VULN-1) -> (s1'=9) & (x1'=0); - // TRANSMIT - // let time pass - [time] s1=9 & x1 (x1'=min(x1+1,TIME_MAX)); - // finish transmission successful - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=1 -> (s1'=10) & (x1'=0); - // finish transmission garbled - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=2 -> (s1'=11) & (x1'=0); - // WAIT FOR SIFS THEN WAIT FOR ACK - - // WAIT FOR SIFS i.e. c1=0 - // check channel and busy: go into backoff - [] s1=10 & c1=0 & x1=0 & busy -> (s1'=2); - // check channel and free: let time pass - [time] s1=10 & c1=0 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - // following guard is always false as SIFS=1 - // [time] s1=10 & c1=0 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // ack is sent after SIFS (since SIFS-1=0 add condition that channel is free) - [send1] s1=10 & c1=0 & (x1=SIFS | (x1=SIFS-1 & free)) -> (s1'=10) & (x1'=0); - - // WAIT FOR ACK i.e. c1=1 - // let time pass - [time] s1=10 & c1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // get acknowledgement so packet sent correctly and move to done - [finish1] s1=10 & c1=1 & (x1=ACK | x1=ACK-1) -> (s1'=12) & (x1'=0) & (bc1'=0); - - // WAIT FOR ACK_TO - // check channel and busy: go into backoff - [] s1=11 & x1=0 & busy -> (s1'=2); - // check channel and free: let time pass - [time] s1=11 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - [time] s1=11 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // no acknowledgement (go to backoff waiting DIFS first) - [] s1=11 & x1=ACK_TO -> (s1'=3) & (x1'=0); - - // DONE - [time] s1=12 -> (s1'=12); -endmodule - -// ---------------------------------------------------------------------------- // -// STATION 2 (rename STATION 1) -module -station2=station1[x1=x2, - s1=s2, - s2=s1, - c1=c2, - c2=c1, - slot1=slot2, - backoff1=backoff2, - bc1=bc2, - send1=send2, - finish1=finish2] -endmodule -// ---------------------------------------------------------------------------- // - -label "twoCollisions" = col=2; -label "fourCollisions" = col=4; -label "sixCollisions" = col=6; \ No newline at end of file diff --git a/examples/mdp/wlan/wlan5_collide.nm b/examples/mdp/wlan/wlan5_collide.nm deleted file mode 100644 index e01b7cfcd..000000000 --- a/examples/mdp/wlan/wlan5_collide.nm +++ /dev/null @@ -1,286 +0,0 @@ -// WLAN PROTOCOL (two stations) -// discrete time model -// gxn/jzs 20/02/02 - -mdp - -// COLLISIONS -const int COL; // maximum number of collisions - -// TIMING CONSTRAINTS -// we have used the FHSS parameters -// then scaled by the value of ASLOTTIME -const int ASLOTTIME = 1; -const int DIFS = 3; // due to scaling can be either 2 or 3 which is modelled by a non-deterministic choice -const int VULN = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -const int TRANS_TIME_MAX; // scaling up -const int TRANS_TIME_MIN = 4; // scaling down -const int ACK_TO = 6; -const int ACK = 4; // due to scaling can be either 3 or 4 which is modelled by a non-deterministic choice -const int SIFS = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -// maximum constant used in timing constraints + 1 -const int TIME_MAX = max(ACK_TO,TRANS_TIME_MAX)+1; - -// CONTENTION WINDOW -// CWMIN =15 & CWMAX =511 -// this means that MAX_BACKOFF IS 5 -const int MAX_BACKOFF = 5; - -//-----------------------------------------------------------------// -// THE MEDIUM/CHANNEL - -// FORMULAE FOR THE CHANNEL -// channel is busy -formula busy = c1>0 | c2>0; -// channel is free -formula free = c1=0 & c2=0; - -module medium - - // number of collisions - col : [0..COL]; - - // medium status - c1 : [0..2]; - c2 : [0..2]; - // ci corresponds to messages associated with station i - // 0 nothing being sent - // 1 being sent correctly - // 2 being sent garbled - - // begin sending message and nothing else currently being sent - [send1] c1=0 & c2=0 -> (c1'=1); - [send2] c2=0 & c1=0 -> (c2'=1); - - // begin sending message and something is already being sent - // in this case both messages become garbled - [send1] c1=0 & c2>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - [send2] c2=0 & c1>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - - // finish sending message - [finish1] c1>0 -> (c1'=0); - [finish2] c2>0 -> (c2'=0); - -endmodule - -//-----------------------------------------------------------------// -// STATION 1 -module station1 - // clock for station 1 - x1 : [0..TIME_MAX]; - - // local state - s1 : [1..12]; - // 1 sense - // 2 wait until free before setting backoff - // 3 wait for DIFS then set slot - // 4 set backoff - // 5 backoff - // 6 wait until free in backoff - // 7 wait for DIFS then resume backoff - // 8 vulnerable - // 9 transmit - // 11 wait for SIFS and then ACK - // 10 wait for ACT_TO - // 12 done - // BACKOFF - // separate into slots - slot1 : [0..31]; - backoff1 : [0..15]; - - // BACKOFF COUNTER - bc1 : [0..MAX_BACKOFF]; - // SENSE - // let time pass - [time] s1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // ready to transmit - [] s1=1 & (x1=DIFS | x1=DIFS-1) -> (s1'=8) & (x1'=0); - // found channel busy so wait until free - [] s1=1 & busy -> (s1'=2) & (x1'=0); - // WAIT UNTIL FREE BEFORE SETTING BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=2 & busy -> (s1'=2); - // find that channel is free so check its free for DIFS before setting backoff - [] s1=2 & free -> (s1'=3); - // WAIT FOR DIFS THEN SET BACKOFF - // let time pass - [time] s1=3 & x1 (x1'=min(x1+1,TIME_MAX)); - // found channel busy so wait until free - [] s1=3 & busy -> (s1'=2) & (x1'=0); - // start backoff first uniformly choose slot - // backoff counter 0 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=0 -> (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 1 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=1 -> 1/2 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/2 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 2 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=2 -> 1/4 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=2) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=3) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 3 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=3 -> 1/8 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=2) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=3) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=4) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=5) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=6) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=7) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 4 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=4 -> 1/16 : (s1'=4) & (x1'=0) & (slot1'=0 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=1 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=2 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=3 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=4 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=5 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=6 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=7 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=8 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=9 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=10) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=11) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=12) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=13) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=14) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=15) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 5 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=5 -> 1/32 : (s1'=4) & (x1'=0) & (slot1'=0 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=1 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=2 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=3 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=4 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=5 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=6 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=7 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=8 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=9 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=10) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=11) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=12) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=13) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=14) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=15) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=16) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=17) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=18) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=19) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=20) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=21) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=22) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=23) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=24) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=25) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=26) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=27) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=28) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=29) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=30) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=31) & (bc1'=min(bc1+1,MAX_BACKOFF)); - - // SET BACKOFF (no time can pass) - // chosen slot now set backoff - [] s1=4 -> 1/16 : (s1'=5) & (backoff1'=0 ) - + 1/16 : (s1'=5) & (backoff1'=1 ) - + 1/16 : (s1'=5) & (backoff1'=2 ) - + 1/16 : (s1'=5) & (backoff1'=3 ) - + 1/16 : (s1'=5) & (backoff1'=4 ) - + 1/16 : (s1'=5) & (backoff1'=5 ) - + 1/16 : (s1'=5) & (backoff1'=6 ) - + 1/16 : (s1'=5) & (backoff1'=7 ) - + 1/16 : (s1'=5) & (backoff1'=8 ) - + 1/16 : (s1'=5) & (backoff1'=9 ) - + 1/16 : (s1'=5) & (backoff1'=10) - + 1/16 : (s1'=5) & (backoff1'=11) - + 1/16 : (s1'=5) & (backoff1'=12) - + 1/16 : (s1'=5) & (backoff1'=13) - + 1/16 : (s1'=5) & (backoff1'=14) - + 1/16 : (s1'=5) & (backoff1'=15); - // BACKOFF - // let time pass - [time] s1=5 & x1 (x1'=min(x1+1,TIME_MAX)); - // decrement backoff - [] s1=5 & x1=ASLOTTIME & backoff1>0 -> (s1'=5) & (x1'=0) & (backoff1'=backoff1-1); - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1>0 -> (s1'=5) & (x1'=0) & (backoff1'=15) & (slot1'=slot1-1); - // finish backoff - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1=0 -> (s1'=8) & (x1'=0); - // found channel busy - [] s1=5 & busy -> (s1'=6) & (x1'=0); - // WAIT UNTIL FREE IN BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=6 & busy -> (s1'=6); - // find that channel is free - [] s1=6 & free -> (s1'=7); - - // WAIT FOR DIFS THEN RESUME BACKOFF - // let time pass - [time] s1=7 & x1 (x1'=min(x1+1,TIME_MAX)); - // resume backoff (start again from previous backoff) - [] s1=7 & (x1=DIFS | x1=DIFS-1) -> (s1'=5) & (x1'=0); - // found channel busy - [] s1=7 & busy -> (s1'=6) & (x1'=0); - - // VULNERABLE - // let time pass - [time] s1=8 & x1 (x1'=min(x1+1,TIME_MAX)); - // move to transmit - [send1] s1=8 & (x1=VULN | x1=VULN-1) -> (s1'=9) & (x1'=0); - // TRANSMIT - // let time pass - [time] s1=9 & x1 (x1'=min(x1+1,TIME_MAX)); - // finish transmission successful - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=1 -> (s1'=10) & (x1'=0); - // finish transmission garbled - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=2 -> (s1'=11) & (x1'=0); - // WAIT FOR SIFS THEN WAIT FOR ACK - - // WAIT FOR SIFS i.e. c1=0 - // check channel and busy: go into backoff - [] s1=10 & c1=0 & x1=0 & busy -> (s1'=2); - // check channel and free: let time pass - [time] s1=10 & c1=0 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - // following guard is always false as SIFS=1 - // [time] s1=10 & c1=0 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // ack is sent after SIFS (since SIFS-1=0 add condition that channel is free) - [send1] s1=10 & c1=0 & (x1=SIFS | (x1=SIFS-1 & free)) -> (s1'=10) & (x1'=0); - - // WAIT FOR ACK i.e. c1=1 - // let time pass - [time] s1=10 & c1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // get acknowledgement so packet sent correctly and move to done - [finish1] s1=10 & c1=1 & (x1=ACK | x1=ACK-1) -> (s1'=12) & (x1'=0) & (bc1'=0); - - // WAIT FOR ACK_TO - // check channel and busy: go into backoff - [] s1=11 & x1=0 & busy -> (s1'=2); - // check channel and free: let time pass - [time] s1=11 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - [time] s1=11 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // no acknowledgement (go to backoff waiting DIFS first) - [] s1=11 & x1=ACK_TO -> (s1'=3) & (x1'=0); - - // DONE - [time] s1=12 -> (s1'=12); -endmodule - -// ---------------------------------------------------------------------------- // -// STATION 2 (rename STATION 1) -module -station2=station1[x1=x2, - s1=s2, - s2=s1, - c1=c2, - c2=c1, - slot1=slot2, - backoff1=backoff2, - bc1=bc2, - send1=send2, - finish1=finish2] -endmodule -// ---------------------------------------------------------------------------- // - -label "twoCollisions" = col=2; -label "fourCollisions" = col=4; -label "sixCollisions" = col=6; \ No newline at end of file diff --git a/examples/mdp/wlan/wlan6_collide.nm b/examples/mdp/wlan/wlan6_collide.nm deleted file mode 100644 index e0a098f71..000000000 --- a/examples/mdp/wlan/wlan6_collide.nm +++ /dev/null @@ -1,351 +0,0 @@ -// WLAN PROTOCOL (two stations) -// discrete time model -// gxn/jzs 20/02/02 - -mdp - -// COLLISIONS -const int COL; // maximum number of collisions - -// TIMING CONSTRAINTS -// we have used the FHSS parameters -// then scaled by the value of ASLOTTIME -const int ASLOTTIME = 1; -const int DIFS = 3; // due to scaling can be either 2 or 3 which is modelled by a non-deterministic choice -const int VULN = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -const int TRANS_TIME_MAX; // scaling up -const int TRANS_TIME_MIN = 4; // scaling down -const int ACK_TO = 6; -const int ACK = 4; // due to scaling can be either 3 or 4 which is modelled by a non-deterministic choice -const int SIFS = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice -// maximum constant used in timing constraints + 1 -const int TIME_MAX = max(ACK_TO,TRANS_TIME_MAX)+1; - -// CONTENTION WINDOW -// CWMIN =15 & CWMAX =1023 -// this means that MAX_BACKOFF IS 6 -const int MAX_BACKOFF = 6; - -//-----------------------------------------------------------------// -// THE MEDIUM/CHANNEL - -// FORMULAE FOR THE CHANNEL -// channel is busy -formula busy = c1>0 | c2>0; -// channel is free -formula free = c1=0 & c2=0; - -module medium - - // number of collisions - col : [0..COL]; - - // medium status - c1 : [0..2]; - c2 : [0..2]; - // ci corresponds to messages associated with station i - // 0 nothing being sent - // 1 being sent correctly - // 2 being sent garbled - - // begin sending message and nothing else currently being sent - [send1] c1=0 & c2=0 -> (c1'=1); - [send2] c2=0 & c1=0 -> (c2'=1); - - // begin sending message and something is already being sent - // in this case both messages become garbled - [send1] c1=0 & c2>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - [send2] c2=0 & c1>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL)); - - // finish sending message - [finish1] c1>0 -> (c1'=0); - [finish2] c2>0 -> (c2'=0); - -endmodule - -//-----------------------------------------------------------------// -// STATION 1 -module station1 - // clock for station 1 - x1 : [0..TIME_MAX]; - - // local state - s1 : [1..12]; - // 1 sense - // 2 wait until free before setting backoff - // 3 wait for DIFS then set slot - // 4 set backoff - // 5 backoff - // 6 wait until free in backoff - // 7 wait for DIFS then resume backoff - // 8 vulnerable - // 9 transmit - // 11 wait for SIFS and then ACK - // 10 wait for ACT_TO - // 12 done - // BACKOFF - // separate into slots - slot1 : [0..63]; - backoff1 : [0..15]; - - // BACKOFF COUNTER - bc1 : [0..MAX_BACKOFF]; - // SENSE - // let time pass - [time] s1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // ready to transmit - [] s1=1 & (x1=DIFS | x1=DIFS-1) -> (s1'=8) & (x1'=0); - // found channel busy so wait until free - [] s1=1 & busy -> (s1'=2) & (x1'=0); - // WAIT UNTIL FREE BEFORE SETTING BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=2 & busy -> (s1'=2); - // find that channel is free so check its free for DIFS before setting backoff - [] s1=2 & free -> (s1'=3); - // WAIT FOR DIFS THEN SET BACKOFF - // let time pass - [time] s1=3 & x1 (x1'=min(x1+1,TIME_MAX)); - // found channel busy so wait until free - [] s1=3 & busy -> (s1'=2) & (x1'=0); - // start backoff first uniformly choose slot - // backoff counter 0 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=0 -> (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 1 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=1 -> 1/2 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/2 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 2 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=2 -> 1/4 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=2) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/4 : (s1'=4) & (x1'=0) & (slot1'=3) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 3 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=3 -> 1/8 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=2) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=3) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=4) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=5) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=6) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/8 : (s1'=4) & (x1'=0) & (slot1'=7) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 4 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=4 -> 1/16 : (s1'=4) & (x1'=0) & (slot1'=0 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=1 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=2 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=3 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=4 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=5 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=6 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=7 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=8 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=9 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=10) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=11) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=12) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=13) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=14) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/16 : (s1'=4) & (x1'=0) & (slot1'=15) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // backoff counter 5 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=5 -> 1/32 : (s1'=4) & (x1'=0) & (slot1'=0 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=1 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=2 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=3 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=4 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=5 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=6 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=7 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=8 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=9 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=10) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=11) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=12) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=13) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=14) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=15) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=16) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=17) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=18) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=19) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=20) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=21) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=22) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=23) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=24) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=25) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=26) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=27) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=28) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=29) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=30) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/32 : (s1'=4) & (x1'=0) & (slot1'=31) & (bc1'=min(bc1+1,MAX_BACKOFF)); - - // backoff counter 6 - [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=6 -> 1/64 : (s1'=4) & (x1'=0) & (slot1'=0 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=1 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=2 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=3 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=4 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=5 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=6 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=7 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=8 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=9 ) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=10) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=11) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=12) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=13) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=14) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=15) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=16) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=17) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=18) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=19) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=20) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=21) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=22) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=23) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=24) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=25) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=26) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=27) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=28) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=29) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=30) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=31) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=32) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=33) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=34) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=35) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=36) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=37) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=38) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=39) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=40) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=41) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=42) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=43) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=44) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=45) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=46) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=47) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=48) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=49) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=50) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=51) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=52) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=53) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=54) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=55) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=56) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=57) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=58) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=59) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=60) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=61) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=62) & (bc1'=min(bc1+1,MAX_BACKOFF)) - + 1/64 : (s1'=4) & (x1'=0) & (slot1'=63) & (bc1'=min(bc1+1,MAX_BACKOFF)); - // SET BACKOFF (no time can pass) - // chosen slot now set backoff - [] s1=4 -> 1/16 : (s1'=5) & (backoff1'=0 ) - + 1/16 : (s1'=5) & (backoff1'=1 ) - + 1/16 : (s1'=5) & (backoff1'=2 ) - + 1/16 : (s1'=5) & (backoff1'=3 ) - + 1/16 : (s1'=5) & (backoff1'=4 ) - + 1/16 : (s1'=5) & (backoff1'=5 ) - + 1/16 : (s1'=5) & (backoff1'=6 ) - + 1/16 : (s1'=5) & (backoff1'=7 ) - + 1/16 : (s1'=5) & (backoff1'=8 ) - + 1/16 : (s1'=5) & (backoff1'=9 ) - + 1/16 : (s1'=5) & (backoff1'=10) - + 1/16 : (s1'=5) & (backoff1'=11) - + 1/16 : (s1'=5) & (backoff1'=12) - + 1/16 : (s1'=5) & (backoff1'=13) - + 1/16 : (s1'=5) & (backoff1'=14) - + 1/16 : (s1'=5) & (backoff1'=15); - // BACKOFF - // let time pass - [time] s1=5 & x1 (x1'=min(x1+1,TIME_MAX)); - // decrement backoff - [] s1=5 & x1=ASLOTTIME & backoff1>0 -> (s1'=5) & (x1'=0) & (backoff1'=backoff1-1); - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1>0 -> (s1'=5) & (x1'=0) & (backoff1'=15) & (slot1'=slot1-1); - // finish backoff - [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1=0 -> (s1'=8) & (x1'=0); - // found channel busy - [] s1=5 & busy -> (s1'=6) & (x1'=0); - // WAIT UNTIL FREE IN BACKOFF - // let time pass (no need for the clock x1 to change) - [time] s1=6 & busy -> (s1'=6); - // find that channel is free - [] s1=6 & free -> (s1'=7); - - // WAIT FOR DIFS THEN RESUME BACKOFF - // let time pass - [time] s1=7 & x1 (x1'=min(x1+1,TIME_MAX)); - // resume backoff (start again from previous backoff) - [] s1=7 & (x1=DIFS | x1=DIFS-1) -> (s1'=5) & (x1'=0); - // found channel busy - [] s1=7 & busy -> (s1'=6) & (x1'=0); - - // VULNERABLE - // let time pass - [time] s1=8 & x1 (x1'=min(x1+1,TIME_MAX)); - // move to transmit - [send1] s1=8 & (x1=VULN | x1=VULN-1) -> (s1'=9) & (x1'=0); - // TRANSMIT - // let time pass - [time] s1=9 & x1 (x1'=min(x1+1,TIME_MAX)); - // finish transmission successful - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=1 -> (s1'=10) & (x1'=0); - // finish transmission garbled - [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=2 -> (s1'=11) & (x1'=0); - // WAIT FOR SIFS THEN WAIT FOR ACK - - // WAIT FOR SIFS i.e. c1=0 - // check channel and busy: go into backoff - [] s1=10 & c1=0 & x1=0 & busy -> (s1'=2); - // check channel and free: let time pass - [time] s1=10 & c1=0 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - // following guard is always false as SIFS=1 - // [time] s1=10 & c1=0 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // ack is sent after SIFS (since SIFS-1=0 add condition that channel is free) - [send1] s1=10 & c1=0 & (x1=SIFS | (x1=SIFS-1 & free)) -> (s1'=10) & (x1'=0); - - // WAIT FOR ACK i.e. c1=1 - // let time pass - [time] s1=10 & c1=1 & x1 (x1'=min(x1+1,TIME_MAX)); - // get acknowledgement so packet sent correctly and move to done - [finish1] s1=10 & c1=1 & (x1=ACK | x1=ACK-1) -> (s1'=12) & (x1'=0) & (bc1'=0); - - // WAIT FOR ACK_TO - // check channel and busy: go into backoff - [] s1=11 & x1=0 & busy -> (s1'=2); - // check channel and free: let time pass - [time] s1=11 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX)); - // let time pass - [time] s1=11 & x1>0 & x1 (x1'=min(x1+1,TIME_MAX)); - // no acknowledgement (go to backoff waiting DIFS first) - [] s1=11 & x1=ACK_TO -> (s1'=3) & (x1'=0); - - // DONE - [time] s1=12 -> (s1'=12); -endmodule - -// ---------------------------------------------------------------------------- // -// STATION 2 (rename STATION 1) -module -station2=station1[x1=x2, - s1=s2, - s2=s1, - c1=c2, - c2=c1, - slot1=slot2, - backoff1=backoff2, - bc1=bc2, - send1=send2, - finish1=finish2] -endmodule -// ---------------------------------------------------------------------------- // - -label "twoCollisions" = col=2; -label "fourCollisions" = col=4; -label "sixCollisions" = col=6; \ No newline at end of file diff --git a/examples/mdp/wlan/wlanX_2.cexprop b/examples/mdp/wlan/wlanX_2.cexprop deleted file mode 100644 index 1dad8767d..000000000 --- a/examples/mdp/wlan/wlanX_2.cexprop +++ /dev/null @@ -1 +0,0 @@ -P<0.1 [ F twoCollisions ] diff --git a/examples/mdp/wlan/wlanX_4.cexprop b/examples/mdp/wlan/wlanX_4.cexprop deleted file mode 100644 index 8af300d54..000000000 --- a/examples/mdp/wlan/wlanX_4.cexprop +++ /dev/null @@ -1 +0,0 @@ -P<0.003 [ F fourCollisions ] diff --git a/examples/mdp/wlan/wlanX_6.cexprop b/examples/mdp/wlan/wlanX_6.cexprop deleted file mode 100644 index b02357fa7..000000000 --- a/examples/mdp/wlan/wlanX_6.cexprop +++ /dev/null @@ -1 +0,0 @@ -P<0.1 [ F sixCollisions ] diff --git a/examples/multiobjective/.gitignore b/examples/multiobjective/.gitignore deleted file mode 100644 index afed0735d..000000000 --- a/examples/multiobjective/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.csv diff --git a/examples/multiobjective/displaypareto/.gitignore b/examples/multiobjective/displaypareto/.gitignore deleted file mode 100644 index 12aacb080..000000000 --- a/examples/multiobjective/displaypareto/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.aux -*.log -*.synctex.gz -*.pdf diff --git a/examples/multiobjective/displaypareto/displaypareto.tex b/examples/multiobjective/displaypareto/displaypareto.tex deleted file mode 100644 index bc6f76c4a..000000000 --- a/examples/multiobjective/displaypareto/displaypareto.tex +++ /dev/null @@ -1,23 +0,0 @@ -% This file can be used to display the exported plots from multi-objective model checking - -\documentclass{article} -\usepackage{pgfplots} -\usepackage{filecontents} - -\newcommand{\resultPath}{../ma/stream/results/} - -\begin{document} - \centering -\begin{tikzpicture}[scale=1.75] -\begin{axis}[ - enlargelimits=false, - axis background/.style={fill=red!50} - ] -\addplot[fill=white, very thin] table [col sep=comma] {\resultPath overapproximation.csv} -- cycle; -\addplot[fill=green, very thin] table [col sep=comma] {\resultPath underapproximation.csv} -- cycle; -\addplot[mark=o, mark options={blue, scale=1.3, thick}, only marks] table [col sep=comma] {\resultPath paretopoints.csv}; -\addplot[mark=false] table [col sep=comma] {\resultPath boundaries.csv}; -\end{axis} -\end{tikzpicture} - -\end{document} \ No newline at end of file diff --git a/examples/multiobjective/ma/mutex/mutex2.ma b/examples/multiobjective/ma/mutex/mutex2.ma deleted file mode 100644 index 296afa8ec..000000000 --- a/examples/multiobjective/ma/mutex/mutex2.ma +++ /dev/null @@ -1,93 +0,0 @@ -// Translation of the MAPA Specification of a mutex system into PRISM code -// http://wwwhome.cs.utwente.nl/~timmer/scoop/papers/qest13/index.html - -ma - -const int N; // The size of the data (should be at most 6) - -formula someEnter = s1=1 | s2=1; -formula someWait = s1=2 | s2=2; -formula someLow = s1=3 | s2=3; -formula someHigh = s1=4 | s2=4; -formula someTie = s1=5 | s2=5; -formula someAdmit = s1=6 | s2=6; -formula otherHigh = s2=4; - -formula someLowTie = someLow | someTie; -formula someLowHighTie = someLow | someHigh | someTie; -formula someAdmitHighTie = someAdmit | someHigh | someTie; -formula someEnterWait = someEnter | someWait; - - -module process1 - - // The internal state of the process - // 0: uninterested - // 1: enter - // 2: wait - // 3: low - // 4: high - // 5: tie - // 6: admit - s1 : [0..6]; - - // the phase of the protocol - phase1 : [1..12]; - - // The considered data - data1 : [1..N]; - - // The result of a coin flip - h1 : bool; - - //[] phase1=1 -> 1 : true; - [] phase1=1 -> 1 : (phase1'=2); - - [] phase1=2 & N>=1 -> 1 : (data1'=1) & (phase1'=3); - [] phase1=2 & N>=2 -> 1 : (data1'=2) & (phase1'=3); - [] phase1=2 & N>=3 -> 1 : (data1'=3) & (phase1'=3); - [] phase1=2 & N>=4 -> 1 : (data1'=4) & (phase1'=3); - [] phase1=2 & N>=5 -> 1 : (data1'=5) & (phase1'=3); - [] phase1=2 & N>=6 -> 1 : (data1'=6) & (phase1'=3); - - [] phase1=3 & (someLowHighTie & !someAdmit) -> 1 : (s1'=2) & (phase1'=4); - [] phase1=3 & (!someLowHighTie | someAdmit) -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - [] phase1=4 & (!someLowHighTie | someAdmit) -> 1 : (s1'=1) & (phase1'=3); - - [] phase1=5 & h1=false -> 1 : (s1'=3) & (phase1'=6); - [] phase1=5 & h1=true -> 1 : (s1'=4) & (phase1'=7) & (h1'=false); - - [] phase1=6 & !someAdmitHighTie -> 1 : (s1'=5) & (phase1'=8); - - [] phase1=7 & (someAdmit | otherHigh) -> 1 : (s1'=5) & (phase1'=9); - [] phase1=7 & (!someAdmit & !otherHigh) -> 1 : (phase1'=10); - - [] phase1=8 -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - [] phase1=9 & !someAdmit & !otherHigh -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - <> phase1=10 -> data1 : (phase1'=11) & (data1'=1); - - [] phase1=11 & (someLowTie | otherHigh) & !someEnter -> 1 : (s1'=0) & (phase1'=1); - [] phase1=11 & !someLowTie & !otherHigh -> 1 : (s1'=6) & (phase1'=12); - - [] phase1=12 & !someEnterWait -> 1 : (s1'=0) & (phase1'=1); - -endmodule - -module process2 = process1 [ s1=s2, phase1=phase2, data1=data2, h1=h2, s2=s1] endmodule - -label "crit1" = phase1=10; -label "crit2" = phase2=10; - - -rewards "timeInCrit1" - phase1=10 : 1; -endrewards - - -rewards "timeInCrit2" - phase2=10 : 1; -endrewards - diff --git a/examples/multiobjective/ma/mutex/mutex3.ma b/examples/multiobjective/ma/mutex/mutex3.ma deleted file mode 100644 index f47ef31f5..000000000 --- a/examples/multiobjective/ma/mutex/mutex3.ma +++ /dev/null @@ -1,98 +0,0 @@ -// Translation of the MAPA Specification of a mutex system into PRISM code -// http://wwwhome.cs.utwente.nl/~timmer/scoop/papers/qest13/index.html - -ma - -const int N; // The size of the data (should be at most 6) - -formula someEnter = s1=1 | s2=1 | s3=1; -formula someWait = s1=2 | s2=2 | s3=2; -formula someLow = s1=3 | s2=3 | s3=3; -formula someHigh = s1=4 | s2=4 | s3=4; -formula someTie = s1=5 | s2=5 | s3=5; -formula someAdmit = s1=6 | s2=6 | s3=6; -formula otherHigh = s2=4 | s3=4; - -formula someLowTie = someLow | someTie; -formula someLowHighTie = someLow | someHigh | someTie; -formula someAdmitHighTie = someAdmit | someHigh | someTie; -formula someEnterWait = someEnter | someWait; - - -module process1 - - // The internal state of the process - // 0: uninterested - // 1: enter - // 2: wait - // 3: low - // 4: high - // 5: tie - // 6: admit - s1 : [0..6]; - - // the phase of the protocol - phase1 : [1..12]; - - // The considered data - data1 : [1..N]; - - // The result of a coin flip - h1 : bool; - - //[] phase1=1 -> 1 : true; - [] phase1=1 -> 1 : (phase1'=2); - - [] phase1=2 & N>=1 -> 1 : (data1'=1) & (phase1'=3); - [] phase1=2 & N>=2 -> 1 : (data1'=2) & (phase1'=3); - [] phase1=2 & N>=3 -> 1 : (data1'=3) & (phase1'=3); - [] phase1=2 & N>=4 -> 1 : (data1'=4) & (phase1'=3); - [] phase1=2 & N>=5 -> 1 : (data1'=5) & (phase1'=3); - [] phase1=2 & N>=6 -> 1 : (data1'=6) & (phase1'=3); - - [] phase1=3 & (someLowHighTie & !someAdmit) -> 1 : (s1'=2) & (phase1'=4); - [] phase1=3 & (!someLowHighTie | someAdmit) -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - [] phase1=4 & (!someLowHighTie | someAdmit) -> 1 : (s1'=1) & (phase1'=3); - - [] phase1=5 & h1=false -> 1 : (s1'=3) & (phase1'=6); - [] phase1=5 & h1=true -> 1 : (s1'=4) & (phase1'=7) & (h1'=false); - - [] phase1=6 & !someAdmitHighTie -> 1 : (s1'=5) & (phase1'=8); - - [] phase1=7 & (someAdmit | otherHigh) -> 1 : (s1'=5) & (phase1'=9); - [] phase1=7 & (!someAdmit & !otherHigh) -> 1 : (phase1'=10); - - [] phase1=8 -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - [] phase1=9 & !someAdmit & !otherHigh -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - <> phase1=10 -> data1 : (phase1'=11) & (data1'=1); - - [] phase1=11 & (someLowTie | otherHigh) & !someEnter -> 1 : (s1'=0) & (phase1'=1); - [] phase1=11 & !someLowTie & !otherHigh -> 1 : (s1'=6) & (phase1'=12); - - [] phase1=12 & !someEnterWait -> 1 : (s1'=0) & (phase1'=1); - -endmodule - -module process2 = process1 [ s1=s2, phase1=phase2, data1=data2, h1=h2, s2=s1] endmodule -module process3 = process1 [ s1=s3, phase1=phase3, data1=data3, h1=h3, s3=s1] endmodule - -label "crit1" = phase1=10; -label "crit2" = phase2=10; -label "crit3" = phase3=10; - - -rewards "timeInCrit1" - phase1=10 : 1; -endrewards - -rewards "timeInCrit2" - phase2=10 : 1; -endrewards - -rewards "timeInCrit3" - phase3=10 : 1; -endrewards - diff --git a/examples/multiobjective/ma/mutex/mutex4.ma b/examples/multiobjective/ma/mutex/mutex4.ma deleted file mode 100644 index 8068933ef..000000000 --- a/examples/multiobjective/ma/mutex/mutex4.ma +++ /dev/null @@ -1,103 +0,0 @@ -// Translation of the MAPA Specification of a mutex system into PRISM code -// http://wwwhome.cs.utwente.nl/~timmer/scoop/papers/qest13/index.html - -ma - -const int N; // The size of the data (should be at most 6) - -formula someEnter = s1=1 | s2=1 | s3=1 | s4=1; -formula someWait = s1=2 | s2=2 | s3=2 | s4=2; -formula someLow = s1=3 | s2=3 | s3=3 | s4=3; -formula someHigh = s1=4 | s2=4 | s3=4 | s4=4; -formula someTie = s1=5 | s2=5 | s3=5 | s4=5; -formula someAdmit = s1=6 | s2=6 | s3=6 | s4=6; -formula otherHigh = s2=4 | s3=4 | s4=4; - -formula someLowTie = someLow | someTie; -formula someLowHighTie = someLow | someHigh | someTie; -formula someAdmitHighTie = someAdmit | someHigh | someTie; -formula someEnterWait = someEnter | someWait; - - -module process1 - - // The internal state of the process - // 0: uninterested - // 1: enter - // 2: wait - // 3: low - // 4: high - // 5: tie - // 6: admit - s1 : [0..6]; - - // the phase of the protocol - phase1 : [1..12]; - - // The considered data - data1 : [1..N]; - - // The result of a coin flip - h1 : bool; - - //[] phase1=1 -> 1 : true; - [] phase1=1 -> 1 : (phase1'=2); - - [] phase1=2 & N>=1 -> 1 : (data1'=1) & (phase1'=3); - [] phase1=2 & N>=2 -> 1 : (data1'=2) & (phase1'=3); - [] phase1=2 & N>=3 -> 1 : (data1'=3) & (phase1'=3); - [] phase1=2 & N>=4 -> 1 : (data1'=4) & (phase1'=3); - [] phase1=2 & N>=5 -> 1 : (data1'=5) & (phase1'=3); - [] phase1=2 & N>=6 -> 1 : (data1'=6) & (phase1'=3); - - [] phase1=3 & (someLowHighTie & !someAdmit) -> 1 : (s1'=2) & (phase1'=4); - [] phase1=3 & (!someLowHighTie | someAdmit) -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - [] phase1=4 & (!someLowHighTie | someAdmit) -> 1 : (s1'=1) & (phase1'=3); - - [] phase1=5 & h1=false -> 1 : (s1'=3) & (phase1'=6); - [] phase1=5 & h1=true -> 1 : (s1'=4) & (phase1'=7) & (h1'=false); - - [] phase1=6 & !someAdmitHighTie -> 1 : (s1'=5) & (phase1'=8); - - [] phase1=7 & (someAdmit | otherHigh) -> 1 : (s1'=5) & (phase1'=9); - [] phase1=7 & (!someAdmit & !otherHigh) -> 1 : (phase1'=10); - - [] phase1=8 -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - [] phase1=9 & !someAdmit & !otherHigh -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - <> phase1=10 -> data1 : (phase1'=11) & (data1'=1); - - [] phase1=11 & (someLowTie | otherHigh) & !someEnter -> 1 : (s1'=0) & (phase1'=1); - [] phase1=11 & !someLowTie & !otherHigh -> 1 : (s1'=6) & (phase1'=12); - - [] phase1=12 & !someEnterWait -> 1 : (s1'=0) & (phase1'=1); - -endmodule - -module process2 = process1 [ s1=s2, phase1=phase2, data1=data2, h1=h2, s2=s1] endmodule -module process3 = process1 [ s1=s3, phase1=phase3, data1=data3, h1=h3, s3=s1] endmodule -module process4 = process1 [ s1=s4, phase1=phase4, data1=data4, h1=h4, s4=s1] endmodule - -label "crit1" = phase1=10; -label "crit2" = phase2=10; -label "crit3" = phase3=10; -label "crit4" = phase4=10; - - -rewards "timeInCrit1" - phase1=10 : 1; -endrewards - -rewards "timeInCrit2" - phase2=10 : 1; -endrewards - -rewards "timeInCrit3" - phase3=10 : 1; -endrewards - -rewards "timeInCrit4" - phase4=10 : 1; -endrewards diff --git a/examples/multiobjective/ma/mutex/mutex5.ma b/examples/multiobjective/ma/mutex/mutex5.ma deleted file mode 100644 index 2755d829c..000000000 --- a/examples/multiobjective/ma/mutex/mutex5.ma +++ /dev/null @@ -1,110 +0,0 @@ -// Translation of the MAPA Specification of a mutex system into PRISM code -// http://wwwhome.cs.utwente.nl/~timmer/scoop/papers/qest13/index.html - -ma - -const int N; // The size of the data (should be at most 6) - -formula someEnter = s1=1 | s2=1 | s3=1 | s4=1 | s5=1; -formula someWait = s1=2 | s2=2 | s3=2 | s4=2 | s5=2; -formula someLow = s1=3 | s2=3 | s3=3 | s4=3 | s5=3; -formula someHigh = s1=4 | s2=4 | s3=4 | s4=4 | s5=4; -formula someTie = s1=5 | s2=5 | s3=5 | s4=5 | s5=5; -formula someAdmit = s1=6 | s2=6 | s3=6 | s4=6 | s5=6; -formula otherHigh = s2=4 | s3=4 | s4=4 | s5=4; - -formula someLowTie = someLow | someTie; -formula someLowHighTie = someLow | someHigh | someTie; -formula someAdmitHighTie = someAdmit | someHigh | someTie; -formula someEnterWait = someEnter | someWait; - -module process1 - - // The internal state of the process - // 0: uninterested - // 1: enter - // 2: wait - // 3: low - // 4: high - // 5: tie - // 6: admit - s1 : [0..6]; - - // the phase of the protocol - phase1 : [1..12]; - - // The considered data - data1 : [1..N]; - - // The result of a coin flip - h1 : bool; - - //[] phase1=1 -> 1 : true; - [] phase1=1 -> 1 : (phase1'=2); - - [] phase1=2 & N>=1 -> 1 : (data1'=1) & (phase1'=3); - [] phase1=2 & N>=2 -> 1 : (data1'=2) & (phase1'=3); - [] phase1=2 & N>=3 -> 1 : (data1'=3) & (phase1'=3); - [] phase1=2 & N>=4 -> 1 : (data1'=4) & (phase1'=3); - [] phase1=2 & N>=5 -> 1 : (data1'=5) & (phase1'=3); - [] phase1=2 & N>=6 -> 1 : (data1'=6) & (phase1'=3); - - [] phase1=3 & (someLowHighTie & !someAdmit) -> 1 : (s1'=2) & (phase1'=4); - [] phase1=3 & (!someLowHighTie | someAdmit) -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - [] phase1=4 & (!someLowHighTie | someAdmit) -> 1 : (s1'=1) & (phase1'=3); - - [] phase1=5 & h1=false -> 1 : (s1'=3) & (phase1'=6); - [] phase1=5 & h1=true -> 1 : (s1'=4) & (phase1'=7) & (h1'=false); - - [] phase1=6 & !someAdmitHighTie -> 1 : (s1'=5) & (phase1'=8); - - [] phase1=7 & (someAdmit | otherHigh) -> 1 : (s1'=5) & (phase1'=9); - [] phase1=7 & (!someAdmit & !otherHigh) -> 1 : (phase1'=10); - - [] phase1=8 -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - [] phase1=9 & !someAdmit & !otherHigh -> 0.5 : (phase1'=5) & (h1'=false) + 0.5 : (phase1'=5) & (h1'=true); - - <> phase1=10 -> data1 : (phase1'=11) & (data1'=1); - - [] phase1=11 & (someLowTie | otherHigh) & !someEnter -> 1 : (s1'=0) & (phase1'=1); - [] phase1=11 & !someLowTie & !otherHigh -> 1 : (s1'=6) & (phase1'=12); - - [] phase1=12 & !someEnterWait -> 1 : (s1'=0) & (phase1'=1); - -endmodule - -module process2 = process1 [ s1=s2, phase1=phase2, data1=data2, h1=h2, s2=s1] endmodule -module process3 = process1 [ s1=s3, phase1=phase3, data1=data3, h1=h3, s3=s1] endmodule -module process4 = process1 [ s1=s4, phase1=phase4, data1=data4, h1=h4, s4=s1] endmodule -module process5 = process1 [ s1=s5, phase1=phase5, data1=data5, h1=h5, s5=s1] endmodule - - -label "crit1" = phase1=10; -label "crit2" = phase2=10; -label "crit3" = phase3=10; -label "crit4" = phase4=10; -label "crit5" = phase5=10; - - -rewards "timeInCrit1" - phase1=10 : 1; -endrewards - -rewards "timeInCrit2" - phase2=10 : 1; -endrewards - -rewards "timeInCrit3" - phase3=10 : 1; -endrewards - -rewards "timeInCrit4" - phase4=10 : 1; -endrewards - -rewards "timeInCrit5" - phase5=10 : 1; -endrewards - diff --git a/examples/multiobjective/ma/polling/polling.ma b/examples/multiobjective/ma/polling/polling.ma deleted file mode 100644 index 5c8a45ad8..000000000 --- a/examples/multiobjective/ma/polling/polling.ma +++ /dev/null @@ -1,101 +0,0 @@ -// Translation of the MAPA Specification of a polling system into PRISM code -// http://wwwhome.cs.utwente.nl/~timmer/scoop/papers/qest13/index.html - -ma - -const int N; // number of job types (should be at most 6) -const int Q; // Maximum queue size in each station - -// Formulae to control the LIFO queue of the stations. -// The queue is represented by some integer whose base N representation has at most Q digits, each representing one of the job types 0, 1, ..., N-1. -// In addition, we store the current size of the queue which is needed to distinguish an empty queue from a queue holding job of type 0 -formula queue1_empty = q1Size=0; -formula queue1_full = q1Size=Q; -formula queue1_pop = floor(q1/N); -formula queue1_head = q1 - (queue1_pop * N); // i.e. q1 modulo N -formula queue1_push = q1*N; -formula queue2_empty = q2Size=0; -formula queue2_full = q2Size=Q; -formula queue2_pop = floor(q2/N); -formula queue2_head = q2 - (queue2_pop * N); // i.e. q2 modulo N -formula queue2_push = q2*N; - -const int queue_maxValue = (N^Q)-1; - -const double inRate1 = 3; // = (2 * #station) + 1; -const double inRate2 = 5; // = (2 * #station) + 1; - -module pollingsys - // The queues for the stations - q1 : [0..queue_maxValue]; - q1Size : [0..Q]; - q2 : [0..queue_maxValue]; - q2Size : [0..Q]; - - // Store the job that is currently processed by the server. j=N means that no job is processed. - j : [0..N] init N; - - // Flag indicating whether a new job arrived - newJob1 : bool init false; - newJob2 : bool init false; - - //<> !newJob1 & !newJob2 & !queue1_full & queue2_full & j=N -> inRate1 : (newJob1'=true); - //<> !newJob1 & !newJob2 & queue1_full & !queue2_full & j=N -> inRate2 : (newJob2'=true); - <> !newJob1 & !newJob2 & !queue1_full & !queue2_full & j=N -> inRate1 : (newJob1'=true) + inRate2 : (newJob2'=true); - <> !newJob1 & !newJob2 & queue1_full & queue2_full & j 2*(j+1) : (j'=N); - <> !newJob1 & !newJob2 & !queue1_full & queue2_full & j inRate1 : (newJob1'=true) + 2*(j+1) : (j'=N); - <> !newJob1 & !newJob2 & queue1_full & !queue2_full & j inRate2 : (newJob2'=true) + 2*(j+1) : (j'=N); - <> !newJob1 & !newJob2 & !queue1_full & !queue2_full & j inRate1 : (newJob1'=true) + inRate2 : (newJob2'=true) + 2*(j+1) : (j'=N); - - [] newJob1 & N>=1 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+0) & (newJob1'=false); - [] newJob1 & N>=2 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+1) & (newJob1'=false); - [] newJob1 & N>=3 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+2) & (newJob1'=false); - [] newJob1 & N>=4 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+3) & (newJob1'=false); - [] newJob1 & N>=5 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+4) & (newJob1'=false); - [] newJob1 & N>=6 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+5) & (newJob1'=false); - - [] newJob2 & N>=1 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+0) & (newJob2'=false); - [] newJob2 & N>=2 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+1) & (newJob2'=false); - [] newJob2 & N>=3 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+2) & (newJob2'=false); - [] newJob2 & N>=4 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+3) & (newJob2'=false); - [] newJob2 & N>=5 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+4) & (newJob2'=false); - [] newJob2 & N>=6 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+5) & (newJob2'=false); - - [copy1] !newJob1 & !newJob2 & !queue1_empty & j=N -> 0.9 : (j'=queue1_head) & (q1Size'=q1Size-1) & (q1'=queue1_pop) + 0.1 : (j'=queue1_head); - [copy2] !newJob1 & !newJob2 & !queue2_empty & j=N -> 0.9 : (j'=queue2_head) & (q2Size'=q2Size-1) & (q2'=queue2_pop) + 0.1 : (j'=queue2_head); - -endmodule - - - -label "q1full" = q1Size=Q; -label "q2full" = q2Size=Q; -label "allqueuesfull" = q1Size=Q & q2Size=Q; - - -// Rewards adapted from Guck et al.: Modelling and Analysis of Markov Reward Automata - -rewards "processedjobs1" - [copy1] true : 0.1; -endrewards - -rewards "processedjobs2" - [copy1] true : 0.1; -endrewards - -rewards "processedjobs" - [copy1] true : 1; - [copy2] true : 1; -endrewards - -rewards "waiting1" - true : (q1Size); -endrewards - -rewards "waiting2" - true : (q2Size); -endrewards - -rewards "waiting" - true : (q1Size + q2Size); -endrewards \ No newline at end of file diff --git a/examples/multiobjective/ma/server/server.csl b/examples/multiobjective/ma/server/server.csl deleted file mode 100644 index 41a74ec79..000000000 --- a/examples/multiobjective/ma/server/server.csl +++ /dev/null @@ -1 +0,0 @@ -multi(Tmax=? [ F "error" ], Pmax=? [ F "processB" ]) diff --git a/examples/multiobjective/ma/simple/simple.csl b/examples/multiobjective/ma/simple/simple.csl deleted file mode 100644 index 75452f1a2..000000000 --- a/examples/multiobjective/ma/simple/simple.csl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F s=3 ], Pmax=? [ F s=4 ]) diff --git a/examples/multiobjective/ma/stream/stream.ma b/examples/multiobjective/ma/stream/stream.ma deleted file mode 100644 index 9a657dd04..000000000 --- a/examples/multiobjective/ma/stream/stream.ma +++ /dev/null @@ -1,45 +0,0 @@ - -ma - -const int N; // num packages - -const double inRate = 4; -const double processingRate = 4; - -module streamingclient - - s : [0..3]; // current state: - // 0: decide whether to start - // 1: buffering - // 2: running - // 3: success - - n : [0..N]; // number of received packages - k : [0..N]; // number of processed packages - - [buffer] s=0 & n 1 : (s'=1); - [buffer] s=0 & n 0.99: (s'=1) + 0.01 : (s'=2) & (k'=k+1); - [start] s=0 & k 1 : (s'=2) & (k'=k+1); - - <> s=1 -> inRate : (n'=n+1) & (s'=0); - - <> s=2 & n inRate : (n'=n+1) + processingRate : (k'=k+1); - <> s=2 & n inRate : (n'=n+1) + processingRate : (s'=0); - <> s=2 & n=N & k processingRate : (k'=k+1); - <> s=2 & n=N & k=N -> processingRate : (s'=3); - - <> s=3 -> 1 : true; -endmodule - - -label "underrun" = (s=0 & k>0); -label "running" = (s=2); -label "done" = (s=3); - -rewards "buffering" - s=1 : 1; -endrewards - -rewards "numrestarts" - [start] k > 0 : 1; -endrewards diff --git a/examples/multiobjective/ma/stream/stream_bounded_pareto.csl b/examples/multiobjective/ma/stream/stream_bounded_pareto.csl deleted file mode 100644 index cdb98287f..000000000 --- a/examples/multiobjective/ma/stream/stream_bounded_pareto.csl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F<=3.5 "done" ], Pmax=? [ F<=1 s=2 ]) diff --git a/examples/multiobjective/ma/stream/stream_mixed_pareto.csl b/examples/multiobjective/ma/stream/stream_mixed_pareto.csl deleted file mode 100644 index 8b4085015..000000000 --- a/examples/multiobjective/ma/stream/stream_mixed_pareto.csl +++ /dev/null @@ -1,2 +0,0 @@ -multi(Pmax=? [ F<=2.5 s=2], R{"numrestarts"}min=? [ F "done"]) -// best looking on stream50 diff --git a/examples/multiobjective/ma/stream/stream_unbounded_pareto.csl b/examples/multiobjective/ma/stream/stream_unbounded_pareto.csl deleted file mode 100644 index 12e469030..000000000 --- a/examples/multiobjective/ma/stream/stream_unbounded_pareto.csl +++ /dev/null @@ -1 +0,0 @@ -multi(R{"initialbuffering"}min=? [ F "done" ], R{"numRestarts"}min=? [ F "done" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus2_3_2.nm b/examples/multiobjective/mdp/consensus/consensus2_3_2.nm deleted file mode 100644 index 8b602a4d7..000000000 --- a/examples/multiobjective/mdp/consensus/consensus2_3_2.nm +++ /dev/null @@ -1,88 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 2; // num processes -const int MAX = 3; // num rounds (R) -const int K = 2; // Parameter for coins - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p1, - r1=r2,r2=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - -endmodule - -// coins 2 and 3 are of no use as there are not enough rounds afterwards to decide - -// Labels -label "one_proc_err" = (s1=5 | s2=5); -label "one_coin_ok" = (c1=0); diff --git a/examples/multiobjective/mdp/consensus/consensus2_3_2_numerical.pctl b/examples/multiobjective/mdp/consensus/consensus2_3_2_numerical.pctl deleted file mode 100644 index f7bb97443..000000000 --- a/examples/multiobjective/mdp/consensus/consensus2_3_2_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], P>=0.8916673903 [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus2_3_2_pareto.pctl b/examples/multiobjective/mdp/consensus/consensus2_3_2_pareto.pctl deleted file mode 100644 index 7cd298d8e..000000000 --- a/examples/multiobjective/mdp/consensus/consensus2_3_2_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], Pmax=? [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus2_4_2.nm b/examples/multiobjective/mdp/consensus/consensus2_4_2.nm deleted file mode 100644 index 02724ba6e..000000000 --- a/examples/multiobjective/mdp/consensus/consensus2_4_2.nm +++ /dev/null @@ -1,114 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 2; // num processes -const int MAX = 4; // num rounds (R) -const int K = 2; // Parameter for coins - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - [coin3_s1_start] s1=2 & r1=3 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin3_s1_p1] s1=3 & r1=3 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin3_s1_p2] s1=3 & r1=3 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p1, - r1=r2,r2=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start,coin3_s1_start=coin3_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1,coin3_s1_p1=coin3_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2,coin3_s1_p2=coin3_s2_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - -endmodule - -// could do with renaming -module coin2_error - - c2 : [0..1]; // 1 is the error state - v2 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin2_s1_p1] v2=0 -> (v2'=1); - [coin2_s2_p1] v2=0 -> (v2'=1); - [coin2_s1_p2] v2=0 -> (v2'=2); - [coin2_s2_p2] v2=0 -> (v2'=2); - // later values returned - [coin2_s1_p1] v2=1 -> true; // good behaviour - [coin2_s2_p1] v2=1 -> true; // good behaviour - [coin2_s1_p2] v2=2 -> true; // good behaviour - [coin2_s2_p2] v2=2 -> true; // good behaviour - [coin2_s1_p1] v2=2 -> (c2'=1); // error - [coin2_s2_p1] v2=2 -> (c2'=1); // error - [coin2_s1_p2] v2=1 -> (c2'=1); // error - [coin2_s2_p2] v2=1 -> (c2'=1); // error - -endmodule - -// coin 3 is of no use because of number of rounds - -// Labels -label "one_proc_err" = (s1=5 | s2=5); -label "one_coin_ok" = (c1=0 | c2=0); diff --git a/examples/multiobjective/mdp/consensus/consensus2_4_2_numerical.pctl b/examples/multiobjective/mdp/consensus/consensus2_4_2_numerical.pctl deleted file mode 100644 index 62c7737ac..000000000 --- a/examples/multiobjective/mdp/consensus/consensus2_4_2_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], P>=0.9882640457 [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus2_4_2_pareto.pctl b/examples/multiobjective/mdp/consensus/consensus2_4_2_pareto.pctl deleted file mode 100644 index 7cd298d8e..000000000 --- a/examples/multiobjective/mdp/consensus/consensus2_4_2_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], Pmax=? [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus2_5_2.nm b/examples/multiobjective/mdp/consensus/consensus2_5_2.nm deleted file mode 100644 index 288579d38..000000000 --- a/examples/multiobjective/mdp/consensus/consensus2_5_2.nm +++ /dev/null @@ -1,140 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 2; // num processes -const int MAX = 5; // num rounds (R) -const int K = 2; // Parameter for coins - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - [coin3_s1_start] s1=2 & r1=3 -> (s1'=3); - [coin4_s1_start] s1=2 & r1=4 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin3_s1_p1] s1=3 & r1=3 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin3_s1_p2] s1=3 & r1=3 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin4_s1_p1] s1=3 & r1=4 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin4_s1_p2] s1=3 & r1=4 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p1, - r1=r2,r2=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start,coin3_s1_start=coin3_s2_start,coin4_s1_start=coin4_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1,coin3_s1_p1=coin3_s2_p1,coin4_s1_p1=coin4_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2,coin3_s1_p2=coin3_s2_p2,coin4_s1_p2=coin4_s2_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - -endmodule - -// could do with renaming -module coin2_error - - c2 : [0..1]; // 1 is the error state - v2 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin2_s1_p1] v2=0 -> (v2'=1); - [coin2_s2_p1] v2=0 -> (v2'=1); - [coin2_s1_p2] v2=0 -> (v2'=2); - [coin2_s2_p2] v2=0 -> (v2'=2); - // later values returned - [coin2_s1_p1] v2=1 -> true; // good behaviour - [coin2_s2_p1] v2=1 -> true; // good behaviour - [coin2_s1_p2] v2=2 -> true; // good behaviour - [coin2_s2_p2] v2=2 -> true; // good behaviour - [coin2_s1_p1] v2=2 -> (c2'=1); // error - [coin2_s2_p1] v2=2 -> (c2'=1); // error - [coin2_s1_p2] v2=1 -> (c2'=1); // error - [coin2_s2_p2] v2=1 -> (c2'=1); // error - -endmodule - -// could do with renaming -module coin3_error - - c3 : [0..1]; // 1 is the error state - v3 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin3_s1_p1] v3=0 -> (v3'=1); - [coin3_s2_p1] v3=0 -> (v3'=1); - [coin3_s1_p2] v3=0 -> (v3'=2); - [coin3_s2_p2] v3=0 -> (v3'=2); - // later values returned - [coin3_s1_p1] v3=1 -> true; // good behaviour - [coin3_s2_p1] v3=1 -> true; // good behaviour - [coin3_s1_p2] v3=2 -> true; // good behaviour - [coin3_s2_p2] v3=2 -> true; // good behaviour - [coin3_s1_p1] v3=2 -> (c3'=1); // error - [coin3_s2_p1] v3=2 -> (c3'=1); // error - [coin3_s1_p2] v3=1 -> (c3'=1); // error - [coin3_s2_p2] v3=1 -> (c3'=1); // error - -endmodule - -// coin 4 is of no use because of number of rounds - -// Labels -label "one_proc_err" = (s1=5 | s2=5); -label "one_coin_ok" = (c1=0 | c2=0 | c3=0); diff --git a/examples/multiobjective/mdp/consensus/consensus2_5_2_numerical.pctl b/examples/multiobjective/mdp/consensus/consensus2_5_2_numerical.pctl deleted file mode 100644 index 3b52e011e..000000000 --- a/examples/multiobjective/mdp/consensus/consensus2_5_2_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], P>=0.9987286134 [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus2_5_2_pareto.pctl b/examples/multiobjective/mdp/consensus/consensus2_5_2_pareto.pctl deleted file mode 100644 index 7cd298d8e..000000000 --- a/examples/multiobjective/mdp/consensus/consensus2_5_2_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], Pmax=? [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus3_3_2.nm b/examples/multiobjective/mdp/consensus/consensus3_3_2.nm deleted file mode 100644 index a7f06fbdf..000000000 --- a/examples/multiobjective/mdp/consensus/consensus3_3_2.nm +++ /dev/null @@ -1,100 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 3; // num processes -const int MAX = 3; // num rounds (R) -const int K = 2; // Parameter for coins - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p3,p3=p1, - r1=r2,r2=r3,r3=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2 ] -endmodule - -module process3 = process1[ s1=s3, - p1=p3,p2=p1,p3=p2, - r1=r3,r2=r1,r3=r2, - coin1_s1_start=coin1_s3_start,coin2_s1_start=coin2_s3_start, - coin1_s1_p1=coin1_s3_p1,coin2_s1_p1=coin2_s3_p1, - coin1_s1_p2=coin1_s3_p2,coin2_s1_p2=coin2_s3_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s3_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - [coin1_s3_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s3_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s3_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s3_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - [coin1_s3_p2] v1=1 -> (c1'=1); // error - -endmodule - -// Labels -label "one_proc_err" = (s1=5 | s2=5 | s3=5); -label "one_coin_ok" = (c1=0); diff --git a/examples/multiobjective/mdp/consensus/consensus3_3_2_numerical.pctl b/examples/multiobjective/mdp/consensus/consensus3_3_2_numerical.pctl deleted file mode 100644 index 4e4f8e3f7..000000000 --- a/examples/multiobjective/mdp/consensus/consensus3_3_2_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], P>=0.7709112445 [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus3_3_2_pareto.pctl b/examples/multiobjective/mdp/consensus/consensus3_3_2_pareto.pctl deleted file mode 100644 index 7cd298d8e..000000000 --- a/examples/multiobjective/mdp/consensus/consensus3_3_2_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], Pmax=? [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus3_4_2.nm b/examples/multiobjective/mdp/consensus/consensus3_4_2.nm deleted file mode 100644 index abfc0ed1e..000000000 --- a/examples/multiobjective/mdp/consensus/consensus3_4_2.nm +++ /dev/null @@ -1,131 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 3; // num processes -const int MAX = 4; // num rounds (R) -const int K = 2; // Parameter for coins - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - [coin3_s1_start] s1=2 & r1=3 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin3_s1_p1] s1=3 & r1=3 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin3_s1_p2] s1=3 & r1=3 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p3,p3=p1, - r1=r2,r2=r3,r3=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start,coin3_s1_start=coin3_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1,coin3_s1_p1=coin3_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2,coin3_s1_p2=coin3_s2_p2 ] -endmodule - -module process3 = process1[ s1=s3, - p1=p3,p2=p1,p3=p2, - r1=r3,r2=r1,r3=r2, - coin1_s1_start=coin1_s3_start,coin2_s1_start=coin2_s3_start,coin3_s1_start=coin3_s3_start, - coin1_s1_p1=coin1_s3_p1,coin2_s1_p1=coin2_s3_p1,coin3_s1_p1=coin3_s3_p1, - coin1_s1_p2=coin1_s3_p2,coin2_s1_p2=coin2_s3_p2,coin3_s1_p2=coin3_s3_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s3_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - [coin1_s3_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s3_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s3_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s3_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - [coin1_s3_p2] v1=1 -> (c1'=1); // error - -endmodule - -module coin2_error - - c2 : [0..1]; // 1 is the error state - v2 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin2_s1_p1] v2=0 -> (v2'=1); - [coin2_s2_p1] v2=0 -> (v2'=1); - [coin2_s3_p1] v2=0 -> (v2'=1); - [coin2_s1_p2] v2=0 -> (v2'=2); - [coin2_s2_p2] v2=0 -> (v2'=2); - [coin2_s3_p2] v2=0 -> (v2'=2); - // later values returned - [coin2_s1_p1] v2=1 -> true; // good behaviour - [coin2_s2_p1] v2=1 -> true; // good behaviour - [coin2_s3_p1] v2=1 -> true; // good behaviour - [coin2_s1_p2] v2=2 -> true; // good behaviour - [coin2_s2_p2] v2=2 -> true; // good behaviour - [coin2_s3_p2] v2=2 -> true; // good behaviour - [coin2_s1_p1] v2=2 -> (c2'=1); // error - [coin2_s2_p1] v2=2 -> (c2'=1); // error - [coin2_s3_p1] v2=2 -> (c2'=1); // error - [coin2_s1_p2] v2=1 -> (c2'=1); // error - [coin2_s2_p2] v2=1 -> (c2'=1); // error - [coin2_s3_p2] v2=1 -> (c2'=1); // error - -endmodule - -// Labels -label "one_proc_err" = (s1=5 | s2=5 | s3=5); -label "one_coin_ok" = (c1=0 | c2=0); diff --git a/examples/multiobjective/mdp/consensus/consensus3_4_2_numerical.pctl b/examples/multiobjective/mdp/consensus/consensus3_4_2_numerical.pctl deleted file mode 100644 index 31768966d..000000000 --- a/examples/multiobjective/mdp/consensus/consensus3_4_2_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], P>=0.9475183421 [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus3_4_2_pareto.pctl b/examples/multiobjective/mdp/consensus/consensus3_4_2_pareto.pctl deleted file mode 100644 index 7cd298d8e..000000000 --- a/examples/multiobjective/mdp/consensus/consensus3_4_2_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], Pmax=? [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus3_5_2.nm b/examples/multiobjective/mdp/consensus/consensus3_5_2.nm deleted file mode 100644 index cc9a7ebbf..000000000 --- a/examples/multiobjective/mdp/consensus/consensus3_5_2.nm +++ /dev/null @@ -1,162 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 3; // num processes -const int MAX = 5; // num rounds (R) -const int K = 2; // Parameter for coins - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - [coin3_s1_start] s1=2 & r1=3 -> (s1'=3); - [coin4_s1_start] s1=2 & r1=4 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin3_s1_p1] s1=3 & r1=3 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin3_s1_p2] s1=3 & r1=3 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin4_s1_p1] s1=3 & r1=4 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin4_s1_p2] s1=3 & r1=4 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p3,p3=p1, - r1=r2,r2=r3,r3=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start,coin3_s1_start=coin3_s2_start,coin4_s1_start=coin4_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1,coin3_s1_p1=coin3_s2_p1,coin4_s1_p1=coin4_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2,coin3_s1_p2=coin3_s2_p2,coin4_s1_p2=coin4_s2_p2 ] -endmodule - -module process3 = process1[ s1=s3, - p1=p3,p2=p1,p3=p2, - r1=r3,r2=r1,r3=r2, - coin1_s1_start=coin1_s3_start,coin2_s1_start=coin2_s3_start,coin3_s1_start=coin3_s3_start,coin4_s1_start=coin4_s3_start, - coin1_s1_p1=coin1_s3_p1,coin2_s1_p1=coin2_s3_p1,coin3_s1_p1=coin3_s3_p1,coin4_s1_p1=coin4_s3_p1, - coin1_s1_p2=coin1_s3_p2,coin2_s1_p2=coin2_s3_p2,coin3_s1_p2=coin3_s3_p2,coin4_s1_p2=coin4_s3_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s3_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - [coin1_s3_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s3_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s3_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s3_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - [coin1_s3_p2] v1=1 -> (c1'=1); // error - -endmodule - -module coin2_error - - c2 : [0..1]; // 1 is the error state - v2 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin2_s1_p1] v2=0 -> (v2'=1); - [coin2_s2_p1] v2=0 -> (v2'=1); - [coin2_s3_p1] v2=0 -> (v2'=1); - [coin2_s1_p2] v2=0 -> (v2'=2); - [coin2_s2_p2] v2=0 -> (v2'=2); - [coin2_s3_p2] v2=0 -> (v2'=2); - // later values returned - [coin2_s1_p1] v2=1 -> true; // good behaviour - [coin2_s2_p1] v2=1 -> true; // good behaviour - [coin2_s3_p1] v2=1 -> true; // good behaviour - [coin2_s1_p2] v2=2 -> true; // good behaviour - [coin2_s2_p2] v2=2 -> true; // good behaviour - [coin2_s3_p2] v2=2 -> true; // good behaviour - [coin2_s1_p1] v2=2 -> (c2'=1); // error - [coin2_s2_p1] v2=2 -> (c2'=1); // error - [coin2_s3_p1] v2=2 -> (c2'=1); // error - [coin2_s1_p2] v2=1 -> (c2'=1); // error - [coin2_s2_p2] v2=1 -> (c2'=1); // error - [coin2_s3_p2] v2=1 -> (c2'=1); // error - -endmodule - -module coin3_error - - c3 : [0..1]; // 1 is the error state - v3 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin3_s1_p1] v3=0 -> (v3'=1); - [coin3_s2_p1] v3=0 -> (v3'=1); - [coin3_s3_p1] v3=0 -> (v3'=1); - [coin3_s1_p2] v3=0 -> (v3'=2); - [coin3_s2_p2] v3=0 -> (v3'=2); - [coin3_s3_p2] v3=0 -> (v3'=2); - // later values returned - [coin3_s1_p1] v3=1 -> true; // good behaviour - [coin3_s2_p1] v3=1 -> true; // good behaviour - [coin3_s3_p1] v3=1 -> true; // good behaviour - [coin3_s1_p2] v3=2 -> true; // good behaviour - [coin3_s2_p2] v3=2 -> true; // good behaviour - [coin3_s3_p2] v3=2 -> true; // good behaviour - [coin3_s1_p1] v3=2 -> (c3'=1); // error - [coin3_s2_p1] v3=2 -> (c3'=1); // error - [coin3_s3_p1] v3=2 -> (c3'=1); // error - [coin3_s1_p2] v3=1 -> (c3'=1); // error - [coin3_s2_p2] v3=1 -> (c3'=1); // error - [coin3_s3_p2] v3=1 -> (c3'=1); // error - -endmodule - -// Labels -label "one_proc_err" = (s1=5 | s2=5 | s3=5); -label "one_coin_ok" = (c1=0 | c2=0 | c3=0); diff --git a/examples/multiobjective/mdp/consensus/consensus3_5_2_numerical.pctl b/examples/multiobjective/mdp/consensus/consensus3_5_2_numerical.pctl deleted file mode 100644 index 6a3113398..000000000 --- a/examples/multiobjective/mdp/consensus/consensus3_5_2_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], P>=0.9879770423 [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/consensus3_5_2_pareto.pctl b/examples/multiobjective/mdp/consensus/consensus3_5_2_pareto.pctl deleted file mode 100644 index 7cd298d8e..000000000 --- a/examples/multiobjective/mdp/consensus/consensus3_5_2_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ -multi(Pmax=? [ F "one_proc_err" ], Pmax=? [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/consensus/origFiles/consensus2_multi3.nm b/examples/multiobjective/mdp/consensus/origFiles/consensus2_multi3.nm deleted file mode 100644 index dbf9dec0f..000000000 --- a/examples/multiobjective/mdp/consensus/origFiles/consensus2_multi3.nm +++ /dev/null @@ -1,87 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 2; // num processes -const int MAX = 3; // num rounds (R) - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p1, - r1=r2,r2=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - -endmodule - -// coins 2 and 3 are of no use as there are not enough rounds afterwards to decide - -// Labels -label "one_proc_err" = (s1=5 | s2=5); -label "one_coin_ok" = (c1=0); diff --git a/examples/multiobjective/mdp/consensus/origFiles/consensus2_multi4.nm b/examples/multiobjective/mdp/consensus/origFiles/consensus2_multi4.nm deleted file mode 100644 index 75f6e8a4d..000000000 --- a/examples/multiobjective/mdp/consensus/origFiles/consensus2_multi4.nm +++ /dev/null @@ -1,113 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 2; // num processes -const int MAX = 4; // num rounds (R) - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - [coin3_s1_start] s1=2 & r1=3 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin3_s1_p1] s1=3 & r1=3 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin3_s1_p2] s1=3 & r1=3 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p1, - r1=r2,r2=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start,coin3_s1_start=coin3_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1,coin3_s1_p1=coin3_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2,coin3_s1_p2=coin3_s2_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - -endmodule - -// could do with renaming -module coin2_error - - c2 : [0..1]; // 1 is the error state - v2 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin2_s1_p1] v2=0 -> (v2'=1); - [coin2_s2_p1] v2=0 -> (v2'=1); - [coin2_s1_p2] v2=0 -> (v2'=2); - [coin2_s2_p2] v2=0 -> (v2'=2); - // later values returned - [coin2_s1_p1] v2=1 -> true; // good behaviour - [coin2_s2_p1] v2=1 -> true; // good behaviour - [coin2_s1_p2] v2=2 -> true; // good behaviour - [coin2_s2_p2] v2=2 -> true; // good behaviour - [coin2_s1_p1] v2=2 -> (c2'=1); // error - [coin2_s2_p1] v2=2 -> (c2'=1); // error - [coin2_s1_p2] v2=1 -> (c2'=1); // error - [coin2_s2_p2] v2=1 -> (c2'=1); // error - -endmodule - -// coin 3 is of no use because of number of rounds - -// Labels -label "one_proc_err" = (s1=5 | s2=5); -label "one_coin_ok" = (c1=0 | c2=0); diff --git a/examples/multiobjective/mdp/consensus/origFiles/consensus2_multi5.nm b/examples/multiobjective/mdp/consensus/origFiles/consensus2_multi5.nm deleted file mode 100644 index a8a7aff6e..000000000 --- a/examples/multiobjective/mdp/consensus/origFiles/consensus2_multi5.nm +++ /dev/null @@ -1,139 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 2; // num processes -const int MAX = 5; // num rounds (R) - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - [coin3_s1_start] s1=2 & r1=3 -> (s1'=3); - [coin4_s1_start] s1=2 & r1=4 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin3_s1_p1] s1=3 & r1=3 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin3_s1_p2] s1=3 & r1=3 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin4_s1_p1] s1=3 & r1=4 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin4_s1_p2] s1=3 & r1=4 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p1, - r1=r2,r2=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start,coin3_s1_start=coin3_s2_start,coin4_s1_start=coin4_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1,coin3_s1_p1=coin3_s2_p1,coin4_s1_p1=coin4_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2,coin3_s1_p2=coin3_s2_p2,coin4_s1_p2=coin4_s2_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - -endmodule - -// could do with renaming -module coin2_error - - c2 : [0..1]; // 1 is the error state - v2 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin2_s1_p1] v2=0 -> (v2'=1); - [coin2_s2_p1] v2=0 -> (v2'=1); - [coin2_s1_p2] v2=0 -> (v2'=2); - [coin2_s2_p2] v2=0 -> (v2'=2); - // later values returned - [coin2_s1_p1] v2=1 -> true; // good behaviour - [coin2_s2_p1] v2=1 -> true; // good behaviour - [coin2_s1_p2] v2=2 -> true; // good behaviour - [coin2_s2_p2] v2=2 -> true; // good behaviour - [coin2_s1_p1] v2=2 -> (c2'=1); // error - [coin2_s2_p1] v2=2 -> (c2'=1); // error - [coin2_s1_p2] v2=1 -> (c2'=1); // error - [coin2_s2_p2] v2=1 -> (c2'=1); // error - -endmodule - -// could do with renaming -module coin3_error - - c3 : [0..1]; // 1 is the error state - v3 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin3_s1_p1] v3=0 -> (v3'=1); - [coin3_s2_p1] v3=0 -> (v3'=1); - [coin3_s1_p2] v3=0 -> (v3'=2); - [coin3_s2_p2] v3=0 -> (v3'=2); - // later values returned - [coin3_s1_p1] v3=1 -> true; // good behaviour - [coin3_s2_p1] v3=1 -> true; // good behaviour - [coin3_s1_p2] v3=2 -> true; // good behaviour - [coin3_s2_p2] v3=2 -> true; // good behaviour - [coin3_s1_p1] v3=2 -> (c3'=1); // error - [coin3_s2_p1] v3=2 -> (c3'=1); // error - [coin3_s1_p2] v3=1 -> (c3'=1); // error - [coin3_s2_p2] v3=1 -> (c3'=1); // error - -endmodule - -// coin 4 is of no use because of number of rounds - -// Labels -label "one_proc_err" = (s1=5 | s2=5); -label "one_coin_ok" = (c1=0 | c2=0 | c3=0); diff --git a/examples/multiobjective/mdp/consensus/origFiles/consensus3_multi3.nm b/examples/multiobjective/mdp/consensus/origFiles/consensus3_multi3.nm deleted file mode 100644 index 4b1e95373..000000000 --- a/examples/multiobjective/mdp/consensus/origFiles/consensus3_multi3.nm +++ /dev/null @@ -1,99 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 3; // num processes -const int MAX = 3; // num rounds (R) - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p3,p3=p1, - r1=r2,r2=r3,r3=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2 ] -endmodule - -module process3 = process1[ s1=s3, - p1=p3,p2=p1,p3=p2, - r1=r3,r2=r1,r3=r2, - coin1_s1_start=coin1_s3_start,coin2_s1_start=coin2_s3_start, - coin1_s1_p1=coin1_s3_p1,coin2_s1_p1=coin2_s3_p1, - coin1_s1_p2=coin1_s3_p2,coin2_s1_p2=coin2_s3_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s3_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - [coin1_s3_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s3_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s3_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s3_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - [coin1_s3_p2] v1=1 -> (c1'=1); // error - -endmodule - -// Labels -label "one_proc_err" = (s1=5 | s2=5 | s3=5); -label "one_coin_ok" = (c1=0); diff --git a/examples/multiobjective/mdp/consensus/origFiles/consensus3_multi4.nm b/examples/multiobjective/mdp/consensus/origFiles/consensus3_multi4.nm deleted file mode 100644 index 052114d1d..000000000 --- a/examples/multiobjective/mdp/consensus/origFiles/consensus3_multi4.nm +++ /dev/null @@ -1,130 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 3; // num processes -const int MAX = 4; // num rounds (R) - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - [coin3_s1_start] s1=2 & r1=3 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin3_s1_p1] s1=3 & r1=3 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin3_s1_p2] s1=3 & r1=3 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p3,p3=p1, - r1=r2,r2=r3,r3=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start,coin3_s1_start=coin3_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1,coin3_s1_p1=coin3_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2,coin3_s1_p2=coin3_s2_p2 ] -endmodule - -module process3 = process1[ s1=s3, - p1=p3,p2=p1,p3=p2, - r1=r3,r2=r1,r3=r2, - coin1_s1_start=coin1_s3_start,coin2_s1_start=coin2_s3_start,coin3_s1_start=coin3_s3_start, - coin1_s1_p1=coin1_s3_p1,coin2_s1_p1=coin2_s3_p1,coin3_s1_p1=coin3_s3_p1, - coin1_s1_p2=coin1_s3_p2,coin2_s1_p2=coin2_s3_p2,coin3_s1_p2=coin3_s3_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s3_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - [coin1_s3_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s3_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s3_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s3_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - [coin1_s3_p2] v1=1 -> (c1'=1); // error - -endmodule - -module coin2_error - - c2 : [0..1]; // 1 is the error state - v2 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin2_s1_p1] v2=0 -> (v2'=1); - [coin2_s2_p1] v2=0 -> (v2'=1); - [coin2_s3_p1] v2=0 -> (v2'=1); - [coin2_s1_p2] v2=0 -> (v2'=2); - [coin2_s2_p2] v2=0 -> (v2'=2); - [coin2_s3_p2] v2=0 -> (v2'=2); - // later values returned - [coin2_s1_p1] v2=1 -> true; // good behaviour - [coin2_s2_p1] v2=1 -> true; // good behaviour - [coin2_s3_p1] v2=1 -> true; // good behaviour - [coin2_s1_p2] v2=2 -> true; // good behaviour - [coin2_s2_p2] v2=2 -> true; // good behaviour - [coin2_s3_p2] v2=2 -> true; // good behaviour - [coin2_s1_p1] v2=2 -> (c2'=1); // error - [coin2_s2_p1] v2=2 -> (c2'=1); // error - [coin2_s3_p1] v2=2 -> (c2'=1); // error - [coin2_s1_p2] v2=1 -> (c2'=1); // error - [coin2_s2_p2] v2=1 -> (c2'=1); // error - [coin2_s3_p2] v2=1 -> (c2'=1); // error - -endmodule - -// Labels -label "one_proc_err" = (s1=5 | s2=5 | s3=5); -label "one_coin_ok" = (c1=0 | c2=0); diff --git a/examples/multiobjective/mdp/consensus/origFiles/consensus3_multi5.nm b/examples/multiobjective/mdp/consensus/origFiles/consensus3_multi5.nm deleted file mode 100644 index 8097dc437..000000000 --- a/examples/multiobjective/mdp/consensus/origFiles/consensus3_multi5.nm +++ /dev/null @@ -1,161 +0,0 @@ -// model of randomised consensus - -mdp - -const int N = 3; // num processes -const int MAX = 5; // num rounds (R) - -// need to turn these into local copies later so the reading phase is complete? -formula leaders_agree1 = (p1=1 | r1 (p1'=1) & (r1'=1); - [] s1=0 & r1=0 -> (p1'=2) & (r1'=1); - - // read registers (currently does nothing because read vs from other processes - [] s1=0 & r1>0 & r1<=MAX -> (s1'=1); - // maxke a decision - [] s1=1 & decide1 -> (s1'=4) & (p1'=1); - [] s1=1 & decide2 -> (s1'=4) & (p1'=2); - [] s1=1 & r1 (s1'=0) & (p1'=1) & (r1'=r1+1); - [] s1=1 & r1 (s1'=0) & (p1'=2) & (r1'=r1+1); - [] s1=1 & r1 (s1'=2) & (p1'=0); - [] s1=1 & r1=MAX & !(decide1 | decide2) -> (s1'=5); // run out of rounds so error - // enter the coin procotol for the current round - [coin1_s1_start] s1=2 & r1=1 -> (s1'=3); - [coin2_s1_start] s1=2 & r1=2 -> (s1'=3); - [coin3_s1_start] s1=2 & r1=3 -> (s1'=3); - [coin4_s1_start] s1=2 & r1=4 -> (s1'=3); - // get response from the coin protocol - [coin1_s1_p1] s1=3 & r1=1 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin1_s1_p2] s1=3 & r1=1 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin2_s1_p1] s1=3 & r1=2 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin2_s1_p2] s1=3 & r1=2 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin3_s1_p1] s1=3 & r1=3 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin3_s1_p2] s1=3 & r1=3 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - [coin4_s1_p1] s1=3 & r1=4 -> (s1'=0) & (p1'=1) & (r1'=r1+1); - [coin4_s1_p2] s1=3 & r1=4 -> (s1'=0) & (p1'=2) & (r1'=r1+1); - // done so loop - [done] s1>=4 -> true; - -endmodule - -module process2 = process1[ s1=s2, - p1=p2,p2=p3,p3=p1, - r1=r2,r2=r3,r3=r1, - coin1_s1_start=coin1_s2_start,coin2_s1_start=coin2_s2_start,coin3_s1_start=coin3_s2_start,coin4_s1_start=coin4_s2_start, - coin1_s1_p1=coin1_s2_p1,coin2_s1_p1=coin2_s2_p1,coin3_s1_p1=coin3_s2_p1,coin4_s1_p1=coin4_s2_p1, - coin1_s1_p2=coin1_s2_p2,coin2_s1_p2=coin2_s2_p2,coin3_s1_p2=coin3_s2_p2,coin4_s1_p2=coin4_s2_p2 ] -endmodule - -module process3 = process1[ s1=s3, - p1=p3,p2=p1,p3=p2, - r1=r3,r2=r1,r3=r2, - coin1_s1_start=coin1_s3_start,coin2_s1_start=coin2_s3_start,coin3_s1_start=coin3_s3_start,coin4_s1_start=coin4_s3_start, - coin1_s1_p1=coin1_s3_p1,coin2_s1_p1=coin2_s3_p1,coin3_s1_p1=coin3_s3_p1,coin4_s1_p1=coin4_s3_p1, - coin1_s1_p2=coin1_s3_p2,coin2_s1_p2=coin2_s3_p2,coin3_s1_p2=coin3_s3_p2,coin4_s1_p2=coin4_s3_p2 ] -endmodule - -module coin1_error - - c1 : [0..1]; // 1 is the error state - v1 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin1_s1_p1] v1=0 -> (v1'=1); - [coin1_s2_p1] v1=0 -> (v1'=1); - [coin1_s3_p1] v1=0 -> (v1'=1); - [coin1_s1_p2] v1=0 -> (v1'=2); - [coin1_s2_p2] v1=0 -> (v1'=2); - [coin1_s3_p2] v1=0 -> (v1'=2); - // later values returned - [coin1_s1_p1] v1=1 -> true; // good behaviour - [coin1_s2_p1] v1=1 -> true; // good behaviour - [coin1_s3_p1] v1=1 -> true; // good behaviour - [coin1_s1_p2] v1=2 -> true; // good behaviour - [coin1_s2_p2] v1=2 -> true; // good behaviour - [coin1_s3_p2] v1=2 -> true; // good behaviour - [coin1_s1_p1] v1=2 -> (c1'=1); // error - [coin1_s2_p1] v1=2 -> (c1'=1); // error - [coin1_s3_p1] v1=2 -> (c1'=1); // error - [coin1_s1_p2] v1=1 -> (c1'=1); // error - [coin1_s2_p2] v1=1 -> (c1'=1); // error - [coin1_s3_p2] v1=1 -> (c1'=1); // error - -endmodule - -module coin2_error - - c2 : [0..1]; // 1 is the error state - v2 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin2_s1_p1] v2=0 -> (v2'=1); - [coin2_s2_p1] v2=0 -> (v2'=1); - [coin2_s3_p1] v2=0 -> (v2'=1); - [coin2_s1_p2] v2=0 -> (v2'=2); - [coin2_s2_p2] v2=0 -> (v2'=2); - [coin2_s3_p2] v2=0 -> (v2'=2); - // later values returned - [coin2_s1_p1] v2=1 -> true; // good behaviour - [coin2_s2_p1] v2=1 -> true; // good behaviour - [coin2_s3_p1] v2=1 -> true; // good behaviour - [coin2_s1_p2] v2=2 -> true; // good behaviour - [coin2_s2_p2] v2=2 -> true; // good behaviour - [coin2_s3_p2] v2=2 -> true; // good behaviour - [coin2_s1_p1] v2=2 -> (c2'=1); // error - [coin2_s2_p1] v2=2 -> (c2'=1); // error - [coin2_s3_p1] v2=2 -> (c2'=1); // error - [coin2_s1_p2] v2=1 -> (c2'=1); // error - [coin2_s2_p2] v2=1 -> (c2'=1); // error - [coin2_s3_p2] v2=1 -> (c2'=1); // error - -endmodule - -module coin3_error - - c3 : [0..1]; // 1 is the error state - v3 : [0..2]; // value of the coin returned the first time - - // first returned value (any processes) - [coin3_s1_p1] v3=0 -> (v3'=1); - [coin3_s2_p1] v3=0 -> (v3'=1); - [coin3_s3_p1] v3=0 -> (v3'=1); - [coin3_s1_p2] v3=0 -> (v3'=2); - [coin3_s2_p2] v3=0 -> (v3'=2); - [coin3_s3_p2] v3=0 -> (v3'=2); - // later values returned - [coin3_s1_p1] v3=1 -> true; // good behaviour - [coin3_s2_p1] v3=1 -> true; // good behaviour - [coin3_s3_p1] v3=1 -> true; // good behaviour - [coin3_s1_p2] v3=2 -> true; // good behaviour - [coin3_s2_p2] v3=2 -> true; // good behaviour - [coin3_s3_p2] v3=2 -> true; // good behaviour - [coin3_s1_p1] v3=2 -> (c3'=1); // error - [coin3_s2_p1] v3=2 -> (c3'=1); // error - [coin3_s3_p1] v3=2 -> (c3'=1); // error - [coin3_s1_p2] v3=1 -> (c3'=1); // error - [coin3_s2_p2] v3=1 -> (c3'=1); // error - [coin3_s3_p2] v3=1 -> (c3'=1); // error - -endmodule - -// Labels -label "one_proc_err" = (s1=5 | s2=5 | s3=5); -label "one_coin_ok" = (c1=0 | c2=0 | c3=0); diff --git a/examples/multiobjective/mdp/consensus/origFiles/consensus_multi.pctl b/examples/multiobjective/mdp/consensus/origFiles/consensus_multi.pctl deleted file mode 100644 index 7a5f12b31..000000000 --- a/examples/multiobjective/mdp/consensus/origFiles/consensus_multi.pctl +++ /dev/null @@ -1,27 +0,0 @@ -// Parameter K for coins -const int K; - -// Max probability of component (coins) violating assumption property (checked separately) -const double p_coin_fail = -N=2 ? ( - K=2 ? 0.10833260973166493 : - K=12 ? 0.04164301267240658 : - K=20 ? 0.01249126244810821 : -0 ) : -N=3 ? ( - K=2 ? 0.22908875545788154 : - K=4 ? 0.12450138796380239 : - K=8 ? 0.06248479880890645 : - K=12 ? 0.04164365757451993 : - K=16 ? 0.031218839562495382 : - K=20 ? 0.024960596483605935 : -0 ) : 0; - -// Probability bound for assumption, derived from above -const double p_one_coin_ok = 1 - pow(p_coin_fail, MAX-2); - -// Assume-guarantee check via multi-objective (using ASYM rule) -"num_ag": multi(Pmax=? [ F "one_proc_err" ], P>=p_one_coin_ok [ G "one_coin_ok" ]) - -// Pareto query for assume-guarantee check -"pareto": multi(Pmax=? [ F "one_proc_err" ], Pmax=? [ G "one_coin_ok" ]) diff --git a/examples/multiobjective/mdp/dpm/dpm100.nm b/examples/multiobjective/mdp/dpm/dpm100.nm deleted file mode 100644 index 0862cfb73..000000000 --- a/examples/multiobjective/mdp/dpm/dpm100.nm +++ /dev/null @@ -1,160 +0,0 @@ -// power manager example -mdp - -const int QMAX =2; // max queue size - -// to model the pm making a choice and then a move being made we need -// two clock ticks for each transition -// first the pm decides tick1 and then the system moves tick2 - -module timer - - c : [0..1]; - - [tick1] c=0 -> (c'=1); - [tick2] c=1 -> (c'=0); - -endmodule - -//------------------------------------------------------------------------- - -// POWER MANAGER -module PM - - pm : [0..4] init 4; - // 0 - go to active - // 1 - go to idle - // 2 - go to idlelp - // 3 - go to stby - // 4 - go to sleep - - [tick1] true -> (pm'=0); - [tick1] true -> (pm'=1); - [tick1] true -> (pm'=2); - [tick1] true -> (pm'=3); - [tick1] true -> (pm'=4); - -endmodule - - -//------------------------------------------------------------------------- - -// SERVICE REQUESTER -module SR - - sr : [0..1] init 0; - // 0 idle - // 1 1req - - [tick2] sr=0 -> 0.898: (sr'=0) + 0.102: (sr'=1); - [tick2] sr=1 -> 0.454: (sr'=0) + 0.546: (sr'=1); - -endmodule - -//------------------------------------------------------------------------- - -// SERVICE PROVIDER - -module SP - - sp : [0..10] init 9; - // 0 active - // 1 idle - // 2 active_idlelp - // 3 idlelp - // 4 idlelp_active - // 5 active_stby - // 6 stby - // 7 stby_active - // 8 active_sleep - // 9 sleep - // 10 sleep_active - - // states where PM has no control (transient states) - [tick2] sp=2 -> 0.75 : (sp'=2) + 0.25 : (sp'=3); // active_idlelp - [tick2] sp=4 -> 0.25 : (sp'=0) + 0.75 : (sp'=4); // idlelp_active - [tick2] sp=5 -> 0.995 : (sp'=5) + 0.005 : (sp'=6); // active_stby - [tick2] sp=7 -> 0.005 : (sp'=0) + 0.995 : (sp'=7); // stby_active - [tick2] sp=8 -> 0.9983 : (sp'=8) + 0.0017 : (sp'=9); // active_sleep - [tick2] sp=10 -> 0.0017 : (sp'=0) + 0.9983 : (sp'=10); // sleep_active - - // states where PM has control - // goto_active - [tick2] sp=0 & pm=0 -> (sp'=0); // active - [tick2] sp=1 & pm=0 -> (sp'=0); // idle - [tick2] sp=3 & pm=0 -> (sp'=4); // idlelp - [tick2] sp=6 & pm=0 -> (sp'=7); // stby - [tick2] sp=9 & pm=0 -> (sp'=10); // sleep - // goto_idle - [tick2] sp=0 & pm=1 -> (sp'=1); // active - [tick2] sp=1 & pm=1 -> (sp'=1); // idle - [tick2] sp=3 & pm=1 -> (sp'=3); // idlelp - [tick2] sp=6 & pm=1 -> (sp'=6); // stby - [tick2] sp=9 & pm=1 -> (sp'=9); // sleep - // goto_idlelp - [tick2] sp=0 & pm=2 -> (sp'=2); // active - [tick2] sp=1 & pm=2 -> (sp'=2); // idle - [tick2] sp=3 & pm=2 -> (sp'=3); // idlelp - [tick2] sp=6 & pm=2 -> (sp'=6); // stby - [tick2] sp=9 & pm=2 -> (sp'=9); // sleep - // goto_stby - [tick2] sp=0 & pm=3 -> (sp'=5); // active - [tick2] sp=1 & pm=3 -> (sp'=5); // idle - [tick2] sp=3 & pm=3 -> (sp'=5); // idlelp - [tick2] sp=6 & pm=3 -> (sp'=6); // stby - [tick2] sp=9 & pm=3 -> (sp'=9); // sleep - // goto_sleep - [tick2] sp=0 & pm=4 -> (sp'=8); // active - [tick2] sp=1 & pm=4 -> (sp'=8); // idle - [tick2] sp=3 & pm=4 -> (sp'=8); // idlelp - [tick2] sp=6 & pm=4 -> (sp'=8); // stby - [tick2] sp=9 & pm=4 -> (sp'=9); // sleep - -endmodule - - -//------------------------------------------------------------------------- - -// SQ -module SQ - - q : [0..QMAX] init 0; - - // serve if busy - [tick2] sr=0 & sp=0 -> (q'=max(q-1,0)); - [tick2] sr=1 & sp=0 -> (q'=q); - - // otherwise do nothing - [tick2] sr=0 & sp>0 -> (q'=q); - [tick2] sr=1 & sp>0 -> (q'=min(q+1,QMAX)); - -endmodule - -//------------------------------------------------------------------------- -//rewards "time" -// [tick2] bat=1 : 1; -//endrewards - -rewards "power" - [tick2] sp=0 & c=1 : 2.5; - [tick2] sp=1 & c=1 : 1.5; - [tick2] sp=2 & c=1 : 2.5; - [tick2] sp=3 & c=1 : 0.8; - [tick2] sp=4 & c=1 : 2.5; - [tick2] sp=5 & c=1 : 2.5; - [tick2] sp=6 & c=1 : 0.3; - [tick2] sp=7 & c=1 : 2.5; - [tick2] sp=8 & c=1 : 2.5; - [tick2] sp=9 & c=1 : 0.1; - [tick2] sp=10 & c=1 : 2.5; -endrewards - -// is an instantaneous property but I suppose we can look at average size -// i.e. divide by the expected number of time steps -rewards "queue" - [tick2] c=1 : q; -endrewards - -rewards "lost" - [tick2] sr=1 & sp>0 & q=2 : 1; -endrewards diff --git a/examples/multiobjective/mdp/dpm/dpm100_numerical.pctl b/examples/multiobjective/mdp/dpm/dpm100_numerical.pctl deleted file mode 100644 index 97de9f0e1..000000000 --- a/examples/multiobjective/mdp/dpm/dpm100_numerical.pctl +++ /dev/null @@ -1,3 +0,0 @@ - multi(R{"power"}min=? [ C<=100 ], R{"queue"}<=70 [ C<=100 ]) -// Note: The property file from http://www.prismmodelchecker.org/files/atva12mo/ does not provide a threshold for the second objective. -// We pick a threshold that intersects the pareto curve. \ No newline at end of file diff --git a/examples/multiobjective/mdp/dpm/dpm100_pareto.pctl b/examples/multiobjective/mdp/dpm/dpm100_pareto.pctl deleted file mode 100644 index 19e3cd685..000000000 --- a/examples/multiobjective/mdp/dpm/dpm100_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(R{"power"}min=? [ C<=100 ], R{"queue"}min=? [ C<=100 ]) diff --git a/examples/multiobjective/mdp/dpm/dpm200.nm b/examples/multiobjective/mdp/dpm/dpm200.nm deleted file mode 100644 index 0862cfb73..000000000 --- a/examples/multiobjective/mdp/dpm/dpm200.nm +++ /dev/null @@ -1,160 +0,0 @@ -// power manager example -mdp - -const int QMAX =2; // max queue size - -// to model the pm making a choice and then a move being made we need -// two clock ticks for each transition -// first the pm decides tick1 and then the system moves tick2 - -module timer - - c : [0..1]; - - [tick1] c=0 -> (c'=1); - [tick2] c=1 -> (c'=0); - -endmodule - -//------------------------------------------------------------------------- - -// POWER MANAGER -module PM - - pm : [0..4] init 4; - // 0 - go to active - // 1 - go to idle - // 2 - go to idlelp - // 3 - go to stby - // 4 - go to sleep - - [tick1] true -> (pm'=0); - [tick1] true -> (pm'=1); - [tick1] true -> (pm'=2); - [tick1] true -> (pm'=3); - [tick1] true -> (pm'=4); - -endmodule - - -//------------------------------------------------------------------------- - -// SERVICE REQUESTER -module SR - - sr : [0..1] init 0; - // 0 idle - // 1 1req - - [tick2] sr=0 -> 0.898: (sr'=0) + 0.102: (sr'=1); - [tick2] sr=1 -> 0.454: (sr'=0) + 0.546: (sr'=1); - -endmodule - -//------------------------------------------------------------------------- - -// SERVICE PROVIDER - -module SP - - sp : [0..10] init 9; - // 0 active - // 1 idle - // 2 active_idlelp - // 3 idlelp - // 4 idlelp_active - // 5 active_stby - // 6 stby - // 7 stby_active - // 8 active_sleep - // 9 sleep - // 10 sleep_active - - // states where PM has no control (transient states) - [tick2] sp=2 -> 0.75 : (sp'=2) + 0.25 : (sp'=3); // active_idlelp - [tick2] sp=4 -> 0.25 : (sp'=0) + 0.75 : (sp'=4); // idlelp_active - [tick2] sp=5 -> 0.995 : (sp'=5) + 0.005 : (sp'=6); // active_stby - [tick2] sp=7 -> 0.005 : (sp'=0) + 0.995 : (sp'=7); // stby_active - [tick2] sp=8 -> 0.9983 : (sp'=8) + 0.0017 : (sp'=9); // active_sleep - [tick2] sp=10 -> 0.0017 : (sp'=0) + 0.9983 : (sp'=10); // sleep_active - - // states where PM has control - // goto_active - [tick2] sp=0 & pm=0 -> (sp'=0); // active - [tick2] sp=1 & pm=0 -> (sp'=0); // idle - [tick2] sp=3 & pm=0 -> (sp'=4); // idlelp - [tick2] sp=6 & pm=0 -> (sp'=7); // stby - [tick2] sp=9 & pm=0 -> (sp'=10); // sleep - // goto_idle - [tick2] sp=0 & pm=1 -> (sp'=1); // active - [tick2] sp=1 & pm=1 -> (sp'=1); // idle - [tick2] sp=3 & pm=1 -> (sp'=3); // idlelp - [tick2] sp=6 & pm=1 -> (sp'=6); // stby - [tick2] sp=9 & pm=1 -> (sp'=9); // sleep - // goto_idlelp - [tick2] sp=0 & pm=2 -> (sp'=2); // active - [tick2] sp=1 & pm=2 -> (sp'=2); // idle - [tick2] sp=3 & pm=2 -> (sp'=3); // idlelp - [tick2] sp=6 & pm=2 -> (sp'=6); // stby - [tick2] sp=9 & pm=2 -> (sp'=9); // sleep - // goto_stby - [tick2] sp=0 & pm=3 -> (sp'=5); // active - [tick2] sp=1 & pm=3 -> (sp'=5); // idle - [tick2] sp=3 & pm=3 -> (sp'=5); // idlelp - [tick2] sp=6 & pm=3 -> (sp'=6); // stby - [tick2] sp=9 & pm=3 -> (sp'=9); // sleep - // goto_sleep - [tick2] sp=0 & pm=4 -> (sp'=8); // active - [tick2] sp=1 & pm=4 -> (sp'=8); // idle - [tick2] sp=3 & pm=4 -> (sp'=8); // idlelp - [tick2] sp=6 & pm=4 -> (sp'=8); // stby - [tick2] sp=9 & pm=4 -> (sp'=9); // sleep - -endmodule - - -//------------------------------------------------------------------------- - -// SQ -module SQ - - q : [0..QMAX] init 0; - - // serve if busy - [tick2] sr=0 & sp=0 -> (q'=max(q-1,0)); - [tick2] sr=1 & sp=0 -> (q'=q); - - // otherwise do nothing - [tick2] sr=0 & sp>0 -> (q'=q); - [tick2] sr=1 & sp>0 -> (q'=min(q+1,QMAX)); - -endmodule - -//------------------------------------------------------------------------- -//rewards "time" -// [tick2] bat=1 : 1; -//endrewards - -rewards "power" - [tick2] sp=0 & c=1 : 2.5; - [tick2] sp=1 & c=1 : 1.5; - [tick2] sp=2 & c=1 : 2.5; - [tick2] sp=3 & c=1 : 0.8; - [tick2] sp=4 & c=1 : 2.5; - [tick2] sp=5 & c=1 : 2.5; - [tick2] sp=6 & c=1 : 0.3; - [tick2] sp=7 & c=1 : 2.5; - [tick2] sp=8 & c=1 : 2.5; - [tick2] sp=9 & c=1 : 0.1; - [tick2] sp=10 & c=1 : 2.5; -endrewards - -// is an instantaneous property but I suppose we can look at average size -// i.e. divide by the expected number of time steps -rewards "queue" - [tick2] c=1 : q; -endrewards - -rewards "lost" - [tick2] sr=1 & sp>0 & q=2 : 1; -endrewards diff --git a/examples/multiobjective/mdp/dpm/dpm200_numerical.pctl b/examples/multiobjective/mdp/dpm/dpm200_numerical.pctl deleted file mode 100644 index 916821715..000000000 --- a/examples/multiobjective/mdp/dpm/dpm200_numerical.pctl +++ /dev/null @@ -1,3 +0,0 @@ - multi(R{"power"}min=? [ C<=200 ], R{"queue"}<=170 [ C<=200 ]) -// Note: The property file from http://www.prismmodelchecker.org/files/atva12mo/ does not provide a threshold for the second objective. -// We pick a threshold that intersects the pareto curve. \ No newline at end of file diff --git a/examples/multiobjective/mdp/dpm/dpm200_pareto.pctl b/examples/multiobjective/mdp/dpm/dpm200_pareto.pctl deleted file mode 100644 index f03284f83..000000000 --- a/examples/multiobjective/mdp/dpm/dpm200_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(R{"power"}min=? [ C<=200 ], R{"queue"}min=? [ C<=200 ]) diff --git a/examples/multiobjective/mdp/dpm/dpm300.nm b/examples/multiobjective/mdp/dpm/dpm300.nm deleted file mode 100644 index 3ac45e621..000000000 --- a/examples/multiobjective/mdp/dpm/dpm300.nm +++ /dev/null @@ -1,160 +0,0 @@ -// power manager example -mdp - -const int QMAX=2; // max queue size - -// to model the pm making a choice and then a move being made we need -// two clock ticks for each transition -// first the pm decides tick1 and then the system moves tick2 - -module timer - - c : [0..1]; - - [tick1] c=0 -> (c'=1); - [tick2] c=1 -> (c'=0); - -endmodule - -//------------------------------------------------------------------------- - -// POWER MANAGER -module PM - - pm : [0..4] init 4; - // 0 - go to active - // 1 - go to idle - // 2 - go to idlelp - // 3 - go to stby - // 4 - go to sleep - - [tick1] true -> (pm'=0); - [tick1] true -> (pm'=1); - [tick1] true -> (pm'=2); - [tick1] true -> (pm'=3); - [tick1] true -> (pm'=4); - -endmodule - - -//------------------------------------------------------------------------- - -// SERVICE REQUESTER -module SR - - sr : [0..1] init 0; - // 0 idle - // 1 1req - - [tick2] sr=0 -> 0.898: (sr'=0) + 0.102: (sr'=1); - [tick2] sr=1 -> 0.454: (sr'=0) + 0.546: (sr'=1); - -endmodule - -//------------------------------------------------------------------------- - -// SERVICE PROVIDER - -module SP - - sp : [0..10] init 9; - // 0 active - // 1 idle - // 2 active_idlelp - // 3 idlelp - // 4 idlelp_active - // 5 active_stby - // 6 stby - // 7 stby_active - // 8 active_sleep - // 9 sleep - // 10 sleep_active - - // states where PM has no control (transient states) - [tick2] sp=2 -> 0.75 : (sp'=2) + 0.25 : (sp'=3); // active_idlelp - [tick2] sp=4 -> 0.25 : (sp'=0) + 0.75 : (sp'=4); // idlelp_active - [tick2] sp=5 -> 0.995 : (sp'=5) + 0.005 : (sp'=6); // active_stby - [tick2] sp=7 -> 0.005 : (sp'=0) + 0.995 : (sp'=7); // stby_active - [tick2] sp=8 -> 0.9983 : (sp'=8) + 0.0017 : (sp'=9); // active_sleep - [tick2] sp=10 -> 0.0017 : (sp'=0) + 0.9983 : (sp'=10); // sleep_active - - // states where PM has control - // goto_active - [tick2] sp=0 & pm=0 -> (sp'=0); // active - [tick2] sp=1 & pm=0 -> (sp'=0); // idle - [tick2] sp=3 & pm=0 -> (sp'=4); // idlelp - [tick2] sp=6 & pm=0 -> (sp'=7); // stby - [tick2] sp=9 & pm=0 -> (sp'=10); // sleep - // goto_idle - [tick2] sp=0 & pm=1 -> (sp'=1); // active - [tick2] sp=1 & pm=1 -> (sp'=1); // idle - [tick2] sp=3 & pm=1 -> (sp'=3); // idlelp - [tick2] sp=6 & pm=1 -> (sp'=6); // stby - [tick2] sp=9 & pm=1 -> (sp'=9); // sleep - // goto_idlelp - [tick2] sp=0 & pm=2 -> (sp'=2); // active - [tick2] sp=1 & pm=2 -> (sp'=2); // idle - [tick2] sp=3 & pm=2 -> (sp'=3); // idlelp - [tick2] sp=6 & pm=2 -> (sp'=6); // stby - [tick2] sp=9 & pm=2 -> (sp'=9); // sleep - // goto_stby - [tick2] sp=0 & pm=3 -> (sp'=5); // active - [tick2] sp=1 & pm=3 -> (sp'=5); // idle - [tick2] sp=3 & pm=3 -> (sp'=5); // idlelp - [tick2] sp=6 & pm=3 -> (sp'=6); // stby - [tick2] sp=9 & pm=3 -> (sp'=9); // sleep - // goto_sleep - [tick2] sp=0 & pm=4 -> (sp'=8); // active - [tick2] sp=1 & pm=4 -> (sp'=8); // idle - [tick2] sp=3 & pm=4 -> (sp'=8); // idlelp - [tick2] sp=6 & pm=4 -> (sp'=8); // stby - [tick2] sp=9 & pm=4 -> (sp'=9); // sleep - -endmodule - - -//------------------------------------------------------------------------- - -// SQ -module SQ - - q : [0..QMAX] init 0; - - // serve if busy - [tick2] sr=0 & sp=0 -> (q'=max(q-1,0)); - [tick2] sr=1 & sp=0 -> (q'=q); - - // otherwise do nothing - [tick2] sr=0 & sp>0 -> (q'=q); - [tick2] sr=1 & sp>0 -> (q'=min(q+1,QMAX)); - -endmodule - -//------------------------------------------------------------------------- -//rewards "time" -// [tick2] bat=1 : 1; -//endrewards - -rewards "power" - [tick2] sp=0 & c=1 : 2.5; - [tick2] sp=1 & c=1 : 1.5; - [tick2] sp=2 & c=1 : 2.5; - [tick2] sp=3 & c=1 : 0.8; - [tick2] sp=4 & c=1 : 2.5; - [tick2] sp=5 & c=1 : 2.5; - [tick2] sp=6 & c=1 : 0.3; - [tick2] sp=7 & c=1 : 2.5; - [tick2] sp=8 & c=1 : 2.5; - [tick2] sp=9 & c=1 : 0.1; - [tick2] sp=10 & c=1 : 2.5; -endrewards - -// is an instantaneous property but I suppose we can look at average size -// i.e. divide by the expected number of time steps -rewards "queue" - [tick2] c=1 : q; -endrewards - -rewards "lost" - [tick2] sr=1 & sp>0 & q=2 : 1; -endrewards diff --git a/examples/multiobjective/mdp/dpm/dpm300_numerical.pctl b/examples/multiobjective/mdp/dpm/dpm300_numerical.pctl deleted file mode 100644 index a75851347..000000000 --- a/examples/multiobjective/mdp/dpm/dpm300_numerical.pctl +++ /dev/null @@ -1,3 +0,0 @@ - multi(R{"power"}min=? [ C<=300 ], R{"queue"}<=270 [ C<=300 ]) -// Note: The property file from http://www.prismmodelchecker.org/files/atva12mo/ does not provide a threshold for the second objective. -// We pick a threshold that intersects the pareto curve. \ No newline at end of file diff --git a/examples/multiobjective/mdp/dpm/dpm300_pareto.pctl b/examples/multiobjective/mdp/dpm/dpm300_pareto.pctl deleted file mode 100644 index bde0f5eb0..000000000 --- a/examples/multiobjective/mdp/dpm/dpm300_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(R{"power"}min=? [ C<=300 ], R{"queue"}min=? [ C<=300 ]) diff --git a/examples/multiobjective/mdp/dpm/origFiles/power-timed.nm b/examples/multiobjective/mdp/dpm/origFiles/power-timed.nm deleted file mode 100644 index 561742815..000000000 --- a/examples/multiobjective/mdp/dpm/origFiles/power-timed.nm +++ /dev/null @@ -1,160 +0,0 @@ -// power manager example -mdp - -const int QMAX; // max queue size - -// to model the pm making a choice and then a move being made we need -// two clock ticks for each transition -// first the pm decides tick1 and then the system moves tick2 - -module timer - - c : [0..1]; - - [tick1] c=0 -> (c'=1); - [tick2] c=1 -> (c'=0); - -endmodule - -//------------------------------------------------------------------------- - -// POWER MANAGER -module PM - - pm : [0..4] init 4; - // 0 - go to active - // 1 - go to idle - // 2 - go to idlelp - // 3 - go to stby - // 4 - go to sleep - - [tick1] true -> (pm'=0); - [tick1] true -> (pm'=1); - [tick1] true -> (pm'=2); - [tick1] true -> (pm'=3); - [tick1] true -> (pm'=4); - -endmodule - - -//------------------------------------------------------------------------- - -// SERVICE REQUESTER -module SR - - sr : [0..1] init 0; - // 0 idle - // 1 1req - - [tick2] sr=0 -> 0.898: (sr'=0) + 0.102: (sr'=1); - [tick2] sr=1 -> 0.454: (sr'=0) + 0.546: (sr'=1); - -endmodule - -//------------------------------------------------------------------------- - -// SERVICE PROVIDER - -module SP - - sp : [0..10] init 9; - // 0 active - // 1 idle - // 2 active_idlelp - // 3 idlelp - // 4 idlelp_active - // 5 active_stby - // 6 stby - // 7 stby_active - // 8 active_sleep - // 9 sleep - // 10 sleep_active - - // states where PM has no control (transient states) - [tick2] sp=2 -> 0.75 : (sp'=2) + 0.25 : (sp'=3); // active_idlelp - [tick2] sp=4 -> 0.25 : (sp'=0) + 0.75 : (sp'=4); // idlelp_active - [tick2] sp=5 -> 0.995 : (sp'=5) + 0.005 : (sp'=6); // active_stby - [tick2] sp=7 -> 0.005 : (sp'=0) + 0.995 : (sp'=7); // stby_active - [tick2] sp=8 -> 0.9983 : (sp'=8) + 0.0017 : (sp'=9); // active_sleep - [tick2] sp=10 -> 0.0017 : (sp'=0) + 0.9983 : (sp'=10); // sleep_active - - // states where PM has control - // goto_active - [tick2] sp=0 & pm=0 -> (sp'=0); // active - [tick2] sp=1 & pm=0 -> (sp'=0); // idle - [tick2] sp=3 & pm=0 -> (sp'=4); // idlelp - [tick2] sp=6 & pm=0 -> (sp'=7); // stby - [tick2] sp=9 & pm=0 -> (sp'=10); // sleep - // goto_idle - [tick2] sp=0 & pm=1 -> (sp'=1); // active - [tick2] sp=1 & pm=1 -> (sp'=1); // idle - [tick2] sp=3 & pm=1 -> (sp'=3); // idlelp - [tick2] sp=6 & pm=1 -> (sp'=6); // stby - [tick2] sp=9 & pm=1 -> (sp'=9); // sleep - // goto_idlelp - [tick2] sp=0 & pm=2 -> (sp'=2); // active - [tick2] sp=1 & pm=2 -> (sp'=2); // idle - [tick2] sp=3 & pm=2 -> (sp'=3); // idlelp - [tick2] sp=6 & pm=2 -> (sp'=6); // stby - [tick2] sp=9 & pm=2 -> (sp'=9); // sleep - // goto_stby - [tick2] sp=0 & pm=3 -> (sp'=5); // active - [tick2] sp=1 & pm=3 -> (sp'=5); // idle - [tick2] sp=3 & pm=3 -> (sp'=5); // idlelp - [tick2] sp=6 & pm=3 -> (sp'=6); // stby - [tick2] sp=9 & pm=3 -> (sp'=9); // sleep - // goto_sleep - [tick2] sp=0 & pm=4 -> (sp'=8); // active - [tick2] sp=1 & pm=4 -> (sp'=8); // idle - [tick2] sp=3 & pm=4 -> (sp'=8); // idlelp - [tick2] sp=6 & pm=4 -> (sp'=8); // stby - [tick2] sp=9 & pm=4 -> (sp'=9); // sleep - -endmodule - - -//------------------------------------------------------------------------- - -// SQ -module SQ - - q : [0..QMAX] init 0; - - // serve if busy - [tick2] sr=0 & sp=0 -> (q'=max(q-1,0)); - [tick2] sr=1 & sp=0 -> (q'=q); - - // otherwise do nothing - [tick2] sr=0 & sp>0 -> (q'=q); - [tick2] sr=1 & sp>0 -> (q'=min(q+1,QMAX)); - -endmodule - -//------------------------------------------------------------------------- -//rewards "time" -// [tick2] bat=1 : 1; -//endrewards - -rewards "power" - [tick2] sp=0 & c=1 : 2.5; - [tick2] sp=1 & c=1 : 1.5; - [tick2] sp=2 & c=1 : 2.5; - [tick2] sp=3 & c=1 : 0.8; - [tick2] sp=4 & c=1 : 2.5; - [tick2] sp=5 & c=1 : 2.5; - [tick2] sp=6 & c=1 : 0.3; - [tick2] sp=7 & c=1 : 2.5; - [tick2] sp=8 & c=1 : 2.5; - [tick2] sp=9 & c=1 : 0.1; - [tick2] sp=10 & c=1 : 2.5; -endrewards - -// is an instantaneous property but I suppose we can look at average size -// i.e. divide by the expected number of time steps -rewards "queue" - [tick2] c=1 : q; -endrewards - -rewards "lost" - [tick2] sr=1 & sp>0 & q=2 : 1; -endrewards diff --git a/examples/multiobjective/mdp/dpm/origFiles/power-timed.pctl b/examples/multiobjective/mdp/dpm/origFiles/power-timed.pctl deleted file mode 100644 index 153141e7c..000000000 --- a/examples/multiobjective/mdp/dpm/origFiles/power-timed.pctl +++ /dev/null @@ -1,11 +0,0 @@ -// Average queue size -const double Q; - -// Time bound -const int k; - -// Minimum energy usage over k time-steps, such that average queue size remains below Q -"num_energy": multi(R{"power"}min=? [ C<=k ], R{"queue"}<=Q*k [ C<=k ]) - -// Pareto query: minimum energy usage vs minimum average queue size -"pareto": multi(R{"power"}min=? [ C<=k ], R{"queue"}min=? [ C<=k ]) diff --git a/examples/multiobjective/mdp/scheduler/origFiles/scheduler.pctl b/examples/multiobjective/mdp/scheduler/origFiles/scheduler.pctl deleted file mode 100644 index 24a09241b..000000000 --- a/examples/multiobjective/mdp/scheduler/origFiles/scheduler.pctl +++ /dev/null @@ -1,8 +0,0 @@ -// Minimise expected completion time given a bound on expected energy usage -"num_time": multi(R{"time"}min=?[ C ], R{"energy"}<=1.45 [ C ]) - -// Minimise expected energy usage given a bound on expected completion time -"num_energy": multi( R{"energy"}min=?[ C ], R{"time"}<=1000[ C ]) - -// Pareto query for assume-guarantee check -"pareto": multi(R{"energy"}min=?[ C ], R{"time"}min=? [ C ]) diff --git a/examples/multiobjective/mdp/scheduler/origFiles/scheduler_prob2_K.nm b/examples/multiobjective/mdp/scheduler/origFiles/scheduler_prob2_K.nm deleted file mode 100644 index 22064b3cb..000000000 --- a/examples/multiobjective/mdp/scheduler/origFiles/scheduler_prob2_K.nm +++ /dev/null @@ -1,95 +0,0 @@ -mdp - -label "tasks_complete" = (task6=3); - -const int K; - -module scheduler - - task1 : [0..3]; - task2 : [0..3]; - task3 : [0..3]; - task4 : [0..3]; - task5 : [0..3]; - task6 : [0..3]; - - [p1_add] task1=0 -> (task1'=1); - [p2_add] task1=0 -> (task1'=2); - [p1_mult] task2=0 -> (task2'=1); - [p2_mult] task2=0 -> (task2'=2); - [p1_mult] task3=0&task1=3 -> (task3'=1); - [p2_mult] task3=0&task1=3 -> (task3'=2); - [p1_add] task4=0&task1=3&task2=3 -> (task4'=1); - [p2_add] task4=0&task1=3&task2=3 -> (task4'=2); - [p1_mult] task5=0&task3=3 -> (task5'=1); - [p2_mult] task5=0&task3=3 -> (task5'=2); - [p1_add] task6=0&task4=3&task5=3 -> (task6'=1); - [p2_add] task6=0&task4=3&task5=3 -> (task6'=2); - [p1_done] task1=1 -> (task1'=3); - [p1_done] task2=1 -> (task2'=3); - [p1_done] task3=1 -> (task3'=3); - [p1_done] task4=1 -> (task4'=3); - [p1_done] task5=1 -> (task5'=3); - [p1_done] task6=1 -> (task6'=3); - [p2_done] task1=2 -> (task1'=3); - [p2_done] task2=2 -> (task2'=3); - [p2_done] task3=2 -> (task3'=3); - [p2_done] task4=2 -> (task4'=3); - [p2_done] task5=2 -> (task5'=3); - [p2_done] task6=2 -> (task6'=3); - [time] true -> 1.0 : true; - -endmodule - -module P1 - - p1 : [0..3]; - c1 : [0..2]; - x1 : [0..4*K+1]; - - [p1_add] (p1=0) -> (p1'=1) & (x1'=0); - [] (p1=1)&(x1=1*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0); - [] (p1=1)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0); - [p1_done] (p1=1)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0); - [p1_mult] (p1=0) -> (p1'=2) & (x1'=0); - [] (p1=2)&(x1=2*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0); - [] (p1=2)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0); - [p1_done] (p1=2)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0); - [p1_done] (p1=3) -> (p1'=0); - [time] (p1=1=>x1+1<=1*K)&((p1=2&c1=0)=>x1+1<=2*K)&((p1=2&c1>0)=>x1+1<=1*K)&(p1=3=>x1+1<=0) -> 1.0 : (x1'=min(x1+1,4*K+1)); - -endmodule - -module P2 - - p2 : [0..3]; - c2 : [0..2]; - x2 : [0..6*K+1]; - - [p2_add] (p2=0) -> (p2'=1) & (x2'=0); - [] (p2=1)&(x2=4*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0); - [] (p2=1)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0); - [p2_done] (p2=1)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0); - [p2_mult] (p2=0) -> (p2'=2) & (x2'=0); - [] (p2=2)&(x2=6*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0); - [] (p2=2)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0); - [p2_done] (p2=2)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0); - [p2_done] (p2=3) -> (p2'=0); - [time] ((p2=1&c2=0)=>x2+1<=4*K)&((p2=1&c2>0)=>x2+1<=1)&((p2=2&c2=0)=>x2+1<=6*K)&((p2=2&c2>0)=>x2+1<=1)&(p2=3=>x2+1<=0) -> 1.0 : (x2'=min(x2+1,6*K+1)); - -endmodule - -rewards "time" - - [time] true : 1/K; - -endrewards - -rewards "energy" - - [time] p1=0 : 10/(1000*K); - [time] p1>0 : 90/(1000*K); - [time] p2=0 : 20/(1000*K); - [time] p2>0 : 30/(1000*K); - -endrewards diff --git a/examples/multiobjective/mdp/scheduler/scheduler05.nm b/examples/multiobjective/mdp/scheduler/scheduler05.nm deleted file mode 100644 index 00f4e9539..000000000 --- a/examples/multiobjective/mdp/scheduler/scheduler05.nm +++ /dev/null @@ -1,95 +0,0 @@ -mdp - -label "tasks_complete" = (task6=3); - -const int K=5; - -module scheduler - - task1 : [0..3]; - task2 : [0..3]; - task3 : [0..3]; - task4 : [0..3]; - task5 : [0..3]; - task6 : [0..3]; - - [p1_add] task1=0 -> (task1'=1); - [p2_add] task1=0 -> (task1'=2); - [p1_mult] task2=0 -> (task2'=1); - [p2_mult] task2=0 -> (task2'=2); - [p1_mult] task3=0&task1=3 -> (task3'=1); - [p2_mult] task3=0&task1=3 -> (task3'=2); - [p1_add] task4=0&task1=3&task2=3 -> (task4'=1); - [p2_add] task4=0&task1=3&task2=3 -> (task4'=2); - [p1_mult] task5=0&task3=3 -> (task5'=1); - [p2_mult] task5=0&task3=3 -> (task5'=2); - [p1_add] task6=0&task4=3&task5=3 -> (task6'=1); - [p2_add] task6=0&task4=3&task5=3 -> (task6'=2); - [p1_done] task1=1 -> (task1'=3); - [p1_done] task2=1 -> (task2'=3); - [p1_done] task3=1 -> (task3'=3); - [p1_done] task4=1 -> (task4'=3); - [p1_done] task5=1 -> (task5'=3); - [p1_done] task6=1 -> (task6'=3); - [p2_done] task1=2 -> (task1'=3); - [p2_done] task2=2 -> (task2'=3); - [p2_done] task3=2 -> (task3'=3); - [p2_done] task4=2 -> (task4'=3); - [p2_done] task5=2 -> (task5'=3); - [p2_done] task6=2 -> (task6'=3); - [time] true -> 1.0 : true; - -endmodule - -module P1 - - p1 : [0..3]; - c1 : [0..2]; - x1 : [0..4*K+1]; - - [p1_add] (p1=0) -> (p1'=1) & (x1'=0); - [] (p1=1)&(x1=1*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0); - [] (p1=1)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0); - [p1_done] (p1=1)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0); - [p1_mult] (p1=0) -> (p1'=2) & (x1'=0); - [] (p1=2)&(x1=2*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0); - [] (p1=2)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0); - [p1_done] (p1=2)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0); - [p1_done] (p1=3) -> (p1'=0); - [time] (p1=1=>x1+1<=1*K)&((p1=2&c1=0)=>x1+1<=2*K)&((p1=2&c1>0)=>x1+1<=1*K)&(p1=3=>x1+1<=0) -> 1.0 : (x1'=min(x1+1,4*K+1)); - -endmodule - -module P2 - - p2 : [0..3]; - c2 : [0..2]; - x2 : [0..6*K+1]; - - [p2_add] (p2=0) -> (p2'=1) & (x2'=0); - [] (p2=1)&(x2=4*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0); - [] (p2=1)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0); - [p2_done] (p2=1)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0); - [p2_mult] (p2=0) -> (p2'=2) & (x2'=0); - [] (p2=2)&(x2=6*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0); - [] (p2=2)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0); - [p2_done] (p2=2)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0); - [p2_done] (p2=3) -> (p2'=0); - [time] ((p2=1&c2=0)=>x2+1<=4*K)&((p2=1&c2>0)=>x2+1<=1)&((p2=2&c2=0)=>x2+1<=6*K)&((p2=2&c2>0)=>x2+1<=1)&(p2=3=>x2+1<=0) -> 1.0 : (x2'=min(x2+1,6*K+1)); - -endmodule - -rewards "time" - - [time] true : 1/K; - -endrewards - -rewards "energy" - - [time] p1=0 : 10/(1000*K); - [time] p1>0 : 90/(1000*K); - [time] p2=0 : 20/(1000*K); - [time] p2>0 : 30/(1000*K); - -endrewards diff --git a/examples/multiobjective/mdp/scheduler/scheduler05_numerical.pctl b/examples/multiobjective/mdp/scheduler/scheduler05_numerical.pctl deleted file mode 100644 index 47ab6d61e..000000000 --- a/examples/multiobjective/mdp/scheduler/scheduler05_numerical.pctl +++ /dev/null @@ -1,4 +0,0 @@ -multi(R{"time"}min=?[ F "tasks_complete" ], R{"energy"}<=1.45 [ F "tasks_complete" ]) -// Original query: -//multi(R{"time"}min=?[ C ], R{"energy"}<=1.45 [ C ]) -// Note that the min values are actually infinity and prism (currently) gives wrong results for this, e.g., R{"time"}min=?[ C<=2000 ] gives a larger value than multi(R{"time"}min=?[ C ], R{"energy"}<=1.45 [ C ]) . \ No newline at end of file diff --git a/examples/multiobjective/mdp/scheduler/scheduler05_pareto.pctl b/examples/multiobjective/mdp/scheduler/scheduler05_pareto.pctl deleted file mode 100644 index b95651662..000000000 --- a/examples/multiobjective/mdp/scheduler/scheduler05_pareto.pctl +++ /dev/null @@ -1,4 +0,0 @@ - multi(R{"time"}min=?[ F "tasks_complete" ], R{"energy"}min=? [ F "tasks_complete" ]) - // Original query: - //multi(R{"energy"}min=?[ C ], R{"time"}min=? [ C ]) -// Note that the min values are actually infinity and prism (currently) gives wrong results for this, e.g., R{"time"}min=?[ C<=2000 ] gives a larger value than multi(R{"time"}min=?[ C ], R{"energy"}<=1.45 [ C ]) . \ No newline at end of file diff --git a/examples/multiobjective/mdp/scheduler/scheduler25.nm b/examples/multiobjective/mdp/scheduler/scheduler25.nm deleted file mode 100644 index 2e75dfbdd..000000000 --- a/examples/multiobjective/mdp/scheduler/scheduler25.nm +++ /dev/null @@ -1,95 +0,0 @@ -mdp - -label "tasks_complete" = (task6=3); - -const int K=25; - -module scheduler - - task1 : [0..3]; - task2 : [0..3]; - task3 : [0..3]; - task4 : [0..3]; - task5 : [0..3]; - task6 : [0..3]; - - [p1_add] task1=0 -> (task1'=1); - [p2_add] task1=0 -> (task1'=2); - [p1_mult] task2=0 -> (task2'=1); - [p2_mult] task2=0 -> (task2'=2); - [p1_mult] task3=0&task1=3 -> (task3'=1); - [p2_mult] task3=0&task1=3 -> (task3'=2); - [p1_add] task4=0&task1=3&task2=3 -> (task4'=1); - [p2_add] task4=0&task1=3&task2=3 -> (task4'=2); - [p1_mult] task5=0&task3=3 -> (task5'=1); - [p2_mult] task5=0&task3=3 -> (task5'=2); - [p1_add] task6=0&task4=3&task5=3 -> (task6'=1); - [p2_add] task6=0&task4=3&task5=3 -> (task6'=2); - [p1_done] task1=1 -> (task1'=3); - [p1_done] task2=1 -> (task2'=3); - [p1_done] task3=1 -> (task3'=3); - [p1_done] task4=1 -> (task4'=3); - [p1_done] task5=1 -> (task5'=3); - [p1_done] task6=1 -> (task6'=3); - [p2_done] task1=2 -> (task1'=3); - [p2_done] task2=2 -> (task2'=3); - [p2_done] task3=2 -> (task3'=3); - [p2_done] task4=2 -> (task4'=3); - [p2_done] task5=2 -> (task5'=3); - [p2_done] task6=2 -> (task6'=3); - [time] true -> 1.0 : true; - -endmodule - -module P1 - - p1 : [0..3]; - c1 : [0..2]; - x1 : [0..4*K+1]; - - [p1_add] (p1=0) -> (p1'=1) & (x1'=0); - [] (p1=1)&(x1=1*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0); - [] (p1=1)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0); - [p1_done] (p1=1)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0); - [p1_mult] (p1=0) -> (p1'=2) & (x1'=0); - [] (p1=2)&(x1=2*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0); - [] (p1=2)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0); - [p1_done] (p1=2)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0); - [p1_done] (p1=3) -> (p1'=0); - [time] (p1=1=>x1+1<=1*K)&((p1=2&c1=0)=>x1+1<=2*K)&((p1=2&c1>0)=>x1+1<=1*K)&(p1=3=>x1+1<=0) -> 1.0 : (x1'=min(x1+1,4*K+1)); - -endmodule - -module P2 - - p2 : [0..3]; - c2 : [0..2]; - x2 : [0..6*K+1]; - - [p2_add] (p2=0) -> (p2'=1) & (x2'=0); - [] (p2=1)&(x2=4*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0); - [] (p2=1)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0); - [p2_done] (p2=1)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0); - [p2_mult] (p2=0) -> (p2'=2) & (x2'=0); - [] (p2=2)&(x2=6*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0); - [] (p2=2)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0); - [p2_done] (p2=2)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0); - [p2_done] (p2=3) -> (p2'=0); - [time] ((p2=1&c2=0)=>x2+1<=4*K)&((p2=1&c2>0)=>x2+1<=1)&((p2=2&c2=0)=>x2+1<=6*K)&((p2=2&c2>0)=>x2+1<=1)&(p2=3=>x2+1<=0) -> 1.0 : (x2'=min(x2+1,6*K+1)); - -endmodule - -rewards "time" - - [time] true : 1/K; - -endrewards - -rewards "energy" - - [time] p1=0 : 10/(1000*K); - [time] p1>0 : 90/(1000*K); - [time] p2=0 : 20/(1000*K); - [time] p2>0 : 30/(1000*K); - -endrewards diff --git a/examples/multiobjective/mdp/scheduler/scheduler25_numerical.pctl b/examples/multiobjective/mdp/scheduler/scheduler25_numerical.pctl deleted file mode 100644 index 6d91107a4..000000000 --- a/examples/multiobjective/mdp/scheduler/scheduler25_numerical.pctl +++ /dev/null @@ -1,4 +0,0 @@ - multi(R{"time"}min=?[ F "tasks_complete" ], R{"energy"}<=1.45 [ F "tasks_complete" ]) -// Original query: -// multi(R{"time"}min=?[ C ], R{"energy"}<=1.45 [ C ]) -// Note that the min values are actually infinity and prism (currently) gives wrong results for this, e.g., R{"time"}min=?[ C<=2000 ] gives a larger value than multi(R{"time"}min=?[ C ], R{"energy"}<=1.45 [ C ]) . \ No newline at end of file diff --git a/examples/multiobjective/mdp/scheduler/scheduler25_pareto.pctl b/examples/multiobjective/mdp/scheduler/scheduler25_pareto.pctl deleted file mode 100644 index d818ef6d2..000000000 --- a/examples/multiobjective/mdp/scheduler/scheduler25_pareto.pctl +++ /dev/null @@ -1,4 +0,0 @@ - multi(R{"time"}min=?[ F "tasks_complete" ], R{"energy"}min=? [ F "tasks_complete" ]) -// Original query: -// multi(R{"energy"}min=?[ C ], R{"time"}min=? [ C ]) -// Note that the min values are actually infinity and prism (currently) gives wrong results for this, e.g., R{"time"}min=?[ C<=2000 ] gives a larger value than multi(R{"time"}min=?[ C ], R{"energy"}<=1.45 [ C ]) . \ No newline at end of file diff --git a/examples/multiobjective/mdp/scheduler/scheduler50.nm b/examples/multiobjective/mdp/scheduler/scheduler50.nm deleted file mode 100644 index 5e44a94fc..000000000 --- a/examples/multiobjective/mdp/scheduler/scheduler50.nm +++ /dev/null @@ -1,95 +0,0 @@ -mdp - -label "tasks_complete" = (task6=3); - -const int K=50; - -module scheduler - - task1 : [0..3]; - task2 : [0..3]; - task3 : [0..3]; - task4 : [0..3]; - task5 : [0..3]; - task6 : [0..3]; - - [p1_add] task1=0 -> (task1'=1); - [p2_add] task1=0 -> (task1'=2); - [p1_mult] task2=0 -> (task2'=1); - [p2_mult] task2=0 -> (task2'=2); - [p1_mult] task3=0&task1=3 -> (task3'=1); - [p2_mult] task3=0&task1=3 -> (task3'=2); - [p1_add] task4=0&task1=3&task2=3 -> (task4'=1); - [p2_add] task4=0&task1=3&task2=3 -> (task4'=2); - [p1_mult] task5=0&task3=3 -> (task5'=1); - [p2_mult] task5=0&task3=3 -> (task5'=2); - [p1_add] task6=0&task4=3&task5=3 -> (task6'=1); - [p2_add] task6=0&task4=3&task5=3 -> (task6'=2); - [p1_done] task1=1 -> (task1'=3); - [p1_done] task2=1 -> (task2'=3); - [p1_done] task3=1 -> (task3'=3); - [p1_done] task4=1 -> (task4'=3); - [p1_done] task5=1 -> (task5'=3); - [p1_done] task6=1 -> (task6'=3); - [p2_done] task1=2 -> (task1'=3); - [p2_done] task2=2 -> (task2'=3); - [p2_done] task3=2 -> (task3'=3); - [p2_done] task4=2 -> (task4'=3); - [p2_done] task5=2 -> (task5'=3); - [p2_done] task6=2 -> (task6'=3); - [time] true -> 1.0 : true; - -endmodule - -module P1 - - p1 : [0..3]; - c1 : [0..2]; - x1 : [0..4*K+1]; - - [p1_add] (p1=0) -> (p1'=1) & (x1'=0); - [] (p1=1)&(x1=1*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0); - [] (p1=1)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0); - [p1_done] (p1=1)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0); - [p1_mult] (p1=0) -> (p1'=2) & (x1'=0); - [] (p1=2)&(x1=2*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0); - [] (p1=2)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0); - [p1_done] (p1=2)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0); - [p1_done] (p1=3) -> (p1'=0); - [time] (p1=1=>x1+1<=1*K)&((p1=2&c1=0)=>x1+1<=2*K)&((p1=2&c1>0)=>x1+1<=1*K)&(p1=3=>x1+1<=0) -> 1.0 : (x1'=min(x1+1,4*K+1)); - -endmodule - -module P2 - - p2 : [0..3]; - c2 : [0..2]; - x2 : [0..6*K+1]; - - [p2_add] (p2=0) -> (p2'=1) & (x2'=0); - [] (p2=1)&(x2=4*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0); - [] (p2=1)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0); - [p2_done] (p2=1)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0); - [p2_mult] (p2=0) -> (p2'=2) & (x2'=0); - [] (p2=2)&(x2=6*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0); - [] (p2=2)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0); - [p2_done] (p2=2)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0); - [p2_done] (p2=3) -> (p2'=0); - [time] ((p2=1&c2=0)=>x2+1<=4*K)&((p2=1&c2>0)=>x2+1<=1)&((p2=2&c2=0)=>x2+1<=6*K)&((p2=2&c2>0)=>x2+1<=1)&(p2=3=>x2+1<=0) -> 1.0 : (x2'=min(x2+1,6*K+1)); - -endmodule - -rewards "time" - - [time] true : 1/K; - -endrewards - -rewards "energy" - - [time] p1=0 : 10/(1000*K); - [time] p1>0 : 90/(1000*K); - [time] p2=0 : 20/(1000*K); - [time] p2>0 : 30/(1000*K); - -endrewards diff --git a/examples/multiobjective/mdp/scheduler/scheduler50_numerical.pctl b/examples/multiobjective/mdp/scheduler/scheduler50_numerical.pctl deleted file mode 100644 index 6d91107a4..000000000 --- a/examples/multiobjective/mdp/scheduler/scheduler50_numerical.pctl +++ /dev/null @@ -1,4 +0,0 @@ - multi(R{"time"}min=?[ F "tasks_complete" ], R{"energy"}<=1.45 [ F "tasks_complete" ]) -// Original query: -// multi(R{"time"}min=?[ C ], R{"energy"}<=1.45 [ C ]) -// Note that the min values are actually infinity and prism (currently) gives wrong results for this, e.g., R{"time"}min=?[ C<=2000 ] gives a larger value than multi(R{"time"}min=?[ C ], R{"energy"}<=1.45 [ C ]) . \ No newline at end of file diff --git a/examples/multiobjective/mdp/scheduler/scheduler50_pareto.pctl b/examples/multiobjective/mdp/scheduler/scheduler50_pareto.pctl deleted file mode 100644 index 9cb7bf3d0..000000000 --- a/examples/multiobjective/mdp/scheduler/scheduler50_pareto.pctl +++ /dev/null @@ -1,4 +0,0 @@ - multi(R{"time"}min=?[ F "tasks_complete" ], R{"energy"}min=? [ F "tasks_complete" ]) -// Original query: -// multi(R{"energy"}min=?[ C ], R{"time"}min=? [ C ]) -// Note that the min values are actually infinity and prism (currently) gives wrong results for this, e.g., R{"time"}min=?[ C<=2000 ] gives a larger value than multi(R{"time"}min=?[ C ], R{"energy"}<=1.45 [ C ]) . \ No newline at end of file diff --git a/examples/multiobjective/mdp/simple/simple.nm b/examples/multiobjective/mdp/simple/simple.nm deleted file mode 100644 index 04c1a0ea0..000000000 --- a/examples/multiobjective/mdp/simple/simple.nm +++ /dev/null @@ -1,25 +0,0 @@ - -mdp - -module simple - - // local state - s : [0..2] init 0; - - [A] s=0 -> 0.2 : (s'=1) + 0.8 : (s'=0); - [B] s=0 -> 1 : (s'=2); - [C] s=0 -> 1 : (s'=0); - [] s>0 -> 1 : (s'=s); -endmodule - -rewards "actA" - [A] true : 1; -endrewards - -rewards "actB" - [B] true : 2; -endrewards - - -label "a" = s=1; -label "b" = s=2; \ No newline at end of file diff --git a/examples/multiobjective/mdp/simple/simple.pctl b/examples/multiobjective/mdp/simple/simple.pctl deleted file mode 100644 index 91d5becac..000000000 --- a/examples/multiobjective/mdp/simple/simple.pctl +++ /dev/null @@ -1,2 +0,0 @@ -multi(P<0.4 [ F "a"], P<0.3 [ F "b"] ) -//multi(Pmin=? [ F<=10 "a"], R<0.3 [ F "b" | "a"] ) \ No newline at end of file diff --git a/examples/multiobjective/mdp/team/origFiles/MDP_a2_r3_t2_full_exp.nm b/examples/multiobjective/mdp/team/origFiles/MDP_a2_r3_t2_full_exp.nm deleted file mode 100644 index 4c183b9cf..000000000 --- a/examples/multiobjective/mdp/team/origFiles/MDP_a2_r3_t2_full_exp.nm +++ /dev/null @@ -1,231 +0,0 @@ -mdp - -// parameters -const int n_resources = 3; -const int n_tasks = 2; -const int n_sensors = 2; - - -// sensor resources -const int resource1=1; -const int resource2=2; - -// network configuration -const int e12=1; -const int e21=e12; - -module controller // schedules the algorithm - - // algorithm status - status : [0..5]; - - // task resource indicator variables - t1_r1 : [0..1]; - t1_r2 : [0..1]; - t1_r3 : [0..1]; - - t2_r1 : [0..1]; - t2_r2 : [0..1]; - t2_r3 : [0..1]; - - // schedule placeholders - turn1 : [0..n_sensors]; - turn2 : [0..n_sensors]; - - // selecting schedule uniformly at random - [] status=0 -> 1/2 : (turn1'=1) & (turn2'=2) & (status'=1) - + 1/2 : (turn1'=2) & (turn2'=1) & (status'=1); - - - // initialising non-empty tasks uniformly at random - [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2); - - // executing the schedule - - // 1st round - [str1] status=2 & turn1=1 -> (status'=2); - [fin1] status=2 & turn1=1 -> (status'=3); - [str2] status=2 & turn1=2 -> (status'=2); - [fin2] status=2 & turn1=2 -> (status'=3); - - // 2nd round - [str1] status=3 & turn2=1 -> (status'=3); - [fin1] status=3 & turn2=1 -> (status'=4); - [str2] status=3 & turn2=2 -> (status'=3); - [fin2] status=3 & turn2=2 -> (status'=4); - - - [] status=4 -> (status'=5); - - [] status=5 -> true; - -endmodule - -module sensor1 - - state1 : [0..1]; - - // team membership indicators - m1_t1 : [0..1]; - m1_t2 : [0..1]; - - // starting turn, selecting order of tasks - [str1] state1=0 -> (state1'=1); - - // if there is no team and has required skill - initiating the team - [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1); - - // if team already exists and one of the neighbours is in it - joining the team - [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1); - - [fin1] state1>0 -> (state1'=0); - -endmodule - -module sensor2 = sensor1 -[ - state1=state2, - - str1=str2, - fin1=fin2, - - m1_t1=m2_t1, - m1_t2=m2_t2, - - m2_t1=m1_t1, - m2_t2=m1_t2, - - resource1=resource2, - resource2=resource1, - - e12=e21, - e13=e23, - e14=e24, - e15=e25, - - e21=e12, - e23=e13, - e24=e14, - e25=e15 -] -endmodule - - - - -// agent is committed to some team -formula committed = (m1_t1+m1_t2) > 0; - -// formulae to compute team sizes -formula team_size_t1 = m1_t1+m2_t1; -formula team_size_t2 = m1_t2+m2_t2; - -// formulae to check whether the agent can join the team -formula can_join_t1 = e12*m2_t1 > 0; -formula can_join_t2 = e12*m2_t2 > 0; - -// formulae to check whether agent has the resource required by the task -formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) ); -formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) ); - -// formulae to check whether the resource of an agent has been already filled in the team -formula resource_filled_t1 = (m2_t1=1 & resource1=resource2); -formula resource_filled_t2 = (m2_t2=1 & resource1=resource2); - -// formula to compute team initiation probability (assuming each agent has at least one connection) -formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))) / (e12); - - - - -// labels and formulae for property specification -formula finished = (status=4); -label "end" = (status=5); - - -formula task1_completed = finished - & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1))) - & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2))) - & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3))); - -formula task2_completed = finished - & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1))) - & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2))) - & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3))); - - - -formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1); -formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1); -formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2); -formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3); - -formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1); -formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1); -formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2); -formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3); - -// rewards -rewards "w_1_total" - [] agent1_joins_successful_team : 1; - [] agent2_joins_successful_team : 1; -endrewards - -rewards "w_2_total" - [] task1_completed : 1; - [] task2_completed : 1; -endrewards - - - - diff --git a/examples/multiobjective/mdp/team/origFiles/MDP_a3_r3_t2_full_exp.nm b/examples/multiobjective/mdp/team/origFiles/MDP_a3_r3_t2_full_exp.nm deleted file mode 100644 index 8a754d922..000000000 --- a/examples/multiobjective/mdp/team/origFiles/MDP_a3_r3_t2_full_exp.nm +++ /dev/null @@ -1,287 +0,0 @@ -mdp - -// parameters -const int n_resources = 3; -const int n_tasks = 2; -const int n_sensors = 3; - - -// sensor resources -const int resource1=1; -const int resource2=2; -const int resource3=3; - -// network configuration -const int e12=1; -const int e13=1; - -const int e21=e12; -const int e23=1; - -const int e31=e13; -const int e32=e23; - - -module controller // schedules the algorithm - - // algorithm status - status : [0..6]; - - // task resource indicator variables - t1_r1 : [0..1]; - t1_r2 : [0..1]; - t1_r3 : [0..1]; - - t2_r1 : [0..1]; - t2_r2 : [0..1]; - t2_r3 : [0..1]; - - // schedule placeholders - turn1 : [0..n_sensors]; - turn2 : [0..n_sensors]; - turn3 : [0..n_sensors]; - - // selecting schedule uniformly at random - [] status=0 -> 1/6 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (status'=1) - + 1/6 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (status'=1) - + 1/6 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (status'=1) - + 1/6 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (status'=1) - + 1/6 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (status'=1) - + 1/6 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (status'=1); - - - // initialising non-empty tasks uniformly at random - [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2); - - // executing the schedule - - // 1st round - [str1] status=2 & turn1=1 -> (status'=2); - [fin1] status=2 & turn1=1 -> (status'=3); - [str2] status=2 & turn1=2 -> (status'=2); - [fin2] status=2 & turn1=2 -> (status'=3); - [str3] status=2 & turn1=3 -> (status'=2); - [fin3] status=2 & turn1=3 -> (status'=3); - - // 2nd round - [str1] status=3 & turn2=1 -> (status'=3); - [fin1] status=3 & turn2=1 -> (status'=4); - [str2] status=3 & turn2=2 -> (status'=3); - [fin2] status=3 & turn2=2 -> (status'=4); - [str3] status=3 & turn2=3 -> (status'=3); - [fin3] status=3 & turn2=3 -> (status'=4); - - // 3rd round - [str1] status=4 & turn3=1 -> (status'=4); - [fin1] status=4 & turn3=1 -> (status'=5); - [str2] status=4 & turn3=2 -> (status'=4); - [fin2] status=4 & turn3=2 -> (status'=5); - [str3] status=4 & turn3=3 -> (status'=4); - [fin3] status=4 & turn3=3 -> (status'=5); - - [] status=5 -> (status'=6); - - [] status=6 -> true; - -endmodule - -module sensor1 - - state1 : [0..1]; - - // team membership indicators - m1_t1 : [0..1]; - m1_t2 : [0..1]; - - // starting turn, selecting order of tasks - [str1] state1=0 -> (state1'=1); - - // if there is no team and has required skill - initiating the team - [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1); - - // if team already exists and one of the neighbours is in it - joining the team - [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1); - - [fin1] state1>0 -> (state1'=0); - -endmodule - -module sensor2 = sensor1 -[ - state1=state2, - - str1=str2, - fin1=fin2, - - m1_t1=m2_t1, - m1_t2=m2_t2, - - m2_t1=m1_t1, - m2_t2=m1_t2, - - resource1=resource2, - resource2=resource1, - - e12=e21, - e13=e23, - e14=e24, - e15=e25, - - e21=e12, - e23=e13, - e24=e14, - e25=e15 -] -endmodule - -module sensor3 = sensor1 -[ - state1=state3, - - str1=str3, - fin1=fin3, - - m1_t1=m3_t1, - m1_t2=m3_t2, - m3_t1=m1_t1, - m3_t2=m1_t2, - - resource1=resource3, - resource3=resource1, - - e12=e32, - e13=e31, - e14=e34, - e15=e35, - - e31=e13, - e32=e12, - e34=e14, - e35=e15 -] -endmodule - - - -// agent is committed to some team -formula committed = (m1_t1+m1_t2) > 0; - -// formulae to compute team sizes -formula team_size_t1 = m1_t1+m2_t1+m3_t1; -formula team_size_t2 = m1_t2+m2_t2+m3_t2; - -// formulae to check whether the agent can join the team -formula can_join_t1 = e12*m2_t1 + e13*m3_t1 > 0; -formula can_join_t2 = e12*m2_t2 + e13*m3_t2 > 0; - -// formulae to check whether agent has the resource required by the task -formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) ); -formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) ); - -// formulae to check whether the resource of an agent has been already filled in the team -formula resource_filled_t1 = (m2_t1=1 & resource1=resource2) | (m3_t1=1 & resource1=resource3); -formula resource_filled_t2 = (m2_t2=1 & resource1=resource2) | (m3_t2=1 & resource1=resource3); - -// formula to compute team initiation probability (assuming each agent has at least one connection) -formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))+e13*(1-((m3_t1+m3_t2)=0?0:1))) / (e12+e13); - - - - -// labels and formulae for property specification -formula finished = (status=5); -label "end" = (status=6); - - -formula task1_completed = finished - & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1)|(m3_t1=1&resource3=1))) - & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2)|(m3_t1=1&resource3=2))) - & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3)|(m3_t1=1&resource3=3))); - -formula task2_completed = finished - & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1)|(m3_t2=1&resource3=1))) - & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2)|(m3_t2=1&resource3=2))) - & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3)|(m3_t2=1&resource3=3))); - - - -formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1); -formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1); -formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2); -formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3); - -formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1); -formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1); -formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2); -formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3); - -formula agent3_joins_successful_team = (task1_completed & m3_t1=1) | (task2_completed & m3_t2=1); -formula agent3_joins_successful_team_of_1 = (task1_completed & m3_t1=1 & team_size_t1=1) | (task2_completed & m3_t2=1 & team_size_t2=1); -formula agent3_joins_successful_team_of_2 = (task1_completed & m3_t1=1 & team_size_t1=2) | (task2_completed & m3_t2=1 & team_size_t2=2); -formula agent3_joins_successful_team_of_3 = (task1_completed & m3_t1=1 & team_size_t1=3) | (task2_completed & m3_t2=1 & team_size_t2=3); - -// rewards -rewards "w_1_total" - [] agent1_joins_successful_team : 1; - [] agent2_joins_successful_team : 1; - [] agent3_joins_successful_team : 1; -endrewards - -rewards "w_2_total" - [] task1_completed : 1; - [] task2_completed : 1; -endrewards - - - - diff --git a/examples/multiobjective/mdp/team/origFiles/MDP_a4_r3_t2_full_exp.nm b/examples/multiobjective/mdp/team/origFiles/MDP_a4_r3_t2_full_exp.nm deleted file mode 100644 index bc9e536c2..000000000 --- a/examples/multiobjective/mdp/team/origFiles/MDP_a4_r3_t2_full_exp.nm +++ /dev/null @@ -1,364 +0,0 @@ -mdp - -// parameters -const int n_resources = 3; -const int n_tasks = 2; -const int n_sensors = 4; - - -// sensor resources -const int resource1=1; -const int resource2=2; -const int resource3=3; -const int resource4=1; - -// network configuration -const int e12=1; -const int e13=1; -const int e14=1; - -const int e21=e12; -const int e23=1; -const int e24=1; - -const int e31=e13; -const int e32=e23; -const int e34=1; - -const int e41=e14; -const int e42=e24; -const int e43=e34; - - -module controller // schedules the algorithm - - // algorithm status - status : [0..7]; - - // task resource indicator variables - t1_r1 : [0..1]; - t1_r2 : [0..1]; - t1_r3 : [0..1]; - - t2_r1 : [0..1]; - t2_r2 : [0..1]; - t2_r3 : [0..1]; - - // schedule placeholders - turn1 : [0..n_sensors]; - turn2 : [0..n_sensors]; - turn3 : [0..n_sensors]; - turn4 : [0..n_sensors]; - turn5 : [0..n_sensors]; - - // selecting schedule uniformly at random - [] status=0 -> 1/24 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=2) & (turn3'=4) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=3) & (turn3'=4) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=4) & (turn3'=2) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=4) & (turn3'=3) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=1) & (turn3'=4) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=3) & (turn3'=4) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=4) & (turn3'=1) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=4) & (turn3'=3) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=1) & (turn3'=4) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=2) & (turn3'=4) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=4) & (turn3'=1) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=4) & (turn3'=2) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=1) & (turn3'=2) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=1) & (turn3'=3) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=2) & (turn3'=1) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=2) & (turn3'=3) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=3) & (turn3'=1) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=3) & (turn3'=2) & (turn4'=1) & (status'=1); - - - // initialising non-empty tasks uniformly at random - [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2); - - // executing the schedule - - // 1st round - [str1] status=2 & turn1=1 -> (status'=2); - [fin1] status=2 & turn1=1 -> (status'=3); - [str2] status=2 & turn1=2 -> (status'=2); - [fin2] status=2 & turn1=2 -> (status'=3); - [str3] status=2 & turn1=3 -> (status'=2); - [fin3] status=2 & turn1=3 -> (status'=3); - [str4] status=2 & turn1=4 -> (status'=2); - [fin4] status=2 & turn1=4 -> (status'=3); - - // 2nd round - [str1] status=3 & turn2=1 -> (status'=3); - [fin1] status=3 & turn2=1 -> (status'=4); - [str2] status=3 & turn2=2 -> (status'=3); - [fin2] status=3 & turn2=2 -> (status'=4); - [str3] status=3 & turn2=3 -> (status'=3); - [fin3] status=3 & turn2=3 -> (status'=4); - [str4] status=3 & turn2=4 -> (status'=3); - [fin4] status=3 & turn2=4 -> (status'=4); - - // 3rd round - [str1] status=4 & turn3=1 -> (status'=4); - [fin1] status=4 & turn3=1 -> (status'=5); - [str2] status=4 & turn3=2 -> (status'=4); - [fin2] status=4 & turn3=2 -> (status'=5); - [str3] status=4 & turn3=3 -> (status'=4); - [fin3] status=4 & turn3=3 -> (status'=5); - [str4] status=4 & turn3=4 -> (status'=4); - [fin4] status=4 & turn3=4 -> (status'=5); - - // 4th round - [str1] status=5 & turn4=1 -> (status'=5); - [fin1] status=5 & turn4=1 -> (status'=6); - [str2] status=5 & turn4=2 -> (status'=5); - [fin2] status=5 & turn4=2 -> (status'=6); - [str3] status=5 & turn4=3 -> (status'=5); - [fin3] status=5 & turn4=3 -> (status'=6); - [str4] status=5 & turn4=4 -> (status'=5); - [fin4] status=5 & turn4=4 -> (status'=6); - - [] status=6 -> (status'=7); - - [] status=7 -> (status'=7); - -endmodule - -module sensor1 - - state1 : [0..1]; - - // team membership indicators - m1_t1 : [0..1]; - m1_t2 : [0..1]; - - // starting turn, selecting order of tasks - [str1] state1=0 -> (state1'=1); - - // if there is no team and has required skill - initiating the team - [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1); - - // if team already exists and one of the neighbours is in it - joining the team - [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1); - - [fin1] state1>0 -> (state1'=0); - -endmodule - -module sensor2 = sensor1 -[ - state1=state2, - - str1=str2, - fin1=fin2, - - m1_t1=m2_t1, - m1_t2=m2_t2, - - m2_t1=m1_t1, - m2_t2=m1_t2, - - resource1=resource2, - resource2=resource1, - - e12=e21, - e13=e23, - e14=e24, - e15=e25, - - e21=e12, - e23=e13, - e24=e14, - e25=e15 -] -endmodule - -module sensor3 = sensor1 -[ - state1=state3, - - str1=str3, - fin1=fin3, - - m1_t1=m3_t1, - m1_t2=m3_t2, - m3_t1=m1_t1, - m3_t2=m1_t2, - - resource1=resource3, - resource3=resource1, - - e12=e32, - e13=e31, - e14=e34, - e15=e35, - - e31=e13, - e32=e12, - e34=e14, - e35=e15 -] -endmodule - -module sensor4 = sensor1 -[ - state1=state4, - - str1=str4, - fin1=fin4, - - m1_t1=m4_t1, - m1_t2=m4_t2, - - m4_t1=m1_t1, - m4_t2=m1_t2, - - resource1=resource4, - resource4=resource1, - - e12=e42, - e13=e43, - e14=e41, - e15=e45, - - e41=e14, - e42=e12, - e43=e13, - e45=e15 -] -endmodule - - - -// agent is committed to some team -formula committed = (m1_t1+m1_t2) > 0; - -// formulae to compute team sizes -formula team_size_t1 = m1_t1+m2_t1+m3_t1+m4_t1; -formula team_size_t2 = m1_t2+m2_t2+m3_t2+m4_t2; - -// formulae to check whether the agent can join the team -formula can_join_t1 = e12*m2_t1 + e13*m3_t1 + e14*m4_t1 > 0; -formula can_join_t2 = e12*m2_t2 + e13*m3_t2 + e14*m4_t2 > 0; - -// formulae to check whether agent has the resource required by the task -formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) ); -formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) ); - -// formulae to check whether the resource of an agent has been already filled in the team -formula resource_filled_t1 = (m2_t1=1 & resource1=resource2) | (m3_t1=1 & resource1=resource3) | (m4_t1=1 & resource1=resource4); -formula resource_filled_t2 = (m2_t2=1 & resource1=resource2) | (m3_t2=1 & resource1=resource3) | (m4_t2=1 & resource1=resource4); - -// formula to compute team initiation probability (assuming each agent has at least one connection) -formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))+e13*(1-((m3_t1+m3_t2)=0?0:1))+e14*(1-((m4_t1+m4_t2)=0?0:1))) / (e12+e13+e14); - - - - -// labels and formulae for property specification -formula finished = (status=6); -label "end" = (status=7); - - -formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1); -formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1); -formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2); -formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3); - -formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1); -formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1); -formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2); -formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3); - -formula agent3_joins_successful_team = (task1_completed & m3_t1=1) | (task2_completed & m3_t2=1); -formula agent3_joins_successful_team_of_1 = (task1_completed & m3_t1=1 & team_size_t1=1) | (task2_completed & m3_t2=1 & team_size_t2=1); -formula agent3_joins_successful_team_of_2 = (task1_completed & m3_t1=1 & team_size_t1=2) | (task2_completed & m3_t2=1 & team_size_t2=2); -formula agent3_joins_successful_team_of_3 = (task1_completed & m3_t1=1 & team_size_t1=3) | (task2_completed & m3_t2=1 & team_size_t2=3); - -formula agent4_joins_successful_team = (task1_completed & m4_t1=1) | (task2_completed & m4_t2=1); -formula agent4_joins_successful_team_of_1 = (task1_completed & m4_t1=1 & team_size_t1=1) | (task2_completed & m4_t2=1 & team_size_t2=1); -formula agent4_joins_successful_team_of_2 = (task1_completed & m4_t1=1 & team_size_t1=2) | (task2_completed & m4_t2=1 & team_size_t2=2); -formula agent4_joins_successful_team_of_3 = (task1_completed & m4_t1=1 & team_size_t1=3) | (task2_completed & m4_t2=1 & team_size_t2=3); - -formula task1_completed = finished - & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1)|(m3_t1=1&resource3=1)|(m4_t1=1&resource4=1))) - & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2)|(m3_t1=1&resource3=2)|(m4_t1=1&resource4=2))) - & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3)|(m3_t1=1&resource3=3)|(m4_t1=1&resource4=3))); - -formula task2_completed = finished - & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1)|(m3_t2=1&resource3=1)|(m4_t2=1&resource4=1))) - & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2)|(m3_t2=1&resource3=2)|(m4_t2=1&resource4=2))) - & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3)|(m3_t2=1&resource3=3)|(m4_t2=1&resource4=3))); - -// rewards -rewards "w_1_total" - [] agent1_joins_successful_team : 1; - [] agent2_joins_successful_team : 1; - [] agent3_joins_successful_team : 1; - [] agent4_joins_successful_team : 1; -endrewards - -rewards "w_2_total" - [] task1_completed : 1; - [] task2_completed : 1; -endrewards - - - - - diff --git a/examples/multiobjective/mdp/team/origFiles/MDP_a5_r3_t2_full_exp.nm b/examples/multiobjective/mdp/team/origFiles/MDP_a5_r3_t2_full_exp.nm deleted file mode 100644 index 4a02b8746..000000000 --- a/examples/multiobjective/mdp/team/origFiles/MDP_a5_r3_t2_full_exp.nm +++ /dev/null @@ -1,531 +0,0 @@ -mdp - -// parameters -const int n_resources = 3; -const int n_tasks = 2; -const int n_sensors = 5; - - -// sensor resources -const int resource1=1; -const int resource2=2; -const int resource3=3; -const int resource4=1; -const int resource5=2; - -// network configuration -const int e12=1; -const int e13=1; -const int e14=1; -const int e15=1; - -const int e21=e12; -const int e23=1; -const int e24=1; -const int e25=1; - -const int e31=e13; -const int e32=e23; -const int e34=1; -const int e35=1; - -const int e41=e14; -const int e42=e24; -const int e43=e34; -const int e45=1; - -const int e51=e15; -const int e52=e25; -const int e53=e35; -const int e54=e45; - -module controller // schedules the algorithm - - // algorithm status - status : [0..8]; - - // task resource indicator variables - t1_r1 : [0..1]; - t1_r2 : [0..1]; - t1_r3 : [0..1]; - - t2_r1 : [0..1]; - t2_r2 : [0..1]; - t2_r3 : [0..1]; - - // schedule placeholders - turn1 : [0..n_sensors]; - turn2 : [0..n_sensors]; - turn3 : [0..n_sensors]; - turn4 : [0..n_sensors]; - turn5 : [0..n_sensors]; - - // selecting schedule uniformly at random - [] status=0 -> 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=4) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=4) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=5) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=5) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=4) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=4) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=5) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=5) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=2) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=2) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=3) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=3) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=5) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=5) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=2) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=2) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=3) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=3) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=4) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=4) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=4) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=4) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=5) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=5) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=4) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=4) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=5) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=5) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=1) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=1) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=3) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=3) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=5) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=5) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=1) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=1) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=3) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=3) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=4) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=4) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=4) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=4) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=5) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=5) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=4) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=4) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=5) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=5) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=1) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=1) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=2) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=2) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=5) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=5) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=1) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=1) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=2) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=2) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=4) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=4) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=2) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=2) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=3) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=3) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=5) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=5) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=1) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=1) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=3) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=3) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=5) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=5) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=1) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=1) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=2) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=2) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=5) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=5) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=1) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=1) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=2) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=2) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=3) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=3) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=2) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=2) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=3) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=3) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=4) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=4) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=1) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=1) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=3) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=3) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=4) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=4) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=1) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=1) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=2) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=2) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=4) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=4) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=1) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=1) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=2) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=2) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=3) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=3) & (turn4'=2) & (turn5'=1) & (status'=1); - - - // initialising non-empty tasks uniformly at random - [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2); - - // executing the schedule - - // 1st round - [str1] status=2 & turn1=1 -> (status'=2); - [fin1] status=2 & turn1=1 -> (status'=3); - [str2] status=2 & turn1=2 -> (status'=2); - [fin2] status=2 & turn1=2 -> (status'=3); - [str3] status=2 & turn1=3 -> (status'=2); - [fin3] status=2 & turn1=3 -> (status'=3); - [str4] status=2 & turn1=4 -> (status'=2); - [fin4] status=2 & turn1=4 -> (status'=3); - [str5] status=2 & turn1=5 -> (status'=2); - [fin5] status=2 & turn1=5 -> (status'=3); - - // 2nd round - [str1] status=3 & turn2=1 -> (status'=3); - [fin1] status=3 & turn2=1 -> (status'=4); - [str2] status=3 & turn2=2 -> (status'=3); - [fin2] status=3 & turn2=2 -> (status'=4); - [str3] status=3 & turn2=3 -> (status'=3); - [fin3] status=3 & turn2=3 -> (status'=4); - [str4] status=3 & turn2=4 -> (status'=3); - [fin4] status=3 & turn2=4 -> (status'=4); - [str5] status=3 & turn2=5 -> (status'=3); - [fin5] status=3 & turn2=5 -> (status'=4); - - // 3rd round - [str1] status=4 & turn3=1 -> (status'=4); - [fin1] status=4 & turn3=1 -> (status'=5); - [str2] status=4 & turn3=2 -> (status'=4); - [fin2] status=4 & turn3=2 -> (status'=5); - [str3] status=4 & turn3=3 -> (status'=4); - [fin3] status=4 & turn3=3 -> (status'=5); - [str4] status=4 & turn3=4 -> (status'=4); - [fin4] status=4 & turn3=4 -> (status'=5); - [str5] status=4 & turn3=5 -> (status'=4); - [fin5] status=4 & turn3=5 -> (status'=5); - - // 4th round - [str1] status=5 & turn4=1 -> (status'=5); - [fin1] status=5 & turn4=1 -> (status'=6); - [str2] status=5 & turn4=2 -> (status'=5); - [fin2] status=5 & turn4=2 -> (status'=6); - [str3] status=5 & turn4=3 -> (status'=5); - [fin3] status=5 & turn4=3 -> (status'=6); - [str4] status=5 & turn4=4 -> (status'=5); - [fin4] status=5 & turn4=4 -> (status'=6); - [str5] status=5 & turn4=5 -> (status'=5); - [fin5] status=5 & turn4=5 -> (status'=6); - - // 5th round - [str1] status=6 & turn5=1 -> (status'=6); - [fin1] status=6 & turn5=1 -> (status'=7); - [str2] status=6 & turn5=2 -> (status'=6); - [fin2] status=6 & turn5=2 -> (status'=7); - [str3] status=6 & turn5=3 -> (status'=6); - [fin3] status=6 & turn5=3 -> (status'=7); - [str4] status=6 & turn5=4 -> (status'=6); - [fin4] status=6 & turn5=4 -> (status'=7); - [str5] status=6 & turn5=5 -> (status'=6); - [fin5] status=6 & turn5=5 -> (status'=7); - - [] status=7 -> (status'=8); - - [] status=8 -> (status'=8); - -endmodule - -module sensor1 - - state1 : [0..1]; - - // team membership indicators - m1_t1 : [0..1]; - m1_t2 : [0..1]; - - // starting turn, selecting order of tasks - [str1] state1=0 -> (state1'=1); - - // if there is no team and has required skill - initiating the team - [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1); - - // if team already exists and one of the neighbours is in it - joining the team - [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1); - - [fin1] state1>0 -> (state1'=0); - -endmodule - -module sensor2 = sensor1 -[ - state1=state2, - - str1=str2, - fin1=fin2, - - m1_t1=m2_t1, - m1_t2=m2_t2, - - m2_t1=m1_t1, - m2_t2=m1_t2, - - resource1=resource2, - resource2=resource1, - - e12=e21, - e13=e23, - e14=e24, - e15=e25, - - e21=e12, - e23=e13, - e24=e14, - e25=e15 -] -endmodule - -module sensor3 = sensor1 -[ - state1=state3, - - str1=str3, - fin1=fin3, - - m1_t1=m3_t1, - m1_t2=m3_t2, - m3_t1=m1_t1, - m3_t2=m1_t2, - - resource1=resource3, - resource3=resource1, - - e12=e32, - e13=e31, - e14=e34, - e15=e35, - - e31=e13, - e32=e12, - e34=e14, - e35=e15 -] -endmodule - -module sensor4 = sensor1 -[ - state1=state4, - - str1=str4, - fin1=fin4, - - m1_t1=m4_t1, - m1_t2=m4_t2, - - m4_t1=m1_t1, - m4_t2=m1_t2, - - resource1=resource4, - resource4=resource1, - - e12=e42, - e13=e43, - e14=e41, - e15=e45, - - e41=e14, - e42=e12, - e43=e13, - e45=e15 -] -endmodule - -module sensor5 = sensor1 -[ - state1=state5, - - str1=str5, - fin1=fin5, - - m1_t1=m5_t1, - m1_t2=m5_t2, - - m5_t1=m1_t1, - m5_t2=m1_t2, - - resource1=resource5, - resource5=resource1, - - e12=e52, - e13=e53, - e14=e54, - e15=e51, - - e51=e15, - e52=e12, - e53=e13, - e54=e14 -] -endmodule - -// formulae for scheduling -formula s1_sched = (turn1=1 | turn2=1 | turn3=1 | turn4=1 | turn5=1); -formula s2_sched = (turn1=2 | turn2=2 | turn3=2 | turn4=2 | turn5=2); -formula s3_sched = (turn1=3 | turn2=3 | turn3=3 | turn4=3 | turn5=3); -formula s4_sched = (turn1=4 | turn2=4 | turn3=4 | turn4=4 | turn5=4); -formula s5_sched = (turn1=5 | turn2=5 | turn3=5 | turn4=5 | turn5=5); -formula all_not_sched = !(s1_sched | s2_sched | s3_sched | s4_sched | s5_sched); -formula all_sched = (s1_sched & s2_sched & s3_sched & s4_sched & s5_sched); - - -// agent is committed to some team -formula committed = (m1_t1+m1_t2) > 0; - -// formulae to compute team sizes -formula team_size_t1 = m1_t1+m2_t1+m3_t1+m4_t1+m5_t1; -formula team_size_t2 = m1_t2+m2_t2+m3_t2+m4_t2+m5_t2; - -// formulae to check whether the agent can join the team -formula can_join_t1 = e12*m2_t1 + e13*m3_t1 + e14*m4_t1 + e15*m5_t1 > 0; -formula can_join_t2 = e12*m2_t2 + e13*m3_t2 + e14*m4_t2 + e15*m5_t2 > 0; - -// formulae to check whether agent has the resource required by the task -formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) ); -formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) ); - -// formulae to check whether the resource of an agent has been already filled in the team -formula resource_filled_t1 = (m2_t1=1 & resource1=resource2) | (m3_t1=1 & resource1=resource3) | (m4_t1=1 & resource1=resource4) | (m5_t1=1 & resource1=resource5); -formula resource_filled_t2 = (m2_t2=1 & resource1=resource2) | (m3_t2=1 & resource1=resource3) | (m4_t2=1 & resource1=resource4) | (m5_t2=1 & resource1=resource5); - -// formula to compute team initiation probability (assuming each agent has at least one connection) -formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))+e13*(1-((m3_t1+m3_t2)=0?0:1))+e14*(1-((m4_t1+m4_t2)=0?0:1))+e15*(1-((m5_t1+m5_t2)=0?0:1))) / (e12+e13+e14+e15); - - - - -// labels and formulae for property specification -formula finished = (status=7); -label "end" = (status=8); - - -formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1); -formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1); -formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2); -formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3); - -formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1); -formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1); -formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2); -formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3); - -formula agent3_joins_successful_team = (task1_completed & m3_t1=1) | (task2_completed & m3_t2=1); -formula agent3_joins_successful_team_of_1 = (task1_completed & m3_t1=1 & team_size_t1=1) | (task2_completed & m3_t2=1 & team_size_t2=1); -formula agent3_joins_successful_team_of_2 = (task1_completed & m3_t1=1 & team_size_t1=2) | (task2_completed & m3_t2=1 & team_size_t2=2); -formula agent3_joins_successful_team_of_3 = (task1_completed & m3_t1=1 & team_size_t1=3) | (task2_completed & m3_t2=1 & team_size_t2=3); - -formula agent4_joins_successful_team = (task1_completed & m4_t1=1) | (task2_completed & m4_t2=1); -formula agent4_joins_successful_team_of_1 = (task1_completed & m4_t1=1 & team_size_t1=1) | (task2_completed & m4_t2=1 & team_size_t2=1); -formula agent4_joins_successful_team_of_2 = (task1_completed & m4_t1=1 & team_size_t1=2) | (task2_completed & m4_t2=1 & team_size_t2=2); -formula agent4_joins_successful_team_of_3 = (task1_completed & m4_t1=1 & team_size_t1=3) | (task2_completed & m4_t2=1 & team_size_t2=3); - -formula agent5_joins_successful_team = (task1_completed & m5_t1=1) | (task2_completed & m5_t2=1); -formula agent5_joins_successful_team_of_1 = (task1_completed & m5_t1=1 & team_size_t1=1) | (task2_completed & m5_t2=1 & team_size_t2=1); -formula agent5_joins_successful_team_of_2 = (task1_completed & m5_t1=1 & team_size_t1=2) | (task2_completed & m5_t2=1 & team_size_t2=2); -formula agent5_joins_successful_team_of_3 = (task1_completed & m5_t1=1 & team_size_t1=3) | (task2_completed & m5_t2=1 & team_size_t2=3); - -formula task1_completed = finished - & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1)|(m3_t1=1&resource3=1)|(m4_t1=1&resource4=1)|(m5_t1=1&resource5=1))) - & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2)|(m3_t1=1&resource3=2)|(m4_t1=1&resource4=2)|(m5_t1=1&resource5=2))) - & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3)|(m3_t1=1&resource3=3)|(m4_t1=1&resource4=3)|(m5_t1=1&resource5=3))); - -formula task2_completed = finished - & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1)|(m3_t2=1&resource3=1)|(m4_t2=1&resource4=1)|(m5_t2=1&resource5=1))) - & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2)|(m3_t2=1&resource3=2)|(m4_t2=1&resource4=2)|(m5_t2=1&resource5=2))) - & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3)|(m3_t2=1&resource3=3)|(m4_t2=1&resource4=3)|(m5_t2=1&resource5=3))); - -// rewards -rewards "w_1_total" - [] agent1_joins_successful_team : 1; - [] agent2_joins_successful_team : 1; - [] agent3_joins_successful_team : 1; - [] agent4_joins_successful_team : 1; - [] agent5_joins_successful_team : 1; -endrewards - -rewards "w_2_total" - [] task1_completed : 1; - [] task2_completed : 1; -endrewards - - - - - diff --git a/examples/multiobjective/mdp/team/origFiles/team.pctl b/examples/multiobjective/mdp/team/origFiles/team.pctl deleted file mode 100644 index 6d262eceb..000000000 --- a/examples/multiobjective/mdp/team/origFiles/team.pctl +++ /dev/null @@ -1,45 +0,0 @@ - -// Max probability of completing task 1 -"single_task1": Pmax=? [ F task1_completed ] - -// Max possible expected W1 (size of successful team) -"single_w1": R{"w_1_total"}max=? [ F "end" ] - -// Max possible expected W2 (num tasks completed) -"single_w2": R{"w_2_total"}max=? [ F "end" ] - -// Values computed using above queries: -const double q1 = -n_sensors=2 ? 0.9795918367346945 : -n_sensors=3 ? 2.3265306122448983 : -n_sensors=4 ? 2.551020408163265 : -n_sensors=5 ? 2.8979591836734775 : -0.0; - -const double q2 = -n_sensors=2 ? 0.7142857142857146 : -n_sensors=3 ? 1.2448979591836744 : -n_sensors=4 ? 1.4285714285714293 : -n_sensors=5 ? 1.6734693877551006 : -0.0; - -// Numerical: maximise probability of completing task 1 -// with 95% of possible value for expected W1 (size of successful team) -"num_task1": multi(Pmax=? [ F task1_completed ], R{"w_1_total"}>=(0.95*q1) [ F true ]) - -// Numerical (3-objective): maximise probability of completing task 1 -// with 95% of possible value for expected W1 (size of successful team) -// and also at least 0.5 probability of completing task 2 -"num_task1_3": multi(Pmax=? [ F task1_completed ], R{"w_1_total"}>=(0.95*q1) [ F true ], P>=0.5 [ F task2_completed ]) - -// Other numerical queries: - -multi(R{"w_1_total"}max=? [ F true ], R{"w_2_total"}>=(0.95*q2) [ F true ]) - -multi(R{"w_2_total"}max=? [ F true ], R{"w_1_total"}>=(0.95*q1) [ F true ]) - -// Pareto: maximise probability of completing task 1 and expected W1 (size of successful team) -"pareto": multi(Pmax=? [ F task1_completed ], R{"w_1_total"}max=? [ F true ]) - -// Pareto (3-objective): maximise probability of completing tasks 1/2 and expected W1 (size of successful team) -"pareto3": multi(Pmax=? [ F task1_completed ], R{"w_1_total"}max=? [ F true ], Pmax=? [ F task2_completed ]) diff --git a/examples/multiobjective/mdp/team/team2obj_3.nm b/examples/multiobjective/mdp/team/team2obj_3.nm deleted file mode 100644 index cd17863ca..000000000 --- a/examples/multiobjective/mdp/team/team2obj_3.nm +++ /dev/null @@ -1,286 +0,0 @@ -mdp - -// parameters -const int n_resources = 3; -const int n_tasks = 2; -const int n_sensors = 3; - - -// sensor resources -const int resource1=1; -const int resource2=2; -const int resource3=3; - -// network configuration -const int e12=1; -const int e13=1; - -const int e21=e12; -const int e23=1; - -const int e31=e13; -const int e32=e23; - - -// agent is committed to some team -formula committed = (m1_t1+m1_t2) > 0; - -// formulae to compute team sizes -formula team_size_t1 = m1_t1+m2_t1+m3_t1; -formula team_size_t2 = m1_t2+m2_t2+m3_t2; - -// formulae to check whether the agent can join the team -formula can_join_t1 = e12*m2_t1 + e13*m3_t1 > 0; -formula can_join_t2 = e12*m2_t2 + e13*m3_t2 > 0; - -// formulae to check whether agent has the resource required by the task -formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) ); -formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) ); - -// formulae to check whether the resource of an agent has been already filled in the team -formula resource_filled_t1 = (m2_t1=1 & resource1=resource2) | (m3_t1=1 & resource1=resource3); -formula resource_filled_t2 = (m2_t2=1 & resource1=resource2) | (m3_t2=1 & resource1=resource3); - -// formula to compute team initiation probability (assuming each agent has at least one connection) -formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))+e13*(1-((m3_t1+m3_t2)=0?0:1))) / (e12+e13); - -module controller // schedules the algorithm - - // algorithm status - status : [0..6]; - - // task resource indicator variables - t1_r1 : [0..1]; - t1_r2 : [0..1]; - t1_r3 : [0..1]; - - t2_r1 : [0..1]; - t2_r2 : [0..1]; - t2_r3 : [0..1]; - - // schedule placeholders - turn1 : [0..n_sensors]; - turn2 : [0..n_sensors]; - turn3 : [0..n_sensors]; - - // selecting schedule uniformly at random - [] status=0 -> 1/6 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (status'=1) - + 1/6 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (status'=1) - + 1/6 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (status'=1) - + 1/6 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (status'=1) - + 1/6 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (status'=1) - + 1/6 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (status'=1); - - - // initialising non-empty tasks uniformly at random - [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2); - - // executing the schedule - - // 1st round - [str1] status=2 & turn1=1 -> (status'=2); - [fin1] status=2 & turn1=1 -> (status'=3); - [str2] status=2 & turn1=2 -> (status'=2); - [fin2] status=2 & turn1=2 -> (status'=3); - [str3] status=2 & turn1=3 -> (status'=2); - [fin3] status=2 & turn1=3 -> (status'=3); - - // 2nd round - [str1] status=3 & turn2=1 -> (status'=3); - [fin1] status=3 & turn2=1 -> (status'=4); - [str2] status=3 & turn2=2 -> (status'=3); - [fin2] status=3 & turn2=2 -> (status'=4); - [str3] status=3 & turn2=3 -> (status'=3); - [fin3] status=3 & turn2=3 -> (status'=4); - - // 3rd round - [str1] status=4 & turn3=1 -> (status'=4); - [fin1] status=4 & turn3=1 -> (status'=5); - [str2] status=4 & turn3=2 -> (status'=4); - [fin2] status=4 & turn3=2 -> (status'=5); - [str3] status=4 & turn3=3 -> (status'=4); - [fin3] status=4 & turn3=3 -> (status'=5); - - [] status=5 -> (status'=6); - - [] status=6 -> true; - -endmodule - -module sensor1 - - state1 : [0..1]; - - // team membership indicators - m1_t1 : [0..1]; - m1_t2 : [0..1]; - - // starting turn, selecting order of tasks - [str1] state1=0 -> (state1'=1); - - // if there is no team and has required skill - initiating the team - [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1); - - // if team already exists and one of the neighbours is in it - joining the team - [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1); - - [fin1] state1>0 -> (state1'=0); - -endmodule - -module sensor2 = sensor1 -[ - state1=state2, - - str1=str2, - fin1=fin2, - - m1_t1=m2_t1, - m1_t2=m2_t2, - - m2_t1=m1_t1, - m2_t2=m1_t2, - - resource1=resource2, - resource2=resource1, - - e12=e21, - e13=e23, - e14=e24, - e15=e25, - - e21=e12, - e23=e13, - e24=e14, - e25=e15 -] -endmodule - -module sensor3 = sensor1 -[ - state1=state3, - - str1=str3, - fin1=fin3, - - m1_t1=m3_t1, - m1_t2=m3_t2, - m3_t1=m1_t1, - m3_t2=m1_t2, - - resource1=resource3, - resource3=resource1, - - e12=e32, - e13=e31, - e14=e34, - e15=e35, - - e31=e13, - e32=e12, - e34=e14, - e35=e15 -] -endmodule - - - - - -// labels and formulae for property specification -formula finished = (status=5); -label "end" = (status=6); - - -formula task1_completed = finished - & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1)|(m3_t1=1&resource3=1))) - & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2)|(m3_t1=1&resource3=2))) - & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3)|(m3_t1=1&resource3=3))); - -formula task2_completed = finished - & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1)|(m3_t2=1&resource3=1))) - & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2)|(m3_t2=1&resource3=2))) - & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3)|(m3_t2=1&resource3=3))); - - - -formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1); -formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1); -formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2); -formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3); - -formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1); -formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1); -formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2); -formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3); - -formula agent3_joins_successful_team = (task1_completed & m3_t1=1) | (task2_completed & m3_t2=1); -formula agent3_joins_successful_team_of_1 = (task1_completed & m3_t1=1 & team_size_t1=1) | (task2_completed & m3_t2=1 & team_size_t2=1); -formula agent3_joins_successful_team_of_2 = (task1_completed & m3_t1=1 & team_size_t1=2) | (task2_completed & m3_t2=1 & team_size_t2=2); -formula agent3_joins_successful_team_of_3 = (task1_completed & m3_t1=1 & team_size_t1=3) | (task2_completed & m3_t2=1 & team_size_t2=3); - -// rewards -rewards "w_1_total" - [] agent1_joins_successful_team : 1; - [] agent2_joins_successful_team : 1; - [] agent3_joins_successful_team : 1; -endrewards - -rewards "w_2_total" - [] task1_completed : 1; - [] task2_completed : 1; -endrewards - - - - diff --git a/examples/multiobjective/mdp/team/team2obj_3_numerical.pctl b/examples/multiobjective/mdp/team/team2obj_3_numerical.pctl deleted file mode 100644 index f6a4553cb..000000000 --- a/examples/multiobjective/mdp/team/team2obj_3_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}>=2.210204082 [ C ]) diff --git a/examples/multiobjective/mdp/team/team2obj_3_pareto.pctl b/examples/multiobjective/mdp/team/team2obj_3_pareto.pctl deleted file mode 100644 index 636cd1772..000000000 --- a/examples/multiobjective/mdp/team/team2obj_3_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}max=? [ C ]) diff --git a/examples/multiobjective/mdp/team/team2obj_4.nm b/examples/multiobjective/mdp/team/team2obj_4.nm deleted file mode 100644 index 2ad4536e3..000000000 --- a/examples/multiobjective/mdp/team/team2obj_4.nm +++ /dev/null @@ -1,368 +0,0 @@ -mdp - -// parameters -const int n_resources = 3; -const int n_tasks = 2; -const int n_sensors = 4; - - -// sensor resources -const int resource1=1; -const int resource2=2; -const int resource3=3; -const int resource4=1; - -// network configuration -const int e12=1; -const int e13=1; -const int e14=1; - -const int e21=e12; -const int e23=1; -const int e24=1; - -const int e31=e13; -const int e32=e23; -const int e34=1; - -const int e41=e14; -const int e42=e24; -const int e43=e34; - - - - -// agent is committed to some team -formula committed = (m1_t1+m1_t2) > 0; - -// formulae to compute team sizes -formula team_size_t1 = m1_t1+m2_t1+m3_t1+m4_t1; -formula team_size_t2 = m1_t2+m2_t2+m3_t2+m4_t2; - -// formulae to check whether the agent can join the team -formula can_join_t1 = e12*m2_t1 + e13*m3_t1 + e14*m4_t1 > 0; -formula can_join_t2 = e12*m2_t2 + e13*m3_t2 + e14*m4_t2 > 0; - -// formulae to check whether agent has the resource required by the task -formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) ); -formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) ); - -// formulae to check whether the resource of an agent has been already filled in the team -formula resource_filled_t1 = (m2_t1=1 & resource1=resource2) | (m3_t1=1 & resource1=resource3) | (m4_t1=1 & resource1=resource4); -formula resource_filled_t2 = (m2_t2=1 & resource1=resource2) | (m3_t2=1 & resource1=resource3) | (m4_t2=1 & resource1=resource4); - -// formula to compute team initiation probability (assuming each agent has at least one connection) -formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))+e13*(1-((m3_t1+m3_t2)=0?0:1))+e14*(1-((m4_t1+m4_t2)=0?0:1))) / (e12+e13+e14); - - - -module controller // schedules the algorithm - - // algorithm status - status : [0..7]; - - // task resource indicator variables - t1_r1 : [0..1]; - t1_r2 : [0..1]; - t1_r3 : [0..1]; - - t2_r1 : [0..1]; - t2_r2 : [0..1]; - t2_r3 : [0..1]; - - // schedule placeholders - turn1 : [0..n_sensors]; - turn2 : [0..n_sensors]; - turn3 : [0..n_sensors]; - turn4 : [0..n_sensors]; - turn5 : [0..n_sensors]; - - // selecting schedule uniformly at random - [] status=0 -> 1/24 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=2) & (turn3'=4) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=3) & (turn3'=4) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=4) & (turn3'=2) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=4) & (turn3'=3) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=1) & (turn3'=4) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=3) & (turn3'=4) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=4) & (turn3'=1) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=4) & (turn3'=3) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=1) & (turn3'=4) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=2) & (turn3'=4) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=4) & (turn3'=1) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=4) & (turn3'=2) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=1) & (turn3'=2) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=1) & (turn3'=3) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=2) & (turn3'=1) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=2) & (turn3'=3) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=3) & (turn3'=1) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=3) & (turn3'=2) & (turn4'=1) & (status'=1); - - - // initialising non-empty tasks uniformly at random - [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2); - - // executing the schedule - - // 1st round - [str1] status=2 & turn1=1 -> (status'=2); - [fin1] status=2 & turn1=1 -> (status'=3); - [str2] status=2 & turn1=2 -> (status'=2); - [fin2] status=2 & turn1=2 -> (status'=3); - [str3] status=2 & turn1=3 -> (status'=2); - [fin3] status=2 & turn1=3 -> (status'=3); - [str4] status=2 & turn1=4 -> (status'=2); - [fin4] status=2 & turn1=4 -> (status'=3); - - // 2nd round - [str1] status=3 & turn2=1 -> (status'=3); - [fin1] status=3 & turn2=1 -> (status'=4); - [str2] status=3 & turn2=2 -> (status'=3); - [fin2] status=3 & turn2=2 -> (status'=4); - [str3] status=3 & turn2=3 -> (status'=3); - [fin3] status=3 & turn2=3 -> (status'=4); - [str4] status=3 & turn2=4 -> (status'=3); - [fin4] status=3 & turn2=4 -> (status'=4); - - // 3rd round - [str1] status=4 & turn3=1 -> (status'=4); - [fin1] status=4 & turn3=1 -> (status'=5); - [str2] status=4 & turn3=2 -> (status'=4); - [fin2] status=4 & turn3=2 -> (status'=5); - [str3] status=4 & turn3=3 -> (status'=4); - [fin3] status=4 & turn3=3 -> (status'=5); - [str4] status=4 & turn3=4 -> (status'=4); - [fin4] status=4 & turn3=4 -> (status'=5); - - // 4th round - [str1] status=5 & turn4=1 -> (status'=5); - [fin1] status=5 & turn4=1 -> (status'=6); - [str2] status=5 & turn4=2 -> (status'=5); - [fin2] status=5 & turn4=2 -> (status'=6); - [str3] status=5 & turn4=3 -> (status'=5); - [fin3] status=5 & turn4=3 -> (status'=6); - [str4] status=5 & turn4=4 -> (status'=5); - [fin4] status=5 & turn4=4 -> (status'=6); - - [] status=6 -> (status'=7); - - [] status=7 -> (status'=7); - -endmodule - -module sensor1 - - state1 : [0..1]; - - // team membership indicators - m1_t1 : [0..1]; - m1_t2 : [0..1]; - - // starting turn, selecting order of tasks - [str1] state1=0 -> (state1'=1); - - // if there is no team and has required skill - initiating the team - [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1); - - // if team already exists and one of the neighbours is in it - joining the team - [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1); - - [fin1] state1>0 -> (state1'=0); - -endmodule - -module sensor2 = sensor1 -[ - state1=state2, - - str1=str2, - fin1=fin2, - - m1_t1=m2_t1, - m1_t2=m2_t2, - - m2_t1=m1_t1, - m2_t2=m1_t2, - - resource1=resource2, - resource2=resource1, - - e12=e21, - e13=e23, - e14=e24, - e15=e25, - - e21=e12, - e23=e13, - e24=e14, - e25=e15 -] -endmodule - -module sensor3 = sensor1 -[ - state1=state3, - - str1=str3, - fin1=fin3, - - m1_t1=m3_t1, - m1_t2=m3_t2, - m3_t1=m1_t1, - m3_t2=m1_t2, - - resource1=resource3, - resource3=resource1, - - e12=e32, - e13=e31, - e14=e34, - e15=e35, - - e31=e13, - e32=e12, - e34=e14, - e35=e15 -] -endmodule - -module sensor4 = sensor1 -[ - state1=state4, - - str1=str4, - fin1=fin4, - - m1_t1=m4_t1, - m1_t2=m4_t2, - - m4_t1=m1_t1, - m4_t2=m1_t2, - - resource1=resource4, - resource4=resource1, - - e12=e42, - e13=e43, - e14=e41, - e15=e45, - - e41=e14, - e42=e12, - e43=e13, - e45=e15 -] -endmodule - - - - - -// labels and formulae for property specification -formula finished = (status=6); -label "end" = (status=7); - - -formula task1_completed = finished - & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1)|(m3_t1=1&resource3=1)|(m4_t1=1&resource4=1))) - & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2)|(m3_t1=1&resource3=2)|(m4_t1=1&resource4=2))) - & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3)|(m3_t1=1&resource3=3)|(m4_t1=1&resource4=3))); - -formula task2_completed = finished - & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1)|(m3_t2=1&resource3=1)|(m4_t2=1&resource4=1))) - & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2)|(m3_t2=1&resource3=2)|(m4_t2=1&resource4=2))) - & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3)|(m3_t2=1&resource3=3)|(m4_t2=1&resource4=3))); - - -formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1); -formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1); -formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2); -formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3); - -formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1); -formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1); -formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2); -formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3); - -formula agent3_joins_successful_team = (task1_completed & m3_t1=1) | (task2_completed & m3_t2=1); -formula agent3_joins_successful_team_of_1 = (task1_completed & m3_t1=1 & team_size_t1=1) | (task2_completed & m3_t2=1 & team_size_t2=1); -formula agent3_joins_successful_team_of_2 = (task1_completed & m3_t1=1 & team_size_t1=2) | (task2_completed & m3_t2=1 & team_size_t2=2); -formula agent3_joins_successful_team_of_3 = (task1_completed & m3_t1=1 & team_size_t1=3) | (task2_completed & m3_t2=1 & team_size_t2=3); - -formula agent4_joins_successful_team = (task1_completed & m4_t1=1) | (task2_completed & m4_t2=1); -formula agent4_joins_successful_team_of_1 = (task1_completed & m4_t1=1 & team_size_t1=1) | (task2_completed & m4_t2=1 & team_size_t2=1); -formula agent4_joins_successful_team_of_2 = (task1_completed & m4_t1=1 & team_size_t1=2) | (task2_completed & m4_t2=1 & team_size_t2=2); -formula agent4_joins_successful_team_of_3 = (task1_completed & m4_t1=1 & team_size_t1=3) | (task2_completed & m4_t2=1 & team_size_t2=3); - -// rewards -rewards "w_1_total" - [] agent1_joins_successful_team : 1; - [] agent2_joins_successful_team : 1; - [] agent3_joins_successful_team : 1; - [] agent4_joins_successful_team : 1; -endrewards - -rewards "w_2_total" - [] task1_completed : 1; - [] task2_completed : 1; -endrewards - - - - - diff --git a/examples/multiobjective/mdp/team/team2obj_4_numerical.pctl b/examples/multiobjective/mdp/team/team2obj_4_numerical.pctl deleted file mode 100644 index 9cb290800..000000000 --- a/examples/multiobjective/mdp/team/team2obj_4_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}>=2.423469388 [ C ]) diff --git a/examples/multiobjective/mdp/team/team2obj_4_pareto.pctl b/examples/multiobjective/mdp/team/team2obj_4_pareto.pctl deleted file mode 100644 index 636cd1772..000000000 --- a/examples/multiobjective/mdp/team/team2obj_4_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}max=? [ C ]) diff --git a/examples/multiobjective/mdp/team/team2obj_5.nm b/examples/multiobjective/mdp/team/team2obj_5.nm deleted file mode 100644 index 2bab4d7f4..000000000 --- a/examples/multiobjective/mdp/team/team2obj_5.nm +++ /dev/null @@ -1,532 +0,0 @@ -mdp - -// parameters -const int n_resources = 3; -const int n_tasks = 2; -const int n_sensors = 5; - - -// sensor resources -const int resource1=1; -const int resource2=2; -const int resource3=3; -const int resource4=1; -const int resource5=2; - -// network configuration -const int e12=1; -const int e13=1; -const int e14=1; -const int e15=1; - -const int e21=e12; -const int e23=1; -const int e24=1; -const int e25=1; - -const int e31=e13; -const int e32=e23; -const int e34=1; -const int e35=1; - -const int e41=e14; -const int e42=e24; -const int e43=e34; -const int e45=1; - -const int e51=e15; -const int e52=e25; -const int e53=e35; -const int e54=e45; - - -// agent is committed to some team -formula committed = (m1_t1+m1_t2) > 0; - -// formulae to compute team sizes -formula team_size_t1 = m1_t1+m2_t1+m3_t1+m4_t1+m5_t1; -formula team_size_t2 = m1_t2+m2_t2+m3_t2+m4_t2+m5_t2; - -// formulae to check whether the agent can join the team -formula can_join_t1 = e12*m2_t1 + e13*m3_t1 + e14*m4_t1 + e15*m5_t1 > 0; -formula can_join_t2 = e12*m2_t2 + e13*m3_t2 + e14*m4_t2 + e15*m5_t2 > 0; - -// formulae to check whether agent has the resource required by the task -formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) ); -formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) ); - -// formulae to check whether the resource of an agent has been already filled in the team -formula resource_filled_t1 = (m2_t1=1 & resource1=resource2) | (m3_t1=1 & resource1=resource3) | (m4_t1=1 & resource1=resource4) | (m5_t1=1 & resource1=resource5); -formula resource_filled_t2 = (m2_t2=1 & resource1=resource2) | (m3_t2=1 & resource1=resource3) | (m4_t2=1 & resource1=resource4) | (m5_t2=1 & resource1=resource5); - -// formula to compute team initiation probability (assuming each agent has at least one connection) -formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))+e13*(1-((m3_t1+m3_t2)=0?0:1))+e14*(1-((m4_t1+m4_t2)=0?0:1))+e15*(1-((m5_t1+m5_t2)=0?0:1))) / (e12+e13+e14+e15); - - - -module controller // schedules the algorithm - - // algorithm status - status : [0..8]; - - // task resource indicator variables - t1_r1 : [0..1]; - t1_r2 : [0..1]; - t1_r3 : [0..1]; - - t2_r1 : [0..1]; - t2_r2 : [0..1]; - t2_r3 : [0..1]; - - // schedule placeholders - turn1 : [0..n_sensors]; - turn2 : [0..n_sensors]; - turn3 : [0..n_sensors]; - turn4 : [0..n_sensors]; - turn5 : [0..n_sensors]; - - // selecting schedule uniformly at random - [] status=0 -> 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=4) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=4) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=5) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=5) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=4) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=4) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=5) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=5) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=2) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=2) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=3) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=3) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=5) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=5) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=2) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=2) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=3) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=3) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=4) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=4) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=4) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=4) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=5) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=5) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=4) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=4) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=5) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=5) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=1) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=1) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=3) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=3) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=5) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=5) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=1) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=1) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=3) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=3) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=4) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=4) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=4) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=4) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=5) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=5) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=4) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=4) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=5) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=5) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=1) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=1) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=2) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=2) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=5) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=5) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=1) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=1) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=2) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=2) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=4) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=4) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=2) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=2) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=3) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=3) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=5) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=5) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=1) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=1) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=3) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=3) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=5) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=5) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=1) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=1) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=2) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=2) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=5) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=5) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=1) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=1) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=2) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=2) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=3) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=3) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=2) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=2) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=3) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=3) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=4) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=4) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=1) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=1) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=3) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=3) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=4) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=4) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=1) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=1) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=2) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=2) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=4) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=4) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=1) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=1) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=2) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=2) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=3) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=3) & (turn4'=2) & (turn5'=1) & (status'=1); - - - // initialising non-empty tasks uniformly at random - [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2); - - // executing the schedule - - // 1st round - [str1] status=2 & turn1=1 -> (status'=2); - [fin1] status=2 & turn1=1 -> (status'=3); - [str2] status=2 & turn1=2 -> (status'=2); - [fin2] status=2 & turn1=2 -> (status'=3); - [str3] status=2 & turn1=3 -> (status'=2); - [fin3] status=2 & turn1=3 -> (status'=3); - [str4] status=2 & turn1=4 -> (status'=2); - [fin4] status=2 & turn1=4 -> (status'=3); - [str5] status=2 & turn1=5 -> (status'=2); - [fin5] status=2 & turn1=5 -> (status'=3); - - // 2nd round - [str1] status=3 & turn2=1 -> (status'=3); - [fin1] status=3 & turn2=1 -> (status'=4); - [str2] status=3 & turn2=2 -> (status'=3); - [fin2] status=3 & turn2=2 -> (status'=4); - [str3] status=3 & turn2=3 -> (status'=3); - [fin3] status=3 & turn2=3 -> (status'=4); - [str4] status=3 & turn2=4 -> (status'=3); - [fin4] status=3 & turn2=4 -> (status'=4); - [str5] status=3 & turn2=5 -> (status'=3); - [fin5] status=3 & turn2=5 -> (status'=4); - - // 3rd round - [str1] status=4 & turn3=1 -> (status'=4); - [fin1] status=4 & turn3=1 -> (status'=5); - [str2] status=4 & turn3=2 -> (status'=4); - [fin2] status=4 & turn3=2 -> (status'=5); - [str3] status=4 & turn3=3 -> (status'=4); - [fin3] status=4 & turn3=3 -> (status'=5); - [str4] status=4 & turn3=4 -> (status'=4); - [fin4] status=4 & turn3=4 -> (status'=5); - [str5] status=4 & turn3=5 -> (status'=4); - [fin5] status=4 & turn3=5 -> (status'=5); - - // 4th round - [str1] status=5 & turn4=1 -> (status'=5); - [fin1] status=5 & turn4=1 -> (status'=6); - [str2] status=5 & turn4=2 -> (status'=5); - [fin2] status=5 & turn4=2 -> (status'=6); - [str3] status=5 & turn4=3 -> (status'=5); - [fin3] status=5 & turn4=3 -> (status'=6); - [str4] status=5 & turn4=4 -> (status'=5); - [fin4] status=5 & turn4=4 -> (status'=6); - [str5] status=5 & turn4=5 -> (status'=5); - [fin5] status=5 & turn4=5 -> (status'=6); - - // 5th round - [str1] status=6 & turn5=1 -> (status'=6); - [fin1] status=6 & turn5=1 -> (status'=7); - [str2] status=6 & turn5=2 -> (status'=6); - [fin2] status=6 & turn5=2 -> (status'=7); - [str3] status=6 & turn5=3 -> (status'=6); - [fin3] status=6 & turn5=3 -> (status'=7); - [str4] status=6 & turn5=4 -> (status'=6); - [fin4] status=6 & turn5=4 -> (status'=7); - [str5] status=6 & turn5=5 -> (status'=6); - [fin5] status=6 & turn5=5 -> (status'=7); - - [] status=7 -> (status'=8); - - [] status=8 -> (status'=8); - -endmodule - -module sensor1 - - state1 : [0..1]; - - // team membership indicators - m1_t1 : [0..1]; - m1_t2 : [0..1]; - - // starting turn, selecting order of tasks - [str1] state1=0 -> (state1'=1); - - // if there is no team and has required skill - initiating the team - [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1); - - // if team already exists and one of the neighbours is in it - joining the team - [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1); - - [fin1] state1>0 -> (state1'=0); - -endmodule - -module sensor2 = sensor1 -[ - state1=state2, - - str1=str2, - fin1=fin2, - - m1_t1=m2_t1, - m1_t2=m2_t2, - - m2_t1=m1_t1, - m2_t2=m1_t2, - - resource1=resource2, - resource2=resource1, - - e12=e21, - e13=e23, - e14=e24, - e15=e25, - - e21=e12, - e23=e13, - e24=e14, - e25=e15 -] -endmodule - -module sensor3 = sensor1 -[ - state1=state3, - - str1=str3, - fin1=fin3, - - m1_t1=m3_t1, - m1_t2=m3_t2, - m3_t1=m1_t1, - m3_t2=m1_t2, - - resource1=resource3, - resource3=resource1, - - e12=e32, - e13=e31, - e14=e34, - e15=e35, - - e31=e13, - e32=e12, - e34=e14, - e35=e15 -] -endmodule - -module sensor4 = sensor1 -[ - state1=state4, - - str1=str4, - fin1=fin4, - - m1_t1=m4_t1, - m1_t2=m4_t2, - - m4_t1=m1_t1, - m4_t2=m1_t2, - - resource1=resource4, - resource4=resource1, - - e12=e42, - e13=e43, - e14=e41, - e15=e45, - - e41=e14, - e42=e12, - e43=e13, - e45=e15 -] -endmodule - -module sensor5 = sensor1 -[ - state1=state5, - - str1=str5, - fin1=fin5, - - m1_t1=m5_t1, - m1_t2=m5_t2, - - m5_t1=m1_t1, - m5_t2=m1_t2, - - resource1=resource5, - resource5=resource1, - - e12=e52, - e13=e53, - e14=e54, - e15=e51, - - e51=e15, - e52=e12, - e53=e13, - e54=e14 -] -endmodule - -// formulae for scheduling -formula s1_sched = (turn1=1 | turn2=1 | turn3=1 | turn4=1 | turn5=1); -formula s2_sched = (turn1=2 | turn2=2 | turn3=2 | turn4=2 | turn5=2); -formula s3_sched = (turn1=3 | turn2=3 | turn3=3 | turn4=3 | turn5=3); -formula s4_sched = (turn1=4 | turn2=4 | turn3=4 | turn4=4 | turn5=4); -formula s5_sched = (turn1=5 | turn2=5 | turn3=5 | turn4=5 | turn5=5); -formula all_not_sched = !(s1_sched | s2_sched | s3_sched | s4_sched | s5_sched); -formula all_sched = (s1_sched & s2_sched & s3_sched & s4_sched & s5_sched); - - -// labels and formulae for property specification -formula finished = (status=7); -label "end" = (status=8); - - -formula task1_completed = finished - & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1)|(m3_t1=1&resource3=1)|(m4_t1=1&resource4=1)|(m5_t1=1&resource5=1))) - & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2)|(m3_t1=1&resource3=2)|(m4_t1=1&resource4=2)|(m5_t1=1&resource5=2))) - & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3)|(m3_t1=1&resource3=3)|(m4_t1=1&resource4=3)|(m5_t1=1&resource5=3))); - -formula task2_completed = finished - & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1)|(m3_t2=1&resource3=1)|(m4_t2=1&resource4=1)|(m5_t2=1&resource5=1))) - & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2)|(m3_t2=1&resource3=2)|(m4_t2=1&resource4=2)|(m5_t2=1&resource5=2))) - & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3)|(m3_t2=1&resource3=3)|(m4_t2=1&resource4=3)|(m5_t2=1&resource5=3))); - - -formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1); -formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1); -formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2); -formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3); - -formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1); -formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1); -formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2); -formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3); - -formula agent3_joins_successful_team = (task1_completed & m3_t1=1) | (task2_completed & m3_t2=1); -formula agent3_joins_successful_team_of_1 = (task1_completed & m3_t1=1 & team_size_t1=1) | (task2_completed & m3_t2=1 & team_size_t2=1); -formula agent3_joins_successful_team_of_2 = (task1_completed & m3_t1=1 & team_size_t1=2) | (task2_completed & m3_t2=1 & team_size_t2=2); -formula agent3_joins_successful_team_of_3 = (task1_completed & m3_t1=1 & team_size_t1=3) | (task2_completed & m3_t2=1 & team_size_t2=3); - -formula agent4_joins_successful_team = (task1_completed & m4_t1=1) | (task2_completed & m4_t2=1); -formula agent4_joins_successful_team_of_1 = (task1_completed & m4_t1=1 & team_size_t1=1) | (task2_completed & m4_t2=1 & team_size_t2=1); -formula agent4_joins_successful_team_of_2 = (task1_completed & m4_t1=1 & team_size_t1=2) | (task2_completed & m4_t2=1 & team_size_t2=2); -formula agent4_joins_successful_team_of_3 = (task1_completed & m4_t1=1 & team_size_t1=3) | (task2_completed & m4_t2=1 & team_size_t2=3); - -formula agent5_joins_successful_team = (task1_completed & m5_t1=1) | (task2_completed & m5_t2=1); -formula agent5_joins_successful_team_of_1 = (task1_completed & m5_t1=1 & team_size_t1=1) | (task2_completed & m5_t2=1 & team_size_t2=1); -formula agent5_joins_successful_team_of_2 = (task1_completed & m5_t1=1 & team_size_t1=2) | (task2_completed & m5_t2=1 & team_size_t2=2); -formula agent5_joins_successful_team_of_3 = (task1_completed & m5_t1=1 & team_size_t1=3) | (task2_completed & m5_t2=1 & team_size_t2=3); - -// rewards -rewards "w_1_total" - [] agent1_joins_successful_team : 1; - [] agent2_joins_successful_team : 1; - [] agent3_joins_successful_team : 1; - [] agent4_joins_successful_team : 1; - [] agent5_joins_successful_team : 1; -endrewards - -rewards "w_2_total" - [] task1_completed : 1; - [] task2_completed : 1; -endrewards - - - - - diff --git a/examples/multiobjective/mdp/team/team2obj_5_numerical.pctl b/examples/multiobjective/mdp/team/team2obj_5_numerical.pctl deleted file mode 100644 index 027c6ef09..000000000 --- a/examples/multiobjective/mdp/team/team2obj_5_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}>=2.753061224 [ C ]) diff --git a/examples/multiobjective/mdp/team/team2obj_5_pareto.pctl b/examples/multiobjective/mdp/team/team2obj_5_pareto.pctl deleted file mode 100644 index 636cd1772..000000000 --- a/examples/multiobjective/mdp/team/team2obj_5_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}max=? [ C ]) diff --git a/examples/multiobjective/mdp/team/team3obj_3.nm b/examples/multiobjective/mdp/team/team3obj_3.nm deleted file mode 100644 index 9e677312d..000000000 --- a/examples/multiobjective/mdp/team/team3obj_3.nm +++ /dev/null @@ -1,288 +0,0 @@ -mdp - -// parameters -const int n_resources = 3; -const int n_tasks = 2; -const int n_sensors = 3; - - -// sensor resources -const int resource1=1; -const int resource2=2; -const int resource3=3; - -// network configuration -const int e12=1; -const int e13=1; - -const int e21=e12; -const int e23=1; - -const int e31=e13; -const int e32=e23; - - - - -// agent is committed to some team -formula committed = (m1_t1+m1_t2) > 0; - -// formulae to compute team sizes -formula team_size_t1 = m1_t1+m2_t1+m3_t1; -formula team_size_t2 = m1_t2+m2_t2+m3_t2; - -// formulae to check whether the agent can join the team -formula can_join_t1 = e12*m2_t1 + e13*m3_t1 > 0; -formula can_join_t2 = e12*m2_t2 + e13*m3_t2 > 0; - -// formulae to check whether agent has the resource required by the task -formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) ); -formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) ); - -// formulae to check whether the resource of an agent has been already filled in the team -formula resource_filled_t1 = (m2_t1=1 & resource1=resource2) | (m3_t1=1 & resource1=resource3); -formula resource_filled_t2 = (m2_t2=1 & resource1=resource2) | (m3_t2=1 & resource1=resource3); - -// formula to compute team initiation probability (assuming each agent has at least one connection) -formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))+e13*(1-((m3_t1+m3_t2)=0?0:1))) / (e12+e13); - - -module controller // schedules the algorithm - - // algorithm status - status : [0..6]; - - // task resource indicator variables - t1_r1 : [0..1]; - t1_r2 : [0..1]; - t1_r3 : [0..1]; - - t2_r1 : [0..1]; - t2_r2 : [0..1]; - t2_r3 : [0..1]; - - // schedule placeholders - turn1 : [0..n_sensors]; - turn2 : [0..n_sensors]; - turn3 : [0..n_sensors]; - - // selecting schedule uniformly at random - [] status=0 -> 1/6 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (status'=1) - + 1/6 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (status'=1) - + 1/6 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (status'=1) - + 1/6 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (status'=1) - + 1/6 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (status'=1) - + 1/6 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (status'=1); - - - // initialising non-empty tasks uniformly at random - [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2); - - // executing the schedule - - // 1st round - [str1] status=2 & turn1=1 -> (status'=2); - [fin1] status=2 & turn1=1 -> (status'=3); - [str2] status=2 & turn1=2 -> (status'=2); - [fin2] status=2 & turn1=2 -> (status'=3); - [str3] status=2 & turn1=3 -> (status'=2); - [fin3] status=2 & turn1=3 -> (status'=3); - - // 2nd round - [str1] status=3 & turn2=1 -> (status'=3); - [fin1] status=3 & turn2=1 -> (status'=4); - [str2] status=3 & turn2=2 -> (status'=3); - [fin2] status=3 & turn2=2 -> (status'=4); - [str3] status=3 & turn2=3 -> (status'=3); - [fin3] status=3 & turn2=3 -> (status'=4); - - // 3rd round - [str1] status=4 & turn3=1 -> (status'=4); - [fin1] status=4 & turn3=1 -> (status'=5); - [str2] status=4 & turn3=2 -> (status'=4); - [fin2] status=4 & turn3=2 -> (status'=5); - [str3] status=4 & turn3=3 -> (status'=4); - [fin3] status=4 & turn3=3 -> (status'=5); - - [] status=5 -> (status'=6); - - [] status=6 -> true; - -endmodule - -module sensor1 - - state1 : [0..1]; - - // team membership indicators - m1_t1 : [0..1]; - m1_t2 : [0..1]; - - // starting turn, selecting order of tasks - [str1] state1=0 -> (state1'=1); - - // if there is no team and has required skill - initiating the team - [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1); - - // if team already exists and one of the neighbours is in it - joining the team - [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1); - - [fin1] state1>0 -> (state1'=0); - -endmodule - -module sensor2 = sensor1 -[ - state1=state2, - - str1=str2, - fin1=fin2, - - m1_t1=m2_t1, - m1_t2=m2_t2, - - m2_t1=m1_t1, - m2_t2=m1_t2, - - resource1=resource2, - resource2=resource1, - - e12=e21, - e13=e23, - e14=e24, - e15=e25, - - e21=e12, - e23=e13, - e24=e14, - e25=e15 -] -endmodule - -module sensor3 = sensor1 -[ - state1=state3, - - str1=str3, - fin1=fin3, - - m1_t1=m3_t1, - m1_t2=m3_t2, - m3_t1=m1_t1, - m3_t2=m1_t2, - - resource1=resource3, - resource3=resource1, - - e12=e32, - e13=e31, - e14=e34, - e15=e35, - - e31=e13, - e32=e12, - e34=e14, - e35=e15 -] -endmodule - - - - -// labels and formulae for property specification -formula finished = (status=5); -label "end" = (status=6); - - -formula task1_completed = finished - & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1)|(m3_t1=1&resource3=1))) - & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2)|(m3_t1=1&resource3=2))) - & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3)|(m3_t1=1&resource3=3))); - -formula task2_completed = finished - & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1)|(m3_t2=1&resource3=1))) - & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2)|(m3_t2=1&resource3=2))) - & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3)|(m3_t2=1&resource3=3))); - - - -formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1); -formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1); -formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2); -formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3); - -formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1); -formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1); -formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2); -formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3); - -formula agent3_joins_successful_team = (task1_completed & m3_t1=1) | (task2_completed & m3_t2=1); -formula agent3_joins_successful_team_of_1 = (task1_completed & m3_t1=1 & team_size_t1=1) | (task2_completed & m3_t2=1 & team_size_t2=1); -formula agent3_joins_successful_team_of_2 = (task1_completed & m3_t1=1 & team_size_t1=2) | (task2_completed & m3_t2=1 & team_size_t2=2); -formula agent3_joins_successful_team_of_3 = (task1_completed & m3_t1=1 & team_size_t1=3) | (task2_completed & m3_t2=1 & team_size_t2=3); - -// rewards -rewards "w_1_total" - [] agent1_joins_successful_team : 1; - [] agent2_joins_successful_team : 1; - [] agent3_joins_successful_team : 1; -endrewards - -rewards "w_2_total" - [] task1_completed : 1; - [] task2_completed : 1; -endrewards - - - - diff --git a/examples/multiobjective/mdp/team/team3obj_3_numerical.pctl b/examples/multiobjective/mdp/team/team3obj_3_numerical.pctl deleted file mode 100644 index 4a02276ce..000000000 --- a/examples/multiobjective/mdp/team/team3obj_3_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}>=2.210204082 [ C ], P>=0.5 [ F task2_completed ]) diff --git a/examples/multiobjective/mdp/team/team3obj_3_pareto.pctl b/examples/multiobjective/mdp/team/team3obj_3_pareto.pctl deleted file mode 100644 index 8343ec77e..000000000 --- a/examples/multiobjective/mdp/team/team3obj_3_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}max=? [ C ], Pmax=? [ F task2_completed ]) diff --git a/examples/multiobjective/mdp/team/team3obj_4.nm b/examples/multiobjective/mdp/team/team3obj_4.nm deleted file mode 100644 index 77a74d3f1..000000000 --- a/examples/multiobjective/mdp/team/team3obj_4.nm +++ /dev/null @@ -1,366 +0,0 @@ -mdp - -// parameters -const int n_resources = 3; -const int n_tasks = 2; -const int n_sensors = 4; - - -// sensor resources -const int resource1=1; -const int resource2=2; -const int resource3=3; -const int resource4=1; - -// network configuration -const int e12=1; -const int e13=1; -const int e14=1; - -const int e21=e12; -const int e23=1; -const int e24=1; - -const int e31=e13; -const int e32=e23; -const int e34=1; - -const int e41=e14; -const int e42=e24; -const int e43=e34; - - - -// agent is committed to some team -formula committed = (m1_t1+m1_t2) > 0; - -// formulae to compute team sizes -formula team_size_t1 = m1_t1+m2_t1+m3_t1+m4_t1; -formula team_size_t2 = m1_t2+m2_t2+m3_t2+m4_t2; - -// formulae to check whether the agent can join the team -formula can_join_t1 = e12*m2_t1 + e13*m3_t1 + e14*m4_t1 > 0; -formula can_join_t2 = e12*m2_t2 + e13*m3_t2 + e14*m4_t2 > 0; - -// formulae to check whether agent has the resource required by the task -formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) ); -formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) ); - -// formulae to check whether the resource of an agent has been already filled in the team -formula resource_filled_t1 = (m2_t1=1 & resource1=resource2) | (m3_t1=1 & resource1=resource3) | (m4_t1=1 & resource1=resource4); -formula resource_filled_t2 = (m2_t2=1 & resource1=resource2) | (m3_t2=1 & resource1=resource3) | (m4_t2=1 & resource1=resource4); - -// formula to compute team initiation probability (assuming each agent has at least one connection) -formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))+e13*(1-((m3_t1+m3_t2)=0?0:1))+e14*(1-((m4_t1+m4_t2)=0?0:1))) / (e12+e13+e14); - - -module controller // schedules the algorithm - - // algorithm status - status : [0..7]; - - // task resource indicator variables - t1_r1 : [0..1]; - t1_r2 : [0..1]; - t1_r3 : [0..1]; - - t2_r1 : [0..1]; - t2_r2 : [0..1]; - t2_r3 : [0..1]; - - // schedule placeholders - turn1 : [0..n_sensors]; - turn2 : [0..n_sensors]; - turn3 : [0..n_sensors]; - turn4 : [0..n_sensors]; - turn5 : [0..n_sensors]; - - // selecting schedule uniformly at random - [] status=0 -> 1/24 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=2) & (turn3'=4) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=3) & (turn3'=4) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=4) & (turn3'=2) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=1) & (turn2'=4) & (turn3'=3) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=1) & (turn3'=4) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=3) & (turn3'=4) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=4) & (turn3'=1) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=2) & (turn2'=4) & (turn3'=3) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=1) & (turn3'=4) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (turn4'=4) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=2) & (turn3'=4) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=4) & (turn3'=1) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=3) & (turn2'=4) & (turn3'=2) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=1) & (turn3'=2) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=1) & (turn3'=3) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=2) & (turn3'=1) & (turn4'=3) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=2) & (turn3'=3) & (turn4'=1) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=3) & (turn3'=1) & (turn4'=2) & (status'=1) - + 1/24 : (turn1'=4) & (turn2'=3) & (turn3'=2) & (turn4'=1) & (status'=1); - - - // initialising non-empty tasks uniformly at random - [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2); - - // executing the schedule - - // 1st round - [str1] status=2 & turn1=1 -> (status'=2); - [fin1] status=2 & turn1=1 -> (status'=3); - [str2] status=2 & turn1=2 -> (status'=2); - [fin2] status=2 & turn1=2 -> (status'=3); - [str3] status=2 & turn1=3 -> (status'=2); - [fin3] status=2 & turn1=3 -> (status'=3); - [str4] status=2 & turn1=4 -> (status'=2); - [fin4] status=2 & turn1=4 -> (status'=3); - - // 2nd round - [str1] status=3 & turn2=1 -> (status'=3); - [fin1] status=3 & turn2=1 -> (status'=4); - [str2] status=3 & turn2=2 -> (status'=3); - [fin2] status=3 & turn2=2 -> (status'=4); - [str3] status=3 & turn2=3 -> (status'=3); - [fin3] status=3 & turn2=3 -> (status'=4); - [str4] status=3 & turn2=4 -> (status'=3); - [fin4] status=3 & turn2=4 -> (status'=4); - - // 3rd round - [str1] status=4 & turn3=1 -> (status'=4); - [fin1] status=4 & turn3=1 -> (status'=5); - [str2] status=4 & turn3=2 -> (status'=4); - [fin2] status=4 & turn3=2 -> (status'=5); - [str3] status=4 & turn3=3 -> (status'=4); - [fin3] status=4 & turn3=3 -> (status'=5); - [str4] status=4 & turn3=4 -> (status'=4); - [fin4] status=4 & turn3=4 -> (status'=5); - - // 4th round - [str1] status=5 & turn4=1 -> (status'=5); - [fin1] status=5 & turn4=1 -> (status'=6); - [str2] status=5 & turn4=2 -> (status'=5); - [fin2] status=5 & turn4=2 -> (status'=6); - [str3] status=5 & turn4=3 -> (status'=5); - [fin3] status=5 & turn4=3 -> (status'=6); - [str4] status=5 & turn4=4 -> (status'=5); - [fin4] status=5 & turn4=4 -> (status'=6); - - [] status=6 -> (status'=7); - - [] status=7 -> (status'=7); - -endmodule - -module sensor1 - - state1 : [0..1]; - - // team membership indicators - m1_t1 : [0..1]; - m1_t2 : [0..1]; - - // starting turn, selecting order of tasks - [str1] state1=0 -> (state1'=1); - - // if there is no team and has required skill - initiating the team - [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1); - - // if team already exists and one of the neighbours is in it - joining the team - [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1); - - [fin1] state1>0 -> (state1'=0); - -endmodule - -module sensor2 = sensor1 -[ - state1=state2, - - str1=str2, - fin1=fin2, - - m1_t1=m2_t1, - m1_t2=m2_t2, - - m2_t1=m1_t1, - m2_t2=m1_t2, - - resource1=resource2, - resource2=resource1, - - e12=e21, - e13=e23, - e14=e24, - e15=e25, - - e21=e12, - e23=e13, - e24=e14, - e25=e15 -] -endmodule - -module sensor3 = sensor1 -[ - state1=state3, - - str1=str3, - fin1=fin3, - - m1_t1=m3_t1, - m1_t2=m3_t2, - m3_t1=m1_t1, - m3_t2=m1_t2, - - resource1=resource3, - resource3=resource1, - - e12=e32, - e13=e31, - e14=e34, - e15=e35, - - e31=e13, - e32=e12, - e34=e14, - e35=e15 -] -endmodule - -module sensor4 = sensor1 -[ - state1=state4, - - str1=str4, - fin1=fin4, - - m1_t1=m4_t1, - m1_t2=m4_t2, - - m4_t1=m1_t1, - m4_t2=m1_t2, - - resource1=resource4, - resource4=resource1, - - e12=e42, - e13=e43, - e14=e41, - e15=e45, - - e41=e14, - e42=e12, - e43=e13, - e45=e15 -] -endmodule - - - - - - -// labels and formulae for property specification -formula finished = (status=6); -label "end" = (status=7); - -formula task1_completed = finished - & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1)|(m3_t1=1&resource3=1)|(m4_t1=1&resource4=1))) - & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2)|(m3_t1=1&resource3=2)|(m4_t1=1&resource4=2))) - & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3)|(m3_t1=1&resource3=3)|(m4_t1=1&resource4=3))); - -formula task2_completed = finished - & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1)|(m3_t2=1&resource3=1)|(m4_t2=1&resource4=1))) - & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2)|(m3_t2=1&resource3=2)|(m4_t2=1&resource4=2))) - & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3)|(m3_t2=1&resource3=3)|(m4_t2=1&resource4=3))); - -formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1); -formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1); -formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2); -formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3); - -formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1); -formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1); -formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2); -formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3); - -formula agent3_joins_successful_team = (task1_completed & m3_t1=1) | (task2_completed & m3_t2=1); -formula agent3_joins_successful_team_of_1 = (task1_completed & m3_t1=1 & team_size_t1=1) | (task2_completed & m3_t2=1 & team_size_t2=1); -formula agent3_joins_successful_team_of_2 = (task1_completed & m3_t1=1 & team_size_t1=2) | (task2_completed & m3_t2=1 & team_size_t2=2); -formula agent3_joins_successful_team_of_3 = (task1_completed & m3_t1=1 & team_size_t1=3) | (task2_completed & m3_t2=1 & team_size_t2=3); - -formula agent4_joins_successful_team = (task1_completed & m4_t1=1) | (task2_completed & m4_t2=1); -formula agent4_joins_successful_team_of_1 = (task1_completed & m4_t1=1 & team_size_t1=1) | (task2_completed & m4_t2=1 & team_size_t2=1); -formula agent4_joins_successful_team_of_2 = (task1_completed & m4_t1=1 & team_size_t1=2) | (task2_completed & m4_t2=1 & team_size_t2=2); -formula agent4_joins_successful_team_of_3 = (task1_completed & m4_t1=1 & team_size_t1=3) | (task2_completed & m4_t2=1 & team_size_t2=3); - - -// rewards -rewards "w_1_total" - [] agent1_joins_successful_team : 1; - [] agent2_joins_successful_team : 1; - [] agent3_joins_successful_team : 1; - [] agent4_joins_successful_team : 1; -endrewards - -rewards "w_2_total" - [] task1_completed : 1; - [] task2_completed : 1; -endrewards - - - - - diff --git a/examples/multiobjective/mdp/team/team3obj_4_numerical.pctl b/examples/multiobjective/mdp/team/team3obj_4_numerical.pctl deleted file mode 100644 index 3712e6d0d..000000000 --- a/examples/multiobjective/mdp/team/team3obj_4_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}>=2.423469388 [ C ], P>=0.5 [ F task2_completed ]) diff --git a/examples/multiobjective/mdp/team/team3obj_4_pareto.pctl b/examples/multiobjective/mdp/team/team3obj_4_pareto.pctl deleted file mode 100644 index 8343ec77e..000000000 --- a/examples/multiobjective/mdp/team/team3obj_4_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}max=? [ C ], Pmax=? [ F task2_completed ]) diff --git a/examples/multiobjective/mdp/team/team3obj_5.nm b/examples/multiobjective/mdp/team/team3obj_5.nm deleted file mode 100644 index 85214bc8c..000000000 --- a/examples/multiobjective/mdp/team/team3obj_5.nm +++ /dev/null @@ -1,532 +0,0 @@ -mdp - -// parameters -const int n_resources = 3; -const int n_tasks = 2; -const int n_sensors = 5; - - -// sensor resources -const int resource1=1; -const int resource2=2; -const int resource3=3; -const int resource4=1; -const int resource5=2; - -// network configuration -const int e12=1; -const int e13=1; -const int e14=1; -const int e15=1; - -const int e21=e12; -const int e23=1; -const int e24=1; -const int e25=1; - -const int e31=e13; -const int e32=e23; -const int e34=1; -const int e35=1; - -const int e41=e14; -const int e42=e24; -const int e43=e34; -const int e45=1; - -const int e51=e15; -const int e52=e25; -const int e53=e35; -const int e54=e45; - - -// agent is committed to some team -formula committed = (m1_t1+m1_t2) > 0; - -// formulae to compute team sizes -formula team_size_t1 = m1_t1+m2_t1+m3_t1+m4_t1+m5_t1; -formula team_size_t2 = m1_t2+m2_t2+m3_t2+m4_t2+m5_t2; - -// formulae to check whether the agent can join the team -formula can_join_t1 = e12*m2_t1 + e13*m3_t1 + e14*m4_t1 + e15*m5_t1 > 0; -formula can_join_t2 = e12*m2_t2 + e13*m3_t2 + e14*m4_t2 + e15*m5_t2 > 0; - -// formulae to check whether agent has the resource required by the task -formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) ); -formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) ); - -// formulae to check whether the resource of an agent has been already filled in the team -formula resource_filled_t1 = (m2_t1=1 & resource1=resource2) | (m3_t1=1 & resource1=resource3) | (m4_t1=1 & resource1=resource4) | (m5_t1=1 & resource1=resource5); -formula resource_filled_t2 = (m2_t2=1 & resource1=resource2) | (m3_t2=1 & resource1=resource3) | (m4_t2=1 & resource1=resource4) | (m5_t2=1 & resource1=resource5); - -// formula to compute team initiation probability (assuming each agent has at least one connection) -formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))+e13*(1-((m3_t1+m3_t2)=0?0:1))+e14*(1-((m4_t1+m4_t2)=0?0:1))+e15*(1-((m5_t1+m5_t2)=0?0:1))) / (e12+e13+e14+e15); - - -module controller // schedules the algorithm - - // algorithm status - status : [0..8]; - - // task resource indicator variables - t1_r1 : [0..1]; - t1_r2 : [0..1]; - t1_r3 : [0..1]; - - t2_r1 : [0..1]; - t2_r2 : [0..1]; - t2_r3 : [0..1]; - - // schedule placeholders - turn1 : [0..n_sensors]; - turn2 : [0..n_sensors]; - turn3 : [0..n_sensors]; - turn4 : [0..n_sensors]; - turn5 : [0..n_sensors]; - - // selecting schedule uniformly at random - [] status=0 -> 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=4) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=4) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=5) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=2) & (turn3'=5) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=4) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=4) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=5) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=3) & (turn3'=5) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=2) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=2) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=3) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=3) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=5) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=4) & (turn3'=5) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=2) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=2) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=3) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=3) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=4) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=1) & (turn2'=5) & (turn3'=4) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=4) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=4) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=5) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=1) & (turn3'=5) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=4) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=4) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=5) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=3) & (turn3'=5) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=1) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=1) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=3) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=3) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=5) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=4) & (turn3'=5) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=1) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=1) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=3) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=3) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=4) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=2) & (turn2'=5) & (turn3'=4) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=4) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=4) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=5) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=1) & (turn3'=5) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (turn4'=4) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (turn4'=5) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=4) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=4) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=5) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=2) & (turn3'=5) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=1) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=1) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=2) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=2) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=5) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=4) & (turn3'=5) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=1) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=1) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=2) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=2) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=4) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=3) & (turn2'=5) & (turn3'=4) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=2) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=2) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=3) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=3) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=5) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=1) & (turn3'=5) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=1) & (turn4'=3) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=1) & (turn4'=5) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=3) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=3) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=5) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=2) & (turn3'=5) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=1) & (turn4'=2) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=1) & (turn4'=5) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=2) & (turn4'=1) & (turn5'=5) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=2) & (turn4'=5) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=5) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=3) & (turn3'=5) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=1) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=1) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=2) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=2) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=3) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=4) & (turn2'=5) & (turn3'=3) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=2) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=2) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=3) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=3) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=4) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=1) & (turn3'=4) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=1) & (turn4'=3) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=1) & (turn4'=4) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=3) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=3) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=4) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=2) & (turn3'=4) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=1) & (turn4'=2) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=1) & (turn4'=4) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=2) & (turn4'=1) & (turn5'=4) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=2) & (turn4'=4) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=4) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=3) & (turn3'=4) & (turn4'=2) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=1) & (turn4'=2) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=1) & (turn4'=3) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=2) & (turn4'=1) & (turn5'=3) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=2) & (turn4'=3) & (turn5'=1) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=3) & (turn4'=1) & (turn5'=2) & (status'=1) - + 1/120 : (turn1'=5) & (turn2'=4) & (turn3'=3) & (turn4'=2) & (turn5'=1) & (status'=1); - - - // initialising non-empty tasks uniformly at random - [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2) - + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2); - - // executing the schedule - - // 1st round - [str1] status=2 & turn1=1 -> (status'=2); - [fin1] status=2 & turn1=1 -> (status'=3); - [str2] status=2 & turn1=2 -> (status'=2); - [fin2] status=2 & turn1=2 -> (status'=3); - [str3] status=2 & turn1=3 -> (status'=2); - [fin3] status=2 & turn1=3 -> (status'=3); - [str4] status=2 & turn1=4 -> (status'=2); - [fin4] status=2 & turn1=4 -> (status'=3); - [str5] status=2 & turn1=5 -> (status'=2); - [fin5] status=2 & turn1=5 -> (status'=3); - - // 2nd round - [str1] status=3 & turn2=1 -> (status'=3); - [fin1] status=3 & turn2=1 -> (status'=4); - [str2] status=3 & turn2=2 -> (status'=3); - [fin2] status=3 & turn2=2 -> (status'=4); - [str3] status=3 & turn2=3 -> (status'=3); - [fin3] status=3 & turn2=3 -> (status'=4); - [str4] status=3 & turn2=4 -> (status'=3); - [fin4] status=3 & turn2=4 -> (status'=4); - [str5] status=3 & turn2=5 -> (status'=3); - [fin5] status=3 & turn2=5 -> (status'=4); - - // 3rd round - [str1] status=4 & turn3=1 -> (status'=4); - [fin1] status=4 & turn3=1 -> (status'=5); - [str2] status=4 & turn3=2 -> (status'=4); - [fin2] status=4 & turn3=2 -> (status'=5); - [str3] status=4 & turn3=3 -> (status'=4); - [fin3] status=4 & turn3=3 -> (status'=5); - [str4] status=4 & turn3=4 -> (status'=4); - [fin4] status=4 & turn3=4 -> (status'=5); - [str5] status=4 & turn3=5 -> (status'=4); - [fin5] status=4 & turn3=5 -> (status'=5); - - // 4th round - [str1] status=5 & turn4=1 -> (status'=5); - [fin1] status=5 & turn4=1 -> (status'=6); - [str2] status=5 & turn4=2 -> (status'=5); - [fin2] status=5 & turn4=2 -> (status'=6); - [str3] status=5 & turn4=3 -> (status'=5); - [fin3] status=5 & turn4=3 -> (status'=6); - [str4] status=5 & turn4=4 -> (status'=5); - [fin4] status=5 & turn4=4 -> (status'=6); - [str5] status=5 & turn4=5 -> (status'=5); - [fin5] status=5 & turn4=5 -> (status'=6); - - // 5th round - [str1] status=6 & turn5=1 -> (status'=6); - [fin1] status=6 & turn5=1 -> (status'=7); - [str2] status=6 & turn5=2 -> (status'=6); - [fin2] status=6 & turn5=2 -> (status'=7); - [str3] status=6 & turn5=3 -> (status'=6); - [fin3] status=6 & turn5=3 -> (status'=7); - [str4] status=6 & turn5=4 -> (status'=6); - [fin4] status=6 & turn5=4 -> (status'=7); - [str5] status=6 & turn5=5 -> (status'=6); - [fin5] status=6 & turn5=5 -> (status'=7); - - [] status=7 -> (status'=8); - - [] status=8 -> (status'=8); - -endmodule - -module sensor1 - - state1 : [0..1]; - - // team membership indicators - m1_t1 : [0..1]; - m1_t2 : [0..1]; - - // starting turn, selecting order of tasks - [str1] state1=0 -> (state1'=1); - - // if there is no team and has required skill - initiating the team - [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1); - - // if team already exists and one of the neighbours is in it - joining the team - [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1); - [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1); - - [fin1] state1>0 -> (state1'=0); - -endmodule - -module sensor2 = sensor1 -[ - state1=state2, - - str1=str2, - fin1=fin2, - - m1_t1=m2_t1, - m1_t2=m2_t2, - - m2_t1=m1_t1, - m2_t2=m1_t2, - - resource1=resource2, - resource2=resource1, - - e12=e21, - e13=e23, - e14=e24, - e15=e25, - - e21=e12, - e23=e13, - e24=e14, - e25=e15 -] -endmodule - -module sensor3 = sensor1 -[ - state1=state3, - - str1=str3, - fin1=fin3, - - m1_t1=m3_t1, - m1_t2=m3_t2, - m3_t1=m1_t1, - m3_t2=m1_t2, - - resource1=resource3, - resource3=resource1, - - e12=e32, - e13=e31, - e14=e34, - e15=e35, - - e31=e13, - e32=e12, - e34=e14, - e35=e15 -] -endmodule - -module sensor4 = sensor1 -[ - state1=state4, - - str1=str4, - fin1=fin4, - - m1_t1=m4_t1, - m1_t2=m4_t2, - - m4_t1=m1_t1, - m4_t2=m1_t2, - - resource1=resource4, - resource4=resource1, - - e12=e42, - e13=e43, - e14=e41, - e15=e45, - - e41=e14, - e42=e12, - e43=e13, - e45=e15 -] -endmodule - -module sensor5 = sensor1 -[ - state1=state5, - - str1=str5, - fin1=fin5, - - m1_t1=m5_t1, - m1_t2=m5_t2, - - m5_t1=m1_t1, - m5_t2=m1_t2, - - resource1=resource5, - resource5=resource1, - - e12=e52, - e13=e53, - e14=e54, - e15=e51, - - e51=e15, - e52=e12, - e53=e13, - e54=e14 -] -endmodule - -// formulae for scheduling -formula s1_sched = (turn1=1 | turn2=1 | turn3=1 | turn4=1 | turn5=1); -formula s2_sched = (turn1=2 | turn2=2 | turn3=2 | turn4=2 | turn5=2); -formula s3_sched = (turn1=3 | turn2=3 | turn3=3 | turn4=3 | turn5=3); -formula s4_sched = (turn1=4 | turn2=4 | turn3=4 | turn4=4 | turn5=4); -formula s5_sched = (turn1=5 | turn2=5 | turn3=5 | turn4=5 | turn5=5); -formula all_not_sched = !(s1_sched | s2_sched | s3_sched | s4_sched | s5_sched); -formula all_sched = (s1_sched & s2_sched & s3_sched & s4_sched & s5_sched); - - - - -// labels and formulae for property specification -formula finished = (status=7); -label "end" = (status=8); - - -formula task1_completed = finished - & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1)|(m3_t1=1&resource3=1)|(m4_t1=1&resource4=1)|(m5_t1=1&resource5=1))) - & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2)|(m3_t1=1&resource3=2)|(m4_t1=1&resource4=2)|(m5_t1=1&resource5=2))) - & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3)|(m3_t1=1&resource3=3)|(m4_t1=1&resource4=3)|(m5_t1=1&resource5=3))); - -formula task2_completed = finished - & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1)|(m3_t2=1&resource3=1)|(m4_t2=1&resource4=1)|(m5_t2=1&resource5=1))) - & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2)|(m3_t2=1&resource3=2)|(m4_t2=1&resource4=2)|(m5_t2=1&resource5=2))) - & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3)|(m3_t2=1&resource3=3)|(m4_t2=1&resource4=3)|(m5_t2=1&resource5=3))); - -formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1); -formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1); -formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2); -formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3); - -formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1); -formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1); -formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2); -formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3); - -formula agent3_joins_successful_team = (task1_completed & m3_t1=1) | (task2_completed & m3_t2=1); -formula agent3_joins_successful_team_of_1 = (task1_completed & m3_t1=1 & team_size_t1=1) | (task2_completed & m3_t2=1 & team_size_t2=1); -formula agent3_joins_successful_team_of_2 = (task1_completed & m3_t1=1 & team_size_t1=2) | (task2_completed & m3_t2=1 & team_size_t2=2); -formula agent3_joins_successful_team_of_3 = (task1_completed & m3_t1=1 & team_size_t1=3) | (task2_completed & m3_t2=1 & team_size_t2=3); - -formula agent4_joins_successful_team = (task1_completed & m4_t1=1) | (task2_completed & m4_t2=1); -formula agent4_joins_successful_team_of_1 = (task1_completed & m4_t1=1 & team_size_t1=1) | (task2_completed & m4_t2=1 & team_size_t2=1); -formula agent4_joins_successful_team_of_2 = (task1_completed & m4_t1=1 & team_size_t1=2) | (task2_completed & m4_t2=1 & team_size_t2=2); -formula agent4_joins_successful_team_of_3 = (task1_completed & m4_t1=1 & team_size_t1=3) | (task2_completed & m4_t2=1 & team_size_t2=3); - -formula agent5_joins_successful_team = (task1_completed & m5_t1=1) | (task2_completed & m5_t2=1); -formula agent5_joins_successful_team_of_1 = (task1_completed & m5_t1=1 & team_size_t1=1) | (task2_completed & m5_t2=1 & team_size_t2=1); -formula agent5_joins_successful_team_of_2 = (task1_completed & m5_t1=1 & team_size_t1=2) | (task2_completed & m5_t2=1 & team_size_t2=2); -formula agent5_joins_successful_team_of_3 = (task1_completed & m5_t1=1 & team_size_t1=3) | (task2_completed & m5_t2=1 & team_size_t2=3); - -// rewards -rewards "w_1_total" - [] agent1_joins_successful_team : 1; - [] agent2_joins_successful_team : 1; - [] agent3_joins_successful_team : 1; - [] agent4_joins_successful_team : 1; - [] agent5_joins_successful_team : 1; -endrewards - -rewards "w_2_total" - [] task1_completed : 1; - [] task2_completed : 1; -endrewards - - - - - diff --git a/examples/multiobjective/mdp/team/team3obj_5_numerical.pctl b/examples/multiobjective/mdp/team/team3obj_5_numerical.pctl deleted file mode 100644 index 541c02e9c..000000000 --- a/examples/multiobjective/mdp/team/team3obj_5_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}>=2.753061224 [ C ], P>=0.5 [ F task2_completed ]) diff --git a/examples/multiobjective/mdp/team/team3obj_5_pareto.pctl b/examples/multiobjective/mdp/team/team3obj_5_pareto.pctl deleted file mode 100644 index 8343ec77e..000000000 --- a/examples/multiobjective/mdp/team/team3obj_5_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F task1_completed ], R{"w_1_total"}max=? [ C ], Pmax=? [ F task2_completed ]) diff --git a/examples/multiobjective/mdp/zeroconf-tb/origFiles/zeroconf_host_multi2_time.nm b/examples/multiobjective/mdp/zeroconf-tb/origFiles/zeroconf_host_multi2_time.nm deleted file mode 100644 index ad0f4a3b7..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/origFiles/zeroconf_host_multi2_time.nm +++ /dev/null @@ -1,169 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=2; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 1/2; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait - - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [configured] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent -const int M; // time between sending and receiving a message - -module env_error2 - - env : [0..1]; // 0 active and 1 done - k : [0..2]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the time bounded assumption -// host does not send configured signal within T seconds -const int T; - -module time_error - - time_error : [0..1]; - done : [0..1]; - t : [0..T]; - - [time] t (t'=t+1); // time passes and bound not reached - [time] t=T-1 & done=0 & time_error=0 -> (time_error'=1); // bound reached so error - [configured] time_error=0 -> (done'=1); // configured within the time bound - - // when in error or done state can loop with either action - [configured] time_error=1 | done=1 -> true; - [time] time_error=1 | done=1 -> true; - -endmodule diff --git a/examples/multiobjective/mdp/zeroconf-tb/origFiles/zeroconf_host_multi4_time.nm b/examples/multiobjective/mdp/zeroconf-tb/origFiles/zeroconf_host_multi4_time.nm deleted file mode 100644 index 71984c286..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/origFiles/zeroconf_host_multi4_time.nm +++ /dev/null @@ -1,174 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=4; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 0.5; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait - - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [configured] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent -const int M; // time between sending and receiving a message - -module env_error4 - - env : [0..1]; // 0 active and 1 done - k : [0..4]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - c3 : [0..M+1]; // time since third message - c4 : [0..M+1]; // time since fourth message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)); - [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2,c3,c4)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the time bounded assumption -// host does not send configured signal within T seconds -const int T; - -module time_error - - time_error : [0..1]; - done : [0..1]; - t : [0..T]; - - [time] t (t'=t+1); // time passes and bound not reached - [time] t=T-1 & done=0 & time_error=0 -> (time_error'=1); // bound reached so error - [configured] time_error=0 -> (done'=1); // configured within the time bound - - // when in error or done state can loop with either action - [configured] time_error=1 | done=1 -> true; - [time] time_error=1 | done=1 -> true; - -endmodule diff --git a/examples/multiobjective/mdp/zeroconf-tb/origFiles/zeroconf_host_multi_time.pctl b/examples/multiobjective/mdp/zeroconf-tb/origFiles/zeroconf_host_multi_time.pctl deleted file mode 100644 index 078b34c65..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/origFiles/zeroconf_host_multi_time.pctl +++ /dev/null @@ -1,13 +0,0 @@ -// Max probability of component violating assumption property (checked separately) -const double p_fail = -K=2 ? 0.19 : -K=4 ? 0.006859000000000001 : -K=6 ? 2.476099000000001E-4 : -K=8 ? 8.938717390000006E-6 : -0; - -// Assume-guarantee check via multi-objective -"num_ag": multi(Pmax=? [ F time_error=1 ] , P>=1-p_fail [ G (error=0) ]) - -// Pareto query for assume-guarantee check -"pareto": multi(Pmax=? [ F time_error=1 ] , Pmax=? [ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb2_14.nm b/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb2_14.nm deleted file mode 100644 index bc433a7f1..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb2_14.nm +++ /dev/null @@ -1,169 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=2; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 1/2; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -const int M=1; // time between sending and receiving a message -const int T=14; - - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [configured] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent - -module env_error2 - - env : [0..1]; // 0 active and 1 done - k : [0..2]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the time bounded assumption -// host does not send configured signal within T seconds - -module time_error - - time_error : [0..1]; - done : [0..1]; - t : [0..T]; - - [time] t (t'=t+1); // time passes and bound not reached - [time] t=T-1 & done=0 & time_error=0 -> (time_error'=1); // bound reached so error - [configured] time_error=0 -> (done'=1); // configured within the time bound - - // when in error or done state can loop with either action - [configured] time_error=1 | done=1 -> true; - [time] time_error=1 | done=1 -> true; - -endmodule diff --git a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb2_14_numerical.pctl b/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb2_14_numerical.pctl deleted file mode 100644 index e8119cae5..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb2_14_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F time_error=1 ] , P>=0.81[ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb2_14_pareto.pctl b/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb2_14_pareto.pctl deleted file mode 100644 index db9996245..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb2_14_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F time_error=1 ] , Pmax=? [ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_10.nm b/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_10.nm deleted file mode 100644 index a8485f2c9..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_10.nm +++ /dev/null @@ -1,174 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=4; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 0.5; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -const int M=1; // time between sending and receiving a message -const int T=10; - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [configured] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent - - -module env_error4 - - env : [0..1]; // 0 active and 1 done - k : [0..4]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - c3 : [0..M+1]; // time since third message - c4 : [0..M+1]; // time since fourth message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)); - [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2,c3,c4)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the time bounded assumption -// host does not send configured signal within T seconds - -module time_error - - time_error : [0..1]; - done : [0..1]; - t : [0..T]; - - [time] t (t'=t+1); // time passes and bound not reached - [time] t=T-1 & done=0 & time_error=0 -> (time_error'=1); // bound reached so error - [configured] time_error=0 -> (done'=1); // configured within the time bound - - // when in error or done state can loop with either action - [configured] time_error=1 | done=1 -> true; - [time] time_error=1 | done=1 -> true; - -endmodule diff --git a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_10_numerical.pctl b/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_10_numerical.pctl deleted file mode 100644 index 84762f3cc..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_10_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F time_error=1 ] , P>=0.993141[ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_10_pareto.pctl b/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_10_pareto.pctl deleted file mode 100644 index db9996245..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_10_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F time_error=1 ] , Pmax=? [ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_14.nm b/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_14.nm deleted file mode 100644 index 4e56d344f..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_14.nm +++ /dev/null @@ -1,173 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=4; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 0.5; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -const int M=1; // time between sending and receiving a message -const int T=14; - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [configured] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent - -module env_error4 - - env : [0..1]; // 0 active and 1 done - k : [0..4]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - c3 : [0..M+1]; // time since third message - c4 : [0..M+1]; // time since fourth message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)); - [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2,c3,c4)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the time bounded assumption -// host does not send configured signal within T seconds - -module time_error - - time_error : [0..1]; - done : [0..1]; - t : [0..T]; - - [time] t (t'=t+1); // time passes and bound not reached - [time] t=T-1 & done=0 & time_error=0 -> (time_error'=1); // bound reached so error - [configured] time_error=0 -> (done'=1); // configured within the time bound - - // when in error or done state can loop with either action - [configured] time_error=1 | done=1 -> true; - [time] time_error=1 | done=1 -> true; - -endmodule diff --git a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_14_numerical.pctl b/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_14_numerical.pctl deleted file mode 100644 index 84762f3cc..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_14_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F time_error=1 ] , P>=0.993141[ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_14_pareto.pctl b/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_14_pareto.pctl deleted file mode 100644 index db9996245..000000000 --- a/examples/multiobjective/mdp/zeroconf-tb/zeroconf-tb4_14_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F time_error=1 ] , Pmax=? [ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi.pctl b/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi.pctl deleted file mode 100644 index b047c3818..000000000 --- a/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi.pctl +++ /dev/null @@ -1,13 +0,0 @@ -// Max probability of component violating assumption property (checked separately) -const double p_fail = -K=2 ? 0.19 : -K=4 ? 0.006859000000000001 : -K=6 ? 2.476099000000001E-4 : -K=8 ? 8.938717390000006E-6 : -0; - -// Assume-guarantee check via multi-objective -"num_ag": multi(Pmax=? [ F l=4 & ip=1 ] , P>=1-p_fail [ G (error=0) ]) - -// Pareto query for assume-guarantee check -"pareto": multi(Pmax=? [ F l=4 & ip=1 ] , Pmax=? [ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi2.nm b/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi2.nm deleted file mode 100644 index 82ade9881..000000000 --- a/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi2.nm +++ /dev/null @@ -1,149 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=2; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 1/2; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait - - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent -const int M; // time between sending and receiving a message - -module env_error2 - - env : [0..1]; // 0 active and 1 done - k : [0..2]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule - diff --git a/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi4.nm b/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi4.nm deleted file mode 100644 index 1c3bafd53..000000000 --- a/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi4.nm +++ /dev/null @@ -1,153 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=4; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 0.5; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait - - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent -const int M; // time between sending and receiving a message - -module env_error4 - - env : [0..1]; // 0 active and 1 done - k : [0..4]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - c3 : [0..M+1]; // time since third message - c4 : [0..M+1]; // time since fourth message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)); - [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2,c3,c4)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule diff --git a/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi6.nm b/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi6.nm deleted file mode 100644 index cde22a032..000000000 --- a/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi6.nm +++ /dev/null @@ -1,157 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=6; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 0.5; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait - - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent -const int M; // time between sending and receiving a message - -module env_error6 - - env : [0..1]; // 0 active and 1 done - k : [0..6]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - c3 : [0..M+1]; // time since third message - c4 : [0..M+1]; // time since fourth message - c5 : [0..M+1]; // time since fifth message - c6 : [0..M+1]; // time since sixth message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)); - [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)); - [time] error=0 & env=0 & k=5 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)); - [time] error=0 & env=0 & k=6 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)) & (c6'=min(c6+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2,c3,c4,c5,c6)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4,c5,c6)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule - diff --git a/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi8.nm b/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi8.nm deleted file mode 100644 index e843a8c12..000000000 --- a/examples/multiobjective/mdp/zeroconf/origFiles/zeroconf_host_multi8.nm +++ /dev/null @@ -1,161 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=8; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 0.5; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait - - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent -const int M; // time between sending and receiving a message - -module env_error8 - - env : [0..1]; // 0 active and 1 done - k : [0..8]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - c3 : [0..M+1]; // time since third message - c4 : [0..M+1]; // time since fourth message - c5 : [0..M+1]; // time since fifth message - c6 : [0..M+1]; // time since sixth message - c7 : [0..M+1]; // time since seventh message - c8 : [0..M+1]; // time since eighth message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)); - [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)); - [time] error=0 & env=0 & k=5 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)); - [time] error=0 & env=0 & k=6 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)) & (c6'=min(c6+1,M+1)); - [time] error=0 & env=0 & k=7 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)) & (c6'=min(c6+1,M+1)) & (c7'=min(c7+1,M+1)); - [time] error=0 & env=0 & k=8 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)) & (c6'=min(c6+1,M+1)) & (c7'=min(c7+1,M+1)) & (c8'=min(c8+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2,c3,c4,c5,c6,c7,c8)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4,c5,c6,c7,c8)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule - diff --git a/examples/multiobjective/mdp/zeroconf/zeroconf4.nm b/examples/multiobjective/mdp/zeroconf/zeroconf4.nm deleted file mode 100644 index 3d5988df2..000000000 --- a/examples/multiobjective/mdp/zeroconf/zeroconf4.nm +++ /dev/null @@ -1,153 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=4; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 0.5; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -const int M=1; // time between sending and receiving a message - - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent - -module env_error4 - - env : [0..1]; // 0 active and 1 done - k : [0..4]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - c3 : [0..M+1]; // time since third message - c4 : [0..M+1]; // time since fourth message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)); - [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2,c3,c4)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule diff --git a/examples/multiobjective/mdp/zeroconf/zeroconf4_numerical.pctl b/examples/multiobjective/mdp/zeroconf/zeroconf4_numerical.pctl deleted file mode 100644 index 646a77159..000000000 --- a/examples/multiobjective/mdp/zeroconf/zeroconf4_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F l=4 & ip=1 ] , P>=0.993141[ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf/zeroconf4_pareto.pctl b/examples/multiobjective/mdp/zeroconf/zeroconf4_pareto.pctl deleted file mode 100644 index 694c19e14..000000000 --- a/examples/multiobjective/mdp/zeroconf/zeroconf4_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F l=4 & ip=1 ] , Pmax=? [ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf/zeroconf6.nm b/examples/multiobjective/mdp/zeroconf/zeroconf6.nm deleted file mode 100644 index 99ce361a5..000000000 --- a/examples/multiobjective/mdp/zeroconf/zeroconf6.nm +++ /dev/null @@ -1,157 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=6; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 0.5; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -const int M=1; // time between sending and receiving a message - - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent - -module env_error6 - - env : [0..1]; // 0 active and 1 done - k : [0..6]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - c3 : [0..M+1]; // time since third message - c4 : [0..M+1]; // time since fourth message - c5 : [0..M+1]; // time since fifth message - c6 : [0..M+1]; // time since sixth message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)); - [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)); - [time] error=0 & env=0 & k=5 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)); - [time] error=0 & env=0 & k=6 & min(c1,c2,c3,c4,c5,c6) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)) & (c6'=min(c6+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2,c3,c4,c5,c6)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4,c5,c6)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule - diff --git a/examples/multiobjective/mdp/zeroconf/zeroconf6_numerical.pctl b/examples/multiobjective/mdp/zeroconf/zeroconf6_numerical.pctl deleted file mode 100644 index 016da75a6..000000000 --- a/examples/multiobjective/mdp/zeroconf/zeroconf6_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F l=4 & ip=1 ] , P>=0.9997523901[ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf/zeroconf6_pareto.pctl b/examples/multiobjective/mdp/zeroconf/zeroconf6_pareto.pctl deleted file mode 100644 index 694c19e14..000000000 --- a/examples/multiobjective/mdp/zeroconf/zeroconf6_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F l=4 & ip=1 ] , Pmax=? [ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf/zeroconf8.nm b/examples/multiobjective/mdp/zeroconf/zeroconf8.nm deleted file mode 100644 index 871e06e2b..000000000 --- a/examples/multiobjective/mdp/zeroconf/zeroconf8.nm +++ /dev/null @@ -1,161 +0,0 @@ -// IPv4: PTA model with digitial clocks -// multi-objective model of the host -// gxn/dxp 28/09/09 - -mdp - -//------------------------------------------------------------- -// VARIABLES -const int N=20; // number of abstract hosts -const int K=8; // number of probes to send - -// PROBABILITIES -const double old = N/65024; // probability pick an ip address being used -//const double old = 0.5; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -const int M=1; // time between sending and receiving a message - - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec0] (l=1) -> true; // get message (ignore since have no ip address) - [rec1] (l=1) -> true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send1] l=2 & ip=1 & x=2 & probes (x'=0) & (probes'=probes+1); - [send2] l=2 & ip=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec0] l=2 & ip!=0 -> (l'=l); - [rec1] l=2 & ip!=1 -> (l'=l); - // get a message with matching ip: reconfigure - [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec0] l=3 & mess=0 & ip!=0 -> (l'=l); - [rec1] l=3 & mess=0 & ip!=1 -> (l'=l); - - - // send probe reply or message for defence - [send1] l=3 & ip=1 & mess=1 -> (mess'=0); - [send2] l=3 & ip=2 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> true; - -endmodule - -//------------------------------------------------------------- -// error automaton for the environment assumption -// do not get a reply when K probes are sent - -module env_error8 - - env : [0..1]; // 0 active and 1 done - k : [0..8]; // counts the number of messages sent - c1 : [0..M+1]; // time since first message - c2 : [0..M+1]; // time since second message - c3 : [0..M+1]; // time since third message - c4 : [0..M+1]; // time since fourth message - c5 : [0..M+1]; // time since fifth message - c6 : [0..M+1]; // time since sixth message - c7 : [0..M+1]; // time since seventh message - c8 : [0..M+1]; // time since eighth message - error : [0..1]; - - // message with new ip address arrives so done - [send2] error=0 & env=0 -> (env'=1); - // message with old ip address arrives so count - [send1] error=0 & env=0 -> (k'=min(k+1,K)); - // time passgae so update relevant clocks - [time] error=0 & env=0 & k=0 -> true; - [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)); - [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)); - [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)); - [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)); - [time] error=0 & env=0 & k=5 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)); - [time] error=0 & env=0 & k=6 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)) & (c6'=min(c6+1,M+1)); - [time] error=0 & env=0 & k=7 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)) & (c6'=min(c6+1,M+1)) & (c7'=min(c7+1,M+1)); - [time] error=0 & env=0 & k=8 & min(c1,c2,c3,c4,c5,c6,c7,c8) (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1)) & (c5'=min(c5+1,M+1)) & (c6'=min(c6+1,M+1)) & (c7'=min(c7+1,M+1)) & (c8'=min(c8+1,M+1)); - // all clocks reached their bound so an error - [time] error=0 & env=0 & min(c1,c2,c3,c4,c5,c6,c7,c8)=M -> (error'=1); - // send a reply (then done) - [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4,c5,c6,c7,c8)<=M -> (env'=1); - // finished so any action can be performed - [time] error=1 | env=1 -> true; - [send1] error=1 | env=1 -> true; - [send2] error=1 | env=1 -> true; - [rec1] error=1 | env=1 -> true; - -endmodule - diff --git a/examples/multiobjective/mdp/zeroconf/zeroconf8_numerical.pctl b/examples/multiobjective/mdp/zeroconf/zeroconf8_numerical.pctl deleted file mode 100644 index 61b79cd13..000000000 --- a/examples/multiobjective/mdp/zeroconf/zeroconf8_numerical.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F l=4 & ip=1 ] , P>=0.9999910613[ G (error=0) ]) diff --git a/examples/multiobjective/mdp/zeroconf/zeroconf8_pareto.pctl b/examples/multiobjective/mdp/zeroconf/zeroconf8_pareto.pctl deleted file mode 100644 index 694c19e14..000000000 --- a/examples/multiobjective/mdp/zeroconf/zeroconf8_pareto.pctl +++ /dev/null @@ -1 +0,0 @@ - multi(Pmax=? [ F l=4 & ip=1 ] , Pmax=? [ G (error=0) ]) diff --git a/examples/pdtmc/brp/brp.pm b/examples/pdtmc/brp/brp.pm deleted file mode 100644 index 897f9909e..000000000 --- a/examples/pdtmc/brp/brp.pm +++ /dev/null @@ -1,135 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N; -// maximum number of retransmissions -const int MAX; - -// reliability of channels -const double pL; -const double pK; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule diff --git a/examples/pdtmc/brp/brp.prctl b/examples/pdtmc/brp/brp.prctl deleted file mode 100644 index 01e593fb3..000000000 --- a/examples/pdtmc/brp/brp.prctl +++ /dev/null @@ -1,2 +0,0 @@ -P<0.5 [ F s=5 ] - diff --git a/examples/pdtmc/brp/brp16_2.pm b/examples/pdtmc/brp/brp16_2.pm deleted file mode 100644 index 2e20b7de4..000000000 --- a/examples/pdtmc/brp/brp16_2.pm +++ /dev/null @@ -1,135 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 16; -// maximum number of retransmissions -const int MAX = 2; - -// reliability of channels -const double pL; -const double pK; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule diff --git a/examples/pdtmc/brp/brp256_5.pm b/examples/pdtmc/brp/brp256_5.pm deleted file mode 100644 index d0c03e52c..000000000 --- a/examples/pdtmc/brp/brp256_5.pm +++ /dev/null @@ -1,135 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 256; -// maximum number of retransmissions -const int MAX = 5; - -// reliability of channels -const double pL; -const double pK; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule diff --git a/examples/pdtmc/brp/brp512_5.pm b/examples/pdtmc/brp/brp512_5.pm deleted file mode 100644 index e70b2a0d4..000000000 --- a/examples/pdtmc/brp/brp512_5.pm +++ /dev/null @@ -1,135 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 512; -// maximum number of retransmissions -const int MAX = 5; - -// reliability of channels -const double pL; -const double pK; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule diff --git a/examples/pdtmc/brp/brp64_4.pm b/examples/pdtmc/brp/brp64_4.pm deleted file mode 100644 index 6b3819cb2..000000000 --- a/examples/pdtmc/brp/brp64_4.pm +++ /dev/null @@ -1,135 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 64; -// maximum number of retransmissions -const int MAX = 4; - -// reliability of channels -const double pL; -const double pK; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule diff --git a/examples/pdtmc/brp/brp_regions.txt b/examples/pdtmc/brp/brp_regions.txt deleted file mode 100644 index c1c19ee3b..000000000 --- a/examples/pdtmc/brp/brp_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=pL<=0.040000, 0.000010<=pK<=0.040000; -0.000010<=pL<=0.040000, 0.040000<=pK<=0.080000; -0.000010<=pL<=0.040000, 0.080000<=pK<=0.120000; -0.000010<=pL<=0.040000, 0.120000<=pK<=0.160000; -0.000010<=pL<=0.040000, 0.160000<=pK<=0.200000; -0.000010<=pL<=0.040000, 0.200000<=pK<=0.240000; -0.000010<=pL<=0.040000, 0.240000<=pK<=0.280000; -0.000010<=pL<=0.040000, 0.280000<=pK<=0.320000; -0.000010<=pL<=0.040000, 0.320000<=pK<=0.360000; -0.000010<=pL<=0.040000, 0.360000<=pK<=0.400000; -0.000010<=pL<=0.040000, 0.400000<=pK<=0.440000; -0.000010<=pL<=0.040000, 0.440000<=pK<=0.480000; -0.000010<=pL<=0.040000, 0.480000<=pK<=0.520000; -0.000010<=pL<=0.040000, 0.520000<=pK<=0.560000; -0.000010<=pL<=0.040000, 0.560000<=pK<=0.600000; -0.000010<=pL<=0.040000, 0.600000<=pK<=0.640000; -0.000010<=pL<=0.040000, 0.640000<=pK<=0.680000; -0.000010<=pL<=0.040000, 0.680000<=pK<=0.720000; -0.000010<=pL<=0.040000, 0.720000<=pK<=0.760000; -0.000010<=pL<=0.040000, 0.760000<=pK<=0.800000; -0.000010<=pL<=0.040000, 0.800000<=pK<=0.840000; -0.000010<=pL<=0.040000, 0.840000<=pK<=0.880000; -0.000010<=pL<=0.040000, 0.880000<=pK<=0.920000; -0.000010<=pL<=0.040000, 0.920000<=pK<=0.960000; -0.000010<=pL<=0.040000, 0.960000<=pK<=0.999990; -0.040000<=pL<=0.080000, 0.000010<=pK<=0.040000; -0.040000<=pL<=0.080000, 0.040000<=pK<=0.080000; -0.040000<=pL<=0.080000, 0.080000<=pK<=0.120000; -0.040000<=pL<=0.080000, 0.120000<=pK<=0.160000; -0.040000<=pL<=0.080000, 0.160000<=pK<=0.200000; -0.040000<=pL<=0.080000, 0.200000<=pK<=0.240000; -0.040000<=pL<=0.080000, 0.240000<=pK<=0.280000; -0.040000<=pL<=0.080000, 0.280000<=pK<=0.320000; -0.040000<=pL<=0.080000, 0.320000<=pK<=0.360000; -0.040000<=pL<=0.080000, 0.360000<=pK<=0.400000; -0.040000<=pL<=0.080000, 0.400000<=pK<=0.440000; -0.040000<=pL<=0.080000, 0.440000<=pK<=0.480000; -0.040000<=pL<=0.080000, 0.480000<=pK<=0.520000; -0.040000<=pL<=0.080000, 0.520000<=pK<=0.560000; -0.040000<=pL<=0.080000, 0.560000<=pK<=0.600000; -0.040000<=pL<=0.080000, 0.600000<=pK<=0.640000; -0.040000<=pL<=0.080000, 0.640000<=pK<=0.680000; -0.040000<=pL<=0.080000, 0.680000<=pK<=0.720000; -0.040000<=pL<=0.080000, 0.720000<=pK<=0.760000; -0.040000<=pL<=0.080000, 0.760000<=pK<=0.800000; -0.040000<=pL<=0.080000, 0.800000<=pK<=0.840000; -0.040000<=pL<=0.080000, 0.840000<=pK<=0.880000; -0.040000<=pL<=0.080000, 0.880000<=pK<=0.920000; -0.040000<=pL<=0.080000, 0.920000<=pK<=0.960000; -0.040000<=pL<=0.080000, 0.960000<=pK<=0.999990; -0.080000<=pL<=0.120000, 0.000010<=pK<=0.040000; -0.080000<=pL<=0.120000, 0.040000<=pK<=0.080000; -0.080000<=pL<=0.120000, 0.080000<=pK<=0.120000; -0.080000<=pL<=0.120000, 0.120000<=pK<=0.160000; -0.080000<=pL<=0.120000, 0.160000<=pK<=0.200000; -0.080000<=pL<=0.120000, 0.200000<=pK<=0.240000; -0.080000<=pL<=0.120000, 0.240000<=pK<=0.280000; -0.080000<=pL<=0.120000, 0.280000<=pK<=0.320000; -0.080000<=pL<=0.120000, 0.320000<=pK<=0.360000; -0.080000<=pL<=0.120000, 0.360000<=pK<=0.400000; -0.080000<=pL<=0.120000, 0.400000<=pK<=0.440000; -0.080000<=pL<=0.120000, 0.440000<=pK<=0.480000; -0.080000<=pL<=0.120000, 0.480000<=pK<=0.520000; -0.080000<=pL<=0.120000, 0.520000<=pK<=0.560000; -0.080000<=pL<=0.120000, 0.560000<=pK<=0.600000; -0.080000<=pL<=0.120000, 0.600000<=pK<=0.640000; -0.080000<=pL<=0.120000, 0.640000<=pK<=0.680000; -0.080000<=pL<=0.120000, 0.680000<=pK<=0.720000; -0.080000<=pL<=0.120000, 0.720000<=pK<=0.760000; -0.080000<=pL<=0.120000, 0.760000<=pK<=0.800000; -0.080000<=pL<=0.120000, 0.800000<=pK<=0.840000; -0.080000<=pL<=0.120000, 0.840000<=pK<=0.880000; -0.080000<=pL<=0.120000, 0.880000<=pK<=0.920000; -0.080000<=pL<=0.120000, 0.920000<=pK<=0.960000; -0.080000<=pL<=0.120000, 0.960000<=pK<=0.999990; -0.120000<=pL<=0.160000, 0.000010<=pK<=0.040000; -0.120000<=pL<=0.160000, 0.040000<=pK<=0.080000; -0.120000<=pL<=0.160000, 0.080000<=pK<=0.120000; -0.120000<=pL<=0.160000, 0.120000<=pK<=0.160000; -0.120000<=pL<=0.160000, 0.160000<=pK<=0.200000; -0.120000<=pL<=0.160000, 0.200000<=pK<=0.240000; -0.120000<=pL<=0.160000, 0.240000<=pK<=0.280000; -0.120000<=pL<=0.160000, 0.280000<=pK<=0.320000; -0.120000<=pL<=0.160000, 0.320000<=pK<=0.360000; -0.120000<=pL<=0.160000, 0.360000<=pK<=0.400000; -0.120000<=pL<=0.160000, 0.400000<=pK<=0.440000; -0.120000<=pL<=0.160000, 0.440000<=pK<=0.480000; -0.120000<=pL<=0.160000, 0.480000<=pK<=0.520000; -0.120000<=pL<=0.160000, 0.520000<=pK<=0.560000; -0.120000<=pL<=0.160000, 0.560000<=pK<=0.600000; -0.120000<=pL<=0.160000, 0.600000<=pK<=0.640000; -0.120000<=pL<=0.160000, 0.640000<=pK<=0.680000; -0.120000<=pL<=0.160000, 0.680000<=pK<=0.720000; -0.120000<=pL<=0.160000, 0.720000<=pK<=0.760000; -0.120000<=pL<=0.160000, 0.760000<=pK<=0.800000; -0.120000<=pL<=0.160000, 0.800000<=pK<=0.840000; -0.120000<=pL<=0.160000, 0.840000<=pK<=0.880000; -0.120000<=pL<=0.160000, 0.880000<=pK<=0.920000; -0.120000<=pL<=0.160000, 0.920000<=pK<=0.960000; -0.120000<=pL<=0.160000, 0.960000<=pK<=0.999990; -0.160000<=pL<=0.200000, 0.000010<=pK<=0.040000; -0.160000<=pL<=0.200000, 0.040000<=pK<=0.080000; -0.160000<=pL<=0.200000, 0.080000<=pK<=0.120000; -0.160000<=pL<=0.200000, 0.120000<=pK<=0.160000; -0.160000<=pL<=0.200000, 0.160000<=pK<=0.200000; -0.160000<=pL<=0.200000, 0.200000<=pK<=0.240000; -0.160000<=pL<=0.200000, 0.240000<=pK<=0.280000; -0.160000<=pL<=0.200000, 0.280000<=pK<=0.320000; -0.160000<=pL<=0.200000, 0.320000<=pK<=0.360000; -0.160000<=pL<=0.200000, 0.360000<=pK<=0.400000; -0.160000<=pL<=0.200000, 0.400000<=pK<=0.440000; -0.160000<=pL<=0.200000, 0.440000<=pK<=0.480000; -0.160000<=pL<=0.200000, 0.480000<=pK<=0.520000; -0.160000<=pL<=0.200000, 0.520000<=pK<=0.560000; -0.160000<=pL<=0.200000, 0.560000<=pK<=0.600000; -0.160000<=pL<=0.200000, 0.600000<=pK<=0.640000; -0.160000<=pL<=0.200000, 0.640000<=pK<=0.680000; -0.160000<=pL<=0.200000, 0.680000<=pK<=0.720000; -0.160000<=pL<=0.200000, 0.720000<=pK<=0.760000; -0.160000<=pL<=0.200000, 0.760000<=pK<=0.800000; -0.160000<=pL<=0.200000, 0.800000<=pK<=0.840000; -0.160000<=pL<=0.200000, 0.840000<=pK<=0.880000; -0.160000<=pL<=0.200000, 0.880000<=pK<=0.920000; -0.160000<=pL<=0.200000, 0.920000<=pK<=0.960000; -0.160000<=pL<=0.200000, 0.960000<=pK<=0.999990; -0.200000<=pL<=0.240000, 0.000010<=pK<=0.040000; -0.200000<=pL<=0.240000, 0.040000<=pK<=0.080000; -0.200000<=pL<=0.240000, 0.080000<=pK<=0.120000; -0.200000<=pL<=0.240000, 0.120000<=pK<=0.160000; -0.200000<=pL<=0.240000, 0.160000<=pK<=0.200000; -0.200000<=pL<=0.240000, 0.200000<=pK<=0.240000; -0.200000<=pL<=0.240000, 0.240000<=pK<=0.280000; -0.200000<=pL<=0.240000, 0.280000<=pK<=0.320000; -0.200000<=pL<=0.240000, 0.320000<=pK<=0.360000; -0.200000<=pL<=0.240000, 0.360000<=pK<=0.400000; -0.200000<=pL<=0.240000, 0.400000<=pK<=0.440000; -0.200000<=pL<=0.240000, 0.440000<=pK<=0.480000; -0.200000<=pL<=0.240000, 0.480000<=pK<=0.520000; -0.200000<=pL<=0.240000, 0.520000<=pK<=0.560000; -0.200000<=pL<=0.240000, 0.560000<=pK<=0.600000; -0.200000<=pL<=0.240000, 0.600000<=pK<=0.640000; -0.200000<=pL<=0.240000, 0.640000<=pK<=0.680000; -0.200000<=pL<=0.240000, 0.680000<=pK<=0.720000; -0.200000<=pL<=0.240000, 0.720000<=pK<=0.760000; -0.200000<=pL<=0.240000, 0.760000<=pK<=0.800000; -0.200000<=pL<=0.240000, 0.800000<=pK<=0.840000; -0.200000<=pL<=0.240000, 0.840000<=pK<=0.880000; -0.200000<=pL<=0.240000, 0.880000<=pK<=0.920000; -0.200000<=pL<=0.240000, 0.920000<=pK<=0.960000; -0.200000<=pL<=0.240000, 0.960000<=pK<=0.999990; -0.240000<=pL<=0.280000, 0.000010<=pK<=0.040000; -0.240000<=pL<=0.280000, 0.040000<=pK<=0.080000; -0.240000<=pL<=0.280000, 0.080000<=pK<=0.120000; -0.240000<=pL<=0.280000, 0.120000<=pK<=0.160000; -0.240000<=pL<=0.280000, 0.160000<=pK<=0.200000; -0.240000<=pL<=0.280000, 0.200000<=pK<=0.240000; -0.240000<=pL<=0.280000, 0.240000<=pK<=0.280000; -0.240000<=pL<=0.280000, 0.280000<=pK<=0.320000; -0.240000<=pL<=0.280000, 0.320000<=pK<=0.360000; -0.240000<=pL<=0.280000, 0.360000<=pK<=0.400000; -0.240000<=pL<=0.280000, 0.400000<=pK<=0.440000; -0.240000<=pL<=0.280000, 0.440000<=pK<=0.480000; -0.240000<=pL<=0.280000, 0.480000<=pK<=0.520000; -0.240000<=pL<=0.280000, 0.520000<=pK<=0.560000; -0.240000<=pL<=0.280000, 0.560000<=pK<=0.600000; -0.240000<=pL<=0.280000, 0.600000<=pK<=0.640000; -0.240000<=pL<=0.280000, 0.640000<=pK<=0.680000; -0.240000<=pL<=0.280000, 0.680000<=pK<=0.720000; -0.240000<=pL<=0.280000, 0.720000<=pK<=0.760000; -0.240000<=pL<=0.280000, 0.760000<=pK<=0.800000; -0.240000<=pL<=0.280000, 0.800000<=pK<=0.840000; -0.240000<=pL<=0.280000, 0.840000<=pK<=0.880000; -0.240000<=pL<=0.280000, 0.880000<=pK<=0.920000; -0.240000<=pL<=0.280000, 0.920000<=pK<=0.960000; -0.240000<=pL<=0.280000, 0.960000<=pK<=0.999990; -0.280000<=pL<=0.320000, 0.000010<=pK<=0.040000; -0.280000<=pL<=0.320000, 0.040000<=pK<=0.080000; -0.280000<=pL<=0.320000, 0.080000<=pK<=0.120000; -0.280000<=pL<=0.320000, 0.120000<=pK<=0.160000; -0.280000<=pL<=0.320000, 0.160000<=pK<=0.200000; -0.280000<=pL<=0.320000, 0.200000<=pK<=0.240000; -0.280000<=pL<=0.320000, 0.240000<=pK<=0.280000; -0.280000<=pL<=0.320000, 0.280000<=pK<=0.320000; -0.280000<=pL<=0.320000, 0.320000<=pK<=0.360000; -0.280000<=pL<=0.320000, 0.360000<=pK<=0.400000; -0.280000<=pL<=0.320000, 0.400000<=pK<=0.440000; -0.280000<=pL<=0.320000, 0.440000<=pK<=0.480000; -0.280000<=pL<=0.320000, 0.480000<=pK<=0.520000; -0.280000<=pL<=0.320000, 0.520000<=pK<=0.560000; -0.280000<=pL<=0.320000, 0.560000<=pK<=0.600000; -0.280000<=pL<=0.320000, 0.600000<=pK<=0.640000; -0.280000<=pL<=0.320000, 0.640000<=pK<=0.680000; -0.280000<=pL<=0.320000, 0.680000<=pK<=0.720000; -0.280000<=pL<=0.320000, 0.720000<=pK<=0.760000; -0.280000<=pL<=0.320000, 0.760000<=pK<=0.800000; -0.280000<=pL<=0.320000, 0.800000<=pK<=0.840000; -0.280000<=pL<=0.320000, 0.840000<=pK<=0.880000; -0.280000<=pL<=0.320000, 0.880000<=pK<=0.920000; -0.280000<=pL<=0.320000, 0.920000<=pK<=0.960000; -0.280000<=pL<=0.320000, 0.960000<=pK<=0.999990; -0.320000<=pL<=0.360000, 0.000010<=pK<=0.040000; -0.320000<=pL<=0.360000, 0.040000<=pK<=0.080000; -0.320000<=pL<=0.360000, 0.080000<=pK<=0.120000; -0.320000<=pL<=0.360000, 0.120000<=pK<=0.160000; -0.320000<=pL<=0.360000, 0.160000<=pK<=0.200000; -0.320000<=pL<=0.360000, 0.200000<=pK<=0.240000; -0.320000<=pL<=0.360000, 0.240000<=pK<=0.280000; -0.320000<=pL<=0.360000, 0.280000<=pK<=0.320000; -0.320000<=pL<=0.360000, 0.320000<=pK<=0.360000; -0.320000<=pL<=0.360000, 0.360000<=pK<=0.400000; -0.320000<=pL<=0.360000, 0.400000<=pK<=0.440000; -0.320000<=pL<=0.360000, 0.440000<=pK<=0.480000; -0.320000<=pL<=0.360000, 0.480000<=pK<=0.520000; -0.320000<=pL<=0.360000, 0.520000<=pK<=0.560000; -0.320000<=pL<=0.360000, 0.560000<=pK<=0.600000; -0.320000<=pL<=0.360000, 0.600000<=pK<=0.640000; -0.320000<=pL<=0.360000, 0.640000<=pK<=0.680000; -0.320000<=pL<=0.360000, 0.680000<=pK<=0.720000; -0.320000<=pL<=0.360000, 0.720000<=pK<=0.760000; -0.320000<=pL<=0.360000, 0.760000<=pK<=0.800000; -0.320000<=pL<=0.360000, 0.800000<=pK<=0.840000; -0.320000<=pL<=0.360000, 0.840000<=pK<=0.880000; -0.320000<=pL<=0.360000, 0.880000<=pK<=0.920000; -0.320000<=pL<=0.360000, 0.920000<=pK<=0.960000; -0.320000<=pL<=0.360000, 0.960000<=pK<=0.999990; -0.360000<=pL<=0.400000, 0.000010<=pK<=0.040000; -0.360000<=pL<=0.400000, 0.040000<=pK<=0.080000; -0.360000<=pL<=0.400000, 0.080000<=pK<=0.120000; -0.360000<=pL<=0.400000, 0.120000<=pK<=0.160000; -0.360000<=pL<=0.400000, 0.160000<=pK<=0.200000; -0.360000<=pL<=0.400000, 0.200000<=pK<=0.240000; -0.360000<=pL<=0.400000, 0.240000<=pK<=0.280000; -0.360000<=pL<=0.400000, 0.280000<=pK<=0.320000; -0.360000<=pL<=0.400000, 0.320000<=pK<=0.360000; -0.360000<=pL<=0.400000, 0.360000<=pK<=0.400000; -0.360000<=pL<=0.400000, 0.400000<=pK<=0.440000; -0.360000<=pL<=0.400000, 0.440000<=pK<=0.480000; -0.360000<=pL<=0.400000, 0.480000<=pK<=0.520000; -0.360000<=pL<=0.400000, 0.520000<=pK<=0.560000; -0.360000<=pL<=0.400000, 0.560000<=pK<=0.600000; -0.360000<=pL<=0.400000, 0.600000<=pK<=0.640000; -0.360000<=pL<=0.400000, 0.640000<=pK<=0.680000; -0.360000<=pL<=0.400000, 0.680000<=pK<=0.720000; -0.360000<=pL<=0.400000, 0.720000<=pK<=0.760000; -0.360000<=pL<=0.400000, 0.760000<=pK<=0.800000; -0.360000<=pL<=0.400000, 0.800000<=pK<=0.840000; -0.360000<=pL<=0.400000, 0.840000<=pK<=0.880000; -0.360000<=pL<=0.400000, 0.880000<=pK<=0.920000; -0.360000<=pL<=0.400000, 0.920000<=pK<=0.960000; -0.360000<=pL<=0.400000, 0.960000<=pK<=0.999990; -0.400000<=pL<=0.440000, 0.000010<=pK<=0.040000; -0.400000<=pL<=0.440000, 0.040000<=pK<=0.080000; -0.400000<=pL<=0.440000, 0.080000<=pK<=0.120000; -0.400000<=pL<=0.440000, 0.120000<=pK<=0.160000; -0.400000<=pL<=0.440000, 0.160000<=pK<=0.200000; -0.400000<=pL<=0.440000, 0.200000<=pK<=0.240000; -0.400000<=pL<=0.440000, 0.240000<=pK<=0.280000; -0.400000<=pL<=0.440000, 0.280000<=pK<=0.320000; -0.400000<=pL<=0.440000, 0.320000<=pK<=0.360000; -0.400000<=pL<=0.440000, 0.360000<=pK<=0.400000; -0.400000<=pL<=0.440000, 0.400000<=pK<=0.440000; -0.400000<=pL<=0.440000, 0.440000<=pK<=0.480000; -0.400000<=pL<=0.440000, 0.480000<=pK<=0.520000; -0.400000<=pL<=0.440000, 0.520000<=pK<=0.560000; -0.400000<=pL<=0.440000, 0.560000<=pK<=0.600000; -0.400000<=pL<=0.440000, 0.600000<=pK<=0.640000; -0.400000<=pL<=0.440000, 0.640000<=pK<=0.680000; -0.400000<=pL<=0.440000, 0.680000<=pK<=0.720000; -0.400000<=pL<=0.440000, 0.720000<=pK<=0.760000; -0.400000<=pL<=0.440000, 0.760000<=pK<=0.800000; -0.400000<=pL<=0.440000, 0.800000<=pK<=0.840000; -0.400000<=pL<=0.440000, 0.840000<=pK<=0.880000; -0.400000<=pL<=0.440000, 0.880000<=pK<=0.920000; -0.400000<=pL<=0.440000, 0.920000<=pK<=0.960000; -0.400000<=pL<=0.440000, 0.960000<=pK<=0.999990; -0.440000<=pL<=0.480000, 0.000010<=pK<=0.040000; -0.440000<=pL<=0.480000, 0.040000<=pK<=0.080000; -0.440000<=pL<=0.480000, 0.080000<=pK<=0.120000; -0.440000<=pL<=0.480000, 0.120000<=pK<=0.160000; -0.440000<=pL<=0.480000, 0.160000<=pK<=0.200000; -0.440000<=pL<=0.480000, 0.200000<=pK<=0.240000; -0.440000<=pL<=0.480000, 0.240000<=pK<=0.280000; -0.440000<=pL<=0.480000, 0.280000<=pK<=0.320000; -0.440000<=pL<=0.480000, 0.320000<=pK<=0.360000; -0.440000<=pL<=0.480000, 0.360000<=pK<=0.400000; -0.440000<=pL<=0.480000, 0.400000<=pK<=0.440000; -0.440000<=pL<=0.480000, 0.440000<=pK<=0.480000; -0.440000<=pL<=0.480000, 0.480000<=pK<=0.520000; -0.440000<=pL<=0.480000, 0.520000<=pK<=0.560000; -0.440000<=pL<=0.480000, 0.560000<=pK<=0.600000; -0.440000<=pL<=0.480000, 0.600000<=pK<=0.640000; -0.440000<=pL<=0.480000, 0.640000<=pK<=0.680000; -0.440000<=pL<=0.480000, 0.680000<=pK<=0.720000; -0.440000<=pL<=0.480000, 0.720000<=pK<=0.760000; -0.440000<=pL<=0.480000, 0.760000<=pK<=0.800000; -0.440000<=pL<=0.480000, 0.800000<=pK<=0.840000; -0.440000<=pL<=0.480000, 0.840000<=pK<=0.880000; -0.440000<=pL<=0.480000, 0.880000<=pK<=0.920000; -0.440000<=pL<=0.480000, 0.920000<=pK<=0.960000; -0.440000<=pL<=0.480000, 0.960000<=pK<=0.999990; -0.480000<=pL<=0.520000, 0.000010<=pK<=0.040000; -0.480000<=pL<=0.520000, 0.040000<=pK<=0.080000; -0.480000<=pL<=0.520000, 0.080000<=pK<=0.120000; -0.480000<=pL<=0.520000, 0.120000<=pK<=0.160000; -0.480000<=pL<=0.520000, 0.160000<=pK<=0.200000; -0.480000<=pL<=0.520000, 0.200000<=pK<=0.240000; -0.480000<=pL<=0.520000, 0.240000<=pK<=0.280000; -0.480000<=pL<=0.520000, 0.280000<=pK<=0.320000; -0.480000<=pL<=0.520000, 0.320000<=pK<=0.360000; -0.480000<=pL<=0.520000, 0.360000<=pK<=0.400000; -0.480000<=pL<=0.520000, 0.400000<=pK<=0.440000; -0.480000<=pL<=0.520000, 0.440000<=pK<=0.480000; -0.480000<=pL<=0.520000, 0.480000<=pK<=0.520000; -0.480000<=pL<=0.520000, 0.520000<=pK<=0.560000; -0.480000<=pL<=0.520000, 0.560000<=pK<=0.600000; -0.480000<=pL<=0.520000, 0.600000<=pK<=0.640000; -0.480000<=pL<=0.520000, 0.640000<=pK<=0.680000; -0.480000<=pL<=0.520000, 0.680000<=pK<=0.720000; -0.480000<=pL<=0.520000, 0.720000<=pK<=0.760000; -0.480000<=pL<=0.520000, 0.760000<=pK<=0.800000; -0.480000<=pL<=0.520000, 0.800000<=pK<=0.840000; -0.480000<=pL<=0.520000, 0.840000<=pK<=0.880000; -0.480000<=pL<=0.520000, 0.880000<=pK<=0.920000; -0.480000<=pL<=0.520000, 0.920000<=pK<=0.960000; -0.480000<=pL<=0.520000, 0.960000<=pK<=0.999990; -0.520000<=pL<=0.560000, 0.000010<=pK<=0.040000; -0.520000<=pL<=0.560000, 0.040000<=pK<=0.080000; -0.520000<=pL<=0.560000, 0.080000<=pK<=0.120000; -0.520000<=pL<=0.560000, 0.120000<=pK<=0.160000; -0.520000<=pL<=0.560000, 0.160000<=pK<=0.200000; -0.520000<=pL<=0.560000, 0.200000<=pK<=0.240000; -0.520000<=pL<=0.560000, 0.240000<=pK<=0.280000; -0.520000<=pL<=0.560000, 0.280000<=pK<=0.320000; -0.520000<=pL<=0.560000, 0.320000<=pK<=0.360000; -0.520000<=pL<=0.560000, 0.360000<=pK<=0.400000; -0.520000<=pL<=0.560000, 0.400000<=pK<=0.440000; -0.520000<=pL<=0.560000, 0.440000<=pK<=0.480000; -0.520000<=pL<=0.560000, 0.480000<=pK<=0.520000; -0.520000<=pL<=0.560000, 0.520000<=pK<=0.560000; -0.520000<=pL<=0.560000, 0.560000<=pK<=0.600000; -0.520000<=pL<=0.560000, 0.600000<=pK<=0.640000; -0.520000<=pL<=0.560000, 0.640000<=pK<=0.680000; -0.520000<=pL<=0.560000, 0.680000<=pK<=0.720000; -0.520000<=pL<=0.560000, 0.720000<=pK<=0.760000; -0.520000<=pL<=0.560000, 0.760000<=pK<=0.800000; -0.520000<=pL<=0.560000, 0.800000<=pK<=0.840000; -0.520000<=pL<=0.560000, 0.840000<=pK<=0.880000; -0.520000<=pL<=0.560000, 0.880000<=pK<=0.920000; -0.520000<=pL<=0.560000, 0.920000<=pK<=0.960000; -0.520000<=pL<=0.560000, 0.960000<=pK<=0.999990; -0.560000<=pL<=0.600000, 0.000010<=pK<=0.040000; -0.560000<=pL<=0.600000, 0.040000<=pK<=0.080000; -0.560000<=pL<=0.600000, 0.080000<=pK<=0.120000; -0.560000<=pL<=0.600000, 0.120000<=pK<=0.160000; -0.560000<=pL<=0.600000, 0.160000<=pK<=0.200000; -0.560000<=pL<=0.600000, 0.200000<=pK<=0.240000; -0.560000<=pL<=0.600000, 0.240000<=pK<=0.280000; -0.560000<=pL<=0.600000, 0.280000<=pK<=0.320000; -0.560000<=pL<=0.600000, 0.320000<=pK<=0.360000; -0.560000<=pL<=0.600000, 0.360000<=pK<=0.400000; -0.560000<=pL<=0.600000, 0.400000<=pK<=0.440000; -0.560000<=pL<=0.600000, 0.440000<=pK<=0.480000; -0.560000<=pL<=0.600000, 0.480000<=pK<=0.520000; -0.560000<=pL<=0.600000, 0.520000<=pK<=0.560000; -0.560000<=pL<=0.600000, 0.560000<=pK<=0.600000; -0.560000<=pL<=0.600000, 0.600000<=pK<=0.640000; -0.560000<=pL<=0.600000, 0.640000<=pK<=0.680000; -0.560000<=pL<=0.600000, 0.680000<=pK<=0.720000; -0.560000<=pL<=0.600000, 0.720000<=pK<=0.760000; -0.560000<=pL<=0.600000, 0.760000<=pK<=0.800000; -0.560000<=pL<=0.600000, 0.800000<=pK<=0.840000; -0.560000<=pL<=0.600000, 0.840000<=pK<=0.880000; -0.560000<=pL<=0.600000, 0.880000<=pK<=0.920000; -0.560000<=pL<=0.600000, 0.920000<=pK<=0.960000; -0.560000<=pL<=0.600000, 0.960000<=pK<=0.999990; -0.600000<=pL<=0.640000, 0.000010<=pK<=0.040000; -0.600000<=pL<=0.640000, 0.040000<=pK<=0.080000; -0.600000<=pL<=0.640000, 0.080000<=pK<=0.120000; -0.600000<=pL<=0.640000, 0.120000<=pK<=0.160000; -0.600000<=pL<=0.640000, 0.160000<=pK<=0.200000; -0.600000<=pL<=0.640000, 0.200000<=pK<=0.240000; -0.600000<=pL<=0.640000, 0.240000<=pK<=0.280000; -0.600000<=pL<=0.640000, 0.280000<=pK<=0.320000; -0.600000<=pL<=0.640000, 0.320000<=pK<=0.360000; -0.600000<=pL<=0.640000, 0.360000<=pK<=0.400000; -0.600000<=pL<=0.640000, 0.400000<=pK<=0.440000; -0.600000<=pL<=0.640000, 0.440000<=pK<=0.480000; -0.600000<=pL<=0.640000, 0.480000<=pK<=0.520000; -0.600000<=pL<=0.640000, 0.520000<=pK<=0.560000; -0.600000<=pL<=0.640000, 0.560000<=pK<=0.600000; -0.600000<=pL<=0.640000, 0.600000<=pK<=0.640000; -0.600000<=pL<=0.640000, 0.640000<=pK<=0.680000; -0.600000<=pL<=0.640000, 0.680000<=pK<=0.720000; -0.600000<=pL<=0.640000, 0.720000<=pK<=0.760000; -0.600000<=pL<=0.640000, 0.760000<=pK<=0.800000; -0.600000<=pL<=0.640000, 0.800000<=pK<=0.840000; -0.600000<=pL<=0.640000, 0.840000<=pK<=0.880000; -0.600000<=pL<=0.640000, 0.880000<=pK<=0.920000; -0.600000<=pL<=0.640000, 0.920000<=pK<=0.960000; -0.600000<=pL<=0.640000, 0.960000<=pK<=0.999990; -0.640000<=pL<=0.680000, 0.000010<=pK<=0.040000; -0.640000<=pL<=0.680000, 0.040000<=pK<=0.080000; -0.640000<=pL<=0.680000, 0.080000<=pK<=0.120000; -0.640000<=pL<=0.680000, 0.120000<=pK<=0.160000; -0.640000<=pL<=0.680000, 0.160000<=pK<=0.200000; -0.640000<=pL<=0.680000, 0.200000<=pK<=0.240000; -0.640000<=pL<=0.680000, 0.240000<=pK<=0.280000; -0.640000<=pL<=0.680000, 0.280000<=pK<=0.320000; -0.640000<=pL<=0.680000, 0.320000<=pK<=0.360000; -0.640000<=pL<=0.680000, 0.360000<=pK<=0.400000; -0.640000<=pL<=0.680000, 0.400000<=pK<=0.440000; -0.640000<=pL<=0.680000, 0.440000<=pK<=0.480000; -0.640000<=pL<=0.680000, 0.480000<=pK<=0.520000; -0.640000<=pL<=0.680000, 0.520000<=pK<=0.560000; -0.640000<=pL<=0.680000, 0.560000<=pK<=0.600000; -0.640000<=pL<=0.680000, 0.600000<=pK<=0.640000; -0.640000<=pL<=0.680000, 0.640000<=pK<=0.680000; -0.640000<=pL<=0.680000, 0.680000<=pK<=0.720000; -0.640000<=pL<=0.680000, 0.720000<=pK<=0.760000; -0.640000<=pL<=0.680000, 0.760000<=pK<=0.800000; -0.640000<=pL<=0.680000, 0.800000<=pK<=0.840000; -0.640000<=pL<=0.680000, 0.840000<=pK<=0.880000; -0.640000<=pL<=0.680000, 0.880000<=pK<=0.920000; -0.640000<=pL<=0.680000, 0.920000<=pK<=0.960000; -0.640000<=pL<=0.680000, 0.960000<=pK<=0.999990; -0.680000<=pL<=0.720000, 0.000010<=pK<=0.040000; -0.680000<=pL<=0.720000, 0.040000<=pK<=0.080000; -0.680000<=pL<=0.720000, 0.080000<=pK<=0.120000; -0.680000<=pL<=0.720000, 0.120000<=pK<=0.160000; -0.680000<=pL<=0.720000, 0.160000<=pK<=0.200000; -0.680000<=pL<=0.720000, 0.200000<=pK<=0.240000; -0.680000<=pL<=0.720000, 0.240000<=pK<=0.280000; -0.680000<=pL<=0.720000, 0.280000<=pK<=0.320000; -0.680000<=pL<=0.720000, 0.320000<=pK<=0.360000; -0.680000<=pL<=0.720000, 0.360000<=pK<=0.400000; -0.680000<=pL<=0.720000, 0.400000<=pK<=0.440000; -0.680000<=pL<=0.720000, 0.440000<=pK<=0.480000; -0.680000<=pL<=0.720000, 0.480000<=pK<=0.520000; -0.680000<=pL<=0.720000, 0.520000<=pK<=0.560000; -0.680000<=pL<=0.720000, 0.560000<=pK<=0.600000; -0.680000<=pL<=0.720000, 0.600000<=pK<=0.640000; -0.680000<=pL<=0.720000, 0.640000<=pK<=0.680000; -0.680000<=pL<=0.720000, 0.680000<=pK<=0.720000; -0.680000<=pL<=0.720000, 0.720000<=pK<=0.760000; -0.680000<=pL<=0.720000, 0.760000<=pK<=0.800000; -0.680000<=pL<=0.720000, 0.800000<=pK<=0.840000; -0.680000<=pL<=0.720000, 0.840000<=pK<=0.880000; -0.680000<=pL<=0.720000, 0.880000<=pK<=0.920000; -0.680000<=pL<=0.720000, 0.920000<=pK<=0.960000; -0.680000<=pL<=0.720000, 0.960000<=pK<=0.999990; -0.720000<=pL<=0.760000, 0.000010<=pK<=0.040000; -0.720000<=pL<=0.760000, 0.040000<=pK<=0.080000; -0.720000<=pL<=0.760000, 0.080000<=pK<=0.120000; -0.720000<=pL<=0.760000, 0.120000<=pK<=0.160000; -0.720000<=pL<=0.760000, 0.160000<=pK<=0.200000; -0.720000<=pL<=0.760000, 0.200000<=pK<=0.240000; -0.720000<=pL<=0.760000, 0.240000<=pK<=0.280000; -0.720000<=pL<=0.760000, 0.280000<=pK<=0.320000; -0.720000<=pL<=0.760000, 0.320000<=pK<=0.360000; -0.720000<=pL<=0.760000, 0.360000<=pK<=0.400000; -0.720000<=pL<=0.760000, 0.400000<=pK<=0.440000; -0.720000<=pL<=0.760000, 0.440000<=pK<=0.480000; -0.720000<=pL<=0.760000, 0.480000<=pK<=0.520000; -0.720000<=pL<=0.760000, 0.520000<=pK<=0.560000; -0.720000<=pL<=0.760000, 0.560000<=pK<=0.600000; -0.720000<=pL<=0.760000, 0.600000<=pK<=0.640000; -0.720000<=pL<=0.760000, 0.640000<=pK<=0.680000; -0.720000<=pL<=0.760000, 0.680000<=pK<=0.720000; -0.720000<=pL<=0.760000, 0.720000<=pK<=0.760000; -0.720000<=pL<=0.760000, 0.760000<=pK<=0.800000; -0.720000<=pL<=0.760000, 0.800000<=pK<=0.840000; -0.720000<=pL<=0.760000, 0.840000<=pK<=0.880000; -0.720000<=pL<=0.760000, 0.880000<=pK<=0.920000; -0.720000<=pL<=0.760000, 0.920000<=pK<=0.960000; -0.720000<=pL<=0.760000, 0.960000<=pK<=0.999990; -0.760000<=pL<=0.800000, 0.000010<=pK<=0.040000; -0.760000<=pL<=0.800000, 0.040000<=pK<=0.080000; -0.760000<=pL<=0.800000, 0.080000<=pK<=0.120000; -0.760000<=pL<=0.800000, 0.120000<=pK<=0.160000; -0.760000<=pL<=0.800000, 0.160000<=pK<=0.200000; -0.760000<=pL<=0.800000, 0.200000<=pK<=0.240000; -0.760000<=pL<=0.800000, 0.240000<=pK<=0.280000; -0.760000<=pL<=0.800000, 0.280000<=pK<=0.320000; -0.760000<=pL<=0.800000, 0.320000<=pK<=0.360000; -0.760000<=pL<=0.800000, 0.360000<=pK<=0.400000; -0.760000<=pL<=0.800000, 0.400000<=pK<=0.440000; -0.760000<=pL<=0.800000, 0.440000<=pK<=0.480000; -0.760000<=pL<=0.800000, 0.480000<=pK<=0.520000; -0.760000<=pL<=0.800000, 0.520000<=pK<=0.560000; -0.760000<=pL<=0.800000, 0.560000<=pK<=0.600000; -0.760000<=pL<=0.800000, 0.600000<=pK<=0.640000; -0.760000<=pL<=0.800000, 0.640000<=pK<=0.680000; -0.760000<=pL<=0.800000, 0.680000<=pK<=0.720000; -0.760000<=pL<=0.800000, 0.720000<=pK<=0.760000; -0.760000<=pL<=0.800000, 0.760000<=pK<=0.800000; -0.760000<=pL<=0.800000, 0.800000<=pK<=0.840000; -0.760000<=pL<=0.800000, 0.840000<=pK<=0.880000; -0.760000<=pL<=0.800000, 0.880000<=pK<=0.920000; -0.760000<=pL<=0.800000, 0.920000<=pK<=0.960000; -0.760000<=pL<=0.800000, 0.960000<=pK<=0.999990; -0.800000<=pL<=0.840000, 0.000010<=pK<=0.040000; -0.800000<=pL<=0.840000, 0.040000<=pK<=0.080000; -0.800000<=pL<=0.840000, 0.080000<=pK<=0.120000; -0.800000<=pL<=0.840000, 0.120000<=pK<=0.160000; -0.800000<=pL<=0.840000, 0.160000<=pK<=0.200000; -0.800000<=pL<=0.840000, 0.200000<=pK<=0.240000; -0.800000<=pL<=0.840000, 0.240000<=pK<=0.280000; -0.800000<=pL<=0.840000, 0.280000<=pK<=0.320000; -0.800000<=pL<=0.840000, 0.320000<=pK<=0.360000; -0.800000<=pL<=0.840000, 0.360000<=pK<=0.400000; -0.800000<=pL<=0.840000, 0.400000<=pK<=0.440000; -0.800000<=pL<=0.840000, 0.440000<=pK<=0.480000; -0.800000<=pL<=0.840000, 0.480000<=pK<=0.520000; -0.800000<=pL<=0.840000, 0.520000<=pK<=0.560000; -0.800000<=pL<=0.840000, 0.560000<=pK<=0.600000; -0.800000<=pL<=0.840000, 0.600000<=pK<=0.640000; -0.800000<=pL<=0.840000, 0.640000<=pK<=0.680000; -0.800000<=pL<=0.840000, 0.680000<=pK<=0.720000; -0.800000<=pL<=0.840000, 0.720000<=pK<=0.760000; -0.800000<=pL<=0.840000, 0.760000<=pK<=0.800000; -0.800000<=pL<=0.840000, 0.800000<=pK<=0.840000; -0.800000<=pL<=0.840000, 0.840000<=pK<=0.880000; -0.800000<=pL<=0.840000, 0.880000<=pK<=0.920000; -0.800000<=pL<=0.840000, 0.920000<=pK<=0.960000; -0.800000<=pL<=0.840000, 0.960000<=pK<=0.999990; -0.840000<=pL<=0.880000, 0.000010<=pK<=0.040000; -0.840000<=pL<=0.880000, 0.040000<=pK<=0.080000; -0.840000<=pL<=0.880000, 0.080000<=pK<=0.120000; -0.840000<=pL<=0.880000, 0.120000<=pK<=0.160000; -0.840000<=pL<=0.880000, 0.160000<=pK<=0.200000; -0.840000<=pL<=0.880000, 0.200000<=pK<=0.240000; -0.840000<=pL<=0.880000, 0.240000<=pK<=0.280000; -0.840000<=pL<=0.880000, 0.280000<=pK<=0.320000; -0.840000<=pL<=0.880000, 0.320000<=pK<=0.360000; -0.840000<=pL<=0.880000, 0.360000<=pK<=0.400000; -0.840000<=pL<=0.880000, 0.400000<=pK<=0.440000; -0.840000<=pL<=0.880000, 0.440000<=pK<=0.480000; -0.840000<=pL<=0.880000, 0.480000<=pK<=0.520000; -0.840000<=pL<=0.880000, 0.520000<=pK<=0.560000; -0.840000<=pL<=0.880000, 0.560000<=pK<=0.600000; -0.840000<=pL<=0.880000, 0.600000<=pK<=0.640000; -0.840000<=pL<=0.880000, 0.640000<=pK<=0.680000; -0.840000<=pL<=0.880000, 0.680000<=pK<=0.720000; -0.840000<=pL<=0.880000, 0.720000<=pK<=0.760000; -0.840000<=pL<=0.880000, 0.760000<=pK<=0.800000; -0.840000<=pL<=0.880000, 0.800000<=pK<=0.840000; -0.840000<=pL<=0.880000, 0.840000<=pK<=0.880000; -0.840000<=pL<=0.880000, 0.880000<=pK<=0.920000; -0.840000<=pL<=0.880000, 0.920000<=pK<=0.960000; -0.840000<=pL<=0.880000, 0.960000<=pK<=0.999990; -0.880000<=pL<=0.920000, 0.000010<=pK<=0.040000; -0.880000<=pL<=0.920000, 0.040000<=pK<=0.080000; -0.880000<=pL<=0.920000, 0.080000<=pK<=0.120000; -0.880000<=pL<=0.920000, 0.120000<=pK<=0.160000; -0.880000<=pL<=0.920000, 0.160000<=pK<=0.200000; -0.880000<=pL<=0.920000, 0.200000<=pK<=0.240000; -0.880000<=pL<=0.920000, 0.240000<=pK<=0.280000; -0.880000<=pL<=0.920000, 0.280000<=pK<=0.320000; -0.880000<=pL<=0.920000, 0.320000<=pK<=0.360000; -0.880000<=pL<=0.920000, 0.360000<=pK<=0.400000; -0.880000<=pL<=0.920000, 0.400000<=pK<=0.440000; -0.880000<=pL<=0.920000, 0.440000<=pK<=0.480000; -0.880000<=pL<=0.920000, 0.480000<=pK<=0.520000; -0.880000<=pL<=0.920000, 0.520000<=pK<=0.560000; -0.880000<=pL<=0.920000, 0.560000<=pK<=0.600000; -0.880000<=pL<=0.920000, 0.600000<=pK<=0.640000; -0.880000<=pL<=0.920000, 0.640000<=pK<=0.680000; -0.880000<=pL<=0.920000, 0.680000<=pK<=0.720000; -0.880000<=pL<=0.920000, 0.720000<=pK<=0.760000; -0.880000<=pL<=0.920000, 0.760000<=pK<=0.800000; -0.880000<=pL<=0.920000, 0.800000<=pK<=0.840000; -0.880000<=pL<=0.920000, 0.840000<=pK<=0.880000; -0.880000<=pL<=0.920000, 0.880000<=pK<=0.920000; -0.880000<=pL<=0.920000, 0.920000<=pK<=0.960000; -0.880000<=pL<=0.920000, 0.960000<=pK<=0.999990; -0.920000<=pL<=0.960000, 0.000010<=pK<=0.040000; -0.920000<=pL<=0.960000, 0.040000<=pK<=0.080000; -0.920000<=pL<=0.960000, 0.080000<=pK<=0.120000; -0.920000<=pL<=0.960000, 0.120000<=pK<=0.160000; -0.920000<=pL<=0.960000, 0.160000<=pK<=0.200000; -0.920000<=pL<=0.960000, 0.200000<=pK<=0.240000; -0.920000<=pL<=0.960000, 0.240000<=pK<=0.280000; -0.920000<=pL<=0.960000, 0.280000<=pK<=0.320000; -0.920000<=pL<=0.960000, 0.320000<=pK<=0.360000; -0.920000<=pL<=0.960000, 0.360000<=pK<=0.400000; -0.920000<=pL<=0.960000, 0.400000<=pK<=0.440000; -0.920000<=pL<=0.960000, 0.440000<=pK<=0.480000; -0.920000<=pL<=0.960000, 0.480000<=pK<=0.520000; -0.920000<=pL<=0.960000, 0.520000<=pK<=0.560000; -0.920000<=pL<=0.960000, 0.560000<=pK<=0.600000; -0.920000<=pL<=0.960000, 0.600000<=pK<=0.640000; -0.920000<=pL<=0.960000, 0.640000<=pK<=0.680000; -0.920000<=pL<=0.960000, 0.680000<=pK<=0.720000; -0.920000<=pL<=0.960000, 0.720000<=pK<=0.760000; -0.920000<=pL<=0.960000, 0.760000<=pK<=0.800000; -0.920000<=pL<=0.960000, 0.800000<=pK<=0.840000; -0.920000<=pL<=0.960000, 0.840000<=pK<=0.880000; -0.920000<=pL<=0.960000, 0.880000<=pK<=0.920000; -0.920000<=pL<=0.960000, 0.920000<=pK<=0.960000; -0.920000<=pL<=0.960000, 0.960000<=pK<=0.999990; -0.960000<=pL<=0.999990, 0.000010<=pK<=0.040000; -0.960000<=pL<=0.999990, 0.040000<=pK<=0.080000; -0.960000<=pL<=0.999990, 0.080000<=pK<=0.120000; -0.960000<=pL<=0.999990, 0.120000<=pK<=0.160000; -0.960000<=pL<=0.999990, 0.160000<=pK<=0.200000; -0.960000<=pL<=0.999990, 0.200000<=pK<=0.240000; -0.960000<=pL<=0.999990, 0.240000<=pK<=0.280000; -0.960000<=pL<=0.999990, 0.280000<=pK<=0.320000; -0.960000<=pL<=0.999990, 0.320000<=pK<=0.360000; -0.960000<=pL<=0.999990, 0.360000<=pK<=0.400000; -0.960000<=pL<=0.999990, 0.400000<=pK<=0.440000; -0.960000<=pL<=0.999990, 0.440000<=pK<=0.480000; -0.960000<=pL<=0.999990, 0.480000<=pK<=0.520000; -0.960000<=pL<=0.999990, 0.520000<=pK<=0.560000; -0.960000<=pL<=0.999990, 0.560000<=pK<=0.600000; -0.960000<=pL<=0.999990, 0.600000<=pK<=0.640000; -0.960000<=pL<=0.999990, 0.640000<=pK<=0.680000; -0.960000<=pL<=0.999990, 0.680000<=pK<=0.720000; -0.960000<=pL<=0.999990, 0.720000<=pK<=0.760000; -0.960000<=pL<=0.999990, 0.760000<=pK<=0.800000; -0.960000<=pL<=0.999990, 0.800000<=pK<=0.840000; -0.960000<=pL<=0.999990, 0.840000<=pK<=0.880000; -0.960000<=pL<=0.999990, 0.880000<=pK<=0.920000; -0.960000<=pL<=0.999990, 0.920000<=pK<=0.960000; -0.960000<=pL<=0.999990, 0.960000<=pK<=0.999990; diff --git a/examples/pdtmc/brp/brp_space.txt b/examples/pdtmc/brp/brp_space.txt deleted file mode 100644 index 444b98e90..000000000 --- a/examples/pdtmc/brp/brp_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=pL<=0.999990, 0.000010<=pK<=0.999990; - diff --git a/examples/pdtmc/brp/models b/examples/pdtmc/brp/models deleted file mode 100644 index b692fffb6..000000000 --- a/examples/pdtmc/brp/models +++ /dev/null @@ -1,2 +0,0 @@ -brp.pm -const N=256,MAX=5 -brp.pm -const N=4096,MAX=5 diff --git a/examples/pdtmc/brp_rewards2/brp_rewards16_2.pm b/examples/pdtmc/brp_rewards2/brp_rewards16_2.pm deleted file mode 100644 index 0b05d22fd..000000000 --- a/examples/pdtmc/brp_rewards2/brp_rewards16_2.pm +++ /dev/null @@ -1,146 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 16; -// maximum number of retransmissions -const int MAX = 2; - -// reliability of channels -const double pL; -const double pK; - -// timeouts -const double TOMsg=0.4; -const double TOAck=0.6; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -rewards - [TO_Msg] true : TOMsg; - [TO_Ack] true : TOAck; -endrewards - - diff --git a/examples/pdtmc/brp_rewards2/brp_rewards2.pm b/examples/pdtmc/brp_rewards2/brp_rewards2.pm deleted file mode 100644 index b4cc546e1..000000000 --- a/examples/pdtmc/brp_rewards2/brp_rewards2.pm +++ /dev/null @@ -1,146 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N; -// maximum number of retransmissions -const int MAX; - -// reliability of channels -const double pL; -const double pK; - -// timeouts -const double TOMsg=0.4; -const double TOAck=0.6; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -rewards - [TO_Msg] true : TOMsg; - [TO_Ack] true : TOAck; -endrewards - - diff --git a/examples/pdtmc/brp_rewards2/brp_rewards2.prctl b/examples/pdtmc/brp_rewards2/brp_rewards2.prctl deleted file mode 100644 index 3a194c0be..000000000 --- a/examples/pdtmc/brp_rewards2/brp_rewards2.prctl +++ /dev/null @@ -1,2 +0,0 @@ -R<3 [ F ((s=5) | (s=0&srep=3)) ] - diff --git a/examples/pdtmc/brp_rewards2/brp_rewards256_5.pm b/examples/pdtmc/brp_rewards2/brp_rewards256_5.pm deleted file mode 100644 index 6d274991a..000000000 --- a/examples/pdtmc/brp_rewards2/brp_rewards256_5.pm +++ /dev/null @@ -1,147 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 256; -// maximum number of retransmissions -const int MAX = 5; - -// reliability of channels -const double pL; -const double pK; - -// timeouts -const double TOMsg=0.4; -const double TOAck=0.6; - - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -rewards - [TO_Msg] true : TOMsg; - [TO_Ack] true : TOAck; -endrewards - - diff --git a/examples/pdtmc/brp_rewards2/brp_rewards2_regions.txt b/examples/pdtmc/brp_rewards2/brp_rewards2_regions.txt deleted file mode 100644 index c1c19ee3b..000000000 --- a/examples/pdtmc/brp_rewards2/brp_rewards2_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=pL<=0.040000, 0.000010<=pK<=0.040000; -0.000010<=pL<=0.040000, 0.040000<=pK<=0.080000; -0.000010<=pL<=0.040000, 0.080000<=pK<=0.120000; -0.000010<=pL<=0.040000, 0.120000<=pK<=0.160000; -0.000010<=pL<=0.040000, 0.160000<=pK<=0.200000; -0.000010<=pL<=0.040000, 0.200000<=pK<=0.240000; -0.000010<=pL<=0.040000, 0.240000<=pK<=0.280000; -0.000010<=pL<=0.040000, 0.280000<=pK<=0.320000; -0.000010<=pL<=0.040000, 0.320000<=pK<=0.360000; -0.000010<=pL<=0.040000, 0.360000<=pK<=0.400000; -0.000010<=pL<=0.040000, 0.400000<=pK<=0.440000; -0.000010<=pL<=0.040000, 0.440000<=pK<=0.480000; -0.000010<=pL<=0.040000, 0.480000<=pK<=0.520000; -0.000010<=pL<=0.040000, 0.520000<=pK<=0.560000; -0.000010<=pL<=0.040000, 0.560000<=pK<=0.600000; -0.000010<=pL<=0.040000, 0.600000<=pK<=0.640000; -0.000010<=pL<=0.040000, 0.640000<=pK<=0.680000; -0.000010<=pL<=0.040000, 0.680000<=pK<=0.720000; -0.000010<=pL<=0.040000, 0.720000<=pK<=0.760000; -0.000010<=pL<=0.040000, 0.760000<=pK<=0.800000; -0.000010<=pL<=0.040000, 0.800000<=pK<=0.840000; -0.000010<=pL<=0.040000, 0.840000<=pK<=0.880000; -0.000010<=pL<=0.040000, 0.880000<=pK<=0.920000; -0.000010<=pL<=0.040000, 0.920000<=pK<=0.960000; -0.000010<=pL<=0.040000, 0.960000<=pK<=0.999990; -0.040000<=pL<=0.080000, 0.000010<=pK<=0.040000; -0.040000<=pL<=0.080000, 0.040000<=pK<=0.080000; -0.040000<=pL<=0.080000, 0.080000<=pK<=0.120000; -0.040000<=pL<=0.080000, 0.120000<=pK<=0.160000; -0.040000<=pL<=0.080000, 0.160000<=pK<=0.200000; -0.040000<=pL<=0.080000, 0.200000<=pK<=0.240000; -0.040000<=pL<=0.080000, 0.240000<=pK<=0.280000; -0.040000<=pL<=0.080000, 0.280000<=pK<=0.320000; -0.040000<=pL<=0.080000, 0.320000<=pK<=0.360000; -0.040000<=pL<=0.080000, 0.360000<=pK<=0.400000; -0.040000<=pL<=0.080000, 0.400000<=pK<=0.440000; -0.040000<=pL<=0.080000, 0.440000<=pK<=0.480000; -0.040000<=pL<=0.080000, 0.480000<=pK<=0.520000; -0.040000<=pL<=0.080000, 0.520000<=pK<=0.560000; -0.040000<=pL<=0.080000, 0.560000<=pK<=0.600000; -0.040000<=pL<=0.080000, 0.600000<=pK<=0.640000; -0.040000<=pL<=0.080000, 0.640000<=pK<=0.680000; -0.040000<=pL<=0.080000, 0.680000<=pK<=0.720000; -0.040000<=pL<=0.080000, 0.720000<=pK<=0.760000; -0.040000<=pL<=0.080000, 0.760000<=pK<=0.800000; -0.040000<=pL<=0.080000, 0.800000<=pK<=0.840000; -0.040000<=pL<=0.080000, 0.840000<=pK<=0.880000; -0.040000<=pL<=0.080000, 0.880000<=pK<=0.920000; -0.040000<=pL<=0.080000, 0.920000<=pK<=0.960000; -0.040000<=pL<=0.080000, 0.960000<=pK<=0.999990; -0.080000<=pL<=0.120000, 0.000010<=pK<=0.040000; -0.080000<=pL<=0.120000, 0.040000<=pK<=0.080000; -0.080000<=pL<=0.120000, 0.080000<=pK<=0.120000; -0.080000<=pL<=0.120000, 0.120000<=pK<=0.160000; -0.080000<=pL<=0.120000, 0.160000<=pK<=0.200000; -0.080000<=pL<=0.120000, 0.200000<=pK<=0.240000; -0.080000<=pL<=0.120000, 0.240000<=pK<=0.280000; -0.080000<=pL<=0.120000, 0.280000<=pK<=0.320000; -0.080000<=pL<=0.120000, 0.320000<=pK<=0.360000; -0.080000<=pL<=0.120000, 0.360000<=pK<=0.400000; -0.080000<=pL<=0.120000, 0.400000<=pK<=0.440000; -0.080000<=pL<=0.120000, 0.440000<=pK<=0.480000; -0.080000<=pL<=0.120000, 0.480000<=pK<=0.520000; -0.080000<=pL<=0.120000, 0.520000<=pK<=0.560000; -0.080000<=pL<=0.120000, 0.560000<=pK<=0.600000; -0.080000<=pL<=0.120000, 0.600000<=pK<=0.640000; -0.080000<=pL<=0.120000, 0.640000<=pK<=0.680000; -0.080000<=pL<=0.120000, 0.680000<=pK<=0.720000; -0.080000<=pL<=0.120000, 0.720000<=pK<=0.760000; -0.080000<=pL<=0.120000, 0.760000<=pK<=0.800000; -0.080000<=pL<=0.120000, 0.800000<=pK<=0.840000; -0.080000<=pL<=0.120000, 0.840000<=pK<=0.880000; -0.080000<=pL<=0.120000, 0.880000<=pK<=0.920000; -0.080000<=pL<=0.120000, 0.920000<=pK<=0.960000; -0.080000<=pL<=0.120000, 0.960000<=pK<=0.999990; -0.120000<=pL<=0.160000, 0.000010<=pK<=0.040000; -0.120000<=pL<=0.160000, 0.040000<=pK<=0.080000; -0.120000<=pL<=0.160000, 0.080000<=pK<=0.120000; -0.120000<=pL<=0.160000, 0.120000<=pK<=0.160000; -0.120000<=pL<=0.160000, 0.160000<=pK<=0.200000; -0.120000<=pL<=0.160000, 0.200000<=pK<=0.240000; -0.120000<=pL<=0.160000, 0.240000<=pK<=0.280000; -0.120000<=pL<=0.160000, 0.280000<=pK<=0.320000; -0.120000<=pL<=0.160000, 0.320000<=pK<=0.360000; -0.120000<=pL<=0.160000, 0.360000<=pK<=0.400000; -0.120000<=pL<=0.160000, 0.400000<=pK<=0.440000; -0.120000<=pL<=0.160000, 0.440000<=pK<=0.480000; -0.120000<=pL<=0.160000, 0.480000<=pK<=0.520000; -0.120000<=pL<=0.160000, 0.520000<=pK<=0.560000; -0.120000<=pL<=0.160000, 0.560000<=pK<=0.600000; -0.120000<=pL<=0.160000, 0.600000<=pK<=0.640000; -0.120000<=pL<=0.160000, 0.640000<=pK<=0.680000; -0.120000<=pL<=0.160000, 0.680000<=pK<=0.720000; -0.120000<=pL<=0.160000, 0.720000<=pK<=0.760000; -0.120000<=pL<=0.160000, 0.760000<=pK<=0.800000; -0.120000<=pL<=0.160000, 0.800000<=pK<=0.840000; -0.120000<=pL<=0.160000, 0.840000<=pK<=0.880000; -0.120000<=pL<=0.160000, 0.880000<=pK<=0.920000; -0.120000<=pL<=0.160000, 0.920000<=pK<=0.960000; -0.120000<=pL<=0.160000, 0.960000<=pK<=0.999990; -0.160000<=pL<=0.200000, 0.000010<=pK<=0.040000; -0.160000<=pL<=0.200000, 0.040000<=pK<=0.080000; -0.160000<=pL<=0.200000, 0.080000<=pK<=0.120000; -0.160000<=pL<=0.200000, 0.120000<=pK<=0.160000; -0.160000<=pL<=0.200000, 0.160000<=pK<=0.200000; -0.160000<=pL<=0.200000, 0.200000<=pK<=0.240000; -0.160000<=pL<=0.200000, 0.240000<=pK<=0.280000; -0.160000<=pL<=0.200000, 0.280000<=pK<=0.320000; -0.160000<=pL<=0.200000, 0.320000<=pK<=0.360000; -0.160000<=pL<=0.200000, 0.360000<=pK<=0.400000; -0.160000<=pL<=0.200000, 0.400000<=pK<=0.440000; -0.160000<=pL<=0.200000, 0.440000<=pK<=0.480000; -0.160000<=pL<=0.200000, 0.480000<=pK<=0.520000; -0.160000<=pL<=0.200000, 0.520000<=pK<=0.560000; -0.160000<=pL<=0.200000, 0.560000<=pK<=0.600000; -0.160000<=pL<=0.200000, 0.600000<=pK<=0.640000; -0.160000<=pL<=0.200000, 0.640000<=pK<=0.680000; -0.160000<=pL<=0.200000, 0.680000<=pK<=0.720000; -0.160000<=pL<=0.200000, 0.720000<=pK<=0.760000; -0.160000<=pL<=0.200000, 0.760000<=pK<=0.800000; -0.160000<=pL<=0.200000, 0.800000<=pK<=0.840000; -0.160000<=pL<=0.200000, 0.840000<=pK<=0.880000; -0.160000<=pL<=0.200000, 0.880000<=pK<=0.920000; -0.160000<=pL<=0.200000, 0.920000<=pK<=0.960000; -0.160000<=pL<=0.200000, 0.960000<=pK<=0.999990; -0.200000<=pL<=0.240000, 0.000010<=pK<=0.040000; -0.200000<=pL<=0.240000, 0.040000<=pK<=0.080000; -0.200000<=pL<=0.240000, 0.080000<=pK<=0.120000; -0.200000<=pL<=0.240000, 0.120000<=pK<=0.160000; -0.200000<=pL<=0.240000, 0.160000<=pK<=0.200000; -0.200000<=pL<=0.240000, 0.200000<=pK<=0.240000; -0.200000<=pL<=0.240000, 0.240000<=pK<=0.280000; -0.200000<=pL<=0.240000, 0.280000<=pK<=0.320000; -0.200000<=pL<=0.240000, 0.320000<=pK<=0.360000; -0.200000<=pL<=0.240000, 0.360000<=pK<=0.400000; -0.200000<=pL<=0.240000, 0.400000<=pK<=0.440000; -0.200000<=pL<=0.240000, 0.440000<=pK<=0.480000; -0.200000<=pL<=0.240000, 0.480000<=pK<=0.520000; -0.200000<=pL<=0.240000, 0.520000<=pK<=0.560000; -0.200000<=pL<=0.240000, 0.560000<=pK<=0.600000; -0.200000<=pL<=0.240000, 0.600000<=pK<=0.640000; -0.200000<=pL<=0.240000, 0.640000<=pK<=0.680000; -0.200000<=pL<=0.240000, 0.680000<=pK<=0.720000; -0.200000<=pL<=0.240000, 0.720000<=pK<=0.760000; -0.200000<=pL<=0.240000, 0.760000<=pK<=0.800000; -0.200000<=pL<=0.240000, 0.800000<=pK<=0.840000; -0.200000<=pL<=0.240000, 0.840000<=pK<=0.880000; -0.200000<=pL<=0.240000, 0.880000<=pK<=0.920000; -0.200000<=pL<=0.240000, 0.920000<=pK<=0.960000; -0.200000<=pL<=0.240000, 0.960000<=pK<=0.999990; -0.240000<=pL<=0.280000, 0.000010<=pK<=0.040000; -0.240000<=pL<=0.280000, 0.040000<=pK<=0.080000; -0.240000<=pL<=0.280000, 0.080000<=pK<=0.120000; -0.240000<=pL<=0.280000, 0.120000<=pK<=0.160000; -0.240000<=pL<=0.280000, 0.160000<=pK<=0.200000; -0.240000<=pL<=0.280000, 0.200000<=pK<=0.240000; -0.240000<=pL<=0.280000, 0.240000<=pK<=0.280000; -0.240000<=pL<=0.280000, 0.280000<=pK<=0.320000; -0.240000<=pL<=0.280000, 0.320000<=pK<=0.360000; -0.240000<=pL<=0.280000, 0.360000<=pK<=0.400000; -0.240000<=pL<=0.280000, 0.400000<=pK<=0.440000; -0.240000<=pL<=0.280000, 0.440000<=pK<=0.480000; -0.240000<=pL<=0.280000, 0.480000<=pK<=0.520000; -0.240000<=pL<=0.280000, 0.520000<=pK<=0.560000; -0.240000<=pL<=0.280000, 0.560000<=pK<=0.600000; -0.240000<=pL<=0.280000, 0.600000<=pK<=0.640000; -0.240000<=pL<=0.280000, 0.640000<=pK<=0.680000; -0.240000<=pL<=0.280000, 0.680000<=pK<=0.720000; -0.240000<=pL<=0.280000, 0.720000<=pK<=0.760000; -0.240000<=pL<=0.280000, 0.760000<=pK<=0.800000; -0.240000<=pL<=0.280000, 0.800000<=pK<=0.840000; -0.240000<=pL<=0.280000, 0.840000<=pK<=0.880000; -0.240000<=pL<=0.280000, 0.880000<=pK<=0.920000; -0.240000<=pL<=0.280000, 0.920000<=pK<=0.960000; -0.240000<=pL<=0.280000, 0.960000<=pK<=0.999990; -0.280000<=pL<=0.320000, 0.000010<=pK<=0.040000; -0.280000<=pL<=0.320000, 0.040000<=pK<=0.080000; -0.280000<=pL<=0.320000, 0.080000<=pK<=0.120000; -0.280000<=pL<=0.320000, 0.120000<=pK<=0.160000; -0.280000<=pL<=0.320000, 0.160000<=pK<=0.200000; -0.280000<=pL<=0.320000, 0.200000<=pK<=0.240000; -0.280000<=pL<=0.320000, 0.240000<=pK<=0.280000; -0.280000<=pL<=0.320000, 0.280000<=pK<=0.320000; -0.280000<=pL<=0.320000, 0.320000<=pK<=0.360000; -0.280000<=pL<=0.320000, 0.360000<=pK<=0.400000; -0.280000<=pL<=0.320000, 0.400000<=pK<=0.440000; -0.280000<=pL<=0.320000, 0.440000<=pK<=0.480000; -0.280000<=pL<=0.320000, 0.480000<=pK<=0.520000; -0.280000<=pL<=0.320000, 0.520000<=pK<=0.560000; -0.280000<=pL<=0.320000, 0.560000<=pK<=0.600000; -0.280000<=pL<=0.320000, 0.600000<=pK<=0.640000; -0.280000<=pL<=0.320000, 0.640000<=pK<=0.680000; -0.280000<=pL<=0.320000, 0.680000<=pK<=0.720000; -0.280000<=pL<=0.320000, 0.720000<=pK<=0.760000; -0.280000<=pL<=0.320000, 0.760000<=pK<=0.800000; -0.280000<=pL<=0.320000, 0.800000<=pK<=0.840000; -0.280000<=pL<=0.320000, 0.840000<=pK<=0.880000; -0.280000<=pL<=0.320000, 0.880000<=pK<=0.920000; -0.280000<=pL<=0.320000, 0.920000<=pK<=0.960000; -0.280000<=pL<=0.320000, 0.960000<=pK<=0.999990; -0.320000<=pL<=0.360000, 0.000010<=pK<=0.040000; -0.320000<=pL<=0.360000, 0.040000<=pK<=0.080000; -0.320000<=pL<=0.360000, 0.080000<=pK<=0.120000; -0.320000<=pL<=0.360000, 0.120000<=pK<=0.160000; -0.320000<=pL<=0.360000, 0.160000<=pK<=0.200000; -0.320000<=pL<=0.360000, 0.200000<=pK<=0.240000; -0.320000<=pL<=0.360000, 0.240000<=pK<=0.280000; -0.320000<=pL<=0.360000, 0.280000<=pK<=0.320000; -0.320000<=pL<=0.360000, 0.320000<=pK<=0.360000; -0.320000<=pL<=0.360000, 0.360000<=pK<=0.400000; -0.320000<=pL<=0.360000, 0.400000<=pK<=0.440000; -0.320000<=pL<=0.360000, 0.440000<=pK<=0.480000; -0.320000<=pL<=0.360000, 0.480000<=pK<=0.520000; -0.320000<=pL<=0.360000, 0.520000<=pK<=0.560000; -0.320000<=pL<=0.360000, 0.560000<=pK<=0.600000; -0.320000<=pL<=0.360000, 0.600000<=pK<=0.640000; -0.320000<=pL<=0.360000, 0.640000<=pK<=0.680000; -0.320000<=pL<=0.360000, 0.680000<=pK<=0.720000; -0.320000<=pL<=0.360000, 0.720000<=pK<=0.760000; -0.320000<=pL<=0.360000, 0.760000<=pK<=0.800000; -0.320000<=pL<=0.360000, 0.800000<=pK<=0.840000; -0.320000<=pL<=0.360000, 0.840000<=pK<=0.880000; -0.320000<=pL<=0.360000, 0.880000<=pK<=0.920000; -0.320000<=pL<=0.360000, 0.920000<=pK<=0.960000; -0.320000<=pL<=0.360000, 0.960000<=pK<=0.999990; -0.360000<=pL<=0.400000, 0.000010<=pK<=0.040000; -0.360000<=pL<=0.400000, 0.040000<=pK<=0.080000; -0.360000<=pL<=0.400000, 0.080000<=pK<=0.120000; -0.360000<=pL<=0.400000, 0.120000<=pK<=0.160000; -0.360000<=pL<=0.400000, 0.160000<=pK<=0.200000; -0.360000<=pL<=0.400000, 0.200000<=pK<=0.240000; -0.360000<=pL<=0.400000, 0.240000<=pK<=0.280000; -0.360000<=pL<=0.400000, 0.280000<=pK<=0.320000; -0.360000<=pL<=0.400000, 0.320000<=pK<=0.360000; -0.360000<=pL<=0.400000, 0.360000<=pK<=0.400000; -0.360000<=pL<=0.400000, 0.400000<=pK<=0.440000; -0.360000<=pL<=0.400000, 0.440000<=pK<=0.480000; -0.360000<=pL<=0.400000, 0.480000<=pK<=0.520000; -0.360000<=pL<=0.400000, 0.520000<=pK<=0.560000; -0.360000<=pL<=0.400000, 0.560000<=pK<=0.600000; -0.360000<=pL<=0.400000, 0.600000<=pK<=0.640000; -0.360000<=pL<=0.400000, 0.640000<=pK<=0.680000; -0.360000<=pL<=0.400000, 0.680000<=pK<=0.720000; -0.360000<=pL<=0.400000, 0.720000<=pK<=0.760000; -0.360000<=pL<=0.400000, 0.760000<=pK<=0.800000; -0.360000<=pL<=0.400000, 0.800000<=pK<=0.840000; -0.360000<=pL<=0.400000, 0.840000<=pK<=0.880000; -0.360000<=pL<=0.400000, 0.880000<=pK<=0.920000; -0.360000<=pL<=0.400000, 0.920000<=pK<=0.960000; -0.360000<=pL<=0.400000, 0.960000<=pK<=0.999990; -0.400000<=pL<=0.440000, 0.000010<=pK<=0.040000; -0.400000<=pL<=0.440000, 0.040000<=pK<=0.080000; -0.400000<=pL<=0.440000, 0.080000<=pK<=0.120000; -0.400000<=pL<=0.440000, 0.120000<=pK<=0.160000; -0.400000<=pL<=0.440000, 0.160000<=pK<=0.200000; -0.400000<=pL<=0.440000, 0.200000<=pK<=0.240000; -0.400000<=pL<=0.440000, 0.240000<=pK<=0.280000; -0.400000<=pL<=0.440000, 0.280000<=pK<=0.320000; -0.400000<=pL<=0.440000, 0.320000<=pK<=0.360000; -0.400000<=pL<=0.440000, 0.360000<=pK<=0.400000; -0.400000<=pL<=0.440000, 0.400000<=pK<=0.440000; -0.400000<=pL<=0.440000, 0.440000<=pK<=0.480000; -0.400000<=pL<=0.440000, 0.480000<=pK<=0.520000; -0.400000<=pL<=0.440000, 0.520000<=pK<=0.560000; -0.400000<=pL<=0.440000, 0.560000<=pK<=0.600000; -0.400000<=pL<=0.440000, 0.600000<=pK<=0.640000; -0.400000<=pL<=0.440000, 0.640000<=pK<=0.680000; -0.400000<=pL<=0.440000, 0.680000<=pK<=0.720000; -0.400000<=pL<=0.440000, 0.720000<=pK<=0.760000; -0.400000<=pL<=0.440000, 0.760000<=pK<=0.800000; -0.400000<=pL<=0.440000, 0.800000<=pK<=0.840000; -0.400000<=pL<=0.440000, 0.840000<=pK<=0.880000; -0.400000<=pL<=0.440000, 0.880000<=pK<=0.920000; -0.400000<=pL<=0.440000, 0.920000<=pK<=0.960000; -0.400000<=pL<=0.440000, 0.960000<=pK<=0.999990; -0.440000<=pL<=0.480000, 0.000010<=pK<=0.040000; -0.440000<=pL<=0.480000, 0.040000<=pK<=0.080000; -0.440000<=pL<=0.480000, 0.080000<=pK<=0.120000; -0.440000<=pL<=0.480000, 0.120000<=pK<=0.160000; -0.440000<=pL<=0.480000, 0.160000<=pK<=0.200000; -0.440000<=pL<=0.480000, 0.200000<=pK<=0.240000; -0.440000<=pL<=0.480000, 0.240000<=pK<=0.280000; -0.440000<=pL<=0.480000, 0.280000<=pK<=0.320000; -0.440000<=pL<=0.480000, 0.320000<=pK<=0.360000; -0.440000<=pL<=0.480000, 0.360000<=pK<=0.400000; -0.440000<=pL<=0.480000, 0.400000<=pK<=0.440000; -0.440000<=pL<=0.480000, 0.440000<=pK<=0.480000; -0.440000<=pL<=0.480000, 0.480000<=pK<=0.520000; -0.440000<=pL<=0.480000, 0.520000<=pK<=0.560000; -0.440000<=pL<=0.480000, 0.560000<=pK<=0.600000; -0.440000<=pL<=0.480000, 0.600000<=pK<=0.640000; -0.440000<=pL<=0.480000, 0.640000<=pK<=0.680000; -0.440000<=pL<=0.480000, 0.680000<=pK<=0.720000; -0.440000<=pL<=0.480000, 0.720000<=pK<=0.760000; -0.440000<=pL<=0.480000, 0.760000<=pK<=0.800000; -0.440000<=pL<=0.480000, 0.800000<=pK<=0.840000; -0.440000<=pL<=0.480000, 0.840000<=pK<=0.880000; -0.440000<=pL<=0.480000, 0.880000<=pK<=0.920000; -0.440000<=pL<=0.480000, 0.920000<=pK<=0.960000; -0.440000<=pL<=0.480000, 0.960000<=pK<=0.999990; -0.480000<=pL<=0.520000, 0.000010<=pK<=0.040000; -0.480000<=pL<=0.520000, 0.040000<=pK<=0.080000; -0.480000<=pL<=0.520000, 0.080000<=pK<=0.120000; -0.480000<=pL<=0.520000, 0.120000<=pK<=0.160000; -0.480000<=pL<=0.520000, 0.160000<=pK<=0.200000; -0.480000<=pL<=0.520000, 0.200000<=pK<=0.240000; -0.480000<=pL<=0.520000, 0.240000<=pK<=0.280000; -0.480000<=pL<=0.520000, 0.280000<=pK<=0.320000; -0.480000<=pL<=0.520000, 0.320000<=pK<=0.360000; -0.480000<=pL<=0.520000, 0.360000<=pK<=0.400000; -0.480000<=pL<=0.520000, 0.400000<=pK<=0.440000; -0.480000<=pL<=0.520000, 0.440000<=pK<=0.480000; -0.480000<=pL<=0.520000, 0.480000<=pK<=0.520000; -0.480000<=pL<=0.520000, 0.520000<=pK<=0.560000; -0.480000<=pL<=0.520000, 0.560000<=pK<=0.600000; -0.480000<=pL<=0.520000, 0.600000<=pK<=0.640000; -0.480000<=pL<=0.520000, 0.640000<=pK<=0.680000; -0.480000<=pL<=0.520000, 0.680000<=pK<=0.720000; -0.480000<=pL<=0.520000, 0.720000<=pK<=0.760000; -0.480000<=pL<=0.520000, 0.760000<=pK<=0.800000; -0.480000<=pL<=0.520000, 0.800000<=pK<=0.840000; -0.480000<=pL<=0.520000, 0.840000<=pK<=0.880000; -0.480000<=pL<=0.520000, 0.880000<=pK<=0.920000; -0.480000<=pL<=0.520000, 0.920000<=pK<=0.960000; -0.480000<=pL<=0.520000, 0.960000<=pK<=0.999990; -0.520000<=pL<=0.560000, 0.000010<=pK<=0.040000; -0.520000<=pL<=0.560000, 0.040000<=pK<=0.080000; -0.520000<=pL<=0.560000, 0.080000<=pK<=0.120000; -0.520000<=pL<=0.560000, 0.120000<=pK<=0.160000; -0.520000<=pL<=0.560000, 0.160000<=pK<=0.200000; -0.520000<=pL<=0.560000, 0.200000<=pK<=0.240000; -0.520000<=pL<=0.560000, 0.240000<=pK<=0.280000; -0.520000<=pL<=0.560000, 0.280000<=pK<=0.320000; -0.520000<=pL<=0.560000, 0.320000<=pK<=0.360000; -0.520000<=pL<=0.560000, 0.360000<=pK<=0.400000; -0.520000<=pL<=0.560000, 0.400000<=pK<=0.440000; -0.520000<=pL<=0.560000, 0.440000<=pK<=0.480000; -0.520000<=pL<=0.560000, 0.480000<=pK<=0.520000; -0.520000<=pL<=0.560000, 0.520000<=pK<=0.560000; -0.520000<=pL<=0.560000, 0.560000<=pK<=0.600000; -0.520000<=pL<=0.560000, 0.600000<=pK<=0.640000; -0.520000<=pL<=0.560000, 0.640000<=pK<=0.680000; -0.520000<=pL<=0.560000, 0.680000<=pK<=0.720000; -0.520000<=pL<=0.560000, 0.720000<=pK<=0.760000; -0.520000<=pL<=0.560000, 0.760000<=pK<=0.800000; -0.520000<=pL<=0.560000, 0.800000<=pK<=0.840000; -0.520000<=pL<=0.560000, 0.840000<=pK<=0.880000; -0.520000<=pL<=0.560000, 0.880000<=pK<=0.920000; -0.520000<=pL<=0.560000, 0.920000<=pK<=0.960000; -0.520000<=pL<=0.560000, 0.960000<=pK<=0.999990; -0.560000<=pL<=0.600000, 0.000010<=pK<=0.040000; -0.560000<=pL<=0.600000, 0.040000<=pK<=0.080000; -0.560000<=pL<=0.600000, 0.080000<=pK<=0.120000; -0.560000<=pL<=0.600000, 0.120000<=pK<=0.160000; -0.560000<=pL<=0.600000, 0.160000<=pK<=0.200000; -0.560000<=pL<=0.600000, 0.200000<=pK<=0.240000; -0.560000<=pL<=0.600000, 0.240000<=pK<=0.280000; -0.560000<=pL<=0.600000, 0.280000<=pK<=0.320000; -0.560000<=pL<=0.600000, 0.320000<=pK<=0.360000; -0.560000<=pL<=0.600000, 0.360000<=pK<=0.400000; -0.560000<=pL<=0.600000, 0.400000<=pK<=0.440000; -0.560000<=pL<=0.600000, 0.440000<=pK<=0.480000; -0.560000<=pL<=0.600000, 0.480000<=pK<=0.520000; -0.560000<=pL<=0.600000, 0.520000<=pK<=0.560000; -0.560000<=pL<=0.600000, 0.560000<=pK<=0.600000; -0.560000<=pL<=0.600000, 0.600000<=pK<=0.640000; -0.560000<=pL<=0.600000, 0.640000<=pK<=0.680000; -0.560000<=pL<=0.600000, 0.680000<=pK<=0.720000; -0.560000<=pL<=0.600000, 0.720000<=pK<=0.760000; -0.560000<=pL<=0.600000, 0.760000<=pK<=0.800000; -0.560000<=pL<=0.600000, 0.800000<=pK<=0.840000; -0.560000<=pL<=0.600000, 0.840000<=pK<=0.880000; -0.560000<=pL<=0.600000, 0.880000<=pK<=0.920000; -0.560000<=pL<=0.600000, 0.920000<=pK<=0.960000; -0.560000<=pL<=0.600000, 0.960000<=pK<=0.999990; -0.600000<=pL<=0.640000, 0.000010<=pK<=0.040000; -0.600000<=pL<=0.640000, 0.040000<=pK<=0.080000; -0.600000<=pL<=0.640000, 0.080000<=pK<=0.120000; -0.600000<=pL<=0.640000, 0.120000<=pK<=0.160000; -0.600000<=pL<=0.640000, 0.160000<=pK<=0.200000; -0.600000<=pL<=0.640000, 0.200000<=pK<=0.240000; -0.600000<=pL<=0.640000, 0.240000<=pK<=0.280000; -0.600000<=pL<=0.640000, 0.280000<=pK<=0.320000; -0.600000<=pL<=0.640000, 0.320000<=pK<=0.360000; -0.600000<=pL<=0.640000, 0.360000<=pK<=0.400000; -0.600000<=pL<=0.640000, 0.400000<=pK<=0.440000; -0.600000<=pL<=0.640000, 0.440000<=pK<=0.480000; -0.600000<=pL<=0.640000, 0.480000<=pK<=0.520000; -0.600000<=pL<=0.640000, 0.520000<=pK<=0.560000; -0.600000<=pL<=0.640000, 0.560000<=pK<=0.600000; -0.600000<=pL<=0.640000, 0.600000<=pK<=0.640000; -0.600000<=pL<=0.640000, 0.640000<=pK<=0.680000; -0.600000<=pL<=0.640000, 0.680000<=pK<=0.720000; -0.600000<=pL<=0.640000, 0.720000<=pK<=0.760000; -0.600000<=pL<=0.640000, 0.760000<=pK<=0.800000; -0.600000<=pL<=0.640000, 0.800000<=pK<=0.840000; -0.600000<=pL<=0.640000, 0.840000<=pK<=0.880000; -0.600000<=pL<=0.640000, 0.880000<=pK<=0.920000; -0.600000<=pL<=0.640000, 0.920000<=pK<=0.960000; -0.600000<=pL<=0.640000, 0.960000<=pK<=0.999990; -0.640000<=pL<=0.680000, 0.000010<=pK<=0.040000; -0.640000<=pL<=0.680000, 0.040000<=pK<=0.080000; -0.640000<=pL<=0.680000, 0.080000<=pK<=0.120000; -0.640000<=pL<=0.680000, 0.120000<=pK<=0.160000; -0.640000<=pL<=0.680000, 0.160000<=pK<=0.200000; -0.640000<=pL<=0.680000, 0.200000<=pK<=0.240000; -0.640000<=pL<=0.680000, 0.240000<=pK<=0.280000; -0.640000<=pL<=0.680000, 0.280000<=pK<=0.320000; -0.640000<=pL<=0.680000, 0.320000<=pK<=0.360000; -0.640000<=pL<=0.680000, 0.360000<=pK<=0.400000; -0.640000<=pL<=0.680000, 0.400000<=pK<=0.440000; -0.640000<=pL<=0.680000, 0.440000<=pK<=0.480000; -0.640000<=pL<=0.680000, 0.480000<=pK<=0.520000; -0.640000<=pL<=0.680000, 0.520000<=pK<=0.560000; -0.640000<=pL<=0.680000, 0.560000<=pK<=0.600000; -0.640000<=pL<=0.680000, 0.600000<=pK<=0.640000; -0.640000<=pL<=0.680000, 0.640000<=pK<=0.680000; -0.640000<=pL<=0.680000, 0.680000<=pK<=0.720000; -0.640000<=pL<=0.680000, 0.720000<=pK<=0.760000; -0.640000<=pL<=0.680000, 0.760000<=pK<=0.800000; -0.640000<=pL<=0.680000, 0.800000<=pK<=0.840000; -0.640000<=pL<=0.680000, 0.840000<=pK<=0.880000; -0.640000<=pL<=0.680000, 0.880000<=pK<=0.920000; -0.640000<=pL<=0.680000, 0.920000<=pK<=0.960000; -0.640000<=pL<=0.680000, 0.960000<=pK<=0.999990; -0.680000<=pL<=0.720000, 0.000010<=pK<=0.040000; -0.680000<=pL<=0.720000, 0.040000<=pK<=0.080000; -0.680000<=pL<=0.720000, 0.080000<=pK<=0.120000; -0.680000<=pL<=0.720000, 0.120000<=pK<=0.160000; -0.680000<=pL<=0.720000, 0.160000<=pK<=0.200000; -0.680000<=pL<=0.720000, 0.200000<=pK<=0.240000; -0.680000<=pL<=0.720000, 0.240000<=pK<=0.280000; -0.680000<=pL<=0.720000, 0.280000<=pK<=0.320000; -0.680000<=pL<=0.720000, 0.320000<=pK<=0.360000; -0.680000<=pL<=0.720000, 0.360000<=pK<=0.400000; -0.680000<=pL<=0.720000, 0.400000<=pK<=0.440000; -0.680000<=pL<=0.720000, 0.440000<=pK<=0.480000; -0.680000<=pL<=0.720000, 0.480000<=pK<=0.520000; -0.680000<=pL<=0.720000, 0.520000<=pK<=0.560000; -0.680000<=pL<=0.720000, 0.560000<=pK<=0.600000; -0.680000<=pL<=0.720000, 0.600000<=pK<=0.640000; -0.680000<=pL<=0.720000, 0.640000<=pK<=0.680000; -0.680000<=pL<=0.720000, 0.680000<=pK<=0.720000; -0.680000<=pL<=0.720000, 0.720000<=pK<=0.760000; -0.680000<=pL<=0.720000, 0.760000<=pK<=0.800000; -0.680000<=pL<=0.720000, 0.800000<=pK<=0.840000; -0.680000<=pL<=0.720000, 0.840000<=pK<=0.880000; -0.680000<=pL<=0.720000, 0.880000<=pK<=0.920000; -0.680000<=pL<=0.720000, 0.920000<=pK<=0.960000; -0.680000<=pL<=0.720000, 0.960000<=pK<=0.999990; -0.720000<=pL<=0.760000, 0.000010<=pK<=0.040000; -0.720000<=pL<=0.760000, 0.040000<=pK<=0.080000; -0.720000<=pL<=0.760000, 0.080000<=pK<=0.120000; -0.720000<=pL<=0.760000, 0.120000<=pK<=0.160000; -0.720000<=pL<=0.760000, 0.160000<=pK<=0.200000; -0.720000<=pL<=0.760000, 0.200000<=pK<=0.240000; -0.720000<=pL<=0.760000, 0.240000<=pK<=0.280000; -0.720000<=pL<=0.760000, 0.280000<=pK<=0.320000; -0.720000<=pL<=0.760000, 0.320000<=pK<=0.360000; -0.720000<=pL<=0.760000, 0.360000<=pK<=0.400000; -0.720000<=pL<=0.760000, 0.400000<=pK<=0.440000; -0.720000<=pL<=0.760000, 0.440000<=pK<=0.480000; -0.720000<=pL<=0.760000, 0.480000<=pK<=0.520000; -0.720000<=pL<=0.760000, 0.520000<=pK<=0.560000; -0.720000<=pL<=0.760000, 0.560000<=pK<=0.600000; -0.720000<=pL<=0.760000, 0.600000<=pK<=0.640000; -0.720000<=pL<=0.760000, 0.640000<=pK<=0.680000; -0.720000<=pL<=0.760000, 0.680000<=pK<=0.720000; -0.720000<=pL<=0.760000, 0.720000<=pK<=0.760000; -0.720000<=pL<=0.760000, 0.760000<=pK<=0.800000; -0.720000<=pL<=0.760000, 0.800000<=pK<=0.840000; -0.720000<=pL<=0.760000, 0.840000<=pK<=0.880000; -0.720000<=pL<=0.760000, 0.880000<=pK<=0.920000; -0.720000<=pL<=0.760000, 0.920000<=pK<=0.960000; -0.720000<=pL<=0.760000, 0.960000<=pK<=0.999990; -0.760000<=pL<=0.800000, 0.000010<=pK<=0.040000; -0.760000<=pL<=0.800000, 0.040000<=pK<=0.080000; -0.760000<=pL<=0.800000, 0.080000<=pK<=0.120000; -0.760000<=pL<=0.800000, 0.120000<=pK<=0.160000; -0.760000<=pL<=0.800000, 0.160000<=pK<=0.200000; -0.760000<=pL<=0.800000, 0.200000<=pK<=0.240000; -0.760000<=pL<=0.800000, 0.240000<=pK<=0.280000; -0.760000<=pL<=0.800000, 0.280000<=pK<=0.320000; -0.760000<=pL<=0.800000, 0.320000<=pK<=0.360000; -0.760000<=pL<=0.800000, 0.360000<=pK<=0.400000; -0.760000<=pL<=0.800000, 0.400000<=pK<=0.440000; -0.760000<=pL<=0.800000, 0.440000<=pK<=0.480000; -0.760000<=pL<=0.800000, 0.480000<=pK<=0.520000; -0.760000<=pL<=0.800000, 0.520000<=pK<=0.560000; -0.760000<=pL<=0.800000, 0.560000<=pK<=0.600000; -0.760000<=pL<=0.800000, 0.600000<=pK<=0.640000; -0.760000<=pL<=0.800000, 0.640000<=pK<=0.680000; -0.760000<=pL<=0.800000, 0.680000<=pK<=0.720000; -0.760000<=pL<=0.800000, 0.720000<=pK<=0.760000; -0.760000<=pL<=0.800000, 0.760000<=pK<=0.800000; -0.760000<=pL<=0.800000, 0.800000<=pK<=0.840000; -0.760000<=pL<=0.800000, 0.840000<=pK<=0.880000; -0.760000<=pL<=0.800000, 0.880000<=pK<=0.920000; -0.760000<=pL<=0.800000, 0.920000<=pK<=0.960000; -0.760000<=pL<=0.800000, 0.960000<=pK<=0.999990; -0.800000<=pL<=0.840000, 0.000010<=pK<=0.040000; -0.800000<=pL<=0.840000, 0.040000<=pK<=0.080000; -0.800000<=pL<=0.840000, 0.080000<=pK<=0.120000; -0.800000<=pL<=0.840000, 0.120000<=pK<=0.160000; -0.800000<=pL<=0.840000, 0.160000<=pK<=0.200000; -0.800000<=pL<=0.840000, 0.200000<=pK<=0.240000; -0.800000<=pL<=0.840000, 0.240000<=pK<=0.280000; -0.800000<=pL<=0.840000, 0.280000<=pK<=0.320000; -0.800000<=pL<=0.840000, 0.320000<=pK<=0.360000; -0.800000<=pL<=0.840000, 0.360000<=pK<=0.400000; -0.800000<=pL<=0.840000, 0.400000<=pK<=0.440000; -0.800000<=pL<=0.840000, 0.440000<=pK<=0.480000; -0.800000<=pL<=0.840000, 0.480000<=pK<=0.520000; -0.800000<=pL<=0.840000, 0.520000<=pK<=0.560000; -0.800000<=pL<=0.840000, 0.560000<=pK<=0.600000; -0.800000<=pL<=0.840000, 0.600000<=pK<=0.640000; -0.800000<=pL<=0.840000, 0.640000<=pK<=0.680000; -0.800000<=pL<=0.840000, 0.680000<=pK<=0.720000; -0.800000<=pL<=0.840000, 0.720000<=pK<=0.760000; -0.800000<=pL<=0.840000, 0.760000<=pK<=0.800000; -0.800000<=pL<=0.840000, 0.800000<=pK<=0.840000; -0.800000<=pL<=0.840000, 0.840000<=pK<=0.880000; -0.800000<=pL<=0.840000, 0.880000<=pK<=0.920000; -0.800000<=pL<=0.840000, 0.920000<=pK<=0.960000; -0.800000<=pL<=0.840000, 0.960000<=pK<=0.999990; -0.840000<=pL<=0.880000, 0.000010<=pK<=0.040000; -0.840000<=pL<=0.880000, 0.040000<=pK<=0.080000; -0.840000<=pL<=0.880000, 0.080000<=pK<=0.120000; -0.840000<=pL<=0.880000, 0.120000<=pK<=0.160000; -0.840000<=pL<=0.880000, 0.160000<=pK<=0.200000; -0.840000<=pL<=0.880000, 0.200000<=pK<=0.240000; -0.840000<=pL<=0.880000, 0.240000<=pK<=0.280000; -0.840000<=pL<=0.880000, 0.280000<=pK<=0.320000; -0.840000<=pL<=0.880000, 0.320000<=pK<=0.360000; -0.840000<=pL<=0.880000, 0.360000<=pK<=0.400000; -0.840000<=pL<=0.880000, 0.400000<=pK<=0.440000; -0.840000<=pL<=0.880000, 0.440000<=pK<=0.480000; -0.840000<=pL<=0.880000, 0.480000<=pK<=0.520000; -0.840000<=pL<=0.880000, 0.520000<=pK<=0.560000; -0.840000<=pL<=0.880000, 0.560000<=pK<=0.600000; -0.840000<=pL<=0.880000, 0.600000<=pK<=0.640000; -0.840000<=pL<=0.880000, 0.640000<=pK<=0.680000; -0.840000<=pL<=0.880000, 0.680000<=pK<=0.720000; -0.840000<=pL<=0.880000, 0.720000<=pK<=0.760000; -0.840000<=pL<=0.880000, 0.760000<=pK<=0.800000; -0.840000<=pL<=0.880000, 0.800000<=pK<=0.840000; -0.840000<=pL<=0.880000, 0.840000<=pK<=0.880000; -0.840000<=pL<=0.880000, 0.880000<=pK<=0.920000; -0.840000<=pL<=0.880000, 0.920000<=pK<=0.960000; -0.840000<=pL<=0.880000, 0.960000<=pK<=0.999990; -0.880000<=pL<=0.920000, 0.000010<=pK<=0.040000; -0.880000<=pL<=0.920000, 0.040000<=pK<=0.080000; -0.880000<=pL<=0.920000, 0.080000<=pK<=0.120000; -0.880000<=pL<=0.920000, 0.120000<=pK<=0.160000; -0.880000<=pL<=0.920000, 0.160000<=pK<=0.200000; -0.880000<=pL<=0.920000, 0.200000<=pK<=0.240000; -0.880000<=pL<=0.920000, 0.240000<=pK<=0.280000; -0.880000<=pL<=0.920000, 0.280000<=pK<=0.320000; -0.880000<=pL<=0.920000, 0.320000<=pK<=0.360000; -0.880000<=pL<=0.920000, 0.360000<=pK<=0.400000; -0.880000<=pL<=0.920000, 0.400000<=pK<=0.440000; -0.880000<=pL<=0.920000, 0.440000<=pK<=0.480000; -0.880000<=pL<=0.920000, 0.480000<=pK<=0.520000; -0.880000<=pL<=0.920000, 0.520000<=pK<=0.560000; -0.880000<=pL<=0.920000, 0.560000<=pK<=0.600000; -0.880000<=pL<=0.920000, 0.600000<=pK<=0.640000; -0.880000<=pL<=0.920000, 0.640000<=pK<=0.680000; -0.880000<=pL<=0.920000, 0.680000<=pK<=0.720000; -0.880000<=pL<=0.920000, 0.720000<=pK<=0.760000; -0.880000<=pL<=0.920000, 0.760000<=pK<=0.800000; -0.880000<=pL<=0.920000, 0.800000<=pK<=0.840000; -0.880000<=pL<=0.920000, 0.840000<=pK<=0.880000; -0.880000<=pL<=0.920000, 0.880000<=pK<=0.920000; -0.880000<=pL<=0.920000, 0.920000<=pK<=0.960000; -0.880000<=pL<=0.920000, 0.960000<=pK<=0.999990; -0.920000<=pL<=0.960000, 0.000010<=pK<=0.040000; -0.920000<=pL<=0.960000, 0.040000<=pK<=0.080000; -0.920000<=pL<=0.960000, 0.080000<=pK<=0.120000; -0.920000<=pL<=0.960000, 0.120000<=pK<=0.160000; -0.920000<=pL<=0.960000, 0.160000<=pK<=0.200000; -0.920000<=pL<=0.960000, 0.200000<=pK<=0.240000; -0.920000<=pL<=0.960000, 0.240000<=pK<=0.280000; -0.920000<=pL<=0.960000, 0.280000<=pK<=0.320000; -0.920000<=pL<=0.960000, 0.320000<=pK<=0.360000; -0.920000<=pL<=0.960000, 0.360000<=pK<=0.400000; -0.920000<=pL<=0.960000, 0.400000<=pK<=0.440000; -0.920000<=pL<=0.960000, 0.440000<=pK<=0.480000; -0.920000<=pL<=0.960000, 0.480000<=pK<=0.520000; -0.920000<=pL<=0.960000, 0.520000<=pK<=0.560000; -0.920000<=pL<=0.960000, 0.560000<=pK<=0.600000; -0.920000<=pL<=0.960000, 0.600000<=pK<=0.640000; -0.920000<=pL<=0.960000, 0.640000<=pK<=0.680000; -0.920000<=pL<=0.960000, 0.680000<=pK<=0.720000; -0.920000<=pL<=0.960000, 0.720000<=pK<=0.760000; -0.920000<=pL<=0.960000, 0.760000<=pK<=0.800000; -0.920000<=pL<=0.960000, 0.800000<=pK<=0.840000; -0.920000<=pL<=0.960000, 0.840000<=pK<=0.880000; -0.920000<=pL<=0.960000, 0.880000<=pK<=0.920000; -0.920000<=pL<=0.960000, 0.920000<=pK<=0.960000; -0.920000<=pL<=0.960000, 0.960000<=pK<=0.999990; -0.960000<=pL<=0.999990, 0.000010<=pK<=0.040000; -0.960000<=pL<=0.999990, 0.040000<=pK<=0.080000; -0.960000<=pL<=0.999990, 0.080000<=pK<=0.120000; -0.960000<=pL<=0.999990, 0.120000<=pK<=0.160000; -0.960000<=pL<=0.999990, 0.160000<=pK<=0.200000; -0.960000<=pL<=0.999990, 0.200000<=pK<=0.240000; -0.960000<=pL<=0.999990, 0.240000<=pK<=0.280000; -0.960000<=pL<=0.999990, 0.280000<=pK<=0.320000; -0.960000<=pL<=0.999990, 0.320000<=pK<=0.360000; -0.960000<=pL<=0.999990, 0.360000<=pK<=0.400000; -0.960000<=pL<=0.999990, 0.400000<=pK<=0.440000; -0.960000<=pL<=0.999990, 0.440000<=pK<=0.480000; -0.960000<=pL<=0.999990, 0.480000<=pK<=0.520000; -0.960000<=pL<=0.999990, 0.520000<=pK<=0.560000; -0.960000<=pL<=0.999990, 0.560000<=pK<=0.600000; -0.960000<=pL<=0.999990, 0.600000<=pK<=0.640000; -0.960000<=pL<=0.999990, 0.640000<=pK<=0.680000; -0.960000<=pL<=0.999990, 0.680000<=pK<=0.720000; -0.960000<=pL<=0.999990, 0.720000<=pK<=0.760000; -0.960000<=pL<=0.999990, 0.760000<=pK<=0.800000; -0.960000<=pL<=0.999990, 0.800000<=pK<=0.840000; -0.960000<=pL<=0.999990, 0.840000<=pK<=0.880000; -0.960000<=pL<=0.999990, 0.880000<=pK<=0.920000; -0.960000<=pL<=0.999990, 0.920000<=pK<=0.960000; -0.960000<=pL<=0.999990, 0.960000<=pK<=0.999990; diff --git a/examples/pdtmc/brp_rewards2/brp_rewards2_space.txt b/examples/pdtmc/brp_rewards2/brp_rewards2_space.txt deleted file mode 100644 index 444b98e90..000000000 --- a/examples/pdtmc/brp_rewards2/brp_rewards2_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=pL<=0.999990, 0.000010<=pK<=0.999990; - diff --git a/examples/pdtmc/brp_rewards2/brp_rewards512_5.pm b/examples/pdtmc/brp_rewards2/brp_rewards512_5.pm deleted file mode 100644 index 344c545da..000000000 --- a/examples/pdtmc/brp_rewards2/brp_rewards512_5.pm +++ /dev/null @@ -1,147 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 512; -// maximum number of retransmissions -const int MAX = 5; - -// reliability of channels -const double pL; -const double pK; - -// timeouts -const double TOMsg=0.4; -const double TOAck=0.6; - - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -rewards - [TO_Msg] true : TOMsg; - [TO_Ack] true : TOAck; -endrewards - - diff --git a/examples/pdtmc/brp_rewards2/brp_rewards64_4.pm b/examples/pdtmc/brp_rewards2/brp_rewards64_4.pm deleted file mode 100644 index 0fdcf94a1..000000000 --- a/examples/pdtmc/brp_rewards2/brp_rewards64_4.pm +++ /dev/null @@ -1,147 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 64; -// maximum number of retransmissions -const int MAX = 4; - -// reliability of channels -const double pL; -const double pK; - -// timeouts -const double TOMsg=0.4; -const double TOAck=0.6; - - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -rewards - [TO_Msg] true : TOMsg; - [TO_Ack] true : TOAck; -endrewards - - diff --git a/examples/pdtmc/brp_rewards2/models b/examples/pdtmc/brp_rewards2/models deleted file mode 100644 index c4ac2bb5e..000000000 --- a/examples/pdtmc/brp_rewards2/models +++ /dev/null @@ -1,2 +0,0 @@ -brp_rewards2.pm -const N=512,MAX=5 -brp_rewards2.pm -const N=4096,MAX=5 diff --git a/examples/pdtmc/brp_rewards4/brp_rewards16_2.pm b/examples/pdtmc/brp_rewards4/brp_rewards16_2.pm deleted file mode 100644 index d756a90ec..000000000 --- a/examples/pdtmc/brp_rewards4/brp_rewards16_2.pm +++ /dev/null @@ -1,146 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 16; -// maximum number of retransmissions -const int MAX = 2; - -// reliability of channels -const double pL; -const double pK; - -// timeouts -const double TOMsg; -const double TOAck; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -rewards - [TO_Msg] true : TOMsg; - [TO_Ack] true : TOAck; -endrewards - - diff --git a/examples/pdtmc/brp_rewards4/brp_rewards256_5.pm b/examples/pdtmc/brp_rewards4/brp_rewards256_5.pm deleted file mode 100644 index 13937379a..000000000 --- a/examples/pdtmc/brp_rewards4/brp_rewards256_5.pm +++ /dev/null @@ -1,146 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 256; -// maximum number of retransmissions -const int MAX = 5; - -// reliability of channels -const double pL; -const double pK; - -// timeouts -const double TOMsg; -const double TOAck; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -rewards - [TO_Msg] true : TOMsg; - [TO_Ack] true : TOAck; -endrewards - - diff --git a/examples/pdtmc/brp_rewards4/brp_rewards4.pm b/examples/pdtmc/brp_rewards4/brp_rewards4.pm deleted file mode 100644 index 5617e839b..000000000 --- a/examples/pdtmc/brp_rewards4/brp_rewards4.pm +++ /dev/null @@ -1,146 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N; -// maximum number of retransmissions -const int MAX; - -// reliability of channels -const double pL; -const double pK; - -// timeouts -const double TOMsg; -const double TOAck; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -rewards - [TO_Msg] true : TOMsg; - [TO_Ack] true : TOAck; -endrewards - - diff --git a/examples/pdtmc/brp_rewards4/brp_rewards4.prctl b/examples/pdtmc/brp_rewards4/brp_rewards4.prctl deleted file mode 100644 index 3a194c0be..000000000 --- a/examples/pdtmc/brp_rewards4/brp_rewards4.prctl +++ /dev/null @@ -1,2 +0,0 @@ -R<3 [ F ((s=5) | (s=0&srep=3)) ] - diff --git a/examples/pdtmc/brp_rewards4/brp_rewards4_regions.txt b/examples/pdtmc/brp_rewards4/brp_rewards4_regions.txt deleted file mode 100644 index 0548f99da..000000000 --- a/examples/pdtmc/brp_rewards4/brp_rewards4_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.000010<=pL<=0.200000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.200000<=pL<=0.400000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.400000<=pL<=0.600000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.600000<=pL<=0.800000, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.000010<=pK<=0.200000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.200000<=pK<=0.400000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.400000<=pK<=0.600000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.600000<=pK<=0.800000, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.000010<=TOMsg<=0.200000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.200000<=TOMsg<=0.400000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.400000<=TOMsg<=0.600000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.600000<=TOMsg<=0.800000, 0.800000<=TOAck<=0.999990; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.000010<=TOAck<=0.200000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.200000<=TOAck<=0.400000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.400000<=TOAck<=0.600000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.600000<=TOAck<=0.800000; -0.800000<=pL<=0.999990, 0.800000<=pK<=0.999990, 0.800000<=TOMsg<=0.999990, 0.800000<=TOAck<=0.999990; diff --git a/examples/pdtmc/brp_rewards4/brp_rewards4_regions2.txt b/examples/pdtmc/brp_rewards4/brp_rewards4_regions2.txt deleted file mode 100644 index 93769008f..000000000 --- a/examples/pdtmc/brp_rewards4/brp_rewards4_regions2.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=pL<=0.040000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.000010<=pL<=0.040000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.040000<=pL<=0.080000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.080000<=pL<=0.120000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.120000<=pL<=0.160000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.160000<=pL<=0.200000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.200000<=pL<=0.240000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.240000<=pL<=0.280000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.280000<=pL<=0.320000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.320000<=pL<=0.360000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.360000<=pL<=0.400000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.400000<=pL<=0.440000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.440000<=pL<=0.480000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.480000<=pL<=0.520000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.520000<=pL<=0.560000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.560000<=pL<=0.600000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.600000<=pL<=0.640000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.640000<=pL<=0.680000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.680000<=pL<=0.720000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.720000<=pL<=0.760000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.760000<=pL<=0.800000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.800000<=pL<=0.840000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.840000<=pL<=0.880000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.880000<=pL<=0.920000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.920000<=pL<=0.960000, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.000010<=pK<=0.040000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.040000<=pK<=0.080000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.080000<=pK<=0.120000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.120000<=pK<=0.160000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.160000<=pK<=0.200000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.200000<=pK<=0.240000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.240000<=pK<=0.280000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.280000<=pK<=0.320000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.320000<=pK<=0.360000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.360000<=pK<=0.400000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.400000<=pK<=0.440000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.440000<=pK<=0.480000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.480000<=pK<=0.520000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.520000<=pK<=0.560000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.560000<=pK<=0.600000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.600000<=pK<=0.640000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.640000<=pK<=0.680000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.680000<=pK<=0.720000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.720000<=pK<=0.760000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.760000<=pK<=0.800000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.800000<=pK<=0.840000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.840000<=pK<=0.880000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.880000<=pK<=0.920000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.920000<=pK<=0.960000, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; -0.960000<=pL<=0.999990, 0.960000<=pK<=0.999990, 0.35<=TOMsg<=0.45, 0.55<=TOAck<=0.65; diff --git a/examples/pdtmc/brp_rewards4/brp_rewards4_space.txt b/examples/pdtmc/brp_rewards4/brp_rewards4_space.txt deleted file mode 100644 index 71a8cd59a..000000000 --- a/examples/pdtmc/brp_rewards4/brp_rewards4_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=pL<=0.999990, 0.000010<=pK<=0.999990, 0.000010<=TOMsg<=0.999990, 0.000010<=TOAck<=0.999990; - diff --git a/examples/pdtmc/brp_rewards4/brp_rewards512_5.pm b/examples/pdtmc/brp_rewards4/brp_rewards512_5.pm deleted file mode 100644 index dba2395b1..000000000 --- a/examples/pdtmc/brp_rewards4/brp_rewards512_5.pm +++ /dev/null @@ -1,146 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 512; -// maximum number of retransmissions -const int MAX = 5; - -// reliability of channels -const double pL; -const double pK; - -// timeouts -const double TOMsg; -const double TOAck; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -rewards - [TO_Msg] true : TOMsg; - [TO_Ack] true : TOAck; -endrewards - - diff --git a/examples/pdtmc/brp_rewards4/brp_rewards64_4.pm b/examples/pdtmc/brp_rewards4/brp_rewards64_4.pm deleted file mode 100644 index 5a0f82b7f..000000000 --- a/examples/pdtmc/brp_rewards4/brp_rewards64_4.pm +++ /dev/null @@ -1,146 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 - -dtmc - -// number of chunks -const int N = 64; -// maximum number of retransmissions -const int MAX = 4; - -// reliability of channels -const double pL; -const double pK; - -// timeouts -const double TOMsg; -const double TOAck; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -// prevents more than one file being sent -module tester - - T : bool; - - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - -rewards - [TO_Msg] true : TOMsg; - [TO_Ack] true : TOAck; -endrewards - - diff --git a/examples/pdtmc/brp_rewards4/models b/examples/pdtmc/brp_rewards4/models deleted file mode 100644 index e3656e3a8..000000000 --- a/examples/pdtmc/brp_rewards4/models +++ /dev/null @@ -1,2 +0,0 @@ -brp_rewards4.pm -const N=256,MAX=5 -brp_rewards4.pm -const N=5012,MAX=5 diff --git a/examples/pdtmc/crowds/crowds.pm b/examples/pdtmc/crowds/crowds.pm deleted file mode 100644 index 1da952d06..000000000 --- a/examples/pdtmc/crowds/crowds.pm +++ /dev/null @@ -1,194 +0,0 @@ -// CROWDS [Reiter,Rubin] -// Vitaly Shmatikov, 2002 -// Modified by Ernst Moritz Hahn (emh@cs.uni-sb.de) - -// note: -// Change everything marked CWDSIZ when changing the size of the crowd -// Change everything marked CWDMAX when increasing max size of the crowd - -dtmc - -// Model parameters -const double PF; // forwarding probability -const double badC; // probability that member is untrustworthy - -// Probability of forwarding -// const double PF = 0.8; -// const double notPF = 0.2; // must be 1-PF - -// Probability that a crowd member is bad -// const double badC = 0.1; -// const double badC = 0.091; -// const double badC = 0.167; -// const double goodC = 0.909; // must be 1-badC -// const double goodC = 0.833; // must be 1-badC - -const int CrowdSize; // CWDSIZ: actual number of good crowd members -const int TotalRuns; // Total number of protocol runs to analyze -const int MaxGood=20; // CWDMAX: maximum number of good crowd members - -// Process definitions -module crowds - - // Auxiliary variables - launch: bool init true; // Start modeling? - newInstance: bool init false; // Initialize a new protocol instance? - runCount: [0..TotalRuns] init TotalRuns; // Counts protocol instances - start: bool init false; // Start the protocol? - run: bool init false; // Run the protocol? - lastSeen: [0..MaxGood] init 0; // Last crowd member to touch msg - good: bool init false; // Crowd member is good? - bad: bool init false; // ... bad? - recordLast: bool init false; // Record last seen crowd member? - badObserve: bool init false; // Bad members observes who sent msg? - deliver: bool init false; // Deliver message to destination? - done: bool init false; // Protocol instance finished? - - // Counters for attackers' observations - // CWDMAX: 1 counter per each good crowd member - observe0: [0..TotalRuns]; - observe1: [0..TotalRuns]; - observe2: [0..TotalRuns]; - observe3: [0..TotalRuns]; - observe4: [0..TotalRuns]; - observe5: [0..TotalRuns]; - observe6: [0..TotalRuns]; - observe7: [0..TotalRuns]; - observe8: [0..TotalRuns]; - observe9: [0..TotalRuns]; - observe10: [0..TotalRuns]; - observe11: [0..TotalRuns]; - observe12: [0..TotalRuns]; - observe13: [0..TotalRuns]; - observe14: [0..TotalRuns]; - observe15: [0..TotalRuns]; - observe16: [0..TotalRuns]; - observe17: [0..TotalRuns]; - observe18: [0..TotalRuns]; - observe19: [0..TotalRuns]; - - [] launch -> (newInstance'=true) & (runCount'=TotalRuns) & (launch'=false); - // Set up a newInstance protocol instance - [] newInstance & runCount>0 -> (runCount'=runCount-1) & (newInstance'=false) & (start'=true); - - // SENDER - // Start the protocol - [] start -> (lastSeen'=0) & (run'=true) & (deliver'=false) & (start'=false); - - // CROWD MEMBERS - // Good or bad crowd member? - [] !good & !bad & !deliver & run -> - 1-badC : (good'=true) & (recordLast'=true) & (run'=false) + - badC : (bad'=true) & (badObserve'=true) & (run'=false); - - // GOOD MEMBERS - // Forward with probability PF, else deliver - [] good & !deliver & run -> PF : (good'=false) + 1-PF : (deliver'=true); - // Record the last crowd member who touched the msg; - // all good members may appear with equal probability - // Note: This is backward. In the real protocol, each honest - // forwarder randomly chooses the next forwarder. - // Here, the identity of an honest forwarder is randomly - // chosen *after* it has forwarded the message. - [] recordLast & CrowdSize=2 -> - 1/2 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/2 : (lastSeen'=1) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=3 -> - 1/3 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/3 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/3 : (lastSeen'=2) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=4 -> - 1/4 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=3) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=5 -> - 1/5 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=4) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=10 -> - 1/10 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=9) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=15 -> - 1/15 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=9) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=10) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=11) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=12) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=13) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=14) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=20 -> - 1/20 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=9) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=10) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=11) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=12) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=13) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=14) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=15) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=16) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=17) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=18) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=19) & (recordLast'=false) & (run'=true); - - // BAD MEMBERS - // Remember from whom the message was received and deliver - // CWDMAX: 1 rule per each good crowd member - [] lastSeen=0 & badObserve & observe0 (observe0' =observe0 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=1 & badObserve & observe1 (observe1' =observe1 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=2 & badObserve & observe2 (observe2' =observe2 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=3 & badObserve & observe3 (observe3' =observe3 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=4 & badObserve & observe4 (observe4' =observe4 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=5 & badObserve & observe5 (observe5' =observe5 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=6 & badObserve & observe6 (observe6' =observe6 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=7 & badObserve & observe7 (observe7' =observe7 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=8 & badObserve & observe8 (observe8' =observe8 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=9 & badObserve & observe9 (observe9' =observe9 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=10 & badObserve & observe10 (observe10'=observe10+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=11 & badObserve & observe11 (observe11'=observe11+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=12 & badObserve & observe12 (observe12'=observe12+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=13 & badObserve & observe13 (observe13'=observe13+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=14 & badObserve & observe14 (observe14'=observe14+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=15 & badObserve & observe15 (observe15'=observe15+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=16 & badObserve & observe16 (observe16'=observe16+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=17 & badObserve & observe17 (observe17'=observe17+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=18 & badObserve & observe18 (observe18'=observe18+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=19 & badObserve & observe19 (observe19'=observe19+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - - // RECIPIENT - // Delivery to destination - [] deliver & run -> (done'=true) & (deliver'=false) & (run'=false) & (good'=false) & (bad'=false); - // Start a newInstance instance - [] done -> (newInstance'=true) & (done'=false) & (run'=false) & (lastSeen'=MaxGood); - -endmodule - -label "observe0Greater1" = observe0 > 1; -label "observeIGreater1" = observe1>1|observe2>1; -label "observeOnlyTrueSender" = observe0>1&observe1<=1 & observe2<=1; diff --git a/examples/pdtmc/crowds/crowds.prctl b/examples/pdtmc/crowds/crowds.prctl deleted file mode 100644 index e2c788377..000000000 --- a/examples/pdtmc/crowds/crowds.prctl +++ /dev/null @@ -1 +0,0 @@ -P<=0.9 [F "observe0Greater1" ] diff --git a/examples/pdtmc/crowds/crowds10_5.pm b/examples/pdtmc/crowds/crowds10_5.pm deleted file mode 100644 index 022e93948..000000000 --- a/examples/pdtmc/crowds/crowds10_5.pm +++ /dev/null @@ -1,195 +0,0 @@ -// CROWDS [Reiter,Rubin] -// Vitaly Shmatikov, 2002 -// Modified by Ernst Moritz Hahn (emh@cs.uni-sb.de) - -// note: -// Change everything marked CWDSIZ when changing the size of the crowd -// Change everything marked CWDMAX when increasing max size of the crowd - -dtmc - -// Model parameters -const double PF; // forwarding probability -const double badC; // probability that member is untrustworthy - -// Probability of forwarding -// const double PF = 0.8; -// const double notPF = 0.2; // must be 1-PF - -// Probability that a crowd member is bad -// const double badC = 0.1; -// const double badC = 0.091; -// const double badC = 0.167; -// const double goodC = 0.909; // must be 1-badC -// const double goodC = 0.833; // must be 1-badC - -const int CrowdSize = 10; // CWDSIZ: actual number of good crowd members -const int TotalRuns = 5; // Total number of protocol runs to analyze -const int MaxGood=20; // CWDMAX: maximum number of good crowd members - -// Process definitions -module crowds - - // Auxiliary variables - launch: bool init true; // Start modeling? - newInstance: bool init false; // Initialize a new protocol instance? - runCount: [0..TotalRuns] init TotalRuns; // Counts protocol instances - start: bool init false; // Start the protocol? - run: bool init false; // Run the protocol? - lastSeen: [0..MaxGood] init 0; // Last crowd member to touch msg - good: bool init false; // Crowd member is good? - bad: bool init false; // ... bad? - recordLast: bool init false; // Record last seen crowd member? - badObserve: bool init false; // Bad members observes who sent msg? - deliver: bool init false; // Deliver message to destination? - done: bool init false; // Protocol instance finished? - - // Counters for attackers' observations - // CWDMAX: 1 counter per each good crowd member - observe0: [0..TotalRuns]; - observe1: [0..TotalRuns]; - observe2: [0..TotalRuns]; - observe3: [0..TotalRuns]; - observe4: [0..TotalRuns]; - observe5: [0..TotalRuns]; - observe6: [0..TotalRuns]; - observe7: [0..TotalRuns]; - observe8: [0..TotalRuns]; - observe9: [0..TotalRuns]; - observe10: [0..TotalRuns]; - observe11: [0..TotalRuns]; - observe12: [0..TotalRuns]; - observe13: [0..TotalRuns]; - observe14: [0..TotalRuns]; - observe15: [0..TotalRuns]; - observe16: [0..TotalRuns]; - observe17: [0..TotalRuns]; - observe18: [0..TotalRuns]; - observe19: [0..TotalRuns]; - - [] launch -> (newInstance'=true) & (runCount'=TotalRuns) & (launch'=false); - // Set up a newInstance protocol instance - [] newInstance & runCount>0 -> (runCount'=runCount-1) & (newInstance'=false) & (start'=true); - - // SENDER - // Start the protocol - [] start -> (lastSeen'=0) & (run'=true) & (deliver'=false) & (start'=false); - - // CROWD MEMBERS - // Good or bad crowd member? - [] !good & !bad & !deliver & run -> - 1-badC : (good'=true) & (recordLast'=true) & (run'=false) + - badC : (bad'=true) & (badObserve'=true) & (run'=false); - - // GOOD MEMBERS - // Forward with probability PF, else deliver - [] good & !deliver & run -> PF : (good'=false) + 1-PF : (deliver'=true); - // Record the last crowd member who touched the msg; - // all good members may appear with equal probability - // Note: This is backward. In the real protocol, each honest - // forwarder randomly chooses the next forwarder. - // Here, the identity of an honest forwarder is randomly - // chosen *after* it has forwarded the message. - [] recordLast & CrowdSize=2 -> - 1/2 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/2 : (lastSeen'=1) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=3 -> - 1/3 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/3 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/3 : (lastSeen'=2) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=4 -> - 1/4 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=3) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=5 -> - 1/5 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=4) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=10 -> - 1/10 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=9) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=15 -> - 1/15 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=9) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=10) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=11) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=12) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=13) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=14) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=20 -> - 1/20 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=9) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=10) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=11) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=12) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=13) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=14) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=15) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=16) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=17) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=18) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=19) & (recordLast'=false) & (run'=true); - - // BAD MEMBERS - // Remember from whom the message was received and deliver - // CWDMAX: 1 rule per each good crowd member - [] lastSeen=0 & badObserve & observe0 (observe0' =observe0 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=1 & badObserve & observe1 (observe1' =observe1 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=2 & badObserve & observe2 (observe2' =observe2 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=3 & badObserve & observe3 (observe3' =observe3 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=4 & badObserve & observe4 (observe4' =observe4 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=5 & badObserve & observe5 (observe5' =observe5 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=6 & badObserve & observe6 (observe6' =observe6 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=7 & badObserve & observe7 (observe7' =observe7 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=8 & badObserve & observe8 (observe8' =observe8 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=9 & badObserve & observe9 (observe9' =observe9 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=10 & badObserve & observe10 (observe10'=observe10+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=11 & badObserve & observe11 (observe11'=observe11+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=12 & badObserve & observe12 (observe12'=observe12+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=13 & badObserve & observe13 (observe13'=observe13+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=14 & badObserve & observe14 (observe14'=observe14+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=15 & badObserve & observe15 (observe15'=observe15+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=16 & badObserve & observe16 (observe16'=observe16+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=17 & badObserve & observe17 (observe17'=observe17+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=18 & badObserve & observe18 (observe18'=observe18+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=19 & badObserve & observe19 (observe19'=observe19+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - - // RECIPIENT - // Delivery to destination - [] deliver & run -> (done'=true) & (deliver'=false) & (run'=false) & (good'=false) & (bad'=false); - // Start a newInstance instance - [] done -> (newInstance'=true) & (done'=false) & (run'=false) & (lastSeen'=MaxGood); - -endmodule - -label "observe0Greater1" = observe0 > 1; -label "observeIGreater1" = observe1 > 1 | observe2 > 1 | observe3 > 1 | observe4 > 1 | observe5 > 1 | observe6 > 1 | observe7 > 1 | observe8 > 1 | observe9 > 1; -label "observeOnlyTrueSender" = observe0 > 1 & observe1 <= 1 & observe2 <= 1 & observe3 <= 1 & observe4 <= 1 & observe5 <= 1 & observe6 <= 1 & observe7 <= 1 & observe8 <= 1 & observe9 <= 1; - diff --git a/examples/pdtmc/crowds/crowds15_5.pm b/examples/pdtmc/crowds/crowds15_5.pm deleted file mode 100644 index 994c2e2dd..000000000 --- a/examples/pdtmc/crowds/crowds15_5.pm +++ /dev/null @@ -1,195 +0,0 @@ -// CROWDS [Reiter,Rubin] -// Vitaly Shmatikov, 2002 -// Modified by Ernst Moritz Hahn (emh@cs.uni-sb.de) - -// note: -// Change everything marked CWDSIZ when changing the size of the crowd -// Change everything marked CWDMAX when increasing max size of the crowd - -dtmc - -// Model parameters -const double PF; // forwarding probability -const double badC; // probability that member is untrustworthy - -// Probability of forwarding -// const double PF = 0.8; -// const double notPF = 0.2; // must be 1-PF - -// Probability that a crowd member is bad -// const double badC = 0.1; -// const double badC = 0.091; -// const double badC = 0.167; -// const double goodC = 0.909; // must be 1-badC -// const double goodC = 0.833; // must be 1-badC - -const int CrowdSize = 15; // CWDSIZ: actual number of good crowd members -const int TotalRuns = 5; // Total number of protocol runs to analyze -const int MaxGood=20; // CWDMAX: maximum number of good crowd members - -// Process definitions -module crowds - - // Auxiliary variables - launch: bool init true; // Start modeling? - newInstance: bool init false; // Initialize a new protocol instance? - runCount: [0..TotalRuns] init TotalRuns; // Counts protocol instances - start: bool init false; // Start the protocol? - run: bool init false; // Run the protocol? - lastSeen: [0..MaxGood] init 0; // Last crowd member to touch msg - good: bool init false; // Crowd member is good? - bad: bool init false; // ... bad? - recordLast: bool init false; // Record last seen crowd member? - badObserve: bool init false; // Bad members observes who sent msg? - deliver: bool init false; // Deliver message to destination? - done: bool init false; // Protocol instance finished? - - // Counters for attackers' observations - // CWDMAX: 1 counter per each good crowd member - observe0: [0..TotalRuns]; - observe1: [0..TotalRuns]; - observe2: [0..TotalRuns]; - observe3: [0..TotalRuns]; - observe4: [0..TotalRuns]; - observe5: [0..TotalRuns]; - observe6: [0..TotalRuns]; - observe7: [0..TotalRuns]; - observe8: [0..TotalRuns]; - observe9: [0..TotalRuns]; - observe10: [0..TotalRuns]; - observe11: [0..TotalRuns]; - observe12: [0..TotalRuns]; - observe13: [0..TotalRuns]; - observe14: [0..TotalRuns]; - observe15: [0..TotalRuns]; - observe16: [0..TotalRuns]; - observe17: [0..TotalRuns]; - observe18: [0..TotalRuns]; - observe19: [0..TotalRuns]; - - [] launch -> (newInstance'=true) & (runCount'=TotalRuns) & (launch'=false); - // Set up a newInstance protocol instance - [] newInstance & runCount>0 -> (runCount'=runCount-1) & (newInstance'=false) & (start'=true); - - // SENDER - // Start the protocol - [] start -> (lastSeen'=0) & (run'=true) & (deliver'=false) & (start'=false); - - // CROWD MEMBERS - // Good or bad crowd member? - [] !good & !bad & !deliver & run -> - 1-badC : (good'=true) & (recordLast'=true) & (run'=false) + - badC : (bad'=true) & (badObserve'=true) & (run'=false); - - // GOOD MEMBERS - // Forward with probability PF, else deliver - [] good & !deliver & run -> PF : (good'=false) + 1-PF : (deliver'=true); - // Record the last crowd member who touched the msg; - // all good members may appear with equal probability - // Note: This is backward. In the real protocol, each honest - // forwarder randomly chooses the next forwarder. - // Here, the identity of an honest forwarder is randomly - // chosen *after* it has forwarded the message. - [] recordLast & CrowdSize=2 -> - 1/2 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/2 : (lastSeen'=1) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=3 -> - 1/3 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/3 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/3 : (lastSeen'=2) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=4 -> - 1/4 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=3) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=5 -> - 1/5 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=4) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=10 -> - 1/10 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=9) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=15 -> - 1/15 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=9) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=10) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=11) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=12) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=13) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=14) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=20 -> - 1/20 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=9) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=10) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=11) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=12) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=13) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=14) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=15) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=16) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=17) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=18) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=19) & (recordLast'=false) & (run'=true); - - // BAD MEMBERS - // Remember from whom the message was received and deliver - // CWDMAX: 1 rule per each good crowd member - [] lastSeen=0 & badObserve & observe0 (observe0' =observe0 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=1 & badObserve & observe1 (observe1' =observe1 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=2 & badObserve & observe2 (observe2' =observe2 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=3 & badObserve & observe3 (observe3' =observe3 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=4 & badObserve & observe4 (observe4' =observe4 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=5 & badObserve & observe5 (observe5' =observe5 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=6 & badObserve & observe6 (observe6' =observe6 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=7 & badObserve & observe7 (observe7' =observe7 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=8 & badObserve & observe8 (observe8' =observe8 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=9 & badObserve & observe9 (observe9' =observe9 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=10 & badObserve & observe10 (observe10'=observe10+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=11 & badObserve & observe11 (observe11'=observe11+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=12 & badObserve & observe12 (observe12'=observe12+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=13 & badObserve & observe13 (observe13'=observe13+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=14 & badObserve & observe14 (observe14'=observe14+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=15 & badObserve & observe15 (observe15'=observe15+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=16 & badObserve & observe16 (observe16'=observe16+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=17 & badObserve & observe17 (observe17'=observe17+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=18 & badObserve & observe18 (observe18'=observe18+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=19 & badObserve & observe19 (observe19'=observe19+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - - // RECIPIENT - // Delivery to destination - [] deliver & run -> (done'=true) & (deliver'=false) & (run'=false) & (good'=false) & (bad'=false); - // Start a newInstance instance - [] done -> (newInstance'=true) & (done'=false) & (run'=false) & (lastSeen'=MaxGood); - -endmodule - -label "observe0Greater1" = observe0 > 1; -label "observeIGreater1" = observe1 > 1 | observe2 > 1 | observe3 > 1 | observe4 > 1 | observe5 > 1 | observe6 > 1 | observe7 > 1 | observe8 > 1 | observe9 > 1 | observe10 > 1 | observe11 > 1 | observe12 > 1 | observe13 > 1 | observe14 > 1; -label "observeOnlyTrueSender" = observe0 > 1 & observe1 <= 1 & observe2 <= 1 & observe3 <= 1 & observe4 <= 1 & observe5 <= 1 & observe6 <= 1 & observe7 <= 1 & observe8 <= 1 & observe9 <= 1 & observe10 <= 1 & observe11 <= 1 & observe12 <= 1 & observe13 <= 1 & observe14 <= 1; - diff --git a/examples/pdtmc/crowds/crowds20_5.pm b/examples/pdtmc/crowds/crowds20_5.pm deleted file mode 100644 index d235ff110..000000000 --- a/examples/pdtmc/crowds/crowds20_5.pm +++ /dev/null @@ -1,194 +0,0 @@ -// CROWDS [Reiter,Rubin] -// Vitaly Shmatikov, 2002 -// Modified by Ernst Moritz Hahn (emh@cs.uni-sb.de) - -// note: -// Change everything marked CWDSIZ when changing the size of the crowd -// Change everything marked CWDMAX when increasing max size of the crowd - -dtmc - -// Model parameters -const double PF; // forwarding probability -const double badC; // probability that member is untrustworthy - -// Probability of forwarding -// const double PF = 0.8; -// const double notPF = 0.2; // must be 1-PF - -// Probability that a crowd member is bad -// const double badC = 0.1; -// const double badC = 0.091; -// const double badC = 0.167; -// const double goodC = 0.909; // must be 1-badC -// const double goodC = 0.833; // must be 1-badC - -const int CrowdSize = 20; // CWDSIZ: actual number of good crowd members -const int TotalRuns = 5; // Total number of protocol runs to analyze -const int MaxGood=20; // CWDMAX: maximum number of good crowd members - -// Process definitions -module crowds - - // Auxiliary variables - launch: bool init true; // Start modeling? - newInstance: bool init false; // Initialize a new protocol instance? - runCount: [0..TotalRuns] init TotalRuns; // Counts protocol instances - start: bool init false; // Start the protocol? - run: bool init false; // Run the protocol? - lastSeen: [0..MaxGood] init MaxGood; // Last crowd member to touch msg - good: bool init false; // Crowd member is good? - bad: bool init false; // ... bad? - recordLast: bool init false; // Record last seen crowd member? - badObserve: bool init false; // Bad members observes who sent msg? - deliver: bool init false; // Deliver message to destination? - done: bool init false; // Protocol instance finished? - - // Counters for attackers' observations - // CWDMAX: 1 counter per each good crowd member - observe0: [0..TotalRuns]; - observe1: [0..TotalRuns]; - observe2: [0..TotalRuns]; - observe3: [0..TotalRuns]; - observe4: [0..TotalRuns]; - observe5: [0..TotalRuns]; - observe6: [0..TotalRuns]; - observe7: [0..TotalRuns]; - observe8: [0..TotalRuns]; - observe9: [0..TotalRuns]; - observe10: [0..TotalRuns]; - observe11: [0..TotalRuns]; - observe12: [0..TotalRuns]; - observe13: [0..TotalRuns]; - observe14: [0..TotalRuns]; - observe15: [0..TotalRuns]; - observe16: [0..TotalRuns]; - observe17: [0..TotalRuns]; - observe18: [0..TotalRuns]; - observe19: [0..TotalRuns]; - - [] launch -> (newInstance'=true) & (runCount'=TotalRuns) & (launch'=false); - // Set up a newInstance protocol instance - [] newInstance & runCount>0 -> (runCount'=runCount-1) & (newInstance'=false) & (start'=true); - - // SENDER - // Start the protocol - [] start -> (lastSeen'=0) & (run'=true) & (deliver'=false) & (start'=false); - - // CROWD MEMBERS - // Good or bad crowd member? - [] !good & !bad & !deliver & run -> - 1-badC : (good'=true) & (recordLast'=true) & (run'=false) + - badC : (bad'=true) & (badObserve'=true) & (run'=false); - - // GOOD MEMBERS - // Forward with probability PF, else deliver - [] good & !deliver & run -> PF : (good'=false) + 1-PF : (deliver'=true); - // Record the last crowd member who touched the msg; - // all good members may appear with equal probability - // Note: This is backward. In the real protocol, each honest - // forwarder randomly chooses the next forwarder. - // Here, the identity of an honest forwarder is randomly - // chosen *after* it has forwarded the message. - [] recordLast & CrowdSize=2 -> - 1/2 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/2 : (lastSeen'=1) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=3 -> - 1/3 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/3 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/3 : (lastSeen'=2) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=4 -> - 1/4 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=3) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=5 -> - 1/5 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=4) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=10 -> - 1/10 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=9) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=15 -> - 1/15 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=9) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=10) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=11) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=12) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=13) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=14) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=20 -> - 1/20 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=9) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=10) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=11) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=12) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=13) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=14) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=15) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=16) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=17) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=18) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=19) & (recordLast'=false) & (run'=true); - - // BAD MEMBERS - // Remember from whom the message was received and deliver - // CWDMAX: 1 rule per each good crowd member - [] lastSeen=0 & badObserve & observe0 (observe0' =observe0 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=1 & badObserve & observe1 (observe1' =observe1 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=2 & badObserve & observe2 (observe2' =observe2 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=3 & badObserve & observe3 (observe3' =observe3 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=4 & badObserve & observe4 (observe4' =observe4 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=5 & badObserve & observe5 (observe5' =observe5 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=6 & badObserve & observe6 (observe6' =observe6 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=7 & badObserve & observe7 (observe7' =observe7 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=8 & badObserve & observe8 (observe8' =observe8 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=9 & badObserve & observe9 (observe9' =observe9 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=10 & badObserve & observe10 (observe10'=observe10+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=11 & badObserve & observe11 (observe11'=observe11+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=12 & badObserve & observe12 (observe12'=observe12+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=13 & badObserve & observe13 (observe13'=observe13+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=14 & badObserve & observe14 (observe14'=observe14+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=15 & badObserve & observe15 (observe15'=observe15+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=16 & badObserve & observe16 (observe16'=observe16+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=17 & badObserve & observe17 (observe17'=observe17+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=18 & badObserve & observe18 (observe18'=observe18+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=19 & badObserve & observe19 (observe19'=observe19+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - - // RECIPIENT - // Delivery to destination - [] deliver & run -> (done'=true) & (deliver'=false) & (run'=false) & (good'=false) & (bad'=false); - // Start a newInstance instance - [] done -> (newInstance'=true) & (done'=false) & (run'=false) & (lastSeen'=MaxGood); - -endmodule - -label "observe0Greater1" = observe0 > 1; -label "observeIGreater1" = observe1 > 1 | observe2 > 1 | observe3 > 1 | observe4 > 1 | observe5 > 1 | observe6 > 1 | observe7 > 1 | observe8 > 1 | observe9 > 1 | observe10 > 1 | observe11 > 1 | observe12 > 1 | observe13 > 1 | observe14 > 1 | observe15 > 1 | observe16 > 1 | observe17 > 1 | observe18 > 1 | observe19 > 1; -label "observeOnlyTrueSender" = observe0 > 1 & observe1 <= 1 & observe2 <= 1 & observe3 <= 1 & observe4 <= 1 & observe5 <= 1 & observe6 <= 1 & observe7 <= 1 & observe8 <= 1 & observe9 <= 1 & observe10 <= 1 & observe11 <= 1 & observe12 <= 1 & observe13 <= 1 & observe14 <= 1 & observe15 <= 1 & observe16 <= 1 & observe17 <= 1 & observe18 <= 1 & observe19 <= 1; diff --git a/examples/pdtmc/crowds/crowds5_5.pm b/examples/pdtmc/crowds/crowds5_5.pm deleted file mode 100644 index e936c45b7..000000000 --- a/examples/pdtmc/crowds/crowds5_5.pm +++ /dev/null @@ -1,194 +0,0 @@ -// CROWDS [Reiter,Rubin] -// Vitaly Shmatikov, 2002 -// Modified by Ernst Moritz Hahn (emh@cs.uni-sb.de) - -// note: -// Change everything marked CWDSIZ when changing the size of the crowd -// Change everything marked CWDMAX when increasing max size of the crowd - -dtmc - -// Model parameters -const double PF; // forwarding probability -const double badC; // probability that member is untrustworthy - -// Probability of forwarding -// const double PF = 0.8; -// const double notPF = 0.2; // must be 1-PF - -// Probability that a crowd member is bad -// const double badC = 0.1; -// const double badC = 0.091; -// const double badC = 0.167; -// const double goodC = 0.909; // must be 1-badC -// const double goodC = 0.833; // must be 1-badC - -const int CrowdSize = 5; // CWDSIZ: actual number of good crowd members -const int TotalRuns = 5; // Total number of protocol runs to analyze -const int MaxGood=20; // CWDMAX: maximum number of good crowd members - -// Process definitions -module crowds - - // Auxiliary variables - launch: bool init true; // Start modeling? - newInstance: bool init false; // Initialize a new protocol instance? - runCount: [0..TotalRuns] init TotalRuns; // Counts protocol instances - start: bool init false; // Start the protocol? - run: bool init false; // Run the protocol? - lastSeen: [0..MaxGood] init 0; // Last crowd member to touch msg - good: bool init false; // Crowd member is good? - bad: bool init false; // ... bad? - recordLast: bool init false; // Record last seen crowd member? - badObserve: bool init false; // Bad members observes who sent msg? - deliver: bool init false; // Deliver message to destination? - done: bool init false; // Protocol instance finished? - - // Counters for attackers' observations - // CWDMAX: 1 counter per each good crowd member - observe0: [0..TotalRuns]; - observe1: [0..TotalRuns]; - observe2: [0..TotalRuns]; - observe3: [0..TotalRuns]; - observe4: [0..TotalRuns]; - observe5: [0..TotalRuns]; - observe6: [0..TotalRuns]; - observe7: [0..TotalRuns]; - observe8: [0..TotalRuns]; - observe9: [0..TotalRuns]; - observe10: [0..TotalRuns]; - observe11: [0..TotalRuns]; - observe12: [0..TotalRuns]; - observe13: [0..TotalRuns]; - observe14: [0..TotalRuns]; - observe15: [0..TotalRuns]; - observe16: [0..TotalRuns]; - observe17: [0..TotalRuns]; - observe18: [0..TotalRuns]; - observe19: [0..TotalRuns]; - - [] launch -> (newInstance'=true) & (runCount'=TotalRuns) & (launch'=false); - // Set up a newInstance protocol instance - [] newInstance & runCount>0 -> (runCount'=runCount-1) & (newInstance'=false) & (start'=true); - - // SENDER - // Start the protocol - [] start -> (lastSeen'=0) & (run'=true) & (deliver'=false) & (start'=false); - - // CROWD MEMBERS - // Good or bad crowd member? - [] !good & !bad & !deliver & run -> - 1-badC : (good'=true) & (recordLast'=true) & (run'=false) + - badC : (bad'=true) & (badObserve'=true) & (run'=false); - - // GOOD MEMBERS - // Forward with probability PF, else deliver - [] good & !deliver & run -> PF : (good'=false) + 1-PF : (deliver'=true); - // Record the last crowd member who touched the msg; - // all good members may appear with equal probability - // Note: This is backward. In the real protocol, each honest - // forwarder randomly chooses the next forwarder. - // Here, the identity of an honest forwarder is randomly - // chosen *after* it has forwarded the message. - [] recordLast & CrowdSize=2 -> - 1/2 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/2 : (lastSeen'=1) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=3 -> - 1/3 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/3 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/3 : (lastSeen'=2) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=4 -> - 1/4 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/4 : (lastSeen'=3) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=5 -> - 1/5 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/5 : (lastSeen'=4) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=10 -> - 1/10 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/10 : (lastSeen'=9) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=15 -> - 1/15 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=9) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=10) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=11) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=12) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=13) & (recordLast'=false) & (run'=true) + - 1/15 : (lastSeen'=14) & (recordLast'=false) & (run'=true); - [] recordLast & CrowdSize=20 -> - 1/20 : (lastSeen'=0) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=1) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=2) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=3) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=4) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=5) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=6) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=7) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=8) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=9) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=10) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=11) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=12) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=13) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=14) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=15) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=16) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=17) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=18) & (recordLast'=false) & (run'=true) + - 1/20 : (lastSeen'=19) & (recordLast'=false) & (run'=true); - - // BAD MEMBERS - // Remember from whom the message was received and deliver - // CWDMAX: 1 rule per each good crowd member - [] lastSeen=0 & badObserve & observe0 (observe0' =observe0 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=1 & badObserve & observe1 (observe1' =observe1 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=2 & badObserve & observe2 (observe2' =observe2 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=3 & badObserve & observe3 (observe3' =observe3 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=4 & badObserve & observe4 (observe4' =observe4 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=5 & badObserve & observe5 (observe5' =observe5 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=6 & badObserve & observe6 (observe6' =observe6 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=7 & badObserve & observe7 (observe7' =observe7 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=8 & badObserve & observe8 (observe8' =observe8 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=9 & badObserve & observe9 (observe9' =observe9 +1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=10 & badObserve & observe10 (observe10'=observe10+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=11 & badObserve & observe11 (observe11'=observe11+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=12 & badObserve & observe12 (observe12'=observe12+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=13 & badObserve & observe13 (observe13'=observe13+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=14 & badObserve & observe14 (observe14'=observe14+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=15 & badObserve & observe15 (observe15'=observe15+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=16 & badObserve & observe16 (observe16'=observe16+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=17 & badObserve & observe17 (observe17'=observe17+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=18 & badObserve & observe18 (observe18'=observe18+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - [] lastSeen=19 & badObserve & observe19 (observe19'=observe19+1) & (deliver'=true) & (run'=true) & (badObserve'=false); - - // RECIPIENT - // Delivery to destination - [] deliver & run -> (done'=true) & (deliver'=false) & (run'=false) & (good'=false) & (bad'=false); - // Start a newInstance instance - [] done -> (newInstance'=true) & (done'=false) & (run'=false) & (lastSeen'=MaxGood); - -endmodule - -label "observe0Greater1" = observe0 > 1; -label "observeIGreater1" = observe1>1|observe2>1|observe3>1|observe4>1; -label "observeOnlyTrueSender" = observe0>1&observe1<=1 & observe2<=1 & observe3<=1 & observe4<=1; diff --git a/examples/pdtmc/crowds/crowds_regions.txt b/examples/pdtmc/crowds/crowds_regions.txt deleted file mode 100644 index 86496ade3..000000000 --- a/examples/pdtmc/crowds/crowds_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=PF<=0.040000, 0.000010<=badC<=0.040000; -0.000010<=PF<=0.040000, 0.040000<=badC<=0.080000; -0.000010<=PF<=0.040000, 0.080000<=badC<=0.120000; -0.000010<=PF<=0.040000, 0.120000<=badC<=0.160000; -0.000010<=PF<=0.040000, 0.160000<=badC<=0.200000; -0.000010<=PF<=0.040000, 0.200000<=badC<=0.240000; -0.000010<=PF<=0.040000, 0.240000<=badC<=0.280000; -0.000010<=PF<=0.040000, 0.280000<=badC<=0.320000; -0.000010<=PF<=0.040000, 0.320000<=badC<=0.360000; -0.000010<=PF<=0.040000, 0.360000<=badC<=0.400000; -0.000010<=PF<=0.040000, 0.400000<=badC<=0.440000; -0.000010<=PF<=0.040000, 0.440000<=badC<=0.480000; -0.000010<=PF<=0.040000, 0.480000<=badC<=0.520000; -0.000010<=PF<=0.040000, 0.520000<=badC<=0.560000; -0.000010<=PF<=0.040000, 0.560000<=badC<=0.600000; -0.000010<=PF<=0.040000, 0.600000<=badC<=0.640000; -0.000010<=PF<=0.040000, 0.640000<=badC<=0.680000; -0.000010<=PF<=0.040000, 0.680000<=badC<=0.720000; -0.000010<=PF<=0.040000, 0.720000<=badC<=0.760000; -0.000010<=PF<=0.040000, 0.760000<=badC<=0.800000; -0.000010<=PF<=0.040000, 0.800000<=badC<=0.840000; -0.000010<=PF<=0.040000, 0.840000<=badC<=0.880000; -0.000010<=PF<=0.040000, 0.880000<=badC<=0.920000; -0.000010<=PF<=0.040000, 0.920000<=badC<=0.960000; -0.000010<=PF<=0.040000, 0.960000<=badC<=0.999990; -0.040000<=PF<=0.080000, 0.000010<=badC<=0.040000; -0.040000<=PF<=0.080000, 0.040000<=badC<=0.080000; -0.040000<=PF<=0.080000, 0.080000<=badC<=0.120000; -0.040000<=PF<=0.080000, 0.120000<=badC<=0.160000; -0.040000<=PF<=0.080000, 0.160000<=badC<=0.200000; -0.040000<=PF<=0.080000, 0.200000<=badC<=0.240000; -0.040000<=PF<=0.080000, 0.240000<=badC<=0.280000; -0.040000<=PF<=0.080000, 0.280000<=badC<=0.320000; -0.040000<=PF<=0.080000, 0.320000<=badC<=0.360000; -0.040000<=PF<=0.080000, 0.360000<=badC<=0.400000; -0.040000<=PF<=0.080000, 0.400000<=badC<=0.440000; -0.040000<=PF<=0.080000, 0.440000<=badC<=0.480000; -0.040000<=PF<=0.080000, 0.480000<=badC<=0.520000; -0.040000<=PF<=0.080000, 0.520000<=badC<=0.560000; -0.040000<=PF<=0.080000, 0.560000<=badC<=0.600000; -0.040000<=PF<=0.080000, 0.600000<=badC<=0.640000; -0.040000<=PF<=0.080000, 0.640000<=badC<=0.680000; -0.040000<=PF<=0.080000, 0.680000<=badC<=0.720000; -0.040000<=PF<=0.080000, 0.720000<=badC<=0.760000; -0.040000<=PF<=0.080000, 0.760000<=badC<=0.800000; -0.040000<=PF<=0.080000, 0.800000<=badC<=0.840000; -0.040000<=PF<=0.080000, 0.840000<=badC<=0.880000; -0.040000<=PF<=0.080000, 0.880000<=badC<=0.920000; -0.040000<=PF<=0.080000, 0.920000<=badC<=0.960000; -0.040000<=PF<=0.080000, 0.960000<=badC<=0.999990; -0.080000<=PF<=0.120000, 0.000010<=badC<=0.040000; -0.080000<=PF<=0.120000, 0.040000<=badC<=0.080000; -0.080000<=PF<=0.120000, 0.080000<=badC<=0.120000; -0.080000<=PF<=0.120000, 0.120000<=badC<=0.160000; -0.080000<=PF<=0.120000, 0.160000<=badC<=0.200000; -0.080000<=PF<=0.120000, 0.200000<=badC<=0.240000; -0.080000<=PF<=0.120000, 0.240000<=badC<=0.280000; -0.080000<=PF<=0.120000, 0.280000<=badC<=0.320000; -0.080000<=PF<=0.120000, 0.320000<=badC<=0.360000; -0.080000<=PF<=0.120000, 0.360000<=badC<=0.400000; -0.080000<=PF<=0.120000, 0.400000<=badC<=0.440000; -0.080000<=PF<=0.120000, 0.440000<=badC<=0.480000; -0.080000<=PF<=0.120000, 0.480000<=badC<=0.520000; -0.080000<=PF<=0.120000, 0.520000<=badC<=0.560000; -0.080000<=PF<=0.120000, 0.560000<=badC<=0.600000; -0.080000<=PF<=0.120000, 0.600000<=badC<=0.640000; -0.080000<=PF<=0.120000, 0.640000<=badC<=0.680000; -0.080000<=PF<=0.120000, 0.680000<=badC<=0.720000; -0.080000<=PF<=0.120000, 0.720000<=badC<=0.760000; -0.080000<=PF<=0.120000, 0.760000<=badC<=0.800000; -0.080000<=PF<=0.120000, 0.800000<=badC<=0.840000; -0.080000<=PF<=0.120000, 0.840000<=badC<=0.880000; -0.080000<=PF<=0.120000, 0.880000<=badC<=0.920000; -0.080000<=PF<=0.120000, 0.920000<=badC<=0.960000; -0.080000<=PF<=0.120000, 0.960000<=badC<=0.999990; -0.120000<=PF<=0.160000, 0.000010<=badC<=0.040000; -0.120000<=PF<=0.160000, 0.040000<=badC<=0.080000; -0.120000<=PF<=0.160000, 0.080000<=badC<=0.120000; -0.120000<=PF<=0.160000, 0.120000<=badC<=0.160000; -0.120000<=PF<=0.160000, 0.160000<=badC<=0.200000; -0.120000<=PF<=0.160000, 0.200000<=badC<=0.240000; -0.120000<=PF<=0.160000, 0.240000<=badC<=0.280000; -0.120000<=PF<=0.160000, 0.280000<=badC<=0.320000; -0.120000<=PF<=0.160000, 0.320000<=badC<=0.360000; -0.120000<=PF<=0.160000, 0.360000<=badC<=0.400000; -0.120000<=PF<=0.160000, 0.400000<=badC<=0.440000; -0.120000<=PF<=0.160000, 0.440000<=badC<=0.480000; -0.120000<=PF<=0.160000, 0.480000<=badC<=0.520000; -0.120000<=PF<=0.160000, 0.520000<=badC<=0.560000; -0.120000<=PF<=0.160000, 0.560000<=badC<=0.600000; -0.120000<=PF<=0.160000, 0.600000<=badC<=0.640000; -0.120000<=PF<=0.160000, 0.640000<=badC<=0.680000; -0.120000<=PF<=0.160000, 0.680000<=badC<=0.720000; -0.120000<=PF<=0.160000, 0.720000<=badC<=0.760000; -0.120000<=PF<=0.160000, 0.760000<=badC<=0.800000; -0.120000<=PF<=0.160000, 0.800000<=badC<=0.840000; -0.120000<=PF<=0.160000, 0.840000<=badC<=0.880000; -0.120000<=PF<=0.160000, 0.880000<=badC<=0.920000; -0.120000<=PF<=0.160000, 0.920000<=badC<=0.960000; -0.120000<=PF<=0.160000, 0.960000<=badC<=0.999990; -0.160000<=PF<=0.200000, 0.000010<=badC<=0.040000; -0.160000<=PF<=0.200000, 0.040000<=badC<=0.080000; -0.160000<=PF<=0.200000, 0.080000<=badC<=0.120000; -0.160000<=PF<=0.200000, 0.120000<=badC<=0.160000; -0.160000<=PF<=0.200000, 0.160000<=badC<=0.200000; -0.160000<=PF<=0.200000, 0.200000<=badC<=0.240000; -0.160000<=PF<=0.200000, 0.240000<=badC<=0.280000; -0.160000<=PF<=0.200000, 0.280000<=badC<=0.320000; -0.160000<=PF<=0.200000, 0.320000<=badC<=0.360000; -0.160000<=PF<=0.200000, 0.360000<=badC<=0.400000; -0.160000<=PF<=0.200000, 0.400000<=badC<=0.440000; -0.160000<=PF<=0.200000, 0.440000<=badC<=0.480000; -0.160000<=PF<=0.200000, 0.480000<=badC<=0.520000; -0.160000<=PF<=0.200000, 0.520000<=badC<=0.560000; -0.160000<=PF<=0.200000, 0.560000<=badC<=0.600000; -0.160000<=PF<=0.200000, 0.600000<=badC<=0.640000; -0.160000<=PF<=0.200000, 0.640000<=badC<=0.680000; -0.160000<=PF<=0.200000, 0.680000<=badC<=0.720000; -0.160000<=PF<=0.200000, 0.720000<=badC<=0.760000; -0.160000<=PF<=0.200000, 0.760000<=badC<=0.800000; -0.160000<=PF<=0.200000, 0.800000<=badC<=0.840000; -0.160000<=PF<=0.200000, 0.840000<=badC<=0.880000; -0.160000<=PF<=0.200000, 0.880000<=badC<=0.920000; -0.160000<=PF<=0.200000, 0.920000<=badC<=0.960000; -0.160000<=PF<=0.200000, 0.960000<=badC<=0.999990; -0.200000<=PF<=0.240000, 0.000010<=badC<=0.040000; -0.200000<=PF<=0.240000, 0.040000<=badC<=0.080000; -0.200000<=PF<=0.240000, 0.080000<=badC<=0.120000; -0.200000<=PF<=0.240000, 0.120000<=badC<=0.160000; -0.200000<=PF<=0.240000, 0.160000<=badC<=0.200000; -0.200000<=PF<=0.240000, 0.200000<=badC<=0.240000; -0.200000<=PF<=0.240000, 0.240000<=badC<=0.280000; -0.200000<=PF<=0.240000, 0.280000<=badC<=0.320000; -0.200000<=PF<=0.240000, 0.320000<=badC<=0.360000; -0.200000<=PF<=0.240000, 0.360000<=badC<=0.400000; -0.200000<=PF<=0.240000, 0.400000<=badC<=0.440000; -0.200000<=PF<=0.240000, 0.440000<=badC<=0.480000; -0.200000<=PF<=0.240000, 0.480000<=badC<=0.520000; -0.200000<=PF<=0.240000, 0.520000<=badC<=0.560000; -0.200000<=PF<=0.240000, 0.560000<=badC<=0.600000; -0.200000<=PF<=0.240000, 0.600000<=badC<=0.640000; -0.200000<=PF<=0.240000, 0.640000<=badC<=0.680000; -0.200000<=PF<=0.240000, 0.680000<=badC<=0.720000; -0.200000<=PF<=0.240000, 0.720000<=badC<=0.760000; -0.200000<=PF<=0.240000, 0.760000<=badC<=0.800000; -0.200000<=PF<=0.240000, 0.800000<=badC<=0.840000; -0.200000<=PF<=0.240000, 0.840000<=badC<=0.880000; -0.200000<=PF<=0.240000, 0.880000<=badC<=0.920000; -0.200000<=PF<=0.240000, 0.920000<=badC<=0.960000; -0.200000<=PF<=0.240000, 0.960000<=badC<=0.999990; -0.240000<=PF<=0.280000, 0.000010<=badC<=0.040000; -0.240000<=PF<=0.280000, 0.040000<=badC<=0.080000; -0.240000<=PF<=0.280000, 0.080000<=badC<=0.120000; -0.240000<=PF<=0.280000, 0.120000<=badC<=0.160000; -0.240000<=PF<=0.280000, 0.160000<=badC<=0.200000; -0.240000<=PF<=0.280000, 0.200000<=badC<=0.240000; -0.240000<=PF<=0.280000, 0.240000<=badC<=0.280000; -0.240000<=PF<=0.280000, 0.280000<=badC<=0.320000; -0.240000<=PF<=0.280000, 0.320000<=badC<=0.360000; -0.240000<=PF<=0.280000, 0.360000<=badC<=0.400000; -0.240000<=PF<=0.280000, 0.400000<=badC<=0.440000; -0.240000<=PF<=0.280000, 0.440000<=badC<=0.480000; -0.240000<=PF<=0.280000, 0.480000<=badC<=0.520000; -0.240000<=PF<=0.280000, 0.520000<=badC<=0.560000; -0.240000<=PF<=0.280000, 0.560000<=badC<=0.600000; -0.240000<=PF<=0.280000, 0.600000<=badC<=0.640000; -0.240000<=PF<=0.280000, 0.640000<=badC<=0.680000; -0.240000<=PF<=0.280000, 0.680000<=badC<=0.720000; -0.240000<=PF<=0.280000, 0.720000<=badC<=0.760000; -0.240000<=PF<=0.280000, 0.760000<=badC<=0.800000; -0.240000<=PF<=0.280000, 0.800000<=badC<=0.840000; -0.240000<=PF<=0.280000, 0.840000<=badC<=0.880000; -0.240000<=PF<=0.280000, 0.880000<=badC<=0.920000; -0.240000<=PF<=0.280000, 0.920000<=badC<=0.960000; -0.240000<=PF<=0.280000, 0.960000<=badC<=0.999990; -0.280000<=PF<=0.320000, 0.000010<=badC<=0.040000; -0.280000<=PF<=0.320000, 0.040000<=badC<=0.080000; -0.280000<=PF<=0.320000, 0.080000<=badC<=0.120000; -0.280000<=PF<=0.320000, 0.120000<=badC<=0.160000; -0.280000<=PF<=0.320000, 0.160000<=badC<=0.200000; -0.280000<=PF<=0.320000, 0.200000<=badC<=0.240000; -0.280000<=PF<=0.320000, 0.240000<=badC<=0.280000; -0.280000<=PF<=0.320000, 0.280000<=badC<=0.320000; -0.280000<=PF<=0.320000, 0.320000<=badC<=0.360000; -0.280000<=PF<=0.320000, 0.360000<=badC<=0.400000; -0.280000<=PF<=0.320000, 0.400000<=badC<=0.440000; -0.280000<=PF<=0.320000, 0.440000<=badC<=0.480000; -0.280000<=PF<=0.320000, 0.480000<=badC<=0.520000; -0.280000<=PF<=0.320000, 0.520000<=badC<=0.560000; -0.280000<=PF<=0.320000, 0.560000<=badC<=0.600000; -0.280000<=PF<=0.320000, 0.600000<=badC<=0.640000; -0.280000<=PF<=0.320000, 0.640000<=badC<=0.680000; -0.280000<=PF<=0.320000, 0.680000<=badC<=0.720000; -0.280000<=PF<=0.320000, 0.720000<=badC<=0.760000; -0.280000<=PF<=0.320000, 0.760000<=badC<=0.800000; -0.280000<=PF<=0.320000, 0.800000<=badC<=0.840000; -0.280000<=PF<=0.320000, 0.840000<=badC<=0.880000; -0.280000<=PF<=0.320000, 0.880000<=badC<=0.920000; -0.280000<=PF<=0.320000, 0.920000<=badC<=0.960000; -0.280000<=PF<=0.320000, 0.960000<=badC<=0.999990; -0.320000<=PF<=0.360000, 0.000010<=badC<=0.040000; -0.320000<=PF<=0.360000, 0.040000<=badC<=0.080000; -0.320000<=PF<=0.360000, 0.080000<=badC<=0.120000; -0.320000<=PF<=0.360000, 0.120000<=badC<=0.160000; -0.320000<=PF<=0.360000, 0.160000<=badC<=0.200000; -0.320000<=PF<=0.360000, 0.200000<=badC<=0.240000; -0.320000<=PF<=0.360000, 0.240000<=badC<=0.280000; -0.320000<=PF<=0.360000, 0.280000<=badC<=0.320000; -0.320000<=PF<=0.360000, 0.320000<=badC<=0.360000; -0.320000<=PF<=0.360000, 0.360000<=badC<=0.400000; -0.320000<=PF<=0.360000, 0.400000<=badC<=0.440000; -0.320000<=PF<=0.360000, 0.440000<=badC<=0.480000; -0.320000<=PF<=0.360000, 0.480000<=badC<=0.520000; -0.320000<=PF<=0.360000, 0.520000<=badC<=0.560000; -0.320000<=PF<=0.360000, 0.560000<=badC<=0.600000; -0.320000<=PF<=0.360000, 0.600000<=badC<=0.640000; -0.320000<=PF<=0.360000, 0.640000<=badC<=0.680000; -0.320000<=PF<=0.360000, 0.680000<=badC<=0.720000; -0.320000<=PF<=0.360000, 0.720000<=badC<=0.760000; -0.320000<=PF<=0.360000, 0.760000<=badC<=0.800000; -0.320000<=PF<=0.360000, 0.800000<=badC<=0.840000; -0.320000<=PF<=0.360000, 0.840000<=badC<=0.880000; -0.320000<=PF<=0.360000, 0.880000<=badC<=0.920000; -0.320000<=PF<=0.360000, 0.920000<=badC<=0.960000; -0.320000<=PF<=0.360000, 0.960000<=badC<=0.999990; -0.360000<=PF<=0.400000, 0.000010<=badC<=0.040000; -0.360000<=PF<=0.400000, 0.040000<=badC<=0.080000; -0.360000<=PF<=0.400000, 0.080000<=badC<=0.120000; -0.360000<=PF<=0.400000, 0.120000<=badC<=0.160000; -0.360000<=PF<=0.400000, 0.160000<=badC<=0.200000; -0.360000<=PF<=0.400000, 0.200000<=badC<=0.240000; -0.360000<=PF<=0.400000, 0.240000<=badC<=0.280000; -0.360000<=PF<=0.400000, 0.280000<=badC<=0.320000; -0.360000<=PF<=0.400000, 0.320000<=badC<=0.360000; -0.360000<=PF<=0.400000, 0.360000<=badC<=0.400000; -0.360000<=PF<=0.400000, 0.400000<=badC<=0.440000; -0.360000<=PF<=0.400000, 0.440000<=badC<=0.480000; -0.360000<=PF<=0.400000, 0.480000<=badC<=0.520000; -0.360000<=PF<=0.400000, 0.520000<=badC<=0.560000; -0.360000<=PF<=0.400000, 0.560000<=badC<=0.600000; -0.360000<=PF<=0.400000, 0.600000<=badC<=0.640000; -0.360000<=PF<=0.400000, 0.640000<=badC<=0.680000; -0.360000<=PF<=0.400000, 0.680000<=badC<=0.720000; -0.360000<=PF<=0.400000, 0.720000<=badC<=0.760000; -0.360000<=PF<=0.400000, 0.760000<=badC<=0.800000; -0.360000<=PF<=0.400000, 0.800000<=badC<=0.840000; -0.360000<=PF<=0.400000, 0.840000<=badC<=0.880000; -0.360000<=PF<=0.400000, 0.880000<=badC<=0.920000; -0.360000<=PF<=0.400000, 0.920000<=badC<=0.960000; -0.360000<=PF<=0.400000, 0.960000<=badC<=0.999990; -0.400000<=PF<=0.440000, 0.000010<=badC<=0.040000; -0.400000<=PF<=0.440000, 0.040000<=badC<=0.080000; -0.400000<=PF<=0.440000, 0.080000<=badC<=0.120000; -0.400000<=PF<=0.440000, 0.120000<=badC<=0.160000; -0.400000<=PF<=0.440000, 0.160000<=badC<=0.200000; -0.400000<=PF<=0.440000, 0.200000<=badC<=0.240000; -0.400000<=PF<=0.440000, 0.240000<=badC<=0.280000; -0.400000<=PF<=0.440000, 0.280000<=badC<=0.320000; -0.400000<=PF<=0.440000, 0.320000<=badC<=0.360000; -0.400000<=PF<=0.440000, 0.360000<=badC<=0.400000; -0.400000<=PF<=0.440000, 0.400000<=badC<=0.440000; -0.400000<=PF<=0.440000, 0.440000<=badC<=0.480000; -0.400000<=PF<=0.440000, 0.480000<=badC<=0.520000; -0.400000<=PF<=0.440000, 0.520000<=badC<=0.560000; -0.400000<=PF<=0.440000, 0.560000<=badC<=0.600000; -0.400000<=PF<=0.440000, 0.600000<=badC<=0.640000; -0.400000<=PF<=0.440000, 0.640000<=badC<=0.680000; -0.400000<=PF<=0.440000, 0.680000<=badC<=0.720000; -0.400000<=PF<=0.440000, 0.720000<=badC<=0.760000; -0.400000<=PF<=0.440000, 0.760000<=badC<=0.800000; -0.400000<=PF<=0.440000, 0.800000<=badC<=0.840000; -0.400000<=PF<=0.440000, 0.840000<=badC<=0.880000; -0.400000<=PF<=0.440000, 0.880000<=badC<=0.920000; -0.400000<=PF<=0.440000, 0.920000<=badC<=0.960000; -0.400000<=PF<=0.440000, 0.960000<=badC<=0.999990; -0.440000<=PF<=0.480000, 0.000010<=badC<=0.040000; -0.440000<=PF<=0.480000, 0.040000<=badC<=0.080000; -0.440000<=PF<=0.480000, 0.080000<=badC<=0.120000; -0.440000<=PF<=0.480000, 0.120000<=badC<=0.160000; -0.440000<=PF<=0.480000, 0.160000<=badC<=0.200000; -0.440000<=PF<=0.480000, 0.200000<=badC<=0.240000; -0.440000<=PF<=0.480000, 0.240000<=badC<=0.280000; -0.440000<=PF<=0.480000, 0.280000<=badC<=0.320000; -0.440000<=PF<=0.480000, 0.320000<=badC<=0.360000; -0.440000<=PF<=0.480000, 0.360000<=badC<=0.400000; -0.440000<=PF<=0.480000, 0.400000<=badC<=0.440000; -0.440000<=PF<=0.480000, 0.440000<=badC<=0.480000; -0.440000<=PF<=0.480000, 0.480000<=badC<=0.520000; -0.440000<=PF<=0.480000, 0.520000<=badC<=0.560000; -0.440000<=PF<=0.480000, 0.560000<=badC<=0.600000; -0.440000<=PF<=0.480000, 0.600000<=badC<=0.640000; -0.440000<=PF<=0.480000, 0.640000<=badC<=0.680000; -0.440000<=PF<=0.480000, 0.680000<=badC<=0.720000; -0.440000<=PF<=0.480000, 0.720000<=badC<=0.760000; -0.440000<=PF<=0.480000, 0.760000<=badC<=0.800000; -0.440000<=PF<=0.480000, 0.800000<=badC<=0.840000; -0.440000<=PF<=0.480000, 0.840000<=badC<=0.880000; -0.440000<=PF<=0.480000, 0.880000<=badC<=0.920000; -0.440000<=PF<=0.480000, 0.920000<=badC<=0.960000; -0.440000<=PF<=0.480000, 0.960000<=badC<=0.999990; -0.480000<=PF<=0.520000, 0.000010<=badC<=0.040000; -0.480000<=PF<=0.520000, 0.040000<=badC<=0.080000; -0.480000<=PF<=0.520000, 0.080000<=badC<=0.120000; -0.480000<=PF<=0.520000, 0.120000<=badC<=0.160000; -0.480000<=PF<=0.520000, 0.160000<=badC<=0.200000; -0.480000<=PF<=0.520000, 0.200000<=badC<=0.240000; -0.480000<=PF<=0.520000, 0.240000<=badC<=0.280000; -0.480000<=PF<=0.520000, 0.280000<=badC<=0.320000; -0.480000<=PF<=0.520000, 0.320000<=badC<=0.360000; -0.480000<=PF<=0.520000, 0.360000<=badC<=0.400000; -0.480000<=PF<=0.520000, 0.400000<=badC<=0.440000; -0.480000<=PF<=0.520000, 0.440000<=badC<=0.480000; -0.480000<=PF<=0.520000, 0.480000<=badC<=0.520000; -0.480000<=PF<=0.520000, 0.520000<=badC<=0.560000; -0.480000<=PF<=0.520000, 0.560000<=badC<=0.600000; -0.480000<=PF<=0.520000, 0.600000<=badC<=0.640000; -0.480000<=PF<=0.520000, 0.640000<=badC<=0.680000; -0.480000<=PF<=0.520000, 0.680000<=badC<=0.720000; -0.480000<=PF<=0.520000, 0.720000<=badC<=0.760000; -0.480000<=PF<=0.520000, 0.760000<=badC<=0.800000; -0.480000<=PF<=0.520000, 0.800000<=badC<=0.840000; -0.480000<=PF<=0.520000, 0.840000<=badC<=0.880000; -0.480000<=PF<=0.520000, 0.880000<=badC<=0.920000; -0.480000<=PF<=0.520000, 0.920000<=badC<=0.960000; -0.480000<=PF<=0.520000, 0.960000<=badC<=0.999990; -0.520000<=PF<=0.560000, 0.000010<=badC<=0.040000; -0.520000<=PF<=0.560000, 0.040000<=badC<=0.080000; -0.520000<=PF<=0.560000, 0.080000<=badC<=0.120000; -0.520000<=PF<=0.560000, 0.120000<=badC<=0.160000; -0.520000<=PF<=0.560000, 0.160000<=badC<=0.200000; -0.520000<=PF<=0.560000, 0.200000<=badC<=0.240000; -0.520000<=PF<=0.560000, 0.240000<=badC<=0.280000; -0.520000<=PF<=0.560000, 0.280000<=badC<=0.320000; -0.520000<=PF<=0.560000, 0.320000<=badC<=0.360000; -0.520000<=PF<=0.560000, 0.360000<=badC<=0.400000; -0.520000<=PF<=0.560000, 0.400000<=badC<=0.440000; -0.520000<=PF<=0.560000, 0.440000<=badC<=0.480000; -0.520000<=PF<=0.560000, 0.480000<=badC<=0.520000; -0.520000<=PF<=0.560000, 0.520000<=badC<=0.560000; -0.520000<=PF<=0.560000, 0.560000<=badC<=0.600000; -0.520000<=PF<=0.560000, 0.600000<=badC<=0.640000; -0.520000<=PF<=0.560000, 0.640000<=badC<=0.680000; -0.520000<=PF<=0.560000, 0.680000<=badC<=0.720000; -0.520000<=PF<=0.560000, 0.720000<=badC<=0.760000; -0.520000<=PF<=0.560000, 0.760000<=badC<=0.800000; -0.520000<=PF<=0.560000, 0.800000<=badC<=0.840000; -0.520000<=PF<=0.560000, 0.840000<=badC<=0.880000; -0.520000<=PF<=0.560000, 0.880000<=badC<=0.920000; -0.520000<=PF<=0.560000, 0.920000<=badC<=0.960000; -0.520000<=PF<=0.560000, 0.960000<=badC<=0.999990; -0.560000<=PF<=0.600000, 0.000010<=badC<=0.040000; -0.560000<=PF<=0.600000, 0.040000<=badC<=0.080000; -0.560000<=PF<=0.600000, 0.080000<=badC<=0.120000; -0.560000<=PF<=0.600000, 0.120000<=badC<=0.160000; -0.560000<=PF<=0.600000, 0.160000<=badC<=0.200000; -0.560000<=PF<=0.600000, 0.200000<=badC<=0.240000; -0.560000<=PF<=0.600000, 0.240000<=badC<=0.280000; -0.560000<=PF<=0.600000, 0.280000<=badC<=0.320000; -0.560000<=PF<=0.600000, 0.320000<=badC<=0.360000; -0.560000<=PF<=0.600000, 0.360000<=badC<=0.400000; -0.560000<=PF<=0.600000, 0.400000<=badC<=0.440000; -0.560000<=PF<=0.600000, 0.440000<=badC<=0.480000; -0.560000<=PF<=0.600000, 0.480000<=badC<=0.520000; -0.560000<=PF<=0.600000, 0.520000<=badC<=0.560000; -0.560000<=PF<=0.600000, 0.560000<=badC<=0.600000; -0.560000<=PF<=0.600000, 0.600000<=badC<=0.640000; -0.560000<=PF<=0.600000, 0.640000<=badC<=0.680000; -0.560000<=PF<=0.600000, 0.680000<=badC<=0.720000; -0.560000<=PF<=0.600000, 0.720000<=badC<=0.760000; -0.560000<=PF<=0.600000, 0.760000<=badC<=0.800000; -0.560000<=PF<=0.600000, 0.800000<=badC<=0.840000; -0.560000<=PF<=0.600000, 0.840000<=badC<=0.880000; -0.560000<=PF<=0.600000, 0.880000<=badC<=0.920000; -0.560000<=PF<=0.600000, 0.920000<=badC<=0.960000; -0.560000<=PF<=0.600000, 0.960000<=badC<=0.999990; -0.600000<=PF<=0.640000, 0.000010<=badC<=0.040000; -0.600000<=PF<=0.640000, 0.040000<=badC<=0.080000; -0.600000<=PF<=0.640000, 0.080000<=badC<=0.120000; -0.600000<=PF<=0.640000, 0.120000<=badC<=0.160000; -0.600000<=PF<=0.640000, 0.160000<=badC<=0.200000; -0.600000<=PF<=0.640000, 0.200000<=badC<=0.240000; -0.600000<=PF<=0.640000, 0.240000<=badC<=0.280000; -0.600000<=PF<=0.640000, 0.280000<=badC<=0.320000; -0.600000<=PF<=0.640000, 0.320000<=badC<=0.360000; -0.600000<=PF<=0.640000, 0.360000<=badC<=0.400000; -0.600000<=PF<=0.640000, 0.400000<=badC<=0.440000; -0.600000<=PF<=0.640000, 0.440000<=badC<=0.480000; -0.600000<=PF<=0.640000, 0.480000<=badC<=0.520000; -0.600000<=PF<=0.640000, 0.520000<=badC<=0.560000; -0.600000<=PF<=0.640000, 0.560000<=badC<=0.600000; -0.600000<=PF<=0.640000, 0.600000<=badC<=0.640000; -0.600000<=PF<=0.640000, 0.640000<=badC<=0.680000; -0.600000<=PF<=0.640000, 0.680000<=badC<=0.720000; -0.600000<=PF<=0.640000, 0.720000<=badC<=0.760000; -0.600000<=PF<=0.640000, 0.760000<=badC<=0.800000; -0.600000<=PF<=0.640000, 0.800000<=badC<=0.840000; -0.600000<=PF<=0.640000, 0.840000<=badC<=0.880000; -0.600000<=PF<=0.640000, 0.880000<=badC<=0.920000; -0.600000<=PF<=0.640000, 0.920000<=badC<=0.960000; -0.600000<=PF<=0.640000, 0.960000<=badC<=0.999990; -0.640000<=PF<=0.680000, 0.000010<=badC<=0.040000; -0.640000<=PF<=0.680000, 0.040000<=badC<=0.080000; -0.640000<=PF<=0.680000, 0.080000<=badC<=0.120000; -0.640000<=PF<=0.680000, 0.120000<=badC<=0.160000; -0.640000<=PF<=0.680000, 0.160000<=badC<=0.200000; -0.640000<=PF<=0.680000, 0.200000<=badC<=0.240000; -0.640000<=PF<=0.680000, 0.240000<=badC<=0.280000; -0.640000<=PF<=0.680000, 0.280000<=badC<=0.320000; -0.640000<=PF<=0.680000, 0.320000<=badC<=0.360000; -0.640000<=PF<=0.680000, 0.360000<=badC<=0.400000; -0.640000<=PF<=0.680000, 0.400000<=badC<=0.440000; -0.640000<=PF<=0.680000, 0.440000<=badC<=0.480000; -0.640000<=PF<=0.680000, 0.480000<=badC<=0.520000; -0.640000<=PF<=0.680000, 0.520000<=badC<=0.560000; -0.640000<=PF<=0.680000, 0.560000<=badC<=0.600000; -0.640000<=PF<=0.680000, 0.600000<=badC<=0.640000; -0.640000<=PF<=0.680000, 0.640000<=badC<=0.680000; -0.640000<=PF<=0.680000, 0.680000<=badC<=0.720000; -0.640000<=PF<=0.680000, 0.720000<=badC<=0.760000; -0.640000<=PF<=0.680000, 0.760000<=badC<=0.800000; -0.640000<=PF<=0.680000, 0.800000<=badC<=0.840000; -0.640000<=PF<=0.680000, 0.840000<=badC<=0.880000; -0.640000<=PF<=0.680000, 0.880000<=badC<=0.920000; -0.640000<=PF<=0.680000, 0.920000<=badC<=0.960000; -0.640000<=PF<=0.680000, 0.960000<=badC<=0.999990; -0.680000<=PF<=0.720000, 0.000010<=badC<=0.040000; -0.680000<=PF<=0.720000, 0.040000<=badC<=0.080000; -0.680000<=PF<=0.720000, 0.080000<=badC<=0.120000; -0.680000<=PF<=0.720000, 0.120000<=badC<=0.160000; -0.680000<=PF<=0.720000, 0.160000<=badC<=0.200000; -0.680000<=PF<=0.720000, 0.200000<=badC<=0.240000; -0.680000<=PF<=0.720000, 0.240000<=badC<=0.280000; -0.680000<=PF<=0.720000, 0.280000<=badC<=0.320000; -0.680000<=PF<=0.720000, 0.320000<=badC<=0.360000; -0.680000<=PF<=0.720000, 0.360000<=badC<=0.400000; -0.680000<=PF<=0.720000, 0.400000<=badC<=0.440000; -0.680000<=PF<=0.720000, 0.440000<=badC<=0.480000; -0.680000<=PF<=0.720000, 0.480000<=badC<=0.520000; -0.680000<=PF<=0.720000, 0.520000<=badC<=0.560000; -0.680000<=PF<=0.720000, 0.560000<=badC<=0.600000; -0.680000<=PF<=0.720000, 0.600000<=badC<=0.640000; -0.680000<=PF<=0.720000, 0.640000<=badC<=0.680000; -0.680000<=PF<=0.720000, 0.680000<=badC<=0.720000; -0.680000<=PF<=0.720000, 0.720000<=badC<=0.760000; -0.680000<=PF<=0.720000, 0.760000<=badC<=0.800000; -0.680000<=PF<=0.720000, 0.800000<=badC<=0.840000; -0.680000<=PF<=0.720000, 0.840000<=badC<=0.880000; -0.680000<=PF<=0.720000, 0.880000<=badC<=0.920000; -0.680000<=PF<=0.720000, 0.920000<=badC<=0.960000; -0.680000<=PF<=0.720000, 0.960000<=badC<=0.999990; -0.720000<=PF<=0.760000, 0.000010<=badC<=0.040000; -0.720000<=PF<=0.760000, 0.040000<=badC<=0.080000; -0.720000<=PF<=0.760000, 0.080000<=badC<=0.120000; -0.720000<=PF<=0.760000, 0.120000<=badC<=0.160000; -0.720000<=PF<=0.760000, 0.160000<=badC<=0.200000; -0.720000<=PF<=0.760000, 0.200000<=badC<=0.240000; -0.720000<=PF<=0.760000, 0.240000<=badC<=0.280000; -0.720000<=PF<=0.760000, 0.280000<=badC<=0.320000; -0.720000<=PF<=0.760000, 0.320000<=badC<=0.360000; -0.720000<=PF<=0.760000, 0.360000<=badC<=0.400000; -0.720000<=PF<=0.760000, 0.400000<=badC<=0.440000; -0.720000<=PF<=0.760000, 0.440000<=badC<=0.480000; -0.720000<=PF<=0.760000, 0.480000<=badC<=0.520000; -0.720000<=PF<=0.760000, 0.520000<=badC<=0.560000; -0.720000<=PF<=0.760000, 0.560000<=badC<=0.600000; -0.720000<=PF<=0.760000, 0.600000<=badC<=0.640000; -0.720000<=PF<=0.760000, 0.640000<=badC<=0.680000; -0.720000<=PF<=0.760000, 0.680000<=badC<=0.720000; -0.720000<=PF<=0.760000, 0.720000<=badC<=0.760000; -0.720000<=PF<=0.760000, 0.760000<=badC<=0.800000; -0.720000<=PF<=0.760000, 0.800000<=badC<=0.840000; -0.720000<=PF<=0.760000, 0.840000<=badC<=0.880000; -0.720000<=PF<=0.760000, 0.880000<=badC<=0.920000; -0.720000<=PF<=0.760000, 0.920000<=badC<=0.960000; -0.720000<=PF<=0.760000, 0.960000<=badC<=0.999990; -0.760000<=PF<=0.800000, 0.000010<=badC<=0.040000; -0.760000<=PF<=0.800000, 0.040000<=badC<=0.080000; -0.760000<=PF<=0.800000, 0.080000<=badC<=0.120000; -0.760000<=PF<=0.800000, 0.120000<=badC<=0.160000; -0.760000<=PF<=0.800000, 0.160000<=badC<=0.200000; -0.760000<=PF<=0.800000, 0.200000<=badC<=0.240000; -0.760000<=PF<=0.800000, 0.240000<=badC<=0.280000; -0.760000<=PF<=0.800000, 0.280000<=badC<=0.320000; -0.760000<=PF<=0.800000, 0.320000<=badC<=0.360000; -0.760000<=PF<=0.800000, 0.360000<=badC<=0.400000; -0.760000<=PF<=0.800000, 0.400000<=badC<=0.440000; -0.760000<=PF<=0.800000, 0.440000<=badC<=0.480000; -0.760000<=PF<=0.800000, 0.480000<=badC<=0.520000; -0.760000<=PF<=0.800000, 0.520000<=badC<=0.560000; -0.760000<=PF<=0.800000, 0.560000<=badC<=0.600000; -0.760000<=PF<=0.800000, 0.600000<=badC<=0.640000; -0.760000<=PF<=0.800000, 0.640000<=badC<=0.680000; -0.760000<=PF<=0.800000, 0.680000<=badC<=0.720000; -0.760000<=PF<=0.800000, 0.720000<=badC<=0.760000; -0.760000<=PF<=0.800000, 0.760000<=badC<=0.800000; -0.760000<=PF<=0.800000, 0.800000<=badC<=0.840000; -0.760000<=PF<=0.800000, 0.840000<=badC<=0.880000; -0.760000<=PF<=0.800000, 0.880000<=badC<=0.920000; -0.760000<=PF<=0.800000, 0.920000<=badC<=0.960000; -0.760000<=PF<=0.800000, 0.960000<=badC<=0.999990; -0.800000<=PF<=0.840000, 0.000010<=badC<=0.040000; -0.800000<=PF<=0.840000, 0.040000<=badC<=0.080000; -0.800000<=PF<=0.840000, 0.080000<=badC<=0.120000; -0.800000<=PF<=0.840000, 0.120000<=badC<=0.160000; -0.800000<=PF<=0.840000, 0.160000<=badC<=0.200000; -0.800000<=PF<=0.840000, 0.200000<=badC<=0.240000; -0.800000<=PF<=0.840000, 0.240000<=badC<=0.280000; -0.800000<=PF<=0.840000, 0.280000<=badC<=0.320000; -0.800000<=PF<=0.840000, 0.320000<=badC<=0.360000; -0.800000<=PF<=0.840000, 0.360000<=badC<=0.400000; -0.800000<=PF<=0.840000, 0.400000<=badC<=0.440000; -0.800000<=PF<=0.840000, 0.440000<=badC<=0.480000; -0.800000<=PF<=0.840000, 0.480000<=badC<=0.520000; -0.800000<=PF<=0.840000, 0.520000<=badC<=0.560000; -0.800000<=PF<=0.840000, 0.560000<=badC<=0.600000; -0.800000<=PF<=0.840000, 0.600000<=badC<=0.640000; -0.800000<=PF<=0.840000, 0.640000<=badC<=0.680000; -0.800000<=PF<=0.840000, 0.680000<=badC<=0.720000; -0.800000<=PF<=0.840000, 0.720000<=badC<=0.760000; -0.800000<=PF<=0.840000, 0.760000<=badC<=0.800000; -0.800000<=PF<=0.840000, 0.800000<=badC<=0.840000; -0.800000<=PF<=0.840000, 0.840000<=badC<=0.880000; -0.800000<=PF<=0.840000, 0.880000<=badC<=0.920000; -0.800000<=PF<=0.840000, 0.920000<=badC<=0.960000; -0.800000<=PF<=0.840000, 0.960000<=badC<=0.999990; -0.840000<=PF<=0.880000, 0.000010<=badC<=0.040000; -0.840000<=PF<=0.880000, 0.040000<=badC<=0.080000; -0.840000<=PF<=0.880000, 0.080000<=badC<=0.120000; -0.840000<=PF<=0.880000, 0.120000<=badC<=0.160000; -0.840000<=PF<=0.880000, 0.160000<=badC<=0.200000; -0.840000<=PF<=0.880000, 0.200000<=badC<=0.240000; -0.840000<=PF<=0.880000, 0.240000<=badC<=0.280000; -0.840000<=PF<=0.880000, 0.280000<=badC<=0.320000; -0.840000<=PF<=0.880000, 0.320000<=badC<=0.360000; -0.840000<=PF<=0.880000, 0.360000<=badC<=0.400000; -0.840000<=PF<=0.880000, 0.400000<=badC<=0.440000; -0.840000<=PF<=0.880000, 0.440000<=badC<=0.480000; -0.840000<=PF<=0.880000, 0.480000<=badC<=0.520000; -0.840000<=PF<=0.880000, 0.520000<=badC<=0.560000; -0.840000<=PF<=0.880000, 0.560000<=badC<=0.600000; -0.840000<=PF<=0.880000, 0.600000<=badC<=0.640000; -0.840000<=PF<=0.880000, 0.640000<=badC<=0.680000; -0.840000<=PF<=0.880000, 0.680000<=badC<=0.720000; -0.840000<=PF<=0.880000, 0.720000<=badC<=0.760000; -0.840000<=PF<=0.880000, 0.760000<=badC<=0.800000; -0.840000<=PF<=0.880000, 0.800000<=badC<=0.840000; -0.840000<=PF<=0.880000, 0.840000<=badC<=0.880000; -0.840000<=PF<=0.880000, 0.880000<=badC<=0.920000; -0.840000<=PF<=0.880000, 0.920000<=badC<=0.960000; -0.840000<=PF<=0.880000, 0.960000<=badC<=0.999990; -0.880000<=PF<=0.920000, 0.000010<=badC<=0.040000; -0.880000<=PF<=0.920000, 0.040000<=badC<=0.080000; -0.880000<=PF<=0.920000, 0.080000<=badC<=0.120000; -0.880000<=PF<=0.920000, 0.120000<=badC<=0.160000; -0.880000<=PF<=0.920000, 0.160000<=badC<=0.200000; -0.880000<=PF<=0.920000, 0.200000<=badC<=0.240000; -0.880000<=PF<=0.920000, 0.240000<=badC<=0.280000; -0.880000<=PF<=0.920000, 0.280000<=badC<=0.320000; -0.880000<=PF<=0.920000, 0.320000<=badC<=0.360000; -0.880000<=PF<=0.920000, 0.360000<=badC<=0.400000; -0.880000<=PF<=0.920000, 0.400000<=badC<=0.440000; -0.880000<=PF<=0.920000, 0.440000<=badC<=0.480000; -0.880000<=PF<=0.920000, 0.480000<=badC<=0.520000; -0.880000<=PF<=0.920000, 0.520000<=badC<=0.560000; -0.880000<=PF<=0.920000, 0.560000<=badC<=0.600000; -0.880000<=PF<=0.920000, 0.600000<=badC<=0.640000; -0.880000<=PF<=0.920000, 0.640000<=badC<=0.680000; -0.880000<=PF<=0.920000, 0.680000<=badC<=0.720000; -0.880000<=PF<=0.920000, 0.720000<=badC<=0.760000; -0.880000<=PF<=0.920000, 0.760000<=badC<=0.800000; -0.880000<=PF<=0.920000, 0.800000<=badC<=0.840000; -0.880000<=PF<=0.920000, 0.840000<=badC<=0.880000; -0.880000<=PF<=0.920000, 0.880000<=badC<=0.920000; -0.880000<=PF<=0.920000, 0.920000<=badC<=0.960000; -0.880000<=PF<=0.920000, 0.960000<=badC<=0.999990; -0.920000<=PF<=0.960000, 0.000010<=badC<=0.040000; -0.920000<=PF<=0.960000, 0.040000<=badC<=0.080000; -0.920000<=PF<=0.960000, 0.080000<=badC<=0.120000; -0.920000<=PF<=0.960000, 0.120000<=badC<=0.160000; -0.920000<=PF<=0.960000, 0.160000<=badC<=0.200000; -0.920000<=PF<=0.960000, 0.200000<=badC<=0.240000; -0.920000<=PF<=0.960000, 0.240000<=badC<=0.280000; -0.920000<=PF<=0.960000, 0.280000<=badC<=0.320000; -0.920000<=PF<=0.960000, 0.320000<=badC<=0.360000; -0.920000<=PF<=0.960000, 0.360000<=badC<=0.400000; -0.920000<=PF<=0.960000, 0.400000<=badC<=0.440000; -0.920000<=PF<=0.960000, 0.440000<=badC<=0.480000; -0.920000<=PF<=0.960000, 0.480000<=badC<=0.520000; -0.920000<=PF<=0.960000, 0.520000<=badC<=0.560000; -0.920000<=PF<=0.960000, 0.560000<=badC<=0.600000; -0.920000<=PF<=0.960000, 0.600000<=badC<=0.640000; -0.920000<=PF<=0.960000, 0.640000<=badC<=0.680000; -0.920000<=PF<=0.960000, 0.680000<=badC<=0.720000; -0.920000<=PF<=0.960000, 0.720000<=badC<=0.760000; -0.920000<=PF<=0.960000, 0.760000<=badC<=0.800000; -0.920000<=PF<=0.960000, 0.800000<=badC<=0.840000; -0.920000<=PF<=0.960000, 0.840000<=badC<=0.880000; -0.920000<=PF<=0.960000, 0.880000<=badC<=0.920000; -0.920000<=PF<=0.960000, 0.920000<=badC<=0.960000; -0.920000<=PF<=0.960000, 0.960000<=badC<=0.999990; -0.960000<=PF<=0.999990, 0.000010<=badC<=0.040000; -0.960000<=PF<=0.999990, 0.040000<=badC<=0.080000; -0.960000<=PF<=0.999990, 0.080000<=badC<=0.120000; -0.960000<=PF<=0.999990, 0.120000<=badC<=0.160000; -0.960000<=PF<=0.999990, 0.160000<=badC<=0.200000; -0.960000<=PF<=0.999990, 0.200000<=badC<=0.240000; -0.960000<=PF<=0.999990, 0.240000<=badC<=0.280000; -0.960000<=PF<=0.999990, 0.280000<=badC<=0.320000; -0.960000<=PF<=0.999990, 0.320000<=badC<=0.360000; -0.960000<=PF<=0.999990, 0.360000<=badC<=0.400000; -0.960000<=PF<=0.999990, 0.400000<=badC<=0.440000; -0.960000<=PF<=0.999990, 0.440000<=badC<=0.480000; -0.960000<=PF<=0.999990, 0.480000<=badC<=0.520000; -0.960000<=PF<=0.999990, 0.520000<=badC<=0.560000; -0.960000<=PF<=0.999990, 0.560000<=badC<=0.600000; -0.960000<=PF<=0.999990, 0.600000<=badC<=0.640000; -0.960000<=PF<=0.999990, 0.640000<=badC<=0.680000; -0.960000<=PF<=0.999990, 0.680000<=badC<=0.720000; -0.960000<=PF<=0.999990, 0.720000<=badC<=0.760000; -0.960000<=PF<=0.999990, 0.760000<=badC<=0.800000; -0.960000<=PF<=0.999990, 0.800000<=badC<=0.840000; -0.960000<=PF<=0.999990, 0.840000<=badC<=0.880000; -0.960000<=PF<=0.999990, 0.880000<=badC<=0.920000; -0.960000<=PF<=0.999990, 0.920000<=badC<=0.960000; -0.960000<=PF<=0.999990, 0.960000<=badC<=0.999990; diff --git a/examples/pdtmc/crowds/crowds_space.txt b/examples/pdtmc/crowds/crowds_space.txt deleted file mode 100644 index f36cebf3e..000000000 --- a/examples/pdtmc/crowds/crowds_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=PF<=0.999990, 0.000010<=badC<=0.999990; - diff --git a/examples/pdtmc/crowds/models b/examples/pdtmc/crowds/models deleted file mode 100644 index fdfc13cee..000000000 --- a/examples/pdtmc/crowds/models +++ /dev/null @@ -1,2 +0,0 @@ -crowds.pm -const CrowdSize=10,TotalRuns=5 -crowds.pm -const CrowdSize=20,TotalRuns=10 diff --git a/examples/pdtmc/nand/models b/examples/pdtmc/nand/models deleted file mode 100644 index a41532a76..000000000 --- a/examples/pdtmc/nand/models +++ /dev/null @@ -1,2 +0,0 @@ -nand.pm -const N=10,K=5 -nand.pm -const N=25,K=5 diff --git a/examples/pdtmc/nand/nand.pm b/examples/pdtmc/nand/nand.pm deleted file mode 100644 index 10c867fca..000000000 --- a/examples/pdtmc/nand/nand.pm +++ /dev/null @@ -1,75 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N; // number of inputs in each bundle -const int K; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr; //(0.02) probability nand works correctly -const double prob1; //(0.9) probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -label "target" = s=4 & z/N<0.1; - -// rewards: final value of gate -rewards - [] s=0 & (c=N) & (u=M) : z/N; -endrewards - diff --git a/examples/pdtmc/nand/nand.prctl b/examples/pdtmc/nand/nand.prctl deleted file mode 100644 index effb39d9e..000000000 --- a/examples/pdtmc/nand/nand.prctl +++ /dev/null @@ -1 +0,0 @@ -P>0.05 [F "target" ] diff --git a/examples/pdtmc/nand/nand10_1.pm b/examples/pdtmc/nand/nand10_1.pm deleted file mode 100644 index f56664199..000000000 --- a/examples/pdtmc/nand/nand10_1.pm +++ /dev/null @@ -1,75 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N = 10; // number of inputs in each bundle -const int K = 1; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr; //(0.02) probability nand works correctly -const double prob1; //(0.9) probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -label "target" = s=4 & z/N<0.1; - -// rewards: final value of gate -rewards - [] s=0 & (c=N) & (u=M) : z/N; -endrewards - diff --git a/examples/pdtmc/nand/nand10_2.pm b/examples/pdtmc/nand/nand10_2.pm deleted file mode 100644 index 0708144e7..000000000 --- a/examples/pdtmc/nand/nand10_2.pm +++ /dev/null @@ -1,75 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N = 10; // number of inputs in each bundle -const int K = 2; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr; //(0.02) probability nand works correctly -const double prob1; //(0.9) probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -label "target" = s=4 & z/N<0.1; - -// rewards: final value of gate -rewards - [] s=0 & (c=N) & (u=M) : z/N; -endrewards - diff --git a/examples/pdtmc/nand/nand10_3.pm b/examples/pdtmc/nand/nand10_3.pm deleted file mode 100644 index 566251af3..000000000 --- a/examples/pdtmc/nand/nand10_3.pm +++ /dev/null @@ -1,75 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N = 10; // number of inputs in each bundle -const int K = 3; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr; //(0.02) probability nand works correctly -const double prob1; //(0.9) probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -label "target" = s=4 & z/N<0.1; - -// rewards: final value of gate -rewards - [] s=0 & (c=N) & (u=M) : z/N; -endrewards - diff --git a/examples/pdtmc/nand/nand10_4.pm b/examples/pdtmc/nand/nand10_4.pm deleted file mode 100644 index 7de796d1d..000000000 --- a/examples/pdtmc/nand/nand10_4.pm +++ /dev/null @@ -1,75 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N = 10; // number of inputs in each bundle -const int K = 4; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr; //(0.02) probability nand works correctly -const double prob1; //(0.9) probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -label "target" = s=4 & z/N<0.1; - -// rewards: final value of gate -rewards - [] s=0 & (c=N) & (u=M) : z/N; -endrewards - diff --git a/examples/pdtmc/nand/nand10_5.pm b/examples/pdtmc/nand/nand10_5.pm deleted file mode 100644 index 2b1405c2f..000000000 --- a/examples/pdtmc/nand/nand10_5.pm +++ /dev/null @@ -1,75 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N = 10; // number of inputs in each bundle -const int K = 5; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr; //(0.02) probability nand works correctly -const double prob1; //(0.9) probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -label "target" = s=4 & z/N<0.1; - -// rewards: final value of gate -rewards - [] s=0 & (c=N) & (u=M) : z/N; -endrewards - diff --git a/examples/pdtmc/nand/nand20_1.pm b/examples/pdtmc/nand/nand20_1.pm deleted file mode 100644 index babaecbe3..000000000 --- a/examples/pdtmc/nand/nand20_1.pm +++ /dev/null @@ -1,75 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N = 20; // number of inputs in each bundle -const int K = 1; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr; //(0.02) probability nand works correctly -const double prob1; //(0.9) probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -label "target" = s=4 & z/N<0.1; - -// rewards: final value of gate -rewards - [] s=0 & (c=N) & (u=M) : z/N; -endrewards - diff --git a/examples/pdtmc/nand/nand20_2.pm b/examples/pdtmc/nand/nand20_2.pm deleted file mode 100644 index 164a03e0f..000000000 --- a/examples/pdtmc/nand/nand20_2.pm +++ /dev/null @@ -1,75 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N = 20; // number of inputs in each bundle -const int K = 2; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr; //(0.02) probability nand works correctly -const double prob1; //(0.9) probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -label "target" = s=4 & z/N<0.1; - -// rewards: final value of gate -rewards - [] s=0 & (c=N) & (u=M) : z/N; -endrewards - diff --git a/examples/pdtmc/nand/nand20_3.pm b/examples/pdtmc/nand/nand20_3.pm deleted file mode 100644 index 5131d1290..000000000 --- a/examples/pdtmc/nand/nand20_3.pm +++ /dev/null @@ -1,75 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N = 20; // number of inputs in each bundle -const int K = 3; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr; //(0.02) probability nand works correctly -const double prob1; //(0.9) probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -label "target" = s=4 & z/N<0.1; - -// rewards: final value of gate -rewards - [] s=0 & (c=N) & (u=M) : z/N; -endrewards - diff --git a/examples/pdtmc/nand/nand20_4.pm b/examples/pdtmc/nand/nand20_4.pm deleted file mode 100644 index 047f8ac5e..000000000 --- a/examples/pdtmc/nand/nand20_4.pm +++ /dev/null @@ -1,75 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N = 20; // number of inputs in each bundle -const int K = 4; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr; //(0.02) probability nand works correctly -const double prob1; //(0.9) probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -label "target" = s=4 & z/N<0.1; - -// rewards: final value of gate -rewards - [] s=0 & (c=N) & (u=M) : z/N; -endrewards - diff --git a/examples/pdtmc/nand/nand20_5.pm b/examples/pdtmc/nand/nand20_5.pm deleted file mode 100644 index 2043bb018..000000000 --- a/examples/pdtmc/nand/nand20_5.pm +++ /dev/null @@ -1,75 +0,0 @@ -// nand multiplex system -// gxn/dxp 20/03/03 - -// U (correctly) performs a random permutation of the outputs of the previous stage - -dtmc - -const int N = 20; // number of inputs in each bundle -const int K = 5; // number of restorative stages - -const int M = 2*K+1; // total number of multiplexing units - -// parameters taken from the following paper -// A system architecture solution for unreliable nanoelectric devices -// J. Han & P. Jonker -// IEEEE trans. on nanotechnology vol 1(4) 2002 - -const double perr; //(0.02) probability nand works correctly -const double prob1; //(0.9) probability initial inputs are stimulated - -// model whole system as a single module by resuing variables -// to decrease the state space -module multiplex - - u : [1..M]; // number of stages - c : [0..N]; // counter (number of copies of the nand done) - - s : [0..4]; // local state - // 0 - initial state - // 1 - set x inputs - // 2 - set y inputs - // 3 - set outputs - // 4 - done - - z : [0..N]; // number of new outputs equal to 1 - zx : [0..N]; // number of old outputs equal to 1 - zy : [0..N]; // need second copy for y - // initially 9 since initially probability of stimulated state is 0.9 - - x : [0..1]; // value of first input - y : [0..1]; // value of second input - - [] s=0 & (c (s'=1); // do next nand if have not done N yet - [] s=0 & (c=N) & (u (s'=1) & (zx'=z) & (zy'=z) & (z'=0) & (u'=u+1) & (c'=0); // move on to next u if not finished - [] s=0 & (c=N) & (u=M) -> (s'=4) & (zx'=0) & (zy'=0) & (x'=0) & (y'=0); // finished (so reset variables not needed to reduce state space) - - // choose x permute selection (have zx stimulated inputs) - // note only need y to be random - [] s=1 & u=1 -> prob1 : (x'=1) & (s'=2) + (1-prob1) : (x'=0) & (s'=2); // initially random - [] s=1 & u>1 & zx>0 -> (x'=1) & (s'=2) & (zx'=zx-1); - [] s=1 & u>1 & zx=0 -> (x'=0) & (s'=2); - - // choose x randomly from selection (have zy stimulated inputs) - [] s=2 & u=1 -> prob1 : (y'=1) & (s'=3) + (1-prob1) : (y'=0) & (s'=3); // initially random - [] s=2 & u>1 & zy<(N-c) & zy>0 -> zy/(N-c) : (y'=1) & (s'=3) & (zy'=zy-1) + 1-(zy/(N-c)) : (y'=0) & (s'=3); - [] s=2 & u>1 & zy=(N-c) & c 1 : (y'=1) & (s'=3) & (zy'=zy-1); - [] s=2 & u>1 & zy=0 -> 1 : (y'=0) & (s'=3); - - // use nand gate - [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - // [] s=3 & z (1-perr) : (z'=z+(1-x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0) // not faulty - // + perr : (z'=z+(x*y)) & (s'=0) & (c'=c+1) & (x'=0) & (y'=0); // von neumann fault - - [] s=4 -> (s'=s); - -endmodule - -label "target" = s=4 & z/N<0.1; - -// rewards: final value of gate -rewards - [] s=0 & (c=N) & (u=M) : z/N; -endrewards - diff --git a/examples/pdtmc/nand/nand_regions.txt b/examples/pdtmc/nand/nand_regions.txt deleted file mode 100644 index 2a1194565..000000000 --- a/examples/pdtmc/nand/nand_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=perr<=0.040000, 0.000010<=prob1<=0.040000; -0.000010<=perr<=0.040000, 0.040000<=prob1<=0.080000; -0.000010<=perr<=0.040000, 0.080000<=prob1<=0.120000; -0.000010<=perr<=0.040000, 0.120000<=prob1<=0.160000; -0.000010<=perr<=0.040000, 0.160000<=prob1<=0.200000; -0.000010<=perr<=0.040000, 0.200000<=prob1<=0.240000; -0.000010<=perr<=0.040000, 0.240000<=prob1<=0.280000; -0.000010<=perr<=0.040000, 0.280000<=prob1<=0.320000; -0.000010<=perr<=0.040000, 0.320000<=prob1<=0.360000; -0.000010<=perr<=0.040000, 0.360000<=prob1<=0.400000; -0.000010<=perr<=0.040000, 0.400000<=prob1<=0.440000; -0.000010<=perr<=0.040000, 0.440000<=prob1<=0.480000; -0.000010<=perr<=0.040000, 0.480000<=prob1<=0.520000; -0.000010<=perr<=0.040000, 0.520000<=prob1<=0.560000; -0.000010<=perr<=0.040000, 0.560000<=prob1<=0.600000; -0.000010<=perr<=0.040000, 0.600000<=prob1<=0.640000; -0.000010<=perr<=0.040000, 0.640000<=prob1<=0.680000; -0.000010<=perr<=0.040000, 0.680000<=prob1<=0.720000; -0.000010<=perr<=0.040000, 0.720000<=prob1<=0.760000; -0.000010<=perr<=0.040000, 0.760000<=prob1<=0.800000; -0.000010<=perr<=0.040000, 0.800000<=prob1<=0.840000; -0.000010<=perr<=0.040000, 0.840000<=prob1<=0.880000; -0.000010<=perr<=0.040000, 0.880000<=prob1<=0.920000; -0.000010<=perr<=0.040000, 0.920000<=prob1<=0.960000; -0.000010<=perr<=0.040000, 0.960000<=prob1<=0.999990; -0.040000<=perr<=0.080000, 0.000010<=prob1<=0.040000; -0.040000<=perr<=0.080000, 0.040000<=prob1<=0.080000; -0.040000<=perr<=0.080000, 0.080000<=prob1<=0.120000; -0.040000<=perr<=0.080000, 0.120000<=prob1<=0.160000; -0.040000<=perr<=0.080000, 0.160000<=prob1<=0.200000; -0.040000<=perr<=0.080000, 0.200000<=prob1<=0.240000; -0.040000<=perr<=0.080000, 0.240000<=prob1<=0.280000; -0.040000<=perr<=0.080000, 0.280000<=prob1<=0.320000; -0.040000<=perr<=0.080000, 0.320000<=prob1<=0.360000; -0.040000<=perr<=0.080000, 0.360000<=prob1<=0.400000; -0.040000<=perr<=0.080000, 0.400000<=prob1<=0.440000; -0.040000<=perr<=0.080000, 0.440000<=prob1<=0.480000; -0.040000<=perr<=0.080000, 0.480000<=prob1<=0.520000; -0.040000<=perr<=0.080000, 0.520000<=prob1<=0.560000; -0.040000<=perr<=0.080000, 0.560000<=prob1<=0.600000; -0.040000<=perr<=0.080000, 0.600000<=prob1<=0.640000; -0.040000<=perr<=0.080000, 0.640000<=prob1<=0.680000; -0.040000<=perr<=0.080000, 0.680000<=prob1<=0.720000; -0.040000<=perr<=0.080000, 0.720000<=prob1<=0.760000; -0.040000<=perr<=0.080000, 0.760000<=prob1<=0.800000; -0.040000<=perr<=0.080000, 0.800000<=prob1<=0.840000; -0.040000<=perr<=0.080000, 0.840000<=prob1<=0.880000; -0.040000<=perr<=0.080000, 0.880000<=prob1<=0.920000; -0.040000<=perr<=0.080000, 0.920000<=prob1<=0.960000; -0.040000<=perr<=0.080000, 0.960000<=prob1<=0.999990; -0.080000<=perr<=0.120000, 0.000010<=prob1<=0.040000; -0.080000<=perr<=0.120000, 0.040000<=prob1<=0.080000; -0.080000<=perr<=0.120000, 0.080000<=prob1<=0.120000; -0.080000<=perr<=0.120000, 0.120000<=prob1<=0.160000; -0.080000<=perr<=0.120000, 0.160000<=prob1<=0.200000; -0.080000<=perr<=0.120000, 0.200000<=prob1<=0.240000; -0.080000<=perr<=0.120000, 0.240000<=prob1<=0.280000; -0.080000<=perr<=0.120000, 0.280000<=prob1<=0.320000; -0.080000<=perr<=0.120000, 0.320000<=prob1<=0.360000; -0.080000<=perr<=0.120000, 0.360000<=prob1<=0.400000; -0.080000<=perr<=0.120000, 0.400000<=prob1<=0.440000; -0.080000<=perr<=0.120000, 0.440000<=prob1<=0.480000; -0.080000<=perr<=0.120000, 0.480000<=prob1<=0.520000; -0.080000<=perr<=0.120000, 0.520000<=prob1<=0.560000; -0.080000<=perr<=0.120000, 0.560000<=prob1<=0.600000; -0.080000<=perr<=0.120000, 0.600000<=prob1<=0.640000; -0.080000<=perr<=0.120000, 0.640000<=prob1<=0.680000; -0.080000<=perr<=0.120000, 0.680000<=prob1<=0.720000; -0.080000<=perr<=0.120000, 0.720000<=prob1<=0.760000; -0.080000<=perr<=0.120000, 0.760000<=prob1<=0.800000; -0.080000<=perr<=0.120000, 0.800000<=prob1<=0.840000; -0.080000<=perr<=0.120000, 0.840000<=prob1<=0.880000; -0.080000<=perr<=0.120000, 0.880000<=prob1<=0.920000; -0.080000<=perr<=0.120000, 0.920000<=prob1<=0.960000; -0.080000<=perr<=0.120000, 0.960000<=prob1<=0.999990; -0.120000<=perr<=0.160000, 0.000010<=prob1<=0.040000; -0.120000<=perr<=0.160000, 0.040000<=prob1<=0.080000; -0.120000<=perr<=0.160000, 0.080000<=prob1<=0.120000; -0.120000<=perr<=0.160000, 0.120000<=prob1<=0.160000; -0.120000<=perr<=0.160000, 0.160000<=prob1<=0.200000; -0.120000<=perr<=0.160000, 0.200000<=prob1<=0.240000; -0.120000<=perr<=0.160000, 0.240000<=prob1<=0.280000; -0.120000<=perr<=0.160000, 0.280000<=prob1<=0.320000; -0.120000<=perr<=0.160000, 0.320000<=prob1<=0.360000; -0.120000<=perr<=0.160000, 0.360000<=prob1<=0.400000; -0.120000<=perr<=0.160000, 0.400000<=prob1<=0.440000; -0.120000<=perr<=0.160000, 0.440000<=prob1<=0.480000; -0.120000<=perr<=0.160000, 0.480000<=prob1<=0.520000; -0.120000<=perr<=0.160000, 0.520000<=prob1<=0.560000; -0.120000<=perr<=0.160000, 0.560000<=prob1<=0.600000; -0.120000<=perr<=0.160000, 0.600000<=prob1<=0.640000; -0.120000<=perr<=0.160000, 0.640000<=prob1<=0.680000; -0.120000<=perr<=0.160000, 0.680000<=prob1<=0.720000; -0.120000<=perr<=0.160000, 0.720000<=prob1<=0.760000; -0.120000<=perr<=0.160000, 0.760000<=prob1<=0.800000; -0.120000<=perr<=0.160000, 0.800000<=prob1<=0.840000; -0.120000<=perr<=0.160000, 0.840000<=prob1<=0.880000; -0.120000<=perr<=0.160000, 0.880000<=prob1<=0.920000; -0.120000<=perr<=0.160000, 0.920000<=prob1<=0.960000; -0.120000<=perr<=0.160000, 0.960000<=prob1<=0.999990; -0.160000<=perr<=0.200000, 0.000010<=prob1<=0.040000; -0.160000<=perr<=0.200000, 0.040000<=prob1<=0.080000; -0.160000<=perr<=0.200000, 0.080000<=prob1<=0.120000; -0.160000<=perr<=0.200000, 0.120000<=prob1<=0.160000; -0.160000<=perr<=0.200000, 0.160000<=prob1<=0.200000; -0.160000<=perr<=0.200000, 0.200000<=prob1<=0.240000; -0.160000<=perr<=0.200000, 0.240000<=prob1<=0.280000; -0.160000<=perr<=0.200000, 0.280000<=prob1<=0.320000; -0.160000<=perr<=0.200000, 0.320000<=prob1<=0.360000; -0.160000<=perr<=0.200000, 0.360000<=prob1<=0.400000; -0.160000<=perr<=0.200000, 0.400000<=prob1<=0.440000; -0.160000<=perr<=0.200000, 0.440000<=prob1<=0.480000; -0.160000<=perr<=0.200000, 0.480000<=prob1<=0.520000; -0.160000<=perr<=0.200000, 0.520000<=prob1<=0.560000; -0.160000<=perr<=0.200000, 0.560000<=prob1<=0.600000; -0.160000<=perr<=0.200000, 0.600000<=prob1<=0.640000; -0.160000<=perr<=0.200000, 0.640000<=prob1<=0.680000; -0.160000<=perr<=0.200000, 0.680000<=prob1<=0.720000; -0.160000<=perr<=0.200000, 0.720000<=prob1<=0.760000; -0.160000<=perr<=0.200000, 0.760000<=prob1<=0.800000; -0.160000<=perr<=0.200000, 0.800000<=prob1<=0.840000; -0.160000<=perr<=0.200000, 0.840000<=prob1<=0.880000; -0.160000<=perr<=0.200000, 0.880000<=prob1<=0.920000; -0.160000<=perr<=0.200000, 0.920000<=prob1<=0.960000; -0.160000<=perr<=0.200000, 0.960000<=prob1<=0.999990; -0.200000<=perr<=0.240000, 0.000010<=prob1<=0.040000; -0.200000<=perr<=0.240000, 0.040000<=prob1<=0.080000; -0.200000<=perr<=0.240000, 0.080000<=prob1<=0.120000; -0.200000<=perr<=0.240000, 0.120000<=prob1<=0.160000; -0.200000<=perr<=0.240000, 0.160000<=prob1<=0.200000; -0.200000<=perr<=0.240000, 0.200000<=prob1<=0.240000; -0.200000<=perr<=0.240000, 0.240000<=prob1<=0.280000; -0.200000<=perr<=0.240000, 0.280000<=prob1<=0.320000; -0.200000<=perr<=0.240000, 0.320000<=prob1<=0.360000; -0.200000<=perr<=0.240000, 0.360000<=prob1<=0.400000; -0.200000<=perr<=0.240000, 0.400000<=prob1<=0.440000; -0.200000<=perr<=0.240000, 0.440000<=prob1<=0.480000; -0.200000<=perr<=0.240000, 0.480000<=prob1<=0.520000; -0.200000<=perr<=0.240000, 0.520000<=prob1<=0.560000; -0.200000<=perr<=0.240000, 0.560000<=prob1<=0.600000; -0.200000<=perr<=0.240000, 0.600000<=prob1<=0.640000; -0.200000<=perr<=0.240000, 0.640000<=prob1<=0.680000; -0.200000<=perr<=0.240000, 0.680000<=prob1<=0.720000; -0.200000<=perr<=0.240000, 0.720000<=prob1<=0.760000; -0.200000<=perr<=0.240000, 0.760000<=prob1<=0.800000; -0.200000<=perr<=0.240000, 0.800000<=prob1<=0.840000; -0.200000<=perr<=0.240000, 0.840000<=prob1<=0.880000; -0.200000<=perr<=0.240000, 0.880000<=prob1<=0.920000; -0.200000<=perr<=0.240000, 0.920000<=prob1<=0.960000; -0.200000<=perr<=0.240000, 0.960000<=prob1<=0.999990; -0.240000<=perr<=0.280000, 0.000010<=prob1<=0.040000; -0.240000<=perr<=0.280000, 0.040000<=prob1<=0.080000; -0.240000<=perr<=0.280000, 0.080000<=prob1<=0.120000; -0.240000<=perr<=0.280000, 0.120000<=prob1<=0.160000; -0.240000<=perr<=0.280000, 0.160000<=prob1<=0.200000; -0.240000<=perr<=0.280000, 0.200000<=prob1<=0.240000; -0.240000<=perr<=0.280000, 0.240000<=prob1<=0.280000; -0.240000<=perr<=0.280000, 0.280000<=prob1<=0.320000; -0.240000<=perr<=0.280000, 0.320000<=prob1<=0.360000; -0.240000<=perr<=0.280000, 0.360000<=prob1<=0.400000; -0.240000<=perr<=0.280000, 0.400000<=prob1<=0.440000; -0.240000<=perr<=0.280000, 0.440000<=prob1<=0.480000; -0.240000<=perr<=0.280000, 0.480000<=prob1<=0.520000; -0.240000<=perr<=0.280000, 0.520000<=prob1<=0.560000; -0.240000<=perr<=0.280000, 0.560000<=prob1<=0.600000; -0.240000<=perr<=0.280000, 0.600000<=prob1<=0.640000; -0.240000<=perr<=0.280000, 0.640000<=prob1<=0.680000; -0.240000<=perr<=0.280000, 0.680000<=prob1<=0.720000; -0.240000<=perr<=0.280000, 0.720000<=prob1<=0.760000; -0.240000<=perr<=0.280000, 0.760000<=prob1<=0.800000; -0.240000<=perr<=0.280000, 0.800000<=prob1<=0.840000; -0.240000<=perr<=0.280000, 0.840000<=prob1<=0.880000; -0.240000<=perr<=0.280000, 0.880000<=prob1<=0.920000; -0.240000<=perr<=0.280000, 0.920000<=prob1<=0.960000; -0.240000<=perr<=0.280000, 0.960000<=prob1<=0.999990; -0.280000<=perr<=0.320000, 0.000010<=prob1<=0.040000; -0.280000<=perr<=0.320000, 0.040000<=prob1<=0.080000; -0.280000<=perr<=0.320000, 0.080000<=prob1<=0.120000; -0.280000<=perr<=0.320000, 0.120000<=prob1<=0.160000; -0.280000<=perr<=0.320000, 0.160000<=prob1<=0.200000; -0.280000<=perr<=0.320000, 0.200000<=prob1<=0.240000; -0.280000<=perr<=0.320000, 0.240000<=prob1<=0.280000; -0.280000<=perr<=0.320000, 0.280000<=prob1<=0.320000; -0.280000<=perr<=0.320000, 0.320000<=prob1<=0.360000; -0.280000<=perr<=0.320000, 0.360000<=prob1<=0.400000; -0.280000<=perr<=0.320000, 0.400000<=prob1<=0.440000; -0.280000<=perr<=0.320000, 0.440000<=prob1<=0.480000; -0.280000<=perr<=0.320000, 0.480000<=prob1<=0.520000; -0.280000<=perr<=0.320000, 0.520000<=prob1<=0.560000; -0.280000<=perr<=0.320000, 0.560000<=prob1<=0.600000; -0.280000<=perr<=0.320000, 0.600000<=prob1<=0.640000; -0.280000<=perr<=0.320000, 0.640000<=prob1<=0.680000; -0.280000<=perr<=0.320000, 0.680000<=prob1<=0.720000; -0.280000<=perr<=0.320000, 0.720000<=prob1<=0.760000; -0.280000<=perr<=0.320000, 0.760000<=prob1<=0.800000; -0.280000<=perr<=0.320000, 0.800000<=prob1<=0.840000; -0.280000<=perr<=0.320000, 0.840000<=prob1<=0.880000; -0.280000<=perr<=0.320000, 0.880000<=prob1<=0.920000; -0.280000<=perr<=0.320000, 0.920000<=prob1<=0.960000; -0.280000<=perr<=0.320000, 0.960000<=prob1<=0.999990; -0.320000<=perr<=0.360000, 0.000010<=prob1<=0.040000; -0.320000<=perr<=0.360000, 0.040000<=prob1<=0.080000; -0.320000<=perr<=0.360000, 0.080000<=prob1<=0.120000; -0.320000<=perr<=0.360000, 0.120000<=prob1<=0.160000; -0.320000<=perr<=0.360000, 0.160000<=prob1<=0.200000; -0.320000<=perr<=0.360000, 0.200000<=prob1<=0.240000; -0.320000<=perr<=0.360000, 0.240000<=prob1<=0.280000; -0.320000<=perr<=0.360000, 0.280000<=prob1<=0.320000; -0.320000<=perr<=0.360000, 0.320000<=prob1<=0.360000; -0.320000<=perr<=0.360000, 0.360000<=prob1<=0.400000; -0.320000<=perr<=0.360000, 0.400000<=prob1<=0.440000; -0.320000<=perr<=0.360000, 0.440000<=prob1<=0.480000; -0.320000<=perr<=0.360000, 0.480000<=prob1<=0.520000; -0.320000<=perr<=0.360000, 0.520000<=prob1<=0.560000; -0.320000<=perr<=0.360000, 0.560000<=prob1<=0.600000; -0.320000<=perr<=0.360000, 0.600000<=prob1<=0.640000; -0.320000<=perr<=0.360000, 0.640000<=prob1<=0.680000; -0.320000<=perr<=0.360000, 0.680000<=prob1<=0.720000; -0.320000<=perr<=0.360000, 0.720000<=prob1<=0.760000; -0.320000<=perr<=0.360000, 0.760000<=prob1<=0.800000; -0.320000<=perr<=0.360000, 0.800000<=prob1<=0.840000; -0.320000<=perr<=0.360000, 0.840000<=prob1<=0.880000; -0.320000<=perr<=0.360000, 0.880000<=prob1<=0.920000; -0.320000<=perr<=0.360000, 0.920000<=prob1<=0.960000; -0.320000<=perr<=0.360000, 0.960000<=prob1<=0.999990; -0.360000<=perr<=0.400000, 0.000010<=prob1<=0.040000; -0.360000<=perr<=0.400000, 0.040000<=prob1<=0.080000; -0.360000<=perr<=0.400000, 0.080000<=prob1<=0.120000; -0.360000<=perr<=0.400000, 0.120000<=prob1<=0.160000; -0.360000<=perr<=0.400000, 0.160000<=prob1<=0.200000; -0.360000<=perr<=0.400000, 0.200000<=prob1<=0.240000; -0.360000<=perr<=0.400000, 0.240000<=prob1<=0.280000; -0.360000<=perr<=0.400000, 0.280000<=prob1<=0.320000; -0.360000<=perr<=0.400000, 0.320000<=prob1<=0.360000; -0.360000<=perr<=0.400000, 0.360000<=prob1<=0.400000; -0.360000<=perr<=0.400000, 0.400000<=prob1<=0.440000; -0.360000<=perr<=0.400000, 0.440000<=prob1<=0.480000; -0.360000<=perr<=0.400000, 0.480000<=prob1<=0.520000; -0.360000<=perr<=0.400000, 0.520000<=prob1<=0.560000; -0.360000<=perr<=0.400000, 0.560000<=prob1<=0.600000; -0.360000<=perr<=0.400000, 0.600000<=prob1<=0.640000; -0.360000<=perr<=0.400000, 0.640000<=prob1<=0.680000; -0.360000<=perr<=0.400000, 0.680000<=prob1<=0.720000; -0.360000<=perr<=0.400000, 0.720000<=prob1<=0.760000; -0.360000<=perr<=0.400000, 0.760000<=prob1<=0.800000; -0.360000<=perr<=0.400000, 0.800000<=prob1<=0.840000; -0.360000<=perr<=0.400000, 0.840000<=prob1<=0.880000; -0.360000<=perr<=0.400000, 0.880000<=prob1<=0.920000; -0.360000<=perr<=0.400000, 0.920000<=prob1<=0.960000; -0.360000<=perr<=0.400000, 0.960000<=prob1<=0.999990; -0.400000<=perr<=0.440000, 0.000010<=prob1<=0.040000; -0.400000<=perr<=0.440000, 0.040000<=prob1<=0.080000; -0.400000<=perr<=0.440000, 0.080000<=prob1<=0.120000; -0.400000<=perr<=0.440000, 0.120000<=prob1<=0.160000; -0.400000<=perr<=0.440000, 0.160000<=prob1<=0.200000; -0.400000<=perr<=0.440000, 0.200000<=prob1<=0.240000; -0.400000<=perr<=0.440000, 0.240000<=prob1<=0.280000; -0.400000<=perr<=0.440000, 0.280000<=prob1<=0.320000; -0.400000<=perr<=0.440000, 0.320000<=prob1<=0.360000; -0.400000<=perr<=0.440000, 0.360000<=prob1<=0.400000; -0.400000<=perr<=0.440000, 0.400000<=prob1<=0.440000; -0.400000<=perr<=0.440000, 0.440000<=prob1<=0.480000; -0.400000<=perr<=0.440000, 0.480000<=prob1<=0.520000; -0.400000<=perr<=0.440000, 0.520000<=prob1<=0.560000; -0.400000<=perr<=0.440000, 0.560000<=prob1<=0.600000; -0.400000<=perr<=0.440000, 0.600000<=prob1<=0.640000; -0.400000<=perr<=0.440000, 0.640000<=prob1<=0.680000; -0.400000<=perr<=0.440000, 0.680000<=prob1<=0.720000; -0.400000<=perr<=0.440000, 0.720000<=prob1<=0.760000; -0.400000<=perr<=0.440000, 0.760000<=prob1<=0.800000; -0.400000<=perr<=0.440000, 0.800000<=prob1<=0.840000; -0.400000<=perr<=0.440000, 0.840000<=prob1<=0.880000; -0.400000<=perr<=0.440000, 0.880000<=prob1<=0.920000; -0.400000<=perr<=0.440000, 0.920000<=prob1<=0.960000; -0.400000<=perr<=0.440000, 0.960000<=prob1<=0.999990; -0.440000<=perr<=0.480000, 0.000010<=prob1<=0.040000; -0.440000<=perr<=0.480000, 0.040000<=prob1<=0.080000; -0.440000<=perr<=0.480000, 0.080000<=prob1<=0.120000; -0.440000<=perr<=0.480000, 0.120000<=prob1<=0.160000; -0.440000<=perr<=0.480000, 0.160000<=prob1<=0.200000; -0.440000<=perr<=0.480000, 0.200000<=prob1<=0.240000; -0.440000<=perr<=0.480000, 0.240000<=prob1<=0.280000; -0.440000<=perr<=0.480000, 0.280000<=prob1<=0.320000; -0.440000<=perr<=0.480000, 0.320000<=prob1<=0.360000; -0.440000<=perr<=0.480000, 0.360000<=prob1<=0.400000; -0.440000<=perr<=0.480000, 0.400000<=prob1<=0.440000; -0.440000<=perr<=0.480000, 0.440000<=prob1<=0.480000; -0.440000<=perr<=0.480000, 0.480000<=prob1<=0.520000; -0.440000<=perr<=0.480000, 0.520000<=prob1<=0.560000; -0.440000<=perr<=0.480000, 0.560000<=prob1<=0.600000; -0.440000<=perr<=0.480000, 0.600000<=prob1<=0.640000; -0.440000<=perr<=0.480000, 0.640000<=prob1<=0.680000; -0.440000<=perr<=0.480000, 0.680000<=prob1<=0.720000; -0.440000<=perr<=0.480000, 0.720000<=prob1<=0.760000; -0.440000<=perr<=0.480000, 0.760000<=prob1<=0.800000; -0.440000<=perr<=0.480000, 0.800000<=prob1<=0.840000; -0.440000<=perr<=0.480000, 0.840000<=prob1<=0.880000; -0.440000<=perr<=0.480000, 0.880000<=prob1<=0.920000; -0.440000<=perr<=0.480000, 0.920000<=prob1<=0.960000; -0.440000<=perr<=0.480000, 0.960000<=prob1<=0.999990; -0.480000<=perr<=0.520000, 0.000010<=prob1<=0.040000; -0.480000<=perr<=0.520000, 0.040000<=prob1<=0.080000; -0.480000<=perr<=0.520000, 0.080000<=prob1<=0.120000; -0.480000<=perr<=0.520000, 0.120000<=prob1<=0.160000; -0.480000<=perr<=0.520000, 0.160000<=prob1<=0.200000; -0.480000<=perr<=0.520000, 0.200000<=prob1<=0.240000; -0.480000<=perr<=0.520000, 0.240000<=prob1<=0.280000; -0.480000<=perr<=0.520000, 0.280000<=prob1<=0.320000; -0.480000<=perr<=0.520000, 0.320000<=prob1<=0.360000; -0.480000<=perr<=0.520000, 0.360000<=prob1<=0.400000; -0.480000<=perr<=0.520000, 0.400000<=prob1<=0.440000; -0.480000<=perr<=0.520000, 0.440000<=prob1<=0.480000; -0.480000<=perr<=0.520000, 0.480000<=prob1<=0.520000; -0.480000<=perr<=0.520000, 0.520000<=prob1<=0.560000; -0.480000<=perr<=0.520000, 0.560000<=prob1<=0.600000; -0.480000<=perr<=0.520000, 0.600000<=prob1<=0.640000; -0.480000<=perr<=0.520000, 0.640000<=prob1<=0.680000; -0.480000<=perr<=0.520000, 0.680000<=prob1<=0.720000; -0.480000<=perr<=0.520000, 0.720000<=prob1<=0.760000; -0.480000<=perr<=0.520000, 0.760000<=prob1<=0.800000; -0.480000<=perr<=0.520000, 0.800000<=prob1<=0.840000; -0.480000<=perr<=0.520000, 0.840000<=prob1<=0.880000; -0.480000<=perr<=0.520000, 0.880000<=prob1<=0.920000; -0.480000<=perr<=0.520000, 0.920000<=prob1<=0.960000; -0.480000<=perr<=0.520000, 0.960000<=prob1<=0.999990; -0.520000<=perr<=0.560000, 0.000010<=prob1<=0.040000; -0.520000<=perr<=0.560000, 0.040000<=prob1<=0.080000; -0.520000<=perr<=0.560000, 0.080000<=prob1<=0.120000; -0.520000<=perr<=0.560000, 0.120000<=prob1<=0.160000; -0.520000<=perr<=0.560000, 0.160000<=prob1<=0.200000; -0.520000<=perr<=0.560000, 0.200000<=prob1<=0.240000; -0.520000<=perr<=0.560000, 0.240000<=prob1<=0.280000; -0.520000<=perr<=0.560000, 0.280000<=prob1<=0.320000; -0.520000<=perr<=0.560000, 0.320000<=prob1<=0.360000; -0.520000<=perr<=0.560000, 0.360000<=prob1<=0.400000; -0.520000<=perr<=0.560000, 0.400000<=prob1<=0.440000; -0.520000<=perr<=0.560000, 0.440000<=prob1<=0.480000; -0.520000<=perr<=0.560000, 0.480000<=prob1<=0.520000; -0.520000<=perr<=0.560000, 0.520000<=prob1<=0.560000; -0.520000<=perr<=0.560000, 0.560000<=prob1<=0.600000; -0.520000<=perr<=0.560000, 0.600000<=prob1<=0.640000; -0.520000<=perr<=0.560000, 0.640000<=prob1<=0.680000; -0.520000<=perr<=0.560000, 0.680000<=prob1<=0.720000; -0.520000<=perr<=0.560000, 0.720000<=prob1<=0.760000; -0.520000<=perr<=0.560000, 0.760000<=prob1<=0.800000; -0.520000<=perr<=0.560000, 0.800000<=prob1<=0.840000; -0.520000<=perr<=0.560000, 0.840000<=prob1<=0.880000; -0.520000<=perr<=0.560000, 0.880000<=prob1<=0.920000; -0.520000<=perr<=0.560000, 0.920000<=prob1<=0.960000; -0.520000<=perr<=0.560000, 0.960000<=prob1<=0.999990; -0.560000<=perr<=0.600000, 0.000010<=prob1<=0.040000; -0.560000<=perr<=0.600000, 0.040000<=prob1<=0.080000; -0.560000<=perr<=0.600000, 0.080000<=prob1<=0.120000; -0.560000<=perr<=0.600000, 0.120000<=prob1<=0.160000; -0.560000<=perr<=0.600000, 0.160000<=prob1<=0.200000; -0.560000<=perr<=0.600000, 0.200000<=prob1<=0.240000; -0.560000<=perr<=0.600000, 0.240000<=prob1<=0.280000; -0.560000<=perr<=0.600000, 0.280000<=prob1<=0.320000; -0.560000<=perr<=0.600000, 0.320000<=prob1<=0.360000; -0.560000<=perr<=0.600000, 0.360000<=prob1<=0.400000; -0.560000<=perr<=0.600000, 0.400000<=prob1<=0.440000; -0.560000<=perr<=0.600000, 0.440000<=prob1<=0.480000; -0.560000<=perr<=0.600000, 0.480000<=prob1<=0.520000; -0.560000<=perr<=0.600000, 0.520000<=prob1<=0.560000; -0.560000<=perr<=0.600000, 0.560000<=prob1<=0.600000; -0.560000<=perr<=0.600000, 0.600000<=prob1<=0.640000; -0.560000<=perr<=0.600000, 0.640000<=prob1<=0.680000; -0.560000<=perr<=0.600000, 0.680000<=prob1<=0.720000; -0.560000<=perr<=0.600000, 0.720000<=prob1<=0.760000; -0.560000<=perr<=0.600000, 0.760000<=prob1<=0.800000; -0.560000<=perr<=0.600000, 0.800000<=prob1<=0.840000; -0.560000<=perr<=0.600000, 0.840000<=prob1<=0.880000; -0.560000<=perr<=0.600000, 0.880000<=prob1<=0.920000; -0.560000<=perr<=0.600000, 0.920000<=prob1<=0.960000; -0.560000<=perr<=0.600000, 0.960000<=prob1<=0.999990; -0.600000<=perr<=0.640000, 0.000010<=prob1<=0.040000; -0.600000<=perr<=0.640000, 0.040000<=prob1<=0.080000; -0.600000<=perr<=0.640000, 0.080000<=prob1<=0.120000; -0.600000<=perr<=0.640000, 0.120000<=prob1<=0.160000; -0.600000<=perr<=0.640000, 0.160000<=prob1<=0.200000; -0.600000<=perr<=0.640000, 0.200000<=prob1<=0.240000; -0.600000<=perr<=0.640000, 0.240000<=prob1<=0.280000; -0.600000<=perr<=0.640000, 0.280000<=prob1<=0.320000; -0.600000<=perr<=0.640000, 0.320000<=prob1<=0.360000; -0.600000<=perr<=0.640000, 0.360000<=prob1<=0.400000; -0.600000<=perr<=0.640000, 0.400000<=prob1<=0.440000; -0.600000<=perr<=0.640000, 0.440000<=prob1<=0.480000; -0.600000<=perr<=0.640000, 0.480000<=prob1<=0.520000; -0.600000<=perr<=0.640000, 0.520000<=prob1<=0.560000; -0.600000<=perr<=0.640000, 0.560000<=prob1<=0.600000; -0.600000<=perr<=0.640000, 0.600000<=prob1<=0.640000; -0.600000<=perr<=0.640000, 0.640000<=prob1<=0.680000; -0.600000<=perr<=0.640000, 0.680000<=prob1<=0.720000; -0.600000<=perr<=0.640000, 0.720000<=prob1<=0.760000; -0.600000<=perr<=0.640000, 0.760000<=prob1<=0.800000; -0.600000<=perr<=0.640000, 0.800000<=prob1<=0.840000; -0.600000<=perr<=0.640000, 0.840000<=prob1<=0.880000; -0.600000<=perr<=0.640000, 0.880000<=prob1<=0.920000; -0.600000<=perr<=0.640000, 0.920000<=prob1<=0.960000; -0.600000<=perr<=0.640000, 0.960000<=prob1<=0.999990; -0.640000<=perr<=0.680000, 0.000010<=prob1<=0.040000; -0.640000<=perr<=0.680000, 0.040000<=prob1<=0.080000; -0.640000<=perr<=0.680000, 0.080000<=prob1<=0.120000; -0.640000<=perr<=0.680000, 0.120000<=prob1<=0.160000; -0.640000<=perr<=0.680000, 0.160000<=prob1<=0.200000; -0.640000<=perr<=0.680000, 0.200000<=prob1<=0.240000; -0.640000<=perr<=0.680000, 0.240000<=prob1<=0.280000; -0.640000<=perr<=0.680000, 0.280000<=prob1<=0.320000; -0.640000<=perr<=0.680000, 0.320000<=prob1<=0.360000; -0.640000<=perr<=0.680000, 0.360000<=prob1<=0.400000; -0.640000<=perr<=0.680000, 0.400000<=prob1<=0.440000; -0.640000<=perr<=0.680000, 0.440000<=prob1<=0.480000; -0.640000<=perr<=0.680000, 0.480000<=prob1<=0.520000; -0.640000<=perr<=0.680000, 0.520000<=prob1<=0.560000; -0.640000<=perr<=0.680000, 0.560000<=prob1<=0.600000; -0.640000<=perr<=0.680000, 0.600000<=prob1<=0.640000; -0.640000<=perr<=0.680000, 0.640000<=prob1<=0.680000; -0.640000<=perr<=0.680000, 0.680000<=prob1<=0.720000; -0.640000<=perr<=0.680000, 0.720000<=prob1<=0.760000; -0.640000<=perr<=0.680000, 0.760000<=prob1<=0.800000; -0.640000<=perr<=0.680000, 0.800000<=prob1<=0.840000; -0.640000<=perr<=0.680000, 0.840000<=prob1<=0.880000; -0.640000<=perr<=0.680000, 0.880000<=prob1<=0.920000; -0.640000<=perr<=0.680000, 0.920000<=prob1<=0.960000; -0.640000<=perr<=0.680000, 0.960000<=prob1<=0.999990; -0.680000<=perr<=0.720000, 0.000010<=prob1<=0.040000; -0.680000<=perr<=0.720000, 0.040000<=prob1<=0.080000; -0.680000<=perr<=0.720000, 0.080000<=prob1<=0.120000; -0.680000<=perr<=0.720000, 0.120000<=prob1<=0.160000; -0.680000<=perr<=0.720000, 0.160000<=prob1<=0.200000; -0.680000<=perr<=0.720000, 0.200000<=prob1<=0.240000; -0.680000<=perr<=0.720000, 0.240000<=prob1<=0.280000; -0.680000<=perr<=0.720000, 0.280000<=prob1<=0.320000; -0.680000<=perr<=0.720000, 0.320000<=prob1<=0.360000; -0.680000<=perr<=0.720000, 0.360000<=prob1<=0.400000; -0.680000<=perr<=0.720000, 0.400000<=prob1<=0.440000; -0.680000<=perr<=0.720000, 0.440000<=prob1<=0.480000; -0.680000<=perr<=0.720000, 0.480000<=prob1<=0.520000; -0.680000<=perr<=0.720000, 0.520000<=prob1<=0.560000; -0.680000<=perr<=0.720000, 0.560000<=prob1<=0.600000; -0.680000<=perr<=0.720000, 0.600000<=prob1<=0.640000; -0.680000<=perr<=0.720000, 0.640000<=prob1<=0.680000; -0.680000<=perr<=0.720000, 0.680000<=prob1<=0.720000; -0.680000<=perr<=0.720000, 0.720000<=prob1<=0.760000; -0.680000<=perr<=0.720000, 0.760000<=prob1<=0.800000; -0.680000<=perr<=0.720000, 0.800000<=prob1<=0.840000; -0.680000<=perr<=0.720000, 0.840000<=prob1<=0.880000; -0.680000<=perr<=0.720000, 0.880000<=prob1<=0.920000; -0.680000<=perr<=0.720000, 0.920000<=prob1<=0.960000; -0.680000<=perr<=0.720000, 0.960000<=prob1<=0.999990; -0.720000<=perr<=0.760000, 0.000010<=prob1<=0.040000; -0.720000<=perr<=0.760000, 0.040000<=prob1<=0.080000; -0.720000<=perr<=0.760000, 0.080000<=prob1<=0.120000; -0.720000<=perr<=0.760000, 0.120000<=prob1<=0.160000; -0.720000<=perr<=0.760000, 0.160000<=prob1<=0.200000; -0.720000<=perr<=0.760000, 0.200000<=prob1<=0.240000; -0.720000<=perr<=0.760000, 0.240000<=prob1<=0.280000; -0.720000<=perr<=0.760000, 0.280000<=prob1<=0.320000; -0.720000<=perr<=0.760000, 0.320000<=prob1<=0.360000; -0.720000<=perr<=0.760000, 0.360000<=prob1<=0.400000; -0.720000<=perr<=0.760000, 0.400000<=prob1<=0.440000; -0.720000<=perr<=0.760000, 0.440000<=prob1<=0.480000; -0.720000<=perr<=0.760000, 0.480000<=prob1<=0.520000; -0.720000<=perr<=0.760000, 0.520000<=prob1<=0.560000; -0.720000<=perr<=0.760000, 0.560000<=prob1<=0.600000; -0.720000<=perr<=0.760000, 0.600000<=prob1<=0.640000; -0.720000<=perr<=0.760000, 0.640000<=prob1<=0.680000; -0.720000<=perr<=0.760000, 0.680000<=prob1<=0.720000; -0.720000<=perr<=0.760000, 0.720000<=prob1<=0.760000; -0.720000<=perr<=0.760000, 0.760000<=prob1<=0.800000; -0.720000<=perr<=0.760000, 0.800000<=prob1<=0.840000; -0.720000<=perr<=0.760000, 0.840000<=prob1<=0.880000; -0.720000<=perr<=0.760000, 0.880000<=prob1<=0.920000; -0.720000<=perr<=0.760000, 0.920000<=prob1<=0.960000; -0.720000<=perr<=0.760000, 0.960000<=prob1<=0.999990; -0.760000<=perr<=0.800000, 0.000010<=prob1<=0.040000; -0.760000<=perr<=0.800000, 0.040000<=prob1<=0.080000; -0.760000<=perr<=0.800000, 0.080000<=prob1<=0.120000; -0.760000<=perr<=0.800000, 0.120000<=prob1<=0.160000; -0.760000<=perr<=0.800000, 0.160000<=prob1<=0.200000; -0.760000<=perr<=0.800000, 0.200000<=prob1<=0.240000; -0.760000<=perr<=0.800000, 0.240000<=prob1<=0.280000; -0.760000<=perr<=0.800000, 0.280000<=prob1<=0.320000; -0.760000<=perr<=0.800000, 0.320000<=prob1<=0.360000; -0.760000<=perr<=0.800000, 0.360000<=prob1<=0.400000; -0.760000<=perr<=0.800000, 0.400000<=prob1<=0.440000; -0.760000<=perr<=0.800000, 0.440000<=prob1<=0.480000; -0.760000<=perr<=0.800000, 0.480000<=prob1<=0.520000; -0.760000<=perr<=0.800000, 0.520000<=prob1<=0.560000; -0.760000<=perr<=0.800000, 0.560000<=prob1<=0.600000; -0.760000<=perr<=0.800000, 0.600000<=prob1<=0.640000; -0.760000<=perr<=0.800000, 0.640000<=prob1<=0.680000; -0.760000<=perr<=0.800000, 0.680000<=prob1<=0.720000; -0.760000<=perr<=0.800000, 0.720000<=prob1<=0.760000; -0.760000<=perr<=0.800000, 0.760000<=prob1<=0.800000; -0.760000<=perr<=0.800000, 0.800000<=prob1<=0.840000; -0.760000<=perr<=0.800000, 0.840000<=prob1<=0.880000; -0.760000<=perr<=0.800000, 0.880000<=prob1<=0.920000; -0.760000<=perr<=0.800000, 0.920000<=prob1<=0.960000; -0.760000<=perr<=0.800000, 0.960000<=prob1<=0.999990; -0.800000<=perr<=0.840000, 0.000010<=prob1<=0.040000; -0.800000<=perr<=0.840000, 0.040000<=prob1<=0.080000; -0.800000<=perr<=0.840000, 0.080000<=prob1<=0.120000; -0.800000<=perr<=0.840000, 0.120000<=prob1<=0.160000; -0.800000<=perr<=0.840000, 0.160000<=prob1<=0.200000; -0.800000<=perr<=0.840000, 0.200000<=prob1<=0.240000; -0.800000<=perr<=0.840000, 0.240000<=prob1<=0.280000; -0.800000<=perr<=0.840000, 0.280000<=prob1<=0.320000; -0.800000<=perr<=0.840000, 0.320000<=prob1<=0.360000; -0.800000<=perr<=0.840000, 0.360000<=prob1<=0.400000; -0.800000<=perr<=0.840000, 0.400000<=prob1<=0.440000; -0.800000<=perr<=0.840000, 0.440000<=prob1<=0.480000; -0.800000<=perr<=0.840000, 0.480000<=prob1<=0.520000; -0.800000<=perr<=0.840000, 0.520000<=prob1<=0.560000; -0.800000<=perr<=0.840000, 0.560000<=prob1<=0.600000; -0.800000<=perr<=0.840000, 0.600000<=prob1<=0.640000; -0.800000<=perr<=0.840000, 0.640000<=prob1<=0.680000; -0.800000<=perr<=0.840000, 0.680000<=prob1<=0.720000; -0.800000<=perr<=0.840000, 0.720000<=prob1<=0.760000; -0.800000<=perr<=0.840000, 0.760000<=prob1<=0.800000; -0.800000<=perr<=0.840000, 0.800000<=prob1<=0.840000; -0.800000<=perr<=0.840000, 0.840000<=prob1<=0.880000; -0.800000<=perr<=0.840000, 0.880000<=prob1<=0.920000; -0.800000<=perr<=0.840000, 0.920000<=prob1<=0.960000; -0.800000<=perr<=0.840000, 0.960000<=prob1<=0.999990; -0.840000<=perr<=0.880000, 0.000010<=prob1<=0.040000; -0.840000<=perr<=0.880000, 0.040000<=prob1<=0.080000; -0.840000<=perr<=0.880000, 0.080000<=prob1<=0.120000; -0.840000<=perr<=0.880000, 0.120000<=prob1<=0.160000; -0.840000<=perr<=0.880000, 0.160000<=prob1<=0.200000; -0.840000<=perr<=0.880000, 0.200000<=prob1<=0.240000; -0.840000<=perr<=0.880000, 0.240000<=prob1<=0.280000; -0.840000<=perr<=0.880000, 0.280000<=prob1<=0.320000; -0.840000<=perr<=0.880000, 0.320000<=prob1<=0.360000; -0.840000<=perr<=0.880000, 0.360000<=prob1<=0.400000; -0.840000<=perr<=0.880000, 0.400000<=prob1<=0.440000; -0.840000<=perr<=0.880000, 0.440000<=prob1<=0.480000; -0.840000<=perr<=0.880000, 0.480000<=prob1<=0.520000; -0.840000<=perr<=0.880000, 0.520000<=prob1<=0.560000; -0.840000<=perr<=0.880000, 0.560000<=prob1<=0.600000; -0.840000<=perr<=0.880000, 0.600000<=prob1<=0.640000; -0.840000<=perr<=0.880000, 0.640000<=prob1<=0.680000; -0.840000<=perr<=0.880000, 0.680000<=prob1<=0.720000; -0.840000<=perr<=0.880000, 0.720000<=prob1<=0.760000; -0.840000<=perr<=0.880000, 0.760000<=prob1<=0.800000; -0.840000<=perr<=0.880000, 0.800000<=prob1<=0.840000; -0.840000<=perr<=0.880000, 0.840000<=prob1<=0.880000; -0.840000<=perr<=0.880000, 0.880000<=prob1<=0.920000; -0.840000<=perr<=0.880000, 0.920000<=prob1<=0.960000; -0.840000<=perr<=0.880000, 0.960000<=prob1<=0.999990; -0.880000<=perr<=0.920000, 0.000010<=prob1<=0.040000; -0.880000<=perr<=0.920000, 0.040000<=prob1<=0.080000; -0.880000<=perr<=0.920000, 0.080000<=prob1<=0.120000; -0.880000<=perr<=0.920000, 0.120000<=prob1<=0.160000; -0.880000<=perr<=0.920000, 0.160000<=prob1<=0.200000; -0.880000<=perr<=0.920000, 0.200000<=prob1<=0.240000; -0.880000<=perr<=0.920000, 0.240000<=prob1<=0.280000; -0.880000<=perr<=0.920000, 0.280000<=prob1<=0.320000; -0.880000<=perr<=0.920000, 0.320000<=prob1<=0.360000; -0.880000<=perr<=0.920000, 0.360000<=prob1<=0.400000; -0.880000<=perr<=0.920000, 0.400000<=prob1<=0.440000; -0.880000<=perr<=0.920000, 0.440000<=prob1<=0.480000; -0.880000<=perr<=0.920000, 0.480000<=prob1<=0.520000; -0.880000<=perr<=0.920000, 0.520000<=prob1<=0.560000; -0.880000<=perr<=0.920000, 0.560000<=prob1<=0.600000; -0.880000<=perr<=0.920000, 0.600000<=prob1<=0.640000; -0.880000<=perr<=0.920000, 0.640000<=prob1<=0.680000; -0.880000<=perr<=0.920000, 0.680000<=prob1<=0.720000; -0.880000<=perr<=0.920000, 0.720000<=prob1<=0.760000; -0.880000<=perr<=0.920000, 0.760000<=prob1<=0.800000; -0.880000<=perr<=0.920000, 0.800000<=prob1<=0.840000; -0.880000<=perr<=0.920000, 0.840000<=prob1<=0.880000; -0.880000<=perr<=0.920000, 0.880000<=prob1<=0.920000; -0.880000<=perr<=0.920000, 0.920000<=prob1<=0.960000; -0.880000<=perr<=0.920000, 0.960000<=prob1<=0.999990; -0.920000<=perr<=0.960000, 0.000010<=prob1<=0.040000; -0.920000<=perr<=0.960000, 0.040000<=prob1<=0.080000; -0.920000<=perr<=0.960000, 0.080000<=prob1<=0.120000; -0.920000<=perr<=0.960000, 0.120000<=prob1<=0.160000; -0.920000<=perr<=0.960000, 0.160000<=prob1<=0.200000; -0.920000<=perr<=0.960000, 0.200000<=prob1<=0.240000; -0.920000<=perr<=0.960000, 0.240000<=prob1<=0.280000; -0.920000<=perr<=0.960000, 0.280000<=prob1<=0.320000; -0.920000<=perr<=0.960000, 0.320000<=prob1<=0.360000; -0.920000<=perr<=0.960000, 0.360000<=prob1<=0.400000; -0.920000<=perr<=0.960000, 0.400000<=prob1<=0.440000; -0.920000<=perr<=0.960000, 0.440000<=prob1<=0.480000; -0.920000<=perr<=0.960000, 0.480000<=prob1<=0.520000; -0.920000<=perr<=0.960000, 0.520000<=prob1<=0.560000; -0.920000<=perr<=0.960000, 0.560000<=prob1<=0.600000; -0.920000<=perr<=0.960000, 0.600000<=prob1<=0.640000; -0.920000<=perr<=0.960000, 0.640000<=prob1<=0.680000; -0.920000<=perr<=0.960000, 0.680000<=prob1<=0.720000; -0.920000<=perr<=0.960000, 0.720000<=prob1<=0.760000; -0.920000<=perr<=0.960000, 0.760000<=prob1<=0.800000; -0.920000<=perr<=0.960000, 0.800000<=prob1<=0.840000; -0.920000<=perr<=0.960000, 0.840000<=prob1<=0.880000; -0.920000<=perr<=0.960000, 0.880000<=prob1<=0.920000; -0.920000<=perr<=0.960000, 0.920000<=prob1<=0.960000; -0.920000<=perr<=0.960000, 0.960000<=prob1<=0.999990; -0.960000<=perr<=0.999990, 0.000010<=prob1<=0.040000; -0.960000<=perr<=0.999990, 0.040000<=prob1<=0.080000; -0.960000<=perr<=0.999990, 0.080000<=prob1<=0.120000; -0.960000<=perr<=0.999990, 0.120000<=prob1<=0.160000; -0.960000<=perr<=0.999990, 0.160000<=prob1<=0.200000; -0.960000<=perr<=0.999990, 0.200000<=prob1<=0.240000; -0.960000<=perr<=0.999990, 0.240000<=prob1<=0.280000; -0.960000<=perr<=0.999990, 0.280000<=prob1<=0.320000; -0.960000<=perr<=0.999990, 0.320000<=prob1<=0.360000; -0.960000<=perr<=0.999990, 0.360000<=prob1<=0.400000; -0.960000<=perr<=0.999990, 0.400000<=prob1<=0.440000; -0.960000<=perr<=0.999990, 0.440000<=prob1<=0.480000; -0.960000<=perr<=0.999990, 0.480000<=prob1<=0.520000; -0.960000<=perr<=0.999990, 0.520000<=prob1<=0.560000; -0.960000<=perr<=0.999990, 0.560000<=prob1<=0.600000; -0.960000<=perr<=0.999990, 0.600000<=prob1<=0.640000; -0.960000<=perr<=0.999990, 0.640000<=prob1<=0.680000; -0.960000<=perr<=0.999990, 0.680000<=prob1<=0.720000; -0.960000<=perr<=0.999990, 0.720000<=prob1<=0.760000; -0.960000<=perr<=0.999990, 0.760000<=prob1<=0.800000; -0.960000<=perr<=0.999990, 0.800000<=prob1<=0.840000; -0.960000<=perr<=0.999990, 0.840000<=prob1<=0.880000; -0.960000<=perr<=0.999990, 0.880000<=prob1<=0.920000; -0.960000<=perr<=0.999990, 0.920000<=prob1<=0.960000; -0.960000<=perr<=0.999990, 0.960000<=prob1<=0.999990; diff --git a/examples/pdtmc/nand/nand_space.txt b/examples/pdtmc/nand/nand_space.txt deleted file mode 100644 index fcd54b798..000000000 --- a/examples/pdtmc/nand/nand_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=perr<=0.999990, 0.000010<=prob1<=0.999990; - diff --git a/examples/pmdp/brp/brp.pm b/examples/pmdp/brp/brp.pm deleted file mode 100644 index 2722cb0ee..000000000 --- a/examples/pmdp/brp/brp.pm +++ /dev/null @@ -1,139 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 -// Modified by Ernst Moritz Hahn (emh@cs.uni-sb.de) - -mdp -//dtmc - -// number of chunks -const int N; -// maximum number of retransmissions -const int MAX; - -// reliability of channels -const double pL; -const double pK; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -module checker - - T : bool init false; - - [NewFile] (T=false) -> (T'=false); - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - - diff --git a/examples/pmdp/brp/brp.prctl b/examples/pmdp/brp/brp.prctl deleted file mode 100644 index 7278b1e7f..000000000 --- a/examples/pmdp/brp/brp.prctl +++ /dev/null @@ -1,2 +0,0 @@ -P<0.5 [ F (s=5 & T) ] - diff --git a/examples/pmdp/brp/brp16_2.pm b/examples/pmdp/brp/brp16_2.pm deleted file mode 100644 index 2141803ae..000000000 --- a/examples/pmdp/brp/brp16_2.pm +++ /dev/null @@ -1,139 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 -// Modified by Ernst Moritz Hahn (emh@cs.uni-sb.de) - -mdp -//dtmc - -// number of chunks -const int N = 16; -// maximum number of retransmissions -const int MAX = 2; - -// reliability of channels -const double pL; -const double pK; - -global T : bool; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -module checker - - [NewFile] (T=false) -> (T'=false); - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - - diff --git a/examples/pmdp/brp/brp256_5.pm b/examples/pmdp/brp/brp256_5.pm deleted file mode 100644 index dd98aee83..000000000 --- a/examples/pmdp/brp/brp256_5.pm +++ /dev/null @@ -1,139 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 -// Modified by Ernst Moritz Hahn (emh@cs.uni-sb.de) - -mdp -//dtmc - -// number of chunks -const int N = 256; -// maximum number of retransmissions -const int MAX = 5; - -// reliability of channels -const double pL; -const double pK; - -global T : bool; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -module checker - - [NewFile] (T=false) -> (T'=false); - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - - diff --git a/examples/pmdp/brp/brp512_5.pm b/examples/pmdp/brp/brp512_5.pm deleted file mode 100644 index 63beec6d5..000000000 --- a/examples/pmdp/brp/brp512_5.pm +++ /dev/null @@ -1,139 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 -// Modified by Ernst Moritz Hahn (emh@cs.uni-sb.de) - -mdp -//dtmc - -// number of chunks -const int N = 512; -// maximum number of retransmissions -const int MAX = 5; - -// reliability of channels -const double pL; -const double pK; - -global T : bool; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -module checker - - [NewFile] (T=false) -> (T'=false); - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - - diff --git a/examples/pmdp/brp/brp64_4.pm b/examples/pmdp/brp/brp64_4.pm deleted file mode 100644 index e75829359..000000000 --- a/examples/pmdp/brp/brp64_4.pm +++ /dev/null @@ -1,139 +0,0 @@ -// bounded retransmission protocol [D'AJJL01] -// gxn/dxp 23/05/2001 -// Modified by Ernst Moritz Hahn (emh@cs.uni-sb.de) - -mdp -//dtmc - -// number of chunks -const int N = 64; -// maximum number of retransmissions -const int MAX = 4; - -// reliability of channels -const double pL; -const double pK; - -global T : bool; - -module sender - - s : [0..6]; - // 0 idle - // 1 next_frame - // 2 wait_ack - // 3 retransmit - // 4 success - // 5 error - // 6 wait sync - srep : [0..3]; - // 0 bottom - // 1 not ok (nok) - // 2 do not know (dk) - // 3 ok (ok) - nrtr : [0..MAX]; - i : [0..N]; - bs : bool; - s_ab : bool; - fs : bool; - ls : bool; - - // idle - [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); - // next_frame - [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); - // wait_ack - [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); - [TO_Msg] (s=2) -> (s'=3); - [TO_Ack] (s=2) -> (s'=3); - // retransmit - [aF] (s=3) & (nrtr (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); - [] (s=3) & (nrtr=MAX) & (i (s'=5) & (srep'=1); - [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); - // success - [] (s=4) & (i (s'=1) & (i'=i+1); - [] (s=4) & (i=N) -> (s'=0) & (srep'=3); - // error - [SyncWait] (s=5) -> (s'=6); - // wait sync - [SyncWait] (s=6) -> (s'=0) & (s_ab'=false); - -endmodule - -module receiver - - r : [0..5]; - // 0 new_file - // 1 fst_safe - // 2 frame_received - // 3 frame_reported - // 4 idle - // 5 resync - rrep : [0..4]; - // 0 bottom - // 1 fst - // 2 inc - // 3 ok - // 4 nok - fr : bool; - lr : bool; - br : bool; - r_ab : bool; - recv : bool; - - - // new_file - [SyncWait] (r=0) -> (r'=0); - [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - // fst_safe_frame - [] (r=1) -> (r'=2) & (r_ab'=br); - // frame_received - [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); - [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); - [aA] (r=2) & !(r_ab=br) -> (r'=4); - // frame_reported - [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); - // idle - [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); - [SyncWait] (r=4) & (ls=true) -> (r'=5); - [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); - // resync - [SyncWait] (r=5) -> (r'=0) & (rrep'=0); - -endmodule - -module checker - - [NewFile] (T=false) -> (T'=false); - [NewFile] (T=false) -> (T'=true); - -endmodule - -module channelK - - k : [0..2]; - - // idle - [aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); - // sending - [aG] (k=1) -> (k'=0); - // lost - [TO_Msg] (k=2) -> (k'=0); - -endmodule - -module channelL - - l : [0..2]; - - // idle - [aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); - // sending - [aB] (l=1) -> (l'=0); - // lost - [TO_Ack] (l=2) -> (l'=0); - -endmodule - - diff --git a/examples/pmdp/brp/brp_regions.txt b/examples/pmdp/brp/brp_regions.txt deleted file mode 100644 index c1c19ee3b..000000000 --- a/examples/pmdp/brp/brp_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=pL<=0.040000, 0.000010<=pK<=0.040000; -0.000010<=pL<=0.040000, 0.040000<=pK<=0.080000; -0.000010<=pL<=0.040000, 0.080000<=pK<=0.120000; -0.000010<=pL<=0.040000, 0.120000<=pK<=0.160000; -0.000010<=pL<=0.040000, 0.160000<=pK<=0.200000; -0.000010<=pL<=0.040000, 0.200000<=pK<=0.240000; -0.000010<=pL<=0.040000, 0.240000<=pK<=0.280000; -0.000010<=pL<=0.040000, 0.280000<=pK<=0.320000; -0.000010<=pL<=0.040000, 0.320000<=pK<=0.360000; -0.000010<=pL<=0.040000, 0.360000<=pK<=0.400000; -0.000010<=pL<=0.040000, 0.400000<=pK<=0.440000; -0.000010<=pL<=0.040000, 0.440000<=pK<=0.480000; -0.000010<=pL<=0.040000, 0.480000<=pK<=0.520000; -0.000010<=pL<=0.040000, 0.520000<=pK<=0.560000; -0.000010<=pL<=0.040000, 0.560000<=pK<=0.600000; -0.000010<=pL<=0.040000, 0.600000<=pK<=0.640000; -0.000010<=pL<=0.040000, 0.640000<=pK<=0.680000; -0.000010<=pL<=0.040000, 0.680000<=pK<=0.720000; -0.000010<=pL<=0.040000, 0.720000<=pK<=0.760000; -0.000010<=pL<=0.040000, 0.760000<=pK<=0.800000; -0.000010<=pL<=0.040000, 0.800000<=pK<=0.840000; -0.000010<=pL<=0.040000, 0.840000<=pK<=0.880000; -0.000010<=pL<=0.040000, 0.880000<=pK<=0.920000; -0.000010<=pL<=0.040000, 0.920000<=pK<=0.960000; -0.000010<=pL<=0.040000, 0.960000<=pK<=0.999990; -0.040000<=pL<=0.080000, 0.000010<=pK<=0.040000; -0.040000<=pL<=0.080000, 0.040000<=pK<=0.080000; -0.040000<=pL<=0.080000, 0.080000<=pK<=0.120000; -0.040000<=pL<=0.080000, 0.120000<=pK<=0.160000; -0.040000<=pL<=0.080000, 0.160000<=pK<=0.200000; -0.040000<=pL<=0.080000, 0.200000<=pK<=0.240000; -0.040000<=pL<=0.080000, 0.240000<=pK<=0.280000; -0.040000<=pL<=0.080000, 0.280000<=pK<=0.320000; -0.040000<=pL<=0.080000, 0.320000<=pK<=0.360000; -0.040000<=pL<=0.080000, 0.360000<=pK<=0.400000; -0.040000<=pL<=0.080000, 0.400000<=pK<=0.440000; -0.040000<=pL<=0.080000, 0.440000<=pK<=0.480000; -0.040000<=pL<=0.080000, 0.480000<=pK<=0.520000; -0.040000<=pL<=0.080000, 0.520000<=pK<=0.560000; -0.040000<=pL<=0.080000, 0.560000<=pK<=0.600000; -0.040000<=pL<=0.080000, 0.600000<=pK<=0.640000; -0.040000<=pL<=0.080000, 0.640000<=pK<=0.680000; -0.040000<=pL<=0.080000, 0.680000<=pK<=0.720000; -0.040000<=pL<=0.080000, 0.720000<=pK<=0.760000; -0.040000<=pL<=0.080000, 0.760000<=pK<=0.800000; -0.040000<=pL<=0.080000, 0.800000<=pK<=0.840000; -0.040000<=pL<=0.080000, 0.840000<=pK<=0.880000; -0.040000<=pL<=0.080000, 0.880000<=pK<=0.920000; -0.040000<=pL<=0.080000, 0.920000<=pK<=0.960000; -0.040000<=pL<=0.080000, 0.960000<=pK<=0.999990; -0.080000<=pL<=0.120000, 0.000010<=pK<=0.040000; -0.080000<=pL<=0.120000, 0.040000<=pK<=0.080000; -0.080000<=pL<=0.120000, 0.080000<=pK<=0.120000; -0.080000<=pL<=0.120000, 0.120000<=pK<=0.160000; -0.080000<=pL<=0.120000, 0.160000<=pK<=0.200000; -0.080000<=pL<=0.120000, 0.200000<=pK<=0.240000; -0.080000<=pL<=0.120000, 0.240000<=pK<=0.280000; -0.080000<=pL<=0.120000, 0.280000<=pK<=0.320000; -0.080000<=pL<=0.120000, 0.320000<=pK<=0.360000; -0.080000<=pL<=0.120000, 0.360000<=pK<=0.400000; -0.080000<=pL<=0.120000, 0.400000<=pK<=0.440000; -0.080000<=pL<=0.120000, 0.440000<=pK<=0.480000; -0.080000<=pL<=0.120000, 0.480000<=pK<=0.520000; -0.080000<=pL<=0.120000, 0.520000<=pK<=0.560000; -0.080000<=pL<=0.120000, 0.560000<=pK<=0.600000; -0.080000<=pL<=0.120000, 0.600000<=pK<=0.640000; -0.080000<=pL<=0.120000, 0.640000<=pK<=0.680000; -0.080000<=pL<=0.120000, 0.680000<=pK<=0.720000; -0.080000<=pL<=0.120000, 0.720000<=pK<=0.760000; -0.080000<=pL<=0.120000, 0.760000<=pK<=0.800000; -0.080000<=pL<=0.120000, 0.800000<=pK<=0.840000; -0.080000<=pL<=0.120000, 0.840000<=pK<=0.880000; -0.080000<=pL<=0.120000, 0.880000<=pK<=0.920000; -0.080000<=pL<=0.120000, 0.920000<=pK<=0.960000; -0.080000<=pL<=0.120000, 0.960000<=pK<=0.999990; -0.120000<=pL<=0.160000, 0.000010<=pK<=0.040000; -0.120000<=pL<=0.160000, 0.040000<=pK<=0.080000; -0.120000<=pL<=0.160000, 0.080000<=pK<=0.120000; -0.120000<=pL<=0.160000, 0.120000<=pK<=0.160000; -0.120000<=pL<=0.160000, 0.160000<=pK<=0.200000; -0.120000<=pL<=0.160000, 0.200000<=pK<=0.240000; -0.120000<=pL<=0.160000, 0.240000<=pK<=0.280000; -0.120000<=pL<=0.160000, 0.280000<=pK<=0.320000; -0.120000<=pL<=0.160000, 0.320000<=pK<=0.360000; -0.120000<=pL<=0.160000, 0.360000<=pK<=0.400000; -0.120000<=pL<=0.160000, 0.400000<=pK<=0.440000; -0.120000<=pL<=0.160000, 0.440000<=pK<=0.480000; -0.120000<=pL<=0.160000, 0.480000<=pK<=0.520000; -0.120000<=pL<=0.160000, 0.520000<=pK<=0.560000; -0.120000<=pL<=0.160000, 0.560000<=pK<=0.600000; -0.120000<=pL<=0.160000, 0.600000<=pK<=0.640000; -0.120000<=pL<=0.160000, 0.640000<=pK<=0.680000; -0.120000<=pL<=0.160000, 0.680000<=pK<=0.720000; -0.120000<=pL<=0.160000, 0.720000<=pK<=0.760000; -0.120000<=pL<=0.160000, 0.760000<=pK<=0.800000; -0.120000<=pL<=0.160000, 0.800000<=pK<=0.840000; -0.120000<=pL<=0.160000, 0.840000<=pK<=0.880000; -0.120000<=pL<=0.160000, 0.880000<=pK<=0.920000; -0.120000<=pL<=0.160000, 0.920000<=pK<=0.960000; -0.120000<=pL<=0.160000, 0.960000<=pK<=0.999990; -0.160000<=pL<=0.200000, 0.000010<=pK<=0.040000; -0.160000<=pL<=0.200000, 0.040000<=pK<=0.080000; -0.160000<=pL<=0.200000, 0.080000<=pK<=0.120000; -0.160000<=pL<=0.200000, 0.120000<=pK<=0.160000; -0.160000<=pL<=0.200000, 0.160000<=pK<=0.200000; -0.160000<=pL<=0.200000, 0.200000<=pK<=0.240000; -0.160000<=pL<=0.200000, 0.240000<=pK<=0.280000; -0.160000<=pL<=0.200000, 0.280000<=pK<=0.320000; -0.160000<=pL<=0.200000, 0.320000<=pK<=0.360000; -0.160000<=pL<=0.200000, 0.360000<=pK<=0.400000; -0.160000<=pL<=0.200000, 0.400000<=pK<=0.440000; -0.160000<=pL<=0.200000, 0.440000<=pK<=0.480000; -0.160000<=pL<=0.200000, 0.480000<=pK<=0.520000; -0.160000<=pL<=0.200000, 0.520000<=pK<=0.560000; -0.160000<=pL<=0.200000, 0.560000<=pK<=0.600000; -0.160000<=pL<=0.200000, 0.600000<=pK<=0.640000; -0.160000<=pL<=0.200000, 0.640000<=pK<=0.680000; -0.160000<=pL<=0.200000, 0.680000<=pK<=0.720000; -0.160000<=pL<=0.200000, 0.720000<=pK<=0.760000; -0.160000<=pL<=0.200000, 0.760000<=pK<=0.800000; -0.160000<=pL<=0.200000, 0.800000<=pK<=0.840000; -0.160000<=pL<=0.200000, 0.840000<=pK<=0.880000; -0.160000<=pL<=0.200000, 0.880000<=pK<=0.920000; -0.160000<=pL<=0.200000, 0.920000<=pK<=0.960000; -0.160000<=pL<=0.200000, 0.960000<=pK<=0.999990; -0.200000<=pL<=0.240000, 0.000010<=pK<=0.040000; -0.200000<=pL<=0.240000, 0.040000<=pK<=0.080000; -0.200000<=pL<=0.240000, 0.080000<=pK<=0.120000; -0.200000<=pL<=0.240000, 0.120000<=pK<=0.160000; -0.200000<=pL<=0.240000, 0.160000<=pK<=0.200000; -0.200000<=pL<=0.240000, 0.200000<=pK<=0.240000; -0.200000<=pL<=0.240000, 0.240000<=pK<=0.280000; -0.200000<=pL<=0.240000, 0.280000<=pK<=0.320000; -0.200000<=pL<=0.240000, 0.320000<=pK<=0.360000; -0.200000<=pL<=0.240000, 0.360000<=pK<=0.400000; -0.200000<=pL<=0.240000, 0.400000<=pK<=0.440000; -0.200000<=pL<=0.240000, 0.440000<=pK<=0.480000; -0.200000<=pL<=0.240000, 0.480000<=pK<=0.520000; -0.200000<=pL<=0.240000, 0.520000<=pK<=0.560000; -0.200000<=pL<=0.240000, 0.560000<=pK<=0.600000; -0.200000<=pL<=0.240000, 0.600000<=pK<=0.640000; -0.200000<=pL<=0.240000, 0.640000<=pK<=0.680000; -0.200000<=pL<=0.240000, 0.680000<=pK<=0.720000; -0.200000<=pL<=0.240000, 0.720000<=pK<=0.760000; -0.200000<=pL<=0.240000, 0.760000<=pK<=0.800000; -0.200000<=pL<=0.240000, 0.800000<=pK<=0.840000; -0.200000<=pL<=0.240000, 0.840000<=pK<=0.880000; -0.200000<=pL<=0.240000, 0.880000<=pK<=0.920000; -0.200000<=pL<=0.240000, 0.920000<=pK<=0.960000; -0.200000<=pL<=0.240000, 0.960000<=pK<=0.999990; -0.240000<=pL<=0.280000, 0.000010<=pK<=0.040000; -0.240000<=pL<=0.280000, 0.040000<=pK<=0.080000; -0.240000<=pL<=0.280000, 0.080000<=pK<=0.120000; -0.240000<=pL<=0.280000, 0.120000<=pK<=0.160000; -0.240000<=pL<=0.280000, 0.160000<=pK<=0.200000; -0.240000<=pL<=0.280000, 0.200000<=pK<=0.240000; -0.240000<=pL<=0.280000, 0.240000<=pK<=0.280000; -0.240000<=pL<=0.280000, 0.280000<=pK<=0.320000; -0.240000<=pL<=0.280000, 0.320000<=pK<=0.360000; -0.240000<=pL<=0.280000, 0.360000<=pK<=0.400000; -0.240000<=pL<=0.280000, 0.400000<=pK<=0.440000; -0.240000<=pL<=0.280000, 0.440000<=pK<=0.480000; -0.240000<=pL<=0.280000, 0.480000<=pK<=0.520000; -0.240000<=pL<=0.280000, 0.520000<=pK<=0.560000; -0.240000<=pL<=0.280000, 0.560000<=pK<=0.600000; -0.240000<=pL<=0.280000, 0.600000<=pK<=0.640000; -0.240000<=pL<=0.280000, 0.640000<=pK<=0.680000; -0.240000<=pL<=0.280000, 0.680000<=pK<=0.720000; -0.240000<=pL<=0.280000, 0.720000<=pK<=0.760000; -0.240000<=pL<=0.280000, 0.760000<=pK<=0.800000; -0.240000<=pL<=0.280000, 0.800000<=pK<=0.840000; -0.240000<=pL<=0.280000, 0.840000<=pK<=0.880000; -0.240000<=pL<=0.280000, 0.880000<=pK<=0.920000; -0.240000<=pL<=0.280000, 0.920000<=pK<=0.960000; -0.240000<=pL<=0.280000, 0.960000<=pK<=0.999990; -0.280000<=pL<=0.320000, 0.000010<=pK<=0.040000; -0.280000<=pL<=0.320000, 0.040000<=pK<=0.080000; -0.280000<=pL<=0.320000, 0.080000<=pK<=0.120000; -0.280000<=pL<=0.320000, 0.120000<=pK<=0.160000; -0.280000<=pL<=0.320000, 0.160000<=pK<=0.200000; -0.280000<=pL<=0.320000, 0.200000<=pK<=0.240000; -0.280000<=pL<=0.320000, 0.240000<=pK<=0.280000; -0.280000<=pL<=0.320000, 0.280000<=pK<=0.320000; -0.280000<=pL<=0.320000, 0.320000<=pK<=0.360000; -0.280000<=pL<=0.320000, 0.360000<=pK<=0.400000; -0.280000<=pL<=0.320000, 0.400000<=pK<=0.440000; -0.280000<=pL<=0.320000, 0.440000<=pK<=0.480000; -0.280000<=pL<=0.320000, 0.480000<=pK<=0.520000; -0.280000<=pL<=0.320000, 0.520000<=pK<=0.560000; -0.280000<=pL<=0.320000, 0.560000<=pK<=0.600000; -0.280000<=pL<=0.320000, 0.600000<=pK<=0.640000; -0.280000<=pL<=0.320000, 0.640000<=pK<=0.680000; -0.280000<=pL<=0.320000, 0.680000<=pK<=0.720000; -0.280000<=pL<=0.320000, 0.720000<=pK<=0.760000; -0.280000<=pL<=0.320000, 0.760000<=pK<=0.800000; -0.280000<=pL<=0.320000, 0.800000<=pK<=0.840000; -0.280000<=pL<=0.320000, 0.840000<=pK<=0.880000; -0.280000<=pL<=0.320000, 0.880000<=pK<=0.920000; -0.280000<=pL<=0.320000, 0.920000<=pK<=0.960000; -0.280000<=pL<=0.320000, 0.960000<=pK<=0.999990; -0.320000<=pL<=0.360000, 0.000010<=pK<=0.040000; -0.320000<=pL<=0.360000, 0.040000<=pK<=0.080000; -0.320000<=pL<=0.360000, 0.080000<=pK<=0.120000; -0.320000<=pL<=0.360000, 0.120000<=pK<=0.160000; -0.320000<=pL<=0.360000, 0.160000<=pK<=0.200000; -0.320000<=pL<=0.360000, 0.200000<=pK<=0.240000; -0.320000<=pL<=0.360000, 0.240000<=pK<=0.280000; -0.320000<=pL<=0.360000, 0.280000<=pK<=0.320000; -0.320000<=pL<=0.360000, 0.320000<=pK<=0.360000; -0.320000<=pL<=0.360000, 0.360000<=pK<=0.400000; -0.320000<=pL<=0.360000, 0.400000<=pK<=0.440000; -0.320000<=pL<=0.360000, 0.440000<=pK<=0.480000; -0.320000<=pL<=0.360000, 0.480000<=pK<=0.520000; -0.320000<=pL<=0.360000, 0.520000<=pK<=0.560000; -0.320000<=pL<=0.360000, 0.560000<=pK<=0.600000; -0.320000<=pL<=0.360000, 0.600000<=pK<=0.640000; -0.320000<=pL<=0.360000, 0.640000<=pK<=0.680000; -0.320000<=pL<=0.360000, 0.680000<=pK<=0.720000; -0.320000<=pL<=0.360000, 0.720000<=pK<=0.760000; -0.320000<=pL<=0.360000, 0.760000<=pK<=0.800000; -0.320000<=pL<=0.360000, 0.800000<=pK<=0.840000; -0.320000<=pL<=0.360000, 0.840000<=pK<=0.880000; -0.320000<=pL<=0.360000, 0.880000<=pK<=0.920000; -0.320000<=pL<=0.360000, 0.920000<=pK<=0.960000; -0.320000<=pL<=0.360000, 0.960000<=pK<=0.999990; -0.360000<=pL<=0.400000, 0.000010<=pK<=0.040000; -0.360000<=pL<=0.400000, 0.040000<=pK<=0.080000; -0.360000<=pL<=0.400000, 0.080000<=pK<=0.120000; -0.360000<=pL<=0.400000, 0.120000<=pK<=0.160000; -0.360000<=pL<=0.400000, 0.160000<=pK<=0.200000; -0.360000<=pL<=0.400000, 0.200000<=pK<=0.240000; -0.360000<=pL<=0.400000, 0.240000<=pK<=0.280000; -0.360000<=pL<=0.400000, 0.280000<=pK<=0.320000; -0.360000<=pL<=0.400000, 0.320000<=pK<=0.360000; -0.360000<=pL<=0.400000, 0.360000<=pK<=0.400000; -0.360000<=pL<=0.400000, 0.400000<=pK<=0.440000; -0.360000<=pL<=0.400000, 0.440000<=pK<=0.480000; -0.360000<=pL<=0.400000, 0.480000<=pK<=0.520000; -0.360000<=pL<=0.400000, 0.520000<=pK<=0.560000; -0.360000<=pL<=0.400000, 0.560000<=pK<=0.600000; -0.360000<=pL<=0.400000, 0.600000<=pK<=0.640000; -0.360000<=pL<=0.400000, 0.640000<=pK<=0.680000; -0.360000<=pL<=0.400000, 0.680000<=pK<=0.720000; -0.360000<=pL<=0.400000, 0.720000<=pK<=0.760000; -0.360000<=pL<=0.400000, 0.760000<=pK<=0.800000; -0.360000<=pL<=0.400000, 0.800000<=pK<=0.840000; -0.360000<=pL<=0.400000, 0.840000<=pK<=0.880000; -0.360000<=pL<=0.400000, 0.880000<=pK<=0.920000; -0.360000<=pL<=0.400000, 0.920000<=pK<=0.960000; -0.360000<=pL<=0.400000, 0.960000<=pK<=0.999990; -0.400000<=pL<=0.440000, 0.000010<=pK<=0.040000; -0.400000<=pL<=0.440000, 0.040000<=pK<=0.080000; -0.400000<=pL<=0.440000, 0.080000<=pK<=0.120000; -0.400000<=pL<=0.440000, 0.120000<=pK<=0.160000; -0.400000<=pL<=0.440000, 0.160000<=pK<=0.200000; -0.400000<=pL<=0.440000, 0.200000<=pK<=0.240000; -0.400000<=pL<=0.440000, 0.240000<=pK<=0.280000; -0.400000<=pL<=0.440000, 0.280000<=pK<=0.320000; -0.400000<=pL<=0.440000, 0.320000<=pK<=0.360000; -0.400000<=pL<=0.440000, 0.360000<=pK<=0.400000; -0.400000<=pL<=0.440000, 0.400000<=pK<=0.440000; -0.400000<=pL<=0.440000, 0.440000<=pK<=0.480000; -0.400000<=pL<=0.440000, 0.480000<=pK<=0.520000; -0.400000<=pL<=0.440000, 0.520000<=pK<=0.560000; -0.400000<=pL<=0.440000, 0.560000<=pK<=0.600000; -0.400000<=pL<=0.440000, 0.600000<=pK<=0.640000; -0.400000<=pL<=0.440000, 0.640000<=pK<=0.680000; -0.400000<=pL<=0.440000, 0.680000<=pK<=0.720000; -0.400000<=pL<=0.440000, 0.720000<=pK<=0.760000; -0.400000<=pL<=0.440000, 0.760000<=pK<=0.800000; -0.400000<=pL<=0.440000, 0.800000<=pK<=0.840000; -0.400000<=pL<=0.440000, 0.840000<=pK<=0.880000; -0.400000<=pL<=0.440000, 0.880000<=pK<=0.920000; -0.400000<=pL<=0.440000, 0.920000<=pK<=0.960000; -0.400000<=pL<=0.440000, 0.960000<=pK<=0.999990; -0.440000<=pL<=0.480000, 0.000010<=pK<=0.040000; -0.440000<=pL<=0.480000, 0.040000<=pK<=0.080000; -0.440000<=pL<=0.480000, 0.080000<=pK<=0.120000; -0.440000<=pL<=0.480000, 0.120000<=pK<=0.160000; -0.440000<=pL<=0.480000, 0.160000<=pK<=0.200000; -0.440000<=pL<=0.480000, 0.200000<=pK<=0.240000; -0.440000<=pL<=0.480000, 0.240000<=pK<=0.280000; -0.440000<=pL<=0.480000, 0.280000<=pK<=0.320000; -0.440000<=pL<=0.480000, 0.320000<=pK<=0.360000; -0.440000<=pL<=0.480000, 0.360000<=pK<=0.400000; -0.440000<=pL<=0.480000, 0.400000<=pK<=0.440000; -0.440000<=pL<=0.480000, 0.440000<=pK<=0.480000; -0.440000<=pL<=0.480000, 0.480000<=pK<=0.520000; -0.440000<=pL<=0.480000, 0.520000<=pK<=0.560000; -0.440000<=pL<=0.480000, 0.560000<=pK<=0.600000; -0.440000<=pL<=0.480000, 0.600000<=pK<=0.640000; -0.440000<=pL<=0.480000, 0.640000<=pK<=0.680000; -0.440000<=pL<=0.480000, 0.680000<=pK<=0.720000; -0.440000<=pL<=0.480000, 0.720000<=pK<=0.760000; -0.440000<=pL<=0.480000, 0.760000<=pK<=0.800000; -0.440000<=pL<=0.480000, 0.800000<=pK<=0.840000; -0.440000<=pL<=0.480000, 0.840000<=pK<=0.880000; -0.440000<=pL<=0.480000, 0.880000<=pK<=0.920000; -0.440000<=pL<=0.480000, 0.920000<=pK<=0.960000; -0.440000<=pL<=0.480000, 0.960000<=pK<=0.999990; -0.480000<=pL<=0.520000, 0.000010<=pK<=0.040000; -0.480000<=pL<=0.520000, 0.040000<=pK<=0.080000; -0.480000<=pL<=0.520000, 0.080000<=pK<=0.120000; -0.480000<=pL<=0.520000, 0.120000<=pK<=0.160000; -0.480000<=pL<=0.520000, 0.160000<=pK<=0.200000; -0.480000<=pL<=0.520000, 0.200000<=pK<=0.240000; -0.480000<=pL<=0.520000, 0.240000<=pK<=0.280000; -0.480000<=pL<=0.520000, 0.280000<=pK<=0.320000; -0.480000<=pL<=0.520000, 0.320000<=pK<=0.360000; -0.480000<=pL<=0.520000, 0.360000<=pK<=0.400000; -0.480000<=pL<=0.520000, 0.400000<=pK<=0.440000; -0.480000<=pL<=0.520000, 0.440000<=pK<=0.480000; -0.480000<=pL<=0.520000, 0.480000<=pK<=0.520000; -0.480000<=pL<=0.520000, 0.520000<=pK<=0.560000; -0.480000<=pL<=0.520000, 0.560000<=pK<=0.600000; -0.480000<=pL<=0.520000, 0.600000<=pK<=0.640000; -0.480000<=pL<=0.520000, 0.640000<=pK<=0.680000; -0.480000<=pL<=0.520000, 0.680000<=pK<=0.720000; -0.480000<=pL<=0.520000, 0.720000<=pK<=0.760000; -0.480000<=pL<=0.520000, 0.760000<=pK<=0.800000; -0.480000<=pL<=0.520000, 0.800000<=pK<=0.840000; -0.480000<=pL<=0.520000, 0.840000<=pK<=0.880000; -0.480000<=pL<=0.520000, 0.880000<=pK<=0.920000; -0.480000<=pL<=0.520000, 0.920000<=pK<=0.960000; -0.480000<=pL<=0.520000, 0.960000<=pK<=0.999990; -0.520000<=pL<=0.560000, 0.000010<=pK<=0.040000; -0.520000<=pL<=0.560000, 0.040000<=pK<=0.080000; -0.520000<=pL<=0.560000, 0.080000<=pK<=0.120000; -0.520000<=pL<=0.560000, 0.120000<=pK<=0.160000; -0.520000<=pL<=0.560000, 0.160000<=pK<=0.200000; -0.520000<=pL<=0.560000, 0.200000<=pK<=0.240000; -0.520000<=pL<=0.560000, 0.240000<=pK<=0.280000; -0.520000<=pL<=0.560000, 0.280000<=pK<=0.320000; -0.520000<=pL<=0.560000, 0.320000<=pK<=0.360000; -0.520000<=pL<=0.560000, 0.360000<=pK<=0.400000; -0.520000<=pL<=0.560000, 0.400000<=pK<=0.440000; -0.520000<=pL<=0.560000, 0.440000<=pK<=0.480000; -0.520000<=pL<=0.560000, 0.480000<=pK<=0.520000; -0.520000<=pL<=0.560000, 0.520000<=pK<=0.560000; -0.520000<=pL<=0.560000, 0.560000<=pK<=0.600000; -0.520000<=pL<=0.560000, 0.600000<=pK<=0.640000; -0.520000<=pL<=0.560000, 0.640000<=pK<=0.680000; -0.520000<=pL<=0.560000, 0.680000<=pK<=0.720000; -0.520000<=pL<=0.560000, 0.720000<=pK<=0.760000; -0.520000<=pL<=0.560000, 0.760000<=pK<=0.800000; -0.520000<=pL<=0.560000, 0.800000<=pK<=0.840000; -0.520000<=pL<=0.560000, 0.840000<=pK<=0.880000; -0.520000<=pL<=0.560000, 0.880000<=pK<=0.920000; -0.520000<=pL<=0.560000, 0.920000<=pK<=0.960000; -0.520000<=pL<=0.560000, 0.960000<=pK<=0.999990; -0.560000<=pL<=0.600000, 0.000010<=pK<=0.040000; -0.560000<=pL<=0.600000, 0.040000<=pK<=0.080000; -0.560000<=pL<=0.600000, 0.080000<=pK<=0.120000; -0.560000<=pL<=0.600000, 0.120000<=pK<=0.160000; -0.560000<=pL<=0.600000, 0.160000<=pK<=0.200000; -0.560000<=pL<=0.600000, 0.200000<=pK<=0.240000; -0.560000<=pL<=0.600000, 0.240000<=pK<=0.280000; -0.560000<=pL<=0.600000, 0.280000<=pK<=0.320000; -0.560000<=pL<=0.600000, 0.320000<=pK<=0.360000; -0.560000<=pL<=0.600000, 0.360000<=pK<=0.400000; -0.560000<=pL<=0.600000, 0.400000<=pK<=0.440000; -0.560000<=pL<=0.600000, 0.440000<=pK<=0.480000; -0.560000<=pL<=0.600000, 0.480000<=pK<=0.520000; -0.560000<=pL<=0.600000, 0.520000<=pK<=0.560000; -0.560000<=pL<=0.600000, 0.560000<=pK<=0.600000; -0.560000<=pL<=0.600000, 0.600000<=pK<=0.640000; -0.560000<=pL<=0.600000, 0.640000<=pK<=0.680000; -0.560000<=pL<=0.600000, 0.680000<=pK<=0.720000; -0.560000<=pL<=0.600000, 0.720000<=pK<=0.760000; -0.560000<=pL<=0.600000, 0.760000<=pK<=0.800000; -0.560000<=pL<=0.600000, 0.800000<=pK<=0.840000; -0.560000<=pL<=0.600000, 0.840000<=pK<=0.880000; -0.560000<=pL<=0.600000, 0.880000<=pK<=0.920000; -0.560000<=pL<=0.600000, 0.920000<=pK<=0.960000; -0.560000<=pL<=0.600000, 0.960000<=pK<=0.999990; -0.600000<=pL<=0.640000, 0.000010<=pK<=0.040000; -0.600000<=pL<=0.640000, 0.040000<=pK<=0.080000; -0.600000<=pL<=0.640000, 0.080000<=pK<=0.120000; -0.600000<=pL<=0.640000, 0.120000<=pK<=0.160000; -0.600000<=pL<=0.640000, 0.160000<=pK<=0.200000; -0.600000<=pL<=0.640000, 0.200000<=pK<=0.240000; -0.600000<=pL<=0.640000, 0.240000<=pK<=0.280000; -0.600000<=pL<=0.640000, 0.280000<=pK<=0.320000; -0.600000<=pL<=0.640000, 0.320000<=pK<=0.360000; -0.600000<=pL<=0.640000, 0.360000<=pK<=0.400000; -0.600000<=pL<=0.640000, 0.400000<=pK<=0.440000; -0.600000<=pL<=0.640000, 0.440000<=pK<=0.480000; -0.600000<=pL<=0.640000, 0.480000<=pK<=0.520000; -0.600000<=pL<=0.640000, 0.520000<=pK<=0.560000; -0.600000<=pL<=0.640000, 0.560000<=pK<=0.600000; -0.600000<=pL<=0.640000, 0.600000<=pK<=0.640000; -0.600000<=pL<=0.640000, 0.640000<=pK<=0.680000; -0.600000<=pL<=0.640000, 0.680000<=pK<=0.720000; -0.600000<=pL<=0.640000, 0.720000<=pK<=0.760000; -0.600000<=pL<=0.640000, 0.760000<=pK<=0.800000; -0.600000<=pL<=0.640000, 0.800000<=pK<=0.840000; -0.600000<=pL<=0.640000, 0.840000<=pK<=0.880000; -0.600000<=pL<=0.640000, 0.880000<=pK<=0.920000; -0.600000<=pL<=0.640000, 0.920000<=pK<=0.960000; -0.600000<=pL<=0.640000, 0.960000<=pK<=0.999990; -0.640000<=pL<=0.680000, 0.000010<=pK<=0.040000; -0.640000<=pL<=0.680000, 0.040000<=pK<=0.080000; -0.640000<=pL<=0.680000, 0.080000<=pK<=0.120000; -0.640000<=pL<=0.680000, 0.120000<=pK<=0.160000; -0.640000<=pL<=0.680000, 0.160000<=pK<=0.200000; -0.640000<=pL<=0.680000, 0.200000<=pK<=0.240000; -0.640000<=pL<=0.680000, 0.240000<=pK<=0.280000; -0.640000<=pL<=0.680000, 0.280000<=pK<=0.320000; -0.640000<=pL<=0.680000, 0.320000<=pK<=0.360000; -0.640000<=pL<=0.680000, 0.360000<=pK<=0.400000; -0.640000<=pL<=0.680000, 0.400000<=pK<=0.440000; -0.640000<=pL<=0.680000, 0.440000<=pK<=0.480000; -0.640000<=pL<=0.680000, 0.480000<=pK<=0.520000; -0.640000<=pL<=0.680000, 0.520000<=pK<=0.560000; -0.640000<=pL<=0.680000, 0.560000<=pK<=0.600000; -0.640000<=pL<=0.680000, 0.600000<=pK<=0.640000; -0.640000<=pL<=0.680000, 0.640000<=pK<=0.680000; -0.640000<=pL<=0.680000, 0.680000<=pK<=0.720000; -0.640000<=pL<=0.680000, 0.720000<=pK<=0.760000; -0.640000<=pL<=0.680000, 0.760000<=pK<=0.800000; -0.640000<=pL<=0.680000, 0.800000<=pK<=0.840000; -0.640000<=pL<=0.680000, 0.840000<=pK<=0.880000; -0.640000<=pL<=0.680000, 0.880000<=pK<=0.920000; -0.640000<=pL<=0.680000, 0.920000<=pK<=0.960000; -0.640000<=pL<=0.680000, 0.960000<=pK<=0.999990; -0.680000<=pL<=0.720000, 0.000010<=pK<=0.040000; -0.680000<=pL<=0.720000, 0.040000<=pK<=0.080000; -0.680000<=pL<=0.720000, 0.080000<=pK<=0.120000; -0.680000<=pL<=0.720000, 0.120000<=pK<=0.160000; -0.680000<=pL<=0.720000, 0.160000<=pK<=0.200000; -0.680000<=pL<=0.720000, 0.200000<=pK<=0.240000; -0.680000<=pL<=0.720000, 0.240000<=pK<=0.280000; -0.680000<=pL<=0.720000, 0.280000<=pK<=0.320000; -0.680000<=pL<=0.720000, 0.320000<=pK<=0.360000; -0.680000<=pL<=0.720000, 0.360000<=pK<=0.400000; -0.680000<=pL<=0.720000, 0.400000<=pK<=0.440000; -0.680000<=pL<=0.720000, 0.440000<=pK<=0.480000; -0.680000<=pL<=0.720000, 0.480000<=pK<=0.520000; -0.680000<=pL<=0.720000, 0.520000<=pK<=0.560000; -0.680000<=pL<=0.720000, 0.560000<=pK<=0.600000; -0.680000<=pL<=0.720000, 0.600000<=pK<=0.640000; -0.680000<=pL<=0.720000, 0.640000<=pK<=0.680000; -0.680000<=pL<=0.720000, 0.680000<=pK<=0.720000; -0.680000<=pL<=0.720000, 0.720000<=pK<=0.760000; -0.680000<=pL<=0.720000, 0.760000<=pK<=0.800000; -0.680000<=pL<=0.720000, 0.800000<=pK<=0.840000; -0.680000<=pL<=0.720000, 0.840000<=pK<=0.880000; -0.680000<=pL<=0.720000, 0.880000<=pK<=0.920000; -0.680000<=pL<=0.720000, 0.920000<=pK<=0.960000; -0.680000<=pL<=0.720000, 0.960000<=pK<=0.999990; -0.720000<=pL<=0.760000, 0.000010<=pK<=0.040000; -0.720000<=pL<=0.760000, 0.040000<=pK<=0.080000; -0.720000<=pL<=0.760000, 0.080000<=pK<=0.120000; -0.720000<=pL<=0.760000, 0.120000<=pK<=0.160000; -0.720000<=pL<=0.760000, 0.160000<=pK<=0.200000; -0.720000<=pL<=0.760000, 0.200000<=pK<=0.240000; -0.720000<=pL<=0.760000, 0.240000<=pK<=0.280000; -0.720000<=pL<=0.760000, 0.280000<=pK<=0.320000; -0.720000<=pL<=0.760000, 0.320000<=pK<=0.360000; -0.720000<=pL<=0.760000, 0.360000<=pK<=0.400000; -0.720000<=pL<=0.760000, 0.400000<=pK<=0.440000; -0.720000<=pL<=0.760000, 0.440000<=pK<=0.480000; -0.720000<=pL<=0.760000, 0.480000<=pK<=0.520000; -0.720000<=pL<=0.760000, 0.520000<=pK<=0.560000; -0.720000<=pL<=0.760000, 0.560000<=pK<=0.600000; -0.720000<=pL<=0.760000, 0.600000<=pK<=0.640000; -0.720000<=pL<=0.760000, 0.640000<=pK<=0.680000; -0.720000<=pL<=0.760000, 0.680000<=pK<=0.720000; -0.720000<=pL<=0.760000, 0.720000<=pK<=0.760000; -0.720000<=pL<=0.760000, 0.760000<=pK<=0.800000; -0.720000<=pL<=0.760000, 0.800000<=pK<=0.840000; -0.720000<=pL<=0.760000, 0.840000<=pK<=0.880000; -0.720000<=pL<=0.760000, 0.880000<=pK<=0.920000; -0.720000<=pL<=0.760000, 0.920000<=pK<=0.960000; -0.720000<=pL<=0.760000, 0.960000<=pK<=0.999990; -0.760000<=pL<=0.800000, 0.000010<=pK<=0.040000; -0.760000<=pL<=0.800000, 0.040000<=pK<=0.080000; -0.760000<=pL<=0.800000, 0.080000<=pK<=0.120000; -0.760000<=pL<=0.800000, 0.120000<=pK<=0.160000; -0.760000<=pL<=0.800000, 0.160000<=pK<=0.200000; -0.760000<=pL<=0.800000, 0.200000<=pK<=0.240000; -0.760000<=pL<=0.800000, 0.240000<=pK<=0.280000; -0.760000<=pL<=0.800000, 0.280000<=pK<=0.320000; -0.760000<=pL<=0.800000, 0.320000<=pK<=0.360000; -0.760000<=pL<=0.800000, 0.360000<=pK<=0.400000; -0.760000<=pL<=0.800000, 0.400000<=pK<=0.440000; -0.760000<=pL<=0.800000, 0.440000<=pK<=0.480000; -0.760000<=pL<=0.800000, 0.480000<=pK<=0.520000; -0.760000<=pL<=0.800000, 0.520000<=pK<=0.560000; -0.760000<=pL<=0.800000, 0.560000<=pK<=0.600000; -0.760000<=pL<=0.800000, 0.600000<=pK<=0.640000; -0.760000<=pL<=0.800000, 0.640000<=pK<=0.680000; -0.760000<=pL<=0.800000, 0.680000<=pK<=0.720000; -0.760000<=pL<=0.800000, 0.720000<=pK<=0.760000; -0.760000<=pL<=0.800000, 0.760000<=pK<=0.800000; -0.760000<=pL<=0.800000, 0.800000<=pK<=0.840000; -0.760000<=pL<=0.800000, 0.840000<=pK<=0.880000; -0.760000<=pL<=0.800000, 0.880000<=pK<=0.920000; -0.760000<=pL<=0.800000, 0.920000<=pK<=0.960000; -0.760000<=pL<=0.800000, 0.960000<=pK<=0.999990; -0.800000<=pL<=0.840000, 0.000010<=pK<=0.040000; -0.800000<=pL<=0.840000, 0.040000<=pK<=0.080000; -0.800000<=pL<=0.840000, 0.080000<=pK<=0.120000; -0.800000<=pL<=0.840000, 0.120000<=pK<=0.160000; -0.800000<=pL<=0.840000, 0.160000<=pK<=0.200000; -0.800000<=pL<=0.840000, 0.200000<=pK<=0.240000; -0.800000<=pL<=0.840000, 0.240000<=pK<=0.280000; -0.800000<=pL<=0.840000, 0.280000<=pK<=0.320000; -0.800000<=pL<=0.840000, 0.320000<=pK<=0.360000; -0.800000<=pL<=0.840000, 0.360000<=pK<=0.400000; -0.800000<=pL<=0.840000, 0.400000<=pK<=0.440000; -0.800000<=pL<=0.840000, 0.440000<=pK<=0.480000; -0.800000<=pL<=0.840000, 0.480000<=pK<=0.520000; -0.800000<=pL<=0.840000, 0.520000<=pK<=0.560000; -0.800000<=pL<=0.840000, 0.560000<=pK<=0.600000; -0.800000<=pL<=0.840000, 0.600000<=pK<=0.640000; -0.800000<=pL<=0.840000, 0.640000<=pK<=0.680000; -0.800000<=pL<=0.840000, 0.680000<=pK<=0.720000; -0.800000<=pL<=0.840000, 0.720000<=pK<=0.760000; -0.800000<=pL<=0.840000, 0.760000<=pK<=0.800000; -0.800000<=pL<=0.840000, 0.800000<=pK<=0.840000; -0.800000<=pL<=0.840000, 0.840000<=pK<=0.880000; -0.800000<=pL<=0.840000, 0.880000<=pK<=0.920000; -0.800000<=pL<=0.840000, 0.920000<=pK<=0.960000; -0.800000<=pL<=0.840000, 0.960000<=pK<=0.999990; -0.840000<=pL<=0.880000, 0.000010<=pK<=0.040000; -0.840000<=pL<=0.880000, 0.040000<=pK<=0.080000; -0.840000<=pL<=0.880000, 0.080000<=pK<=0.120000; -0.840000<=pL<=0.880000, 0.120000<=pK<=0.160000; -0.840000<=pL<=0.880000, 0.160000<=pK<=0.200000; -0.840000<=pL<=0.880000, 0.200000<=pK<=0.240000; -0.840000<=pL<=0.880000, 0.240000<=pK<=0.280000; -0.840000<=pL<=0.880000, 0.280000<=pK<=0.320000; -0.840000<=pL<=0.880000, 0.320000<=pK<=0.360000; -0.840000<=pL<=0.880000, 0.360000<=pK<=0.400000; -0.840000<=pL<=0.880000, 0.400000<=pK<=0.440000; -0.840000<=pL<=0.880000, 0.440000<=pK<=0.480000; -0.840000<=pL<=0.880000, 0.480000<=pK<=0.520000; -0.840000<=pL<=0.880000, 0.520000<=pK<=0.560000; -0.840000<=pL<=0.880000, 0.560000<=pK<=0.600000; -0.840000<=pL<=0.880000, 0.600000<=pK<=0.640000; -0.840000<=pL<=0.880000, 0.640000<=pK<=0.680000; -0.840000<=pL<=0.880000, 0.680000<=pK<=0.720000; -0.840000<=pL<=0.880000, 0.720000<=pK<=0.760000; -0.840000<=pL<=0.880000, 0.760000<=pK<=0.800000; -0.840000<=pL<=0.880000, 0.800000<=pK<=0.840000; -0.840000<=pL<=0.880000, 0.840000<=pK<=0.880000; -0.840000<=pL<=0.880000, 0.880000<=pK<=0.920000; -0.840000<=pL<=0.880000, 0.920000<=pK<=0.960000; -0.840000<=pL<=0.880000, 0.960000<=pK<=0.999990; -0.880000<=pL<=0.920000, 0.000010<=pK<=0.040000; -0.880000<=pL<=0.920000, 0.040000<=pK<=0.080000; -0.880000<=pL<=0.920000, 0.080000<=pK<=0.120000; -0.880000<=pL<=0.920000, 0.120000<=pK<=0.160000; -0.880000<=pL<=0.920000, 0.160000<=pK<=0.200000; -0.880000<=pL<=0.920000, 0.200000<=pK<=0.240000; -0.880000<=pL<=0.920000, 0.240000<=pK<=0.280000; -0.880000<=pL<=0.920000, 0.280000<=pK<=0.320000; -0.880000<=pL<=0.920000, 0.320000<=pK<=0.360000; -0.880000<=pL<=0.920000, 0.360000<=pK<=0.400000; -0.880000<=pL<=0.920000, 0.400000<=pK<=0.440000; -0.880000<=pL<=0.920000, 0.440000<=pK<=0.480000; -0.880000<=pL<=0.920000, 0.480000<=pK<=0.520000; -0.880000<=pL<=0.920000, 0.520000<=pK<=0.560000; -0.880000<=pL<=0.920000, 0.560000<=pK<=0.600000; -0.880000<=pL<=0.920000, 0.600000<=pK<=0.640000; -0.880000<=pL<=0.920000, 0.640000<=pK<=0.680000; -0.880000<=pL<=0.920000, 0.680000<=pK<=0.720000; -0.880000<=pL<=0.920000, 0.720000<=pK<=0.760000; -0.880000<=pL<=0.920000, 0.760000<=pK<=0.800000; -0.880000<=pL<=0.920000, 0.800000<=pK<=0.840000; -0.880000<=pL<=0.920000, 0.840000<=pK<=0.880000; -0.880000<=pL<=0.920000, 0.880000<=pK<=0.920000; -0.880000<=pL<=0.920000, 0.920000<=pK<=0.960000; -0.880000<=pL<=0.920000, 0.960000<=pK<=0.999990; -0.920000<=pL<=0.960000, 0.000010<=pK<=0.040000; -0.920000<=pL<=0.960000, 0.040000<=pK<=0.080000; -0.920000<=pL<=0.960000, 0.080000<=pK<=0.120000; -0.920000<=pL<=0.960000, 0.120000<=pK<=0.160000; -0.920000<=pL<=0.960000, 0.160000<=pK<=0.200000; -0.920000<=pL<=0.960000, 0.200000<=pK<=0.240000; -0.920000<=pL<=0.960000, 0.240000<=pK<=0.280000; -0.920000<=pL<=0.960000, 0.280000<=pK<=0.320000; -0.920000<=pL<=0.960000, 0.320000<=pK<=0.360000; -0.920000<=pL<=0.960000, 0.360000<=pK<=0.400000; -0.920000<=pL<=0.960000, 0.400000<=pK<=0.440000; -0.920000<=pL<=0.960000, 0.440000<=pK<=0.480000; -0.920000<=pL<=0.960000, 0.480000<=pK<=0.520000; -0.920000<=pL<=0.960000, 0.520000<=pK<=0.560000; -0.920000<=pL<=0.960000, 0.560000<=pK<=0.600000; -0.920000<=pL<=0.960000, 0.600000<=pK<=0.640000; -0.920000<=pL<=0.960000, 0.640000<=pK<=0.680000; -0.920000<=pL<=0.960000, 0.680000<=pK<=0.720000; -0.920000<=pL<=0.960000, 0.720000<=pK<=0.760000; -0.920000<=pL<=0.960000, 0.760000<=pK<=0.800000; -0.920000<=pL<=0.960000, 0.800000<=pK<=0.840000; -0.920000<=pL<=0.960000, 0.840000<=pK<=0.880000; -0.920000<=pL<=0.960000, 0.880000<=pK<=0.920000; -0.920000<=pL<=0.960000, 0.920000<=pK<=0.960000; -0.920000<=pL<=0.960000, 0.960000<=pK<=0.999990; -0.960000<=pL<=0.999990, 0.000010<=pK<=0.040000; -0.960000<=pL<=0.999990, 0.040000<=pK<=0.080000; -0.960000<=pL<=0.999990, 0.080000<=pK<=0.120000; -0.960000<=pL<=0.999990, 0.120000<=pK<=0.160000; -0.960000<=pL<=0.999990, 0.160000<=pK<=0.200000; -0.960000<=pL<=0.999990, 0.200000<=pK<=0.240000; -0.960000<=pL<=0.999990, 0.240000<=pK<=0.280000; -0.960000<=pL<=0.999990, 0.280000<=pK<=0.320000; -0.960000<=pL<=0.999990, 0.320000<=pK<=0.360000; -0.960000<=pL<=0.999990, 0.360000<=pK<=0.400000; -0.960000<=pL<=0.999990, 0.400000<=pK<=0.440000; -0.960000<=pL<=0.999990, 0.440000<=pK<=0.480000; -0.960000<=pL<=0.999990, 0.480000<=pK<=0.520000; -0.960000<=pL<=0.999990, 0.520000<=pK<=0.560000; -0.960000<=pL<=0.999990, 0.560000<=pK<=0.600000; -0.960000<=pL<=0.999990, 0.600000<=pK<=0.640000; -0.960000<=pL<=0.999990, 0.640000<=pK<=0.680000; -0.960000<=pL<=0.999990, 0.680000<=pK<=0.720000; -0.960000<=pL<=0.999990, 0.720000<=pK<=0.760000; -0.960000<=pL<=0.999990, 0.760000<=pK<=0.800000; -0.960000<=pL<=0.999990, 0.800000<=pK<=0.840000; -0.960000<=pL<=0.999990, 0.840000<=pK<=0.880000; -0.960000<=pL<=0.999990, 0.880000<=pK<=0.920000; -0.960000<=pL<=0.999990, 0.920000<=pK<=0.960000; -0.960000<=pL<=0.999990, 0.960000<=pK<=0.999990; diff --git a/examples/pmdp/brp/brp_space.txt b/examples/pmdp/brp/brp_space.txt deleted file mode 100644 index 444b98e90..000000000 --- a/examples/pmdp/brp/brp_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=pL<=0.999990, 0.000010<=pK<=0.999990; - diff --git a/examples/pmdp/brp/models b/examples/pmdp/brp/models deleted file mode 100644 index b692fffb6..000000000 --- a/examples/pmdp/brp/models +++ /dev/null @@ -1,2 +0,0 @@ -brp.pm -const N=256,MAX=5 -brp.pm -const N=4096,MAX=5 diff --git a/examples/pmdp/coin2/coin2.pm b/examples/pmdp/coin2/coin2.pm deleted file mode 100644 index 8baa365f4..000000000 --- a/examples/pmdp/coin2/coin2.pm +++ /dev/null @@ -1,56 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] - - -const int N=2; -const int K; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -label "finished" = pc1=3 &pc2=3 ; -label "all_coins_equal_1" = coin1=1 &coin2=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin2/coin2.prctl b/examples/pmdp/coin2/coin2.prctl deleted file mode 100644 index 2fe017f65..000000000 --- a/examples/pmdp/coin2/coin2.prctl +++ /dev/null @@ -1,4 +0,0 @@ -P>=0.25 [ F "finished"&"all_coins_equal_1" ] - - - diff --git a/examples/pmdp/coin2/coin2_128.pm b/examples/pmdp/coin2/coin2_128.pm deleted file mode 100644 index 73944141b..000000000 --- a/examples/pmdp/coin2/coin2_128.pm +++ /dev/null @@ -1,56 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] - - -const int N=2; -const int K=128; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -label "finished" = pc1=3 &pc2=3 ; -label "all_coins_equal_1" = coin1=1 &coin2=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin2/coin2_16.pm b/examples/pmdp/coin2/coin2_16.pm deleted file mode 100644 index 0918beafe..000000000 --- a/examples/pmdp/coin2/coin2_16.pm +++ /dev/null @@ -1,56 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] - - -const int N=2; -const int K=16; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -label "finished" = pc1=3 &pc2=3 ; -label "all_coins_equal_1" = coin1=1 &coin2=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin2/coin2_32.pm b/examples/pmdp/coin2/coin2_32.pm deleted file mode 100644 index eb49c17ad..000000000 --- a/examples/pmdp/coin2/coin2_32.pm +++ /dev/null @@ -1,56 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] - - -const int N=2; -const int K=32; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -label "finished" = pc1=3 &pc2=3 ; -label "all_coins_equal_1" = coin1=1 &coin2=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin2/coin2_4.pm b/examples/pmdp/coin2/coin2_4.pm deleted file mode 100644 index ce7bd1e80..000000000 --- a/examples/pmdp/coin2/coin2_4.pm +++ /dev/null @@ -1,56 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] - - -const int N=2; -const int K=4; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -label "finished" = pc1=3 &pc2=3 ; -label "all_coins_equal_1" = coin1=1 &coin2=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin2/coin2_64.pm b/examples/pmdp/coin2/coin2_64.pm deleted file mode 100644 index 7f516964c..000000000 --- a/examples/pmdp/coin2/coin2_64.pm +++ /dev/null @@ -1,56 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] - - -const int N=2; -const int K=64; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -label "finished" = pc1=3 &pc2=3 ; -label "all_coins_equal_1" = coin1=1 &coin2=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin2/coin2_7.pm b/examples/pmdp/coin2/coin2_7.pm deleted file mode 100644 index 8b86e2c6a..000000000 --- a/examples/pmdp/coin2/coin2_7.pm +++ /dev/null @@ -1,56 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] - - -const int N=2; -const int K=7; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -label "finished" = pc1=3 &pc2=3 ; -label "all_coins_equal_1" = coin1=1 &coin2=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin2/coin2_8.pm b/examples/pmdp/coin2/coin2_8.pm deleted file mode 100644 index 81d9bf13c..000000000 --- a/examples/pmdp/coin2/coin2_8.pm +++ /dev/null @@ -1,56 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] - - -const int N=2; -const int K=8; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -label "finished" = pc1=3 &pc2=3 ; -label "all_coins_equal_1" = coin1=1 &coin2=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin2/coin2_regions.txt b/examples/pmdp/coin2/coin2_regions.txt deleted file mode 100644 index 028dc16ef..000000000 --- a/examples/pmdp/coin2/coin2_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=p1<=0.040000, 0.000010<=p2<=0.040000; -0.000010<=p1<=0.040000, 0.040000<=p2<=0.080000; -0.000010<=p1<=0.040000, 0.080000<=p2<=0.120000; -0.000010<=p1<=0.040000, 0.120000<=p2<=0.160000; -0.000010<=p1<=0.040000, 0.160000<=p2<=0.200000; -0.000010<=p1<=0.040000, 0.200000<=p2<=0.240000; -0.000010<=p1<=0.040000, 0.240000<=p2<=0.280000; -0.000010<=p1<=0.040000, 0.280000<=p2<=0.320000; -0.000010<=p1<=0.040000, 0.320000<=p2<=0.360000; -0.000010<=p1<=0.040000, 0.360000<=p2<=0.400000; -0.000010<=p1<=0.040000, 0.400000<=p2<=0.440000; -0.000010<=p1<=0.040000, 0.440000<=p2<=0.480000; -0.000010<=p1<=0.040000, 0.480000<=p2<=0.520000; -0.000010<=p1<=0.040000, 0.520000<=p2<=0.560000; -0.000010<=p1<=0.040000, 0.560000<=p2<=0.600000; -0.000010<=p1<=0.040000, 0.600000<=p2<=0.640000; -0.000010<=p1<=0.040000, 0.640000<=p2<=0.680000; -0.000010<=p1<=0.040000, 0.680000<=p2<=0.720000; -0.000010<=p1<=0.040000, 0.720000<=p2<=0.760000; -0.000010<=p1<=0.040000, 0.760000<=p2<=0.800000; -0.000010<=p1<=0.040000, 0.800000<=p2<=0.840000; -0.000010<=p1<=0.040000, 0.840000<=p2<=0.880000; -0.000010<=p1<=0.040000, 0.880000<=p2<=0.920000; -0.000010<=p1<=0.040000, 0.920000<=p2<=0.960000; -0.000010<=p1<=0.040000, 0.960000<=p2<=0.999990; -0.040000<=p1<=0.080000, 0.000010<=p2<=0.040000; -0.040000<=p1<=0.080000, 0.040000<=p2<=0.080000; -0.040000<=p1<=0.080000, 0.080000<=p2<=0.120000; -0.040000<=p1<=0.080000, 0.120000<=p2<=0.160000; -0.040000<=p1<=0.080000, 0.160000<=p2<=0.200000; -0.040000<=p1<=0.080000, 0.200000<=p2<=0.240000; -0.040000<=p1<=0.080000, 0.240000<=p2<=0.280000; -0.040000<=p1<=0.080000, 0.280000<=p2<=0.320000; -0.040000<=p1<=0.080000, 0.320000<=p2<=0.360000; -0.040000<=p1<=0.080000, 0.360000<=p2<=0.400000; -0.040000<=p1<=0.080000, 0.400000<=p2<=0.440000; -0.040000<=p1<=0.080000, 0.440000<=p2<=0.480000; -0.040000<=p1<=0.080000, 0.480000<=p2<=0.520000; -0.040000<=p1<=0.080000, 0.520000<=p2<=0.560000; -0.040000<=p1<=0.080000, 0.560000<=p2<=0.600000; -0.040000<=p1<=0.080000, 0.600000<=p2<=0.640000; -0.040000<=p1<=0.080000, 0.640000<=p2<=0.680000; -0.040000<=p1<=0.080000, 0.680000<=p2<=0.720000; -0.040000<=p1<=0.080000, 0.720000<=p2<=0.760000; -0.040000<=p1<=0.080000, 0.760000<=p2<=0.800000; -0.040000<=p1<=0.080000, 0.800000<=p2<=0.840000; -0.040000<=p1<=0.080000, 0.840000<=p2<=0.880000; -0.040000<=p1<=0.080000, 0.880000<=p2<=0.920000; -0.040000<=p1<=0.080000, 0.920000<=p2<=0.960000; -0.040000<=p1<=0.080000, 0.960000<=p2<=0.999990; -0.080000<=p1<=0.120000, 0.000010<=p2<=0.040000; -0.080000<=p1<=0.120000, 0.040000<=p2<=0.080000; -0.080000<=p1<=0.120000, 0.080000<=p2<=0.120000; -0.080000<=p1<=0.120000, 0.120000<=p2<=0.160000; -0.080000<=p1<=0.120000, 0.160000<=p2<=0.200000; -0.080000<=p1<=0.120000, 0.200000<=p2<=0.240000; -0.080000<=p1<=0.120000, 0.240000<=p2<=0.280000; -0.080000<=p1<=0.120000, 0.280000<=p2<=0.320000; -0.080000<=p1<=0.120000, 0.320000<=p2<=0.360000; -0.080000<=p1<=0.120000, 0.360000<=p2<=0.400000; -0.080000<=p1<=0.120000, 0.400000<=p2<=0.440000; -0.080000<=p1<=0.120000, 0.440000<=p2<=0.480000; -0.080000<=p1<=0.120000, 0.480000<=p2<=0.520000; -0.080000<=p1<=0.120000, 0.520000<=p2<=0.560000; -0.080000<=p1<=0.120000, 0.560000<=p2<=0.600000; -0.080000<=p1<=0.120000, 0.600000<=p2<=0.640000; -0.080000<=p1<=0.120000, 0.640000<=p2<=0.680000; -0.080000<=p1<=0.120000, 0.680000<=p2<=0.720000; -0.080000<=p1<=0.120000, 0.720000<=p2<=0.760000; -0.080000<=p1<=0.120000, 0.760000<=p2<=0.800000; -0.080000<=p1<=0.120000, 0.800000<=p2<=0.840000; -0.080000<=p1<=0.120000, 0.840000<=p2<=0.880000; -0.080000<=p1<=0.120000, 0.880000<=p2<=0.920000; -0.080000<=p1<=0.120000, 0.920000<=p2<=0.960000; -0.080000<=p1<=0.120000, 0.960000<=p2<=0.999990; -0.120000<=p1<=0.160000, 0.000010<=p2<=0.040000; -0.120000<=p1<=0.160000, 0.040000<=p2<=0.080000; -0.120000<=p1<=0.160000, 0.080000<=p2<=0.120000; -0.120000<=p1<=0.160000, 0.120000<=p2<=0.160000; -0.120000<=p1<=0.160000, 0.160000<=p2<=0.200000; -0.120000<=p1<=0.160000, 0.200000<=p2<=0.240000; -0.120000<=p1<=0.160000, 0.240000<=p2<=0.280000; -0.120000<=p1<=0.160000, 0.280000<=p2<=0.320000; -0.120000<=p1<=0.160000, 0.320000<=p2<=0.360000; -0.120000<=p1<=0.160000, 0.360000<=p2<=0.400000; -0.120000<=p1<=0.160000, 0.400000<=p2<=0.440000; -0.120000<=p1<=0.160000, 0.440000<=p2<=0.480000; -0.120000<=p1<=0.160000, 0.480000<=p2<=0.520000; -0.120000<=p1<=0.160000, 0.520000<=p2<=0.560000; -0.120000<=p1<=0.160000, 0.560000<=p2<=0.600000; -0.120000<=p1<=0.160000, 0.600000<=p2<=0.640000; -0.120000<=p1<=0.160000, 0.640000<=p2<=0.680000; -0.120000<=p1<=0.160000, 0.680000<=p2<=0.720000; -0.120000<=p1<=0.160000, 0.720000<=p2<=0.760000; -0.120000<=p1<=0.160000, 0.760000<=p2<=0.800000; -0.120000<=p1<=0.160000, 0.800000<=p2<=0.840000; -0.120000<=p1<=0.160000, 0.840000<=p2<=0.880000; -0.120000<=p1<=0.160000, 0.880000<=p2<=0.920000; -0.120000<=p1<=0.160000, 0.920000<=p2<=0.960000; -0.120000<=p1<=0.160000, 0.960000<=p2<=0.999990; -0.160000<=p1<=0.200000, 0.000010<=p2<=0.040000; -0.160000<=p1<=0.200000, 0.040000<=p2<=0.080000; -0.160000<=p1<=0.200000, 0.080000<=p2<=0.120000; -0.160000<=p1<=0.200000, 0.120000<=p2<=0.160000; -0.160000<=p1<=0.200000, 0.160000<=p2<=0.200000; -0.160000<=p1<=0.200000, 0.200000<=p2<=0.240000; -0.160000<=p1<=0.200000, 0.240000<=p2<=0.280000; -0.160000<=p1<=0.200000, 0.280000<=p2<=0.320000; -0.160000<=p1<=0.200000, 0.320000<=p2<=0.360000; -0.160000<=p1<=0.200000, 0.360000<=p2<=0.400000; -0.160000<=p1<=0.200000, 0.400000<=p2<=0.440000; -0.160000<=p1<=0.200000, 0.440000<=p2<=0.480000; -0.160000<=p1<=0.200000, 0.480000<=p2<=0.520000; -0.160000<=p1<=0.200000, 0.520000<=p2<=0.560000; -0.160000<=p1<=0.200000, 0.560000<=p2<=0.600000; -0.160000<=p1<=0.200000, 0.600000<=p2<=0.640000; -0.160000<=p1<=0.200000, 0.640000<=p2<=0.680000; -0.160000<=p1<=0.200000, 0.680000<=p2<=0.720000; -0.160000<=p1<=0.200000, 0.720000<=p2<=0.760000; -0.160000<=p1<=0.200000, 0.760000<=p2<=0.800000; -0.160000<=p1<=0.200000, 0.800000<=p2<=0.840000; -0.160000<=p1<=0.200000, 0.840000<=p2<=0.880000; -0.160000<=p1<=0.200000, 0.880000<=p2<=0.920000; -0.160000<=p1<=0.200000, 0.920000<=p2<=0.960000; -0.160000<=p1<=0.200000, 0.960000<=p2<=0.999990; -0.200000<=p1<=0.240000, 0.000010<=p2<=0.040000; -0.200000<=p1<=0.240000, 0.040000<=p2<=0.080000; -0.200000<=p1<=0.240000, 0.080000<=p2<=0.120000; -0.200000<=p1<=0.240000, 0.120000<=p2<=0.160000; -0.200000<=p1<=0.240000, 0.160000<=p2<=0.200000; -0.200000<=p1<=0.240000, 0.200000<=p2<=0.240000; -0.200000<=p1<=0.240000, 0.240000<=p2<=0.280000; -0.200000<=p1<=0.240000, 0.280000<=p2<=0.320000; -0.200000<=p1<=0.240000, 0.320000<=p2<=0.360000; -0.200000<=p1<=0.240000, 0.360000<=p2<=0.400000; -0.200000<=p1<=0.240000, 0.400000<=p2<=0.440000; -0.200000<=p1<=0.240000, 0.440000<=p2<=0.480000; -0.200000<=p1<=0.240000, 0.480000<=p2<=0.520000; -0.200000<=p1<=0.240000, 0.520000<=p2<=0.560000; -0.200000<=p1<=0.240000, 0.560000<=p2<=0.600000; -0.200000<=p1<=0.240000, 0.600000<=p2<=0.640000; -0.200000<=p1<=0.240000, 0.640000<=p2<=0.680000; -0.200000<=p1<=0.240000, 0.680000<=p2<=0.720000; -0.200000<=p1<=0.240000, 0.720000<=p2<=0.760000; -0.200000<=p1<=0.240000, 0.760000<=p2<=0.800000; -0.200000<=p1<=0.240000, 0.800000<=p2<=0.840000; -0.200000<=p1<=0.240000, 0.840000<=p2<=0.880000; -0.200000<=p1<=0.240000, 0.880000<=p2<=0.920000; -0.200000<=p1<=0.240000, 0.920000<=p2<=0.960000; -0.200000<=p1<=0.240000, 0.960000<=p2<=0.999990; -0.240000<=p1<=0.280000, 0.000010<=p2<=0.040000; -0.240000<=p1<=0.280000, 0.040000<=p2<=0.080000; -0.240000<=p1<=0.280000, 0.080000<=p2<=0.120000; -0.240000<=p1<=0.280000, 0.120000<=p2<=0.160000; -0.240000<=p1<=0.280000, 0.160000<=p2<=0.200000; -0.240000<=p1<=0.280000, 0.200000<=p2<=0.240000; -0.240000<=p1<=0.280000, 0.240000<=p2<=0.280000; -0.240000<=p1<=0.280000, 0.280000<=p2<=0.320000; -0.240000<=p1<=0.280000, 0.320000<=p2<=0.360000; -0.240000<=p1<=0.280000, 0.360000<=p2<=0.400000; -0.240000<=p1<=0.280000, 0.400000<=p2<=0.440000; -0.240000<=p1<=0.280000, 0.440000<=p2<=0.480000; -0.240000<=p1<=0.280000, 0.480000<=p2<=0.520000; -0.240000<=p1<=0.280000, 0.520000<=p2<=0.560000; -0.240000<=p1<=0.280000, 0.560000<=p2<=0.600000; -0.240000<=p1<=0.280000, 0.600000<=p2<=0.640000; -0.240000<=p1<=0.280000, 0.640000<=p2<=0.680000; -0.240000<=p1<=0.280000, 0.680000<=p2<=0.720000; -0.240000<=p1<=0.280000, 0.720000<=p2<=0.760000; -0.240000<=p1<=0.280000, 0.760000<=p2<=0.800000; -0.240000<=p1<=0.280000, 0.800000<=p2<=0.840000; -0.240000<=p1<=0.280000, 0.840000<=p2<=0.880000; -0.240000<=p1<=0.280000, 0.880000<=p2<=0.920000; -0.240000<=p1<=0.280000, 0.920000<=p2<=0.960000; -0.240000<=p1<=0.280000, 0.960000<=p2<=0.999990; -0.280000<=p1<=0.320000, 0.000010<=p2<=0.040000; -0.280000<=p1<=0.320000, 0.040000<=p2<=0.080000; -0.280000<=p1<=0.320000, 0.080000<=p2<=0.120000; -0.280000<=p1<=0.320000, 0.120000<=p2<=0.160000; -0.280000<=p1<=0.320000, 0.160000<=p2<=0.200000; -0.280000<=p1<=0.320000, 0.200000<=p2<=0.240000; -0.280000<=p1<=0.320000, 0.240000<=p2<=0.280000; -0.280000<=p1<=0.320000, 0.280000<=p2<=0.320000; -0.280000<=p1<=0.320000, 0.320000<=p2<=0.360000; -0.280000<=p1<=0.320000, 0.360000<=p2<=0.400000; -0.280000<=p1<=0.320000, 0.400000<=p2<=0.440000; -0.280000<=p1<=0.320000, 0.440000<=p2<=0.480000; -0.280000<=p1<=0.320000, 0.480000<=p2<=0.520000; -0.280000<=p1<=0.320000, 0.520000<=p2<=0.560000; -0.280000<=p1<=0.320000, 0.560000<=p2<=0.600000; -0.280000<=p1<=0.320000, 0.600000<=p2<=0.640000; -0.280000<=p1<=0.320000, 0.640000<=p2<=0.680000; -0.280000<=p1<=0.320000, 0.680000<=p2<=0.720000; -0.280000<=p1<=0.320000, 0.720000<=p2<=0.760000; -0.280000<=p1<=0.320000, 0.760000<=p2<=0.800000; -0.280000<=p1<=0.320000, 0.800000<=p2<=0.840000; -0.280000<=p1<=0.320000, 0.840000<=p2<=0.880000; -0.280000<=p1<=0.320000, 0.880000<=p2<=0.920000; -0.280000<=p1<=0.320000, 0.920000<=p2<=0.960000; -0.280000<=p1<=0.320000, 0.960000<=p2<=0.999990; -0.320000<=p1<=0.360000, 0.000010<=p2<=0.040000; -0.320000<=p1<=0.360000, 0.040000<=p2<=0.080000; -0.320000<=p1<=0.360000, 0.080000<=p2<=0.120000; -0.320000<=p1<=0.360000, 0.120000<=p2<=0.160000; -0.320000<=p1<=0.360000, 0.160000<=p2<=0.200000; -0.320000<=p1<=0.360000, 0.200000<=p2<=0.240000; -0.320000<=p1<=0.360000, 0.240000<=p2<=0.280000; -0.320000<=p1<=0.360000, 0.280000<=p2<=0.320000; -0.320000<=p1<=0.360000, 0.320000<=p2<=0.360000; -0.320000<=p1<=0.360000, 0.360000<=p2<=0.400000; -0.320000<=p1<=0.360000, 0.400000<=p2<=0.440000; -0.320000<=p1<=0.360000, 0.440000<=p2<=0.480000; -0.320000<=p1<=0.360000, 0.480000<=p2<=0.520000; -0.320000<=p1<=0.360000, 0.520000<=p2<=0.560000; -0.320000<=p1<=0.360000, 0.560000<=p2<=0.600000; -0.320000<=p1<=0.360000, 0.600000<=p2<=0.640000; -0.320000<=p1<=0.360000, 0.640000<=p2<=0.680000; -0.320000<=p1<=0.360000, 0.680000<=p2<=0.720000; -0.320000<=p1<=0.360000, 0.720000<=p2<=0.760000; -0.320000<=p1<=0.360000, 0.760000<=p2<=0.800000; -0.320000<=p1<=0.360000, 0.800000<=p2<=0.840000; -0.320000<=p1<=0.360000, 0.840000<=p2<=0.880000; -0.320000<=p1<=0.360000, 0.880000<=p2<=0.920000; -0.320000<=p1<=0.360000, 0.920000<=p2<=0.960000; -0.320000<=p1<=0.360000, 0.960000<=p2<=0.999990; -0.360000<=p1<=0.400000, 0.000010<=p2<=0.040000; -0.360000<=p1<=0.400000, 0.040000<=p2<=0.080000; -0.360000<=p1<=0.400000, 0.080000<=p2<=0.120000; -0.360000<=p1<=0.400000, 0.120000<=p2<=0.160000; -0.360000<=p1<=0.400000, 0.160000<=p2<=0.200000; -0.360000<=p1<=0.400000, 0.200000<=p2<=0.240000; -0.360000<=p1<=0.400000, 0.240000<=p2<=0.280000; -0.360000<=p1<=0.400000, 0.280000<=p2<=0.320000; -0.360000<=p1<=0.400000, 0.320000<=p2<=0.360000; -0.360000<=p1<=0.400000, 0.360000<=p2<=0.400000; -0.360000<=p1<=0.400000, 0.400000<=p2<=0.440000; -0.360000<=p1<=0.400000, 0.440000<=p2<=0.480000; -0.360000<=p1<=0.400000, 0.480000<=p2<=0.520000; -0.360000<=p1<=0.400000, 0.520000<=p2<=0.560000; -0.360000<=p1<=0.400000, 0.560000<=p2<=0.600000; -0.360000<=p1<=0.400000, 0.600000<=p2<=0.640000; -0.360000<=p1<=0.400000, 0.640000<=p2<=0.680000; -0.360000<=p1<=0.400000, 0.680000<=p2<=0.720000; -0.360000<=p1<=0.400000, 0.720000<=p2<=0.760000; -0.360000<=p1<=0.400000, 0.760000<=p2<=0.800000; -0.360000<=p1<=0.400000, 0.800000<=p2<=0.840000; -0.360000<=p1<=0.400000, 0.840000<=p2<=0.880000; -0.360000<=p1<=0.400000, 0.880000<=p2<=0.920000; -0.360000<=p1<=0.400000, 0.920000<=p2<=0.960000; -0.360000<=p1<=0.400000, 0.960000<=p2<=0.999990; -0.400000<=p1<=0.440000, 0.000010<=p2<=0.040000; -0.400000<=p1<=0.440000, 0.040000<=p2<=0.080000; -0.400000<=p1<=0.440000, 0.080000<=p2<=0.120000; -0.400000<=p1<=0.440000, 0.120000<=p2<=0.160000; -0.400000<=p1<=0.440000, 0.160000<=p2<=0.200000; -0.400000<=p1<=0.440000, 0.200000<=p2<=0.240000; -0.400000<=p1<=0.440000, 0.240000<=p2<=0.280000; -0.400000<=p1<=0.440000, 0.280000<=p2<=0.320000; -0.400000<=p1<=0.440000, 0.320000<=p2<=0.360000; -0.400000<=p1<=0.440000, 0.360000<=p2<=0.400000; -0.400000<=p1<=0.440000, 0.400000<=p2<=0.440000; -0.400000<=p1<=0.440000, 0.440000<=p2<=0.480000; -0.400000<=p1<=0.440000, 0.480000<=p2<=0.520000; -0.400000<=p1<=0.440000, 0.520000<=p2<=0.560000; -0.400000<=p1<=0.440000, 0.560000<=p2<=0.600000; -0.400000<=p1<=0.440000, 0.600000<=p2<=0.640000; -0.400000<=p1<=0.440000, 0.640000<=p2<=0.680000; -0.400000<=p1<=0.440000, 0.680000<=p2<=0.720000; -0.400000<=p1<=0.440000, 0.720000<=p2<=0.760000; -0.400000<=p1<=0.440000, 0.760000<=p2<=0.800000; -0.400000<=p1<=0.440000, 0.800000<=p2<=0.840000; -0.400000<=p1<=0.440000, 0.840000<=p2<=0.880000; -0.400000<=p1<=0.440000, 0.880000<=p2<=0.920000; -0.400000<=p1<=0.440000, 0.920000<=p2<=0.960000; -0.400000<=p1<=0.440000, 0.960000<=p2<=0.999990; -0.440000<=p1<=0.480000, 0.000010<=p2<=0.040000; -0.440000<=p1<=0.480000, 0.040000<=p2<=0.080000; -0.440000<=p1<=0.480000, 0.080000<=p2<=0.120000; -0.440000<=p1<=0.480000, 0.120000<=p2<=0.160000; -0.440000<=p1<=0.480000, 0.160000<=p2<=0.200000; -0.440000<=p1<=0.480000, 0.200000<=p2<=0.240000; -0.440000<=p1<=0.480000, 0.240000<=p2<=0.280000; -0.440000<=p1<=0.480000, 0.280000<=p2<=0.320000; -0.440000<=p1<=0.480000, 0.320000<=p2<=0.360000; -0.440000<=p1<=0.480000, 0.360000<=p2<=0.400000; -0.440000<=p1<=0.480000, 0.400000<=p2<=0.440000; -0.440000<=p1<=0.480000, 0.440000<=p2<=0.480000; -0.440000<=p1<=0.480000, 0.480000<=p2<=0.520000; -0.440000<=p1<=0.480000, 0.520000<=p2<=0.560000; -0.440000<=p1<=0.480000, 0.560000<=p2<=0.600000; -0.440000<=p1<=0.480000, 0.600000<=p2<=0.640000; -0.440000<=p1<=0.480000, 0.640000<=p2<=0.680000; -0.440000<=p1<=0.480000, 0.680000<=p2<=0.720000; -0.440000<=p1<=0.480000, 0.720000<=p2<=0.760000; -0.440000<=p1<=0.480000, 0.760000<=p2<=0.800000; -0.440000<=p1<=0.480000, 0.800000<=p2<=0.840000; -0.440000<=p1<=0.480000, 0.840000<=p2<=0.880000; -0.440000<=p1<=0.480000, 0.880000<=p2<=0.920000; -0.440000<=p1<=0.480000, 0.920000<=p2<=0.960000; -0.440000<=p1<=0.480000, 0.960000<=p2<=0.999990; -0.480000<=p1<=0.520000, 0.000010<=p2<=0.040000; -0.480000<=p1<=0.520000, 0.040000<=p2<=0.080000; -0.480000<=p1<=0.520000, 0.080000<=p2<=0.120000; -0.480000<=p1<=0.520000, 0.120000<=p2<=0.160000; -0.480000<=p1<=0.520000, 0.160000<=p2<=0.200000; -0.480000<=p1<=0.520000, 0.200000<=p2<=0.240000; -0.480000<=p1<=0.520000, 0.240000<=p2<=0.280000; -0.480000<=p1<=0.520000, 0.280000<=p2<=0.320000; -0.480000<=p1<=0.520000, 0.320000<=p2<=0.360000; -0.480000<=p1<=0.520000, 0.360000<=p2<=0.400000; -0.480000<=p1<=0.520000, 0.400000<=p2<=0.440000; -0.480000<=p1<=0.520000, 0.440000<=p2<=0.480000; -0.480000<=p1<=0.520000, 0.480000<=p2<=0.520000; -0.480000<=p1<=0.520000, 0.520000<=p2<=0.560000; -0.480000<=p1<=0.520000, 0.560000<=p2<=0.600000; -0.480000<=p1<=0.520000, 0.600000<=p2<=0.640000; -0.480000<=p1<=0.520000, 0.640000<=p2<=0.680000; -0.480000<=p1<=0.520000, 0.680000<=p2<=0.720000; -0.480000<=p1<=0.520000, 0.720000<=p2<=0.760000; -0.480000<=p1<=0.520000, 0.760000<=p2<=0.800000; -0.480000<=p1<=0.520000, 0.800000<=p2<=0.840000; -0.480000<=p1<=0.520000, 0.840000<=p2<=0.880000; -0.480000<=p1<=0.520000, 0.880000<=p2<=0.920000; -0.480000<=p1<=0.520000, 0.920000<=p2<=0.960000; -0.480000<=p1<=0.520000, 0.960000<=p2<=0.999990; -0.520000<=p1<=0.560000, 0.000010<=p2<=0.040000; -0.520000<=p1<=0.560000, 0.040000<=p2<=0.080000; -0.520000<=p1<=0.560000, 0.080000<=p2<=0.120000; -0.520000<=p1<=0.560000, 0.120000<=p2<=0.160000; -0.520000<=p1<=0.560000, 0.160000<=p2<=0.200000; -0.520000<=p1<=0.560000, 0.200000<=p2<=0.240000; -0.520000<=p1<=0.560000, 0.240000<=p2<=0.280000; -0.520000<=p1<=0.560000, 0.280000<=p2<=0.320000; -0.520000<=p1<=0.560000, 0.320000<=p2<=0.360000; -0.520000<=p1<=0.560000, 0.360000<=p2<=0.400000; -0.520000<=p1<=0.560000, 0.400000<=p2<=0.440000; -0.520000<=p1<=0.560000, 0.440000<=p2<=0.480000; -0.520000<=p1<=0.560000, 0.480000<=p2<=0.520000; -0.520000<=p1<=0.560000, 0.520000<=p2<=0.560000; -0.520000<=p1<=0.560000, 0.560000<=p2<=0.600000; -0.520000<=p1<=0.560000, 0.600000<=p2<=0.640000; -0.520000<=p1<=0.560000, 0.640000<=p2<=0.680000; -0.520000<=p1<=0.560000, 0.680000<=p2<=0.720000; -0.520000<=p1<=0.560000, 0.720000<=p2<=0.760000; -0.520000<=p1<=0.560000, 0.760000<=p2<=0.800000; -0.520000<=p1<=0.560000, 0.800000<=p2<=0.840000; -0.520000<=p1<=0.560000, 0.840000<=p2<=0.880000; -0.520000<=p1<=0.560000, 0.880000<=p2<=0.920000; -0.520000<=p1<=0.560000, 0.920000<=p2<=0.960000; -0.520000<=p1<=0.560000, 0.960000<=p2<=0.999990; -0.560000<=p1<=0.600000, 0.000010<=p2<=0.040000; -0.560000<=p1<=0.600000, 0.040000<=p2<=0.080000; -0.560000<=p1<=0.600000, 0.080000<=p2<=0.120000; -0.560000<=p1<=0.600000, 0.120000<=p2<=0.160000; -0.560000<=p1<=0.600000, 0.160000<=p2<=0.200000; -0.560000<=p1<=0.600000, 0.200000<=p2<=0.240000; -0.560000<=p1<=0.600000, 0.240000<=p2<=0.280000; -0.560000<=p1<=0.600000, 0.280000<=p2<=0.320000; -0.560000<=p1<=0.600000, 0.320000<=p2<=0.360000; -0.560000<=p1<=0.600000, 0.360000<=p2<=0.400000; -0.560000<=p1<=0.600000, 0.400000<=p2<=0.440000; -0.560000<=p1<=0.600000, 0.440000<=p2<=0.480000; -0.560000<=p1<=0.600000, 0.480000<=p2<=0.520000; -0.560000<=p1<=0.600000, 0.520000<=p2<=0.560000; -0.560000<=p1<=0.600000, 0.560000<=p2<=0.600000; -0.560000<=p1<=0.600000, 0.600000<=p2<=0.640000; -0.560000<=p1<=0.600000, 0.640000<=p2<=0.680000; -0.560000<=p1<=0.600000, 0.680000<=p2<=0.720000; -0.560000<=p1<=0.600000, 0.720000<=p2<=0.760000; -0.560000<=p1<=0.600000, 0.760000<=p2<=0.800000; -0.560000<=p1<=0.600000, 0.800000<=p2<=0.840000; -0.560000<=p1<=0.600000, 0.840000<=p2<=0.880000; -0.560000<=p1<=0.600000, 0.880000<=p2<=0.920000; -0.560000<=p1<=0.600000, 0.920000<=p2<=0.960000; -0.560000<=p1<=0.600000, 0.960000<=p2<=0.999990; -0.600000<=p1<=0.640000, 0.000010<=p2<=0.040000; -0.600000<=p1<=0.640000, 0.040000<=p2<=0.080000; -0.600000<=p1<=0.640000, 0.080000<=p2<=0.120000; -0.600000<=p1<=0.640000, 0.120000<=p2<=0.160000; -0.600000<=p1<=0.640000, 0.160000<=p2<=0.200000; -0.600000<=p1<=0.640000, 0.200000<=p2<=0.240000; -0.600000<=p1<=0.640000, 0.240000<=p2<=0.280000; -0.600000<=p1<=0.640000, 0.280000<=p2<=0.320000; -0.600000<=p1<=0.640000, 0.320000<=p2<=0.360000; -0.600000<=p1<=0.640000, 0.360000<=p2<=0.400000; -0.600000<=p1<=0.640000, 0.400000<=p2<=0.440000; -0.600000<=p1<=0.640000, 0.440000<=p2<=0.480000; -0.600000<=p1<=0.640000, 0.480000<=p2<=0.520000; -0.600000<=p1<=0.640000, 0.520000<=p2<=0.560000; -0.600000<=p1<=0.640000, 0.560000<=p2<=0.600000; -0.600000<=p1<=0.640000, 0.600000<=p2<=0.640000; -0.600000<=p1<=0.640000, 0.640000<=p2<=0.680000; -0.600000<=p1<=0.640000, 0.680000<=p2<=0.720000; -0.600000<=p1<=0.640000, 0.720000<=p2<=0.760000; -0.600000<=p1<=0.640000, 0.760000<=p2<=0.800000; -0.600000<=p1<=0.640000, 0.800000<=p2<=0.840000; -0.600000<=p1<=0.640000, 0.840000<=p2<=0.880000; -0.600000<=p1<=0.640000, 0.880000<=p2<=0.920000; -0.600000<=p1<=0.640000, 0.920000<=p2<=0.960000; -0.600000<=p1<=0.640000, 0.960000<=p2<=0.999990; -0.640000<=p1<=0.680000, 0.000010<=p2<=0.040000; -0.640000<=p1<=0.680000, 0.040000<=p2<=0.080000; -0.640000<=p1<=0.680000, 0.080000<=p2<=0.120000; -0.640000<=p1<=0.680000, 0.120000<=p2<=0.160000; -0.640000<=p1<=0.680000, 0.160000<=p2<=0.200000; -0.640000<=p1<=0.680000, 0.200000<=p2<=0.240000; -0.640000<=p1<=0.680000, 0.240000<=p2<=0.280000; -0.640000<=p1<=0.680000, 0.280000<=p2<=0.320000; -0.640000<=p1<=0.680000, 0.320000<=p2<=0.360000; -0.640000<=p1<=0.680000, 0.360000<=p2<=0.400000; -0.640000<=p1<=0.680000, 0.400000<=p2<=0.440000; -0.640000<=p1<=0.680000, 0.440000<=p2<=0.480000; -0.640000<=p1<=0.680000, 0.480000<=p2<=0.520000; -0.640000<=p1<=0.680000, 0.520000<=p2<=0.560000; -0.640000<=p1<=0.680000, 0.560000<=p2<=0.600000; -0.640000<=p1<=0.680000, 0.600000<=p2<=0.640000; -0.640000<=p1<=0.680000, 0.640000<=p2<=0.680000; -0.640000<=p1<=0.680000, 0.680000<=p2<=0.720000; -0.640000<=p1<=0.680000, 0.720000<=p2<=0.760000; -0.640000<=p1<=0.680000, 0.760000<=p2<=0.800000; -0.640000<=p1<=0.680000, 0.800000<=p2<=0.840000; -0.640000<=p1<=0.680000, 0.840000<=p2<=0.880000; -0.640000<=p1<=0.680000, 0.880000<=p2<=0.920000; -0.640000<=p1<=0.680000, 0.920000<=p2<=0.960000; -0.640000<=p1<=0.680000, 0.960000<=p2<=0.999990; -0.680000<=p1<=0.720000, 0.000010<=p2<=0.040000; -0.680000<=p1<=0.720000, 0.040000<=p2<=0.080000; -0.680000<=p1<=0.720000, 0.080000<=p2<=0.120000; -0.680000<=p1<=0.720000, 0.120000<=p2<=0.160000; -0.680000<=p1<=0.720000, 0.160000<=p2<=0.200000; -0.680000<=p1<=0.720000, 0.200000<=p2<=0.240000; -0.680000<=p1<=0.720000, 0.240000<=p2<=0.280000; -0.680000<=p1<=0.720000, 0.280000<=p2<=0.320000; -0.680000<=p1<=0.720000, 0.320000<=p2<=0.360000; -0.680000<=p1<=0.720000, 0.360000<=p2<=0.400000; -0.680000<=p1<=0.720000, 0.400000<=p2<=0.440000; -0.680000<=p1<=0.720000, 0.440000<=p2<=0.480000; -0.680000<=p1<=0.720000, 0.480000<=p2<=0.520000; -0.680000<=p1<=0.720000, 0.520000<=p2<=0.560000; -0.680000<=p1<=0.720000, 0.560000<=p2<=0.600000; -0.680000<=p1<=0.720000, 0.600000<=p2<=0.640000; -0.680000<=p1<=0.720000, 0.640000<=p2<=0.680000; -0.680000<=p1<=0.720000, 0.680000<=p2<=0.720000; -0.680000<=p1<=0.720000, 0.720000<=p2<=0.760000; -0.680000<=p1<=0.720000, 0.760000<=p2<=0.800000; -0.680000<=p1<=0.720000, 0.800000<=p2<=0.840000; -0.680000<=p1<=0.720000, 0.840000<=p2<=0.880000; -0.680000<=p1<=0.720000, 0.880000<=p2<=0.920000; -0.680000<=p1<=0.720000, 0.920000<=p2<=0.960000; -0.680000<=p1<=0.720000, 0.960000<=p2<=0.999990; -0.720000<=p1<=0.760000, 0.000010<=p2<=0.040000; -0.720000<=p1<=0.760000, 0.040000<=p2<=0.080000; -0.720000<=p1<=0.760000, 0.080000<=p2<=0.120000; -0.720000<=p1<=0.760000, 0.120000<=p2<=0.160000; -0.720000<=p1<=0.760000, 0.160000<=p2<=0.200000; -0.720000<=p1<=0.760000, 0.200000<=p2<=0.240000; -0.720000<=p1<=0.760000, 0.240000<=p2<=0.280000; -0.720000<=p1<=0.760000, 0.280000<=p2<=0.320000; -0.720000<=p1<=0.760000, 0.320000<=p2<=0.360000; -0.720000<=p1<=0.760000, 0.360000<=p2<=0.400000; -0.720000<=p1<=0.760000, 0.400000<=p2<=0.440000; -0.720000<=p1<=0.760000, 0.440000<=p2<=0.480000; -0.720000<=p1<=0.760000, 0.480000<=p2<=0.520000; -0.720000<=p1<=0.760000, 0.520000<=p2<=0.560000; -0.720000<=p1<=0.760000, 0.560000<=p2<=0.600000; -0.720000<=p1<=0.760000, 0.600000<=p2<=0.640000; -0.720000<=p1<=0.760000, 0.640000<=p2<=0.680000; -0.720000<=p1<=0.760000, 0.680000<=p2<=0.720000; -0.720000<=p1<=0.760000, 0.720000<=p2<=0.760000; -0.720000<=p1<=0.760000, 0.760000<=p2<=0.800000; -0.720000<=p1<=0.760000, 0.800000<=p2<=0.840000; -0.720000<=p1<=0.760000, 0.840000<=p2<=0.880000; -0.720000<=p1<=0.760000, 0.880000<=p2<=0.920000; -0.720000<=p1<=0.760000, 0.920000<=p2<=0.960000; -0.720000<=p1<=0.760000, 0.960000<=p2<=0.999990; -0.760000<=p1<=0.800000, 0.000010<=p2<=0.040000; -0.760000<=p1<=0.800000, 0.040000<=p2<=0.080000; -0.760000<=p1<=0.800000, 0.080000<=p2<=0.120000; -0.760000<=p1<=0.800000, 0.120000<=p2<=0.160000; -0.760000<=p1<=0.800000, 0.160000<=p2<=0.200000; -0.760000<=p1<=0.800000, 0.200000<=p2<=0.240000; -0.760000<=p1<=0.800000, 0.240000<=p2<=0.280000; -0.760000<=p1<=0.800000, 0.280000<=p2<=0.320000; -0.760000<=p1<=0.800000, 0.320000<=p2<=0.360000; -0.760000<=p1<=0.800000, 0.360000<=p2<=0.400000; -0.760000<=p1<=0.800000, 0.400000<=p2<=0.440000; -0.760000<=p1<=0.800000, 0.440000<=p2<=0.480000; -0.760000<=p1<=0.800000, 0.480000<=p2<=0.520000; -0.760000<=p1<=0.800000, 0.520000<=p2<=0.560000; -0.760000<=p1<=0.800000, 0.560000<=p2<=0.600000; -0.760000<=p1<=0.800000, 0.600000<=p2<=0.640000; -0.760000<=p1<=0.800000, 0.640000<=p2<=0.680000; -0.760000<=p1<=0.800000, 0.680000<=p2<=0.720000; -0.760000<=p1<=0.800000, 0.720000<=p2<=0.760000; -0.760000<=p1<=0.800000, 0.760000<=p2<=0.800000; -0.760000<=p1<=0.800000, 0.800000<=p2<=0.840000; -0.760000<=p1<=0.800000, 0.840000<=p2<=0.880000; -0.760000<=p1<=0.800000, 0.880000<=p2<=0.920000; -0.760000<=p1<=0.800000, 0.920000<=p2<=0.960000; -0.760000<=p1<=0.800000, 0.960000<=p2<=0.999990; -0.800000<=p1<=0.840000, 0.000010<=p2<=0.040000; -0.800000<=p1<=0.840000, 0.040000<=p2<=0.080000; -0.800000<=p1<=0.840000, 0.080000<=p2<=0.120000; -0.800000<=p1<=0.840000, 0.120000<=p2<=0.160000; -0.800000<=p1<=0.840000, 0.160000<=p2<=0.200000; -0.800000<=p1<=0.840000, 0.200000<=p2<=0.240000; -0.800000<=p1<=0.840000, 0.240000<=p2<=0.280000; -0.800000<=p1<=0.840000, 0.280000<=p2<=0.320000; -0.800000<=p1<=0.840000, 0.320000<=p2<=0.360000; -0.800000<=p1<=0.840000, 0.360000<=p2<=0.400000; -0.800000<=p1<=0.840000, 0.400000<=p2<=0.440000; -0.800000<=p1<=0.840000, 0.440000<=p2<=0.480000; -0.800000<=p1<=0.840000, 0.480000<=p2<=0.520000; -0.800000<=p1<=0.840000, 0.520000<=p2<=0.560000; -0.800000<=p1<=0.840000, 0.560000<=p2<=0.600000; -0.800000<=p1<=0.840000, 0.600000<=p2<=0.640000; -0.800000<=p1<=0.840000, 0.640000<=p2<=0.680000; -0.800000<=p1<=0.840000, 0.680000<=p2<=0.720000; -0.800000<=p1<=0.840000, 0.720000<=p2<=0.760000; -0.800000<=p1<=0.840000, 0.760000<=p2<=0.800000; -0.800000<=p1<=0.840000, 0.800000<=p2<=0.840000; -0.800000<=p1<=0.840000, 0.840000<=p2<=0.880000; -0.800000<=p1<=0.840000, 0.880000<=p2<=0.920000; -0.800000<=p1<=0.840000, 0.920000<=p2<=0.960000; -0.800000<=p1<=0.840000, 0.960000<=p2<=0.999990; -0.840000<=p1<=0.880000, 0.000010<=p2<=0.040000; -0.840000<=p1<=0.880000, 0.040000<=p2<=0.080000; -0.840000<=p1<=0.880000, 0.080000<=p2<=0.120000; -0.840000<=p1<=0.880000, 0.120000<=p2<=0.160000; -0.840000<=p1<=0.880000, 0.160000<=p2<=0.200000; -0.840000<=p1<=0.880000, 0.200000<=p2<=0.240000; -0.840000<=p1<=0.880000, 0.240000<=p2<=0.280000; -0.840000<=p1<=0.880000, 0.280000<=p2<=0.320000; -0.840000<=p1<=0.880000, 0.320000<=p2<=0.360000; -0.840000<=p1<=0.880000, 0.360000<=p2<=0.400000; -0.840000<=p1<=0.880000, 0.400000<=p2<=0.440000; -0.840000<=p1<=0.880000, 0.440000<=p2<=0.480000; -0.840000<=p1<=0.880000, 0.480000<=p2<=0.520000; -0.840000<=p1<=0.880000, 0.520000<=p2<=0.560000; -0.840000<=p1<=0.880000, 0.560000<=p2<=0.600000; -0.840000<=p1<=0.880000, 0.600000<=p2<=0.640000; -0.840000<=p1<=0.880000, 0.640000<=p2<=0.680000; -0.840000<=p1<=0.880000, 0.680000<=p2<=0.720000; -0.840000<=p1<=0.880000, 0.720000<=p2<=0.760000; -0.840000<=p1<=0.880000, 0.760000<=p2<=0.800000; -0.840000<=p1<=0.880000, 0.800000<=p2<=0.840000; -0.840000<=p1<=0.880000, 0.840000<=p2<=0.880000; -0.840000<=p1<=0.880000, 0.880000<=p2<=0.920000; -0.840000<=p1<=0.880000, 0.920000<=p2<=0.960000; -0.840000<=p1<=0.880000, 0.960000<=p2<=0.999990; -0.880000<=p1<=0.920000, 0.000010<=p2<=0.040000; -0.880000<=p1<=0.920000, 0.040000<=p2<=0.080000; -0.880000<=p1<=0.920000, 0.080000<=p2<=0.120000; -0.880000<=p1<=0.920000, 0.120000<=p2<=0.160000; -0.880000<=p1<=0.920000, 0.160000<=p2<=0.200000; -0.880000<=p1<=0.920000, 0.200000<=p2<=0.240000; -0.880000<=p1<=0.920000, 0.240000<=p2<=0.280000; -0.880000<=p1<=0.920000, 0.280000<=p2<=0.320000; -0.880000<=p1<=0.920000, 0.320000<=p2<=0.360000; -0.880000<=p1<=0.920000, 0.360000<=p2<=0.400000; -0.880000<=p1<=0.920000, 0.400000<=p2<=0.440000; -0.880000<=p1<=0.920000, 0.440000<=p2<=0.480000; -0.880000<=p1<=0.920000, 0.480000<=p2<=0.520000; -0.880000<=p1<=0.920000, 0.520000<=p2<=0.560000; -0.880000<=p1<=0.920000, 0.560000<=p2<=0.600000; -0.880000<=p1<=0.920000, 0.600000<=p2<=0.640000; -0.880000<=p1<=0.920000, 0.640000<=p2<=0.680000; -0.880000<=p1<=0.920000, 0.680000<=p2<=0.720000; -0.880000<=p1<=0.920000, 0.720000<=p2<=0.760000; -0.880000<=p1<=0.920000, 0.760000<=p2<=0.800000; -0.880000<=p1<=0.920000, 0.800000<=p2<=0.840000; -0.880000<=p1<=0.920000, 0.840000<=p2<=0.880000; -0.880000<=p1<=0.920000, 0.880000<=p2<=0.920000; -0.880000<=p1<=0.920000, 0.920000<=p2<=0.960000; -0.880000<=p1<=0.920000, 0.960000<=p2<=0.999990; -0.920000<=p1<=0.960000, 0.000010<=p2<=0.040000; -0.920000<=p1<=0.960000, 0.040000<=p2<=0.080000; -0.920000<=p1<=0.960000, 0.080000<=p2<=0.120000; -0.920000<=p1<=0.960000, 0.120000<=p2<=0.160000; -0.920000<=p1<=0.960000, 0.160000<=p2<=0.200000; -0.920000<=p1<=0.960000, 0.200000<=p2<=0.240000; -0.920000<=p1<=0.960000, 0.240000<=p2<=0.280000; -0.920000<=p1<=0.960000, 0.280000<=p2<=0.320000; -0.920000<=p1<=0.960000, 0.320000<=p2<=0.360000; -0.920000<=p1<=0.960000, 0.360000<=p2<=0.400000; -0.920000<=p1<=0.960000, 0.400000<=p2<=0.440000; -0.920000<=p1<=0.960000, 0.440000<=p2<=0.480000; -0.920000<=p1<=0.960000, 0.480000<=p2<=0.520000; -0.920000<=p1<=0.960000, 0.520000<=p2<=0.560000; -0.920000<=p1<=0.960000, 0.560000<=p2<=0.600000; -0.920000<=p1<=0.960000, 0.600000<=p2<=0.640000; -0.920000<=p1<=0.960000, 0.640000<=p2<=0.680000; -0.920000<=p1<=0.960000, 0.680000<=p2<=0.720000; -0.920000<=p1<=0.960000, 0.720000<=p2<=0.760000; -0.920000<=p1<=0.960000, 0.760000<=p2<=0.800000; -0.920000<=p1<=0.960000, 0.800000<=p2<=0.840000; -0.920000<=p1<=0.960000, 0.840000<=p2<=0.880000; -0.920000<=p1<=0.960000, 0.880000<=p2<=0.920000; -0.920000<=p1<=0.960000, 0.920000<=p2<=0.960000; -0.920000<=p1<=0.960000, 0.960000<=p2<=0.999990; -0.960000<=p1<=0.999990, 0.000010<=p2<=0.040000; -0.960000<=p1<=0.999990, 0.040000<=p2<=0.080000; -0.960000<=p1<=0.999990, 0.080000<=p2<=0.120000; -0.960000<=p1<=0.999990, 0.120000<=p2<=0.160000; -0.960000<=p1<=0.999990, 0.160000<=p2<=0.200000; -0.960000<=p1<=0.999990, 0.200000<=p2<=0.240000; -0.960000<=p1<=0.999990, 0.240000<=p2<=0.280000; -0.960000<=p1<=0.999990, 0.280000<=p2<=0.320000; -0.960000<=p1<=0.999990, 0.320000<=p2<=0.360000; -0.960000<=p1<=0.999990, 0.360000<=p2<=0.400000; -0.960000<=p1<=0.999990, 0.400000<=p2<=0.440000; -0.960000<=p1<=0.999990, 0.440000<=p2<=0.480000; -0.960000<=p1<=0.999990, 0.480000<=p2<=0.520000; -0.960000<=p1<=0.999990, 0.520000<=p2<=0.560000; -0.960000<=p1<=0.999990, 0.560000<=p2<=0.600000; -0.960000<=p1<=0.999990, 0.600000<=p2<=0.640000; -0.960000<=p1<=0.999990, 0.640000<=p2<=0.680000; -0.960000<=p1<=0.999990, 0.680000<=p2<=0.720000; -0.960000<=p1<=0.999990, 0.720000<=p2<=0.760000; -0.960000<=p1<=0.999990, 0.760000<=p2<=0.800000; -0.960000<=p1<=0.999990, 0.800000<=p2<=0.840000; -0.960000<=p1<=0.999990, 0.840000<=p2<=0.880000; -0.960000<=p1<=0.999990, 0.880000<=p2<=0.920000; -0.960000<=p1<=0.999990, 0.920000<=p2<=0.960000; -0.960000<=p1<=0.999990, 0.960000<=p2<=0.999990; diff --git a/examples/pmdp/coin2/coin2_space.txt b/examples/pmdp/coin2/coin2_space.txt deleted file mode 100644 index 618c29eee..000000000 --- a/examples/pmdp/coin2/coin2_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=p1<=0.999990, 0.000010<=p2<=0.999990; - diff --git a/examples/pmdp/coin2/models b/examples/pmdp/coin2/models deleted file mode 100644 index 00f6f4cd9..000000000 --- a/examples/pmdp/coin2/models +++ /dev/null @@ -1,2 +0,0 @@ -coin2.pm -const K=2 -coin2.pm -const K=32 diff --git a/examples/pmdp/coin4/coin4.pm b/examples/pmdp/coin4/coin4.pm deleted file mode 100644 index bdb4bd877..000000000 --- a/examples/pmdp/coin4/coin4.pm +++ /dev/null @@ -1,61 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] -const double p3; // in [0.2 , 0.8] -const double p4; // in [0.2 , 0.8] - - -const int N=4; -const int K; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -module process3 = process1[pc1=pc3,coin1=coin3,p1=p3] endmodule -module process4 = process1[pc1=pc4,coin1=coin4,p1=p4] endmodule - -label "finished" = pc1=3 &pc2=3 &pc3=3 &pc4=3; -label "all_coins_equal_1" = coin1=1 &coin2=1 &coin3=1 &coin4=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin4/coin4.prctl b/examples/pmdp/coin4/coin4.prctl deleted file mode 100644 index 2fe017f65..000000000 --- a/examples/pmdp/coin4/coin4.prctl +++ /dev/null @@ -1,4 +0,0 @@ -P>=0.25 [ F "finished"&"all_coins_equal_1" ] - - - diff --git a/examples/pmdp/coin4/coin4_16.pm b/examples/pmdp/coin4/coin4_16.pm deleted file mode 100644 index 9d4f8aca5..000000000 --- a/examples/pmdp/coin4/coin4_16.pm +++ /dev/null @@ -1,61 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] -const double p3; // in [0.2 , 0.8] -const double p4; // in [0.2 , 0.8] - - -const int N=4; -const int K=16; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -module process3 = process1[pc1=pc3,coin1=coin3,p1=p3] endmodule -module process4 = process1[pc1=pc4,coin1=coin4,p1=p4] endmodule - -label "finished" = pc1=3 &pc2=3 &pc3=3 &pc4=3; -label "all_coins_equal_1" = coin1=1 &coin2=1 &coin3=1 &coin4=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin4/coin4_2.pm b/examples/pmdp/coin4/coin4_2.pm deleted file mode 100644 index bf328a4f0..000000000 --- a/examples/pmdp/coin4/coin4_2.pm +++ /dev/null @@ -1,61 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] -const double p3; // in [0.2 , 0.8] -const double p4; // in [0.2 , 0.8] - - -const int N=4; -const int K=2; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -module process3 = process1[pc1=pc3,coin1=coin3,p1=p3] endmodule -module process4 = process1[pc1=pc4,coin1=coin4,p1=p4] endmodule - -label "finished" = pc1=3 &pc2=3 &pc3=3 &pc4=3; -label "all_coins_equal_1" = coin1=1 &coin2=1 &coin3=1 &coin4=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin4/coin4_32.pm b/examples/pmdp/coin4/coin4_32.pm deleted file mode 100644 index 9ff59b79e..000000000 --- a/examples/pmdp/coin4/coin4_32.pm +++ /dev/null @@ -1,61 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] -const double p3; // in [0.2 , 0.8] -const double p4; // in [0.2 , 0.8] - - -const int N=4; -const int K=32; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -module process3 = process1[pc1=pc3,coin1=coin3,p1=p3] endmodule -module process4 = process1[pc1=pc4,coin1=coin4,p1=p4] endmodule - -label "finished" = pc1=3 &pc2=3 &pc3=3 &pc4=3; -label "all_coins_equal_1" = coin1=1 &coin2=1 &coin3=1 &coin4=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin4/coin4_4.pm b/examples/pmdp/coin4/coin4_4.pm deleted file mode 100644 index 71ff09c96..000000000 --- a/examples/pmdp/coin4/coin4_4.pm +++ /dev/null @@ -1,61 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] -const double p3; // in [0.2 , 0.8] -const double p4; // in [0.2 , 0.8] - - -const int N=4; -const int K=4; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -module process3 = process1[pc1=pc3,coin1=coin3,p1=p3] endmodule -module process4 = process1[pc1=pc4,coin1=coin4,p1=p4] endmodule - -label "finished" = pc1=3 &pc2=3 &pc3=3 &pc4=3; -label "all_coins_equal_1" = coin1=1 &coin2=1 &coin3=1 &coin4=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin4/coin4_64.pm b/examples/pmdp/coin4/coin4_64.pm deleted file mode 100644 index 11f489bd8..000000000 --- a/examples/pmdp/coin4/coin4_64.pm +++ /dev/null @@ -1,61 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] -const double p3; // in [0.2 , 0.8] -const double p4; // in [0.2 , 0.8] - - -const int N=4; -const int K=64; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -module process3 = process1[pc1=pc3,coin1=coin3,p1=p3] endmodule -module process4 = process1[pc1=pc4,coin1=coin4,p1=p4] endmodule - -label "finished" = pc1=3 &pc2=3 &pc3=3 &pc4=3; -label "all_coins_equal_1" = coin1=1 &coin2=1 &coin3=1 &coin4=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin4/coin4_8.pm b/examples/pmdp/coin4/coin4_8.pm deleted file mode 100644 index fa25965a1..000000000 --- a/examples/pmdp/coin4/coin4_8.pm +++ /dev/null @@ -1,61 +0,0 @@ -//Randomised Consensus Protocol - -mdp -const double p1; // in [0.2 , 0.8] -const double p2; // in [0.2 , 0.8] -const double p3; // in [0.2 , 0.8] -const double p4; // in [0.2 , 0.8] - - -const int N=4; -const int K=8; -const int range = 2*(K+1)*N; -const int counter_init = (K+1)*N; -const int left = N; -const int right = 2*(K+1)*N - N; - -// shared coin -global counter : [0..range] init counter_init; - -module process1 - - // program counter - pc1 : [0..3]; - // 0 - flip - // 1 - write - // 2 - check - // 3 - finished - - // local coin - coin1 : [0..1]; - - // flip coin - [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1); - // write tails -1 (reset coin to add regularity) - [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0); - // write heads +1 (reset coin to add regularity) - [] (pc1=1) & (coin1=1) & (counter (counter'=counter+1) & (pc1'=2) & (coin1'=0); - // check - // decide tails - [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0); - // decide heads - [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1); - // flip again - [] (pc1=2) & (counter>left) & (counter (pc1'=0); - // loop (all loop together when done) - [done] (pc1=3) -> (pc1'=3); - -endmodule - -module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule -module process3 = process1[pc1=pc3,coin1=coin3,p1=p3] endmodule -module process4 = process1[pc1=pc4,coin1=coin4,p1=p4] endmodule - -label "finished" = pc1=3 &pc2=3 &pc3=3 &pc4=3; -label "all_coins_equal_1" = coin1=1 &coin2=1 &coin3=1 &coin4=1 ; -rewards "steps" - true : 1; -endrewards - - - diff --git a/examples/pmdp/coin4/coin4_regions.txt b/examples/pmdp/coin4/coin4_regions.txt deleted file mode 100644 index 38d868525..000000000 --- a/examples/pmdp/coin4/coin4_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.000010<=p1<=0.200000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.200000<=p1<=0.400000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.400000<=p1<=0.600000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.600000<=p1<=0.800000, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.000010<=p2<=0.200000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.200000<=p2<=0.400000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.400000<=p2<=0.600000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.600000<=p2<=0.800000, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.000010<=p3<=0.200000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.200000<=p3<=0.400000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.400000<=p3<=0.600000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.600000<=p3<=0.800000, 0.800000<=p4<=0.999990; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.000010<=p4<=0.200000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.200000<=p4<=0.400000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.400000<=p4<=0.600000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.600000<=p4<=0.800000; -0.800000<=p1<=0.999990, 0.800000<=p2<=0.999990, 0.800000<=p3<=0.999990, 0.800000<=p4<=0.999990; diff --git a/examples/pmdp/coin4/coin4_regions2.txt b/examples/pmdp/coin4/coin4_regions2.txt deleted file mode 100644 index 2a838b2c3..000000000 --- a/examples/pmdp/coin4/coin4_regions2.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=p1<=0.040000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.000010<=p1<=0.040000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.040000<=p1<=0.080000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.080000<=p1<=0.120000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.120000<=p1<=0.160000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.160000<=p1<=0.200000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.200000<=p1<=0.240000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.240000<=p1<=0.280000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.280000<=p1<=0.320000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.320000<=p1<=0.360000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.360000<=p1<=0.400000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.400000<=p1<=0.440000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.440000<=p1<=0.480000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.480000<=p1<=0.520000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.520000<=p1<=0.560000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.560000<=p1<=0.600000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.600000<=p1<=0.640000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.640000<=p1<=0.680000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.680000<=p1<=0.720000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.720000<=p1<=0.760000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.760000<=p1<=0.800000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.800000<=p1<=0.840000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.840000<=p1<=0.880000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.880000<=p1<=0.920000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.920000<=p1<=0.960000, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.000010<=p2<=0.040000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.040000<=p2<=0.080000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.080000<=p2<=0.120000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.120000<=p2<=0.160000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.160000<=p2<=0.200000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.200000<=p2<=0.240000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.240000<=p2<=0.280000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.280000<=p2<=0.320000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.320000<=p2<=0.360000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.360000<=p2<=0.400000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.400000<=p2<=0.440000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.440000<=p2<=0.480000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.480000<=p2<=0.520000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.520000<=p2<=0.560000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.560000<=p2<=0.600000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.600000<=p2<=0.640000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.640000<=p2<=0.680000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.680000<=p2<=0.720000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.720000<=p2<=0.760000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.760000<=p2<=0.800000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.800000<=p2<=0.840000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.840000<=p2<=0.880000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.880000<=p2<=0.920000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.920000<=p2<=0.960000, 0.45<=p3<=0.55, 0.45<=p4<=0.55; -0.960000<=p1<=0.999990, 0.960000<=p2<=0.999990, 0.45<=p3<=0.55, 0.45<=p4<=0.55; diff --git a/examples/pmdp/coin4/coin4_space.txt b/examples/pmdp/coin4/coin4_space.txt deleted file mode 100644 index 4c0a341e1..000000000 --- a/examples/pmdp/coin4/coin4_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=p1<=0.999990, 0.000010<=p2<=0.999990, 0.000010<=p3<=0.999990, 0.000010<=p4<=0.999990; - diff --git a/examples/pmdp/coin4/models b/examples/pmdp/coin4/models deleted file mode 100644 index 1544a9647..000000000 --- a/examples/pmdp/coin4/models +++ /dev/null @@ -1,2 +0,0 @@ -coin4.pm -const K=2 -coin4.pm -const K=4 diff --git a/examples/pmdp/firewire/firewire.prctl b/examples/pmdp/firewire/firewire.prctl deleted file mode 100644 index badab488f..000000000 --- a/examples/pmdp/firewire/firewire.prctl +++ /dev/null @@ -1,2 +0,0 @@ -P>0.5[ F (s1=7 & s2=8) ] - diff --git a/examples/pmdp/firewire/firewire3.pm b/examples/pmdp/firewire/firewire3.pm deleted file mode 100644 index 32ba94a5e..000000000 --- a/examples/pmdp/firewire/firewire3.pm +++ /dev/null @@ -1,176 +0,0 @@ -// firewire protocol with integer semantics -// dxp/gxn 14/06/01 - -// CLOCKS -// x1 (x2) clock for node1 (node2) -// y1 and y2 (z1 and z2) clocks for wire12 (wire21) - -mdp - -// maximum and minimum delays -// fast -const int rc_fast_max = 85; -const int rc_fast_min = 76; -// slow -const int rc_slow_max = 167; -const int rc_slow_min = 159; -// delay caused by the wire length -const int delay=3; -// probability of choosing fast -const double fast1; // = 0.5; -const double slow1=1-fast1; -const double fast2; // = 0.5; -const double slow2=1-fast2; - -module wire12 - - // local state - w12 : [0..9]; - // 0 - empty - // 1 - rec_req - // 2 - rec_req_ack - // 3 - rec_ack - // 4 - rec_ack_idle - // 5 - rec_idle - // 6 - rec_idle_req - // 7 - rec_ack_req - // 8 - rec_req_idle - // 9 - rec_idle_ack - - // clock for wire12 - y1 : [0..delay+1]; - y2 : [0..delay+1]; - - // empty - // do not need y1 and y2 to increase as always reset when this state is left - // similarly can reset y1 and y2 when we re-enter this state - [snd_req12] w12=0 -> (w12'=1) & (y1'=0) & (y2'=0); - [snd_ack12] w12=0 -> (w12'=3) & (y1'=0) & (y2'=0); - [snd_idle12] w12=0 -> (w12'=5) & (y1'=0) & (y2'=0); - [time] w12=0 -> (w12'=w12); - // rec_req - [snd_req12] w12=1 -> (w12'=1); - [rec_req12] w12=1 -> (w12'=0) & (y1'=0) & (y2'=0); - [snd_ack12] w12=1 -> (w12'=2) & (y2'=0); - [snd_idle12] w12=1 -> (w12'=8) & (y2'=0); - [time] w12=1 & y2 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_req_ack - [snd_ack12] w12=2 -> (w12'=2); - [rec_req12] w12=2 -> (w12'=3); - [time] w12=2 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_ack - [snd_ack12] w12=3 -> (w12'=3); - [rec_ack12] w12=3 -> (w12'=0) & (y1'=0) & (y2'=0); - [snd_idle12] w12=3 -> (w12'=4) & (y2'=0); - [snd_req12] w12=3 -> (w12'=7) & (y2'=0); - [time] w12=3 & y2 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_ack_idle - [snd_idle12] w12=4 -> (w12'=4); - [rec_ack12] w12=4 -> (w12'=5); - [time] w12=4 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_idle - [snd_idle12] w12=5 -> (w12'=5); - [rec_idle12] w12=5 -> (w12'=0) & (y1'=0) & (y2'=0); - [snd_req12] w12=5 -> (w12'=6) & (y2'=0); - [snd_ack12] w12=5 -> (w12'=9) & (y2'=0); - [time] w12=5 & y2 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_idle_req - [snd_req12] w12=6 -> (w12'=6); - [rec_idle12] w12=6 -> (w12'=1); - [time] w12=6 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_ack_req - [snd_req12] w12=7 -> (w12'=7); - [rec_ack12] w12=7 -> (w12'=1); - [time] w12=7 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_req_idle - [snd_idle12] w12=8 -> (w12'=8); - [rec_req12] w12=8 -> (w12'=5); - [time] w12=8 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_idle_ack - [snd_ack12] w12=9 -> (w12'=9); - [rec_idle12] w12=9 -> (w12'=3); - [time] w12=9 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - -endmodule - -module node1 - - // clock for node1 - x1 : [0..168]; - - // local state - s1 : [0..8]; - // 0 - root contention - // 1 - rec_idle - // 2 - rec_req_fast - // 3 - rec_req_slow - // 4 - rec_idle_fast - // 5 - rec_idle_slow - // 6 - snd_req - // 7- almost_root - // 8 - almost_child - - // added resets to x1 when not considered again until after rest - // removed root and child (using almost root and almost child) - - // root contention immediate state) - [snd_idle12] s1=0 -> fast1 : (s1'=2) & (x1'=0) + slow1 : (s1'=3) & (x1'=0); - [rec_idle21] s1=0 -> (s1'=1); - // rec_idle immediate state) - [snd_idle12] s1=1 -> fast1 : (s1'=4) & (x1'=0) + slow1 : (s1'=5) & (x1'=0); - [rec_req21] s1=1 -> (s1'=0); - // rec_req_fast - [rec_idle21] s1=2 -> (s1'=4); - [snd_ack12] s1=2 & x1>=rc_fast_min -> (s1'=7) & (x1'=0); - [time] s1=2 & x1 (x1'=min(x1+1,168)); - // rec_req_slow - [rec_idle21] s1=3 -> (s1'=5); - [snd_ack12] s1=3 & x1>=rc_slow_min -> (s1'=7) & (x1'=0); - [time] s1=3 & x1 (x1'=min(x1+1,168)); - // rec_idle_fast - [rec_req21] s1=4 -> (s1'=2); - [snd_req12] s1=4 & x1>=rc_fast_min -> (s1'=6) & (x1'=0); - [time] s1=4 & x1 (x1'=min(x1+1,168)); - // rec_idle_slow - [rec_req21] s1=5 -> (s1'=3); - [snd_req12] s1=5 & x1>=rc_slow_min -> (s1'=6) & (x1'=0); - [time] s1=5 & x1 (x1'=min(x1+1,168)); - // snd_req - // do not use x1 until reset (in state 0 or in state 1) so do not need to increase x1 - // also can set x1 to 0 upon entering this state - [rec_req21] s1=6 -> (s1'=0); - [rec_ack21] s1=6 -> (s1'=8); - [time] s1=6 -> (s1'=s1); - // almost root (immediate) - // loop in final states to remove deadlock - [] s1=7 & s2=8 -> (s1'=s1); - [] s1=8 & s2=7 -> (s1'=s1); - [time] s1=7 -> (s1'=s1); - [time] s1=8 -> (s1'=s1); - -endmodule - -// construct remaining automata through renaming -module wire21=wire12[w12=w21, y1=z1, y2=z2, - snd_req12=snd_req21, snd_idle12=snd_idle21, snd_ack12=snd_ack21, - rec_req12=rec_req21, rec_idle12=rec_idle21, rec_ack12=rec_ack21] -endmodule -module node2=node1[s1=s2, s2=s1, x1=x2, fast1=fast2, slow1=slow2, - rec_req21=rec_req12, rec_idle21=rec_idle12, rec_ack21=rec_ack12, - snd_req12=snd_req21, snd_idle12=snd_idle21, snd_ack12=snd_ack21] -endmodule - -// labels -label "done" = (s1=8 & s2=7) | (s1=7 & s2=8); - -// reward structures - -// time -rewards "time" - [time] true : 1; -endrewards - -// time nodes sending -rewards "time_sending" - [time] (w12>0 | w21>0) : 1; -endrewards diff --git a/examples/pmdp/firewire/firewire36.pm b/examples/pmdp/firewire/firewire36.pm deleted file mode 100644 index e81dbfd8d..000000000 --- a/examples/pmdp/firewire/firewire36.pm +++ /dev/null @@ -1,176 +0,0 @@ -// firewire protocol with integer semantics -// dxp/gxn 14/06/01 - -// CLOCKS -// x1 (x2) clock for node1 (node2) -// y1 and y2 (z1 and z2) clocks for wire12 (wire21) - -mdp - -// maximum and minimum delays -// fast -const int rc_fast_max = 85; -const int rc_fast_min = 76; -// slow -const int rc_slow_max = 167; -const int rc_slow_min = 159; -// delay caused by the wire length -const int delay=36; -// probability of choosing fast -const double fast1; // = 0.5; -const double slow1=1-fast1; -const double fast2; // = 0.5; -const double slow2=1-fast2; - -module wire12 - - // local state - w12 : [0..9]; - // 0 - empty - // 1 - rec_req - // 2 - rec_req_ack - // 3 - rec_ack - // 4 - rec_ack_idle - // 5 - rec_idle - // 6 - rec_idle_req - // 7 - rec_ack_req - // 8 - rec_req_idle - // 9 - rec_idle_ack - - // clock for wire12 - y1 : [0..delay+1]; - y2 : [0..delay+1]; - - // empty - // do not need y1 and y2 to increase as always reset when this state is left - // similarly can reset y1 and y2 when we re-enter this state - [snd_req12] w12=0 -> (w12'=1) & (y1'=0) & (y2'=0); - [snd_ack12] w12=0 -> (w12'=3) & (y1'=0) & (y2'=0); - [snd_idle12] w12=0 -> (w12'=5) & (y1'=0) & (y2'=0); - [time] w12=0 -> (w12'=w12); - // rec_req - [snd_req12] w12=1 -> (w12'=1); - [rec_req12] w12=1 -> (w12'=0) & (y1'=0) & (y2'=0); - [snd_ack12] w12=1 -> (w12'=2) & (y2'=0); - [snd_idle12] w12=1 -> (w12'=8) & (y2'=0); - [time] w12=1 & y2 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_req_ack - [snd_ack12] w12=2 -> (w12'=2); - [rec_req12] w12=2 -> (w12'=3); - [time] w12=2 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_ack - [snd_ack12] w12=3 -> (w12'=3); - [rec_ack12] w12=3 -> (w12'=0) & (y1'=0) & (y2'=0); - [snd_idle12] w12=3 -> (w12'=4) & (y2'=0); - [snd_req12] w12=3 -> (w12'=7) & (y2'=0); - [time] w12=3 & y2 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_ack_idle - [snd_idle12] w12=4 -> (w12'=4); - [rec_ack12] w12=4 -> (w12'=5); - [time] w12=4 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_idle - [snd_idle12] w12=5 -> (w12'=5); - [rec_idle12] w12=5 -> (w12'=0) & (y1'=0) & (y2'=0); - [snd_req12] w12=5 -> (w12'=6) & (y2'=0); - [snd_ack12] w12=5 -> (w12'=9) & (y2'=0); - [time] w12=5 & y2 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_idle_req - [snd_req12] w12=6 -> (w12'=6); - [rec_idle12] w12=6 -> (w12'=1); - [time] w12=6 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_ack_req - [snd_req12] w12=7 -> (w12'=7); - [rec_ack12] w12=7 -> (w12'=1); - [time] w12=7 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_req_idle - [snd_idle12] w12=8 -> (w12'=8); - [rec_req12] w12=8 -> (w12'=5); - [time] w12=8 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - // rec_idle_ack - [snd_ack12] w12=9 -> (w12'=9); - [rec_idle12] w12=9 -> (w12'=3); - [time] w12=9 & y1 (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1)); - -endmodule - -module node1 - - // clock for node1 - x1 : [0..168]; - - // local state - s1 : [0..8]; - // 0 - root contention - // 1 - rec_idle - // 2 - rec_req_fast - // 3 - rec_req_slow - // 4 - rec_idle_fast - // 5 - rec_idle_slow - // 6 - snd_req - // 7- almost_root - // 8 - almost_child - - // added resets to x1 when not considered again until after rest - // removed root and child (using almost root and almost child) - - // root contention immediate state) - [snd_idle12] s1=0 -> fast1 : (s1'=2) & (x1'=0) + slow1 : (s1'=3) & (x1'=0); - [rec_idle21] s1=0 -> (s1'=1); - // rec_idle immediate state) - [snd_idle12] s1=1 -> fast1 : (s1'=4) & (x1'=0) + slow1 : (s1'=5) & (x1'=0); - [rec_req21] s1=1 -> (s1'=0); - // rec_req_fast - [rec_idle21] s1=2 -> (s1'=4); - [snd_ack12] s1=2 & x1>=rc_fast_min -> (s1'=7) & (x1'=0); - [time] s1=2 & x1 (x1'=min(x1+1,168)); - // rec_req_slow - [rec_idle21] s1=3 -> (s1'=5); - [snd_ack12] s1=3 & x1>=rc_slow_min -> (s1'=7) & (x1'=0); - [time] s1=3 & x1 (x1'=min(x1+1,168)); - // rec_idle_fast - [rec_req21] s1=4 -> (s1'=2); - [snd_req12] s1=4 & x1>=rc_fast_min -> (s1'=6) & (x1'=0); - [time] s1=4 & x1 (x1'=min(x1+1,168)); - // rec_idle_slow - [rec_req21] s1=5 -> (s1'=3); - [snd_req12] s1=5 & x1>=rc_slow_min -> (s1'=6) & (x1'=0); - [time] s1=5 & x1 (x1'=min(x1+1,168)); - // snd_req - // do not use x1 until reset (in state 0 or in state 1) so do not need to increase x1 - // also can set x1 to 0 upon entering this state - [rec_req21] s1=6 -> (s1'=0); - [rec_ack21] s1=6 -> (s1'=8); - [time] s1=6 -> (s1'=s1); - // almost root (immediate) - // loop in final states to remove deadlock - [] s1=7 & s2=8 -> (s1'=s1); - [] s1=8 & s2=7 -> (s1'=s1); - [time] s1=7 -> (s1'=s1); - [time] s1=8 -> (s1'=s1); - -endmodule - -// construct remaining automata through renaming -module wire21=wire12[w12=w21, y1=z1, y2=z2, - snd_req12=snd_req21, snd_idle12=snd_idle21, snd_ack12=snd_ack21, - rec_req12=rec_req21, rec_idle12=rec_idle21, rec_ack12=rec_ack21] -endmodule -module node2=node1[s1=s2, s2=s1, x1=x2, fast1=fast2, slow1=slow2, - rec_req21=rec_req12, rec_idle21=rec_idle12, rec_ack21=rec_ack12, - snd_req12=snd_req21, snd_idle12=snd_idle21, snd_ack12=snd_ack21] -endmodule - -// labels -label "done" = (s1=8 & s2=7) | (s1=7 & s2=8); - -// reward structures - -// time -rewards "time" - [time] true : 1; -endrewards - -// time nodes sending -rewards "time_sending" - [time] (w12>0 | w21>0) : 1; -endrewards diff --git a/examples/pmdp/firewire/firewire_regions.txt b/examples/pmdp/firewire/firewire_regions.txt deleted file mode 100644 index c7c9b5a9f..000000000 --- a/examples/pmdp/firewire/firewire_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=fast1<=0.040000, 0.000010<=fast2<=0.040000; -0.000010<=fast1<=0.040000, 0.040000<=fast2<=0.080000; -0.000010<=fast1<=0.040000, 0.080000<=fast2<=0.120000; -0.000010<=fast1<=0.040000, 0.120000<=fast2<=0.160000; -0.000010<=fast1<=0.040000, 0.160000<=fast2<=0.200000; -0.000010<=fast1<=0.040000, 0.200000<=fast2<=0.240000; -0.000010<=fast1<=0.040000, 0.240000<=fast2<=0.280000; -0.000010<=fast1<=0.040000, 0.280000<=fast2<=0.320000; -0.000010<=fast1<=0.040000, 0.320000<=fast2<=0.360000; -0.000010<=fast1<=0.040000, 0.360000<=fast2<=0.400000; -0.000010<=fast1<=0.040000, 0.400000<=fast2<=0.440000; -0.000010<=fast1<=0.040000, 0.440000<=fast2<=0.480000; -0.000010<=fast1<=0.040000, 0.480000<=fast2<=0.520000; -0.000010<=fast1<=0.040000, 0.520000<=fast2<=0.560000; -0.000010<=fast1<=0.040000, 0.560000<=fast2<=0.600000; -0.000010<=fast1<=0.040000, 0.600000<=fast2<=0.640000; -0.000010<=fast1<=0.040000, 0.640000<=fast2<=0.680000; -0.000010<=fast1<=0.040000, 0.680000<=fast2<=0.720000; -0.000010<=fast1<=0.040000, 0.720000<=fast2<=0.760000; -0.000010<=fast1<=0.040000, 0.760000<=fast2<=0.800000; -0.000010<=fast1<=0.040000, 0.800000<=fast2<=0.840000; -0.000010<=fast1<=0.040000, 0.840000<=fast2<=0.880000; -0.000010<=fast1<=0.040000, 0.880000<=fast2<=0.920000; -0.000010<=fast1<=0.040000, 0.920000<=fast2<=0.960000; -0.000010<=fast1<=0.040000, 0.960000<=fast2<=0.999990; -0.040000<=fast1<=0.080000, 0.000010<=fast2<=0.040000; -0.040000<=fast1<=0.080000, 0.040000<=fast2<=0.080000; -0.040000<=fast1<=0.080000, 0.080000<=fast2<=0.120000; -0.040000<=fast1<=0.080000, 0.120000<=fast2<=0.160000; -0.040000<=fast1<=0.080000, 0.160000<=fast2<=0.200000; -0.040000<=fast1<=0.080000, 0.200000<=fast2<=0.240000; -0.040000<=fast1<=0.080000, 0.240000<=fast2<=0.280000; -0.040000<=fast1<=0.080000, 0.280000<=fast2<=0.320000; -0.040000<=fast1<=0.080000, 0.320000<=fast2<=0.360000; -0.040000<=fast1<=0.080000, 0.360000<=fast2<=0.400000; -0.040000<=fast1<=0.080000, 0.400000<=fast2<=0.440000; -0.040000<=fast1<=0.080000, 0.440000<=fast2<=0.480000; -0.040000<=fast1<=0.080000, 0.480000<=fast2<=0.520000; -0.040000<=fast1<=0.080000, 0.520000<=fast2<=0.560000; -0.040000<=fast1<=0.080000, 0.560000<=fast2<=0.600000; -0.040000<=fast1<=0.080000, 0.600000<=fast2<=0.640000; -0.040000<=fast1<=0.080000, 0.640000<=fast2<=0.680000; -0.040000<=fast1<=0.080000, 0.680000<=fast2<=0.720000; -0.040000<=fast1<=0.080000, 0.720000<=fast2<=0.760000; -0.040000<=fast1<=0.080000, 0.760000<=fast2<=0.800000; -0.040000<=fast1<=0.080000, 0.800000<=fast2<=0.840000; -0.040000<=fast1<=0.080000, 0.840000<=fast2<=0.880000; -0.040000<=fast1<=0.080000, 0.880000<=fast2<=0.920000; -0.040000<=fast1<=0.080000, 0.920000<=fast2<=0.960000; -0.040000<=fast1<=0.080000, 0.960000<=fast2<=0.999990; -0.080000<=fast1<=0.120000, 0.000010<=fast2<=0.040000; -0.080000<=fast1<=0.120000, 0.040000<=fast2<=0.080000; -0.080000<=fast1<=0.120000, 0.080000<=fast2<=0.120000; -0.080000<=fast1<=0.120000, 0.120000<=fast2<=0.160000; -0.080000<=fast1<=0.120000, 0.160000<=fast2<=0.200000; -0.080000<=fast1<=0.120000, 0.200000<=fast2<=0.240000; -0.080000<=fast1<=0.120000, 0.240000<=fast2<=0.280000; -0.080000<=fast1<=0.120000, 0.280000<=fast2<=0.320000; -0.080000<=fast1<=0.120000, 0.320000<=fast2<=0.360000; -0.080000<=fast1<=0.120000, 0.360000<=fast2<=0.400000; -0.080000<=fast1<=0.120000, 0.400000<=fast2<=0.440000; -0.080000<=fast1<=0.120000, 0.440000<=fast2<=0.480000; -0.080000<=fast1<=0.120000, 0.480000<=fast2<=0.520000; -0.080000<=fast1<=0.120000, 0.520000<=fast2<=0.560000; -0.080000<=fast1<=0.120000, 0.560000<=fast2<=0.600000; -0.080000<=fast1<=0.120000, 0.600000<=fast2<=0.640000; -0.080000<=fast1<=0.120000, 0.640000<=fast2<=0.680000; -0.080000<=fast1<=0.120000, 0.680000<=fast2<=0.720000; -0.080000<=fast1<=0.120000, 0.720000<=fast2<=0.760000; -0.080000<=fast1<=0.120000, 0.760000<=fast2<=0.800000; -0.080000<=fast1<=0.120000, 0.800000<=fast2<=0.840000; -0.080000<=fast1<=0.120000, 0.840000<=fast2<=0.880000; -0.080000<=fast1<=0.120000, 0.880000<=fast2<=0.920000; -0.080000<=fast1<=0.120000, 0.920000<=fast2<=0.960000; -0.080000<=fast1<=0.120000, 0.960000<=fast2<=0.999990; -0.120000<=fast1<=0.160000, 0.000010<=fast2<=0.040000; -0.120000<=fast1<=0.160000, 0.040000<=fast2<=0.080000; -0.120000<=fast1<=0.160000, 0.080000<=fast2<=0.120000; -0.120000<=fast1<=0.160000, 0.120000<=fast2<=0.160000; -0.120000<=fast1<=0.160000, 0.160000<=fast2<=0.200000; -0.120000<=fast1<=0.160000, 0.200000<=fast2<=0.240000; -0.120000<=fast1<=0.160000, 0.240000<=fast2<=0.280000; -0.120000<=fast1<=0.160000, 0.280000<=fast2<=0.320000; -0.120000<=fast1<=0.160000, 0.320000<=fast2<=0.360000; -0.120000<=fast1<=0.160000, 0.360000<=fast2<=0.400000; -0.120000<=fast1<=0.160000, 0.400000<=fast2<=0.440000; -0.120000<=fast1<=0.160000, 0.440000<=fast2<=0.480000; -0.120000<=fast1<=0.160000, 0.480000<=fast2<=0.520000; -0.120000<=fast1<=0.160000, 0.520000<=fast2<=0.560000; -0.120000<=fast1<=0.160000, 0.560000<=fast2<=0.600000; -0.120000<=fast1<=0.160000, 0.600000<=fast2<=0.640000; -0.120000<=fast1<=0.160000, 0.640000<=fast2<=0.680000; -0.120000<=fast1<=0.160000, 0.680000<=fast2<=0.720000; -0.120000<=fast1<=0.160000, 0.720000<=fast2<=0.760000; -0.120000<=fast1<=0.160000, 0.760000<=fast2<=0.800000; -0.120000<=fast1<=0.160000, 0.800000<=fast2<=0.840000; -0.120000<=fast1<=0.160000, 0.840000<=fast2<=0.880000; -0.120000<=fast1<=0.160000, 0.880000<=fast2<=0.920000; -0.120000<=fast1<=0.160000, 0.920000<=fast2<=0.960000; -0.120000<=fast1<=0.160000, 0.960000<=fast2<=0.999990; -0.160000<=fast1<=0.200000, 0.000010<=fast2<=0.040000; -0.160000<=fast1<=0.200000, 0.040000<=fast2<=0.080000; -0.160000<=fast1<=0.200000, 0.080000<=fast2<=0.120000; -0.160000<=fast1<=0.200000, 0.120000<=fast2<=0.160000; -0.160000<=fast1<=0.200000, 0.160000<=fast2<=0.200000; -0.160000<=fast1<=0.200000, 0.200000<=fast2<=0.240000; -0.160000<=fast1<=0.200000, 0.240000<=fast2<=0.280000; -0.160000<=fast1<=0.200000, 0.280000<=fast2<=0.320000; -0.160000<=fast1<=0.200000, 0.320000<=fast2<=0.360000; -0.160000<=fast1<=0.200000, 0.360000<=fast2<=0.400000; -0.160000<=fast1<=0.200000, 0.400000<=fast2<=0.440000; -0.160000<=fast1<=0.200000, 0.440000<=fast2<=0.480000; -0.160000<=fast1<=0.200000, 0.480000<=fast2<=0.520000; -0.160000<=fast1<=0.200000, 0.520000<=fast2<=0.560000; -0.160000<=fast1<=0.200000, 0.560000<=fast2<=0.600000; -0.160000<=fast1<=0.200000, 0.600000<=fast2<=0.640000; -0.160000<=fast1<=0.200000, 0.640000<=fast2<=0.680000; -0.160000<=fast1<=0.200000, 0.680000<=fast2<=0.720000; -0.160000<=fast1<=0.200000, 0.720000<=fast2<=0.760000; -0.160000<=fast1<=0.200000, 0.760000<=fast2<=0.800000; -0.160000<=fast1<=0.200000, 0.800000<=fast2<=0.840000; -0.160000<=fast1<=0.200000, 0.840000<=fast2<=0.880000; -0.160000<=fast1<=0.200000, 0.880000<=fast2<=0.920000; -0.160000<=fast1<=0.200000, 0.920000<=fast2<=0.960000; -0.160000<=fast1<=0.200000, 0.960000<=fast2<=0.999990; -0.200000<=fast1<=0.240000, 0.000010<=fast2<=0.040000; -0.200000<=fast1<=0.240000, 0.040000<=fast2<=0.080000; -0.200000<=fast1<=0.240000, 0.080000<=fast2<=0.120000; -0.200000<=fast1<=0.240000, 0.120000<=fast2<=0.160000; -0.200000<=fast1<=0.240000, 0.160000<=fast2<=0.200000; -0.200000<=fast1<=0.240000, 0.200000<=fast2<=0.240000; -0.200000<=fast1<=0.240000, 0.240000<=fast2<=0.280000; -0.200000<=fast1<=0.240000, 0.280000<=fast2<=0.320000; -0.200000<=fast1<=0.240000, 0.320000<=fast2<=0.360000; -0.200000<=fast1<=0.240000, 0.360000<=fast2<=0.400000; -0.200000<=fast1<=0.240000, 0.400000<=fast2<=0.440000; -0.200000<=fast1<=0.240000, 0.440000<=fast2<=0.480000; -0.200000<=fast1<=0.240000, 0.480000<=fast2<=0.520000; -0.200000<=fast1<=0.240000, 0.520000<=fast2<=0.560000; -0.200000<=fast1<=0.240000, 0.560000<=fast2<=0.600000; -0.200000<=fast1<=0.240000, 0.600000<=fast2<=0.640000; -0.200000<=fast1<=0.240000, 0.640000<=fast2<=0.680000; -0.200000<=fast1<=0.240000, 0.680000<=fast2<=0.720000; -0.200000<=fast1<=0.240000, 0.720000<=fast2<=0.760000; -0.200000<=fast1<=0.240000, 0.760000<=fast2<=0.800000; -0.200000<=fast1<=0.240000, 0.800000<=fast2<=0.840000; -0.200000<=fast1<=0.240000, 0.840000<=fast2<=0.880000; -0.200000<=fast1<=0.240000, 0.880000<=fast2<=0.920000; -0.200000<=fast1<=0.240000, 0.920000<=fast2<=0.960000; -0.200000<=fast1<=0.240000, 0.960000<=fast2<=0.999990; -0.240000<=fast1<=0.280000, 0.000010<=fast2<=0.040000; -0.240000<=fast1<=0.280000, 0.040000<=fast2<=0.080000; -0.240000<=fast1<=0.280000, 0.080000<=fast2<=0.120000; -0.240000<=fast1<=0.280000, 0.120000<=fast2<=0.160000; -0.240000<=fast1<=0.280000, 0.160000<=fast2<=0.200000; -0.240000<=fast1<=0.280000, 0.200000<=fast2<=0.240000; -0.240000<=fast1<=0.280000, 0.240000<=fast2<=0.280000; -0.240000<=fast1<=0.280000, 0.280000<=fast2<=0.320000; -0.240000<=fast1<=0.280000, 0.320000<=fast2<=0.360000; -0.240000<=fast1<=0.280000, 0.360000<=fast2<=0.400000; -0.240000<=fast1<=0.280000, 0.400000<=fast2<=0.440000; -0.240000<=fast1<=0.280000, 0.440000<=fast2<=0.480000; -0.240000<=fast1<=0.280000, 0.480000<=fast2<=0.520000; -0.240000<=fast1<=0.280000, 0.520000<=fast2<=0.560000; -0.240000<=fast1<=0.280000, 0.560000<=fast2<=0.600000; -0.240000<=fast1<=0.280000, 0.600000<=fast2<=0.640000; -0.240000<=fast1<=0.280000, 0.640000<=fast2<=0.680000; -0.240000<=fast1<=0.280000, 0.680000<=fast2<=0.720000; -0.240000<=fast1<=0.280000, 0.720000<=fast2<=0.760000; -0.240000<=fast1<=0.280000, 0.760000<=fast2<=0.800000; -0.240000<=fast1<=0.280000, 0.800000<=fast2<=0.840000; -0.240000<=fast1<=0.280000, 0.840000<=fast2<=0.880000; -0.240000<=fast1<=0.280000, 0.880000<=fast2<=0.920000; -0.240000<=fast1<=0.280000, 0.920000<=fast2<=0.960000; -0.240000<=fast1<=0.280000, 0.960000<=fast2<=0.999990; -0.280000<=fast1<=0.320000, 0.000010<=fast2<=0.040000; -0.280000<=fast1<=0.320000, 0.040000<=fast2<=0.080000; -0.280000<=fast1<=0.320000, 0.080000<=fast2<=0.120000; -0.280000<=fast1<=0.320000, 0.120000<=fast2<=0.160000; -0.280000<=fast1<=0.320000, 0.160000<=fast2<=0.200000; -0.280000<=fast1<=0.320000, 0.200000<=fast2<=0.240000; -0.280000<=fast1<=0.320000, 0.240000<=fast2<=0.280000; -0.280000<=fast1<=0.320000, 0.280000<=fast2<=0.320000; -0.280000<=fast1<=0.320000, 0.320000<=fast2<=0.360000; -0.280000<=fast1<=0.320000, 0.360000<=fast2<=0.400000; -0.280000<=fast1<=0.320000, 0.400000<=fast2<=0.440000; -0.280000<=fast1<=0.320000, 0.440000<=fast2<=0.480000; -0.280000<=fast1<=0.320000, 0.480000<=fast2<=0.520000; -0.280000<=fast1<=0.320000, 0.520000<=fast2<=0.560000; -0.280000<=fast1<=0.320000, 0.560000<=fast2<=0.600000; -0.280000<=fast1<=0.320000, 0.600000<=fast2<=0.640000; -0.280000<=fast1<=0.320000, 0.640000<=fast2<=0.680000; -0.280000<=fast1<=0.320000, 0.680000<=fast2<=0.720000; -0.280000<=fast1<=0.320000, 0.720000<=fast2<=0.760000; -0.280000<=fast1<=0.320000, 0.760000<=fast2<=0.800000; -0.280000<=fast1<=0.320000, 0.800000<=fast2<=0.840000; -0.280000<=fast1<=0.320000, 0.840000<=fast2<=0.880000; -0.280000<=fast1<=0.320000, 0.880000<=fast2<=0.920000; -0.280000<=fast1<=0.320000, 0.920000<=fast2<=0.960000; -0.280000<=fast1<=0.320000, 0.960000<=fast2<=0.999990; -0.320000<=fast1<=0.360000, 0.000010<=fast2<=0.040000; -0.320000<=fast1<=0.360000, 0.040000<=fast2<=0.080000; -0.320000<=fast1<=0.360000, 0.080000<=fast2<=0.120000; -0.320000<=fast1<=0.360000, 0.120000<=fast2<=0.160000; -0.320000<=fast1<=0.360000, 0.160000<=fast2<=0.200000; -0.320000<=fast1<=0.360000, 0.200000<=fast2<=0.240000; -0.320000<=fast1<=0.360000, 0.240000<=fast2<=0.280000; -0.320000<=fast1<=0.360000, 0.280000<=fast2<=0.320000; -0.320000<=fast1<=0.360000, 0.320000<=fast2<=0.360000; -0.320000<=fast1<=0.360000, 0.360000<=fast2<=0.400000; -0.320000<=fast1<=0.360000, 0.400000<=fast2<=0.440000; -0.320000<=fast1<=0.360000, 0.440000<=fast2<=0.480000; -0.320000<=fast1<=0.360000, 0.480000<=fast2<=0.520000; -0.320000<=fast1<=0.360000, 0.520000<=fast2<=0.560000; -0.320000<=fast1<=0.360000, 0.560000<=fast2<=0.600000; -0.320000<=fast1<=0.360000, 0.600000<=fast2<=0.640000; -0.320000<=fast1<=0.360000, 0.640000<=fast2<=0.680000; -0.320000<=fast1<=0.360000, 0.680000<=fast2<=0.720000; -0.320000<=fast1<=0.360000, 0.720000<=fast2<=0.760000; -0.320000<=fast1<=0.360000, 0.760000<=fast2<=0.800000; -0.320000<=fast1<=0.360000, 0.800000<=fast2<=0.840000; -0.320000<=fast1<=0.360000, 0.840000<=fast2<=0.880000; -0.320000<=fast1<=0.360000, 0.880000<=fast2<=0.920000; -0.320000<=fast1<=0.360000, 0.920000<=fast2<=0.960000; -0.320000<=fast1<=0.360000, 0.960000<=fast2<=0.999990; -0.360000<=fast1<=0.400000, 0.000010<=fast2<=0.040000; -0.360000<=fast1<=0.400000, 0.040000<=fast2<=0.080000; -0.360000<=fast1<=0.400000, 0.080000<=fast2<=0.120000; -0.360000<=fast1<=0.400000, 0.120000<=fast2<=0.160000; -0.360000<=fast1<=0.400000, 0.160000<=fast2<=0.200000; -0.360000<=fast1<=0.400000, 0.200000<=fast2<=0.240000; -0.360000<=fast1<=0.400000, 0.240000<=fast2<=0.280000; -0.360000<=fast1<=0.400000, 0.280000<=fast2<=0.320000; -0.360000<=fast1<=0.400000, 0.320000<=fast2<=0.360000; -0.360000<=fast1<=0.400000, 0.360000<=fast2<=0.400000; -0.360000<=fast1<=0.400000, 0.400000<=fast2<=0.440000; -0.360000<=fast1<=0.400000, 0.440000<=fast2<=0.480000; -0.360000<=fast1<=0.400000, 0.480000<=fast2<=0.520000; -0.360000<=fast1<=0.400000, 0.520000<=fast2<=0.560000; -0.360000<=fast1<=0.400000, 0.560000<=fast2<=0.600000; -0.360000<=fast1<=0.400000, 0.600000<=fast2<=0.640000; -0.360000<=fast1<=0.400000, 0.640000<=fast2<=0.680000; -0.360000<=fast1<=0.400000, 0.680000<=fast2<=0.720000; -0.360000<=fast1<=0.400000, 0.720000<=fast2<=0.760000; -0.360000<=fast1<=0.400000, 0.760000<=fast2<=0.800000; -0.360000<=fast1<=0.400000, 0.800000<=fast2<=0.840000; -0.360000<=fast1<=0.400000, 0.840000<=fast2<=0.880000; -0.360000<=fast1<=0.400000, 0.880000<=fast2<=0.920000; -0.360000<=fast1<=0.400000, 0.920000<=fast2<=0.960000; -0.360000<=fast1<=0.400000, 0.960000<=fast2<=0.999990; -0.400000<=fast1<=0.440000, 0.000010<=fast2<=0.040000; -0.400000<=fast1<=0.440000, 0.040000<=fast2<=0.080000; -0.400000<=fast1<=0.440000, 0.080000<=fast2<=0.120000; -0.400000<=fast1<=0.440000, 0.120000<=fast2<=0.160000; -0.400000<=fast1<=0.440000, 0.160000<=fast2<=0.200000; -0.400000<=fast1<=0.440000, 0.200000<=fast2<=0.240000; -0.400000<=fast1<=0.440000, 0.240000<=fast2<=0.280000; -0.400000<=fast1<=0.440000, 0.280000<=fast2<=0.320000; -0.400000<=fast1<=0.440000, 0.320000<=fast2<=0.360000; -0.400000<=fast1<=0.440000, 0.360000<=fast2<=0.400000; -0.400000<=fast1<=0.440000, 0.400000<=fast2<=0.440000; -0.400000<=fast1<=0.440000, 0.440000<=fast2<=0.480000; -0.400000<=fast1<=0.440000, 0.480000<=fast2<=0.520000; -0.400000<=fast1<=0.440000, 0.520000<=fast2<=0.560000; -0.400000<=fast1<=0.440000, 0.560000<=fast2<=0.600000; -0.400000<=fast1<=0.440000, 0.600000<=fast2<=0.640000; -0.400000<=fast1<=0.440000, 0.640000<=fast2<=0.680000; -0.400000<=fast1<=0.440000, 0.680000<=fast2<=0.720000; -0.400000<=fast1<=0.440000, 0.720000<=fast2<=0.760000; -0.400000<=fast1<=0.440000, 0.760000<=fast2<=0.800000; -0.400000<=fast1<=0.440000, 0.800000<=fast2<=0.840000; -0.400000<=fast1<=0.440000, 0.840000<=fast2<=0.880000; -0.400000<=fast1<=0.440000, 0.880000<=fast2<=0.920000; -0.400000<=fast1<=0.440000, 0.920000<=fast2<=0.960000; -0.400000<=fast1<=0.440000, 0.960000<=fast2<=0.999990; -0.440000<=fast1<=0.480000, 0.000010<=fast2<=0.040000; -0.440000<=fast1<=0.480000, 0.040000<=fast2<=0.080000; -0.440000<=fast1<=0.480000, 0.080000<=fast2<=0.120000; -0.440000<=fast1<=0.480000, 0.120000<=fast2<=0.160000; -0.440000<=fast1<=0.480000, 0.160000<=fast2<=0.200000; -0.440000<=fast1<=0.480000, 0.200000<=fast2<=0.240000; -0.440000<=fast1<=0.480000, 0.240000<=fast2<=0.280000; -0.440000<=fast1<=0.480000, 0.280000<=fast2<=0.320000; -0.440000<=fast1<=0.480000, 0.320000<=fast2<=0.360000; -0.440000<=fast1<=0.480000, 0.360000<=fast2<=0.400000; -0.440000<=fast1<=0.480000, 0.400000<=fast2<=0.440000; -0.440000<=fast1<=0.480000, 0.440000<=fast2<=0.480000; -0.440000<=fast1<=0.480000, 0.480000<=fast2<=0.520000; -0.440000<=fast1<=0.480000, 0.520000<=fast2<=0.560000; -0.440000<=fast1<=0.480000, 0.560000<=fast2<=0.600000; -0.440000<=fast1<=0.480000, 0.600000<=fast2<=0.640000; -0.440000<=fast1<=0.480000, 0.640000<=fast2<=0.680000; -0.440000<=fast1<=0.480000, 0.680000<=fast2<=0.720000; -0.440000<=fast1<=0.480000, 0.720000<=fast2<=0.760000; -0.440000<=fast1<=0.480000, 0.760000<=fast2<=0.800000; -0.440000<=fast1<=0.480000, 0.800000<=fast2<=0.840000; -0.440000<=fast1<=0.480000, 0.840000<=fast2<=0.880000; -0.440000<=fast1<=0.480000, 0.880000<=fast2<=0.920000; -0.440000<=fast1<=0.480000, 0.920000<=fast2<=0.960000; -0.440000<=fast1<=0.480000, 0.960000<=fast2<=0.999990; -0.480000<=fast1<=0.520000, 0.000010<=fast2<=0.040000; -0.480000<=fast1<=0.520000, 0.040000<=fast2<=0.080000; -0.480000<=fast1<=0.520000, 0.080000<=fast2<=0.120000; -0.480000<=fast1<=0.520000, 0.120000<=fast2<=0.160000; -0.480000<=fast1<=0.520000, 0.160000<=fast2<=0.200000; -0.480000<=fast1<=0.520000, 0.200000<=fast2<=0.240000; -0.480000<=fast1<=0.520000, 0.240000<=fast2<=0.280000; -0.480000<=fast1<=0.520000, 0.280000<=fast2<=0.320000; -0.480000<=fast1<=0.520000, 0.320000<=fast2<=0.360000; -0.480000<=fast1<=0.520000, 0.360000<=fast2<=0.400000; -0.480000<=fast1<=0.520000, 0.400000<=fast2<=0.440000; -0.480000<=fast1<=0.520000, 0.440000<=fast2<=0.480000; -0.480000<=fast1<=0.520000, 0.480000<=fast2<=0.520000; -0.480000<=fast1<=0.520000, 0.520000<=fast2<=0.560000; -0.480000<=fast1<=0.520000, 0.560000<=fast2<=0.600000; -0.480000<=fast1<=0.520000, 0.600000<=fast2<=0.640000; -0.480000<=fast1<=0.520000, 0.640000<=fast2<=0.680000; -0.480000<=fast1<=0.520000, 0.680000<=fast2<=0.720000; -0.480000<=fast1<=0.520000, 0.720000<=fast2<=0.760000; -0.480000<=fast1<=0.520000, 0.760000<=fast2<=0.800000; -0.480000<=fast1<=0.520000, 0.800000<=fast2<=0.840000; -0.480000<=fast1<=0.520000, 0.840000<=fast2<=0.880000; -0.480000<=fast1<=0.520000, 0.880000<=fast2<=0.920000; -0.480000<=fast1<=0.520000, 0.920000<=fast2<=0.960000; -0.480000<=fast1<=0.520000, 0.960000<=fast2<=0.999990; -0.520000<=fast1<=0.560000, 0.000010<=fast2<=0.040000; -0.520000<=fast1<=0.560000, 0.040000<=fast2<=0.080000; -0.520000<=fast1<=0.560000, 0.080000<=fast2<=0.120000; -0.520000<=fast1<=0.560000, 0.120000<=fast2<=0.160000; -0.520000<=fast1<=0.560000, 0.160000<=fast2<=0.200000; -0.520000<=fast1<=0.560000, 0.200000<=fast2<=0.240000; -0.520000<=fast1<=0.560000, 0.240000<=fast2<=0.280000; -0.520000<=fast1<=0.560000, 0.280000<=fast2<=0.320000; -0.520000<=fast1<=0.560000, 0.320000<=fast2<=0.360000; -0.520000<=fast1<=0.560000, 0.360000<=fast2<=0.400000; -0.520000<=fast1<=0.560000, 0.400000<=fast2<=0.440000; -0.520000<=fast1<=0.560000, 0.440000<=fast2<=0.480000; -0.520000<=fast1<=0.560000, 0.480000<=fast2<=0.520000; -0.520000<=fast1<=0.560000, 0.520000<=fast2<=0.560000; -0.520000<=fast1<=0.560000, 0.560000<=fast2<=0.600000; -0.520000<=fast1<=0.560000, 0.600000<=fast2<=0.640000; -0.520000<=fast1<=0.560000, 0.640000<=fast2<=0.680000; -0.520000<=fast1<=0.560000, 0.680000<=fast2<=0.720000; -0.520000<=fast1<=0.560000, 0.720000<=fast2<=0.760000; -0.520000<=fast1<=0.560000, 0.760000<=fast2<=0.800000; -0.520000<=fast1<=0.560000, 0.800000<=fast2<=0.840000; -0.520000<=fast1<=0.560000, 0.840000<=fast2<=0.880000; -0.520000<=fast1<=0.560000, 0.880000<=fast2<=0.920000; -0.520000<=fast1<=0.560000, 0.920000<=fast2<=0.960000; -0.520000<=fast1<=0.560000, 0.960000<=fast2<=0.999990; -0.560000<=fast1<=0.600000, 0.000010<=fast2<=0.040000; -0.560000<=fast1<=0.600000, 0.040000<=fast2<=0.080000; -0.560000<=fast1<=0.600000, 0.080000<=fast2<=0.120000; -0.560000<=fast1<=0.600000, 0.120000<=fast2<=0.160000; -0.560000<=fast1<=0.600000, 0.160000<=fast2<=0.200000; -0.560000<=fast1<=0.600000, 0.200000<=fast2<=0.240000; -0.560000<=fast1<=0.600000, 0.240000<=fast2<=0.280000; -0.560000<=fast1<=0.600000, 0.280000<=fast2<=0.320000; -0.560000<=fast1<=0.600000, 0.320000<=fast2<=0.360000; -0.560000<=fast1<=0.600000, 0.360000<=fast2<=0.400000; -0.560000<=fast1<=0.600000, 0.400000<=fast2<=0.440000; -0.560000<=fast1<=0.600000, 0.440000<=fast2<=0.480000; -0.560000<=fast1<=0.600000, 0.480000<=fast2<=0.520000; -0.560000<=fast1<=0.600000, 0.520000<=fast2<=0.560000; -0.560000<=fast1<=0.600000, 0.560000<=fast2<=0.600000; -0.560000<=fast1<=0.600000, 0.600000<=fast2<=0.640000; -0.560000<=fast1<=0.600000, 0.640000<=fast2<=0.680000; -0.560000<=fast1<=0.600000, 0.680000<=fast2<=0.720000; -0.560000<=fast1<=0.600000, 0.720000<=fast2<=0.760000; -0.560000<=fast1<=0.600000, 0.760000<=fast2<=0.800000; -0.560000<=fast1<=0.600000, 0.800000<=fast2<=0.840000; -0.560000<=fast1<=0.600000, 0.840000<=fast2<=0.880000; -0.560000<=fast1<=0.600000, 0.880000<=fast2<=0.920000; -0.560000<=fast1<=0.600000, 0.920000<=fast2<=0.960000; -0.560000<=fast1<=0.600000, 0.960000<=fast2<=0.999990; -0.600000<=fast1<=0.640000, 0.000010<=fast2<=0.040000; -0.600000<=fast1<=0.640000, 0.040000<=fast2<=0.080000; -0.600000<=fast1<=0.640000, 0.080000<=fast2<=0.120000; -0.600000<=fast1<=0.640000, 0.120000<=fast2<=0.160000; -0.600000<=fast1<=0.640000, 0.160000<=fast2<=0.200000; -0.600000<=fast1<=0.640000, 0.200000<=fast2<=0.240000; -0.600000<=fast1<=0.640000, 0.240000<=fast2<=0.280000; -0.600000<=fast1<=0.640000, 0.280000<=fast2<=0.320000; -0.600000<=fast1<=0.640000, 0.320000<=fast2<=0.360000; -0.600000<=fast1<=0.640000, 0.360000<=fast2<=0.400000; -0.600000<=fast1<=0.640000, 0.400000<=fast2<=0.440000; -0.600000<=fast1<=0.640000, 0.440000<=fast2<=0.480000; -0.600000<=fast1<=0.640000, 0.480000<=fast2<=0.520000; -0.600000<=fast1<=0.640000, 0.520000<=fast2<=0.560000; -0.600000<=fast1<=0.640000, 0.560000<=fast2<=0.600000; -0.600000<=fast1<=0.640000, 0.600000<=fast2<=0.640000; -0.600000<=fast1<=0.640000, 0.640000<=fast2<=0.680000; -0.600000<=fast1<=0.640000, 0.680000<=fast2<=0.720000; -0.600000<=fast1<=0.640000, 0.720000<=fast2<=0.760000; -0.600000<=fast1<=0.640000, 0.760000<=fast2<=0.800000; -0.600000<=fast1<=0.640000, 0.800000<=fast2<=0.840000; -0.600000<=fast1<=0.640000, 0.840000<=fast2<=0.880000; -0.600000<=fast1<=0.640000, 0.880000<=fast2<=0.920000; -0.600000<=fast1<=0.640000, 0.920000<=fast2<=0.960000; -0.600000<=fast1<=0.640000, 0.960000<=fast2<=0.999990; -0.640000<=fast1<=0.680000, 0.000010<=fast2<=0.040000; -0.640000<=fast1<=0.680000, 0.040000<=fast2<=0.080000; -0.640000<=fast1<=0.680000, 0.080000<=fast2<=0.120000; -0.640000<=fast1<=0.680000, 0.120000<=fast2<=0.160000; -0.640000<=fast1<=0.680000, 0.160000<=fast2<=0.200000; -0.640000<=fast1<=0.680000, 0.200000<=fast2<=0.240000; -0.640000<=fast1<=0.680000, 0.240000<=fast2<=0.280000; -0.640000<=fast1<=0.680000, 0.280000<=fast2<=0.320000; -0.640000<=fast1<=0.680000, 0.320000<=fast2<=0.360000; -0.640000<=fast1<=0.680000, 0.360000<=fast2<=0.400000; -0.640000<=fast1<=0.680000, 0.400000<=fast2<=0.440000; -0.640000<=fast1<=0.680000, 0.440000<=fast2<=0.480000; -0.640000<=fast1<=0.680000, 0.480000<=fast2<=0.520000; -0.640000<=fast1<=0.680000, 0.520000<=fast2<=0.560000; -0.640000<=fast1<=0.680000, 0.560000<=fast2<=0.600000; -0.640000<=fast1<=0.680000, 0.600000<=fast2<=0.640000; -0.640000<=fast1<=0.680000, 0.640000<=fast2<=0.680000; -0.640000<=fast1<=0.680000, 0.680000<=fast2<=0.720000; -0.640000<=fast1<=0.680000, 0.720000<=fast2<=0.760000; -0.640000<=fast1<=0.680000, 0.760000<=fast2<=0.800000; -0.640000<=fast1<=0.680000, 0.800000<=fast2<=0.840000; -0.640000<=fast1<=0.680000, 0.840000<=fast2<=0.880000; -0.640000<=fast1<=0.680000, 0.880000<=fast2<=0.920000; -0.640000<=fast1<=0.680000, 0.920000<=fast2<=0.960000; -0.640000<=fast1<=0.680000, 0.960000<=fast2<=0.999990; -0.680000<=fast1<=0.720000, 0.000010<=fast2<=0.040000; -0.680000<=fast1<=0.720000, 0.040000<=fast2<=0.080000; -0.680000<=fast1<=0.720000, 0.080000<=fast2<=0.120000; -0.680000<=fast1<=0.720000, 0.120000<=fast2<=0.160000; -0.680000<=fast1<=0.720000, 0.160000<=fast2<=0.200000; -0.680000<=fast1<=0.720000, 0.200000<=fast2<=0.240000; -0.680000<=fast1<=0.720000, 0.240000<=fast2<=0.280000; -0.680000<=fast1<=0.720000, 0.280000<=fast2<=0.320000; -0.680000<=fast1<=0.720000, 0.320000<=fast2<=0.360000; -0.680000<=fast1<=0.720000, 0.360000<=fast2<=0.400000; -0.680000<=fast1<=0.720000, 0.400000<=fast2<=0.440000; -0.680000<=fast1<=0.720000, 0.440000<=fast2<=0.480000; -0.680000<=fast1<=0.720000, 0.480000<=fast2<=0.520000; -0.680000<=fast1<=0.720000, 0.520000<=fast2<=0.560000; -0.680000<=fast1<=0.720000, 0.560000<=fast2<=0.600000; -0.680000<=fast1<=0.720000, 0.600000<=fast2<=0.640000; -0.680000<=fast1<=0.720000, 0.640000<=fast2<=0.680000; -0.680000<=fast1<=0.720000, 0.680000<=fast2<=0.720000; -0.680000<=fast1<=0.720000, 0.720000<=fast2<=0.760000; -0.680000<=fast1<=0.720000, 0.760000<=fast2<=0.800000; -0.680000<=fast1<=0.720000, 0.800000<=fast2<=0.840000; -0.680000<=fast1<=0.720000, 0.840000<=fast2<=0.880000; -0.680000<=fast1<=0.720000, 0.880000<=fast2<=0.920000; -0.680000<=fast1<=0.720000, 0.920000<=fast2<=0.960000; -0.680000<=fast1<=0.720000, 0.960000<=fast2<=0.999990; -0.720000<=fast1<=0.760000, 0.000010<=fast2<=0.040000; -0.720000<=fast1<=0.760000, 0.040000<=fast2<=0.080000; -0.720000<=fast1<=0.760000, 0.080000<=fast2<=0.120000; -0.720000<=fast1<=0.760000, 0.120000<=fast2<=0.160000; -0.720000<=fast1<=0.760000, 0.160000<=fast2<=0.200000; -0.720000<=fast1<=0.760000, 0.200000<=fast2<=0.240000; -0.720000<=fast1<=0.760000, 0.240000<=fast2<=0.280000; -0.720000<=fast1<=0.760000, 0.280000<=fast2<=0.320000; -0.720000<=fast1<=0.760000, 0.320000<=fast2<=0.360000; -0.720000<=fast1<=0.760000, 0.360000<=fast2<=0.400000; -0.720000<=fast1<=0.760000, 0.400000<=fast2<=0.440000; -0.720000<=fast1<=0.760000, 0.440000<=fast2<=0.480000; -0.720000<=fast1<=0.760000, 0.480000<=fast2<=0.520000; -0.720000<=fast1<=0.760000, 0.520000<=fast2<=0.560000; -0.720000<=fast1<=0.760000, 0.560000<=fast2<=0.600000; -0.720000<=fast1<=0.760000, 0.600000<=fast2<=0.640000; -0.720000<=fast1<=0.760000, 0.640000<=fast2<=0.680000; -0.720000<=fast1<=0.760000, 0.680000<=fast2<=0.720000; -0.720000<=fast1<=0.760000, 0.720000<=fast2<=0.760000; -0.720000<=fast1<=0.760000, 0.760000<=fast2<=0.800000; -0.720000<=fast1<=0.760000, 0.800000<=fast2<=0.840000; -0.720000<=fast1<=0.760000, 0.840000<=fast2<=0.880000; -0.720000<=fast1<=0.760000, 0.880000<=fast2<=0.920000; -0.720000<=fast1<=0.760000, 0.920000<=fast2<=0.960000; -0.720000<=fast1<=0.760000, 0.960000<=fast2<=0.999990; -0.760000<=fast1<=0.800000, 0.000010<=fast2<=0.040000; -0.760000<=fast1<=0.800000, 0.040000<=fast2<=0.080000; -0.760000<=fast1<=0.800000, 0.080000<=fast2<=0.120000; -0.760000<=fast1<=0.800000, 0.120000<=fast2<=0.160000; -0.760000<=fast1<=0.800000, 0.160000<=fast2<=0.200000; -0.760000<=fast1<=0.800000, 0.200000<=fast2<=0.240000; -0.760000<=fast1<=0.800000, 0.240000<=fast2<=0.280000; -0.760000<=fast1<=0.800000, 0.280000<=fast2<=0.320000; -0.760000<=fast1<=0.800000, 0.320000<=fast2<=0.360000; -0.760000<=fast1<=0.800000, 0.360000<=fast2<=0.400000; -0.760000<=fast1<=0.800000, 0.400000<=fast2<=0.440000; -0.760000<=fast1<=0.800000, 0.440000<=fast2<=0.480000; -0.760000<=fast1<=0.800000, 0.480000<=fast2<=0.520000; -0.760000<=fast1<=0.800000, 0.520000<=fast2<=0.560000; -0.760000<=fast1<=0.800000, 0.560000<=fast2<=0.600000; -0.760000<=fast1<=0.800000, 0.600000<=fast2<=0.640000; -0.760000<=fast1<=0.800000, 0.640000<=fast2<=0.680000; -0.760000<=fast1<=0.800000, 0.680000<=fast2<=0.720000; -0.760000<=fast1<=0.800000, 0.720000<=fast2<=0.760000; -0.760000<=fast1<=0.800000, 0.760000<=fast2<=0.800000; -0.760000<=fast1<=0.800000, 0.800000<=fast2<=0.840000; -0.760000<=fast1<=0.800000, 0.840000<=fast2<=0.880000; -0.760000<=fast1<=0.800000, 0.880000<=fast2<=0.920000; -0.760000<=fast1<=0.800000, 0.920000<=fast2<=0.960000; -0.760000<=fast1<=0.800000, 0.960000<=fast2<=0.999990; -0.800000<=fast1<=0.840000, 0.000010<=fast2<=0.040000; -0.800000<=fast1<=0.840000, 0.040000<=fast2<=0.080000; -0.800000<=fast1<=0.840000, 0.080000<=fast2<=0.120000; -0.800000<=fast1<=0.840000, 0.120000<=fast2<=0.160000; -0.800000<=fast1<=0.840000, 0.160000<=fast2<=0.200000; -0.800000<=fast1<=0.840000, 0.200000<=fast2<=0.240000; -0.800000<=fast1<=0.840000, 0.240000<=fast2<=0.280000; -0.800000<=fast1<=0.840000, 0.280000<=fast2<=0.320000; -0.800000<=fast1<=0.840000, 0.320000<=fast2<=0.360000; -0.800000<=fast1<=0.840000, 0.360000<=fast2<=0.400000; -0.800000<=fast1<=0.840000, 0.400000<=fast2<=0.440000; -0.800000<=fast1<=0.840000, 0.440000<=fast2<=0.480000; -0.800000<=fast1<=0.840000, 0.480000<=fast2<=0.520000; -0.800000<=fast1<=0.840000, 0.520000<=fast2<=0.560000; -0.800000<=fast1<=0.840000, 0.560000<=fast2<=0.600000; -0.800000<=fast1<=0.840000, 0.600000<=fast2<=0.640000; -0.800000<=fast1<=0.840000, 0.640000<=fast2<=0.680000; -0.800000<=fast1<=0.840000, 0.680000<=fast2<=0.720000; -0.800000<=fast1<=0.840000, 0.720000<=fast2<=0.760000; -0.800000<=fast1<=0.840000, 0.760000<=fast2<=0.800000; -0.800000<=fast1<=0.840000, 0.800000<=fast2<=0.840000; -0.800000<=fast1<=0.840000, 0.840000<=fast2<=0.880000; -0.800000<=fast1<=0.840000, 0.880000<=fast2<=0.920000; -0.800000<=fast1<=0.840000, 0.920000<=fast2<=0.960000; -0.800000<=fast1<=0.840000, 0.960000<=fast2<=0.999990; -0.840000<=fast1<=0.880000, 0.000010<=fast2<=0.040000; -0.840000<=fast1<=0.880000, 0.040000<=fast2<=0.080000; -0.840000<=fast1<=0.880000, 0.080000<=fast2<=0.120000; -0.840000<=fast1<=0.880000, 0.120000<=fast2<=0.160000; -0.840000<=fast1<=0.880000, 0.160000<=fast2<=0.200000; -0.840000<=fast1<=0.880000, 0.200000<=fast2<=0.240000; -0.840000<=fast1<=0.880000, 0.240000<=fast2<=0.280000; -0.840000<=fast1<=0.880000, 0.280000<=fast2<=0.320000; -0.840000<=fast1<=0.880000, 0.320000<=fast2<=0.360000; -0.840000<=fast1<=0.880000, 0.360000<=fast2<=0.400000; -0.840000<=fast1<=0.880000, 0.400000<=fast2<=0.440000; -0.840000<=fast1<=0.880000, 0.440000<=fast2<=0.480000; -0.840000<=fast1<=0.880000, 0.480000<=fast2<=0.520000; -0.840000<=fast1<=0.880000, 0.520000<=fast2<=0.560000; -0.840000<=fast1<=0.880000, 0.560000<=fast2<=0.600000; -0.840000<=fast1<=0.880000, 0.600000<=fast2<=0.640000; -0.840000<=fast1<=0.880000, 0.640000<=fast2<=0.680000; -0.840000<=fast1<=0.880000, 0.680000<=fast2<=0.720000; -0.840000<=fast1<=0.880000, 0.720000<=fast2<=0.760000; -0.840000<=fast1<=0.880000, 0.760000<=fast2<=0.800000; -0.840000<=fast1<=0.880000, 0.800000<=fast2<=0.840000; -0.840000<=fast1<=0.880000, 0.840000<=fast2<=0.880000; -0.840000<=fast1<=0.880000, 0.880000<=fast2<=0.920000; -0.840000<=fast1<=0.880000, 0.920000<=fast2<=0.960000; -0.840000<=fast1<=0.880000, 0.960000<=fast2<=0.999990; -0.880000<=fast1<=0.920000, 0.000010<=fast2<=0.040000; -0.880000<=fast1<=0.920000, 0.040000<=fast2<=0.080000; -0.880000<=fast1<=0.920000, 0.080000<=fast2<=0.120000; -0.880000<=fast1<=0.920000, 0.120000<=fast2<=0.160000; -0.880000<=fast1<=0.920000, 0.160000<=fast2<=0.200000; -0.880000<=fast1<=0.920000, 0.200000<=fast2<=0.240000; -0.880000<=fast1<=0.920000, 0.240000<=fast2<=0.280000; -0.880000<=fast1<=0.920000, 0.280000<=fast2<=0.320000; -0.880000<=fast1<=0.920000, 0.320000<=fast2<=0.360000; -0.880000<=fast1<=0.920000, 0.360000<=fast2<=0.400000; -0.880000<=fast1<=0.920000, 0.400000<=fast2<=0.440000; -0.880000<=fast1<=0.920000, 0.440000<=fast2<=0.480000; -0.880000<=fast1<=0.920000, 0.480000<=fast2<=0.520000; -0.880000<=fast1<=0.920000, 0.520000<=fast2<=0.560000; -0.880000<=fast1<=0.920000, 0.560000<=fast2<=0.600000; -0.880000<=fast1<=0.920000, 0.600000<=fast2<=0.640000; -0.880000<=fast1<=0.920000, 0.640000<=fast2<=0.680000; -0.880000<=fast1<=0.920000, 0.680000<=fast2<=0.720000; -0.880000<=fast1<=0.920000, 0.720000<=fast2<=0.760000; -0.880000<=fast1<=0.920000, 0.760000<=fast2<=0.800000; -0.880000<=fast1<=0.920000, 0.800000<=fast2<=0.840000; -0.880000<=fast1<=0.920000, 0.840000<=fast2<=0.880000; -0.880000<=fast1<=0.920000, 0.880000<=fast2<=0.920000; -0.880000<=fast1<=0.920000, 0.920000<=fast2<=0.960000; -0.880000<=fast1<=0.920000, 0.960000<=fast2<=0.999990; -0.920000<=fast1<=0.960000, 0.000010<=fast2<=0.040000; -0.920000<=fast1<=0.960000, 0.040000<=fast2<=0.080000; -0.920000<=fast1<=0.960000, 0.080000<=fast2<=0.120000; -0.920000<=fast1<=0.960000, 0.120000<=fast2<=0.160000; -0.920000<=fast1<=0.960000, 0.160000<=fast2<=0.200000; -0.920000<=fast1<=0.960000, 0.200000<=fast2<=0.240000; -0.920000<=fast1<=0.960000, 0.240000<=fast2<=0.280000; -0.920000<=fast1<=0.960000, 0.280000<=fast2<=0.320000; -0.920000<=fast1<=0.960000, 0.320000<=fast2<=0.360000; -0.920000<=fast1<=0.960000, 0.360000<=fast2<=0.400000; -0.920000<=fast1<=0.960000, 0.400000<=fast2<=0.440000; -0.920000<=fast1<=0.960000, 0.440000<=fast2<=0.480000; -0.920000<=fast1<=0.960000, 0.480000<=fast2<=0.520000; -0.920000<=fast1<=0.960000, 0.520000<=fast2<=0.560000; -0.920000<=fast1<=0.960000, 0.560000<=fast2<=0.600000; -0.920000<=fast1<=0.960000, 0.600000<=fast2<=0.640000; -0.920000<=fast1<=0.960000, 0.640000<=fast2<=0.680000; -0.920000<=fast1<=0.960000, 0.680000<=fast2<=0.720000; -0.920000<=fast1<=0.960000, 0.720000<=fast2<=0.760000; -0.920000<=fast1<=0.960000, 0.760000<=fast2<=0.800000; -0.920000<=fast1<=0.960000, 0.800000<=fast2<=0.840000; -0.920000<=fast1<=0.960000, 0.840000<=fast2<=0.880000; -0.920000<=fast1<=0.960000, 0.880000<=fast2<=0.920000; -0.920000<=fast1<=0.960000, 0.920000<=fast2<=0.960000; -0.920000<=fast1<=0.960000, 0.960000<=fast2<=0.999990; -0.960000<=fast1<=0.999990, 0.000010<=fast2<=0.040000; -0.960000<=fast1<=0.999990, 0.040000<=fast2<=0.080000; -0.960000<=fast1<=0.999990, 0.080000<=fast2<=0.120000; -0.960000<=fast1<=0.999990, 0.120000<=fast2<=0.160000; -0.960000<=fast1<=0.999990, 0.160000<=fast2<=0.200000; -0.960000<=fast1<=0.999990, 0.200000<=fast2<=0.240000; -0.960000<=fast1<=0.999990, 0.240000<=fast2<=0.280000; -0.960000<=fast1<=0.999990, 0.280000<=fast2<=0.320000; -0.960000<=fast1<=0.999990, 0.320000<=fast2<=0.360000; -0.960000<=fast1<=0.999990, 0.360000<=fast2<=0.400000; -0.960000<=fast1<=0.999990, 0.400000<=fast2<=0.440000; -0.960000<=fast1<=0.999990, 0.440000<=fast2<=0.480000; -0.960000<=fast1<=0.999990, 0.480000<=fast2<=0.520000; -0.960000<=fast1<=0.999990, 0.520000<=fast2<=0.560000; -0.960000<=fast1<=0.999990, 0.560000<=fast2<=0.600000; -0.960000<=fast1<=0.999990, 0.600000<=fast2<=0.640000; -0.960000<=fast1<=0.999990, 0.640000<=fast2<=0.680000; -0.960000<=fast1<=0.999990, 0.680000<=fast2<=0.720000; -0.960000<=fast1<=0.999990, 0.720000<=fast2<=0.760000; -0.960000<=fast1<=0.999990, 0.760000<=fast2<=0.800000; -0.960000<=fast1<=0.999990, 0.800000<=fast2<=0.840000; -0.960000<=fast1<=0.999990, 0.840000<=fast2<=0.880000; -0.960000<=fast1<=0.999990, 0.880000<=fast2<=0.920000; -0.960000<=fast1<=0.999990, 0.920000<=fast2<=0.960000; -0.960000<=fast1<=0.999990, 0.960000<=fast2<=0.999990; diff --git a/examples/pmdp/firewire/firewire_space.txt b/examples/pmdp/firewire/firewire_space.txt deleted file mode 100644 index 189ca282f..000000000 --- a/examples/pmdp/firewire/firewire_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=fast1<=0.999990, 0.000010<=fast2<=0.999990; - diff --git a/examples/pmdp/janitor/janitor.pm b/examples/pmdp/janitor/janitor.pm deleted file mode 100644 index 1005d3e32..000000000 --- a/examples/pmdp/janitor/janitor.pm +++ /dev/null @@ -1,124 +0,0 @@ -// GRID WORLD MODEL OF ROBOT AND JANITOR -// Hakan Younes/gxn/dxp 04/05/04 -// Variant by Sebastian Junges, RWTH Aachen University -// As described in -// Junges, Jansen, Dehnert, Topcu, Katoen: -// Safety Constrained Reinforcement Learning -// Proc. of TACAS’16 - -mdp - -// PARAMETERS: Probability that the janitor moves North, South, East or West -const double jProbN; -const double jProbE; -const double jProbS = 1 - jProbN; -const double jProbW = 1 - jProbE; - -// CONSTANTS -const int xSize = 6; // size of the grid -const int ySize = 6; -const int jXmin = 1; // janitor area -const int jXmax = 6; -const int jYmin = 1; -const int jYmax = 6; -const int maxSteps = 15; - -formula T = (xR = xSize & yR = ySize); -formula C = (xR = xJ & yR = yJ); - -module counter - count : [0..maxSteps] init 0; - [forward] (count 1:(count'=count+1); - [turnLeft] (count 1:(count'=count+1); - [turnRight] (count 1:(count'=count+1); - [forward] (count 1:(count'=maxSteps); - [turnLeft] (count 1:(count'=maxSteps); - [turnRight] (count 1:(count'=maxSteps); - [forward] (count=maxSteps) -> 1:true; - [turnLeft] (count=maxSteps) -> 1:true; - [turnRight] (count=maxSteps) -> 1:true; -endmodule - -module robot - xR : [1..xSize] init 1; - yR : [1..ySize] init 1; - d: [0..3] init 0; - - [forward] (d=0 & yR < ySize & !T) -> 1:(yR'=yR+1); - [forward] (d=2 & yR > 1 & !T) -> 1:(yR'=yR-1); - [forward] (d=1 & xR < xSize & !T) -> 1:(xR'=xR+1); - [forward] (d=3 & xR > 1 & !T) -> 1:(xR'=xR-1); - //[backward] (d=0 & yR > 1 & !T) -> 1:(yR'=yR-1); - //[backward] (d=2 & yR < ySize & !T) -> 1:(yR'=yR+1); - //[backward] (d=1 & xR > 1 & !T) -> 1:(xR'=xR-1); - //[backward] (d=3 & xR < xSize & !T) -> 1:(xR'=xR+1); - [turnLeft] (d>0 & !T) -> 1:(d'=d-1); - [turnLeft] (d=0 & !T) -> 1:(d'=3); - [turnRight] (d=3 & !T) -> 1:(d'=0); - [turnRight] (d<3 & !T) -> 1:(d'=d+1); - // [turnLeft] (d=1) -> 1:(d’=0); - // [turnRight] (d=0) -> 1:(d’=1); - [done] T -> 1:true; -endmodule - -// The Janitor moves probabilistically within the grid. -module janitor - xJ : [jXmin..jXmax] init jXmax; // x position of janitor - yJ : [jYmin..jYmax] init jYmin; // y position of janitor - - [forward] (yJ=jYmax & xJ=jXmax) -> 0.5:(yJ'=yJ-1) + 0.5:(xJ'=xJ-1); - [forward] (yJ=jYmax & xJ=jXmin) -> 0.5:(yJ'=yJ-1) + 0.5:(xJ'=xJ+1); - [forward] (yJ=jYmax & xJ jXmin) -> 0.3333:(yJ'=yJ-1) + 0.6667*jProbW:(xJ'=xJ-1) + 0.6667*jProbE:(xJ'=xJ+1); - [forward] (yJ=jYmin & xJ=jXmax) -> 0.5:(yJ'=yJ+1) + 0.5:(xJ'=xJ-1); - [forward] (yJ=jYmin & xJ=jXmin) -> 0.5:(yJ'=yJ+1) + 0.5:(xJ'=xJ+1); - [forward] (yJ=jYmin & xJjXmin) -> 0.3333:(yJ'=yJ+1) + 0.6667*jProbW:(xJ'=xJ-1) + 0.6667*jProbE:(xJ'=xJ+1); - [forward] (yJjYmin & xJ=jXmax) -> 0.6667*jProbN:(yJ'=yJ+1) + 0.6667*jProbS:(yJ'=yJ-1) + 0.3333:(xJ'=xJ-1); - [forward] (yJjYmin & xJ=jXmin) -> 0.6667*jProbN:(yJ'=yJ+1) + 0.6667*jProbS:(yJ'=yJ-1) + 0.3333:(xJ'=xJ+1); - [forward] (yJjYmin & xJjXmin) -> 0.5*jProbS:(yJ'=yJ-1) + 0.5*jProbN:(yJ'=yJ+1) + 0.5*jProbW:(xJ'=xJ-1) + 0.5*jProbE:(xJ'=xJ+1); - - - [turnLeft] (yJ=jYmax & xJ=jXmax) -> 0.5:(yJ'=yJ-1) + 0.5:(xJ'=xJ-1); - [turnLeft] (yJ=jYmax & xJ=jXmin) -> 0.5:(yJ'=yJ-1) + 0.5:(xJ'=xJ+1); - [turnLeft] (yJ=jYmax & xJ jXmin) -> 0.3333:(yJ'=yJ-1) + 0.6667*jProbW:(xJ'=xJ-1) + 0.6667*jProbE:(xJ'=xJ+1); - [turnLeft] (yJ=jYmin & xJ=jXmax) -> 0.5:(yJ'=yJ+1) + 0.5:(xJ'=xJ-1); - [turnLeft] (yJ=jYmin & xJ=jXmin) -> 0.5:(yJ'=yJ+1) + 0.5:(xJ'=xJ+1); - [turnLeft] (yJ=jYmin & xJjXmin) -> 0.3333:(yJ'=yJ+1) + 0.6667*jProbW:(xJ'=xJ-1) + 0.6667*jProbE:(xJ'=xJ+1); - [turnLeft] (yJjYmin & xJ=jXmax) -> 0.6667*jProbN:(yJ'=yJ+1) + 0.6667*jProbS:(yJ'=yJ-1) + 0.3333:(xJ'=xJ-1); - [turnLeft] (yJjYmin & xJ=jXmin) -> 0.6667*jProbN:(yJ'=yJ+1) + 0.6667*jProbS:(yJ'=yJ-1) + 0.3333:(xJ'=xJ+1); - [turnLeft] (yJjYmin & xJjXmin) -> 0.5*jProbS:(yJ'=yJ-1) + 0.5*jProbN:(yJ'=yJ+1) + 0.5*jProbW:(xJ'=xJ-1) + 0.5*jProbE:(xJ'=xJ+1); - - [turnRight] (yJ=jYmax & xJ=jXmax) -> 0.5:(yJ'=yJ-1) + 0.5:(xJ'=xJ-1); - [turnRight] (yJ=jYmax & xJ=jXmin) -> 0.5:(yJ'=yJ-1) + 0.5:(xJ'=xJ+1); - [turnRight] (yJ=jYmax & xJ jXmin) -> 0.3333:(yJ'=yJ-1) + 0.6667*jProbW:(xJ'=xJ-1) + 0.6667*jProbE:(xJ'=xJ+1); - [turnRight] (yJ=jYmin & xJ=jXmax) -> 0.5:(yJ'=yJ+1) + 0.5:(xJ'=xJ-1); - [turnRight] (yJ=jYmin & xJ=jXmin) -> 0.5:(yJ'=yJ+1) + 0.5:(xJ'=xJ+1); - [turnRight] (yJ=jYmin & xJjXmin) -> 0.3333:(yJ'=yJ+1) + 0.6667*jProbW:(xJ'=xJ-1) + 0.6667*jProbE:(xJ'=xJ+1); - [turnRight] (yJjYmin & xJ=jXmax) -> 0.6667*jProbN:(yJ'=yJ+1) + 0.6667*jProbS:(yJ'=yJ-1) + 0.3333:(xJ'=xJ-1); - [turnRight] (yJjYmin & xJ=jXmin) -> 0.6667*jProbN:(yJ'=yJ+1) + 0.6667*jProbS:(yJ'=yJ-1) + 0.3333:(xJ'=xJ+1); - [turnRight] (yJjYmin & xJjXmin) -> 0.5*jProbS:(yJ'=yJ-1) + 0.5*jProbN:(yJ'=yJ+1) + 0.5*jProbW:(xJ'=xJ-1) + 0.5*jProbE:(xJ'=xJ+1); - -endmodule - -rewards "mvbased" - [forward] true: 5; - //[backward] true: 10; - [turnLeft] true: 25; - [turnRight] true: 28; -endrewards - -rewards "mvbased_upper" - [forward] true: 30; - //[backward] true: 35; - [turnLeft] true: 40; - [turnRight] true: 40; -endrewards - -rewards "mvbased_lower" - [forward] true: 4; - //[backward] true: 4; - [turnLeft] true: 8; - [turnRight] true: 8; -endrewards - -label "Target" = T & (count 1:(xLoc'=xLoc+1) & (unreported' = 0) & (hasSendNow'=false); - [up] xLoc < Xsize & !T & !hasSendNow -> 1:(xLoc'=xLoc+1) & (unreported'=min(unreported+1, B)); - [right] yLoc < Ysize & !T & hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported' = 0)& (hasSendNow'=false); - [right] yLoc < Ysize & !T & !hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported'=min(unreported+1,B)); - [sendL] !hasSendNow & !T & tries < MAXTRIES -> (pLMin + pLDiff * xLoc/Xsize):(hasSendNow'=true) & (tries'=0) + (1 - pLMin - pLDiff * xLoc/Xsize): (tries'=tries+1); - [sendH] !hasSendNow & !T & tries < MAXTRIES -> (pHMin + pHDiff * yLoc/Ysize):(hasSendNow'=true) & (tries'=0) + (1 - pHMin - pHDiff * yLoc/Ysize): (tries'=tries+1); - [done] T -> 1:true; -endmodule - -rewards "sendbased" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: max(10, min(11 + xLoc - yLoc, 20)); - [sendH] true: min(13 + xLoc + yLoc, 24); -endrewards - -rewards "sendbased_lower" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 10; - [sendH] true: 12; -endrewards - -rewards "sendbased_upper" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 20; - [sendH] true: 24; -endrewards - -label "Target" = T; -label "Crash" = unreported=B; diff --git a/examples/pmdp/reporter2/reporter2.prctl b/examples/pmdp/reporter2/reporter2.prctl deleted file mode 100644 index 959df1e88..000000000 --- a/examples/pmdp/reporter2/reporter2.prctl +++ /dev/null @@ -1 +0,0 @@ -P>0.3[F "Crash" ] diff --git a/examples/pmdp/reporter2/reporter2_25_25_5_5.pm b/examples/pmdp/reporter2/reporter2_25_25_5_5.pm deleted file mode 100644 index e8ec99525..000000000 --- a/examples/pmdp/reporter2/reporter2_25_25_5_5.pm +++ /dev/null @@ -1,73 +0,0 @@ -// GRID WORLD MODEL OF A SEMIAUTONOMOUS EXPLORING ROBOT -// Sebastian Junges, RWTH Aachen University -// As described in -// Junges, Jansen, Dehnert, Topcu, Katoen: -// Safety Constrained Reinforcement Learning -// Proc. of TACAS’16 - -mdp - -//PARAMETERS -//The difference of the reliability of the channels between the worst and at the best position -const double pLDiff=0.1; -const double pHDiff=0.1; -//Scaling factor for the minimum reliability of the channels -const double pL;//=8/9; -const double pH;//=1; - -//CONSTANTS -//The minimum reliablities -const double pLMin=pL*(1-pLDiff); -const double pHMin=pH*(1-pHDiff); - -// Grid size -const int Xsize = 25; -const int Ysize = 25; -// Number of tries before an error -const int MAXTRIES = 5; -// Ball within the robot has to move. -const int B=5; - - -formula T = (xLoc = Xsize & yLoc = Ysize); - - -module robot - xLoc : [1..Ysize] init 1; - yLoc : [1..Xsize] init 1; - unreported : [0..B] init 0; - hasSendNow : bool init false; - tries : [0..MAXTRIES] init 0; - - [up] xLoc < Xsize & !T & hasSendNow -> 1:(xLoc'=xLoc+1) & (unreported' = 0) & (hasSendNow'=false); - [up] xLoc < Xsize & !T & !hasSendNow -> 1:(xLoc'=xLoc+1) & (unreported'=min(unreported+1, B)); - [right] yLoc < Ysize & !T & hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported' = 0)& (hasSendNow'=false); - [right] yLoc < Ysize & !T & !hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported'=min(unreported+1,B)); - [sendL] !hasSendNow & !T & tries < MAXTRIES -> (pLMin + pLDiff * xLoc/Xsize):(hasSendNow'=true) & (tries'=0) + (1 - pLMin - pLDiff * xLoc/Xsize): (tries'=tries+1); - [sendH] !hasSendNow & !T & tries < MAXTRIES -> (pHMin + pHDiff * yLoc/Ysize):(hasSendNow'=true) & (tries'=0) + (1 - pHMin - pHDiff * yLoc/Ysize): (tries'=tries+1); - [done] T -> 1:true; -endmodule - -rewards "sendbased" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: max(10, min(11 + xLoc - yLoc, 20)); - [sendH] true: min(13 + xLoc + yLoc, 24); -endrewards - -rewards "sendbased_lower" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 10; - [sendH] true: 12; -endrewards - -rewards "sendbased_upper" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 20; - [sendH] true: 24; -endrewards - -label "Target" = T; -label "Crash" = unreported=B; diff --git a/examples/pmdp/reporter2/reporter2_6_6_2_2.pm b/examples/pmdp/reporter2/reporter2_6_6_2_2.pm deleted file mode 100644 index 68269cfbb..000000000 --- a/examples/pmdp/reporter2/reporter2_6_6_2_2.pm +++ /dev/null @@ -1,73 +0,0 @@ -// GRID WORLD MODEL OF A SEMIAUTONOMOUS EXPLORING ROBOT -// Sebastian Junges, RWTH Aachen University -// As described in -// Junges, Jansen, Dehnert, Topcu, Katoen: -// Safety Constrained Reinforcement Learning -// Proc. of TACAS’16 - -mdp - -//PARAMETERS -//The difference of the reliability of the channels between the worst and at the best position -const double pLDiff=0.1; -const double pHDiff=0.1; -//Scaling factor for the minimum reliability of the channels -const double pL;//=8/9; -const double pH;//=1; - -//CONSTANTS -//The minimum reliablities -const double pLMin=pL*(1-pLDiff); -const double pHMin=pH*(1-pHDiff); - -// Grid size -const int Xsize = 6; -const int Ysize = 6; -// Number of tries before an error -const int MAXTRIES = 2; -// Ball within the robot has to move. -const int B=2; - - -formula T = (xLoc = Xsize & yLoc = Ysize); - - -module robot - xLoc : [1..Ysize] init 1; - yLoc : [1..Xsize] init 1; - unreported : [0..B] init 0; - hasSendNow : bool init false; - tries : [0..MAXTRIES] init 0; - - [up] xLoc < Xsize & !T & hasSendNow -> 1:(xLoc'=xLoc+1) & (unreported' = 0) & (hasSendNow'=false); - [up] xLoc < Xsize & !T & !hasSendNow -> 1:(xLoc'=xLoc+1) & (unreported'=min(unreported+1, B)); - [right] yLoc < Ysize & !T & hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported' = 0)& (hasSendNow'=false); - [right] yLoc < Ysize & !T & !hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported'=min(unreported+1,B)); - [sendL] !hasSendNow & !T & tries < MAXTRIES -> (pLMin + pLDiff * xLoc/Xsize):(hasSendNow'=true) & (tries'=0) + (1 - pLMin - pLDiff * xLoc/Xsize): (tries'=tries+1); - [sendH] !hasSendNow & !T & tries < MAXTRIES -> (pHMin + pHDiff * yLoc/Ysize):(hasSendNow'=true) & (tries'=0) + (1 - pHMin - pHDiff * yLoc/Ysize): (tries'=tries+1); - [done] T -> 1:true; -endmodule - -rewards "sendbased" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: max(10, min(11 + xLoc - yLoc, 20)); - [sendH] true: min(13 + xLoc + yLoc, 24); -endrewards - -rewards "sendbased_lower" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 10; - [sendH] true: 12; -endrewards - -rewards "sendbased_upper" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 20; - [sendH] true: 24; -endrewards - -label "Target" = T; -label "Crash" = unreported=B; diff --git a/examples/pmdp/reporter2/reporter2_regions.txt b/examples/pmdp/reporter2/reporter2_regions.txt deleted file mode 100644 index 8e3b7580c..000000000 --- a/examples/pmdp/reporter2/reporter2_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=pL<=0.040000, 0.000010<=pH<=0.040000; -0.000010<=pL<=0.040000, 0.040000<=pH<=0.080000; -0.000010<=pL<=0.040000, 0.080000<=pH<=0.120000; -0.000010<=pL<=0.040000, 0.120000<=pH<=0.160000; -0.000010<=pL<=0.040000, 0.160000<=pH<=0.200000; -0.000010<=pL<=0.040000, 0.200000<=pH<=0.240000; -0.000010<=pL<=0.040000, 0.240000<=pH<=0.280000; -0.000010<=pL<=0.040000, 0.280000<=pH<=0.320000; -0.000010<=pL<=0.040000, 0.320000<=pH<=0.360000; -0.000010<=pL<=0.040000, 0.360000<=pH<=0.400000; -0.000010<=pL<=0.040000, 0.400000<=pH<=0.440000; -0.000010<=pL<=0.040000, 0.440000<=pH<=0.480000; -0.000010<=pL<=0.040000, 0.480000<=pH<=0.520000; -0.000010<=pL<=0.040000, 0.520000<=pH<=0.560000; -0.000010<=pL<=0.040000, 0.560000<=pH<=0.600000; -0.000010<=pL<=0.040000, 0.600000<=pH<=0.640000; -0.000010<=pL<=0.040000, 0.640000<=pH<=0.680000; -0.000010<=pL<=0.040000, 0.680000<=pH<=0.720000; -0.000010<=pL<=0.040000, 0.720000<=pH<=0.760000; -0.000010<=pL<=0.040000, 0.760000<=pH<=0.800000; -0.000010<=pL<=0.040000, 0.800000<=pH<=0.840000; -0.000010<=pL<=0.040000, 0.840000<=pH<=0.880000; -0.000010<=pL<=0.040000, 0.880000<=pH<=0.920000; -0.000010<=pL<=0.040000, 0.920000<=pH<=0.960000; -0.000010<=pL<=0.040000, 0.960000<=pH<=0.999990; -0.040000<=pL<=0.080000, 0.000010<=pH<=0.040000; -0.040000<=pL<=0.080000, 0.040000<=pH<=0.080000; -0.040000<=pL<=0.080000, 0.080000<=pH<=0.120000; -0.040000<=pL<=0.080000, 0.120000<=pH<=0.160000; -0.040000<=pL<=0.080000, 0.160000<=pH<=0.200000; -0.040000<=pL<=0.080000, 0.200000<=pH<=0.240000; -0.040000<=pL<=0.080000, 0.240000<=pH<=0.280000; -0.040000<=pL<=0.080000, 0.280000<=pH<=0.320000; -0.040000<=pL<=0.080000, 0.320000<=pH<=0.360000; -0.040000<=pL<=0.080000, 0.360000<=pH<=0.400000; -0.040000<=pL<=0.080000, 0.400000<=pH<=0.440000; -0.040000<=pL<=0.080000, 0.440000<=pH<=0.480000; -0.040000<=pL<=0.080000, 0.480000<=pH<=0.520000; -0.040000<=pL<=0.080000, 0.520000<=pH<=0.560000; -0.040000<=pL<=0.080000, 0.560000<=pH<=0.600000; -0.040000<=pL<=0.080000, 0.600000<=pH<=0.640000; -0.040000<=pL<=0.080000, 0.640000<=pH<=0.680000; -0.040000<=pL<=0.080000, 0.680000<=pH<=0.720000; -0.040000<=pL<=0.080000, 0.720000<=pH<=0.760000; -0.040000<=pL<=0.080000, 0.760000<=pH<=0.800000; -0.040000<=pL<=0.080000, 0.800000<=pH<=0.840000; -0.040000<=pL<=0.080000, 0.840000<=pH<=0.880000; -0.040000<=pL<=0.080000, 0.880000<=pH<=0.920000; -0.040000<=pL<=0.080000, 0.920000<=pH<=0.960000; -0.040000<=pL<=0.080000, 0.960000<=pH<=0.999990; -0.080000<=pL<=0.120000, 0.000010<=pH<=0.040000; -0.080000<=pL<=0.120000, 0.040000<=pH<=0.080000; -0.080000<=pL<=0.120000, 0.080000<=pH<=0.120000; -0.080000<=pL<=0.120000, 0.120000<=pH<=0.160000; -0.080000<=pL<=0.120000, 0.160000<=pH<=0.200000; -0.080000<=pL<=0.120000, 0.200000<=pH<=0.240000; -0.080000<=pL<=0.120000, 0.240000<=pH<=0.280000; -0.080000<=pL<=0.120000, 0.280000<=pH<=0.320000; -0.080000<=pL<=0.120000, 0.320000<=pH<=0.360000; -0.080000<=pL<=0.120000, 0.360000<=pH<=0.400000; -0.080000<=pL<=0.120000, 0.400000<=pH<=0.440000; -0.080000<=pL<=0.120000, 0.440000<=pH<=0.480000; -0.080000<=pL<=0.120000, 0.480000<=pH<=0.520000; -0.080000<=pL<=0.120000, 0.520000<=pH<=0.560000; -0.080000<=pL<=0.120000, 0.560000<=pH<=0.600000; -0.080000<=pL<=0.120000, 0.600000<=pH<=0.640000; -0.080000<=pL<=0.120000, 0.640000<=pH<=0.680000; -0.080000<=pL<=0.120000, 0.680000<=pH<=0.720000; -0.080000<=pL<=0.120000, 0.720000<=pH<=0.760000; -0.080000<=pL<=0.120000, 0.760000<=pH<=0.800000; -0.080000<=pL<=0.120000, 0.800000<=pH<=0.840000; -0.080000<=pL<=0.120000, 0.840000<=pH<=0.880000; -0.080000<=pL<=0.120000, 0.880000<=pH<=0.920000; -0.080000<=pL<=0.120000, 0.920000<=pH<=0.960000; -0.080000<=pL<=0.120000, 0.960000<=pH<=0.999990; -0.120000<=pL<=0.160000, 0.000010<=pH<=0.040000; -0.120000<=pL<=0.160000, 0.040000<=pH<=0.080000; -0.120000<=pL<=0.160000, 0.080000<=pH<=0.120000; -0.120000<=pL<=0.160000, 0.120000<=pH<=0.160000; -0.120000<=pL<=0.160000, 0.160000<=pH<=0.200000; -0.120000<=pL<=0.160000, 0.200000<=pH<=0.240000; -0.120000<=pL<=0.160000, 0.240000<=pH<=0.280000; -0.120000<=pL<=0.160000, 0.280000<=pH<=0.320000; -0.120000<=pL<=0.160000, 0.320000<=pH<=0.360000; -0.120000<=pL<=0.160000, 0.360000<=pH<=0.400000; -0.120000<=pL<=0.160000, 0.400000<=pH<=0.440000; -0.120000<=pL<=0.160000, 0.440000<=pH<=0.480000; -0.120000<=pL<=0.160000, 0.480000<=pH<=0.520000; -0.120000<=pL<=0.160000, 0.520000<=pH<=0.560000; -0.120000<=pL<=0.160000, 0.560000<=pH<=0.600000; -0.120000<=pL<=0.160000, 0.600000<=pH<=0.640000; -0.120000<=pL<=0.160000, 0.640000<=pH<=0.680000; -0.120000<=pL<=0.160000, 0.680000<=pH<=0.720000; -0.120000<=pL<=0.160000, 0.720000<=pH<=0.760000; -0.120000<=pL<=0.160000, 0.760000<=pH<=0.800000; -0.120000<=pL<=0.160000, 0.800000<=pH<=0.840000; -0.120000<=pL<=0.160000, 0.840000<=pH<=0.880000; -0.120000<=pL<=0.160000, 0.880000<=pH<=0.920000; -0.120000<=pL<=0.160000, 0.920000<=pH<=0.960000; -0.120000<=pL<=0.160000, 0.960000<=pH<=0.999990; -0.160000<=pL<=0.200000, 0.000010<=pH<=0.040000; -0.160000<=pL<=0.200000, 0.040000<=pH<=0.080000; -0.160000<=pL<=0.200000, 0.080000<=pH<=0.120000; -0.160000<=pL<=0.200000, 0.120000<=pH<=0.160000; -0.160000<=pL<=0.200000, 0.160000<=pH<=0.200000; -0.160000<=pL<=0.200000, 0.200000<=pH<=0.240000; -0.160000<=pL<=0.200000, 0.240000<=pH<=0.280000; -0.160000<=pL<=0.200000, 0.280000<=pH<=0.320000; -0.160000<=pL<=0.200000, 0.320000<=pH<=0.360000; -0.160000<=pL<=0.200000, 0.360000<=pH<=0.400000; -0.160000<=pL<=0.200000, 0.400000<=pH<=0.440000; -0.160000<=pL<=0.200000, 0.440000<=pH<=0.480000; -0.160000<=pL<=0.200000, 0.480000<=pH<=0.520000; -0.160000<=pL<=0.200000, 0.520000<=pH<=0.560000; -0.160000<=pL<=0.200000, 0.560000<=pH<=0.600000; -0.160000<=pL<=0.200000, 0.600000<=pH<=0.640000; -0.160000<=pL<=0.200000, 0.640000<=pH<=0.680000; -0.160000<=pL<=0.200000, 0.680000<=pH<=0.720000; -0.160000<=pL<=0.200000, 0.720000<=pH<=0.760000; -0.160000<=pL<=0.200000, 0.760000<=pH<=0.800000; -0.160000<=pL<=0.200000, 0.800000<=pH<=0.840000; -0.160000<=pL<=0.200000, 0.840000<=pH<=0.880000; -0.160000<=pL<=0.200000, 0.880000<=pH<=0.920000; -0.160000<=pL<=0.200000, 0.920000<=pH<=0.960000; -0.160000<=pL<=0.200000, 0.960000<=pH<=0.999990; -0.200000<=pL<=0.240000, 0.000010<=pH<=0.040000; -0.200000<=pL<=0.240000, 0.040000<=pH<=0.080000; -0.200000<=pL<=0.240000, 0.080000<=pH<=0.120000; -0.200000<=pL<=0.240000, 0.120000<=pH<=0.160000; -0.200000<=pL<=0.240000, 0.160000<=pH<=0.200000; -0.200000<=pL<=0.240000, 0.200000<=pH<=0.240000; -0.200000<=pL<=0.240000, 0.240000<=pH<=0.280000; -0.200000<=pL<=0.240000, 0.280000<=pH<=0.320000; -0.200000<=pL<=0.240000, 0.320000<=pH<=0.360000; -0.200000<=pL<=0.240000, 0.360000<=pH<=0.400000; -0.200000<=pL<=0.240000, 0.400000<=pH<=0.440000; -0.200000<=pL<=0.240000, 0.440000<=pH<=0.480000; -0.200000<=pL<=0.240000, 0.480000<=pH<=0.520000; -0.200000<=pL<=0.240000, 0.520000<=pH<=0.560000; -0.200000<=pL<=0.240000, 0.560000<=pH<=0.600000; -0.200000<=pL<=0.240000, 0.600000<=pH<=0.640000; -0.200000<=pL<=0.240000, 0.640000<=pH<=0.680000; -0.200000<=pL<=0.240000, 0.680000<=pH<=0.720000; -0.200000<=pL<=0.240000, 0.720000<=pH<=0.760000; -0.200000<=pL<=0.240000, 0.760000<=pH<=0.800000; -0.200000<=pL<=0.240000, 0.800000<=pH<=0.840000; -0.200000<=pL<=0.240000, 0.840000<=pH<=0.880000; -0.200000<=pL<=0.240000, 0.880000<=pH<=0.920000; -0.200000<=pL<=0.240000, 0.920000<=pH<=0.960000; -0.200000<=pL<=0.240000, 0.960000<=pH<=0.999990; -0.240000<=pL<=0.280000, 0.000010<=pH<=0.040000; -0.240000<=pL<=0.280000, 0.040000<=pH<=0.080000; -0.240000<=pL<=0.280000, 0.080000<=pH<=0.120000; -0.240000<=pL<=0.280000, 0.120000<=pH<=0.160000; -0.240000<=pL<=0.280000, 0.160000<=pH<=0.200000; -0.240000<=pL<=0.280000, 0.200000<=pH<=0.240000; -0.240000<=pL<=0.280000, 0.240000<=pH<=0.280000; -0.240000<=pL<=0.280000, 0.280000<=pH<=0.320000; -0.240000<=pL<=0.280000, 0.320000<=pH<=0.360000; -0.240000<=pL<=0.280000, 0.360000<=pH<=0.400000; -0.240000<=pL<=0.280000, 0.400000<=pH<=0.440000; -0.240000<=pL<=0.280000, 0.440000<=pH<=0.480000; -0.240000<=pL<=0.280000, 0.480000<=pH<=0.520000; -0.240000<=pL<=0.280000, 0.520000<=pH<=0.560000; -0.240000<=pL<=0.280000, 0.560000<=pH<=0.600000; -0.240000<=pL<=0.280000, 0.600000<=pH<=0.640000; -0.240000<=pL<=0.280000, 0.640000<=pH<=0.680000; -0.240000<=pL<=0.280000, 0.680000<=pH<=0.720000; -0.240000<=pL<=0.280000, 0.720000<=pH<=0.760000; -0.240000<=pL<=0.280000, 0.760000<=pH<=0.800000; -0.240000<=pL<=0.280000, 0.800000<=pH<=0.840000; -0.240000<=pL<=0.280000, 0.840000<=pH<=0.880000; -0.240000<=pL<=0.280000, 0.880000<=pH<=0.920000; -0.240000<=pL<=0.280000, 0.920000<=pH<=0.960000; -0.240000<=pL<=0.280000, 0.960000<=pH<=0.999990; -0.280000<=pL<=0.320000, 0.000010<=pH<=0.040000; -0.280000<=pL<=0.320000, 0.040000<=pH<=0.080000; -0.280000<=pL<=0.320000, 0.080000<=pH<=0.120000; -0.280000<=pL<=0.320000, 0.120000<=pH<=0.160000; -0.280000<=pL<=0.320000, 0.160000<=pH<=0.200000; -0.280000<=pL<=0.320000, 0.200000<=pH<=0.240000; -0.280000<=pL<=0.320000, 0.240000<=pH<=0.280000; -0.280000<=pL<=0.320000, 0.280000<=pH<=0.320000; -0.280000<=pL<=0.320000, 0.320000<=pH<=0.360000; -0.280000<=pL<=0.320000, 0.360000<=pH<=0.400000; -0.280000<=pL<=0.320000, 0.400000<=pH<=0.440000; -0.280000<=pL<=0.320000, 0.440000<=pH<=0.480000; -0.280000<=pL<=0.320000, 0.480000<=pH<=0.520000; -0.280000<=pL<=0.320000, 0.520000<=pH<=0.560000; -0.280000<=pL<=0.320000, 0.560000<=pH<=0.600000; -0.280000<=pL<=0.320000, 0.600000<=pH<=0.640000; -0.280000<=pL<=0.320000, 0.640000<=pH<=0.680000; -0.280000<=pL<=0.320000, 0.680000<=pH<=0.720000; -0.280000<=pL<=0.320000, 0.720000<=pH<=0.760000; -0.280000<=pL<=0.320000, 0.760000<=pH<=0.800000; -0.280000<=pL<=0.320000, 0.800000<=pH<=0.840000; -0.280000<=pL<=0.320000, 0.840000<=pH<=0.880000; -0.280000<=pL<=0.320000, 0.880000<=pH<=0.920000; -0.280000<=pL<=0.320000, 0.920000<=pH<=0.960000; -0.280000<=pL<=0.320000, 0.960000<=pH<=0.999990; -0.320000<=pL<=0.360000, 0.000010<=pH<=0.040000; -0.320000<=pL<=0.360000, 0.040000<=pH<=0.080000; -0.320000<=pL<=0.360000, 0.080000<=pH<=0.120000; -0.320000<=pL<=0.360000, 0.120000<=pH<=0.160000; -0.320000<=pL<=0.360000, 0.160000<=pH<=0.200000; -0.320000<=pL<=0.360000, 0.200000<=pH<=0.240000; -0.320000<=pL<=0.360000, 0.240000<=pH<=0.280000; -0.320000<=pL<=0.360000, 0.280000<=pH<=0.320000; -0.320000<=pL<=0.360000, 0.320000<=pH<=0.360000; -0.320000<=pL<=0.360000, 0.360000<=pH<=0.400000; -0.320000<=pL<=0.360000, 0.400000<=pH<=0.440000; -0.320000<=pL<=0.360000, 0.440000<=pH<=0.480000; -0.320000<=pL<=0.360000, 0.480000<=pH<=0.520000; -0.320000<=pL<=0.360000, 0.520000<=pH<=0.560000; -0.320000<=pL<=0.360000, 0.560000<=pH<=0.600000; -0.320000<=pL<=0.360000, 0.600000<=pH<=0.640000; -0.320000<=pL<=0.360000, 0.640000<=pH<=0.680000; -0.320000<=pL<=0.360000, 0.680000<=pH<=0.720000; -0.320000<=pL<=0.360000, 0.720000<=pH<=0.760000; -0.320000<=pL<=0.360000, 0.760000<=pH<=0.800000; -0.320000<=pL<=0.360000, 0.800000<=pH<=0.840000; -0.320000<=pL<=0.360000, 0.840000<=pH<=0.880000; -0.320000<=pL<=0.360000, 0.880000<=pH<=0.920000; -0.320000<=pL<=0.360000, 0.920000<=pH<=0.960000; -0.320000<=pL<=0.360000, 0.960000<=pH<=0.999990; -0.360000<=pL<=0.400000, 0.000010<=pH<=0.040000; -0.360000<=pL<=0.400000, 0.040000<=pH<=0.080000; -0.360000<=pL<=0.400000, 0.080000<=pH<=0.120000; -0.360000<=pL<=0.400000, 0.120000<=pH<=0.160000; -0.360000<=pL<=0.400000, 0.160000<=pH<=0.200000; -0.360000<=pL<=0.400000, 0.200000<=pH<=0.240000; -0.360000<=pL<=0.400000, 0.240000<=pH<=0.280000; -0.360000<=pL<=0.400000, 0.280000<=pH<=0.320000; -0.360000<=pL<=0.400000, 0.320000<=pH<=0.360000; -0.360000<=pL<=0.400000, 0.360000<=pH<=0.400000; -0.360000<=pL<=0.400000, 0.400000<=pH<=0.440000; -0.360000<=pL<=0.400000, 0.440000<=pH<=0.480000; -0.360000<=pL<=0.400000, 0.480000<=pH<=0.520000; -0.360000<=pL<=0.400000, 0.520000<=pH<=0.560000; -0.360000<=pL<=0.400000, 0.560000<=pH<=0.600000; -0.360000<=pL<=0.400000, 0.600000<=pH<=0.640000; -0.360000<=pL<=0.400000, 0.640000<=pH<=0.680000; -0.360000<=pL<=0.400000, 0.680000<=pH<=0.720000; -0.360000<=pL<=0.400000, 0.720000<=pH<=0.760000; -0.360000<=pL<=0.400000, 0.760000<=pH<=0.800000; -0.360000<=pL<=0.400000, 0.800000<=pH<=0.840000; -0.360000<=pL<=0.400000, 0.840000<=pH<=0.880000; -0.360000<=pL<=0.400000, 0.880000<=pH<=0.920000; -0.360000<=pL<=0.400000, 0.920000<=pH<=0.960000; -0.360000<=pL<=0.400000, 0.960000<=pH<=0.999990; -0.400000<=pL<=0.440000, 0.000010<=pH<=0.040000; -0.400000<=pL<=0.440000, 0.040000<=pH<=0.080000; -0.400000<=pL<=0.440000, 0.080000<=pH<=0.120000; -0.400000<=pL<=0.440000, 0.120000<=pH<=0.160000; -0.400000<=pL<=0.440000, 0.160000<=pH<=0.200000; -0.400000<=pL<=0.440000, 0.200000<=pH<=0.240000; -0.400000<=pL<=0.440000, 0.240000<=pH<=0.280000; -0.400000<=pL<=0.440000, 0.280000<=pH<=0.320000; -0.400000<=pL<=0.440000, 0.320000<=pH<=0.360000; -0.400000<=pL<=0.440000, 0.360000<=pH<=0.400000; -0.400000<=pL<=0.440000, 0.400000<=pH<=0.440000; -0.400000<=pL<=0.440000, 0.440000<=pH<=0.480000; -0.400000<=pL<=0.440000, 0.480000<=pH<=0.520000; -0.400000<=pL<=0.440000, 0.520000<=pH<=0.560000; -0.400000<=pL<=0.440000, 0.560000<=pH<=0.600000; -0.400000<=pL<=0.440000, 0.600000<=pH<=0.640000; -0.400000<=pL<=0.440000, 0.640000<=pH<=0.680000; -0.400000<=pL<=0.440000, 0.680000<=pH<=0.720000; -0.400000<=pL<=0.440000, 0.720000<=pH<=0.760000; -0.400000<=pL<=0.440000, 0.760000<=pH<=0.800000; -0.400000<=pL<=0.440000, 0.800000<=pH<=0.840000; -0.400000<=pL<=0.440000, 0.840000<=pH<=0.880000; -0.400000<=pL<=0.440000, 0.880000<=pH<=0.920000; -0.400000<=pL<=0.440000, 0.920000<=pH<=0.960000; -0.400000<=pL<=0.440000, 0.960000<=pH<=0.999990; -0.440000<=pL<=0.480000, 0.000010<=pH<=0.040000; -0.440000<=pL<=0.480000, 0.040000<=pH<=0.080000; -0.440000<=pL<=0.480000, 0.080000<=pH<=0.120000; -0.440000<=pL<=0.480000, 0.120000<=pH<=0.160000; -0.440000<=pL<=0.480000, 0.160000<=pH<=0.200000; -0.440000<=pL<=0.480000, 0.200000<=pH<=0.240000; -0.440000<=pL<=0.480000, 0.240000<=pH<=0.280000; -0.440000<=pL<=0.480000, 0.280000<=pH<=0.320000; -0.440000<=pL<=0.480000, 0.320000<=pH<=0.360000; -0.440000<=pL<=0.480000, 0.360000<=pH<=0.400000; -0.440000<=pL<=0.480000, 0.400000<=pH<=0.440000; -0.440000<=pL<=0.480000, 0.440000<=pH<=0.480000; -0.440000<=pL<=0.480000, 0.480000<=pH<=0.520000; -0.440000<=pL<=0.480000, 0.520000<=pH<=0.560000; -0.440000<=pL<=0.480000, 0.560000<=pH<=0.600000; -0.440000<=pL<=0.480000, 0.600000<=pH<=0.640000; -0.440000<=pL<=0.480000, 0.640000<=pH<=0.680000; -0.440000<=pL<=0.480000, 0.680000<=pH<=0.720000; -0.440000<=pL<=0.480000, 0.720000<=pH<=0.760000; -0.440000<=pL<=0.480000, 0.760000<=pH<=0.800000; -0.440000<=pL<=0.480000, 0.800000<=pH<=0.840000; -0.440000<=pL<=0.480000, 0.840000<=pH<=0.880000; -0.440000<=pL<=0.480000, 0.880000<=pH<=0.920000; -0.440000<=pL<=0.480000, 0.920000<=pH<=0.960000; -0.440000<=pL<=0.480000, 0.960000<=pH<=0.999990; -0.480000<=pL<=0.520000, 0.000010<=pH<=0.040000; -0.480000<=pL<=0.520000, 0.040000<=pH<=0.080000; -0.480000<=pL<=0.520000, 0.080000<=pH<=0.120000; -0.480000<=pL<=0.520000, 0.120000<=pH<=0.160000; -0.480000<=pL<=0.520000, 0.160000<=pH<=0.200000; -0.480000<=pL<=0.520000, 0.200000<=pH<=0.240000; -0.480000<=pL<=0.520000, 0.240000<=pH<=0.280000; -0.480000<=pL<=0.520000, 0.280000<=pH<=0.320000; -0.480000<=pL<=0.520000, 0.320000<=pH<=0.360000; -0.480000<=pL<=0.520000, 0.360000<=pH<=0.400000; -0.480000<=pL<=0.520000, 0.400000<=pH<=0.440000; -0.480000<=pL<=0.520000, 0.440000<=pH<=0.480000; -0.480000<=pL<=0.520000, 0.480000<=pH<=0.520000; -0.480000<=pL<=0.520000, 0.520000<=pH<=0.560000; -0.480000<=pL<=0.520000, 0.560000<=pH<=0.600000; -0.480000<=pL<=0.520000, 0.600000<=pH<=0.640000; -0.480000<=pL<=0.520000, 0.640000<=pH<=0.680000; -0.480000<=pL<=0.520000, 0.680000<=pH<=0.720000; -0.480000<=pL<=0.520000, 0.720000<=pH<=0.760000; -0.480000<=pL<=0.520000, 0.760000<=pH<=0.800000; -0.480000<=pL<=0.520000, 0.800000<=pH<=0.840000; -0.480000<=pL<=0.520000, 0.840000<=pH<=0.880000; -0.480000<=pL<=0.520000, 0.880000<=pH<=0.920000; -0.480000<=pL<=0.520000, 0.920000<=pH<=0.960000; -0.480000<=pL<=0.520000, 0.960000<=pH<=0.999990; -0.520000<=pL<=0.560000, 0.000010<=pH<=0.040000; -0.520000<=pL<=0.560000, 0.040000<=pH<=0.080000; -0.520000<=pL<=0.560000, 0.080000<=pH<=0.120000; -0.520000<=pL<=0.560000, 0.120000<=pH<=0.160000; -0.520000<=pL<=0.560000, 0.160000<=pH<=0.200000; -0.520000<=pL<=0.560000, 0.200000<=pH<=0.240000; -0.520000<=pL<=0.560000, 0.240000<=pH<=0.280000; -0.520000<=pL<=0.560000, 0.280000<=pH<=0.320000; -0.520000<=pL<=0.560000, 0.320000<=pH<=0.360000; -0.520000<=pL<=0.560000, 0.360000<=pH<=0.400000; -0.520000<=pL<=0.560000, 0.400000<=pH<=0.440000; -0.520000<=pL<=0.560000, 0.440000<=pH<=0.480000; -0.520000<=pL<=0.560000, 0.480000<=pH<=0.520000; -0.520000<=pL<=0.560000, 0.520000<=pH<=0.560000; -0.520000<=pL<=0.560000, 0.560000<=pH<=0.600000; -0.520000<=pL<=0.560000, 0.600000<=pH<=0.640000; -0.520000<=pL<=0.560000, 0.640000<=pH<=0.680000; -0.520000<=pL<=0.560000, 0.680000<=pH<=0.720000; -0.520000<=pL<=0.560000, 0.720000<=pH<=0.760000; -0.520000<=pL<=0.560000, 0.760000<=pH<=0.800000; -0.520000<=pL<=0.560000, 0.800000<=pH<=0.840000; -0.520000<=pL<=0.560000, 0.840000<=pH<=0.880000; -0.520000<=pL<=0.560000, 0.880000<=pH<=0.920000; -0.520000<=pL<=0.560000, 0.920000<=pH<=0.960000; -0.520000<=pL<=0.560000, 0.960000<=pH<=0.999990; -0.560000<=pL<=0.600000, 0.000010<=pH<=0.040000; -0.560000<=pL<=0.600000, 0.040000<=pH<=0.080000; -0.560000<=pL<=0.600000, 0.080000<=pH<=0.120000; -0.560000<=pL<=0.600000, 0.120000<=pH<=0.160000; -0.560000<=pL<=0.600000, 0.160000<=pH<=0.200000; -0.560000<=pL<=0.600000, 0.200000<=pH<=0.240000; -0.560000<=pL<=0.600000, 0.240000<=pH<=0.280000; -0.560000<=pL<=0.600000, 0.280000<=pH<=0.320000; -0.560000<=pL<=0.600000, 0.320000<=pH<=0.360000; -0.560000<=pL<=0.600000, 0.360000<=pH<=0.400000; -0.560000<=pL<=0.600000, 0.400000<=pH<=0.440000; -0.560000<=pL<=0.600000, 0.440000<=pH<=0.480000; -0.560000<=pL<=0.600000, 0.480000<=pH<=0.520000; -0.560000<=pL<=0.600000, 0.520000<=pH<=0.560000; -0.560000<=pL<=0.600000, 0.560000<=pH<=0.600000; -0.560000<=pL<=0.600000, 0.600000<=pH<=0.640000; -0.560000<=pL<=0.600000, 0.640000<=pH<=0.680000; -0.560000<=pL<=0.600000, 0.680000<=pH<=0.720000; -0.560000<=pL<=0.600000, 0.720000<=pH<=0.760000; -0.560000<=pL<=0.600000, 0.760000<=pH<=0.800000; -0.560000<=pL<=0.600000, 0.800000<=pH<=0.840000; -0.560000<=pL<=0.600000, 0.840000<=pH<=0.880000; -0.560000<=pL<=0.600000, 0.880000<=pH<=0.920000; -0.560000<=pL<=0.600000, 0.920000<=pH<=0.960000; -0.560000<=pL<=0.600000, 0.960000<=pH<=0.999990; -0.600000<=pL<=0.640000, 0.000010<=pH<=0.040000; -0.600000<=pL<=0.640000, 0.040000<=pH<=0.080000; -0.600000<=pL<=0.640000, 0.080000<=pH<=0.120000; -0.600000<=pL<=0.640000, 0.120000<=pH<=0.160000; -0.600000<=pL<=0.640000, 0.160000<=pH<=0.200000; -0.600000<=pL<=0.640000, 0.200000<=pH<=0.240000; -0.600000<=pL<=0.640000, 0.240000<=pH<=0.280000; -0.600000<=pL<=0.640000, 0.280000<=pH<=0.320000; -0.600000<=pL<=0.640000, 0.320000<=pH<=0.360000; -0.600000<=pL<=0.640000, 0.360000<=pH<=0.400000; -0.600000<=pL<=0.640000, 0.400000<=pH<=0.440000; -0.600000<=pL<=0.640000, 0.440000<=pH<=0.480000; -0.600000<=pL<=0.640000, 0.480000<=pH<=0.520000; -0.600000<=pL<=0.640000, 0.520000<=pH<=0.560000; -0.600000<=pL<=0.640000, 0.560000<=pH<=0.600000; -0.600000<=pL<=0.640000, 0.600000<=pH<=0.640000; -0.600000<=pL<=0.640000, 0.640000<=pH<=0.680000; -0.600000<=pL<=0.640000, 0.680000<=pH<=0.720000; -0.600000<=pL<=0.640000, 0.720000<=pH<=0.760000; -0.600000<=pL<=0.640000, 0.760000<=pH<=0.800000; -0.600000<=pL<=0.640000, 0.800000<=pH<=0.840000; -0.600000<=pL<=0.640000, 0.840000<=pH<=0.880000; -0.600000<=pL<=0.640000, 0.880000<=pH<=0.920000; -0.600000<=pL<=0.640000, 0.920000<=pH<=0.960000; -0.600000<=pL<=0.640000, 0.960000<=pH<=0.999990; -0.640000<=pL<=0.680000, 0.000010<=pH<=0.040000; -0.640000<=pL<=0.680000, 0.040000<=pH<=0.080000; -0.640000<=pL<=0.680000, 0.080000<=pH<=0.120000; -0.640000<=pL<=0.680000, 0.120000<=pH<=0.160000; -0.640000<=pL<=0.680000, 0.160000<=pH<=0.200000; -0.640000<=pL<=0.680000, 0.200000<=pH<=0.240000; -0.640000<=pL<=0.680000, 0.240000<=pH<=0.280000; -0.640000<=pL<=0.680000, 0.280000<=pH<=0.320000; -0.640000<=pL<=0.680000, 0.320000<=pH<=0.360000; -0.640000<=pL<=0.680000, 0.360000<=pH<=0.400000; -0.640000<=pL<=0.680000, 0.400000<=pH<=0.440000; -0.640000<=pL<=0.680000, 0.440000<=pH<=0.480000; -0.640000<=pL<=0.680000, 0.480000<=pH<=0.520000; -0.640000<=pL<=0.680000, 0.520000<=pH<=0.560000; -0.640000<=pL<=0.680000, 0.560000<=pH<=0.600000; -0.640000<=pL<=0.680000, 0.600000<=pH<=0.640000; -0.640000<=pL<=0.680000, 0.640000<=pH<=0.680000; -0.640000<=pL<=0.680000, 0.680000<=pH<=0.720000; -0.640000<=pL<=0.680000, 0.720000<=pH<=0.760000; -0.640000<=pL<=0.680000, 0.760000<=pH<=0.800000; -0.640000<=pL<=0.680000, 0.800000<=pH<=0.840000; -0.640000<=pL<=0.680000, 0.840000<=pH<=0.880000; -0.640000<=pL<=0.680000, 0.880000<=pH<=0.920000; -0.640000<=pL<=0.680000, 0.920000<=pH<=0.960000; -0.640000<=pL<=0.680000, 0.960000<=pH<=0.999990; -0.680000<=pL<=0.720000, 0.000010<=pH<=0.040000; -0.680000<=pL<=0.720000, 0.040000<=pH<=0.080000; -0.680000<=pL<=0.720000, 0.080000<=pH<=0.120000; -0.680000<=pL<=0.720000, 0.120000<=pH<=0.160000; -0.680000<=pL<=0.720000, 0.160000<=pH<=0.200000; -0.680000<=pL<=0.720000, 0.200000<=pH<=0.240000; -0.680000<=pL<=0.720000, 0.240000<=pH<=0.280000; -0.680000<=pL<=0.720000, 0.280000<=pH<=0.320000; -0.680000<=pL<=0.720000, 0.320000<=pH<=0.360000; -0.680000<=pL<=0.720000, 0.360000<=pH<=0.400000; -0.680000<=pL<=0.720000, 0.400000<=pH<=0.440000; -0.680000<=pL<=0.720000, 0.440000<=pH<=0.480000; -0.680000<=pL<=0.720000, 0.480000<=pH<=0.520000; -0.680000<=pL<=0.720000, 0.520000<=pH<=0.560000; -0.680000<=pL<=0.720000, 0.560000<=pH<=0.600000; -0.680000<=pL<=0.720000, 0.600000<=pH<=0.640000; -0.680000<=pL<=0.720000, 0.640000<=pH<=0.680000; -0.680000<=pL<=0.720000, 0.680000<=pH<=0.720000; -0.680000<=pL<=0.720000, 0.720000<=pH<=0.760000; -0.680000<=pL<=0.720000, 0.760000<=pH<=0.800000; -0.680000<=pL<=0.720000, 0.800000<=pH<=0.840000; -0.680000<=pL<=0.720000, 0.840000<=pH<=0.880000; -0.680000<=pL<=0.720000, 0.880000<=pH<=0.920000; -0.680000<=pL<=0.720000, 0.920000<=pH<=0.960000; -0.680000<=pL<=0.720000, 0.960000<=pH<=0.999990; -0.720000<=pL<=0.760000, 0.000010<=pH<=0.040000; -0.720000<=pL<=0.760000, 0.040000<=pH<=0.080000; -0.720000<=pL<=0.760000, 0.080000<=pH<=0.120000; -0.720000<=pL<=0.760000, 0.120000<=pH<=0.160000; -0.720000<=pL<=0.760000, 0.160000<=pH<=0.200000; -0.720000<=pL<=0.760000, 0.200000<=pH<=0.240000; -0.720000<=pL<=0.760000, 0.240000<=pH<=0.280000; -0.720000<=pL<=0.760000, 0.280000<=pH<=0.320000; -0.720000<=pL<=0.760000, 0.320000<=pH<=0.360000; -0.720000<=pL<=0.760000, 0.360000<=pH<=0.400000; -0.720000<=pL<=0.760000, 0.400000<=pH<=0.440000; -0.720000<=pL<=0.760000, 0.440000<=pH<=0.480000; -0.720000<=pL<=0.760000, 0.480000<=pH<=0.520000; -0.720000<=pL<=0.760000, 0.520000<=pH<=0.560000; -0.720000<=pL<=0.760000, 0.560000<=pH<=0.600000; -0.720000<=pL<=0.760000, 0.600000<=pH<=0.640000; -0.720000<=pL<=0.760000, 0.640000<=pH<=0.680000; -0.720000<=pL<=0.760000, 0.680000<=pH<=0.720000; -0.720000<=pL<=0.760000, 0.720000<=pH<=0.760000; -0.720000<=pL<=0.760000, 0.760000<=pH<=0.800000; -0.720000<=pL<=0.760000, 0.800000<=pH<=0.840000; -0.720000<=pL<=0.760000, 0.840000<=pH<=0.880000; -0.720000<=pL<=0.760000, 0.880000<=pH<=0.920000; -0.720000<=pL<=0.760000, 0.920000<=pH<=0.960000; -0.720000<=pL<=0.760000, 0.960000<=pH<=0.999990; -0.760000<=pL<=0.800000, 0.000010<=pH<=0.040000; -0.760000<=pL<=0.800000, 0.040000<=pH<=0.080000; -0.760000<=pL<=0.800000, 0.080000<=pH<=0.120000; -0.760000<=pL<=0.800000, 0.120000<=pH<=0.160000; -0.760000<=pL<=0.800000, 0.160000<=pH<=0.200000; -0.760000<=pL<=0.800000, 0.200000<=pH<=0.240000; -0.760000<=pL<=0.800000, 0.240000<=pH<=0.280000; -0.760000<=pL<=0.800000, 0.280000<=pH<=0.320000; -0.760000<=pL<=0.800000, 0.320000<=pH<=0.360000; -0.760000<=pL<=0.800000, 0.360000<=pH<=0.400000; -0.760000<=pL<=0.800000, 0.400000<=pH<=0.440000; -0.760000<=pL<=0.800000, 0.440000<=pH<=0.480000; -0.760000<=pL<=0.800000, 0.480000<=pH<=0.520000; -0.760000<=pL<=0.800000, 0.520000<=pH<=0.560000; -0.760000<=pL<=0.800000, 0.560000<=pH<=0.600000; -0.760000<=pL<=0.800000, 0.600000<=pH<=0.640000; -0.760000<=pL<=0.800000, 0.640000<=pH<=0.680000; -0.760000<=pL<=0.800000, 0.680000<=pH<=0.720000; -0.760000<=pL<=0.800000, 0.720000<=pH<=0.760000; -0.760000<=pL<=0.800000, 0.760000<=pH<=0.800000; -0.760000<=pL<=0.800000, 0.800000<=pH<=0.840000; -0.760000<=pL<=0.800000, 0.840000<=pH<=0.880000; -0.760000<=pL<=0.800000, 0.880000<=pH<=0.920000; -0.760000<=pL<=0.800000, 0.920000<=pH<=0.960000; -0.760000<=pL<=0.800000, 0.960000<=pH<=0.999990; -0.800000<=pL<=0.840000, 0.000010<=pH<=0.040000; -0.800000<=pL<=0.840000, 0.040000<=pH<=0.080000; -0.800000<=pL<=0.840000, 0.080000<=pH<=0.120000; -0.800000<=pL<=0.840000, 0.120000<=pH<=0.160000; -0.800000<=pL<=0.840000, 0.160000<=pH<=0.200000; -0.800000<=pL<=0.840000, 0.200000<=pH<=0.240000; -0.800000<=pL<=0.840000, 0.240000<=pH<=0.280000; -0.800000<=pL<=0.840000, 0.280000<=pH<=0.320000; -0.800000<=pL<=0.840000, 0.320000<=pH<=0.360000; -0.800000<=pL<=0.840000, 0.360000<=pH<=0.400000; -0.800000<=pL<=0.840000, 0.400000<=pH<=0.440000; -0.800000<=pL<=0.840000, 0.440000<=pH<=0.480000; -0.800000<=pL<=0.840000, 0.480000<=pH<=0.520000; -0.800000<=pL<=0.840000, 0.520000<=pH<=0.560000; -0.800000<=pL<=0.840000, 0.560000<=pH<=0.600000; -0.800000<=pL<=0.840000, 0.600000<=pH<=0.640000; -0.800000<=pL<=0.840000, 0.640000<=pH<=0.680000; -0.800000<=pL<=0.840000, 0.680000<=pH<=0.720000; -0.800000<=pL<=0.840000, 0.720000<=pH<=0.760000; -0.800000<=pL<=0.840000, 0.760000<=pH<=0.800000; -0.800000<=pL<=0.840000, 0.800000<=pH<=0.840000; -0.800000<=pL<=0.840000, 0.840000<=pH<=0.880000; -0.800000<=pL<=0.840000, 0.880000<=pH<=0.920000; -0.800000<=pL<=0.840000, 0.920000<=pH<=0.960000; -0.800000<=pL<=0.840000, 0.960000<=pH<=0.999990; -0.840000<=pL<=0.880000, 0.000010<=pH<=0.040000; -0.840000<=pL<=0.880000, 0.040000<=pH<=0.080000; -0.840000<=pL<=0.880000, 0.080000<=pH<=0.120000; -0.840000<=pL<=0.880000, 0.120000<=pH<=0.160000; -0.840000<=pL<=0.880000, 0.160000<=pH<=0.200000; -0.840000<=pL<=0.880000, 0.200000<=pH<=0.240000; -0.840000<=pL<=0.880000, 0.240000<=pH<=0.280000; -0.840000<=pL<=0.880000, 0.280000<=pH<=0.320000; -0.840000<=pL<=0.880000, 0.320000<=pH<=0.360000; -0.840000<=pL<=0.880000, 0.360000<=pH<=0.400000; -0.840000<=pL<=0.880000, 0.400000<=pH<=0.440000; -0.840000<=pL<=0.880000, 0.440000<=pH<=0.480000; -0.840000<=pL<=0.880000, 0.480000<=pH<=0.520000; -0.840000<=pL<=0.880000, 0.520000<=pH<=0.560000; -0.840000<=pL<=0.880000, 0.560000<=pH<=0.600000; -0.840000<=pL<=0.880000, 0.600000<=pH<=0.640000; -0.840000<=pL<=0.880000, 0.640000<=pH<=0.680000; -0.840000<=pL<=0.880000, 0.680000<=pH<=0.720000; -0.840000<=pL<=0.880000, 0.720000<=pH<=0.760000; -0.840000<=pL<=0.880000, 0.760000<=pH<=0.800000; -0.840000<=pL<=0.880000, 0.800000<=pH<=0.840000; -0.840000<=pL<=0.880000, 0.840000<=pH<=0.880000; -0.840000<=pL<=0.880000, 0.880000<=pH<=0.920000; -0.840000<=pL<=0.880000, 0.920000<=pH<=0.960000; -0.840000<=pL<=0.880000, 0.960000<=pH<=0.999990; -0.880000<=pL<=0.920000, 0.000010<=pH<=0.040000; -0.880000<=pL<=0.920000, 0.040000<=pH<=0.080000; -0.880000<=pL<=0.920000, 0.080000<=pH<=0.120000; -0.880000<=pL<=0.920000, 0.120000<=pH<=0.160000; -0.880000<=pL<=0.920000, 0.160000<=pH<=0.200000; -0.880000<=pL<=0.920000, 0.200000<=pH<=0.240000; -0.880000<=pL<=0.920000, 0.240000<=pH<=0.280000; -0.880000<=pL<=0.920000, 0.280000<=pH<=0.320000; -0.880000<=pL<=0.920000, 0.320000<=pH<=0.360000; -0.880000<=pL<=0.920000, 0.360000<=pH<=0.400000; -0.880000<=pL<=0.920000, 0.400000<=pH<=0.440000; -0.880000<=pL<=0.920000, 0.440000<=pH<=0.480000; -0.880000<=pL<=0.920000, 0.480000<=pH<=0.520000; -0.880000<=pL<=0.920000, 0.520000<=pH<=0.560000; -0.880000<=pL<=0.920000, 0.560000<=pH<=0.600000; -0.880000<=pL<=0.920000, 0.600000<=pH<=0.640000; -0.880000<=pL<=0.920000, 0.640000<=pH<=0.680000; -0.880000<=pL<=0.920000, 0.680000<=pH<=0.720000; -0.880000<=pL<=0.920000, 0.720000<=pH<=0.760000; -0.880000<=pL<=0.920000, 0.760000<=pH<=0.800000; -0.880000<=pL<=0.920000, 0.800000<=pH<=0.840000; -0.880000<=pL<=0.920000, 0.840000<=pH<=0.880000; -0.880000<=pL<=0.920000, 0.880000<=pH<=0.920000; -0.880000<=pL<=0.920000, 0.920000<=pH<=0.960000; -0.880000<=pL<=0.920000, 0.960000<=pH<=0.999990; -0.920000<=pL<=0.960000, 0.000010<=pH<=0.040000; -0.920000<=pL<=0.960000, 0.040000<=pH<=0.080000; -0.920000<=pL<=0.960000, 0.080000<=pH<=0.120000; -0.920000<=pL<=0.960000, 0.120000<=pH<=0.160000; -0.920000<=pL<=0.960000, 0.160000<=pH<=0.200000; -0.920000<=pL<=0.960000, 0.200000<=pH<=0.240000; -0.920000<=pL<=0.960000, 0.240000<=pH<=0.280000; -0.920000<=pL<=0.960000, 0.280000<=pH<=0.320000; -0.920000<=pL<=0.960000, 0.320000<=pH<=0.360000; -0.920000<=pL<=0.960000, 0.360000<=pH<=0.400000; -0.920000<=pL<=0.960000, 0.400000<=pH<=0.440000; -0.920000<=pL<=0.960000, 0.440000<=pH<=0.480000; -0.920000<=pL<=0.960000, 0.480000<=pH<=0.520000; -0.920000<=pL<=0.960000, 0.520000<=pH<=0.560000; -0.920000<=pL<=0.960000, 0.560000<=pH<=0.600000; -0.920000<=pL<=0.960000, 0.600000<=pH<=0.640000; -0.920000<=pL<=0.960000, 0.640000<=pH<=0.680000; -0.920000<=pL<=0.960000, 0.680000<=pH<=0.720000; -0.920000<=pL<=0.960000, 0.720000<=pH<=0.760000; -0.920000<=pL<=0.960000, 0.760000<=pH<=0.800000; -0.920000<=pL<=0.960000, 0.800000<=pH<=0.840000; -0.920000<=pL<=0.960000, 0.840000<=pH<=0.880000; -0.920000<=pL<=0.960000, 0.880000<=pH<=0.920000; -0.920000<=pL<=0.960000, 0.920000<=pH<=0.960000; -0.920000<=pL<=0.960000, 0.960000<=pH<=0.999990; -0.960000<=pL<=0.999990, 0.000010<=pH<=0.040000; -0.960000<=pL<=0.999990, 0.040000<=pH<=0.080000; -0.960000<=pL<=0.999990, 0.080000<=pH<=0.120000; -0.960000<=pL<=0.999990, 0.120000<=pH<=0.160000; -0.960000<=pL<=0.999990, 0.160000<=pH<=0.200000; -0.960000<=pL<=0.999990, 0.200000<=pH<=0.240000; -0.960000<=pL<=0.999990, 0.240000<=pH<=0.280000; -0.960000<=pL<=0.999990, 0.280000<=pH<=0.320000; -0.960000<=pL<=0.999990, 0.320000<=pH<=0.360000; -0.960000<=pL<=0.999990, 0.360000<=pH<=0.400000; -0.960000<=pL<=0.999990, 0.400000<=pH<=0.440000; -0.960000<=pL<=0.999990, 0.440000<=pH<=0.480000; -0.960000<=pL<=0.999990, 0.480000<=pH<=0.520000; -0.960000<=pL<=0.999990, 0.520000<=pH<=0.560000; -0.960000<=pL<=0.999990, 0.560000<=pH<=0.600000; -0.960000<=pL<=0.999990, 0.600000<=pH<=0.640000; -0.960000<=pL<=0.999990, 0.640000<=pH<=0.680000; -0.960000<=pL<=0.999990, 0.680000<=pH<=0.720000; -0.960000<=pL<=0.999990, 0.720000<=pH<=0.760000; -0.960000<=pL<=0.999990, 0.760000<=pH<=0.800000; -0.960000<=pL<=0.999990, 0.800000<=pH<=0.840000; -0.960000<=pL<=0.999990, 0.840000<=pH<=0.880000; -0.960000<=pL<=0.999990, 0.880000<=pH<=0.920000; -0.960000<=pL<=0.999990, 0.920000<=pH<=0.960000; -0.960000<=pL<=0.999990, 0.960000<=pH<=0.999990; diff --git a/examples/pmdp/reporter2/reporter2_space.txt b/examples/pmdp/reporter2/reporter2_space.txt deleted file mode 100644 index ef1f8db6c..000000000 --- a/examples/pmdp/reporter2/reporter2_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=pL<=0.999990, 0.000010<=pH<=0.999990; - diff --git a/examples/pmdp/reporter4/models b/examples/pmdp/reporter4/models deleted file mode 100644 index f9a0e194c..000000000 --- a/examples/pmdp/reporter4/models +++ /dev/null @@ -1,2 +0,0 @@ -reporter4.pm -const Xsize=6,Ysize=6,MAXTRIES=2,B=2 -reporter4.pm -const Xsize=10,Ysize=10,MAXTRIES=3,B=3 diff --git a/examples/pmdp/reporter4/reporter25_25_5_5.pm b/examples/pmdp/reporter4/reporter25_25_5_5.pm deleted file mode 100644 index ef8ac7bdf..000000000 --- a/examples/pmdp/reporter4/reporter25_25_5_5.pm +++ /dev/null @@ -1,73 +0,0 @@ -// GRID WORLD MODEL OF A SEMIAUTONOMOUS EXPLORING ROBOT -// Sebastian Junges, RWTH Aachen University -// As described in -// Junges, Jansen, Dehnert, Topcu, Katoen: -// Safety Constrained Reinforcement Learning -// Proc. of TACAS’16 - -mdp - -//PARAMETERS -//The difference of the reliability of the channels between the worst and at the best position -const double pLDiff;//=0.1; -const double pHDiff;//=0.1; -//Scaling factor for the minimum reliability of the channels -const double pL;//=8/9; -const double pH;//=1; - -//CONSTANTS -//The minimum reliablities -const double pLMin=pL*(1-pLDiff); -const double pHMin=pH*(1-pHDiff); - -// Grid size -const int Xsize = 25; -const int Ysize = 25; -// Number of tries before an error -const int MAXTRIES = 5; -// Ball within the robot has to move. -const int B=5; - - -formula T = (xLoc = Xsize & yLoc = Ysize); - - -module robot - xLoc : [1..Ysize] init 1; - yLoc : [1..Xsize] init 1; - unreported : [0..B] init 0; - hasSendNow : bool init false; - tries : [0..MAXTRIES] init 0; - - [up] xLoc < Xsize & !T & hasSendNow -> 1:(xLoc'=xLoc+1) & (unreported' = 0) & (hasSendNow'=false); - [up] xLoc < Xsize & !T & !hasSendNow -> 1:(xLoc'=xLoc+1) & (unreported'=min(unreported+1, B)); - [right] yLoc < Ysize & !T & hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported' = 0)& (hasSendNow'=false); - [right] yLoc < Ysize & !T & !hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported'=min(unreported+1,B)); - [sendL] !hasSendNow & !T & tries < MAXTRIES -> (pLMin + pLDiff * xLoc/Xsize):(hasSendNow'=true) & (tries'=0) + (1 - pLMin - pLDiff * xLoc/Xsize): (tries'=tries+1); - [sendH] !hasSendNow & !T & tries < MAXTRIES -> (pHMin + pHDiff * yLoc/Ysize):(hasSendNow'=true) & (tries'=0) + (1 - pHMin - pHDiff * yLoc/Ysize): (tries'=tries+1); - [done] T -> 1:true; -endmodule - -rewards "sendbased" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: max(10, min(11 + xLoc - yLoc, 20)); - [sendH] true: min(13 + xLoc + yLoc, 24); -endrewards - -rewards "sendbased_lower" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 10; - [sendH] true: 12; -endrewards - -rewards "sendbased_upper" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 20; - [sendH] true: 24; -endrewards - -label "Target" = T; -label "Crash" = unreported=B; diff --git a/examples/pmdp/reporter4/reporter4.pm b/examples/pmdp/reporter4/reporter4.pm deleted file mode 100644 index 1b4227741..000000000 --- a/examples/pmdp/reporter4/reporter4.pm +++ /dev/null @@ -1,73 +0,0 @@ -// GRID WORLD MODEL OF A SEMIAUTONOMOUS EXPLORING ROBOT -// Sebastian Junges, RWTH Aachen University -// As described in -// Junges, Jansen, Dehnert, Topcu, Katoen: -// Safety Constrained Reinforcement Learning -// Proc. of TACAS’16 - -mdp - -//PARAMETERS -//The difference of the reliability of the channels between the worst and at the best position -const double pLDiff;//=0.1; -const double pHDiff;//=0.1; -//Scaling factor for the minimum reliability of the channels -const double pL;//=8/9; -const double pH;//=1; - -//CONSTANTS -//The minimum reliablities -const double pLMin=pL*(1-pLDiff); -const double pHMin=pH*(1-pHDiff); - -// Grid size -const int Xsize; -const int Ysize; -// Number of tries before an error -const int MAXTRIES; -// Ball within the robot has to move. -const int B; - - -formula T = (xLoc = Xsize & yLoc = Ysize); - - -module robot - xLoc : [1..Ysize] init 1; - yLoc : [1..Xsize] init 1; - unreported : [0..B] init 0; - hasSendNow : bool init false; - tries : [0..MAXTRIES] init 0; - - [up] xLoc < Xsize & !T & hasSendNow -> 1:(xLoc'=xLoc+1) & (unreported' = 0) & (hasSendNow'=false); - [up] xLoc < Xsize & !T & !hasSendNow -> 1:(xLoc'=xLoc+1) & (unreported'=min(unreported+1, B)); - [right] yLoc < Ysize & !T & hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported' = 0)& (hasSendNow'=false); - [right] yLoc < Ysize & !T & !hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported'=min(unreported+1,B)); - [sendL] !hasSendNow & !T & tries < MAXTRIES -> (pLMin + pLDiff * xLoc/Xsize):(hasSendNow'=true) & (tries'=0) + (1 - pLMin - pLDiff * xLoc/Xsize): (tries'=tries+1); - [sendH] !hasSendNow & !T & tries < MAXTRIES -> (pHMin + pHDiff * yLoc/Ysize):(hasSendNow'=true) & (tries'=0) + (1 - pHMin - pHDiff * yLoc/Ysize): (tries'=tries+1); - [done] T -> 1:true; -endmodule - -rewards "sendbased" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: max(10, min(11 + xLoc - yLoc, 20)); - [sendH] true: min(13 + xLoc + yLoc, 24); -endrewards - -rewards "sendbased_lower" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 10; - [sendH] true: 12; -endrewards - -rewards "sendbased_upper" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 20; - [sendH] true: 24; -endrewards - -label "Target" = T; -label "Crash" = unreported=B; diff --git a/examples/pmdp/reporter4/reporter4.prctl b/examples/pmdp/reporter4/reporter4.prctl deleted file mode 100644 index 959df1e88..000000000 --- a/examples/pmdp/reporter4/reporter4.prctl +++ /dev/null @@ -1 +0,0 @@ -P>0.3[F "Crash" ] diff --git a/examples/pmdp/reporter4/reporter4_regions.txt b/examples/pmdp/reporter4/reporter4_regions.txt deleted file mode 100644 index 9b1faa972..000000000 --- a/examples/pmdp/reporter4/reporter4_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.000010<=pL<=0.200000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.200000<=pL<=0.400000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.400000<=pL<=0.600000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.600000<=pL<=0.800000, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.000010<=pH<=0.200000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.200000<=pH<=0.400000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.400000<=pH<=0.600000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.600000<=pH<=0.800000, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.000010<=pLDiff<=0.200000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.200000<=pLDiff<=0.400000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.400000<=pLDiff<=0.600000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.600000<=pLDiff<=0.800000, 0.800000<=pHDiff<=0.999990; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.200000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.200000<=pHDiff<=0.400000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.400000<=pHDiff<=0.600000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.600000<=pHDiff<=0.800000; -0.800000<=pL<=0.999990, 0.800000<=pH<=0.999990, 0.800000<=pLDiff<=0.999990, 0.800000<=pHDiff<=0.999990; diff --git a/examples/pmdp/reporter4/reporter4_regions2.txt b/examples/pmdp/reporter4/reporter4_regions2.txt deleted file mode 100644 index 539b3bd60..000000000 --- a/examples/pmdp/reporter4/reporter4_regions2.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=pL<=0.040000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.000010<=pL<=0.040000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.040000<=pL<=0.080000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.080000<=pL<=0.120000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.120000<=pL<=0.160000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.160000<=pL<=0.200000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.200000<=pL<=0.240000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.240000<=pL<=0.280000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.280000<=pL<=0.320000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.320000<=pL<=0.360000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.360000<=pL<=0.400000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.400000<=pL<=0.440000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.440000<=pL<=0.480000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.480000<=pL<=0.520000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.520000<=pL<=0.560000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.560000<=pL<=0.600000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.600000<=pL<=0.640000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.640000<=pL<=0.680000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.680000<=pL<=0.720000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.720000<=pL<=0.760000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.760000<=pL<=0.800000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.800000<=pL<=0.840000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.840000<=pL<=0.880000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.880000<=pL<=0.920000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.920000<=pL<=0.960000, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.000010<=pH<=0.040000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.040000<=pH<=0.080000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.080000<=pH<=0.120000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.120000<=pH<=0.160000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.160000<=pH<=0.200000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.200000<=pH<=0.240000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.240000<=pH<=0.280000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.280000<=pH<=0.320000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.320000<=pH<=0.360000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.360000<=pH<=0.400000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.400000<=pH<=0.440000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.440000<=pH<=0.480000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.480000<=pH<=0.520000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.520000<=pH<=0.560000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.560000<=pH<=0.600000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.600000<=pH<=0.640000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.640000<=pH<=0.680000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.680000<=pH<=0.720000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.720000<=pH<=0.760000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.760000<=pH<=0.800000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.800000<=pH<=0.840000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.840000<=pH<=0.880000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.880000<=pH<=0.920000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.920000<=pH<=0.960000, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; -0.960000<=pL<=0.999990, 0.960000<=pH<=0.999990, 0.05<=pLDiff<=0.15, 0.05<=pHDiff<=0.15; diff --git a/examples/pmdp/reporter4/reporter4_space.txt b/examples/pmdp/reporter4/reporter4_space.txt deleted file mode 100644 index d0f12ccfc..000000000 --- a/examples/pmdp/reporter4/reporter4_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=pL<=0.999990, 0.000010<=pH<=0.999990, 0.000010<=pLDiff<=0.999990, 0.000010<=pHDiff<=0.999990; - diff --git a/examples/pmdp/reporter4/reporter6_6_2_2.pm b/examples/pmdp/reporter4/reporter6_6_2_2.pm deleted file mode 100644 index 1ce47c201..000000000 --- a/examples/pmdp/reporter4/reporter6_6_2_2.pm +++ /dev/null @@ -1,73 +0,0 @@ -// GRID WORLD MODEL OF A SEMIAUTONOMOUS EXPLORING ROBOT -// Sebastian Junges, RWTH Aachen University -// As described in -// Junges, Jansen, Dehnert, Topcu, Katoen: -// Safety Constrained Reinforcement Learning -// Proc. of TACAS’16 - -mdp - -//PARAMETERS -//The difference of the reliability of the channels between the worst and at the best position -const double pLDiff;//=0.1; -const double pHDiff;//=0.1; -//Scaling factor for the minimum reliability of the channels -const double pL;//=8/9; -const double pH;//=1; - -//CONSTANTS -//The minimum reliablities -const double pLMin=pL*(1-pLDiff); -const double pHMin=pH*(1-pHDiff); - -// Grid size -const int Xsize = 6; -const int Ysize = 6; -// Number of tries before an error -const int MAXTRIES = 2; -// Ball within the robot has to move. -const int B=2; - - -formula T = (xLoc = Xsize & yLoc = Ysize); - - -module robot - xLoc : [1..Ysize] init 1; - yLoc : [1..Xsize] init 1; - unreported : [0..B] init 0; - hasSendNow : bool init false; - tries : [0..MAXTRIES] init 0; - - [up] xLoc < Xsize & !T & hasSendNow -> 1:(xLoc'=xLoc+1) & (unreported' = 0) & (hasSendNow'=false); - [up] xLoc < Xsize & !T & !hasSendNow -> 1:(xLoc'=xLoc+1) & (unreported'=min(unreported+1, B)); - [right] yLoc < Ysize & !T & hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported' = 0)& (hasSendNow'=false); - [right] yLoc < Ysize & !T & !hasSendNow -> 1:(yLoc'=yLoc+1) & (unreported'=min(unreported+1,B)); - [sendL] !hasSendNow & !T & tries < MAXTRIES -> (pLMin + pLDiff * xLoc/Xsize):(hasSendNow'=true) & (tries'=0) + (1 - pLMin - pLDiff * xLoc/Xsize): (tries'=tries+1); - [sendH] !hasSendNow & !T & tries < MAXTRIES -> (pHMin + pHDiff * yLoc/Ysize):(hasSendNow'=true) & (tries'=0) + (1 - pHMin - pHDiff * yLoc/Ysize): (tries'=tries+1); - [done] T -> 1:true; -endmodule - -rewards "sendbased" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: max(10, min(11 + xLoc - yLoc, 20)); - [sendH] true: min(13 + xLoc + yLoc, 24); -endrewards - -rewards "sendbased_lower" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 10; - [sendH] true: 12; -endrewards - -rewards "sendbased_upper" - [up] true: 0.03; - [right] true: 0.03; - [sendL] true: 20; - [sendH] true: 24; -endrewards - -label "Target" = T; -label "Crash" = unreported=B; diff --git a/examples/pmdp/zeroconf/models b/examples/pmdp/zeroconf/models deleted file mode 100644 index 07d1fa6b7..000000000 --- a/examples/pmdp/zeroconf/models +++ /dev/null @@ -1,2 +0,0 @@ -zeroconf.pm -const K=2 -zeroconf.pm -const K=5 diff --git a/examples/pmdp/zeroconf/zeroconf.pm b/examples/pmdp/zeroconf/zeroconf.pm deleted file mode 100644 index 9c71181f2..000000000 --- a/examples/pmdp/zeroconf/zeroconf.pm +++ /dev/null @@ -1,258 +0,0 @@ -// IPv4: PTA model with digitial clocks -// one concrete host attempting to choose an ip address -// when a number of (abstract) hosts have already got ip addresses -// gxn/dxp/jzs 02/05/03 - -// model is an mdp -mdp - -// reset or noreset model -const bool reset=false; - -//------------------------------------------------------------- - -// we suppose that -// - the abstract hosts have already picked their addresses -// and always defend their addresses -// - the concrete host never picks the same ip address twice -// (this can happen only with a verys small probability) - -// under these assumptions we do not need message types because: -// 1) since messages to the concrete host will never be a probe, -// this host will react to all messages in the same way -// 2) since the abstract hosts always defend their addresses, -// all messages from the host will get an arp reply if the ip matches - -// following from the above assumptions we require only three abstract IP addresses -// (0,1 and 2) which correspond to the following sets of IP addresses: - -// 0 - the IP addresses of the abstract hosts which the concrete host -// previously tried to configure -// 1 - an IP address of an abstract host which the concrete host is -// currently trying to configure -// 2 - a fresh IP address which the concrete host is currently trying to configure - -// if the host picks an address that is being used it may end up picking another ip address -// in which case there may still be messages corresponding to the old ip address -// to be sent both from and to the host which the host should now disregard -// (since it will never pick the same ip address) - -// to deal with this situation: when a host picks a new ip address we reconfigure the -// messages that are still be be sent or are being sent by changing the ip address to 0 -// (an old ip address of the host) - -// all the messages from the abstract hosts for the 'old' address (in fact the -// set of old addresses since it may have started again more than once) -// can arrive in any order since they are equivalent to the host - it ignores then all - -// also the messages for the old and new address will come from different hosts -// (the ones with that ip address) which we model by allowing them to arrive in any order -// i.e. not neccessarily in the order they where sent - -//------------------------------------------------------------- - - -//------------------------------------------------------------- -// VARIABLES -//const int N; // number of abstract hosts -const int K; // number of probes to send -const double loss; // probability of message loss - -// PROBABILITIES -const double old; //=N/65024; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -// size of buffers for other hosts -const int B0 = 20; // buffer size for one abstract host -const int B1 = 8; // buffer sizes for all abstract hosts - -//------------------------------------------------------------- -// ENVIRONMENT - models: medium, output buffer of concrete host and all other hosts -module environment - - // buffer of concrete host - b_ip7 : [0..2]; // ip address of message in buffer position 8 - b_ip6 : [0..2]; // ip address of message in buffer position 7 - b_ip5 : [0..2]; // ip address of message in buffer position 6 - b_ip4 : [0..2]; // ip address of message in buffer position 5 - b_ip3 : [0..2]; // ip address of message in buffer position 4 - b_ip2 : [0..2]; // ip address of message in buffer position 3 - b_ip1 : [0..2]; // ip address of message in buffer position 2 - b_ip0 : [0..2]; // ip address of message in buffer position 1 - n : [0..8]; // number of places in the buffer used (from host) - - // messages to be sent from abstract hosts to concrete host - n0 : [0..B0]; // number of messages which do not have the host's current ip address - n1 : [0..B1]; // number of messages which have the host's current ip address - - b : [0..2]; // local state - // 0 - idle - // 1 - sending message from concrete host - // 2 - sending message from abstract host - - z : [0..1]; // clock of environment (needed for the time to send a message) - - ip_mess : [0..2]; // ip in the current message being sent - // 0 - different from concrete host - // 1 - same as the concrete host and in use - // 2 - same as the concrete host and not in use - - // RESET/RECONFIG: when host is about to choose new ip address - // suppose that the host cannot choose the same ip address - // (since happens with very small probability). - // Therefore all messages will have a different ip address, - // i.e. all n1 messages become n0 ones. - // Note this include any message currently being sent (ip is set to zero 0) - [reset] true -> (n1'=0) & (n0'=min(B0,n0+n1)) // abstract buffers - & (ip_mess'=0) // message being set - & (n'=(reset)?0:n) // concrete buffer (remove this update to get NO_RESET model) - & (b_ip7'=0) - & (b_ip6'=0) - & (b_ip5'=0) - & (b_ip4'=0) - & (b_ip3'=0) - & (b_ip2'=0) - & (b_ip1'=0) - & (b_ip0'=0); - // note: prevent anything else from happening when reconfiguration needs to take place - - // time passage (only if no messages to send or sending a message) - [time] l>0 & b=0 & n=0 & n0=0 & n1=0 -> (b'=b); // cannot send a message - [time] l>0 & b>0 & z<1 -> (z'=min(z+1,TIME_MAX_Z)); // sending a message - - // get messages to be sent (so message has same ip address as host) - [send] l>0 & n=0 -> (b_ip0'=ip) & (n'=n+1); - [send] l>0 & n=1 -> (b_ip1'=ip) & (n'=n+1); - [send] l>0 & n=2 -> (b_ip2'=ip) & (n'=n+1); - [send] l>0 & n=3 -> (b_ip3'=ip) & (n'=n+1); - [send] l>0 & n=4 -> (b_ip4'=ip) & (n'=n+1); - [send] l>0 & n=5 -> (b_ip5'=ip) & (n'=n+1); - [send] l>0 & n=6 -> (b_ip6'=ip) & (n'=n+1); - [send] l>0 & n=7 -> (b_ip7'=ip) & (n'=n+1); - [send] l>0 & n=8 -> (n'=n); // buffer full so lose message - - // start sending message from host - [] l>0 & b=0 & n>0 -> (1-loss) : (b'=1) & (ip_mess'=b_ip0) - & (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1) // send message - + loss : (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1); // lose message - - // start sending message to host - [] l>0 & b=0 & n0>0 -> (1-loss) : (b'=2) & (ip_mess'=0) & (n0'=n0-1) + loss : (n0'=n0-1); // different ip - [] l>0 & b=0 & n1>0 -> (1-loss) : (b'=2) & (ip_mess'=1) & (n1'=n1-1) + loss : (n1'=n1-1); // same ip - - // finish sending message from host - [] l>0 & b=1 & ip_mess=0 -> (b'=0) & (z'=0) & (n0'=min(n0+1,B0)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=1 -> (b'=0) & (z'=0) & (n1'=min(n1+1,B1)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - - // finish sending message to host - [rec] l>0 & b=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - -endmodule - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec] (l=1) -> 1: true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send] l=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec] l=2 & ip_mess!=ip -> (l'=l); - // get a message with matching ip: reconfigure - [rec] l=2 & ip_mess=ip -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec] l=3 & mess=0 & ip_mess!=ip -> (l'=l); - - - // send probe reply or message for defence - [send] l=3 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send] l=3 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send] l=3 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> 1 : true; - -endmodule diff --git a/examples/pmdp/zeroconf/zeroconf.prctl b/examples/pmdp/zeroconf/zeroconf.prctl deleted file mode 100644 index bc250be36..000000000 --- a/examples/pmdp/zeroconf/zeroconf.prctl +++ /dev/null @@ -1 +0,0 @@ -P<=0.1 [ F (l=4 & ip=1) ] diff --git a/examples/pmdp/zeroconf/zeroconf2.pm b/examples/pmdp/zeroconf/zeroconf2.pm deleted file mode 100644 index 2354cd9cb..000000000 --- a/examples/pmdp/zeroconf/zeroconf2.pm +++ /dev/null @@ -1,258 +0,0 @@ -// IPv4: PTA model with digitial clocks -// one concrete host attempting to choose an ip address -// when a number of (abstract) hosts have already got ip addresses -// gxn/dxp/jzs 02/05/03 - -// model is an mdp -mdp - -// reset or noreset model -const bool reset=false; - -//------------------------------------------------------------- - -// we suppose that -// - the abstract hosts have already picked their addresses -// and always defend their addresses -// - the concrete host never picks the same ip address twice -// (this can happen only with a verys small probability) - -// under these assumptions we do not need message types because: -// 1) since messages to the concrete host will never be a probe, -// this host will react to all messages in the same way -// 2) since the abstract hosts always defend their addresses, -// all messages from the host will get an arp reply if the ip matches - -// following from the above assumptions we require only three abstract IP addresses -// (0,1 and 2) which correspond to the following sets of IP addresses: - -// 0 - the IP addresses of the abstract hosts which the concrete host -// previously tried to configure -// 1 - an IP address of an abstract host which the concrete host is -// currently trying to configure -// 2 - a fresh IP address which the concrete host is currently trying to configure - -// if the host picks an address that is being used it may end up picking another ip address -// in which case there may still be messages corresponding to the old ip address -// to be sent both from and to the host which the host should now disregard -// (since it will never pick the same ip address) - -// to deal with this situation: when a host picks a new ip address we reconfigure the -// messages that are still be be sent or are being sent by changing the ip address to 0 -// (an old ip address of the host) - -// all the messages from the abstract hosts for the 'old' address (in fact the -// set of old addresses since it may have started again more than once) -// can arrive in any order since they are equivalent to the host - it ignores then all - -// also the messages for the old and new address will come from different hosts -// (the ones with that ip address) which we model by allowing them to arrive in any order -// i.e. not neccessarily in the order they where sent - -//------------------------------------------------------------- - - -//------------------------------------------------------------- -// VARIABLES -//const int N; // number of abstract hosts -const int K=2; // number of probes to send -const double loss; // probability of message loss - -// PROBABILITIES -const double old; //=N/65024; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -// size of buffers for other hosts -const int B0 = 20; // buffer size for one abstract host -const int B1 = 8; // buffer sizes for all abstract hosts - -//------------------------------------------------------------- -// ENVIRONMENT - models: medium, output buffer of concrete host and all other hosts -module environment - - // buffer of concrete host - b_ip7 : [0..2]; // ip address of message in buffer position 8 - b_ip6 : [0..2]; // ip address of message in buffer position 7 - b_ip5 : [0..2]; // ip address of message in buffer position 6 - b_ip4 : [0..2]; // ip address of message in buffer position 5 - b_ip3 : [0..2]; // ip address of message in buffer position 4 - b_ip2 : [0..2]; // ip address of message in buffer position 3 - b_ip1 : [0..2]; // ip address of message in buffer position 2 - b_ip0 : [0..2]; // ip address of message in buffer position 1 - n : [0..8]; // number of places in the buffer used (from host) - - // messages to be sent from abstract hosts to concrete host - n0 : [0..B0]; // number of messages which do not have the host's current ip address - n1 : [0..B1]; // number of messages which have the host's current ip address - - b : [0..2]; // local state - // 0 - idle - // 1 - sending message from concrete host - // 2 - sending message from abstract host - - z : [0..1]; // clock of environment (needed for the time to send a message) - - ip_mess : [0..2]; // ip in the current message being sent - // 0 - different from concrete host - // 1 - same as the concrete host and in use - // 2 - same as the concrete host and not in use - - // RESET/RECONFIG: when host is about to choose new ip address - // suppose that the host cannot choose the same ip address - // (since happens with very small probability). - // Therefore all messages will have a different ip address, - // i.e. all n1 messages become n0 ones. - // Note this include any message currently being sent (ip is set to zero 0) - [reset] true -> (n1'=0) & (n0'=min(B0,n0+n1)) // abstract buffers - & (ip_mess'=0) // message being set - & (n'=(reset)?0:n) // concrete buffer (remove this update to get NO_RESET model) - & (b_ip7'=0) - & (b_ip6'=0) - & (b_ip5'=0) - & (b_ip4'=0) - & (b_ip3'=0) - & (b_ip2'=0) - & (b_ip1'=0) - & (b_ip0'=0); - // note: prevent anything else from happening when reconfiguration needs to take place - - // time passage (only if no messages to send or sending a message) - [time] l>0 & b=0 & n=0 & n0=0 & n1=0 -> (b'=b); // cannot send a message - [time] l>0 & b>0 & z<1 -> (z'=min(z+1,TIME_MAX_Z)); // sending a message - - // get messages to be sent (so message has same ip address as host) - [send] l>0 & n=0 -> (b_ip0'=ip) & (n'=n+1); - [send] l>0 & n=1 -> (b_ip1'=ip) & (n'=n+1); - [send] l>0 & n=2 -> (b_ip2'=ip) & (n'=n+1); - [send] l>0 & n=3 -> (b_ip3'=ip) & (n'=n+1); - [send] l>0 & n=4 -> (b_ip4'=ip) & (n'=n+1); - [send] l>0 & n=5 -> (b_ip5'=ip) & (n'=n+1); - [send] l>0 & n=6 -> (b_ip6'=ip) & (n'=n+1); - [send] l>0 & n=7 -> (b_ip7'=ip) & (n'=n+1); - [send] l>0 & n=8 -> (n'=n); // buffer full so lose message - - // start sending message from host - [] l>0 & b=0 & n>0 -> (1-loss) : (b'=1) & (ip_mess'=b_ip0) - & (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1) // send message - + loss : (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1); // lose message - - // start sending message to host - [] l>0 & b=0 & n0>0 -> (1-loss) : (b'=2) & (ip_mess'=0) & (n0'=n0-1) + loss : (n0'=n0-1); // different ip - [] l>0 & b=0 & n1>0 -> (1-loss) : (b'=2) & (ip_mess'=1) & (n1'=n1-1) + loss : (n1'=n1-1); // same ip - - // finish sending message from host - [] l>0 & b=1 & ip_mess=0 -> (b'=0) & (z'=0) & (n0'=min(n0+1,B0)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=1 -> (b'=0) & (z'=0) & (n1'=min(n1+1,B1)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - - // finish sending message to host - [rec] l>0 & b=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - -endmodule - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec] (l=1) -> 1: true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send] l=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec] l=2 & ip_mess!=ip -> (l'=l); - // get a message with matching ip: reconfigure - [rec] l=2 & ip_mess=ip -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec] l=3 & mess=0 & ip_mess!=ip -> (l'=l); - - - // send probe reply or message for defence - [send] l=3 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send] l=3 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send] l=3 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> 1 : true; - -endmodule diff --git a/examples/pmdp/zeroconf/zeroconf3.pm b/examples/pmdp/zeroconf/zeroconf3.pm deleted file mode 100644 index 9cd95ac4b..000000000 --- a/examples/pmdp/zeroconf/zeroconf3.pm +++ /dev/null @@ -1,258 +0,0 @@ -// IPv4: PTA model with digitial clocks -// one concrete host attempting to choose an ip address -// when a number of (abstract) hosts have already got ip addresses -// gxn/dxp/jzs 02/05/03 - -// model is an mdp -mdp - -// reset or noreset model -const bool reset=false; - -//------------------------------------------------------------- - -// we suppose that -// - the abstract hosts have already picked their addresses -// and always defend their addresses -// - the concrete host never picks the same ip address twice -// (this can happen only with a verys small probability) - -// under these assumptions we do not need message types because: -// 1) since messages to the concrete host will never be a probe, -// this host will react to all messages in the same way -// 2) since the abstract hosts always defend their addresses, -// all messages from the host will get an arp reply if the ip matches - -// following from the above assumptions we require only three abstract IP addresses -// (0,1 and 2) which correspond to the following sets of IP addresses: - -// 0 - the IP addresses of the abstract hosts which the concrete host -// previously tried to configure -// 1 - an IP address of an abstract host which the concrete host is -// currently trying to configure -// 2 - a fresh IP address which the concrete host is currently trying to configure - -// if the host picks an address that is being used it may end up picking another ip address -// in which case there may still be messages corresponding to the old ip address -// to be sent both from and to the host which the host should now disregard -// (since it will never pick the same ip address) - -// to deal with this situation: when a host picks a new ip address we reconfigure the -// messages that are still be be sent or are being sent by changing the ip address to 0 -// (an old ip address of the host) - -// all the messages from the abstract hosts for the 'old' address (in fact the -// set of old addresses since it may have started again more than once) -// can arrive in any order since they are equivalent to the host - it ignores then all - -// also the messages for the old and new address will come from different hosts -// (the ones with that ip address) which we model by allowing them to arrive in any order -// i.e. not neccessarily in the order they where sent - -//------------------------------------------------------------- - - -//------------------------------------------------------------- -// VARIABLES -//const int N; // number of abstract hosts -const int K=3; // number of probes to send -const double loss; // probability of message loss - -// PROBABILITIES -const double old; //=N/65024; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -// size of buffers for other hosts -const int B0 = 20; // buffer size for one abstract host -const int B1 = 8; // buffer sizes for all abstract hosts - -//------------------------------------------------------------- -// ENVIRONMENT - models: medium, output buffer of concrete host and all other hosts -module environment - - // buffer of concrete host - b_ip7 : [0..2]; // ip address of message in buffer position 8 - b_ip6 : [0..2]; // ip address of message in buffer position 7 - b_ip5 : [0..2]; // ip address of message in buffer position 6 - b_ip4 : [0..2]; // ip address of message in buffer position 5 - b_ip3 : [0..2]; // ip address of message in buffer position 4 - b_ip2 : [0..2]; // ip address of message in buffer position 3 - b_ip1 : [0..2]; // ip address of message in buffer position 2 - b_ip0 : [0..2]; // ip address of message in buffer position 1 - n : [0..8]; // number of places in the buffer used (from host) - - // messages to be sent from abstract hosts to concrete host - n0 : [0..B0]; // number of messages which do not have the host's current ip address - n1 : [0..B1]; // number of messages which have the host's current ip address - - b : [0..2]; // local state - // 0 - idle - // 1 - sending message from concrete host - // 2 - sending message from abstract host - - z : [0..1]; // clock of environment (needed for the time to send a message) - - ip_mess : [0..2]; // ip in the current message being sent - // 0 - different from concrete host - // 1 - same as the concrete host and in use - // 2 - same as the concrete host and not in use - - // RESET/RECONFIG: when host is about to choose new ip address - // suppose that the host cannot choose the same ip address - // (since happens with very small probability). - // Therefore all messages will have a different ip address, - // i.e. all n1 messages become n0 ones. - // Note this include any message currently being sent (ip is set to zero 0) - [reset] true -> (n1'=0) & (n0'=min(B0,n0+n1)) // abstract buffers - & (ip_mess'=0) // message being set - & (n'=(reset)?0:n) // concrete buffer (remove this update to get NO_RESET model) - & (b_ip7'=0) - & (b_ip6'=0) - & (b_ip5'=0) - & (b_ip4'=0) - & (b_ip3'=0) - & (b_ip2'=0) - & (b_ip1'=0) - & (b_ip0'=0); - // note: prevent anything else from happening when reconfiguration needs to take place - - // time passage (only if no messages to send or sending a message) - [time] l>0 & b=0 & n=0 & n0=0 & n1=0 -> (b'=b); // cannot send a message - [time] l>0 & b>0 & z<1 -> (z'=min(z+1,TIME_MAX_Z)); // sending a message - - // get messages to be sent (so message has same ip address as host) - [send] l>0 & n=0 -> (b_ip0'=ip) & (n'=n+1); - [send] l>0 & n=1 -> (b_ip1'=ip) & (n'=n+1); - [send] l>0 & n=2 -> (b_ip2'=ip) & (n'=n+1); - [send] l>0 & n=3 -> (b_ip3'=ip) & (n'=n+1); - [send] l>0 & n=4 -> (b_ip4'=ip) & (n'=n+1); - [send] l>0 & n=5 -> (b_ip5'=ip) & (n'=n+1); - [send] l>0 & n=6 -> (b_ip6'=ip) & (n'=n+1); - [send] l>0 & n=7 -> (b_ip7'=ip) & (n'=n+1); - [send] l>0 & n=8 -> (n'=n); // buffer full so lose message - - // start sending message from host - [] l>0 & b=0 & n>0 -> (1-loss) : (b'=1) & (ip_mess'=b_ip0) - & (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1) // send message - + loss : (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1); // lose message - - // start sending message to host - [] l>0 & b=0 & n0>0 -> (1-loss) : (b'=2) & (ip_mess'=0) & (n0'=n0-1) + loss : (n0'=n0-1); // different ip - [] l>0 & b=0 & n1>0 -> (1-loss) : (b'=2) & (ip_mess'=1) & (n1'=n1-1) + loss : (n1'=n1-1); // same ip - - // finish sending message from host - [] l>0 & b=1 & ip_mess=0 -> (b'=0) & (z'=0) & (n0'=min(n0+1,B0)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=1 -> (b'=0) & (z'=0) & (n1'=min(n1+1,B1)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - - // finish sending message to host - [rec] l>0 & b=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - -endmodule - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec] (l=1) -> 1: true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send] l=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec] l=2 & ip_mess!=ip -> (l'=l); - // get a message with matching ip: reconfigure - [rec] l=2 & ip_mess=ip -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec] l=3 & mess=0 & ip_mess!=ip -> (l'=l); - - - // send probe reply or message for defence - [send] l=3 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send] l=3 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send] l=3 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> 1 : true; - -endmodule diff --git a/examples/pmdp/zeroconf/zeroconf4.pm b/examples/pmdp/zeroconf/zeroconf4.pm deleted file mode 100644 index ec52b31a2..000000000 --- a/examples/pmdp/zeroconf/zeroconf4.pm +++ /dev/null @@ -1,258 +0,0 @@ -// IPv4: PTA model with digitial clocks -// one concrete host attempting to choose an ip address -// when a number of (abstract) hosts have already got ip addresses -// gxn/dxp/jzs 02/05/03 - -// model is an mdp -mdp - -// reset or noreset model -const bool reset=false; - -//------------------------------------------------------------- - -// we suppose that -// - the abstract hosts have already picked their addresses -// and always defend their addresses -// - the concrete host never picks the same ip address twice -// (this can happen only with a verys small probability) - -// under these assumptions we do not need message types because: -// 1) since messages to the concrete host will never be a probe, -// this host will react to all messages in the same way -// 2) since the abstract hosts always defend their addresses, -// all messages from the host will get an arp reply if the ip matches - -// following from the above assumptions we require only three abstract IP addresses -// (0,1 and 2) which correspond to the following sets of IP addresses: - -// 0 - the IP addresses of the abstract hosts which the concrete host -// previously tried to configure -// 1 - an IP address of an abstract host which the concrete host is -// currently trying to configure -// 2 - a fresh IP address which the concrete host is currently trying to configure - -// if the host picks an address that is being used it may end up picking another ip address -// in which case there may still be messages corresponding to the old ip address -// to be sent both from and to the host which the host should now disregard -// (since it will never pick the same ip address) - -// to deal with this situation: when a host picks a new ip address we reconfigure the -// messages that are still be be sent or are being sent by changing the ip address to 0 -// (an old ip address of the host) - -// all the messages from the abstract hosts for the 'old' address (in fact the -// set of old addresses since it may have started again more than once) -// can arrive in any order since they are equivalent to the host - it ignores then all - -// also the messages for the old and new address will come from different hosts -// (the ones with that ip address) which we model by allowing them to arrive in any order -// i.e. not neccessarily in the order they where sent - -//------------------------------------------------------------- - - -//------------------------------------------------------------- -// VARIABLES -//const int N; // number of abstract hosts -const int K=4; // number of probes to send -const double loss; // probability of message loss - -// PROBABILITIES -const double old; //=N/65024; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -// size of buffers for other hosts -const int B0 = 20; // buffer size for one abstract host -const int B1 = 8; // buffer sizes for all abstract hosts - -//------------------------------------------------------------- -// ENVIRONMENT - models: medium, output buffer of concrete host and all other hosts -module environment - - // buffer of concrete host - b_ip7 : [0..2]; // ip address of message in buffer position 8 - b_ip6 : [0..2]; // ip address of message in buffer position 7 - b_ip5 : [0..2]; // ip address of message in buffer position 6 - b_ip4 : [0..2]; // ip address of message in buffer position 5 - b_ip3 : [0..2]; // ip address of message in buffer position 4 - b_ip2 : [0..2]; // ip address of message in buffer position 3 - b_ip1 : [0..2]; // ip address of message in buffer position 2 - b_ip0 : [0..2]; // ip address of message in buffer position 1 - n : [0..8]; // number of places in the buffer used (from host) - - // messages to be sent from abstract hosts to concrete host - n0 : [0..B0]; // number of messages which do not have the host's current ip address - n1 : [0..B1]; // number of messages which have the host's current ip address - - b : [0..2]; // local state - // 0 - idle - // 1 - sending message from concrete host - // 2 - sending message from abstract host - - z : [0..1]; // clock of environment (needed for the time to send a message) - - ip_mess : [0..2]; // ip in the current message being sent - // 0 - different from concrete host - // 1 - same as the concrete host and in use - // 2 - same as the concrete host and not in use - - // RESET/RECONFIG: when host is about to choose new ip address - // suppose that the host cannot choose the same ip address - // (since happens with very small probability). - // Therefore all messages will have a different ip address, - // i.e. all n1 messages become n0 ones. - // Note this include any message currently being sent (ip is set to zero 0) - [reset] true -> (n1'=0) & (n0'=min(B0,n0+n1)) // abstract buffers - & (ip_mess'=0) // message being set - & (n'=(reset)?0:n) // concrete buffer (remove this update to get NO_RESET model) - & (b_ip7'=0) - & (b_ip6'=0) - & (b_ip5'=0) - & (b_ip4'=0) - & (b_ip3'=0) - & (b_ip2'=0) - & (b_ip1'=0) - & (b_ip0'=0); - // note: prevent anything else from happening when reconfiguration needs to take place - - // time passage (only if no messages to send or sending a message) - [time] l>0 & b=0 & n=0 & n0=0 & n1=0 -> (b'=b); // cannot send a message - [time] l>0 & b>0 & z<1 -> (z'=min(z+1,TIME_MAX_Z)); // sending a message - - // get messages to be sent (so message has same ip address as host) - [send] l>0 & n=0 -> (b_ip0'=ip) & (n'=n+1); - [send] l>0 & n=1 -> (b_ip1'=ip) & (n'=n+1); - [send] l>0 & n=2 -> (b_ip2'=ip) & (n'=n+1); - [send] l>0 & n=3 -> (b_ip3'=ip) & (n'=n+1); - [send] l>0 & n=4 -> (b_ip4'=ip) & (n'=n+1); - [send] l>0 & n=5 -> (b_ip5'=ip) & (n'=n+1); - [send] l>0 & n=6 -> (b_ip6'=ip) & (n'=n+1); - [send] l>0 & n=7 -> (b_ip7'=ip) & (n'=n+1); - [send] l>0 & n=8 -> (n'=n); // buffer full so lose message - - // start sending message from host - [] l>0 & b=0 & n>0 -> (1-loss) : (b'=1) & (ip_mess'=b_ip0) - & (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1) // send message - + loss : (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1); // lose message - - // start sending message to host - [] l>0 & b=0 & n0>0 -> (1-loss) : (b'=2) & (ip_mess'=0) & (n0'=n0-1) + loss : (n0'=n0-1); // different ip - [] l>0 & b=0 & n1>0 -> (1-loss) : (b'=2) & (ip_mess'=1) & (n1'=n1-1) + loss : (n1'=n1-1); // same ip - - // finish sending message from host - [] l>0 & b=1 & ip_mess=0 -> (b'=0) & (z'=0) & (n0'=min(n0+1,B0)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=1 -> (b'=0) & (z'=0) & (n1'=min(n1+1,B1)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - - // finish sending message to host - [rec] l>0 & b=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - -endmodule - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec] (l=1) -> 1: true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send] l=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec] l=2 & ip_mess!=ip -> (l'=l); - // get a message with matching ip: reconfigure - [rec] l=2 & ip_mess=ip -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec] l=3 & mess=0 & ip_mess!=ip -> (l'=l); - - - // send probe reply or message for defence - [send] l=3 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send] l=3 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send] l=3 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> 1 : true; - -endmodule diff --git a/examples/pmdp/zeroconf/zeroconf5.pm b/examples/pmdp/zeroconf/zeroconf5.pm deleted file mode 100644 index e13a42d9f..000000000 --- a/examples/pmdp/zeroconf/zeroconf5.pm +++ /dev/null @@ -1,258 +0,0 @@ -// IPv4: PTA model with digitial clocks -// one concrete host attempting to choose an ip address -// when a number of (abstract) hosts have already got ip addresses -// gxn/dxp/jzs 02/05/03 - -// model is an mdp -mdp - -// reset or noreset model -const bool reset=false; - -//------------------------------------------------------------- - -// we suppose that -// - the abstract hosts have already picked their addresses -// and always defend their addresses -// - the concrete host never picks the same ip address twice -// (this can happen only with a verys small probability) - -// under these assumptions we do not need message types because: -// 1) since messages to the concrete host will never be a probe, -// this host will react to all messages in the same way -// 2) since the abstract hosts always defend their addresses, -// all messages from the host will get an arp reply if the ip matches - -// following from the above assumptions we require only three abstract IP addresses -// (0,1 and 2) which correspond to the following sets of IP addresses: - -// 0 - the IP addresses of the abstract hosts which the concrete host -// previously tried to configure -// 1 - an IP address of an abstract host which the concrete host is -// currently trying to configure -// 2 - a fresh IP address which the concrete host is currently trying to configure - -// if the host picks an address that is being used it may end up picking another ip address -// in which case there may still be messages corresponding to the old ip address -// to be sent both from and to the host which the host should now disregard -// (since it will never pick the same ip address) - -// to deal with this situation: when a host picks a new ip address we reconfigure the -// messages that are still be be sent or are being sent by changing the ip address to 0 -// (an old ip address of the host) - -// all the messages from the abstract hosts for the 'old' address (in fact the -// set of old addresses since it may have started again more than once) -// can arrive in any order since they are equivalent to the host - it ignores then all - -// also the messages for the old and new address will come from different hosts -// (the ones with that ip address) which we model by allowing them to arrive in any order -// i.e. not neccessarily in the order they where sent - -//------------------------------------------------------------- - - -//------------------------------------------------------------- -// VARIABLES -//const int N; // number of abstract hosts -const int K=5; // number of probes to send -const double loss; // probability of message loss - -// PROBABILITIES -const double old; //=N/65024; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -// size of buffers for other hosts -const int B0 = 20; // buffer size for one abstract host -const int B1 = 8; // buffer sizes for all abstract hosts - -//------------------------------------------------------------- -// ENVIRONMENT - models: medium, output buffer of concrete host and all other hosts -module environment - - // buffer of concrete host - b_ip7 : [0..2]; // ip address of message in buffer position 8 - b_ip6 : [0..2]; // ip address of message in buffer position 7 - b_ip5 : [0..2]; // ip address of message in buffer position 6 - b_ip4 : [0..2]; // ip address of message in buffer position 5 - b_ip3 : [0..2]; // ip address of message in buffer position 4 - b_ip2 : [0..2]; // ip address of message in buffer position 3 - b_ip1 : [0..2]; // ip address of message in buffer position 2 - b_ip0 : [0..2]; // ip address of message in buffer position 1 - n : [0..8]; // number of places in the buffer used (from host) - - // messages to be sent from abstract hosts to concrete host - n0 : [0..B0]; // number of messages which do not have the host's current ip address - n1 : [0..B1]; // number of messages which have the host's current ip address - - b : [0..2]; // local state - // 0 - idle - // 1 - sending message from concrete host - // 2 - sending message from abstract host - - z : [0..1]; // clock of environment (needed for the time to send a message) - - ip_mess : [0..2]; // ip in the current message being sent - // 0 - different from concrete host - // 1 - same as the concrete host and in use - // 2 - same as the concrete host and not in use - - // RESET/RECONFIG: when host is about to choose new ip address - // suppose that the host cannot choose the same ip address - // (since happens with very small probability). - // Therefore all messages will have a different ip address, - // i.e. all n1 messages become n0 ones. - // Note this include any message currently being sent (ip is set to zero 0) - [reset] true -> (n1'=0) & (n0'=min(B0,n0+n1)) // abstract buffers - & (ip_mess'=0) // message being set - & (n'=(reset)?0:n) // concrete buffer (remove this update to get NO_RESET model) - & (b_ip7'=0) - & (b_ip6'=0) - & (b_ip5'=0) - & (b_ip4'=0) - & (b_ip3'=0) - & (b_ip2'=0) - & (b_ip1'=0) - & (b_ip0'=0); - // note: prevent anything else from happening when reconfiguration needs to take place - - // time passage (only if no messages to send or sending a message) - [time] l>0 & b=0 & n=0 & n0=0 & n1=0 -> (b'=b); // cannot send a message - [time] l>0 & b>0 & z<1 -> (z'=min(z+1,TIME_MAX_Z)); // sending a message - - // get messages to be sent (so message has same ip address as host) - [send] l>0 & n=0 -> (b_ip0'=ip) & (n'=n+1); - [send] l>0 & n=1 -> (b_ip1'=ip) & (n'=n+1); - [send] l>0 & n=2 -> (b_ip2'=ip) & (n'=n+1); - [send] l>0 & n=3 -> (b_ip3'=ip) & (n'=n+1); - [send] l>0 & n=4 -> (b_ip4'=ip) & (n'=n+1); - [send] l>0 & n=5 -> (b_ip5'=ip) & (n'=n+1); - [send] l>0 & n=6 -> (b_ip6'=ip) & (n'=n+1); - [send] l>0 & n=7 -> (b_ip7'=ip) & (n'=n+1); - [send] l>0 & n=8 -> (n'=n); // buffer full so lose message - - // start sending message from host - [] l>0 & b=0 & n>0 -> (1-loss) : (b'=1) & (ip_mess'=b_ip0) - & (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1) // send message - + loss : (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1); // lose message - - // start sending message to host - [] l>0 & b=0 & n0>0 -> (1-loss) : (b'=2) & (ip_mess'=0) & (n0'=n0-1) + loss : (n0'=n0-1); // different ip - [] l>0 & b=0 & n1>0 -> (1-loss) : (b'=2) & (ip_mess'=1) & (n1'=n1-1) + loss : (n1'=n1-1); // same ip - - // finish sending message from host - [] l>0 & b=1 & ip_mess=0 -> (b'=0) & (z'=0) & (n0'=min(n0+1,B0)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=1 -> (b'=0) & (z'=0) & (n1'=min(n1+1,B1)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - - // finish sending message to host - [rec] l>0 & b=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - -endmodule - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec] (l=1) -> 1: true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send] l=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec] l=2 & ip_mess!=ip -> (l'=l); - // get a message with matching ip: reconfigure - [rec] l=2 & ip_mess=ip -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec] l=3 & mess=0 & ip_mess!=ip -> (l'=l); - - - // send probe reply or message for defence - [send] l=3 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send] l=3 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send] l=3 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> 1 : true; - -endmodule diff --git a/examples/pmdp/zeroconf/zeroconf6.pm b/examples/pmdp/zeroconf/zeroconf6.pm deleted file mode 100644 index cee65ee94..000000000 --- a/examples/pmdp/zeroconf/zeroconf6.pm +++ /dev/null @@ -1,258 +0,0 @@ -// IPv4: PTA model with digitial clocks -// one concrete host attempting to choose an ip address -// when a number of (abstract) hosts have already got ip addresses -// gxn/dxp/jzs 02/05/03 - -// model is an mdp -mdp - -// reset or noreset model -const bool reset=false; - -//------------------------------------------------------------- - -// we suppose that -// - the abstract hosts have already picked their addresses -// and always defend their addresses -// - the concrete host never picks the same ip address twice -// (this can happen only with a verys small probability) - -// under these assumptions we do not need message types because: -// 1) since messages to the concrete host will never be a probe, -// this host will react to all messages in the same way -// 2) since the abstract hosts always defend their addresses, -// all messages from the host will get an arp reply if the ip matches - -// following from the above assumptions we require only three abstract IP addresses -// (0,1 and 2) which correspond to the following sets of IP addresses: - -// 0 - the IP addresses of the abstract hosts which the concrete host -// previously tried to configure -// 1 - an IP address of an abstract host which the concrete host is -// currently trying to configure -// 2 - a fresh IP address which the concrete host is currently trying to configure - -// if the host picks an address that is being used it may end up picking another ip address -// in which case there may still be messages corresponding to the old ip address -// to be sent both from and to the host which the host should now disregard -// (since it will never pick the same ip address) - -// to deal with this situation: when a host picks a new ip address we reconfigure the -// messages that are still be be sent or are being sent by changing the ip address to 0 -// (an old ip address of the host) - -// all the messages from the abstract hosts for the 'old' address (in fact the -// set of old addresses since it may have started again more than once) -// can arrive in any order since they are equivalent to the host - it ignores then all - -// also the messages for the old and new address will come from different hosts -// (the ones with that ip address) which we model by allowing them to arrive in any order -// i.e. not neccessarily in the order they where sent - -//------------------------------------------------------------- - - -//------------------------------------------------------------- -// VARIABLES -//const int N; // number of abstract hosts -const int K=6; // number of probes to send -const double loss; // probability of message loss - -// PROBABILITIES -const double old; //=N/65024; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -// size of buffers for other hosts -const int B0 = 20; // buffer size for one abstract host -const int B1 = 8; // buffer sizes for all abstract hosts - -//------------------------------------------------------------- -// ENVIRONMENT - models: medium, output buffer of concrete host and all other hosts -module environment - - // buffer of concrete host - b_ip7 : [0..2]; // ip address of message in buffer position 8 - b_ip6 : [0..2]; // ip address of message in buffer position 7 - b_ip5 : [0..2]; // ip address of message in buffer position 6 - b_ip4 : [0..2]; // ip address of message in buffer position 5 - b_ip3 : [0..2]; // ip address of message in buffer position 4 - b_ip2 : [0..2]; // ip address of message in buffer position 3 - b_ip1 : [0..2]; // ip address of message in buffer position 2 - b_ip0 : [0..2]; // ip address of message in buffer position 1 - n : [0..8]; // number of places in the buffer used (from host) - - // messages to be sent from abstract hosts to concrete host - n0 : [0..B0]; // number of messages which do not have the host's current ip address - n1 : [0..B1]; // number of messages which have the host's current ip address - - b : [0..2]; // local state - // 0 - idle - // 1 - sending message from concrete host - // 2 - sending message from abstract host - - z : [0..1]; // clock of environment (needed for the time to send a message) - - ip_mess : [0..2]; // ip in the current message being sent - // 0 - different from concrete host - // 1 - same as the concrete host and in use - // 2 - same as the concrete host and not in use - - // RESET/RECONFIG: when host is about to choose new ip address - // suppose that the host cannot choose the same ip address - // (since happens with very small probability). - // Therefore all messages will have a different ip address, - // i.e. all n1 messages become n0 ones. - // Note this include any message currently being sent (ip is set to zero 0) - [reset] true -> (n1'=0) & (n0'=min(B0,n0+n1)) // abstract buffers - & (ip_mess'=0) // message being set - & (n'=(reset)?0:n) // concrete buffer (remove this update to get NO_RESET model) - & (b_ip7'=0) - & (b_ip6'=0) - & (b_ip5'=0) - & (b_ip4'=0) - & (b_ip3'=0) - & (b_ip2'=0) - & (b_ip1'=0) - & (b_ip0'=0); - // note: prevent anything else from happening when reconfiguration needs to take place - - // time passage (only if no messages to send or sending a message) - [time] l>0 & b=0 & n=0 & n0=0 & n1=0 -> (b'=b); // cannot send a message - [time] l>0 & b>0 & z<1 -> (z'=min(z+1,TIME_MAX_Z)); // sending a message - - // get messages to be sent (so message has same ip address as host) - [send] l>0 & n=0 -> (b_ip0'=ip) & (n'=n+1); - [send] l>0 & n=1 -> (b_ip1'=ip) & (n'=n+1); - [send] l>0 & n=2 -> (b_ip2'=ip) & (n'=n+1); - [send] l>0 & n=3 -> (b_ip3'=ip) & (n'=n+1); - [send] l>0 & n=4 -> (b_ip4'=ip) & (n'=n+1); - [send] l>0 & n=5 -> (b_ip5'=ip) & (n'=n+1); - [send] l>0 & n=6 -> (b_ip6'=ip) & (n'=n+1); - [send] l>0 & n=7 -> (b_ip7'=ip) & (n'=n+1); - [send] l>0 & n=8 -> (n'=n); // buffer full so lose message - - // start sending message from host - [] l>0 & b=0 & n>0 -> (1-loss) : (b'=1) & (ip_mess'=b_ip0) - & (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1) // send message - + loss : (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1); // lose message - - // start sending message to host - [] l>0 & b=0 & n0>0 -> (1-loss) : (b'=2) & (ip_mess'=0) & (n0'=n0-1) + loss : (n0'=n0-1); // different ip - [] l>0 & b=0 & n1>0 -> (1-loss) : (b'=2) & (ip_mess'=1) & (n1'=n1-1) + loss : (n1'=n1-1); // same ip - - // finish sending message from host - [] l>0 & b=1 & ip_mess=0 -> (b'=0) & (z'=0) & (n0'=min(n0+1,B0)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=1 -> (b'=0) & (z'=0) & (n1'=min(n1+1,B1)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - - // finish sending message to host - [rec] l>0 & b=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - -endmodule - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec] (l=1) -> 1: true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send] l=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec] l=2 & ip_mess!=ip -> (l'=l); - // get a message with matching ip: reconfigure - [rec] l=2 & ip_mess=ip -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec] l=3 & mess=0 & ip_mess!=ip -> (l'=l); - - - // send probe reply or message for defence - [send] l=3 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send] l=3 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send] l=3 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> 1 : true; - -endmodule diff --git a/examples/pmdp/zeroconf/zeroconf7.pm b/examples/pmdp/zeroconf/zeroconf7.pm deleted file mode 100644 index 445882db8..000000000 --- a/examples/pmdp/zeroconf/zeroconf7.pm +++ /dev/null @@ -1,258 +0,0 @@ -// IPv4: PTA model with digitial clocks -// one concrete host attempting to choose an ip address -// when a number of (abstract) hosts have already got ip addresses -// gxn/dxp/jzs 02/05/03 - -// model is an mdp -mdp - -// reset or noreset model -const bool reset=false; - -//------------------------------------------------------------- - -// we suppose that -// - the abstract hosts have already picked their addresses -// and always defend their addresses -// - the concrete host never picks the same ip address twice -// (this can happen only with a verys small probability) - -// under these assumptions we do not need message types because: -// 1) since messages to the concrete host will never be a probe, -// this host will react to all messages in the same way -// 2) since the abstract hosts always defend their addresses, -// all messages from the host will get an arp reply if the ip matches - -// following from the above assumptions we require only three abstract IP addresses -// (0,1 and 2) which correspond to the following sets of IP addresses: - -// 0 - the IP addresses of the abstract hosts which the concrete host -// previously tried to configure -// 1 - an IP address of an abstract host which the concrete host is -// currently trying to configure -// 2 - a fresh IP address which the concrete host is currently trying to configure - -// if the host picks an address that is being used it may end up picking another ip address -// in which case there may still be messages corresponding to the old ip address -// to be sent both from and to the host which the host should now disregard -// (since it will never pick the same ip address) - -// to deal with this situation: when a host picks a new ip address we reconfigure the -// messages that are still be be sent or are being sent by changing the ip address to 0 -// (an old ip address of the host) - -// all the messages from the abstract hosts for the 'old' address (in fact the -// set of old addresses since it may have started again more than once) -// can arrive in any order since they are equivalent to the host - it ignores then all - -// also the messages for the old and new address will come from different hosts -// (the ones with that ip address) which we model by allowing them to arrive in any order -// i.e. not neccessarily in the order they where sent - -//------------------------------------------------------------- - - -//------------------------------------------------------------- -// VARIABLES -//const int N; // number of abstract hosts -const int K=7; // number of probes to send -const double loss; // probability of message loss - -// PROBABILITIES -const double old; //=N/65024; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -// size of buffers for other hosts -const int B0 = 20; // buffer size for one abstract host -const int B1 = 8; // buffer sizes for all abstract hosts - -//------------------------------------------------------------- -// ENVIRONMENT - models: medium, output buffer of concrete host and all other hosts -module environment - - // buffer of concrete host - b_ip7 : [0..2]; // ip address of message in buffer position 8 - b_ip6 : [0..2]; // ip address of message in buffer position 7 - b_ip5 : [0..2]; // ip address of message in buffer position 6 - b_ip4 : [0..2]; // ip address of message in buffer position 5 - b_ip3 : [0..2]; // ip address of message in buffer position 4 - b_ip2 : [0..2]; // ip address of message in buffer position 3 - b_ip1 : [0..2]; // ip address of message in buffer position 2 - b_ip0 : [0..2]; // ip address of message in buffer position 1 - n : [0..8]; // number of places in the buffer used (from host) - - // messages to be sent from abstract hosts to concrete host - n0 : [0..B0]; // number of messages which do not have the host's current ip address - n1 : [0..B1]; // number of messages which have the host's current ip address - - b : [0..2]; // local state - // 0 - idle - // 1 - sending message from concrete host - // 2 - sending message from abstract host - - z : [0..1]; // clock of environment (needed for the time to send a message) - - ip_mess : [0..2]; // ip in the current message being sent - // 0 - different from concrete host - // 1 - same as the concrete host and in use - // 2 - same as the concrete host and not in use - - // RESET/RECONFIG: when host is about to choose new ip address - // suppose that the host cannot choose the same ip address - // (since happens with very small probability). - // Therefore all messages will have a different ip address, - // i.e. all n1 messages become n0 ones. - // Note this include any message currently being sent (ip is set to zero 0) - [reset] true -> (n1'=0) & (n0'=min(B0,n0+n1)) // abstract buffers - & (ip_mess'=0) // message being set - & (n'=(reset)?0:n) // concrete buffer (remove this update to get NO_RESET model) - & (b_ip7'=0) - & (b_ip6'=0) - & (b_ip5'=0) - & (b_ip4'=0) - & (b_ip3'=0) - & (b_ip2'=0) - & (b_ip1'=0) - & (b_ip0'=0); - // note: prevent anything else from happening when reconfiguration needs to take place - - // time passage (only if no messages to send or sending a message) - [time] l>0 & b=0 & n=0 & n0=0 & n1=0 -> (b'=b); // cannot send a message - [time] l>0 & b>0 & z<1 -> (z'=min(z+1,TIME_MAX_Z)); // sending a message - - // get messages to be sent (so message has same ip address as host) - [send] l>0 & n=0 -> (b_ip0'=ip) & (n'=n+1); - [send] l>0 & n=1 -> (b_ip1'=ip) & (n'=n+1); - [send] l>0 & n=2 -> (b_ip2'=ip) & (n'=n+1); - [send] l>0 & n=3 -> (b_ip3'=ip) & (n'=n+1); - [send] l>0 & n=4 -> (b_ip4'=ip) & (n'=n+1); - [send] l>0 & n=5 -> (b_ip5'=ip) & (n'=n+1); - [send] l>0 & n=6 -> (b_ip6'=ip) & (n'=n+1); - [send] l>0 & n=7 -> (b_ip7'=ip) & (n'=n+1); - [send] l>0 & n=8 -> (n'=n); // buffer full so lose message - - // start sending message from host - [] l>0 & b=0 & n>0 -> (1-loss) : (b'=1) & (ip_mess'=b_ip0) - & (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1) // send message - + loss : (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1); // lose message - - // start sending message to host - [] l>0 & b=0 & n0>0 -> (1-loss) : (b'=2) & (ip_mess'=0) & (n0'=n0-1) + loss : (n0'=n0-1); // different ip - [] l>0 & b=0 & n1>0 -> (1-loss) : (b'=2) & (ip_mess'=1) & (n1'=n1-1) + loss : (n1'=n1-1); // same ip - - // finish sending message from host - [] l>0 & b=1 & ip_mess=0 -> (b'=0) & (z'=0) & (n0'=min(n0+1,B0)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=1 -> (b'=0) & (z'=0) & (n1'=min(n1+1,B1)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - - // finish sending message to host - [rec] l>0 & b=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - -endmodule - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec] (l=1) -> 1: true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send] l=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec] l=2 & ip_mess!=ip -> (l'=l); - // get a message with matching ip: reconfigure - [rec] l=2 & ip_mess=ip -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec] l=3 & mess=0 & ip_mess!=ip -> (l'=l); - - - // send probe reply or message for defence - [send] l=3 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send] l=3 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send] l=3 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> 1 : true; - -endmodule diff --git a/examples/pmdp/zeroconf/zeroconf8.pm b/examples/pmdp/zeroconf/zeroconf8.pm deleted file mode 100644 index f79b991cf..000000000 --- a/examples/pmdp/zeroconf/zeroconf8.pm +++ /dev/null @@ -1,258 +0,0 @@ -// IPv4: PTA model with digitial clocks -// one concrete host attempting to choose an ip address -// when a number of (abstract) hosts have already got ip addresses -// gxn/dxp/jzs 02/05/03 - -// model is an mdp -mdp - -// reset or noreset model -const bool reset=false; - -//------------------------------------------------------------- - -// we suppose that -// - the abstract hosts have already picked their addresses -// and always defend their addresses -// - the concrete host never picks the same ip address twice -// (this can happen only with a verys small probability) - -// under these assumptions we do not need message types because: -// 1) since messages to the concrete host will never be a probe, -// this host will react to all messages in the same way -// 2) since the abstract hosts always defend their addresses, -// all messages from the host will get an arp reply if the ip matches - -// following from the above assumptions we require only three abstract IP addresses -// (0,1 and 2) which correspond to the following sets of IP addresses: - -// 0 - the IP addresses of the abstract hosts which the concrete host -// previously tried to configure -// 1 - an IP address of an abstract host which the concrete host is -// currently trying to configure -// 2 - a fresh IP address which the concrete host is currently trying to configure - -// if the host picks an address that is being used it may end up picking another ip address -// in which case there may still be messages corresponding to the old ip address -// to be sent both from and to the host which the host should now disregard -// (since it will never pick the same ip address) - -// to deal with this situation: when a host picks a new ip address we reconfigure the -// messages that are still be be sent or are being sent by changing the ip address to 0 -// (an old ip address of the host) - -// all the messages from the abstract hosts for the 'old' address (in fact the -// set of old addresses since it may have started again more than once) -// can arrive in any order since they are equivalent to the host - it ignores then all - -// also the messages for the old and new address will come from different hosts -// (the ones with that ip address) which we model by allowing them to arrive in any order -// i.e. not neccessarily in the order they where sent - -//------------------------------------------------------------- - - -//------------------------------------------------------------- -// VARIABLES -//const int N; // number of abstract hosts -const int K=8; // number of probes to send -const double loss; // probability of message loss - -// PROBABILITIES -const double old; //=N/65024; // probability pick an ip address being used -const double new = (1-old); // probability pick a new ip address - -// TIMING CONSTANTS -const int CONSEC = 2; // time interval between sending consecutive probles -const int TRANSTIME = 1; // upper bound on transmission time delay -const int LONGWAIT = 60; // minimum time delay after a high number of address collisions -const int DEFEND = 10; - -const int TIME_MAX_X = 60; // max value of clock x -const int TIME_MAX_Y = 10; // max value of clock y -const int TIME_MAX_Z = 1; // max value of clock z - -// OTHER CONSTANTS -const int MAXCOLL = 10; // maximum number of collisions before long wait -// size of buffers for other hosts -const int B0 = 20; // buffer size for one abstract host -const int B1 = 8; // buffer sizes for all abstract hosts - -//------------------------------------------------------------- -// ENVIRONMENT - models: medium, output buffer of concrete host and all other hosts -module environment - - // buffer of concrete host - b_ip7 : [0..2]; // ip address of message in buffer position 8 - b_ip6 : [0..2]; // ip address of message in buffer position 7 - b_ip5 : [0..2]; // ip address of message in buffer position 6 - b_ip4 : [0..2]; // ip address of message in buffer position 5 - b_ip3 : [0..2]; // ip address of message in buffer position 4 - b_ip2 : [0..2]; // ip address of message in buffer position 3 - b_ip1 : [0..2]; // ip address of message in buffer position 2 - b_ip0 : [0..2]; // ip address of message in buffer position 1 - n : [0..8]; // number of places in the buffer used (from host) - - // messages to be sent from abstract hosts to concrete host - n0 : [0..B0]; // number of messages which do not have the host's current ip address - n1 : [0..B1]; // number of messages which have the host's current ip address - - b : [0..2]; // local state - // 0 - idle - // 1 - sending message from concrete host - // 2 - sending message from abstract host - - z : [0..1]; // clock of environment (needed for the time to send a message) - - ip_mess : [0..2]; // ip in the current message being sent - // 0 - different from concrete host - // 1 - same as the concrete host and in use - // 2 - same as the concrete host and not in use - - // RESET/RECONFIG: when host is about to choose new ip address - // suppose that the host cannot choose the same ip address - // (since happens with very small probability). - // Therefore all messages will have a different ip address, - // i.e. all n1 messages become n0 ones. - // Note this include any message currently being sent (ip is set to zero 0) - [reset] true -> (n1'=0) & (n0'=min(B0,n0+n1)) // abstract buffers - & (ip_mess'=0) // message being set - & (n'=(reset)?0:n) // concrete buffer (remove this update to get NO_RESET model) - & (b_ip7'=0) - & (b_ip6'=0) - & (b_ip5'=0) - & (b_ip4'=0) - & (b_ip3'=0) - & (b_ip2'=0) - & (b_ip1'=0) - & (b_ip0'=0); - // note: prevent anything else from happening when reconfiguration needs to take place - - // time passage (only if no messages to send or sending a message) - [time] l>0 & b=0 & n=0 & n0=0 & n1=0 -> (b'=b); // cannot send a message - [time] l>0 & b>0 & z<1 -> (z'=min(z+1,TIME_MAX_Z)); // sending a message - - // get messages to be sent (so message has same ip address as host) - [send] l>0 & n=0 -> (b_ip0'=ip) & (n'=n+1); - [send] l>0 & n=1 -> (b_ip1'=ip) & (n'=n+1); - [send] l>0 & n=2 -> (b_ip2'=ip) & (n'=n+1); - [send] l>0 & n=3 -> (b_ip3'=ip) & (n'=n+1); - [send] l>0 & n=4 -> (b_ip4'=ip) & (n'=n+1); - [send] l>0 & n=5 -> (b_ip5'=ip) & (n'=n+1); - [send] l>0 & n=6 -> (b_ip6'=ip) & (n'=n+1); - [send] l>0 & n=7 -> (b_ip7'=ip) & (n'=n+1); - [send] l>0 & n=8 -> (n'=n); // buffer full so lose message - - // start sending message from host - [] l>0 & b=0 & n>0 -> (1-loss) : (b'=1) & (ip_mess'=b_ip0) - & (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1) // send message - + loss : (n'=n-1) - & (b_ip7'=0) - & (b_ip6'=b_ip7) - & (b_ip5'=b_ip6) - & (b_ip4'=b_ip5) - & (b_ip3'=b_ip4) - & (b_ip2'=b_ip3) - & (b_ip1'=b_ip2) - & (b_ip0'=b_ip1); // lose message - - // start sending message to host - [] l>0 & b=0 & n0>0 -> (1-loss) : (b'=2) & (ip_mess'=0) & (n0'=n0-1) + loss : (n0'=n0-1); // different ip - [] l>0 & b=0 & n1>0 -> (1-loss) : (b'=2) & (ip_mess'=1) & (n1'=n1-1) + loss : (n1'=n1-1); // same ip - - // finish sending message from host - [] l>0 & b=1 & ip_mess=0 -> (b'=0) & (z'=0) & (n0'=min(n0+1,B0)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=1 -> (b'=0) & (z'=0) & (n1'=min(n1+1,B1)) & (ip_mess'=0); - [] l>0 & b=1 & ip_mess=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - - // finish sending message to host - [rec] l>0 & b=2 -> (b'=0) & (z'=0) & (ip_mess'=0); - -endmodule - -//------------------------------------------------------------- -// CONCRETE HOST -module host0 - - x : [0..TIME_MAX_X]; // first clock of the host - y : [0..TIME_MAX_Y]; // second clock of the host - - coll : [0..MAXCOLL]; // number of address collisions - probes : [0..K]; // counter (number of probes sent) - mess : [0..1]; // need to send a message or not - defend : [0..1]; // defend (if =1, try to defend IP address) - - ip : [1..2]; // ip address (1 - in use & 2 - fresh) - - l : [0..4] init 1; // location - // 0 : RECONFIGURE - // 1 : RANDOM - // 2 : WAITSP - // 3 : WAITSG - // 4 : USE - - // RECONFIGURE - [reset] l=0 -> (l'=1); - - // RANDOM (choose IP address) - [rec] (l=1) -> 1: true; // get message (ignore since have no ip address) - // small number of collisions (choose straight away) - [] l=1 & coll 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - // large number of collisions: (wait for LONGWAIT) - [time] l=1 & coll=MAXCOLL & x (x'=min(x+1,TIME_MAX_X)); - [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0) - + 1/3*old : (l'=2) & (ip'=1) & (x'=1) - + 1/3*old : (l'=2) & (ip'=1) & (x'=2) - + 1/3*new : (l'=2) & (ip'=2) & (x'=0) - + 1/3*new : (l'=2) & (ip'=2) & (x'=1) - + 1/3*new : (l'=2) & (ip'=2) & (x'=2); - - // WAITSP - // let time pass - [time] l=2 & x<2 -> (x'=min(x+1,2)); - // send probe - [send] l=2 & x=2 & probes (x'=0) & (probes'=probes+1); - // sent K probes and waited 2 seconds - [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0); - // get message and ip does not match: ignore - [rec] l=2 & ip_mess!=ip -> (l'=l); - // get a message with matching ip: reconfigure - [rec] l=2 & ip_mess=ip -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0); - - // WAITSG (sends two gratuitious arp probes) - // time passage - [time] l=3 & mess=0 & defend=0 & x (x'=min(x+1,TIME_MAX_X)); - [time] l=3 & mess=0 & defend=1 & x (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND)); - - // receive message and same ip: defend - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0); - // receive message and same ip: defer - [rec] l=3 & mess=0 & ip_mess=ip & (defend=0 | y (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0); - // receive message and different ip - [rec] l=3 & mess=0 & ip_mess!=ip -> (l'=l); - - - // send probe reply or message for defence - [send] l=3 & mess=1 -> (mess'=0); - // send first gratuitous arp message - [send] l=3 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1); - // send second gratuitous arp message (move to use) - [send] l=3 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0); - - // USE (only interested in reaching this state so do not need to add anything here) - [] l=4 -> 1 : true; - -endmodule diff --git a/examples/pmdp/zeroconf/zeroconf_regions.txt b/examples/pmdp/zeroconf/zeroconf_regions.txt deleted file mode 100644 index 1cdf24689..000000000 --- a/examples/pmdp/zeroconf/zeroconf_regions.txt +++ /dev/null @@ -1,625 +0,0 @@ -0.000010<=loss<=0.040000, 0.000010<=old<=0.040000; -0.000010<=loss<=0.040000, 0.040000<=old<=0.080000; -0.000010<=loss<=0.040000, 0.080000<=old<=0.120000; -0.000010<=loss<=0.040000, 0.120000<=old<=0.160000; -0.000010<=loss<=0.040000, 0.160000<=old<=0.200000; -0.000010<=loss<=0.040000, 0.200000<=old<=0.240000; -0.000010<=loss<=0.040000, 0.240000<=old<=0.280000; -0.000010<=loss<=0.040000, 0.280000<=old<=0.320000; -0.000010<=loss<=0.040000, 0.320000<=old<=0.360000; -0.000010<=loss<=0.040000, 0.360000<=old<=0.400000; -0.000010<=loss<=0.040000, 0.400000<=old<=0.440000; -0.000010<=loss<=0.040000, 0.440000<=old<=0.480000; -0.000010<=loss<=0.040000, 0.480000<=old<=0.520000; -0.000010<=loss<=0.040000, 0.520000<=old<=0.560000; -0.000010<=loss<=0.040000, 0.560000<=old<=0.600000; -0.000010<=loss<=0.040000, 0.600000<=old<=0.640000; -0.000010<=loss<=0.040000, 0.640000<=old<=0.680000; -0.000010<=loss<=0.040000, 0.680000<=old<=0.720000; -0.000010<=loss<=0.040000, 0.720000<=old<=0.760000; -0.000010<=loss<=0.040000, 0.760000<=old<=0.800000; -0.000010<=loss<=0.040000, 0.800000<=old<=0.840000; -0.000010<=loss<=0.040000, 0.840000<=old<=0.880000; -0.000010<=loss<=0.040000, 0.880000<=old<=0.920000; -0.000010<=loss<=0.040000, 0.920000<=old<=0.960000; -0.000010<=loss<=0.040000, 0.960000<=old<=0.999990; -0.040000<=loss<=0.080000, 0.000010<=old<=0.040000; -0.040000<=loss<=0.080000, 0.040000<=old<=0.080000; -0.040000<=loss<=0.080000, 0.080000<=old<=0.120000; -0.040000<=loss<=0.080000, 0.120000<=old<=0.160000; -0.040000<=loss<=0.080000, 0.160000<=old<=0.200000; -0.040000<=loss<=0.080000, 0.200000<=old<=0.240000; -0.040000<=loss<=0.080000, 0.240000<=old<=0.280000; -0.040000<=loss<=0.080000, 0.280000<=old<=0.320000; -0.040000<=loss<=0.080000, 0.320000<=old<=0.360000; -0.040000<=loss<=0.080000, 0.360000<=old<=0.400000; -0.040000<=loss<=0.080000, 0.400000<=old<=0.440000; -0.040000<=loss<=0.080000, 0.440000<=old<=0.480000; -0.040000<=loss<=0.080000, 0.480000<=old<=0.520000; -0.040000<=loss<=0.080000, 0.520000<=old<=0.560000; -0.040000<=loss<=0.080000, 0.560000<=old<=0.600000; -0.040000<=loss<=0.080000, 0.600000<=old<=0.640000; -0.040000<=loss<=0.080000, 0.640000<=old<=0.680000; -0.040000<=loss<=0.080000, 0.680000<=old<=0.720000; -0.040000<=loss<=0.080000, 0.720000<=old<=0.760000; -0.040000<=loss<=0.080000, 0.760000<=old<=0.800000; -0.040000<=loss<=0.080000, 0.800000<=old<=0.840000; -0.040000<=loss<=0.080000, 0.840000<=old<=0.880000; -0.040000<=loss<=0.080000, 0.880000<=old<=0.920000; -0.040000<=loss<=0.080000, 0.920000<=old<=0.960000; -0.040000<=loss<=0.080000, 0.960000<=old<=0.999990; -0.080000<=loss<=0.120000, 0.000010<=old<=0.040000; -0.080000<=loss<=0.120000, 0.040000<=old<=0.080000; -0.080000<=loss<=0.120000, 0.080000<=old<=0.120000; -0.080000<=loss<=0.120000, 0.120000<=old<=0.160000; -0.080000<=loss<=0.120000, 0.160000<=old<=0.200000; -0.080000<=loss<=0.120000, 0.200000<=old<=0.240000; -0.080000<=loss<=0.120000, 0.240000<=old<=0.280000; -0.080000<=loss<=0.120000, 0.280000<=old<=0.320000; -0.080000<=loss<=0.120000, 0.320000<=old<=0.360000; -0.080000<=loss<=0.120000, 0.360000<=old<=0.400000; -0.080000<=loss<=0.120000, 0.400000<=old<=0.440000; -0.080000<=loss<=0.120000, 0.440000<=old<=0.480000; -0.080000<=loss<=0.120000, 0.480000<=old<=0.520000; -0.080000<=loss<=0.120000, 0.520000<=old<=0.560000; -0.080000<=loss<=0.120000, 0.560000<=old<=0.600000; -0.080000<=loss<=0.120000, 0.600000<=old<=0.640000; -0.080000<=loss<=0.120000, 0.640000<=old<=0.680000; -0.080000<=loss<=0.120000, 0.680000<=old<=0.720000; -0.080000<=loss<=0.120000, 0.720000<=old<=0.760000; -0.080000<=loss<=0.120000, 0.760000<=old<=0.800000; -0.080000<=loss<=0.120000, 0.800000<=old<=0.840000; -0.080000<=loss<=0.120000, 0.840000<=old<=0.880000; -0.080000<=loss<=0.120000, 0.880000<=old<=0.920000; -0.080000<=loss<=0.120000, 0.920000<=old<=0.960000; -0.080000<=loss<=0.120000, 0.960000<=old<=0.999990; -0.120000<=loss<=0.160000, 0.000010<=old<=0.040000; -0.120000<=loss<=0.160000, 0.040000<=old<=0.080000; -0.120000<=loss<=0.160000, 0.080000<=old<=0.120000; -0.120000<=loss<=0.160000, 0.120000<=old<=0.160000; -0.120000<=loss<=0.160000, 0.160000<=old<=0.200000; -0.120000<=loss<=0.160000, 0.200000<=old<=0.240000; -0.120000<=loss<=0.160000, 0.240000<=old<=0.280000; -0.120000<=loss<=0.160000, 0.280000<=old<=0.320000; -0.120000<=loss<=0.160000, 0.320000<=old<=0.360000; -0.120000<=loss<=0.160000, 0.360000<=old<=0.400000; -0.120000<=loss<=0.160000, 0.400000<=old<=0.440000; -0.120000<=loss<=0.160000, 0.440000<=old<=0.480000; -0.120000<=loss<=0.160000, 0.480000<=old<=0.520000; -0.120000<=loss<=0.160000, 0.520000<=old<=0.560000; -0.120000<=loss<=0.160000, 0.560000<=old<=0.600000; -0.120000<=loss<=0.160000, 0.600000<=old<=0.640000; -0.120000<=loss<=0.160000, 0.640000<=old<=0.680000; -0.120000<=loss<=0.160000, 0.680000<=old<=0.720000; -0.120000<=loss<=0.160000, 0.720000<=old<=0.760000; -0.120000<=loss<=0.160000, 0.760000<=old<=0.800000; -0.120000<=loss<=0.160000, 0.800000<=old<=0.840000; -0.120000<=loss<=0.160000, 0.840000<=old<=0.880000; -0.120000<=loss<=0.160000, 0.880000<=old<=0.920000; -0.120000<=loss<=0.160000, 0.920000<=old<=0.960000; -0.120000<=loss<=0.160000, 0.960000<=old<=0.999990; -0.160000<=loss<=0.200000, 0.000010<=old<=0.040000; -0.160000<=loss<=0.200000, 0.040000<=old<=0.080000; -0.160000<=loss<=0.200000, 0.080000<=old<=0.120000; -0.160000<=loss<=0.200000, 0.120000<=old<=0.160000; -0.160000<=loss<=0.200000, 0.160000<=old<=0.200000; -0.160000<=loss<=0.200000, 0.200000<=old<=0.240000; -0.160000<=loss<=0.200000, 0.240000<=old<=0.280000; -0.160000<=loss<=0.200000, 0.280000<=old<=0.320000; -0.160000<=loss<=0.200000, 0.320000<=old<=0.360000; -0.160000<=loss<=0.200000, 0.360000<=old<=0.400000; -0.160000<=loss<=0.200000, 0.400000<=old<=0.440000; -0.160000<=loss<=0.200000, 0.440000<=old<=0.480000; -0.160000<=loss<=0.200000, 0.480000<=old<=0.520000; -0.160000<=loss<=0.200000, 0.520000<=old<=0.560000; -0.160000<=loss<=0.200000, 0.560000<=old<=0.600000; -0.160000<=loss<=0.200000, 0.600000<=old<=0.640000; -0.160000<=loss<=0.200000, 0.640000<=old<=0.680000; -0.160000<=loss<=0.200000, 0.680000<=old<=0.720000; -0.160000<=loss<=0.200000, 0.720000<=old<=0.760000; -0.160000<=loss<=0.200000, 0.760000<=old<=0.800000; -0.160000<=loss<=0.200000, 0.800000<=old<=0.840000; -0.160000<=loss<=0.200000, 0.840000<=old<=0.880000; -0.160000<=loss<=0.200000, 0.880000<=old<=0.920000; -0.160000<=loss<=0.200000, 0.920000<=old<=0.960000; -0.160000<=loss<=0.200000, 0.960000<=old<=0.999990; -0.200000<=loss<=0.240000, 0.000010<=old<=0.040000; -0.200000<=loss<=0.240000, 0.040000<=old<=0.080000; -0.200000<=loss<=0.240000, 0.080000<=old<=0.120000; -0.200000<=loss<=0.240000, 0.120000<=old<=0.160000; -0.200000<=loss<=0.240000, 0.160000<=old<=0.200000; -0.200000<=loss<=0.240000, 0.200000<=old<=0.240000; -0.200000<=loss<=0.240000, 0.240000<=old<=0.280000; -0.200000<=loss<=0.240000, 0.280000<=old<=0.320000; -0.200000<=loss<=0.240000, 0.320000<=old<=0.360000; -0.200000<=loss<=0.240000, 0.360000<=old<=0.400000; -0.200000<=loss<=0.240000, 0.400000<=old<=0.440000; -0.200000<=loss<=0.240000, 0.440000<=old<=0.480000; -0.200000<=loss<=0.240000, 0.480000<=old<=0.520000; -0.200000<=loss<=0.240000, 0.520000<=old<=0.560000; -0.200000<=loss<=0.240000, 0.560000<=old<=0.600000; -0.200000<=loss<=0.240000, 0.600000<=old<=0.640000; -0.200000<=loss<=0.240000, 0.640000<=old<=0.680000; -0.200000<=loss<=0.240000, 0.680000<=old<=0.720000; -0.200000<=loss<=0.240000, 0.720000<=old<=0.760000; -0.200000<=loss<=0.240000, 0.760000<=old<=0.800000; -0.200000<=loss<=0.240000, 0.800000<=old<=0.840000; -0.200000<=loss<=0.240000, 0.840000<=old<=0.880000; -0.200000<=loss<=0.240000, 0.880000<=old<=0.920000; -0.200000<=loss<=0.240000, 0.920000<=old<=0.960000; -0.200000<=loss<=0.240000, 0.960000<=old<=0.999990; -0.240000<=loss<=0.280000, 0.000010<=old<=0.040000; -0.240000<=loss<=0.280000, 0.040000<=old<=0.080000; -0.240000<=loss<=0.280000, 0.080000<=old<=0.120000; -0.240000<=loss<=0.280000, 0.120000<=old<=0.160000; -0.240000<=loss<=0.280000, 0.160000<=old<=0.200000; -0.240000<=loss<=0.280000, 0.200000<=old<=0.240000; -0.240000<=loss<=0.280000, 0.240000<=old<=0.280000; -0.240000<=loss<=0.280000, 0.280000<=old<=0.320000; -0.240000<=loss<=0.280000, 0.320000<=old<=0.360000; -0.240000<=loss<=0.280000, 0.360000<=old<=0.400000; -0.240000<=loss<=0.280000, 0.400000<=old<=0.440000; -0.240000<=loss<=0.280000, 0.440000<=old<=0.480000; -0.240000<=loss<=0.280000, 0.480000<=old<=0.520000; -0.240000<=loss<=0.280000, 0.520000<=old<=0.560000; -0.240000<=loss<=0.280000, 0.560000<=old<=0.600000; -0.240000<=loss<=0.280000, 0.600000<=old<=0.640000; -0.240000<=loss<=0.280000, 0.640000<=old<=0.680000; -0.240000<=loss<=0.280000, 0.680000<=old<=0.720000; -0.240000<=loss<=0.280000, 0.720000<=old<=0.760000; -0.240000<=loss<=0.280000, 0.760000<=old<=0.800000; -0.240000<=loss<=0.280000, 0.800000<=old<=0.840000; -0.240000<=loss<=0.280000, 0.840000<=old<=0.880000; -0.240000<=loss<=0.280000, 0.880000<=old<=0.920000; -0.240000<=loss<=0.280000, 0.920000<=old<=0.960000; -0.240000<=loss<=0.280000, 0.960000<=old<=0.999990; -0.280000<=loss<=0.320000, 0.000010<=old<=0.040000; -0.280000<=loss<=0.320000, 0.040000<=old<=0.080000; -0.280000<=loss<=0.320000, 0.080000<=old<=0.120000; -0.280000<=loss<=0.320000, 0.120000<=old<=0.160000; -0.280000<=loss<=0.320000, 0.160000<=old<=0.200000; -0.280000<=loss<=0.320000, 0.200000<=old<=0.240000; -0.280000<=loss<=0.320000, 0.240000<=old<=0.280000; -0.280000<=loss<=0.320000, 0.280000<=old<=0.320000; -0.280000<=loss<=0.320000, 0.320000<=old<=0.360000; -0.280000<=loss<=0.320000, 0.360000<=old<=0.400000; -0.280000<=loss<=0.320000, 0.400000<=old<=0.440000; -0.280000<=loss<=0.320000, 0.440000<=old<=0.480000; -0.280000<=loss<=0.320000, 0.480000<=old<=0.520000; -0.280000<=loss<=0.320000, 0.520000<=old<=0.560000; -0.280000<=loss<=0.320000, 0.560000<=old<=0.600000; -0.280000<=loss<=0.320000, 0.600000<=old<=0.640000; -0.280000<=loss<=0.320000, 0.640000<=old<=0.680000; -0.280000<=loss<=0.320000, 0.680000<=old<=0.720000; -0.280000<=loss<=0.320000, 0.720000<=old<=0.760000; -0.280000<=loss<=0.320000, 0.760000<=old<=0.800000; -0.280000<=loss<=0.320000, 0.800000<=old<=0.840000; -0.280000<=loss<=0.320000, 0.840000<=old<=0.880000; -0.280000<=loss<=0.320000, 0.880000<=old<=0.920000; -0.280000<=loss<=0.320000, 0.920000<=old<=0.960000; -0.280000<=loss<=0.320000, 0.960000<=old<=0.999990; -0.320000<=loss<=0.360000, 0.000010<=old<=0.040000; -0.320000<=loss<=0.360000, 0.040000<=old<=0.080000; -0.320000<=loss<=0.360000, 0.080000<=old<=0.120000; -0.320000<=loss<=0.360000, 0.120000<=old<=0.160000; -0.320000<=loss<=0.360000, 0.160000<=old<=0.200000; -0.320000<=loss<=0.360000, 0.200000<=old<=0.240000; -0.320000<=loss<=0.360000, 0.240000<=old<=0.280000; -0.320000<=loss<=0.360000, 0.280000<=old<=0.320000; -0.320000<=loss<=0.360000, 0.320000<=old<=0.360000; -0.320000<=loss<=0.360000, 0.360000<=old<=0.400000; -0.320000<=loss<=0.360000, 0.400000<=old<=0.440000; -0.320000<=loss<=0.360000, 0.440000<=old<=0.480000; -0.320000<=loss<=0.360000, 0.480000<=old<=0.520000; -0.320000<=loss<=0.360000, 0.520000<=old<=0.560000; -0.320000<=loss<=0.360000, 0.560000<=old<=0.600000; -0.320000<=loss<=0.360000, 0.600000<=old<=0.640000; -0.320000<=loss<=0.360000, 0.640000<=old<=0.680000; -0.320000<=loss<=0.360000, 0.680000<=old<=0.720000; -0.320000<=loss<=0.360000, 0.720000<=old<=0.760000; -0.320000<=loss<=0.360000, 0.760000<=old<=0.800000; -0.320000<=loss<=0.360000, 0.800000<=old<=0.840000; -0.320000<=loss<=0.360000, 0.840000<=old<=0.880000; -0.320000<=loss<=0.360000, 0.880000<=old<=0.920000; -0.320000<=loss<=0.360000, 0.920000<=old<=0.960000; -0.320000<=loss<=0.360000, 0.960000<=old<=0.999990; -0.360000<=loss<=0.400000, 0.000010<=old<=0.040000; -0.360000<=loss<=0.400000, 0.040000<=old<=0.080000; -0.360000<=loss<=0.400000, 0.080000<=old<=0.120000; -0.360000<=loss<=0.400000, 0.120000<=old<=0.160000; -0.360000<=loss<=0.400000, 0.160000<=old<=0.200000; -0.360000<=loss<=0.400000, 0.200000<=old<=0.240000; -0.360000<=loss<=0.400000, 0.240000<=old<=0.280000; -0.360000<=loss<=0.400000, 0.280000<=old<=0.320000; -0.360000<=loss<=0.400000, 0.320000<=old<=0.360000; -0.360000<=loss<=0.400000, 0.360000<=old<=0.400000; -0.360000<=loss<=0.400000, 0.400000<=old<=0.440000; -0.360000<=loss<=0.400000, 0.440000<=old<=0.480000; -0.360000<=loss<=0.400000, 0.480000<=old<=0.520000; -0.360000<=loss<=0.400000, 0.520000<=old<=0.560000; -0.360000<=loss<=0.400000, 0.560000<=old<=0.600000; -0.360000<=loss<=0.400000, 0.600000<=old<=0.640000; -0.360000<=loss<=0.400000, 0.640000<=old<=0.680000; -0.360000<=loss<=0.400000, 0.680000<=old<=0.720000; -0.360000<=loss<=0.400000, 0.720000<=old<=0.760000; -0.360000<=loss<=0.400000, 0.760000<=old<=0.800000; -0.360000<=loss<=0.400000, 0.800000<=old<=0.840000; -0.360000<=loss<=0.400000, 0.840000<=old<=0.880000; -0.360000<=loss<=0.400000, 0.880000<=old<=0.920000; -0.360000<=loss<=0.400000, 0.920000<=old<=0.960000; -0.360000<=loss<=0.400000, 0.960000<=old<=0.999990; -0.400000<=loss<=0.440000, 0.000010<=old<=0.040000; -0.400000<=loss<=0.440000, 0.040000<=old<=0.080000; -0.400000<=loss<=0.440000, 0.080000<=old<=0.120000; -0.400000<=loss<=0.440000, 0.120000<=old<=0.160000; -0.400000<=loss<=0.440000, 0.160000<=old<=0.200000; -0.400000<=loss<=0.440000, 0.200000<=old<=0.240000; -0.400000<=loss<=0.440000, 0.240000<=old<=0.280000; -0.400000<=loss<=0.440000, 0.280000<=old<=0.320000; -0.400000<=loss<=0.440000, 0.320000<=old<=0.360000; -0.400000<=loss<=0.440000, 0.360000<=old<=0.400000; -0.400000<=loss<=0.440000, 0.400000<=old<=0.440000; -0.400000<=loss<=0.440000, 0.440000<=old<=0.480000; -0.400000<=loss<=0.440000, 0.480000<=old<=0.520000; -0.400000<=loss<=0.440000, 0.520000<=old<=0.560000; -0.400000<=loss<=0.440000, 0.560000<=old<=0.600000; -0.400000<=loss<=0.440000, 0.600000<=old<=0.640000; -0.400000<=loss<=0.440000, 0.640000<=old<=0.680000; -0.400000<=loss<=0.440000, 0.680000<=old<=0.720000; -0.400000<=loss<=0.440000, 0.720000<=old<=0.760000; -0.400000<=loss<=0.440000, 0.760000<=old<=0.800000; -0.400000<=loss<=0.440000, 0.800000<=old<=0.840000; -0.400000<=loss<=0.440000, 0.840000<=old<=0.880000; -0.400000<=loss<=0.440000, 0.880000<=old<=0.920000; -0.400000<=loss<=0.440000, 0.920000<=old<=0.960000; -0.400000<=loss<=0.440000, 0.960000<=old<=0.999990; -0.440000<=loss<=0.480000, 0.000010<=old<=0.040000; -0.440000<=loss<=0.480000, 0.040000<=old<=0.080000; -0.440000<=loss<=0.480000, 0.080000<=old<=0.120000; -0.440000<=loss<=0.480000, 0.120000<=old<=0.160000; -0.440000<=loss<=0.480000, 0.160000<=old<=0.200000; -0.440000<=loss<=0.480000, 0.200000<=old<=0.240000; -0.440000<=loss<=0.480000, 0.240000<=old<=0.280000; -0.440000<=loss<=0.480000, 0.280000<=old<=0.320000; -0.440000<=loss<=0.480000, 0.320000<=old<=0.360000; -0.440000<=loss<=0.480000, 0.360000<=old<=0.400000; -0.440000<=loss<=0.480000, 0.400000<=old<=0.440000; -0.440000<=loss<=0.480000, 0.440000<=old<=0.480000; -0.440000<=loss<=0.480000, 0.480000<=old<=0.520000; -0.440000<=loss<=0.480000, 0.520000<=old<=0.560000; -0.440000<=loss<=0.480000, 0.560000<=old<=0.600000; -0.440000<=loss<=0.480000, 0.600000<=old<=0.640000; -0.440000<=loss<=0.480000, 0.640000<=old<=0.680000; -0.440000<=loss<=0.480000, 0.680000<=old<=0.720000; -0.440000<=loss<=0.480000, 0.720000<=old<=0.760000; -0.440000<=loss<=0.480000, 0.760000<=old<=0.800000; -0.440000<=loss<=0.480000, 0.800000<=old<=0.840000; -0.440000<=loss<=0.480000, 0.840000<=old<=0.880000; -0.440000<=loss<=0.480000, 0.880000<=old<=0.920000; -0.440000<=loss<=0.480000, 0.920000<=old<=0.960000; -0.440000<=loss<=0.480000, 0.960000<=old<=0.999990; -0.480000<=loss<=0.520000, 0.000010<=old<=0.040000; -0.480000<=loss<=0.520000, 0.040000<=old<=0.080000; -0.480000<=loss<=0.520000, 0.080000<=old<=0.120000; -0.480000<=loss<=0.520000, 0.120000<=old<=0.160000; -0.480000<=loss<=0.520000, 0.160000<=old<=0.200000; -0.480000<=loss<=0.520000, 0.200000<=old<=0.240000; -0.480000<=loss<=0.520000, 0.240000<=old<=0.280000; -0.480000<=loss<=0.520000, 0.280000<=old<=0.320000; -0.480000<=loss<=0.520000, 0.320000<=old<=0.360000; -0.480000<=loss<=0.520000, 0.360000<=old<=0.400000; -0.480000<=loss<=0.520000, 0.400000<=old<=0.440000; -0.480000<=loss<=0.520000, 0.440000<=old<=0.480000; -0.480000<=loss<=0.520000, 0.480000<=old<=0.520000; -0.480000<=loss<=0.520000, 0.520000<=old<=0.560000; -0.480000<=loss<=0.520000, 0.560000<=old<=0.600000; -0.480000<=loss<=0.520000, 0.600000<=old<=0.640000; -0.480000<=loss<=0.520000, 0.640000<=old<=0.680000; -0.480000<=loss<=0.520000, 0.680000<=old<=0.720000; -0.480000<=loss<=0.520000, 0.720000<=old<=0.760000; -0.480000<=loss<=0.520000, 0.760000<=old<=0.800000; -0.480000<=loss<=0.520000, 0.800000<=old<=0.840000; -0.480000<=loss<=0.520000, 0.840000<=old<=0.880000; -0.480000<=loss<=0.520000, 0.880000<=old<=0.920000; -0.480000<=loss<=0.520000, 0.920000<=old<=0.960000; -0.480000<=loss<=0.520000, 0.960000<=old<=0.999990; -0.520000<=loss<=0.560000, 0.000010<=old<=0.040000; -0.520000<=loss<=0.560000, 0.040000<=old<=0.080000; -0.520000<=loss<=0.560000, 0.080000<=old<=0.120000; -0.520000<=loss<=0.560000, 0.120000<=old<=0.160000; -0.520000<=loss<=0.560000, 0.160000<=old<=0.200000; -0.520000<=loss<=0.560000, 0.200000<=old<=0.240000; -0.520000<=loss<=0.560000, 0.240000<=old<=0.280000; -0.520000<=loss<=0.560000, 0.280000<=old<=0.320000; -0.520000<=loss<=0.560000, 0.320000<=old<=0.360000; -0.520000<=loss<=0.560000, 0.360000<=old<=0.400000; -0.520000<=loss<=0.560000, 0.400000<=old<=0.440000; -0.520000<=loss<=0.560000, 0.440000<=old<=0.480000; -0.520000<=loss<=0.560000, 0.480000<=old<=0.520000; -0.520000<=loss<=0.560000, 0.520000<=old<=0.560000; -0.520000<=loss<=0.560000, 0.560000<=old<=0.600000; -0.520000<=loss<=0.560000, 0.600000<=old<=0.640000; -0.520000<=loss<=0.560000, 0.640000<=old<=0.680000; -0.520000<=loss<=0.560000, 0.680000<=old<=0.720000; -0.520000<=loss<=0.560000, 0.720000<=old<=0.760000; -0.520000<=loss<=0.560000, 0.760000<=old<=0.800000; -0.520000<=loss<=0.560000, 0.800000<=old<=0.840000; -0.520000<=loss<=0.560000, 0.840000<=old<=0.880000; -0.520000<=loss<=0.560000, 0.880000<=old<=0.920000; -0.520000<=loss<=0.560000, 0.920000<=old<=0.960000; -0.520000<=loss<=0.560000, 0.960000<=old<=0.999990; -0.560000<=loss<=0.600000, 0.000010<=old<=0.040000; -0.560000<=loss<=0.600000, 0.040000<=old<=0.080000; -0.560000<=loss<=0.600000, 0.080000<=old<=0.120000; -0.560000<=loss<=0.600000, 0.120000<=old<=0.160000; -0.560000<=loss<=0.600000, 0.160000<=old<=0.200000; -0.560000<=loss<=0.600000, 0.200000<=old<=0.240000; -0.560000<=loss<=0.600000, 0.240000<=old<=0.280000; -0.560000<=loss<=0.600000, 0.280000<=old<=0.320000; -0.560000<=loss<=0.600000, 0.320000<=old<=0.360000; -0.560000<=loss<=0.600000, 0.360000<=old<=0.400000; -0.560000<=loss<=0.600000, 0.400000<=old<=0.440000; -0.560000<=loss<=0.600000, 0.440000<=old<=0.480000; -0.560000<=loss<=0.600000, 0.480000<=old<=0.520000; -0.560000<=loss<=0.600000, 0.520000<=old<=0.560000; -0.560000<=loss<=0.600000, 0.560000<=old<=0.600000; -0.560000<=loss<=0.600000, 0.600000<=old<=0.640000; -0.560000<=loss<=0.600000, 0.640000<=old<=0.680000; -0.560000<=loss<=0.600000, 0.680000<=old<=0.720000; -0.560000<=loss<=0.600000, 0.720000<=old<=0.760000; -0.560000<=loss<=0.600000, 0.760000<=old<=0.800000; -0.560000<=loss<=0.600000, 0.800000<=old<=0.840000; -0.560000<=loss<=0.600000, 0.840000<=old<=0.880000; -0.560000<=loss<=0.600000, 0.880000<=old<=0.920000; -0.560000<=loss<=0.600000, 0.920000<=old<=0.960000; -0.560000<=loss<=0.600000, 0.960000<=old<=0.999990; -0.600000<=loss<=0.640000, 0.000010<=old<=0.040000; -0.600000<=loss<=0.640000, 0.040000<=old<=0.080000; -0.600000<=loss<=0.640000, 0.080000<=old<=0.120000; -0.600000<=loss<=0.640000, 0.120000<=old<=0.160000; -0.600000<=loss<=0.640000, 0.160000<=old<=0.200000; -0.600000<=loss<=0.640000, 0.200000<=old<=0.240000; -0.600000<=loss<=0.640000, 0.240000<=old<=0.280000; -0.600000<=loss<=0.640000, 0.280000<=old<=0.320000; -0.600000<=loss<=0.640000, 0.320000<=old<=0.360000; -0.600000<=loss<=0.640000, 0.360000<=old<=0.400000; -0.600000<=loss<=0.640000, 0.400000<=old<=0.440000; -0.600000<=loss<=0.640000, 0.440000<=old<=0.480000; -0.600000<=loss<=0.640000, 0.480000<=old<=0.520000; -0.600000<=loss<=0.640000, 0.520000<=old<=0.560000; -0.600000<=loss<=0.640000, 0.560000<=old<=0.600000; -0.600000<=loss<=0.640000, 0.600000<=old<=0.640000; -0.600000<=loss<=0.640000, 0.640000<=old<=0.680000; -0.600000<=loss<=0.640000, 0.680000<=old<=0.720000; -0.600000<=loss<=0.640000, 0.720000<=old<=0.760000; -0.600000<=loss<=0.640000, 0.760000<=old<=0.800000; -0.600000<=loss<=0.640000, 0.800000<=old<=0.840000; -0.600000<=loss<=0.640000, 0.840000<=old<=0.880000; -0.600000<=loss<=0.640000, 0.880000<=old<=0.920000; -0.600000<=loss<=0.640000, 0.920000<=old<=0.960000; -0.600000<=loss<=0.640000, 0.960000<=old<=0.999990; -0.640000<=loss<=0.680000, 0.000010<=old<=0.040000; -0.640000<=loss<=0.680000, 0.040000<=old<=0.080000; -0.640000<=loss<=0.680000, 0.080000<=old<=0.120000; -0.640000<=loss<=0.680000, 0.120000<=old<=0.160000; -0.640000<=loss<=0.680000, 0.160000<=old<=0.200000; -0.640000<=loss<=0.680000, 0.200000<=old<=0.240000; -0.640000<=loss<=0.680000, 0.240000<=old<=0.280000; -0.640000<=loss<=0.680000, 0.280000<=old<=0.320000; -0.640000<=loss<=0.680000, 0.320000<=old<=0.360000; -0.640000<=loss<=0.680000, 0.360000<=old<=0.400000; -0.640000<=loss<=0.680000, 0.400000<=old<=0.440000; -0.640000<=loss<=0.680000, 0.440000<=old<=0.480000; -0.640000<=loss<=0.680000, 0.480000<=old<=0.520000; -0.640000<=loss<=0.680000, 0.520000<=old<=0.560000; -0.640000<=loss<=0.680000, 0.560000<=old<=0.600000; -0.640000<=loss<=0.680000, 0.600000<=old<=0.640000; -0.640000<=loss<=0.680000, 0.640000<=old<=0.680000; -0.640000<=loss<=0.680000, 0.680000<=old<=0.720000; -0.640000<=loss<=0.680000, 0.720000<=old<=0.760000; -0.640000<=loss<=0.680000, 0.760000<=old<=0.800000; -0.640000<=loss<=0.680000, 0.800000<=old<=0.840000; -0.640000<=loss<=0.680000, 0.840000<=old<=0.880000; -0.640000<=loss<=0.680000, 0.880000<=old<=0.920000; -0.640000<=loss<=0.680000, 0.920000<=old<=0.960000; -0.640000<=loss<=0.680000, 0.960000<=old<=0.999990; -0.680000<=loss<=0.720000, 0.000010<=old<=0.040000; -0.680000<=loss<=0.720000, 0.040000<=old<=0.080000; -0.680000<=loss<=0.720000, 0.080000<=old<=0.120000; -0.680000<=loss<=0.720000, 0.120000<=old<=0.160000; -0.680000<=loss<=0.720000, 0.160000<=old<=0.200000; -0.680000<=loss<=0.720000, 0.200000<=old<=0.240000; -0.680000<=loss<=0.720000, 0.240000<=old<=0.280000; -0.680000<=loss<=0.720000, 0.280000<=old<=0.320000; -0.680000<=loss<=0.720000, 0.320000<=old<=0.360000; -0.680000<=loss<=0.720000, 0.360000<=old<=0.400000; -0.680000<=loss<=0.720000, 0.400000<=old<=0.440000; -0.680000<=loss<=0.720000, 0.440000<=old<=0.480000; -0.680000<=loss<=0.720000, 0.480000<=old<=0.520000; -0.680000<=loss<=0.720000, 0.520000<=old<=0.560000; -0.680000<=loss<=0.720000, 0.560000<=old<=0.600000; -0.680000<=loss<=0.720000, 0.600000<=old<=0.640000; -0.680000<=loss<=0.720000, 0.640000<=old<=0.680000; -0.680000<=loss<=0.720000, 0.680000<=old<=0.720000; -0.680000<=loss<=0.720000, 0.720000<=old<=0.760000; -0.680000<=loss<=0.720000, 0.760000<=old<=0.800000; -0.680000<=loss<=0.720000, 0.800000<=old<=0.840000; -0.680000<=loss<=0.720000, 0.840000<=old<=0.880000; -0.680000<=loss<=0.720000, 0.880000<=old<=0.920000; -0.680000<=loss<=0.720000, 0.920000<=old<=0.960000; -0.680000<=loss<=0.720000, 0.960000<=old<=0.999990; -0.720000<=loss<=0.760000, 0.000010<=old<=0.040000; -0.720000<=loss<=0.760000, 0.040000<=old<=0.080000; -0.720000<=loss<=0.760000, 0.080000<=old<=0.120000; -0.720000<=loss<=0.760000, 0.120000<=old<=0.160000; -0.720000<=loss<=0.760000, 0.160000<=old<=0.200000; -0.720000<=loss<=0.760000, 0.200000<=old<=0.240000; -0.720000<=loss<=0.760000, 0.240000<=old<=0.280000; -0.720000<=loss<=0.760000, 0.280000<=old<=0.320000; -0.720000<=loss<=0.760000, 0.320000<=old<=0.360000; -0.720000<=loss<=0.760000, 0.360000<=old<=0.400000; -0.720000<=loss<=0.760000, 0.400000<=old<=0.440000; -0.720000<=loss<=0.760000, 0.440000<=old<=0.480000; -0.720000<=loss<=0.760000, 0.480000<=old<=0.520000; -0.720000<=loss<=0.760000, 0.520000<=old<=0.560000; -0.720000<=loss<=0.760000, 0.560000<=old<=0.600000; -0.720000<=loss<=0.760000, 0.600000<=old<=0.640000; -0.720000<=loss<=0.760000, 0.640000<=old<=0.680000; -0.720000<=loss<=0.760000, 0.680000<=old<=0.720000; -0.720000<=loss<=0.760000, 0.720000<=old<=0.760000; -0.720000<=loss<=0.760000, 0.760000<=old<=0.800000; -0.720000<=loss<=0.760000, 0.800000<=old<=0.840000; -0.720000<=loss<=0.760000, 0.840000<=old<=0.880000; -0.720000<=loss<=0.760000, 0.880000<=old<=0.920000; -0.720000<=loss<=0.760000, 0.920000<=old<=0.960000; -0.720000<=loss<=0.760000, 0.960000<=old<=0.999990; -0.760000<=loss<=0.800000, 0.000010<=old<=0.040000; -0.760000<=loss<=0.800000, 0.040000<=old<=0.080000; -0.760000<=loss<=0.800000, 0.080000<=old<=0.120000; -0.760000<=loss<=0.800000, 0.120000<=old<=0.160000; -0.760000<=loss<=0.800000, 0.160000<=old<=0.200000; -0.760000<=loss<=0.800000, 0.200000<=old<=0.240000; -0.760000<=loss<=0.800000, 0.240000<=old<=0.280000; -0.760000<=loss<=0.800000, 0.280000<=old<=0.320000; -0.760000<=loss<=0.800000, 0.320000<=old<=0.360000; -0.760000<=loss<=0.800000, 0.360000<=old<=0.400000; -0.760000<=loss<=0.800000, 0.400000<=old<=0.440000; -0.760000<=loss<=0.800000, 0.440000<=old<=0.480000; -0.760000<=loss<=0.800000, 0.480000<=old<=0.520000; -0.760000<=loss<=0.800000, 0.520000<=old<=0.560000; -0.760000<=loss<=0.800000, 0.560000<=old<=0.600000; -0.760000<=loss<=0.800000, 0.600000<=old<=0.640000; -0.760000<=loss<=0.800000, 0.640000<=old<=0.680000; -0.760000<=loss<=0.800000, 0.680000<=old<=0.720000; -0.760000<=loss<=0.800000, 0.720000<=old<=0.760000; -0.760000<=loss<=0.800000, 0.760000<=old<=0.800000; -0.760000<=loss<=0.800000, 0.800000<=old<=0.840000; -0.760000<=loss<=0.800000, 0.840000<=old<=0.880000; -0.760000<=loss<=0.800000, 0.880000<=old<=0.920000; -0.760000<=loss<=0.800000, 0.920000<=old<=0.960000; -0.760000<=loss<=0.800000, 0.960000<=old<=0.999990; -0.800000<=loss<=0.840000, 0.000010<=old<=0.040000; -0.800000<=loss<=0.840000, 0.040000<=old<=0.080000; -0.800000<=loss<=0.840000, 0.080000<=old<=0.120000; -0.800000<=loss<=0.840000, 0.120000<=old<=0.160000; -0.800000<=loss<=0.840000, 0.160000<=old<=0.200000; -0.800000<=loss<=0.840000, 0.200000<=old<=0.240000; -0.800000<=loss<=0.840000, 0.240000<=old<=0.280000; -0.800000<=loss<=0.840000, 0.280000<=old<=0.320000; -0.800000<=loss<=0.840000, 0.320000<=old<=0.360000; -0.800000<=loss<=0.840000, 0.360000<=old<=0.400000; -0.800000<=loss<=0.840000, 0.400000<=old<=0.440000; -0.800000<=loss<=0.840000, 0.440000<=old<=0.480000; -0.800000<=loss<=0.840000, 0.480000<=old<=0.520000; -0.800000<=loss<=0.840000, 0.520000<=old<=0.560000; -0.800000<=loss<=0.840000, 0.560000<=old<=0.600000; -0.800000<=loss<=0.840000, 0.600000<=old<=0.640000; -0.800000<=loss<=0.840000, 0.640000<=old<=0.680000; -0.800000<=loss<=0.840000, 0.680000<=old<=0.720000; -0.800000<=loss<=0.840000, 0.720000<=old<=0.760000; -0.800000<=loss<=0.840000, 0.760000<=old<=0.800000; -0.800000<=loss<=0.840000, 0.800000<=old<=0.840000; -0.800000<=loss<=0.840000, 0.840000<=old<=0.880000; -0.800000<=loss<=0.840000, 0.880000<=old<=0.920000; -0.800000<=loss<=0.840000, 0.920000<=old<=0.960000; -0.800000<=loss<=0.840000, 0.960000<=old<=0.999990; -0.840000<=loss<=0.880000, 0.000010<=old<=0.040000; -0.840000<=loss<=0.880000, 0.040000<=old<=0.080000; -0.840000<=loss<=0.880000, 0.080000<=old<=0.120000; -0.840000<=loss<=0.880000, 0.120000<=old<=0.160000; -0.840000<=loss<=0.880000, 0.160000<=old<=0.200000; -0.840000<=loss<=0.880000, 0.200000<=old<=0.240000; -0.840000<=loss<=0.880000, 0.240000<=old<=0.280000; -0.840000<=loss<=0.880000, 0.280000<=old<=0.320000; -0.840000<=loss<=0.880000, 0.320000<=old<=0.360000; -0.840000<=loss<=0.880000, 0.360000<=old<=0.400000; -0.840000<=loss<=0.880000, 0.400000<=old<=0.440000; -0.840000<=loss<=0.880000, 0.440000<=old<=0.480000; -0.840000<=loss<=0.880000, 0.480000<=old<=0.520000; -0.840000<=loss<=0.880000, 0.520000<=old<=0.560000; -0.840000<=loss<=0.880000, 0.560000<=old<=0.600000; -0.840000<=loss<=0.880000, 0.600000<=old<=0.640000; -0.840000<=loss<=0.880000, 0.640000<=old<=0.680000; -0.840000<=loss<=0.880000, 0.680000<=old<=0.720000; -0.840000<=loss<=0.880000, 0.720000<=old<=0.760000; -0.840000<=loss<=0.880000, 0.760000<=old<=0.800000; -0.840000<=loss<=0.880000, 0.800000<=old<=0.840000; -0.840000<=loss<=0.880000, 0.840000<=old<=0.880000; -0.840000<=loss<=0.880000, 0.880000<=old<=0.920000; -0.840000<=loss<=0.880000, 0.920000<=old<=0.960000; -0.840000<=loss<=0.880000, 0.960000<=old<=0.999990; -0.880000<=loss<=0.920000, 0.000010<=old<=0.040000; -0.880000<=loss<=0.920000, 0.040000<=old<=0.080000; -0.880000<=loss<=0.920000, 0.080000<=old<=0.120000; -0.880000<=loss<=0.920000, 0.120000<=old<=0.160000; -0.880000<=loss<=0.920000, 0.160000<=old<=0.200000; -0.880000<=loss<=0.920000, 0.200000<=old<=0.240000; -0.880000<=loss<=0.920000, 0.240000<=old<=0.280000; -0.880000<=loss<=0.920000, 0.280000<=old<=0.320000; -0.880000<=loss<=0.920000, 0.320000<=old<=0.360000; -0.880000<=loss<=0.920000, 0.360000<=old<=0.400000; -0.880000<=loss<=0.920000, 0.400000<=old<=0.440000; -0.880000<=loss<=0.920000, 0.440000<=old<=0.480000; -0.880000<=loss<=0.920000, 0.480000<=old<=0.520000; -0.880000<=loss<=0.920000, 0.520000<=old<=0.560000; -0.880000<=loss<=0.920000, 0.560000<=old<=0.600000; -0.880000<=loss<=0.920000, 0.600000<=old<=0.640000; -0.880000<=loss<=0.920000, 0.640000<=old<=0.680000; -0.880000<=loss<=0.920000, 0.680000<=old<=0.720000; -0.880000<=loss<=0.920000, 0.720000<=old<=0.760000; -0.880000<=loss<=0.920000, 0.760000<=old<=0.800000; -0.880000<=loss<=0.920000, 0.800000<=old<=0.840000; -0.880000<=loss<=0.920000, 0.840000<=old<=0.880000; -0.880000<=loss<=0.920000, 0.880000<=old<=0.920000; -0.880000<=loss<=0.920000, 0.920000<=old<=0.960000; -0.880000<=loss<=0.920000, 0.960000<=old<=0.999990; -0.920000<=loss<=0.960000, 0.000010<=old<=0.040000; -0.920000<=loss<=0.960000, 0.040000<=old<=0.080000; -0.920000<=loss<=0.960000, 0.080000<=old<=0.120000; -0.920000<=loss<=0.960000, 0.120000<=old<=0.160000; -0.920000<=loss<=0.960000, 0.160000<=old<=0.200000; -0.920000<=loss<=0.960000, 0.200000<=old<=0.240000; -0.920000<=loss<=0.960000, 0.240000<=old<=0.280000; -0.920000<=loss<=0.960000, 0.280000<=old<=0.320000; -0.920000<=loss<=0.960000, 0.320000<=old<=0.360000; -0.920000<=loss<=0.960000, 0.360000<=old<=0.400000; -0.920000<=loss<=0.960000, 0.400000<=old<=0.440000; -0.920000<=loss<=0.960000, 0.440000<=old<=0.480000; -0.920000<=loss<=0.960000, 0.480000<=old<=0.520000; -0.920000<=loss<=0.960000, 0.520000<=old<=0.560000; -0.920000<=loss<=0.960000, 0.560000<=old<=0.600000; -0.920000<=loss<=0.960000, 0.600000<=old<=0.640000; -0.920000<=loss<=0.960000, 0.640000<=old<=0.680000; -0.920000<=loss<=0.960000, 0.680000<=old<=0.720000; -0.920000<=loss<=0.960000, 0.720000<=old<=0.760000; -0.920000<=loss<=0.960000, 0.760000<=old<=0.800000; -0.920000<=loss<=0.960000, 0.800000<=old<=0.840000; -0.920000<=loss<=0.960000, 0.840000<=old<=0.880000; -0.920000<=loss<=0.960000, 0.880000<=old<=0.920000; -0.920000<=loss<=0.960000, 0.920000<=old<=0.960000; -0.920000<=loss<=0.960000, 0.960000<=old<=0.999990; -0.960000<=loss<=0.999990, 0.000010<=old<=0.040000; -0.960000<=loss<=0.999990, 0.040000<=old<=0.080000; -0.960000<=loss<=0.999990, 0.080000<=old<=0.120000; -0.960000<=loss<=0.999990, 0.120000<=old<=0.160000; -0.960000<=loss<=0.999990, 0.160000<=old<=0.200000; -0.960000<=loss<=0.999990, 0.200000<=old<=0.240000; -0.960000<=loss<=0.999990, 0.240000<=old<=0.280000; -0.960000<=loss<=0.999990, 0.280000<=old<=0.320000; -0.960000<=loss<=0.999990, 0.320000<=old<=0.360000; -0.960000<=loss<=0.999990, 0.360000<=old<=0.400000; -0.960000<=loss<=0.999990, 0.400000<=old<=0.440000; -0.960000<=loss<=0.999990, 0.440000<=old<=0.480000; -0.960000<=loss<=0.999990, 0.480000<=old<=0.520000; -0.960000<=loss<=0.999990, 0.520000<=old<=0.560000; -0.960000<=loss<=0.999990, 0.560000<=old<=0.600000; -0.960000<=loss<=0.999990, 0.600000<=old<=0.640000; -0.960000<=loss<=0.999990, 0.640000<=old<=0.680000; -0.960000<=loss<=0.999990, 0.680000<=old<=0.720000; -0.960000<=loss<=0.999990, 0.720000<=old<=0.760000; -0.960000<=loss<=0.999990, 0.760000<=old<=0.800000; -0.960000<=loss<=0.999990, 0.800000<=old<=0.840000; -0.960000<=loss<=0.999990, 0.840000<=old<=0.880000; -0.960000<=loss<=0.999990, 0.880000<=old<=0.920000; -0.960000<=loss<=0.999990, 0.920000<=old<=0.960000; -0.960000<=loss<=0.999990, 0.960000<=old<=0.999990; diff --git a/examples/pmdp/zeroconf/zeroconf_space.txt b/examples/pmdp/zeroconf/zeroconf_space.txt deleted file mode 100644 index 54ffa3425..000000000 --- a/examples/pmdp/zeroconf/zeroconf_space.txt +++ /dev/null @@ -1,2 +0,0 @@ -0.000010<=loss<=0.999990, 0.000010<=old<=0.999990; - diff --git a/install.sh b/install.sh index 86e8ffcb0..384bbb2e9 100755 --- a/install.sh +++ b/install.sh @@ -1,2 +1,2 @@ #!/bin/bash -pip install -ve . --install-option="--cmake=" --install-option="--make=" +pip install -ve stormpy diff --git a/resources/3rdparty/CMakeLists.txt b/resources/3rdparty/CMakeLists.txt index 665062ae0..6e85cf5b3 100644 --- a/resources/3rdparty/CMakeLists.txt +++ b/resources/3rdparty/CMakeLists.txt @@ -4,10 +4,6 @@ add_custom_target(test-resources) set(STORM_3RDPARTY_SOURCE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty) set(STORM_3RDPARTY_BINARY_DIR ${PROJECT_BINARY_DIR}/resources/3rdparty) -#### -#### Find autoreconf for cudd update step -find_program(AUTORECONF autoreconf) -mark_as_advanced(AUTORECONF) ############################################################# ## @@ -15,22 +11,22 @@ mark_as_advanced(AUTORECONF) ## ############################################################# - # Do not take a branch, needs internet connection. ExternalProject_Add( - l3pp + l3pp_ext GIT_REPOSITORY https://github.com/hbruintjes/l3pp.git GIT_TAG e4f8d7fe6c328849aff34d2dfd6fd592c14070d5 SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/l3pp + UPDATE_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" LOG_INSTALL ON ) -ExternalProject_Get_Property(l3pp source_dir) +ExternalProject_Get_Property(l3pp_ext source_dir) set(l3pp_INCLUDE "${source_dir}/") -include_directories(${l3pp_INCLUDE}) -add_dependencies(resources l3pp) +add_imported_library_interface(l3pp "${l3pp_INCLUDE}") +list(APPEND STORM_DEP_TARGETS l3pp) ############################################################# ## @@ -38,9 +34,8 @@ add_dependencies(resources l3pp) ## ############################################################# -# Add the shipped version of GMM to the include pathes -set(GMMXX_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/gmm-5.0/include") -include_directories(${GMMXX_INCLUDE_DIR}) +add_imported_library_interface(gmm "${PROJECT_SOURCE_DIR}/resources/3rdparty/gmm-5.0/include") +list(APPEND STORM_DEP_TARGETS gmm) ############################################################# ## @@ -48,9 +43,8 @@ include_directories(${GMMXX_INCLUDE_DIR}) ## ############################################################# -# Add the shipped version of Eigen to the include pathes -set(EIGEN_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen-3.3-beta1") -include_directories(${EIGEN_INCLUDE_DIR}) +add_imported_library_interface(Eigen33 "${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen-3.3-beta1") +list(APPEND STORM_DEP_TARGETS Eigen33) ############################################################# @@ -64,8 +58,14 @@ set(Boost_USE_STATIC_LIBS ${USE_BOOST_STATIC_LIBRARIES}) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) -find_package(Boost 1.57.0 QUIET REQUIRED) - +find_package(Boost 1.61.0 QUIET REQUIRED COMPONENTS filesystem system) +if (NOT Boost_FOUND) + if (Boost_VERSION) + message(FATAL_ERROR "The required Boost version is 1.61.0 or newer, however, only ${Boost_VERSION} was found.") + else () + message(FATAL_ERROR "Boost was not found.") + endif () +endif () if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL "")) set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib") endif () @@ -73,9 +73,9 @@ link_directories(${Boost_LIBRARY_DIRS}) include_directories(${Boost_INCLUDE_DIRS}) list(APPEND STORM_LINK_LIBRARIES ${Boost_LIBRARIES}) -message(STATUS "StoRM - Using Boost ${Boost_VERSION} (lib ${Boost_LIB_VERSION})") -#message(STATUS "StoRM - BOOST_INCLUDE_DIRS is ${Boost_INCLUDE_DIRS}") -#message(STATUS "StoRM - BOOST_LIBRARY_DIRS is ${Boost_LIBRARY_DIRS}") +message(STATUS "Storm - Using boost ${Boost_VERSION} (library version ${Boost_LIB_VERSION}).") +# set the information for the config header +set(STORM_BOOST_INCLUDE_DIR "${Boost_INCLUDE_DIRS}") ############################################################# ## @@ -84,8 +84,28 @@ message(STATUS "StoRM - Using Boost ${Boost_VERSION} (lib ${Boost_LIB_VERSION})" ############################################################# # Use the shipped version of ExprTK -message (STATUS "StoRM - Including ExprTk") -include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk") +message (STATUS "Storm - Including ExprTk.") +add_imported_library_interface(ExprTk "${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk") +list(APPEND STORM_DEP_TARGETS ExprTk) + +############################################################# +## +## Sparsepp +## +############################################################# + +# Use the shipped version of Sparsepp +message (STATUS "Storm - Including Sparsepp.") +include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/sparsepp") + +# Add sparsepp.h to the headers that are copied to the include directory in thebuild directory. +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp/sparsepp.h + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/resources/3rdparty/sparsepp/sparsepp.h ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp/sparsepp.h + DEPENDS ${PROJECT_SOURCE_DIR}/resources/3rdparty/sparsepp/sparsepp.h +) +list(APPEND STORM_RESOURCES_HEADERS "${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp/sparsepp.h") ############################################################# ## @@ -94,8 +114,9 @@ include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk") ############################################################# #use the shipped version of modernjson -message (STATUS "StoRM - Including ModernJSON") -include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/modernjson/src/") +message (STATUS "Storm - Including ModernJSON.") +add_imported_library_interface(ModernJSON "${PROJECT_SOURCE_DIR}/resources/3rdparty/modernjson/src/") +list(APPEND STORM_DEP_TARGETS ModernJSON) ############################################################# ## @@ -109,7 +130,7 @@ find_package(Z3 QUIET) set(STORM_HAVE_Z3 ${Z3_FOUND}) if(Z3_FOUND) - message (STATUS "StoRM - Linking with Z3") + message (STATUS "Storm - Linking with Z3.") include_directories(${Z3_INCLUDE_DIRS}) list(APPEND STORM_LINK_LIBRARIES ${Z3_LIBRARIES}) endif(Z3_FOUND) @@ -132,12 +153,9 @@ if (STORM_USE_GUROBI) find_package(Gurobi QUIET REQUIRED) set(STORM_HAVE_GUROBI ${GUROBI_FOUND}) if (GUROBI_FOUND) - message (STATUS "StoRM - Linking with Gurobi") - include_directories(${GUROBI_INCLUDE_DIRS}) - list(APPEND STORM_LINK_LIBRARIES ${GUROBI_LIBRARY}) - #link_directories("${GUROBI_ROOT}/lib") - else() - #message(FATAL_ERROR "StoRM - Gurobi was requested, but not found!") + message (STATUS "Storm - Linking with Gurobi.") + add_imported_library(Gurobi "" ${GUROBI_LIBRARY} ${GUROBI_INCLUDE_DIRS}) + list(APPEND STORM_DEP_TARGETS Gurobi) endif() else() set(STORM_HAVE_GUROBI OFF) @@ -152,23 +170,12 @@ include(${STORM_3RDPARTY_SOURCE_DIR}/include_cudd.cmake) ############################################################# ## -## CLN +## cpptemplate ## ############################################################# +include(${STORM_3RDPARTY_SOURCE_DIR}/include_cpptemplate.cmake) -find_package(CLN QUIET) -if(CLN_FOUND) - set(STORM_HAVE_CLN ON) - message(STATUS "StoRM - Linking with CLN ${CLN_VERSION_STRING}") - include_directories("${CLN_INCLUDE_DIR}") - list(APPEND STORM_LINK_LIBRARIES ${CLN_LIBRARIES}) -else() - set(STORM_HAVE_CLN OFF) - if(NOT GMP_FOUND) - message(FATAL_ERROR "StoRM - Neither CLN nor GMP found") - endif() -endif() ############################################################# ## @@ -181,34 +188,60 @@ if(USE_CARL) find_package(carl QUIET) if(carl_FOUND) set(STORM_HAVE_CARL ON) - message(STATUS "StoRM - Use system version of carl") - message(STATUS "StoRM - Linking with carl ${carl_VERSION_STRING}") - include_directories("${carl_INCLUDE_DIR}") - list(APPEND STORM_LINK_LIBRARIES ${carl_LIBRARIES}) + message(STATUS "Storm - Use system version of carl.") + message(STATUS "Storm - Linking with carl ${carl_VERSION} (CARL_USE_CLN_NUMBERS: ${CARL_USE_CLN_NUMBERS}).") + set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS}) else() - message(STATUS "StoRM - Using shipped version of carl") - # + # The first external project will be built at *configure stage* + message("START CARL CONFIG PROCESS") + file(MAKE_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download) + execute_process( + COMMAND ${CMAKE_COMMAND} ${STORM_3RDPARTY_SOURCE_DIR}/carl "-DSTORM_3RDPARTY_BINARY_DIR=${STORM_3RDPARTY_BINARY_DIR}" + WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download + OUTPUT_VARIABLE carlconfig_out + RESULT_VARIABLE carlconfig_result + ) + + + if(NOT carlconfig_result) + message("${carlconfig_out}") + endif() + execute_process( + COMMAND ${CMAKE_COMMAND} --build . --target carl-config + WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download + OUTPUT_VARIABLE carlconfig_out + RESULT_VARIABLE carlconfig_result + ) + if(NOT carlconfig_result) + message("${carlconfig_out}") + endif() + message("END CARL CONFIG PROCESS") + + message(STATUS "Storm - Using shipped version of carl.") + set(CARL_BUILD_COMMAND make lib_carl) ExternalProject_Add( carl - GIT_REPOSITORY https://github.com/smtrat/carl - GIT_TAG master - INSTALL_DIR ${STORM_3RDPARTY_BINARY_DIR}/carl - SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/carl - CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DEXPORT_TO_CMAKE=0 -DUSE_CLN_NUMBERS=1 -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=1 -DCMAKE_INSTALL_PREFIX:PATH=${STORM_3RDPARTY_BINARY_DIR}/carl - BUILD_IN_SOURCE 0 + SOURCE_DIR ${STORM_3RDPARTY_BINARY_DIR}/carl + CONFIGURE_COMMAND "" + BUILD_IN_SOURCE 1 BUILD_COMMAND make lib_carl - INSTALL_COMMAND make install - LOG_UPDATE ON - LOG_CONFIGURE ON + INSTALL_COMMAND "" LOG_BUILD ON - LOG_INSTALL ON + BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT} ) - - add_dependencies(resources carl) - include_directories(${STORM_3RDPARTY_BINARY_DIR}/carl/include) - list(APPEND STORM_LINK_LIBRARIES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT}) + include(${STORM_3RDPARTY_BINARY_DIR}/carl/carlConfig.cmake) + message("CARL_USE_CLN_NUMBERS: ${CARL_USE_CLN_NUMBERS}") + set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS}) + add_dependencies(resources carl) + set(carl_INCLUDE_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/build/include") set(STORM_HAVE_CARL ON) endif() + if(STORM_USE_CLN_NUMBERS AND NOT STORM_HAVE_CLN) + message(FATAL_ERROR "Cannot use CLN numbers if carl is build without") + endif() + + list(APPEND STORM_DEP_IMP_TARGETS lib_carl) + endif() @@ -223,7 +256,7 @@ if(USE_SMTRAT) find_package(smtrat QUIET REQUIRED) if(smtrat_FOUND) set(STORM_HAVE_SMTRAT ON) - message(STATUS "StoRM - Linking with smtrat.") + message(STATUS "Storm - Linking with smtrat.") include_directories("${smtrat_INCLUDE_DIR}") list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES}) else() @@ -243,9 +276,8 @@ if(USE_HYPRO) find_package(hypro QUIET REQUIRED) if(hypro_FOUND) set(STORM_HAVE_HYPRO ON) - message(STATUS "StoRM - Linking with hypro ${hypro_VERSION_STRING}") + message(STATUS "Storm - Linking with hypro.") include_directories("${hypro_INCLUDE_DIR}") - link_directories( /Users/tim/hypro/build ) list(APPEND STORM_LINK_LIBRARIES ${hypro_LIBRARIES}) else() message(FATAL_ERROR "StoRM - HyPro was requested but not found") @@ -254,26 +286,6 @@ endif() -############################################################# -## -## GiNaC -## -############################################################# - -find_package(GiNaC QUIET) - -if(GINAC_FOUND) - set(STORM_HAVE_GINAC ON) - message(STATUS "StoRM - Linking with GiNaC ${GINAC_VERSION_STRING}") - # Right now only link with GiNaC for carl - #include_directories("${GINAC_INCLUDE_DIR}") - list(APPEND STORM_LINK_LIBRARIES ${GINAC_LIBRARIES}) -else() - set(STORM_HAVE_GINAC OFF) - #TODO: Check if CARL actually requires the use of GiNaC -endif() - - ############################################################# ## ## gmp @@ -298,7 +310,7 @@ endif() # MathSAT Defines set(STORM_HAVE_MSAT ${ENABLE_MSAT}) if (ENABLE_MSAT) - message (STATUS "StoRM - Linking with MathSAT") + message (STATUS "Storm - Linking with MathSAT.") link_directories("${MSAT_ROOT}/lib") include_directories("${MSAT_ROOT}/include") list(APPEND STORM_LINK_LIBRARIES "mathsat") @@ -332,34 +344,33 @@ ExternalProject_Add( DOWNLOAD_COMMAND "" PREFIX "sylvan" SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/sylvan - CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DSYLVAN_BUILD_TEST=Off -DSYLVAN_BUILD_EXAMPLES=Off -DCMAKE_BUILD_TYPE=Release - BINARY_DIR "${PROJECT_BINARY_DIR}/sylvan" + CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DSYLVAN_BUILD_TEST=Off -DSYLVAN_BUILD_EXAMPLES=Off -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON + BINARY_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan BUILD_IN_SOURCE 0 INSTALL_COMMAND "" - INSTALL_DIR "${STORM_3RDPARTY_BINARY_DIR}/sylvan" + INSTALL_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan LOG_CONFIGURE ON LOG_BUILD ON + BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/sylvan/src/libsylvan${STATIC_EXT} ) ExternalProject_Get_Property(sylvan source_dir) ExternalProject_Get_Property(sylvan binary_dir) set(Sylvan_INCLUDE_DIR "${source_dir}/src") -set(Sylvan_LIBRARY "${binary_dir}/src/libsylvan.a") - - - -message(STATUS "StoRM - Using shipped version of sylvan") -message(STATUS "StoRM - Linking with sylvan") -include_directories("${Sylvan_INCLUDE_DIR}") -list(APPEND STORM_LINK_LIBRARIES ${Sylvan_LIBRARY}) -add_dependencies(resources sylvan) - -if(${OPERATING_SYSTEM} MATCHES "Linux") - find_package(Hwloc QUIET REQUIRED) - if(Hwloc_FOUND) - message(STATUS "StoRM - Linking with hwloc ${Hwloc_VERSION}") - list(APPEND STORM_LINK_LIBRARIES ${Hwloc_LIBRARIES}) - else() - message(FATAL_ERROR "HWLOC is required but was not found.") +set(Sylvan_LIBRARY "${binary_dir}/src/libsylvan${STATIC_EXT}") +message(STATUS "Storm - Using shipped version of sylvan.") +message(STATUS "Storm - Linking with sylvan.") +add_imported_library(sylvan STATIC ${Sylvan_LIBRARY} ${Sylvan_INCLUDE_DIR}) +add_dependencies(sylvan_STATIC sylvan) +list(APPEND STORM_DEP_TARGETS sylvan_STATIC) + +find_package(Hwloc QUIET REQUIRED) +if(HWLOC_FOUND) + message(STATUS "Storm - Linking with hwloc ${HWLOC_VERSION}.") + add_imported_library(hwloc STATIC ${HWLOC_LIBRARIES} "") + list(APPEND STORM_DEP_TARGETS hwloc_STATIC) +else() + if(${OPERATING_SYSTEM} MATCHES "Linux") + message(FATAL_ERROR "HWLOC is required on Linux but was not found.") endif() endif() @@ -368,6 +379,7 @@ endif() ## Google Test gtest ## ############################################################# +set(GOOGLETEST_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/gtest-1.7.0) ExternalProject_Add( googletest #For downloads (may be useful later!) @@ -377,21 +389,23 @@ ExternalProject_Add( SOURCE_DIR "${STORM_3RDPARTY_SOURCE_DIR}/gtest-1.7.0" # Force the same output paths for debug and release builds so that # we know in which place the binaries end up when using the Xcode generator - CMAKE_ARGS -Dgtest_force_shared_crt=ON -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=${STORM_3RDPARTY_BINARY_DIR}/gtest-1.7.0 -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=${STORM_3RDPARTY_BINARY_DIR}/gtest-1.7.0 + CMAKE_ARGS -Dgtest_force_shared_crt=ON -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=${GOOGLETEST_LIB_DIR} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=${GOOGLETEST_LIB_DIR} # Disable install step INSTALL_COMMAND "" - BINARY_DIR "${STORM_3RDPARTY_BINARY_DIR}/gtest-1.7.0" - INSTALL_DIR "${STORM_3RDPARTY_BINARY_DIR}/gtest-1.7.0" + BINARY_DIR ${GOOGLETEST_LIB_DIR} + INSTALL_DIR ${GOOGLETEST_LIB_DIR} # Wrap download, configure and build steps in a script to log output LOG_CONFIGURE ON - LOG_BUILD ON) + LOG_BUILD ON + BUILD_BYPRODUCTS ${GOOGLETEST_LIB_DIR}/libgtest${STATIC_EXT} ${GOOGLETEST_LIB_DIR}/libgtest_main${STATIC_EXT} +) # Specify include dir ExternalProject_Get_Property(googletest source_dir) set(GTEST_INCLUDE_DIR ${source_dir}/include) # Specify MainTest's link libraries ExternalProject_Get_Property(googletest binary_dir) -set(GTEST_LIBRARIES ${binary_dir}/libgtest.a ${binary_dir}/libgtest_main.a) +set(GTEST_LIBRARIES ${binary_dir}/libgtest${STATIC_EXT} ${binary_dir}/libgtest_main${STATIC_EXT}) add_dependencies(test-resources googletest) list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES}) @@ -404,19 +418,17 @@ list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES}) set(STORM_HAVE_INTELTBB OFF) if (STORM_USE_INTELTBB) - # Point to shipped TBB directory - set(TBB_INSTALL_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/tbb42_20140122_merged-win-lin-mac") find_package(TBB QUIET REQUIRED) if (TBB_FOUND) - message(STATUS "StoRM - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.") - message(STATUS "StoRM - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.") + message(STATUS "Storm - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.") + message(STATUS "Storm - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.") set(STORM_HAVE_INTELTBB ON) link_directories(${TBB_LIBRARY_DIRS}) include_directories(${TBB_INCLUDE_DIRS}) list(APPEND STORM_LINK_LIBRARIES tbb tbbmalloc) else(TBB_FOUND) - message(FATAL_ERROR "StoRM - TBB was requested, but not found!") + message(FATAL_ERROR "Storm - TBB was requested, but not found.") endif(TBB_FOUND) endif(STORM_USE_INTELTBB) @@ -428,7 +440,7 @@ endif(STORM_USE_INTELTBB) find_package(Threads QUIET REQUIRED) if (NOT Threads_FOUND) - message(FATAL_ERROR "StoRM - Threads was requested, but not found!") + message(FATAL_ERROR "Storm - Threads was requested, but not found.") endif() include_directories(${THREADS_INCLUDE_DIRS}) list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) @@ -436,12 +448,6 @@ if (STORM_USE_COTIRE) target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT}) endif(STORM_USE_COTIRE) -if (MSVC) - # Add the DebugHelper DLL - set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} Dbghelp.lib") - target_link_libraries(storm "Dbghelp.lib") -endif(MSVC) - ############################################################# ## ## CUDA Library generation @@ -468,18 +474,17 @@ set(STORM_CPP_CUDAFORSTORM_DEF "undef") if(ENABLE_CUDA) - # Test for type alignment try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp" COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR ) if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT) - message(FATAL_ERROR "StoRM (CudaPlugin) - Could not test type alignment, there was an Error while compiling the file ${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp: ${OUTPUT_TEST_VAR}") + message(FATAL_ERROR "Storm (CudaPlugin) - Could not test type alignment, there was an Error while compiling the file ${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp: ${OUTPUT_TEST_VAR}") elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0) message(STATUS "StoRM (CudaPlugin) - Result of Type Alignment Check: OK.") else() - message(FATAL_ERROR "StoRM (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})") + message(FATAL_ERROR "Storm (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})") endif() # Test for Float 64bit Alignment @@ -488,15 +493,15 @@ if(ENABLE_CUDA) COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR ) if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT) - message(FATAL_ERROR "StoRM (CudaPlugin) - Could not test float type alignment, there was an Error while compiling the file ${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp: ${OUTPUT_TEST_VAR}") + message(FATAL_ERROR "Storm (CudaPlugin) - Could not test float type alignment, there was an Error while compiling the file ${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp: ${OUTPUT_TEST_VAR}") elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2) - message(STATUS "StoRM (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.") + message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.") set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define") elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3) - message(STATUS "StoRM (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.") + message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.") set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef") else() - message(FATAL_ERROR "StoRM (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})") + message(FATAL_ERROR "Storm (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})") endif() # # Make a version file containing the current version from git. @@ -515,7 +520,7 @@ if(ENABLE_CUDA) else() set(STORM_CUDAPLUGIN_VERSION_DIRTY 0) endif() - message(STATUS "StoRM (CudaPlugin) - Version information: ${STORM_CUDAPLUGIN_VERSION_MAJOR}.${STORM_CUDAPLUGIN_VERSION_MINOR}.${STORM_CUDAPLUGIN_VERSION_PATCH} (${STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD} commits ahead of Tag) build from ${STORM_CUDAPLUGIN_VERSION_HASH} (Dirty: ${STORM_CUDAPLUGIN_VERSION_DIRTY})") + message(STATUS "Storm (CudaPlugin) - Version information: ${STORM_CUDAPLUGIN_VERSION_MAJOR}.${STORM_CUDAPLUGIN_VERSION_MINOR}.${STORM_CUDAPLUGIN_VERSION_PATCH} (${STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD} commits ahead of Tag) build from ${STORM_CUDAPLUGIN_VERSION_HASH} (Dirty: ${STORM_CUDAPLUGIN_VERSION_DIRTY})") # Configure a header file to pass some of the CMake settings to the source code @@ -549,9 +554,9 @@ if(ENABLE_CUDA) if(CUSP_FOUND) include_directories(${CUSP_INCLUDE_DIR}) cuda_include_directories(${CUSP_INCLUDE_DIR}) - message(STATUS "StoRM (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}") + message(STATUS "Storm (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}.") else() - message(FATAL_ERROR "StoRM (CudaPlugin) - Could not find CUSP!") + message(FATAL_ERROR "Storm (CudaPlugin) - Could not find CUSP.") endif() ############################################################# @@ -562,9 +567,9 @@ if(ENABLE_CUDA) if(THRUST_FOUND) include_directories(${THRUST_INCLUDE_DIR}) cuda_include_directories(${THRUST_INCLUDE_DIR}) - message(STATUS "StoRM (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}") + message(STATUS "Storm (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}.") else() - message(FATAL_ERROR "StoRM (CudaPlugin) - Could not find Thrust! Check your CUDA installation.") + message(FATAL_ERROR "Storm (CudaPlugin) - Could not find Thrust. Check your CUDA installation.") endif() include_directories(${CUDA_INCLUDE_DIRS}) @@ -574,7 +579,9 @@ if(ENABLE_CUDA) ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES} ) - message (STATUS "StoRM - Linking with CUDA") + message (STATUS "Storm - Linking with CUDA.") list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME}) include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/") endif() + +add_custom_target(copy_resources_headers DEPENDS ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp/sparsepp.h ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp/sparsepp.h) diff --git a/resources/3rdparty/carl/CMakeLists.txt b/resources/3rdparty/carl/CMakeLists.txt new file mode 100644 index 000000000..749b561aa --- /dev/null +++ b/resources/3rdparty/carl/CMakeLists.txt @@ -0,0 +1,25 @@ +project(carlext) +cmake_minimum_required(VERSION 3.3) +include(ExternalProject) + +option(STORM_3RDPARTY_BINARY_DIR "3rd party bin dir") + +message(STORM_3RDPARTY_BINARY_DIR: ${STORM_3RDPARTY_BINARY_DIR}) + +ExternalProject_Add(carl-config + GIT_REPOSITORY https://github.com/smtrat/carl + GIT_TAG master + PREFIX here + SOURCE_DIR source_dir + BINARY_DIR ${STORM_3RDPARTY_BINARY_DIR}/carl + CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBOOST_INCLUDEDIR=${Boost_INCLUDE_DIRS} -DBOOST_LIBRARYDIR=${Boost_LIBRARY_DIRS} -DBoost_NO_SYSTEM_PATHS=1 -DEXPORT_TO_CMAKE=0 -DUSE_CLN_NUMBERS=1 -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=1 -DCMAKE_INSTALL_PREFIX:PATH=${STORM_3RDPARTY_BINARY_DIR}/carl + BUILD_IN_SOURCE 0 + LOG_UPDATE OFF + LOG_CONFIGURE OFF + BUILD_COMMAND "" # Disable build step. + INSTALL_COMMAND "" # Disable install step too. +) +add_custom_target(build-carl) +add_dependencies(build-carl carl-config) + +message("done") diff --git a/resources/3rdparty/cpplint/cpplint.py b/resources/3rdparty/cpplint/cpplint.py deleted file mode 100644 index 526b9556d..000000000 --- a/resources/3rdparty/cpplint/cpplint.py +++ /dev/null @@ -1,3361 +0,0 @@ -#!/usr/bin/python -# -# Copyright (c) 2009 Google Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * 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. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "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 COPYRIGHT -# OWNER OR CONTRIBUTORS 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. - -# Here are some issues that I've had people identify in my code during reviews, -# that I think are possible to flag automatically in a lint tool. If these were -# caught by lint, it would save time both for myself and that of my reviewers. -# Most likely, some of these are beyond the scope of the current lint framework, -# but I think it is valuable to retain these wish-list items even if they cannot -# be immediately implemented. -# -# Suggestions -# ----------- -# - Check for no 'explicit' for multi-arg ctor -# - Check for boolean assign RHS in parens -# - Check for ctor initializer-list colon position and spacing -# - Check that if there's a ctor, there should be a dtor -# - Check accessors that return non-pointer member variables are -# declared const -# - Check accessors that return non-const pointer member vars are -# *not* declared const -# - Check for using public includes for testing -# - Check for spaces between brackets in one-line inline method -# - Check for no assert() -# - Check for spaces surrounding operators -# - Check for 0 in pointer context (should be NULL) -# - Check for 0 in char context (should be '\0') -# - Check for camel-case method name conventions for methods -# that are not simple inline getters and setters -# - Check that base classes have virtual destructors -# put " // namespace" after } that closes a namespace, with -# namespace's name after 'namespace' if it is named. -# - Do not indent namespace contents -# - Avoid inlining non-trivial constructors in header files -# include base/basictypes.h if DISALLOW_EVIL_CONSTRUCTORS is used -# - Check for old-school (void) cast for call-sites of functions -# ignored return value -# - Check gUnit usage of anonymous namespace -# - Check for class declaration order (typedefs, consts, enums, -# ctor(s?), dtor, friend declarations, methods, member vars) -# - -"""Does google-lint on c++ files. - -The goal of this script is to identify places in the code that *may* -be in non-compliance with google style. It does not attempt to fix -up these problems -- the point is to educate. It does also not -attempt to find all problems, or to ensure that everything it does -find is legitimately a problem. - -In particular, we can get very confused by /* and // inside strings! -We do a small hack, which is to ignore //'s with "'s after them on the -same line, but it is far from perfect (in either direction). -""" - -import codecs -import getopt -import math # for log -import os -import re -import sre_compile -import string -import sys -import unicodedata - - -_USAGE = """ -Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...] - [--counting=total|toplevel|detailed] - [file] ... - - The style guidelines this tries to follow are those in - http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml - - Every problem is given a confidence score from 1-5, with 5 meaning we are - certain of the problem, and 1 meaning it could be a legitimate construct. - This will miss some errors, and is not a substitute for a code review. - - To suppress false-positive errors of a certain category, add a - 'NOLINT(category)' comment to the line. NOLINT or NOLINT(*) - suppresses errors of all categories on that line. - - The files passed in will be linted; at least one file must be provided. - Linted extensions are .cc, .cpp, and .h. Other file types will be ignored. - - Flags: - - output=vs7 - By default, the output is formatted to ease emacs parsing. Visual Studio - compatible output (vs7) may also be used. Other formats are unsupported. - - verbose=# - Specify a number 0-5 to restrict errors to certain verbosity levels. - - filter=-x,+y,... - Specify a comma-separated list of category-filters to apply: only - error messages whose category names pass the filters will be printed. - (Category names are printed with the message and look like - "[whitespace/indent]".) Filters are evaluated left to right. - "-FOO" and "FOO" means "do not print categories that start with FOO". - "+FOO" means "do print categories that start with FOO". - - Examples: --filter=-whitespace,+whitespace/braces - --filter=whitespace,runtime/printf,+runtime/printf_format - --filter=-,+build/include_what_you_use - - To see a list of all the categories used in cpplint, pass no arg: - --filter= - - counting=total|toplevel|detailed - The total number of errors found is always printed. If - 'toplevel' is provided, then the count of errors in each of - the top-level categories like 'build' and 'whitespace' will - also be printed. If 'detailed' is provided, then a count - is provided for each category like 'build/class'. -""" - -# We categorize each error message we print. Here are the categories. -# We want an explicit list so we can list them all in cpplint --filter=. -# If you add a new error message with a new category, add it to the list -# here! cpplint_unittest.py should tell you if you forget to do this. -# \ used for clearer layout -- pylint: disable-msg=C6013 -_ERROR_CATEGORIES = [ - 'build/class', - 'build/deprecated', - 'build/endif_comment', - 'build/explicit_make_pair', - 'build/forward_decl', - 'build/header_guard', - 'build/include', - 'build/include_alpha', - 'build/include_order', - 'build/include_what_you_use', - 'build/namespaces', - 'build/printf_format', - 'build/storage_class', - 'legal/copyright', - 'readability/braces', - 'readability/casting', - 'readability/check', - 'readability/constructors', - 'readability/fn_size', - 'readability/function', - 'readability/multiline_comment', - 'readability/multiline_string', - 'readability/nolint', - 'readability/streams', - 'readability/todo', - 'readability/utf8', - 'runtime/arrays', - 'runtime/casting', - 'runtime/explicit', - 'runtime/int', - 'runtime/init', - 'runtime/invalid_increment', - 'runtime/member_string_references', - 'runtime/memset', - 'runtime/operator', - 'runtime/printf', - 'runtime/printf_format', - 'runtime/references', - 'runtime/rtti', - 'runtime/sizeof', - 'runtime/string', - 'runtime/threadsafe_fn', - 'runtime/virtual', - 'whitespace/blank_line', - 'whitespace/braces', - 'whitespace/comma', - 'whitespace/comments', - 'whitespace/end_of_line', - 'whitespace/ending_newline', - 'whitespace/indent', - 'whitespace/labels', - 'whitespace/line_length', - 'whitespace/newline', - 'whitespace/operators', - 'whitespace/parens', - 'whitespace/semicolon', - 'whitespace/tab', - 'whitespace/todo' - ] - -# The default state of the category filter. This is overrided by the --filter= -# flag. By default all errors are on, so only add here categories that should be -# off by default (i.e., categories that must be enabled by the --filter= flags). -# All entries here should start with a '-' or '+', as in the --filter= flag. -_DEFAULT_FILTERS = ['-build/include_alpha'] - -# We used to check for high-bit characters, but after much discussion we -# decided those were OK, as long as they were in UTF-8 and didn't represent -# hard-coded international strings, which belong in a separate i18n file. - -# Headers that we consider STL headers. -_STL_HEADERS = frozenset([ - 'algobase.h', 'algorithm', 'alloc.h', 'bitset', 'deque', 'exception', - 'function.h', 'functional', 'hash_map', 'hash_map.h', 'hash_set', - 'hash_set.h', 'iterator', 'list', 'list.h', 'map', 'memory', 'new', - 'pair.h', 'pthread_alloc', 'queue', 'set', 'set.h', 'sstream', 'stack', - 'stl_alloc.h', 'stl_relops.h', 'type_traits.h', - 'utility', 'vector', 'vector.h', - ]) - - -# Non-STL C++ system headers. -_CPP_HEADERS = frozenset([ - 'algo.h', 'builtinbuf.h', 'bvector.h', 'cassert', 'cctype', - 'cerrno', 'cfloat', 'ciso646', 'climits', 'clocale', 'cmath', - 'complex', 'complex.h', 'csetjmp', 'csignal', 'cstdarg', 'cstddef', - 'cstdio', 'cstdlib', 'cstring', 'ctime', 'cwchar', 'cwctype', - 'defalloc.h', 'deque.h', 'editbuf.h', 'exception', 'fstream', - 'fstream.h', 'hashtable.h', 'heap.h', 'indstream.h', 'iomanip', - 'iomanip.h', 'ios', 'iosfwd', 'iostream', 'iostream.h', 'istream', - 'istream.h', 'iterator.h', 'limits', 'map.h', 'multimap.h', 'multiset.h', - 'numeric', 'ostream', 'ostream.h', 'parsestream.h', 'pfstream.h', - 'PlotFile.h', 'procbuf.h', 'pthread_alloc.h', 'rope', 'rope.h', - 'ropeimpl.h', 'SFile.h', 'slist', 'slist.h', 'stack.h', 'stdexcept', - 'stdiostream.h', 'streambuf.h', 'stream.h', 'strfile.h', 'string', - 'strstream', 'strstream.h', 'tempbuf.h', 'tree.h', 'typeinfo', 'valarray', - ]) - - -# Assertion macros. These are defined in base/logging.h and -# testing/base/gunit.h. Note that the _M versions need to come first -# for substring matching to work. -_CHECK_MACROS = [ - 'DCHECK', 'CHECK', - 'EXPECT_TRUE_M', 'EXPECT_TRUE', - 'ASSERT_TRUE_M', 'ASSERT_TRUE', - 'EXPECT_FALSE_M', 'EXPECT_FALSE', - 'ASSERT_FALSE_M', 'ASSERT_FALSE', - ] - -# Replacement macros for CHECK/DCHECK/EXPECT_TRUE/EXPECT_FALSE -_CHECK_REPLACEMENT = dict([(m, {}) for m in _CHECK_MACROS]) - -for op, replacement in [('==', 'EQ'), ('!=', 'NE'), - ('>=', 'GE'), ('>', 'GT'), - ('<=', 'LE'), ('<', 'LT')]: - _CHECK_REPLACEMENT['DCHECK'][op] = 'DCHECK_%s' % replacement - _CHECK_REPLACEMENT['CHECK'][op] = 'CHECK_%s' % replacement - _CHECK_REPLACEMENT['EXPECT_TRUE'][op] = 'EXPECT_%s' % replacement - _CHECK_REPLACEMENT['ASSERT_TRUE'][op] = 'ASSERT_%s' % replacement - _CHECK_REPLACEMENT['EXPECT_TRUE_M'][op] = 'EXPECT_%s_M' % replacement - _CHECK_REPLACEMENT['ASSERT_TRUE_M'][op] = 'ASSERT_%s_M' % replacement - -for op, inv_replacement in [('==', 'NE'), ('!=', 'EQ'), - ('>=', 'LT'), ('>', 'LE'), - ('<=', 'GT'), ('<', 'GE')]: - _CHECK_REPLACEMENT['EXPECT_FALSE'][op] = 'EXPECT_%s' % inv_replacement - _CHECK_REPLACEMENT['ASSERT_FALSE'][op] = 'ASSERT_%s' % inv_replacement - _CHECK_REPLACEMENT['EXPECT_FALSE_M'][op] = 'EXPECT_%s_M' % inv_replacement - _CHECK_REPLACEMENT['ASSERT_FALSE_M'][op] = 'ASSERT_%s_M' % inv_replacement - - -# These constants define types of headers for use with -# _IncludeState.CheckNextIncludeOrder(). -_C_SYS_HEADER = 1 -_CPP_SYS_HEADER = 2 -_LIKELY_MY_HEADER = 3 -_POSSIBLE_MY_HEADER = 4 -_OTHER_HEADER = 5 - - -_regexp_compile_cache = {} - -# Finds occurrences of NOLINT or NOLINT(...). -_RE_SUPPRESSION = re.compile(r'\bNOLINT\b(\([^)]*\))?') - -# {str, set(int)}: a map from error categories to sets of linenumbers -# on which those errors are expected and should be suppressed. -_error_suppressions = {} - -def ParseNolintSuppressions(filename, raw_line, linenum, error): - """Updates the global list of error-suppressions. - - Parses any NOLINT comments on the current line, updating the global - error_suppressions store. Reports an error if the NOLINT comment - was malformed. - - Args: - filename: str, the name of the input file. - raw_line: str, the line of input text, with comments. - linenum: int, the number of the current line. - error: function, an error handler. - """ - # FIXME(adonovan): "NOLINT(" is misparsed as NOLINT(*). - matched = _RE_SUPPRESSION.search(raw_line) - if matched: - category = matched.group(1) - if category in (None, '(*)'): # => "suppress all" - _error_suppressions.setdefault(None, set()).add(linenum) - else: - if category.startswith('(') and category.endswith(')'): - category = category[1:-1] - if category in _ERROR_CATEGORIES: - _error_suppressions.setdefault(category, set()).add(linenum) - else: - error(filename, linenum, 'readability/nolint', 5, - 'Unknown NOLINT error category: %s' % category) - - -def ResetNolintSuppressions(): - "Resets the set of NOLINT suppressions to empty." - _error_suppressions.clear() - - -def IsErrorSuppressedByNolint(category, linenum): - """Returns true if the specified error category is suppressed on this line. - - Consults the global error_suppressions map populated by - ParseNolintSuppressions/ResetNolintSuppressions. - - Args: - category: str, the category of the error. - linenum: int, the current line number. - Returns: - bool, True iff the error should be suppressed due to a NOLINT comment. - """ - return (linenum in _error_suppressions.get(category, set()) or - linenum in _error_suppressions.get(None, set())) - -def Match(pattern, s): - """Matches the string with the pattern, caching the compiled regexp.""" - # The regexp compilation caching is inlined in both Match and Search for - # performance reasons; factoring it out into a separate function turns out - # to be noticeably expensive. - if not pattern in _regexp_compile_cache: - _regexp_compile_cache[pattern] = sre_compile.compile(pattern) - return _regexp_compile_cache[pattern].match(s) - - -def Search(pattern, s): - """Searches the string for the pattern, caching the compiled regexp.""" - if not pattern in _regexp_compile_cache: - _regexp_compile_cache[pattern] = sre_compile.compile(pattern) - return _regexp_compile_cache[pattern].search(s) - - -class _IncludeState(dict): - """Tracks line numbers for includes, and the order in which includes appear. - - As a dict, an _IncludeState object serves as a mapping between include - filename and line number on which that file was included. - - Call CheckNextIncludeOrder() once for each header in the file, passing - in the type constants defined above. Calls in an illegal order will - raise an _IncludeError with an appropriate error message. - - """ - # self._section will move monotonically through this set. If it ever - # needs to move backwards, CheckNextIncludeOrder will raise an error. - _INITIAL_SECTION = 0 - _MY_H_SECTION = 1 - _C_SECTION = 2 - _CPP_SECTION = 3 - _OTHER_H_SECTION = 4 - - _TYPE_NAMES = { - _C_SYS_HEADER: 'C system header', - _CPP_SYS_HEADER: 'C++ system header', - _LIKELY_MY_HEADER: 'header this file implements', - _POSSIBLE_MY_HEADER: 'header this file may implement', - _OTHER_HEADER: 'other header', - } - _SECTION_NAMES = { - _INITIAL_SECTION: "... nothing. (This can't be an error.)", - _MY_H_SECTION: 'a header this file implements', - _C_SECTION: 'C system header', - _CPP_SECTION: 'C++ system header', - _OTHER_H_SECTION: 'other header', - } - - def __init__(self): - dict.__init__(self) - # The name of the current section. - self._section = self._INITIAL_SECTION - # The path of last found header. - self._last_header = '' - - def CanonicalizeAlphabeticalOrder(self, header_path): - """Returns a path canonicalized for alphabetical comparison. - - - replaces "-" with "_" so they both cmp the same. - - removes '-inl' since we don't require them to be after the main header. - - lowercase everything, just in case. - - Args: - header_path: Path to be canonicalized. - - Returns: - Canonicalized path. - """ - return header_path.replace('-inl.h', '.h').replace('-', '_').lower() - - def IsInAlphabeticalOrder(self, header_path): - """Check if a header is in alphabetical order with the previous header. - - Args: - header_path: Header to be checked. - - Returns: - Returns true if the header is in alphabetical order. - """ - canonical_header = self.CanonicalizeAlphabeticalOrder(header_path) - if self._last_header > canonical_header: - return False - self._last_header = canonical_header - return True - - def CheckNextIncludeOrder(self, header_type): - """Returns a non-empty error message if the next header is out of order. - - This function also updates the internal state to be ready to check - the next include. - - Args: - header_type: One of the _XXX_HEADER constants defined above. - - Returns: - The empty string if the header is in the right order, or an - error message describing what's wrong. - - """ - error_message = ('Found %s after %s' % - (self._TYPE_NAMES[header_type], - self._SECTION_NAMES[self._section])) - - last_section = self._section - - if header_type == _C_SYS_HEADER: - if self._section <= self._C_SECTION: - self._section = self._C_SECTION - else: - self._last_header = '' - return error_message - elif header_type == _CPP_SYS_HEADER: - if self._section <= self._CPP_SECTION: - self._section = self._CPP_SECTION - else: - self._last_header = '' - return error_message - elif header_type == _LIKELY_MY_HEADER: - if self._section <= self._MY_H_SECTION: - self._section = self._MY_H_SECTION - else: - self._section = self._OTHER_H_SECTION - elif header_type == _POSSIBLE_MY_HEADER: - if self._section <= self._MY_H_SECTION: - self._section = self._MY_H_SECTION - else: - # This will always be the fallback because we're not sure - # enough that the header is associated with this file. - self._section = self._OTHER_H_SECTION - else: - assert header_type == _OTHER_HEADER - self._section = self._OTHER_H_SECTION - - if last_section != self._section: - self._last_header = '' - - return '' - - -class _CppLintState(object): - """Maintains module-wide state..""" - - def __init__(self): - self.verbose_level = 1 # global setting. - self.error_count = 0 # global count of reported errors - # filters to apply when emitting error messages - self.filters = _DEFAULT_FILTERS[:] - self.counting = 'total' # In what way are we counting errors? - self.errors_by_category = {} # string to int dict storing error counts - - # output format: - # "emacs" - format that emacs can parse (default) - # "vs7" - format that Microsoft Visual Studio 7 can parse - self.output_format = 'emacs' - - def SetOutputFormat(self, output_format): - """Sets the output format for errors.""" - self.output_format = output_format - - def SetVerboseLevel(self, level): - """Sets the module's verbosity, and returns the previous setting.""" - last_verbose_level = self.verbose_level - self.verbose_level = level - return last_verbose_level - - def SetCountingStyle(self, counting_style): - """Sets the module's counting options.""" - self.counting = counting_style - - def SetFilters(self, filters): - """Sets the error-message filters. - - These filters are applied when deciding whether to emit a given - error message. - - Args: - filters: A string of comma-separated filters (eg "+whitespace/indent"). - Each filter should start with + or -; else we die. - - Raises: - ValueError: The comma-separated filters did not all start with '+' or '-'. - E.g. "-,+whitespace,-whitespace/indent,whitespace/badfilter" - """ - # Default filters always have less priority than the flag ones. - self.filters = _DEFAULT_FILTERS[:] - for filt in filters.split(','): - clean_filt = filt.strip() - if clean_filt: - self.filters.append(clean_filt) - for filt in self.filters: - if not (filt.startswith('+') or filt.startswith('-')): - raise ValueError('Every filter in --filters must start with + or -' - ' (%s does not)' % filt) - - def ResetErrorCounts(self): - """Sets the module's error statistic back to zero.""" - self.error_count = 0 - self.errors_by_category = {} - - def IncrementErrorCount(self, category): - """Bumps the module's error statistic.""" - self.error_count += 1 - if self.counting in ('toplevel', 'detailed'): - if self.counting != 'detailed': - category = category.split('/')[0] - if category not in self.errors_by_category: - self.errors_by_category[category] = 0 - self.errors_by_category[category] += 1 - - def PrintErrorCounts(self): - """Print a summary of errors by category, and the total.""" - for category, count in self.errors_by_category.iteritems(): - sys.stderr.write('Category \'%s\' errors found: %d\n' % - (category, count)) - sys.stderr.write('Total errors found: %d\n' % self.error_count) - -_cpplint_state = _CppLintState() - - -def _OutputFormat(): - """Gets the module's output format.""" - return _cpplint_state.output_format - - -def _SetOutputFormat(output_format): - """Sets the module's output format.""" - _cpplint_state.SetOutputFormat(output_format) - - -def _VerboseLevel(): - """Returns the module's verbosity setting.""" - return _cpplint_state.verbose_level - - -def _SetVerboseLevel(level): - """Sets the module's verbosity, and returns the previous setting.""" - return _cpplint_state.SetVerboseLevel(level) - - -def _SetCountingStyle(level): - """Sets the module's counting options.""" - _cpplint_state.SetCountingStyle(level) - - -def _Filters(): - """Returns the module's list of output filters, as a list.""" - return _cpplint_state.filters - - -def _SetFilters(filters): - """Sets the module's error-message filters. - - These filters are applied when deciding whether to emit a given - error message. - - Args: - filters: A string of comma-separated filters (eg "whitespace/indent"). - Each filter should start with + or -; else we die. - """ - _cpplint_state.SetFilters(filters) - - -class _FunctionState(object): - """Tracks current function name and the number of lines in its body.""" - - _NORMAL_TRIGGER = 250 # for --v=0, 500 for --v=1, etc. - _TEST_TRIGGER = 400 # about 50% more than _NORMAL_TRIGGER. - - def __init__(self): - self.in_a_function = False - self.lines_in_function = 0 - self.current_function = '' - - def Begin(self, function_name): - """Start analyzing function body. - - Args: - function_name: The name of the function being tracked. - """ - self.in_a_function = True - self.lines_in_function = 0 - self.current_function = function_name - - def Count(self): - """Count line in current function body.""" - if self.in_a_function: - self.lines_in_function += 1 - - def Check(self, error, filename, linenum): - """Report if too many lines in function body. - - Args: - error: The function to call with any errors found. - filename: The name of the current file. - linenum: The number of the line to check. - """ - if Match(r'T(EST|est)', self.current_function): - base_trigger = self._TEST_TRIGGER - else: - base_trigger = self._NORMAL_TRIGGER - trigger = base_trigger * 2**_VerboseLevel() - - if self.lines_in_function > trigger: - error_level = int(math.log(self.lines_in_function / base_trigger, 2)) - # 50 => 0, 100 => 1, 200 => 2, 400 => 3, 800 => 4, 1600 => 5, ... - if error_level > 5: - error_level = 5 - error(filename, linenum, 'readability/fn_size', error_level, - 'Small and focused functions are preferred:' - ' %s has %d non-comment lines' - ' (error triggered by exceeding %d lines).' % ( - self.current_function, self.lines_in_function, trigger)) - - def End(self): - """Stop analyzing function body.""" - self.in_a_function = False - - -class _IncludeError(Exception): - """Indicates a problem with the include order in a file.""" - pass - - -class FileInfo: - """Provides utility functions for filenames. - - FileInfo provides easy access to the components of a file's path - relative to the project root. - """ - - def __init__(self, filename): - self._filename = filename - - def FullName(self): - """Make Windows paths like Unix.""" - return os.path.abspath(self._filename).replace('\\', '/') - - def RepositoryName(self): - """FullName after removing the local path to the repository. - - If we have a real absolute path name here we can try to do something smart: - detecting the root of the checkout and truncating /path/to/checkout from - the name so that we get header guards that don't include things like - "C:\Documents and Settings\..." or "/home/username/..." in them and thus - people on different computers who have checked the source out to different - locations won't see bogus errors. - """ - fullname = self.FullName() - - if os.path.exists(fullname): - project_dir = os.path.dirname(fullname) - - if os.path.exists(os.path.join(project_dir, ".svn")): - # If there's a .svn file in the current directory, we recursively look - # up the directory tree for the top of the SVN checkout - root_dir = project_dir - one_up_dir = os.path.dirname(root_dir) - while os.path.exists(os.path.join(one_up_dir, ".svn")): - root_dir = os.path.dirname(root_dir) - one_up_dir = os.path.dirname(one_up_dir) - - prefix = os.path.commonprefix([root_dir, project_dir]) - return fullname[len(prefix) + 1:] - - # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by - # searching up from the current path. - root_dir = os.path.dirname(fullname) - while (root_dir != os.path.dirname(root_dir) and - not os.path.exists(os.path.join(root_dir, ".git")) and - not os.path.exists(os.path.join(root_dir, ".hg")) and - not os.path.exists(os.path.join(root_dir, ".svn"))): - root_dir = os.path.dirname(root_dir) - - if (os.path.exists(os.path.join(root_dir, ".git")) or - os.path.exists(os.path.join(root_dir, ".hg")) or - os.path.exists(os.path.join(root_dir, ".svn"))): - prefix = os.path.commonprefix([root_dir, project_dir]) - return fullname[len(prefix) + 1:] - - # Don't know what to do; header guard warnings may be wrong... - return fullname - - def Split(self): - """Splits the file into the directory, basename, and extension. - - For 'chrome/browser/browser.cc', Split() would - return ('chrome/browser', 'browser', '.cc') - - Returns: - A tuple of (directory, basename, extension). - """ - - googlename = self.RepositoryName() - project, rest = os.path.split(googlename) - return (project,) + os.path.splitext(rest) - - def BaseName(self): - """File base name - text after the final slash, before the final period.""" - return self.Split()[1] - - def Extension(self): - """File extension - text following the final period.""" - return self.Split()[2] - - def NoExtension(self): - """File has no source file extension.""" - return '/'.join(self.Split()[0:2]) - - def IsSource(self): - """File has a source file extension.""" - return self.Extension()[1:] in ('c', 'cc', 'cpp', 'cxx') - - -def _ShouldPrintError(category, confidence, linenum): - """If confidence >= verbose, category passes filter and is not suppressed.""" - - # There are three ways we might decide not to print an error message: - # a "NOLINT(category)" comment appears in the source, - # the verbosity level isn't high enough, or the filters filter it out. - if IsErrorSuppressedByNolint(category, linenum): - return False - if confidence < _cpplint_state.verbose_level: - return False - - is_filtered = False - for one_filter in _Filters(): - if one_filter.startswith('-'): - if category.startswith(one_filter[1:]): - is_filtered = True - elif one_filter.startswith('+'): - if category.startswith(one_filter[1:]): - is_filtered = False - else: - assert False # should have been checked for in SetFilter. - if is_filtered: - return False - - return True - - -def Error(filename, linenum, category, confidence, message): - """Logs the fact we've found a lint error. - - We log where the error was found, and also our confidence in the error, - that is, how certain we are this is a legitimate style regression, and - not a misidentification or a use that's sometimes justified. - - False positives can be suppressed by the use of - "cpplint(category)" comments on the offending line. These are - parsed into _error_suppressions. - - Args: - filename: The name of the file containing the error. - linenum: The number of the line containing the error. - category: A string used to describe the "category" this bug - falls under: "whitespace", say, or "runtime". Categories - may have a hierarchy separated by slashes: "whitespace/indent". - confidence: A number from 1-5 representing a confidence score for - the error, with 5 meaning that we are certain of the problem, - and 1 meaning that it could be a legitimate construct. - message: The error message. - """ - if _ShouldPrintError(category, confidence, linenum): - _cpplint_state.IncrementErrorCount(category) - if _cpplint_state.output_format == 'vs7': - sys.stderr.write('%s(%s): %s [%s] [%d]\n' % ( - filename, linenum, message, category, confidence)) - else: - sys.stderr.write('%s:%s: %s [%s] [%d]\n' % ( - filename, linenum, message, category, confidence)) - - -# Matches standard C++ escape esequences per 2.13.2.3 of the C++ standard. -_RE_PATTERN_CLEANSE_LINE_ESCAPES = re.compile( - r'\\([abfnrtv?"\\\']|\d+|x[0-9a-fA-F]+)') -# Matches strings. Escape codes should already be removed by ESCAPES. -_RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES = re.compile(r'"[^"]*"') -# Matches characters. Escape codes should already be removed by ESCAPES. -_RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES = re.compile(r"'.'") -# Matches multi-line C++ comments. -# This RE is a little bit more complicated than one might expect, because we -# have to take care of space removals tools so we can handle comments inside -# statements better. -# The current rule is: We only clear spaces from both sides when we're at the -# end of the line. Otherwise, we try to remove spaces from the right side, -# if this doesn't work we try on left side but only if there's a non-character -# on the right. -_RE_PATTERN_CLEANSE_LINE_C_COMMENTS = re.compile( - r"""(\s*/\*.*\*/\s*$| - /\*.*\*/\s+| - \s+/\*.*\*/(?=\W)| - /\*.*\*/)""", re.VERBOSE) - - -def IsCppString(line): - """Does line terminate so, that the next symbol is in string constant. - - This function does not consider single-line nor multi-line comments. - - Args: - line: is a partial line of code starting from the 0..n. - - Returns: - True, if next character appended to 'line' is inside a - string constant. - """ - - line = line.replace(r'\\', 'XX') # after this, \\" does not match to \" - return ((line.count('"') - line.count(r'\"') - line.count("'\"'")) & 1) == 1 - - -def FindNextMultiLineCommentStart(lines, lineix): - """Find the beginning marker for a multiline comment.""" - while lineix < len(lines): - if lines[lineix].strip().startswith('/*'): - # Only return this marker if the comment goes beyond this line - if lines[lineix].strip().find('*/', 2) < 0: - return lineix - lineix += 1 - return len(lines) - - -def FindNextMultiLineCommentEnd(lines, lineix): - """We are inside a comment, find the end marker.""" - while lineix < len(lines): - if lines[lineix].strip().endswith('*/'): - return lineix - lineix += 1 - return len(lines) - - -def RemoveMultiLineCommentsFromRange(lines, begin, end): - """Clears a range of lines for multi-line comments.""" - # Having // dummy comments makes the lines non-empty, so we will not get - # unnecessary blank line warnings later in the code. - for i in range(begin, end): - lines[i] = '// dummy' - - -def RemoveMultiLineComments(filename, lines, error): - """Removes multiline (c-style) comments from lines.""" - lineix = 0 - while lineix < len(lines): - lineix_begin = FindNextMultiLineCommentStart(lines, lineix) - if lineix_begin >= len(lines): - return - lineix_end = FindNextMultiLineCommentEnd(lines, lineix_begin) - if lineix_end >= len(lines): - error(filename, lineix_begin + 1, 'readability/multiline_comment', 5, - 'Could not find end of multi-line comment') - return - RemoveMultiLineCommentsFromRange(lines, lineix_begin, lineix_end + 1) - lineix = lineix_end + 1 - - -def CleanseComments(line): - """Removes //-comments and single-line C-style /* */ comments. - - Args: - line: A line of C++ source. - - Returns: - The line with single-line comments removed. - """ - commentpos = line.find('//') - if commentpos != -1 and not IsCppString(line[:commentpos]): - line = line[:commentpos].rstrip() - # get rid of /* ... */ - return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) - - -class CleansedLines(object): - """Holds 3 copies of all lines with different preprocessing applied to them. - - 1) elided member contains lines without strings and comments, - 2) lines member contains lines without comments, and - 3) raw member contains all the lines without processing. - All these three members are of , and of the same length. - """ - - def __init__(self, lines): - self.elided = [] - self.lines = [] - self.raw_lines = lines - self.num_lines = len(lines) - for linenum in range(len(lines)): - self.lines.append(CleanseComments(lines[linenum])) - elided = self._CollapseStrings(lines[linenum]) - self.elided.append(CleanseComments(elided)) - - def NumLines(self): - """Returns the number of lines represented.""" - return self.num_lines - - @staticmethod - def _CollapseStrings(elided): - """Collapses strings and chars on a line to simple "" or '' blocks. - - We nix strings first so we're not fooled by text like '"http://"' - - Args: - elided: The line being processed. - - Returns: - The line with collapsed strings. - """ - if not _RE_PATTERN_INCLUDE.match(elided): - # Remove escaped characters first to make quote/single quote collapsing - # basic. Things that look like escaped characters shouldn't occur - # outside of strings and chars. - elided = _RE_PATTERN_CLEANSE_LINE_ESCAPES.sub('', elided) - elided = _RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES.sub("''", elided) - elided = _RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES.sub('""', elided) - return elided - - -def CloseExpression(clean_lines, linenum, pos): - """If input points to ( or { or [, finds the position that closes it. - - If lines[linenum][pos] points to a '(' or '{' or '[', finds the - linenum/pos that correspond to the closing of the expression. - - Args: - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - pos: A position on the line. - - Returns: - A tuple (line, linenum, pos) pointer *past* the closing brace, or - (line, len(lines), -1) if we never find a close. Note we ignore - strings and comments when matching; and the line we return is the - 'cleansed' line at linenum. - """ - - line = clean_lines.elided[linenum] - startchar = line[pos] - if startchar not in '({[': - return (line, clean_lines.NumLines(), -1) - if startchar == '(': endchar = ')' - if startchar == '[': endchar = ']' - if startchar == '{': endchar = '}' - - num_open = line.count(startchar) - line.count(endchar) - while linenum < clean_lines.NumLines() and num_open > 0: - linenum += 1 - line = clean_lines.elided[linenum] - num_open += line.count(startchar) - line.count(endchar) - # OK, now find the endchar that actually got us back to even - endpos = len(line) - while num_open >= 0: - endpos = line.rfind(')', 0, endpos) - num_open -= 1 # chopped off another ) - return (line, linenum, endpos + 1) - - -def CheckForCopyright(filename, lines, error): - """Logs an error if no Copyright message appears at the top of the file.""" - - # We'll say it should occur by line 10. Don't forget there's a - # dummy line at the front. - for line in xrange(1, min(len(lines), 11)): - if re.search(r'Copyright', lines[line], re.I): break - else: # means no copyright line was found - error(filename, 0, 'legal/copyright', 5, - 'No copyright message found. ' - 'You should have a line: "Copyright [year] "') - - -def GetHeaderGuardCPPVariable(filename): - """Returns the CPP variable that should be used as a header guard. - - Args: - filename: The name of a C++ header file. - - Returns: - The CPP variable that should be used as a header guard in the - named file. - - """ - - # Restores original filename in case that cpplint is invoked from Emacs's - # flymake. - filename = re.sub(r'_flymake\.h$', '.h', filename) - - fileinfo = FileInfo(filename) - return re.sub(r'[-./\s]', '_', fileinfo.RepositoryName()).upper() + '_' - - -def CheckForHeaderGuard(filename, lines, error): - """Checks that the file contains a header guard. - - Logs an error if no #ifndef header guard is present. For other - headers, checks that the full pathname is used. - - Args: - filename: The name of the C++ header file. - lines: An array of strings, each representing a line of the file. - error: The function to call with any errors found. - """ - - cppvar = GetHeaderGuardCPPVariable(filename) - - ifndef = None - ifndef_linenum = 0 - define = None - endif = None - endif_linenum = 0 - for linenum, line in enumerate(lines): - linesplit = line.split() - if len(linesplit) >= 2: - # find the first occurrence of #ifndef and #define, save arg - if not ifndef and linesplit[0] == '#ifndef': - # set ifndef to the header guard presented on the #ifndef line. - ifndef = linesplit[1] - ifndef_linenum = linenum - if not define and linesplit[0] == '#define': - define = linesplit[1] - # find the last occurrence of #endif, save entire line - if line.startswith('#endif'): - endif = line - endif_linenum = linenum - - if not ifndef: - error(filename, 0, 'build/header_guard', 5, - 'No #ifndef header guard found, suggested CPP variable is: %s' % - cppvar) - return - - if not define: - error(filename, 0, 'build/header_guard', 5, - 'No #define header guard found, suggested CPP variable is: %s' % - cppvar) - return - - # The guard should be PATH_FILE_H_, but we also allow PATH_FILE_H__ - # for backward compatibility. - if ifndef != cppvar: - error_level = 0 - if ifndef != cppvar + '_': - error_level = 5 - - ParseNolintSuppressions(filename, lines[ifndef_linenum], ifndef_linenum, - error) - error(filename, ifndef_linenum, 'build/header_guard', error_level, - '#ifndef header guard has wrong style, please use: %s' % cppvar) - - if define != ifndef: - error(filename, 0, 'build/header_guard', 5, - '#ifndef and #define don\'t match, suggested CPP variable is: %s' % - cppvar) - return - - if endif != ('#endif // %s' % cppvar): - error_level = 0 - if endif != ('#endif // %s' % (cppvar + '_')): - error_level = 5 - - ParseNolintSuppressions(filename, lines[endif_linenum], endif_linenum, - error) - error(filename, endif_linenum, 'build/header_guard', error_level, - '#endif line should be "#endif // %s"' % cppvar) - - -def CheckForUnicodeReplacementCharacters(filename, lines, error): - """Logs an error for each line containing Unicode replacement characters. - - These indicate that either the file contained invalid UTF-8 (likely) - or Unicode replacement characters (which it shouldn't). Note that - it's possible for this to throw off line numbering if the invalid - UTF-8 occurred adjacent to a newline. - - Args: - filename: The name of the current file. - lines: An array of strings, each representing a line of the file. - error: The function to call with any errors found. - """ - for linenum, line in enumerate(lines): - if u'\ufffd' in line: - error(filename, linenum, 'readability/utf8', 5, - 'Line contains invalid UTF-8 (or Unicode replacement character).') - - -def CheckForNewlineAtEOF(filename, lines, error): - """Logs an error if there is no newline char at the end of the file. - - Args: - filename: The name of the current file. - lines: An array of strings, each representing a line of the file. - error: The function to call with any errors found. - """ - - # The array lines() was created by adding two newlines to the - # original file (go figure), then splitting on \n. - # To verify that the file ends in \n, we just have to make sure the - # last-but-two element of lines() exists and is empty. - if len(lines) < 3 or lines[-2]: - error(filename, len(lines) - 2, 'whitespace/ending_newline', 5, - 'Could not find a newline character at the end of the file.') - - -def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error): - """Logs an error if we see /* ... */ or "..." that extend past one line. - - /* ... */ comments are legit inside macros, for one line. - Otherwise, we prefer // comments, so it's ok to warn about the - other. Likewise, it's ok for strings to extend across multiple - lines, as long as a line continuation character (backslash) - terminates each line. Although not currently prohibited by the C++ - style guide, it's ugly and unnecessary. We don't do well with either - in this lint program, so we warn about both. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - # Remove all \\ (escaped backslashes) from the line. They are OK, and the - # second (escaped) slash may trigger later \" detection erroneously. - line = line.replace('\\\\', '') - - if line.count('/*') > line.count('*/'): - error(filename, linenum, 'readability/multiline_comment', 5, - 'Complex multi-line /*...*/-style comment found. ' - 'Lint may give bogus warnings. ' - 'Consider replacing these with //-style comments, ' - 'with #if 0...#endif, ' - 'or with more clearly structured multi-line comments.') - - if (line.count('"') - line.count('\\"')) % 2: - error(filename, linenum, 'readability/multiline_string', 5, - 'Multi-line string ("...") found. This lint script doesn\'t ' - 'do well with such strings, and may give bogus warnings. They\'re ' - 'ugly and unnecessary, and you should use concatenation instead".') - - -threading_list = ( - ('asctime(', 'asctime_r('), - ('ctime(', 'ctime_r('), - ('getgrgid(', 'getgrgid_r('), - ('getgrnam(', 'getgrnam_r('), - ('getlogin(', 'getlogin_r('), - ('getpwnam(', 'getpwnam_r('), - ('getpwuid(', 'getpwuid_r('), - ('gmtime(', 'gmtime_r('), - ('localtime(', 'localtime_r('), - ('rand(', 'rand_r('), - ('readdir(', 'readdir_r('), - ('strtok(', 'strtok_r('), - ('ttyname(', 'ttyname_r('), - ) - - -def CheckPosixThreading(filename, clean_lines, linenum, error): - """Checks for calls to thread-unsafe functions. - - Much code has been originally written without consideration of - multi-threading. Also, engineers are relying on their old experience; - they have learned posix before threading extensions were added. These - tests guide the engineers to use thread-safe functions (when using - posix directly). - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - for single_thread_function, multithread_safe_function in threading_list: - ix = line.find(single_thread_function) - # Comparisons made explicit for clarity -- pylint: disable-msg=C6403 - if ix >= 0 and (ix == 0 or (not line[ix - 1].isalnum() and - line[ix - 1] not in ('_', '.', '>'))): - error(filename, linenum, 'runtime/threadsafe_fn', 2, - 'Consider using ' + multithread_safe_function + - '...) instead of ' + single_thread_function + - '...) for improved thread safety.') - - -# Matches invalid increment: *count++, which moves pointer instead of -# incrementing a value. -_RE_PATTERN_INVALID_INCREMENT = re.compile( - r'^\s*\*\w+(\+\+|--);') - - -def CheckInvalidIncrement(filename, clean_lines, linenum, error): - """Checks for invalid increment *count++. - - For example following function: - void increment_counter(int* count) { - *count++; - } - is invalid, because it effectively does count++, moving pointer, and should - be replaced with ++*count, (*count)++ or *count += 1. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - if _RE_PATTERN_INVALID_INCREMENT.match(line): - error(filename, linenum, 'runtime/invalid_increment', 5, - 'Changing pointer instead of value (or unused value of operator*).') - - -class _ClassInfo(object): - """Stores information about a class.""" - - def __init__(self, name, clean_lines, linenum): - self.name = name - self.linenum = linenum - self.seen_open_brace = False - self.is_derived = False - self.virtual_method_linenumber = None - self.has_virtual_destructor = False - self.brace_depth = 0 - - # Try to find the end of the class. This will be confused by things like: - # class A { - # } *x = { ... - # - # But it's still good enough for CheckSectionSpacing. - self.last_line = 0 - depth = 0 - for i in range(linenum, clean_lines.NumLines()): - line = clean_lines.lines[i] - depth += line.count('{') - line.count('}') - if not depth: - self.last_line = i - break - - -class _ClassState(object): - """Holds the current state of the parse relating to class declarations. - - It maintains a stack of _ClassInfos representing the parser's guess - as to the current nesting of class declarations. The innermost class - is at the top (back) of the stack. Typically, the stack will either - be empty or have exactly one entry. - """ - - def __init__(self): - self.classinfo_stack = [] - - def CheckFinished(self, filename, error): - """Checks that all classes have been completely parsed. - - Call this when all lines in a file have been processed. - Args: - filename: The name of the current file. - error: The function to call with any errors found. - """ - if self.classinfo_stack: - # Note: This test can result in false positives if #ifdef constructs - # get in the way of brace matching. See the testBuildClass test in - # cpplint_unittest.py for an example of this. - error(filename, self.classinfo_stack[0].linenum, 'build/class', 5, - 'Failed to find complete declaration of class %s' % - self.classinfo_stack[0].name) - - -def CheckForNonStandardConstructs(filename, clean_lines, linenum, - class_state, error): - """Logs an error if we see certain non-ANSI constructs ignored by gcc-2. - - Complain about several constructs which gcc-2 accepts, but which are - not standard C++. Warning about these in lint is one way to ease the - transition to new compilers. - - put storage class first (e.g. "static const" instead of "const static"). - - "%lld" instead of %qd" in printf-type functions. - - "%1$d" is non-standard in printf-type functions. - - "\%" is an undefined character escape sequence. - - text after #endif is not allowed. - - invalid inner-style forward declaration. - - >? and ?= and )\?=?\s*(\w+|[+-]?\d+)(\.\d*)?', - line): - error(filename, linenum, 'build/deprecated', 3, - '>? and ))?' - # r'\s*const\s*' + type_name + '\s*&\s*\w+\s*;' - error(filename, linenum, 'runtime/member_string_references', 2, - 'const string& members are dangerous. It is much better to use ' - 'alternatives, such as pointers or simple constants.') - - # Track class entry and exit, and attempt to find cases within the - # class declaration that don't meet the C++ style - # guidelines. Tracking is very dependent on the code matching Google - # style guidelines, but it seems to perform well enough in testing - # to be a worthwhile addition to the checks. - classinfo_stack = class_state.classinfo_stack - # Look for a class declaration. The regexp accounts for decorated classes - # such as in: - # class LOCKABLE API Object { - # }; - class_decl_match = Match( - r'\s*(template\s*<[\w\s<>,:]*>\s*)?' - '(class|struct)\s+([A-Z_]+\s+)*(\w+(::\w+)*)', line) - if class_decl_match: - classinfo_stack.append(_ClassInfo( - class_decl_match.group(4), clean_lines, linenum)) - - # Everything else in this function uses the top of the stack if it's - # not empty. - if not classinfo_stack: - return - - classinfo = classinfo_stack[-1] - - # If the opening brace hasn't been seen look for it and also - # parent class declarations. - if not classinfo.seen_open_brace: - # If the line has a ';' in it, assume it's a forward declaration or - # a single-line class declaration, which we won't process. - if line.find(';') != -1: - classinfo_stack.pop() - return - classinfo.seen_open_brace = (line.find('{') != -1) - # Look for a bare ':' - if Search('(^|[^:]):($|[^:])', line): - classinfo.is_derived = True - if not classinfo.seen_open_brace: - return # Everything else in this function is for after open brace - - # The class may have been declared with namespace or classname qualifiers. - # The constructor and destructor will not have those qualifiers. - base_classname = classinfo.name.split('::')[-1] - - # Look for single-argument constructors that aren't marked explicit. - # Technically a valid construct, but against style. - args = Match(r'\s+(?:inline\s+)?%s\s*\(([^,()]+)\)' - % re.escape(base_classname), - line) - if (args and - args.group(1) != 'void' and - not Match(r'(const\s+)?%s\s*(?:<\w+>\s*)?&' % re.escape(base_classname), - args.group(1).strip())): - error(filename, linenum, 'runtime/explicit', 5, - 'Single-argument constructors should be marked explicit.') - - # Look for methods declared virtual. - if Search(r'\bvirtual\b', line): - classinfo.virtual_method_linenumber = linenum - # Only look for a destructor declaration on the same line. It would - # be extremely unlikely for the destructor declaration to occupy - # more than one line. - if Search(r'~%s\s*\(' % base_classname, line): - classinfo.has_virtual_destructor = True - - # Look for class end. - brace_depth = classinfo.brace_depth - brace_depth = brace_depth + line.count('{') - line.count('}') - if brace_depth <= 0: - classinfo = classinfo_stack.pop() - # Try to detect missing virtual destructor declarations. - # For now, only warn if a non-derived class with virtual methods lacks - # a virtual destructor. This is to make it less likely that people will - # declare derived virtual destructors without declaring the base - # destructor virtual. - if ((classinfo.virtual_method_linenumber is not None) and - (not classinfo.has_virtual_destructor) and - (not classinfo.is_derived)): # Only warn for base classes - error(filename, classinfo.linenum, 'runtime/virtual', 4, - 'The class %s probably needs a virtual destructor due to ' - 'having virtual method(s), one declared at line %d.' - % (classinfo.name, classinfo.virtual_method_linenumber)) - else: - classinfo.brace_depth = brace_depth - - -def CheckSpacingForFunctionCall(filename, line, linenum, error): - """Checks for the correctness of various spacing around function calls. - - Args: - filename: The name of the current file. - line: The text of the line to check. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - - # Since function calls often occur inside if/for/while/switch - # expressions - which have their own, more liberal conventions - we - # first see if we should be looking inside such an expression for a - # function call, to which we can apply more strict standards. - fncall = line # if there's no control flow construct, look at whole line - for pattern in (r'\bif\s*\((.*)\)\s*{', - r'\bfor\s*\((.*)\)\s*{', - r'\bwhile\s*\((.*)\)\s*[{;]', - r'\bswitch\s*\((.*)\)\s*{'): - match = Search(pattern, line) - if match: - fncall = match.group(1) # look inside the parens for function calls - break - - # Except in if/for/while/switch, there should never be space - # immediately inside parens (eg "f( 3, 4 )"). We make an exception - # for nested parens ( (a+b) + c ). Likewise, there should never be - # a space before a ( when it's a function argument. I assume it's a - # function argument when the char before the whitespace is legal in - # a function name (alnum + _) and we're not starting a macro. Also ignore - # pointers and references to arrays and functions coz they're too tricky: - # we use a very simple way to recognize these: - # " (something)(maybe-something)" or - # " (something)(maybe-something," or - # " (something)[something]" - # Note that we assume the contents of [] to be short enough that - # they'll never need to wrap. - if ( # Ignore control structures. - not Search(r'\b(if|for|while|switch|return|delete)\b', fncall) and - # Ignore pointers/references to functions. - not Search(r' \([^)]+\)\([^)]*(\)|,$)', fncall) and - # Ignore pointers/references to arrays. - not Search(r' \([^)]+\)\[[^\]]+\]', fncall)): - if Search(r'\w\s*\(\s(?!\s*\\$)', fncall): # a ( used for a fn call - error(filename, linenum, 'whitespace/parens', 4, - 'Extra space after ( in function call') - elif Search(r'\(\s+(?!(\s*\\)|\()', fncall): - error(filename, linenum, 'whitespace/parens', 2, - 'Extra space after (') - if (Search(r'\w\s+\(', fncall) and - not Search(r'#\s*define|typedef', fncall)): - error(filename, linenum, 'whitespace/parens', 4, - 'Extra space before ( in function call') - # If the ) is followed only by a newline or a { + newline, assume it's - # part of a control statement (if/while/etc), and don't complain - if Search(r'[^)]\s+\)\s*[^{\s]', fncall): - # If the closing parenthesis is preceded by only whitespaces, - # try to give a more descriptive error message. - if Search(r'^\s+\)', fncall): - error(filename, linenum, 'whitespace/parens', 2, - 'Closing ) should be moved to the previous line') - else: - error(filename, linenum, 'whitespace/parens', 2, - 'Extra space before )') - - -def IsBlankLine(line): - """Returns true if the given line is blank. - - We consider a line to be blank if the line is empty or consists of - only white spaces. - - Args: - line: A line of a string. - - Returns: - True, if the given line is blank. - """ - return not line or line.isspace() - - -def CheckForFunctionLengths(filename, clean_lines, linenum, - function_state, error): - """Reports for long function bodies. - - For an overview why this is done, see: - http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions - - Uses a simplistic algorithm assuming other style guidelines - (especially spacing) are followed. - Only checks unindented functions, so class members are unchecked. - Trivial bodies are unchecked, so constructors with huge initializer lists - may be missed. - Blank/comment lines are not counted so as to avoid encouraging the removal - of vertical space and comments just to get through a lint check. - NOLINT *on the last line of a function* disables this check. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - function_state: Current function name and lines in body so far. - error: The function to call with any errors found. - """ - lines = clean_lines.lines - line = lines[linenum] - raw = clean_lines.raw_lines - raw_line = raw[linenum] - joined_line = '' - - starting_func = False - regexp = r'(\w(\w|::|\*|\&|\s)*)\(' # decls * & space::name( ... - match_result = Match(regexp, line) - if match_result: - # If the name is all caps and underscores, figure it's a macro and - # ignore it, unless it's TEST or TEST_F. - function_name = match_result.group(1).split()[-1] - if function_name == 'TEST' or function_name == 'TEST_F' or ( - not Match(r'[A-Z_]+$', function_name)): - starting_func = True - - if starting_func: - body_found = False - for start_linenum in xrange(linenum, clean_lines.NumLines()): - start_line = lines[start_linenum] - joined_line += ' ' + start_line.lstrip() - if Search(r'(;|})', start_line): # Declarations and trivial functions - body_found = True - break # ... ignore - elif Search(r'{', start_line): - body_found = True - function = Search(r'((\w|:)*)\(', line).group(1) - if Match(r'TEST', function): # Handle TEST... macros - parameter_regexp = Search(r'(\(.*\))', joined_line) - if parameter_regexp: # Ignore bad syntax - function += parameter_regexp.group(1) - else: - function += '()' - function_state.Begin(function) - break - if not body_found: - # No body for the function (or evidence of a non-function) was found. - error(filename, linenum, 'readability/fn_size', 5, - 'Lint failed to find start of function body.') - elif Match(r'^\}\s*$', line): # function end - function_state.Check(error, filename, linenum) - function_state.End() - elif not Match(r'^\s*$', line): - function_state.Count() # Count non-blank/non-comment lines. - - -_RE_PATTERN_TODO = re.compile(r'^//(\s*)TODO(\(.+?\))?:?(\s|$)?') - - -def CheckComment(comment, filename, linenum, error): - """Checks for common mistakes in TODO comments. - - Args: - comment: The text of the comment from the line in question. - filename: The name of the current file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - match = _RE_PATTERN_TODO.match(comment) - if match: - # One whitespace is correct; zero whitespace is handled elsewhere. - leading_whitespace = match.group(1) - if len(leading_whitespace) > 1: - error(filename, linenum, 'whitespace/todo', 2, - 'Too many spaces before TODO') - - username = match.group(2) - if not username: - error(filename, linenum, 'readability/todo', 2, - 'Missing username in TODO; it should look like ' - '"// TODO(my_username): Stuff."') - - middle_whitespace = match.group(3) - # Comparisons made explicit for correctness -- pylint: disable-msg=C6403 - if middle_whitespace != ' ' and middle_whitespace != '': - error(filename, linenum, 'whitespace/todo', 2, - 'TODO(my_username) should be followed by a space') - - -def CheckSpacing(filename, clean_lines, linenum, error): - """Checks for the correctness of various spacing issues in the code. - - Things we check for: spaces around operators, spaces after - if/for/while/switch, no spaces around parens in function calls, two - spaces between code and comment, don't start a block with a blank - line, don't end a function with a blank line, don't add a blank line - after public/protected/private, don't have too many blank lines in a row. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - - raw = clean_lines.raw_lines - line = raw[linenum] - - # Before nixing comments, check if the line is blank for no good - # reason. This includes the first line after a block is opened, and - # blank lines at the end of a function (ie, right before a line like '}' - if IsBlankLine(line): - elided = clean_lines.elided - prev_line = elided[linenum - 1] - prevbrace = prev_line.rfind('{') - # TODO(unknown): Don't complain if line before blank line, and line after, - # both start with alnums and are indented the same amount. - # This ignores whitespace at the start of a namespace block - # because those are not usually indented. - if (prevbrace != -1 and prev_line[prevbrace:].find('}') == -1 - and prev_line[:prevbrace].find('namespace') == -1): - # OK, we have a blank line at the start of a code block. Before we - # complain, we check if it is an exception to the rule: The previous - # non-empty line has the parameters of a function header that are indented - # 4 spaces (because they did not fit in a 80 column line when placed on - # the same line as the function name). We also check for the case where - # the previous line is indented 6 spaces, which may happen when the - # initializers of a constructor do not fit into a 80 column line. - exception = False - if Match(r' {6}\w', prev_line): # Initializer list? - # We are looking for the opening column of initializer list, which - # should be indented 4 spaces to cause 6 space indentation afterwards. - search_position = linenum-2 - while (search_position >= 0 - and Match(r' {6}\w', elided[search_position])): - search_position -= 1 - exception = (search_position >= 0 - and elided[search_position][:5] == ' :') - else: - # Search for the function arguments or an initializer list. We use a - # simple heuristic here: If the line is indented 4 spaces; and we have a - # closing paren, without the opening paren, followed by an opening brace - # or colon (for initializer lists) we assume that it is the last line of - # a function header. If we have a colon indented 4 spaces, it is an - # initializer list. - exception = (Match(r' {4}\w[^\(]*\)\s*(const\s*)?(\{\s*$|:)', - prev_line) - or Match(r' {4}:', prev_line)) - - if not exception: - error(filename, linenum, 'whitespace/blank_line', 2, - 'Blank line at the start of a code block. Is this needed?') - # This doesn't ignore whitespace at the end of a namespace block - # because that is too hard without pairing open/close braces; - # however, a special exception is made for namespace closing - # brackets which have a comment containing "namespace". - # - # Also, ignore blank lines at the end of a block in a long if-else - # chain, like this: - # if (condition1) { - # // Something followed by a blank line - # - # } else if (condition2) { - # // Something else - # } - if linenum + 1 < clean_lines.NumLines(): - next_line = raw[linenum + 1] - if (next_line - and Match(r'\s*}', next_line) - and next_line.find('namespace') == -1 - and next_line.find('} else ') == -1): - error(filename, linenum, 'whitespace/blank_line', 3, - 'Blank line at the end of a code block. Is this needed?') - - matched = Match(r'\s*(public|protected|private):', prev_line) - if matched: - error(filename, linenum, 'whitespace/blank_line', 3, - 'Do not leave a blank line after "%s:"' % matched.group(1)) - - # Next, we complain if there's a comment too near the text - commentpos = line.find('//') - if commentpos != -1: - # Check if the // may be in quotes. If so, ignore it - # Comparisons made explicit for clarity -- pylint: disable-msg=C6403 - if (line.count('"', 0, commentpos) - - line.count('\\"', 0, commentpos)) % 2 == 0: # not in quotes - # Allow one space for new scopes, two spaces otherwise: - if (not Match(r'^\s*{ //', line) and - ((commentpos >= 1 and - line[commentpos-1] not in string.whitespace) or - (commentpos >= 2 and - line[commentpos-2] not in string.whitespace))): - error(filename, linenum, 'whitespace/comments', 2, - 'At least two spaces is best between code and comments') - # There should always be a space between the // and the comment - commentend = commentpos + 2 - if commentend < len(line) and not line[commentend] == ' ': - # but some lines are exceptions -- e.g. if they're big - # comment delimiters like: - # //---------------------------------------------------------- - # or are an empty C++ style Doxygen comment, like: - # /// - # or they begin with multiple slashes followed by a space: - # //////// Header comment - match = (Search(r'[=/-]{4,}\s*$', line[commentend:]) or - Search(r'^/$', line[commentend:]) or - Search(r'^/+ ', line[commentend:])) - if not match: - error(filename, linenum, 'whitespace/comments', 4, - 'Should have a space between // and comment') - CheckComment(line[commentpos:], filename, linenum, error) - - line = clean_lines.elided[linenum] # get rid of comments and strings - - # Don't try to do spacing checks for operator methods - line = re.sub(r'operator(==|!=|<|<<|<=|>=|>>|>)\(', 'operator\(', line) - - # We allow no-spaces around = within an if: "if ( (a=Foo()) == 0 )". - # Otherwise not. Note we only check for non-spaces on *both* sides; - # sometimes people put non-spaces on one side when aligning ='s among - # many lines (not that this is behavior that I approve of...) - if Search(r'[\w.]=[\w.]', line) and not Search(r'\b(if|while) ', line): - error(filename, linenum, 'whitespace/operators', 4, - 'Missing spaces around =') - - # It's ok not to have spaces around binary operators like + - * /, but if - # there's too little whitespace, we get concerned. It's hard to tell, - # though, so we punt on this one for now. TODO. - - # You should always have whitespace around binary operators. - # Alas, we can't test < or > because they're legitimately used sans spaces - # (a->b, vector a). The only time we can tell is a < with no >, and - # only if it's not template params list spilling into the next line. - match = Search(r'[^<>=!\s](==|!=|<=|>=)[^<>=!\s]', line) - if not match: - # Note that while it seems that the '<[^<]*' term in the following - # regexp could be simplified to '<.*', which would indeed match - # the same class of strings, the [^<] means that searching for the - # regexp takes linear rather than quadratic time. - if not Search(r'<[^<]*,\s*$', line): # template params spill - match = Search(r'[^<>=!\s](<)[^<>=!\s]([^>]|->)*$', line) - if match: - error(filename, linenum, 'whitespace/operators', 3, - 'Missing spaces around %s' % match.group(1)) - # We allow no-spaces around << and >> when used like this: 10<<20, but - # not otherwise (particularly, not when used as streams) - match = Search(r'[^0-9\s](<<|>>)[^0-9\s]', line) - if match: - error(filename, linenum, 'whitespace/operators', 3, - 'Missing spaces around %s' % match.group(1)) - - # There shouldn't be space around unary operators - match = Search(r'(!\s|~\s|[\s]--[\s;]|[\s]\+\+[\s;])', line) - if match: - error(filename, linenum, 'whitespace/operators', 4, - 'Extra space for operator %s' % match.group(1)) - - # A pet peeve of mine: no spaces after an if, while, switch, or for - match = Search(r' (if\(|for\(|while\(|switch\()', line) - if match: - error(filename, linenum, 'whitespace/parens', 5, - 'Missing space before ( in %s' % match.group(1)) - - # For if/for/while/switch, the left and right parens should be - # consistent about how many spaces are inside the parens, and - # there should either be zero or one spaces inside the parens. - # We don't want: "if ( foo)" or "if ( foo )". - # Exception: "for ( ; foo; bar)" and "for (foo; bar; )" are allowed. - match = Search(r'\b(if|for|while|switch)\s*' - r'\(([ ]*)(.).*[^ ]+([ ]*)\)\s*{\s*$', - line) - if match: - if len(match.group(2)) != len(match.group(4)): - if not (match.group(3) == ';' and - len(match.group(2)) == 1 + len(match.group(4)) or - not match.group(2) and Search(r'\bfor\s*\(.*; \)', line)): - error(filename, linenum, 'whitespace/parens', 5, - 'Mismatching spaces inside () in %s' % match.group(1)) - if not len(match.group(2)) in [0, 1]: - error(filename, linenum, 'whitespace/parens', 5, - 'Should have zero or one spaces inside ( and ) in %s' % - match.group(1)) - - # You should always have a space after a comma (either as fn arg or operator) - if Search(r',[^\s]', line): - error(filename, linenum, 'whitespace/comma', 3, - 'Missing space after ,') - - # You should always have a space after a semicolon - # except for few corner cases - # TODO(unknown): clarify if 'if (1) { return 1;}' is requires one more - # space after ; - if Search(r';[^\s};\\)/]', line): - error(filename, linenum, 'whitespace/semicolon', 3, - 'Missing space after ;') - - # Next we will look for issues with function calls. - CheckSpacingForFunctionCall(filename, line, linenum, error) - - # Except after an opening paren, or after another opening brace (in case of - # an initializer list, for instance), you should have spaces before your - # braces. And since you should never have braces at the beginning of a line, - # this is an easy test. - if Search(r'[^ ({]{', line): - error(filename, linenum, 'whitespace/braces', 5, - 'Missing space before {') - - # Make sure '} else {' has spaces. - if Search(r'}else', line): - error(filename, linenum, 'whitespace/braces', 5, - 'Missing space before else') - - # You shouldn't have spaces before your brackets, except maybe after - # 'delete []' or 'new char * []'. - if Search(r'\w\s+\[', line) and not Search(r'delete\s+\[', line): - error(filename, linenum, 'whitespace/braces', 5, - 'Extra space before [') - - # You shouldn't have a space before a semicolon at the end of the line. - # There's a special case for "for" since the style guide allows space before - # the semicolon there. - if Search(r':\s*;\s*$', line): - error(filename, linenum, 'whitespace/semicolon', 5, - 'Semicolon defining empty statement. Use { } instead.') - elif Search(r'^\s*;\s*$', line): - error(filename, linenum, 'whitespace/semicolon', 5, - 'Line contains only semicolon. If this should be an empty statement, ' - 'use { } instead.') - elif (Search(r'\s+;\s*$', line) and - not Search(r'\bfor\b', line)): - error(filename, linenum, 'whitespace/semicolon', 5, - 'Extra space before last semicolon. If this should be an empty ' - 'statement, use { } instead.') - - -def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error): - """Checks for additional blank line issues related to sections. - - Currently the only thing checked here is blank line before protected/private. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - class_info: A _ClassInfo objects. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - # Skip checks if the class is small, where small means 25 lines or less. - # 25 lines seems like a good cutoff since that's the usual height of - # terminals, and any class that can't fit in one screen can't really - # be considered "small". - # - # Also skip checks if we are on the first line. This accounts for - # classes that look like - # class Foo { public: ... }; - # - # If we didn't find the end of the class, last_line would be zero, - # and the check will be skipped by the first condition. - if (class_info.last_line - class_info.linenum <= 24 or - linenum <= class_info.linenum): - return - - matched = Match(r'\s*(public|protected|private):', clean_lines.lines[linenum]) - if matched: - # Issue warning if the line before public/protected/private was - # not a blank line, but don't do this if the previous line contains - # "class" or "struct". This can happen two ways: - # - We are at the beginning of the class. - # - We are forward-declaring an inner class that is semantically - # private, but needed to be public for implementation reasons. - prev_line = clean_lines.lines[linenum - 1] - if (not IsBlankLine(prev_line) and - not Search(r'\b(class|struct)\b', prev_line)): - # Try a bit harder to find the beginning of the class. This is to - # account for multi-line base-specifier lists, e.g.: - # class Derived - # : public Base { - end_class_head = class_info.linenum - for i in range(class_info.linenum, linenum): - if Search(r'\{\s*$', clean_lines.lines[i]): - end_class_head = i - break - if end_class_head < linenum - 1: - error(filename, linenum, 'whitespace/blank_line', 3, - '"%s:" should be preceded by a blank line' % matched.group(1)) - - -def GetPreviousNonBlankLine(clean_lines, linenum): - """Return the most recent non-blank line and its line number. - - Args: - clean_lines: A CleansedLines instance containing the file contents. - linenum: The number of the line to check. - - Returns: - A tuple with two elements. The first element is the contents of the last - non-blank line before the current line, or the empty string if this is the - first non-blank line. The second is the line number of that line, or -1 - if this is the first non-blank line. - """ - - prevlinenum = linenum - 1 - while prevlinenum >= 0: - prevline = clean_lines.elided[prevlinenum] - if not IsBlankLine(prevline): # if not a blank line... - return (prevline, prevlinenum) - prevlinenum -= 1 - return ('', -1) - - -def CheckBraces(filename, clean_lines, linenum, error): - """Looks for misplaced braces (e.g. at the end of line). - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - - line = clean_lines.elided[linenum] # get rid of comments and strings - - if Match(r'\s*{\s*$', line): - # We allow an open brace to start a line in the case where someone - # is using braces in a block to explicitly create a new scope, - # which is commonly used to control the lifetime of - # stack-allocated variables. We don't detect this perfectly: we - # just don't complain if the last non-whitespace character on the - # previous non-blank line is ';', ':', '{', or '}'. - prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] - if not Search(r'[;:}{]\s*$', prevline): - error(filename, linenum, 'whitespace/braces', 4, - '{ should almost always be at the end of the previous line') - - # An else clause should be on the same line as the preceding closing brace. - if Match(r'\s*else\s*', line): - prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] - if Match(r'\s*}\s*$', prevline): - error(filename, linenum, 'whitespace/newline', 4, - 'An else should appear on the same line as the preceding }') - - # If braces come on one side of an else, they should be on both. - # However, we have to worry about "else if" that spans multiple lines! - if Search(r'}\s*else[^{]*$', line) or Match(r'[^}]*else\s*{', line): - if Search(r'}\s*else if([^{]*)$', line): # could be multi-line if - # find the ( after the if - pos = line.find('else if') - pos = line.find('(', pos) - if pos > 0: - (endline, _, endpos) = CloseExpression(clean_lines, linenum, pos) - if endline[endpos:].find('{') == -1: # must be brace after if - error(filename, linenum, 'readability/braces', 5, - 'If an else has a brace on one side, it should have it on both') - else: # common case: else not followed by a multi-line if - error(filename, linenum, 'readability/braces', 5, - 'If an else has a brace on one side, it should have it on both') - - # Likewise, an else should never have the else clause on the same line - if Search(r'\belse [^\s{]', line) and not Search(r'\belse if\b', line): - error(filename, linenum, 'whitespace/newline', 4, - 'Else clause should never be on same line as else (use 2 lines)') - - # In the same way, a do/while should never be on one line - if Match(r'\s*do [^\s{]', line): - error(filename, linenum, 'whitespace/newline', 4, - 'do/while clauses should not be on a single line') - - # Braces shouldn't be followed by a ; unless they're defining a struct - # or initializing an array. - # We can't tell in general, but we can for some common cases. - prevlinenum = linenum - while True: - (prevline, prevlinenum) = GetPreviousNonBlankLine(clean_lines, prevlinenum) - if Match(r'\s+{.*}\s*;', line) and not prevline.count(';'): - line = prevline + line - else: - break - if (Search(r'{.*}\s*;', line) and - line.count('{') == line.count('}') and - not Search(r'struct|class|enum|\s*=\s*{', line)): - error(filename, linenum, 'readability/braces', 4, - "You don't need a ; after a }") - - -def ReplaceableCheck(operator, macro, line): - """Determine whether a basic CHECK can be replaced with a more specific one. - - For example suggest using CHECK_EQ instead of CHECK(a == b) and - similarly for CHECK_GE, CHECK_GT, CHECK_LE, CHECK_LT, CHECK_NE. - - Args: - operator: The C++ operator used in the CHECK. - macro: The CHECK or EXPECT macro being called. - line: The current source line. - - Returns: - True if the CHECK can be replaced with a more specific one. - """ - - # This matches decimal and hex integers, strings, and chars (in that order). - match_constant = r'([-+]?(\d+|0[xX][0-9a-fA-F]+)[lLuU]{0,3}|".*"|\'.*\')' - - # Expression to match two sides of the operator with something that - # looks like a literal, since CHECK(x == iterator) won't compile. - # This means we can't catch all the cases where a more specific - # CHECK is possible, but it's less annoying than dealing with - # extraneous warnings. - match_this = (r'\s*' + macro + r'\((\s*' + - match_constant + r'\s*' + operator + r'[^<>].*|' - r'.*[^<>]' + operator + r'\s*' + match_constant + - r'\s*\))') - - # Don't complain about CHECK(x == NULL) or similar because - # CHECK_EQ(x, NULL) won't compile (requires a cast). - # Also, don't complain about more complex boolean expressions - # involving && or || such as CHECK(a == b || c == d). - return Match(match_this, line) and not Search(r'NULL|&&|\|\|', line) - - -def CheckCheck(filename, clean_lines, linenum, error): - """Checks the use of CHECK and EXPECT macros. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - - # Decide the set of replacement macros that should be suggested - raw_lines = clean_lines.raw_lines - current_macro = '' - for macro in _CHECK_MACROS: - if raw_lines[linenum].find(macro) >= 0: - current_macro = macro - break - if not current_macro: - # Don't waste time here if line doesn't contain 'CHECK' or 'EXPECT' - return - - line = clean_lines.elided[linenum] # get rid of comments and strings - - # Encourage replacing plain CHECKs with CHECK_EQ/CHECK_NE/etc. - for operator in ['==', '!=', '>=', '>', '<=', '<']: - if ReplaceableCheck(operator, current_macro, line): - error(filename, linenum, 'readability/check', 2, - 'Consider using %s instead of %s(a %s b)' % ( - _CHECK_REPLACEMENT[current_macro][operator], - current_macro, operator)) - break - - -def GetLineWidth(line): - """Determines the width of the line in column positions. - - Args: - line: A string, which may be a Unicode string. - - Returns: - The width of the line in column positions, accounting for Unicode - combining characters and wide characters. - """ - if isinstance(line, unicode): - width = 0 - for uc in unicodedata.normalize('NFC', line): - if unicodedata.east_asian_width(uc) in ('W', 'F'): - width += 2 - elif not unicodedata.combining(uc): - width += 1 - return width - else: - return len(line) - - -def CheckStyle(filename, clean_lines, linenum, file_extension, class_state, - error): - """Checks rules from the 'C++ style rules' section of cppguide.html. - - Most of these rules are hard to test (naming, comment style), but we - do what we can. In particular we check for 2-space indents, line lengths, - tab usage, spaces inside code, etc. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - file_extension: The extension (without the dot) of the filename. - error: The function to call with any errors found. - """ - - raw_lines = clean_lines.raw_lines - line = raw_lines[linenum] - - if line.find('\t') != -1: - error(filename, linenum, 'whitespace/tab', 1, - 'Tab found; better to use spaces') - - # One or three blank spaces at the beginning of the line is weird; it's - # hard to reconcile that with 2-space indents. - # NOTE: here are the conditions rob pike used for his tests. Mine aren't - # as sophisticated, but it may be worth becoming so: RLENGTH==initial_spaces - # if(RLENGTH > 20) complain = 0; - # if(match($0, " +(error|private|public|protected):")) complain = 0; - # if(match(prev, "&& *$")) complain = 0; - # if(match(prev, "\\|\\| *$")) complain = 0; - # if(match(prev, "[\",=><] *$")) complain = 0; - # if(match($0, " <<")) complain = 0; - # if(match(prev, " +for \\(")) complain = 0; - # if(prevodd && match(prevprev, " +for \\(")) complain = 0; - initial_spaces = 0 - cleansed_line = clean_lines.elided[linenum] - while initial_spaces < len(line) and line[initial_spaces] == ' ': - initial_spaces += 1 - if line and line[-1].isspace(): - error(filename, linenum, 'whitespace/end_of_line', 4, - 'Line ends in whitespace. Consider deleting these extra spaces.') - # There are certain situations we allow one space, notably for labels - elif ((initial_spaces == 1 or initial_spaces == 3) and - not Match(r'\s*\w+\s*:\s*$', cleansed_line)): - error(filename, linenum, 'whitespace/indent', 3, - 'Weird number of spaces at line-start. ' - 'Are you using a 2-space indent?') - # Labels should always be indented at least one space. - elif not initial_spaces and line[:2] != '//' and Search(r'[^:]:\s*$', - line): - error(filename, linenum, 'whitespace/labels', 4, - 'Labels should always be indented at least one space. ' - 'If this is a member-initializer list in a constructor or ' - 'the base class list in a class definition, the colon should ' - 'be on the following line.') - - - # Check if the line is a header guard. - is_header_guard = False - if file_extension == 'h': - cppvar = GetHeaderGuardCPPVariable(filename) - if (line.startswith('#ifndef %s' % cppvar) or - line.startswith('#define %s' % cppvar) or - line.startswith('#endif // %s' % cppvar)): - is_header_guard = True - # #include lines and header guards can be long, since there's no clean way to - # split them. - # - # URLs can be long too. It's possible to split these, but it makes them - # harder to cut&paste. - # - # The "$Id:...$" comment may also get very long without it being the - # developers fault. - if (not line.startswith('#include') and not is_header_guard and - not Match(r'^\s*//.*http(s?)://\S*$', line) and - not Match(r'^// \$Id:.*#[0-9]+ \$$', line)): - line_width = GetLineWidth(line) - if line_width > 100: - error(filename, linenum, 'whitespace/line_length', 4, - 'Lines should very rarely be longer than 100 characters') - elif line_width > 80: - error(filename, linenum, 'whitespace/line_length', 2, - 'Lines should be <= 80 characters long') - - if (cleansed_line.count(';') > 1 and - # for loops are allowed two ;'s (and may run over two lines). - cleansed_line.find('for') == -1 and - (GetPreviousNonBlankLine(clean_lines, linenum)[0].find('for') == -1 or - GetPreviousNonBlankLine(clean_lines, linenum)[0].find(';') != -1) and - # It's ok to have many commands in a switch case that fits in 1 line - not ((cleansed_line.find('case ') != -1 or - cleansed_line.find('default:') != -1) and - cleansed_line.find('break;') != -1)): - error(filename, linenum, 'whitespace/newline', 4, - 'More than one command on the same line') - - # Some more style checks - CheckBraces(filename, clean_lines, linenum, error) - CheckSpacing(filename, clean_lines, linenum, error) - CheckCheck(filename, clean_lines, linenum, error) - if class_state and class_state.classinfo_stack: - CheckSectionSpacing(filename, clean_lines, - class_state.classinfo_stack[-1], linenum, error) - - -_RE_PATTERN_INCLUDE_NEW_STYLE = re.compile(r'#include +"[^/]+\.h"') -_RE_PATTERN_INCLUDE = re.compile(r'^\s*#\s*include\s*([<"])([^>"]*)[>"].*$') -# Matches the first component of a filename delimited by -s and _s. That is: -# _RE_FIRST_COMPONENT.match('foo').group(0) == 'foo' -# _RE_FIRST_COMPONENT.match('foo.cc').group(0) == 'foo' -# _RE_FIRST_COMPONENT.match('foo-bar_baz.cc').group(0) == 'foo' -# _RE_FIRST_COMPONENT.match('foo_bar-baz.cc').group(0) == 'foo' -_RE_FIRST_COMPONENT = re.compile(r'^[^-_.]+') - - -def _DropCommonSuffixes(filename): - """Drops common suffixes like _test.cc or -inl.h from filename. - - For example: - >>> _DropCommonSuffixes('foo/foo-inl.h') - 'foo/foo' - >>> _DropCommonSuffixes('foo/bar/foo.cc') - 'foo/bar/foo' - >>> _DropCommonSuffixes('foo/foo_internal.h') - 'foo/foo' - >>> _DropCommonSuffixes('foo/foo_unusualinternal.h') - 'foo/foo_unusualinternal' - - Args: - filename: The input filename. - - Returns: - The filename with the common suffix removed. - """ - for suffix in ('test.cc', 'regtest.cc', 'unittest.cc', - 'inl.h', 'impl.h', 'internal.h'): - if (filename.endswith(suffix) and len(filename) > len(suffix) and - filename[-len(suffix) - 1] in ('-', '_')): - return filename[:-len(suffix) - 1] - return os.path.splitext(filename)[0] - - -def _IsTestFilename(filename): - """Determines if the given filename has a suffix that identifies it as a test. - - Args: - filename: The input filename. - - Returns: - True if 'filename' looks like a test, False otherwise. - """ - if (filename.endswith('_test.cc') or - filename.endswith('_unittest.cc') or - filename.endswith('_regtest.cc')): - return True - else: - return False - - -def _ClassifyInclude(fileinfo, include, is_system): - """Figures out what kind of header 'include' is. - - Args: - fileinfo: The current file cpplint is running over. A FileInfo instance. - include: The path to a #included file. - is_system: True if the #include used <> rather than "". - - Returns: - One of the _XXX_HEADER constants. - - For example: - >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'stdio.h', True) - _C_SYS_HEADER - >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'string', True) - _CPP_SYS_HEADER - >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/foo.h', False) - _LIKELY_MY_HEADER - >>> _ClassifyInclude(FileInfo('foo/foo_unknown_extension.cc'), - ... 'bar/foo_other_ext.h', False) - _POSSIBLE_MY_HEADER - >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/bar.h', False) - _OTHER_HEADER - """ - # This is a list of all standard c++ header files, except - # those already checked for above. - is_stl_h = include in _STL_HEADERS - is_cpp_h = is_stl_h or include in _CPP_HEADERS - - if is_system: - if is_cpp_h: - return _CPP_SYS_HEADER - else: - return _C_SYS_HEADER - - # If the target file and the include we're checking share a - # basename when we drop common extensions, and the include - # lives in . , then it's likely to be owned by the target file. - target_dir, target_base = ( - os.path.split(_DropCommonSuffixes(fileinfo.RepositoryName()))) - include_dir, include_base = os.path.split(_DropCommonSuffixes(include)) - if target_base == include_base and ( - include_dir == target_dir or - include_dir == os.path.normpath(target_dir + '/../public')): - return _LIKELY_MY_HEADER - - # If the target and include share some initial basename - # component, it's possible the target is implementing the - # include, so it's allowed to be first, but we'll never - # complain if it's not there. - target_first_component = _RE_FIRST_COMPONENT.match(target_base) - include_first_component = _RE_FIRST_COMPONENT.match(include_base) - if (target_first_component and include_first_component and - target_first_component.group(0) == - include_first_component.group(0)): - return _POSSIBLE_MY_HEADER - - return _OTHER_HEADER - - - -def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): - """Check rules that are applicable to #include lines. - - Strings on #include lines are NOT removed from elided line, to make - certain tasks easier. However, to prevent false positives, checks - applicable to #include lines in CheckLanguage must be put here. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - include_state: An _IncludeState instance in which the headers are inserted. - error: The function to call with any errors found. - """ - fileinfo = FileInfo(filename) - - line = clean_lines.lines[linenum] - - # "include" should use the new style "foo/bar.h" instead of just "bar.h" - if _RE_PATTERN_INCLUDE_NEW_STYLE.search(line): - error(filename, linenum, 'build/include', 4, - 'Include the directory when naming .h files') - - # we shouldn't include a file more than once. actually, there are a - # handful of instances where doing so is okay, but in general it's - # not. - match = _RE_PATTERN_INCLUDE.search(line) - if match: - include = match.group(2) - is_system = (match.group(1) == '<') - if include in include_state: - error(filename, linenum, 'build/include', 4, - '"%s" already included at %s:%s' % - (include, filename, include_state[include])) - else: - include_state[include] = linenum - - # We want to ensure that headers appear in the right order: - # 1) for foo.cc, foo.h (preferred location) - # 2) c system files - # 3) cpp system files - # 4) for foo.cc, foo.h (deprecated location) - # 5) other google headers - # - # We classify each include statement as one of those 5 types - # using a number of techniques. The include_state object keeps - # track of the highest type seen, and complains if we see a - # lower type after that. - error_message = include_state.CheckNextIncludeOrder( - _ClassifyInclude(fileinfo, include, is_system)) - if error_message: - error(filename, linenum, 'build/include_order', 4, - '%s. Should be: %s.h, c system, c++ system, other.' % - (error_message, fileinfo.BaseName())) - if not include_state.IsInAlphabeticalOrder(include): - error(filename, linenum, 'build/include_alpha', 4, - 'Include "%s" not in alphabetical order' % include) - - # Look for any of the stream classes that are part of standard C++. - match = _RE_PATTERN_INCLUDE.match(line) - if match: - include = match.group(2) - if Match(r'(f|ind|io|i|o|parse|pf|stdio|str|)?stream$', include): - # Many unit tests use cout, so we exempt them. - if not _IsTestFilename(filename): - error(filename, linenum, 'readability/streams', 3, - 'Streams are highly discouraged.') - - -def _GetTextInside(text, start_pattern): - """Retrieves all the text between matching open and close parentheses. - - Given a string of lines and a regular expression string, retrieve all the text - following the expression and between opening punctuation symbols like - (, [, or {, and the matching close-punctuation symbol. This properly nested - occurrences of the punctuations, so for the text like - printf(a(), b(c())); - a call to _GetTextInside(text, r'printf\(') will return 'a(), b(c())'. - start_pattern must match string having an open punctuation symbol at the end. - - Args: - text: The lines to extract text. Its comments and strings must be elided. - It can be single line and can span multiple lines. - start_pattern: The regexp string indicating where to start extracting - the text. - Returns: - The extracted text. - None if either the opening string or ending punctuation could not be found. - """ - # TODO(sugawarayu): Audit cpplint.py to see what places could be profitably - # rewritten to use _GetTextInside (and use inferior regexp matching today). - - # Give opening punctuations to get the matching close-punctuations. - matching_punctuation = {'(': ')', '{': '}', '[': ']'} - closing_punctuation = set(matching_punctuation.itervalues()) - - # Find the position to start extracting text. - match = re.search(start_pattern, text, re.M) - if not match: # start_pattern not found in text. - return None - start_position = match.end(0) - - assert start_position > 0, ( - 'start_pattern must ends with an opening punctuation.') - assert text[start_position - 1] in matching_punctuation, ( - 'start_pattern must ends with an opening punctuation.') - # Stack of closing punctuations we expect to have in text after position. - punctuation_stack = [matching_punctuation[text[start_position - 1]]] - position = start_position - while punctuation_stack and position < len(text): - if text[position] == punctuation_stack[-1]: - punctuation_stack.pop() - elif text[position] in closing_punctuation: - # A closing punctuation without matching opening punctuations. - return None - elif text[position] in matching_punctuation: - punctuation_stack.append(matching_punctuation[text[position]]) - position += 1 - if punctuation_stack: - # Opening punctuations left without matching close-punctuations. - return None - # punctuations match. - return text[start_position:position - 1] - - -def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, - error): - """Checks rules from the 'C++ language rules' section of cppguide.html. - - Some of these rules are hard to test (function overloading, using - uint32 inappropriately), but we do the best we can. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - file_extension: The extension (without the dot) of the filename. - include_state: An _IncludeState instance in which the headers are inserted. - error: The function to call with any errors found. - """ - # If the line is empty or consists of entirely a comment, no need to - # check it. - line = clean_lines.elided[linenum] - if not line: - return - - match = _RE_PATTERN_INCLUDE.search(line) - if match: - CheckIncludeLine(filename, clean_lines, linenum, include_state, error) - return - - # Create an extended_line, which is the concatenation of the current and - # next lines, for more effective checking of code that may span more than one - # line. - if linenum + 1 < clean_lines.NumLines(): - extended_line = line + clean_lines.elided[linenum + 1] - else: - extended_line = line - - # Make Windows paths like Unix. - fullname = os.path.abspath(filename).replace('\\', '/') - - # TODO(unknown): figure out if they're using default arguments in fn proto. - - # Check for non-const references in functions. This is tricky because & - # is also used to take the address of something. We allow <> for templates, - # (ignoring whatever is between the braces) and : for classes. - # These are complicated re's. They try to capture the following: - # paren (for fn-prototype start), typename, &, varname. For the const - # version, we're willing for const to be before typename or after - # Don't check the implementation on same line. - fnline = line.split('{', 1)[0] - if (len(re.findall(r'\([^()]*\b(?:[\w:]|<[^()]*>)+(\s?&|&\s?)\w+', fnline)) > - len(re.findall(r'\([^()]*\bconst\s+(?:typename\s+)?(?:struct\s+)?' - r'(?:[\w:]|<[^()]*>)+(\s?&|&\s?)\w+', fnline)) + - len(re.findall(r'\([^()]*\b(?:[\w:]|<[^()]*>)+\s+const(\s?&|&\s?)[\w]+', - fnline))): - - # We allow non-const references in a few standard places, like functions - # called "swap()" or iostream operators like "<<" or ">>". - if not Search( - r'(swap|Swap|operator[<>][<>])\s*\(\s*(?:[\w:]|<.*>)+\s*&', - fnline): - error(filename, linenum, 'runtime/references', 2, - 'Is this a non-const reference? ' - 'If so, make const or use a pointer.') - - # Check to see if they're using an conversion function cast. - # I just try to capture the most common basic types, though there are more. - # Parameterless conversion functions, such as bool(), are allowed as they are - # probably a member operator declaration or default constructor. - match = Search( - r'(\bnew\s+)?\b' # Grab 'new' operator, if it's there - r'(int|float|double|bool|char|int32|uint32|int64|uint64)\([^)]', line) - if match: - # gMock methods are defined using some variant of MOCK_METHODx(name, type) - # where type may be float(), int(string), etc. Without context they are - # virtually indistinguishable from int(x) casts. Likewise, gMock's - # MockCallback takes a template parameter of the form return_type(arg_type), - # which looks much like the cast we're trying to detect. - if (match.group(1) is None and # If new operator, then this isn't a cast - not (Match(r'^\s*MOCK_(CONST_)?METHOD\d+(_T)?\(', line) or - Match(r'^\s*MockCallback<.*>', line))): - error(filename, linenum, 'readability/casting', 4, - 'Using deprecated casting style. ' - 'Use static_cast<%s>(...) instead' % - match.group(2)) - - CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], - 'static_cast', - r'\((int|float|double|bool|char|u?int(16|32|64))\)', error) - - # This doesn't catch all cases. Consider (const char * const)"hello". - # - # (char *) "foo" should always be a const_cast (reinterpret_cast won't - # compile). - if CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], - 'const_cast', r'\((char\s?\*+\s?)\)\s*"', error): - pass - else: - # Check pointer casts for other than string constants - CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], - 'reinterpret_cast', r'\((\w+\s?\*+\s?)\)', error) - - # In addition, we look for people taking the address of a cast. This - # is dangerous -- casts can assign to temporaries, so the pointer doesn't - # point where you think. - if Search( - r'(&\([^)]+\)[\w(])|(&(static|dynamic|reinterpret)_cast\b)', line): - error(filename, linenum, 'runtime/casting', 4, - ('Are you taking an address of a cast? ' - 'This is dangerous: could be a temp var. ' - 'Take the address before doing the cast, rather than after')) - - # Check for people declaring static/global STL strings at the top level. - # This is dangerous because the C++ language does not guarantee that - # globals with constructors are initialized before the first access. - match = Match( - r'((?:|static +)(?:|const +))string +([a-zA-Z0-9_:]+)\b(.*)', - line) - # Make sure it's not a function. - # Function template specialization looks like: "string foo(...". - # Class template definitions look like: "string Foo::Method(...". - if match and not Match(r'\s*(<.*>)?(::[a-zA-Z0-9_]+)?\s*\(([^"]|$)', - match.group(3)): - error(filename, linenum, 'runtime/string', 4, - 'For a static/global string constant, use a C style string instead: ' - '"%schar %s[]".' % - (match.group(1), match.group(2))) - - # Check that we're not using RTTI outside of testing code. - if Search(r'\bdynamic_cast<', line) and not _IsTestFilename(filename): - error(filename, linenum, 'runtime/rtti', 5, - 'Do not use dynamic_cast<>. If you need to cast within a class ' - "hierarchy, use static_cast<> to upcast. Google doesn't support " - 'RTTI.') - - if Search(r'\b([A-Za-z0-9_]*_)\(\1\)', line): - error(filename, linenum, 'runtime/init', 4, - 'You seem to be initializing a member variable with itself.') - - if file_extension == 'h': - # TODO(unknown): check that 1-arg constructors are explicit. - # How to tell it's a constructor? - # (handled in CheckForNonStandardConstructs for now) - # TODO(unknown): check that classes have DISALLOW_EVIL_CONSTRUCTORS - # (level 1 error) - pass - - # Check if people are using the verboten C basic types. The only exception - # we regularly allow is "unsigned short port" for port. - if Search(r'\bshort port\b', line): - if not Search(r'\bunsigned short port\b', line): - error(filename, linenum, 'runtime/int', 4, - 'Use "unsigned short" for ports, not "short"') - else: - match = Search(r'\b(short|long(?! +double)|long long)\b', line) - if match: - error(filename, linenum, 'runtime/int', 4, - 'Use int16/int64/etc, rather than the C type %s' % match.group(1)) - - # When snprintf is used, the second argument shouldn't be a literal. - match = Search(r'snprintf\s*\(([^,]*),\s*([0-9]*)\s*,', line) - if match and match.group(2) != '0': - # If 2nd arg is zero, snprintf is used to calculate size. - error(filename, linenum, 'runtime/printf', 3, - 'If you can, use sizeof(%s) instead of %s as the 2nd arg ' - 'to snprintf.' % (match.group(1), match.group(2))) - - # Check if some verboten C functions are being used. - if Search(r'\bsprintf\b', line): - error(filename, linenum, 'runtime/printf', 5, - 'Never use sprintf. Use snprintf instead.') - match = Search(r'\b(strcpy|strcat)\b', line) - if match: - error(filename, linenum, 'runtime/printf', 4, - 'Almost always, snprintf is better than %s' % match.group(1)) - - if Search(r'\bsscanf\b', line): - error(filename, linenum, 'runtime/printf', 1, - 'sscanf can be ok, but is slow and can overflow buffers.') - - # Check if some verboten operator overloading is going on - # TODO(unknown): catch out-of-line unary operator&: - # class X {}; - # int operator&(const X& x) { return 42; } // unary operator& - # The trick is it's hard to tell apart from binary operator&: - # class Y { int operator&(const Y& x) { return 23; } }; // binary operator& - if Search(r'\boperator\s*&\s*\(\s*\)', line): - error(filename, linenum, 'runtime/operator', 4, - 'Unary operator& is dangerous. Do not use it.') - - # Check for suspicious usage of "if" like - # } if (a == b) { - if Search(r'\}\s*if\s*\(', line): - error(filename, linenum, 'readability/braces', 4, - 'Did you mean "else if"? If not, start a new line for "if".') - - # Check for potential format string bugs like printf(foo). - # We constrain the pattern not to pick things like DocidForPrintf(foo). - # Not perfect but it can catch printf(foo.c_str()) and printf(foo->c_str()) - # TODO(sugawarayu): Catch the following case. Need to change the calling - # convention of the whole function to process multiple line to handle it. - # printf( - # boy_this_is_a_really_long_variable_that_cannot_fit_on_the_prev_line); - printf_args = _GetTextInside(line, r'(?i)\b(string)?printf\s*\(') - if printf_args: - match = Match(r'([\w.\->()]+)$', printf_args) - if match: - function_name = re.search(r'\b((?:string)?printf)\s*\(', - line, re.I).group(1) - error(filename, linenum, 'runtime/printf', 4, - 'Potential format string bug. Do %s("%%s", %s) instead.' - % (function_name, match.group(1))) - - # Check for potential memset bugs like memset(buf, sizeof(buf), 0). - match = Search(r'memset\s*\(([^,]*),\s*([^,]*),\s*0\s*\)', line) - if match and not Match(r"^''|-?[0-9]+|0x[0-9A-Fa-f]$", match.group(2)): - error(filename, linenum, 'runtime/memset', 4, - 'Did you mean "memset(%s, 0, %s)"?' - % (match.group(1), match.group(2))) - - if Search(r'\busing namespace\b', line): - error(filename, linenum, 'build/namespaces', 5, - 'Do not use namespace using-directives. ' - 'Use using-declarations instead.') - - # Detect variable-length arrays. - match = Match(r'\s*(.+::)?(\w+) [a-z]\w*\[(.+)];', line) - if (match and match.group(2) != 'return' and match.group(2) != 'delete' and - match.group(3).find(']') == -1): - # Split the size using space and arithmetic operators as delimiters. - # If any of the resulting tokens are not compile time constants then - # report the error. - tokens = re.split(r'\s|\+|\-|\*|\/|<<|>>]', match.group(3)) - is_const = True - skip_next = False - for tok in tokens: - if skip_next: - skip_next = False - continue - - if Search(r'sizeof\(.+\)', tok): continue - if Search(r'arraysize\(\w+\)', tok): continue - - tok = tok.lstrip('(') - tok = tok.rstrip(')') - if not tok: continue - if Match(r'\d+', tok): continue - if Match(r'0[xX][0-9a-fA-F]+', tok): continue - if Match(r'k[A-Z0-9]\w*', tok): continue - if Match(r'(.+::)?k[A-Z0-9]\w*', tok): continue - if Match(r'(.+::)?[A-Z][A-Z0-9_]*', tok): continue - # A catch all for tricky sizeof cases, including 'sizeof expression', - # 'sizeof(*type)', 'sizeof(const type)', 'sizeof(struct StructName)' - # requires skipping the next token because we split on ' ' and '*'. - if tok.startswith('sizeof'): - skip_next = True - continue - is_const = False - break - if not is_const: - error(filename, linenum, 'runtime/arrays', 1, - 'Do not use variable-length arrays. Use an appropriately named ' - "('k' followed by CamelCase) compile-time constant for the size.") - - # If DISALLOW_EVIL_CONSTRUCTORS, DISALLOW_COPY_AND_ASSIGN, or - # DISALLOW_IMPLICIT_CONSTRUCTORS is present, then it should be the last thing - # in the class declaration. - match = Match( - (r'\s*' - r'(DISALLOW_(EVIL_CONSTRUCTORS|COPY_AND_ASSIGN|IMPLICIT_CONSTRUCTORS))' - r'\(.*\);$'), - line) - if match and linenum + 1 < clean_lines.NumLines(): - next_line = clean_lines.elided[linenum + 1] - # We allow some, but not all, declarations of variables to be present - # in the statement that defines the class. The [\w\*,\s]* fragment of - # the regular expression below allows users to declare instances of - # the class or pointers to instances, but not less common types such - # as function pointers or arrays. It's a tradeoff between allowing - # reasonable code and avoiding trying to parse more C++ using regexps. - if not Search(r'^\s*}[\w\*,\s]*;', next_line): - error(filename, linenum, 'readability/constructors', 3, - match.group(1) + ' should be the last thing in the class') - - # Check for use of unnamed namespaces in header files. Registration - # macros are typically OK, so we allow use of "namespace {" on lines - # that end with backslashes. - if (file_extension == 'h' - and Search(r'\bnamespace\s*{', line) - and line[-1] != '\\'): - error(filename, linenum, 'build/namespaces', 4, - 'Do not use unnamed namespaces in header files. See ' - 'http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces' - ' for more information.') - - -def CheckCStyleCast(filename, linenum, line, raw_line, cast_type, pattern, - error): - """Checks for a C-style cast by looking for the pattern. - - This also handles sizeof(type) warnings, due to similarity of content. - - Args: - filename: The name of the current file. - linenum: The number of the line to check. - line: The line of code to check. - raw_line: The raw line of code to check, with comments. - cast_type: The string for the C++ cast to recommend. This is either - reinterpret_cast, static_cast, or const_cast, depending. - pattern: The regular expression used to find C-style casts. - error: The function to call with any errors found. - - Returns: - True if an error was emitted. - False otherwise. - """ - match = Search(pattern, line) - if not match: - return False - - # e.g., sizeof(int) - sizeof_match = Match(r'.*sizeof\s*$', line[0:match.start(1) - 1]) - if sizeof_match: - error(filename, linenum, 'runtime/sizeof', 1, - 'Using sizeof(type). Use sizeof(varname) instead if possible') - return True - - remainder = line[match.end(0):] - - # The close paren is for function pointers as arguments to a function. - # eg, void foo(void (*bar)(int)); - # The semicolon check is a more basic function check; also possibly a - # function pointer typedef. - # eg, void foo(int); or void foo(int) const; - # The equals check is for function pointer assignment. - # eg, void *(*foo)(int) = ... - # The > is for MockCallback<...> ... - # - # Right now, this will only catch cases where there's a single argument, and - # it's unnamed. It should probably be expanded to check for multiple - # arguments with some unnamed. - function_match = Match(r'\s*(\)|=|(const)?\s*(;|\{|throw\(\)|>))', remainder) - if function_match: - if (not function_match.group(3) or - function_match.group(3) == ';' or - ('MockCallback<' not in raw_line and - '/*' not in raw_line)): - error(filename, linenum, 'readability/function', 3, - 'All parameters should be named in a function') - return True - - # At this point, all that should be left is actual casts. - error(filename, linenum, 'readability/casting', 4, - 'Using C-style cast. Use %s<%s>(...) instead' % - (cast_type, match.group(1))) - - return True - - -_HEADERS_CONTAINING_TEMPLATES = ( - ('', ('deque',)), - ('', ('unary_function', 'binary_function', - 'plus', 'minus', 'multiplies', 'divides', 'modulus', - 'negate', - 'equal_to', 'not_equal_to', 'greater', 'less', - 'greater_equal', 'less_equal', - 'logical_and', 'logical_or', 'logical_not', - 'unary_negate', 'not1', 'binary_negate', 'not2', - 'bind1st', 'bind2nd', - 'pointer_to_unary_function', - 'pointer_to_binary_function', - 'ptr_fun', - 'mem_fun_t', 'mem_fun', 'mem_fun1_t', 'mem_fun1_ref_t', - 'mem_fun_ref_t', - 'const_mem_fun_t', 'const_mem_fun1_t', - 'const_mem_fun_ref_t', 'const_mem_fun1_ref_t', - 'mem_fun_ref', - )), - ('', ('numeric_limits',)), - ('', ('list',)), - ('', ('map', 'multimap',)), - ('', ('allocator',)), - ('', ('queue', 'priority_queue',)), - ('', ('set', 'multiset',)), - ('', ('stack',)), - ('', ('char_traits', 'basic_string',)), - ('', ('pair',)), - ('', ('vector',)), - - # gcc extensions. - # Note: std::hash is their hash, ::hash is our hash - ('', ('hash_map', 'hash_multimap',)), - ('', ('hash_set', 'hash_multiset',)), - ('', ('slist',)), - ) - -_RE_PATTERN_STRING = re.compile(r'\bstring\b') - -_re_pattern_algorithm_header = [] -for _template in ('copy', 'max', 'min', 'min_element', 'sort', 'swap', - 'transform'): - # Match max(..., ...), max(..., ...), but not foo->max, foo.max or - # type::max(). - _re_pattern_algorithm_header.append( - (re.compile(r'[^>.]\b' + _template + r'(<.*?>)?\([^\)]'), - _template, - '')) - -_re_pattern_templates = [] -for _header, _templates in _HEADERS_CONTAINING_TEMPLATES: - for _template in _templates: - _re_pattern_templates.append( - (re.compile(r'(\<|\b)' + _template + r'\s*\<'), - _template + '<>', - _header)) - - -def FilesBelongToSameModule(filename_cc, filename_h): - """Check if these two filenames belong to the same module. - - The concept of a 'module' here is a as follows: - foo.h, foo-inl.h, foo.cc, foo_test.cc and foo_unittest.cc belong to the - same 'module' if they are in the same directory. - some/path/public/xyzzy and some/path/internal/xyzzy are also considered - to belong to the same module here. - - If the filename_cc contains a longer path than the filename_h, for example, - '/absolute/path/to/base/sysinfo.cc', and this file would include - 'base/sysinfo.h', this function also produces the prefix needed to open the - header. This is used by the caller of this function to more robustly open the - header file. We don't have access to the real include paths in this context, - so we need this guesswork here. - - Known bugs: tools/base/bar.cc and base/bar.h belong to the same module - according to this implementation. Because of this, this function gives - some false positives. This should be sufficiently rare in practice. - - Args: - filename_cc: is the path for the .cc file - filename_h: is the path for the header path - - Returns: - Tuple with a bool and a string: - bool: True if filename_cc and filename_h belong to the same module. - string: the additional prefix needed to open the header file. - """ - - if not filename_cc.endswith('.cc'): - return (False, '') - filename_cc = filename_cc[:-len('.cc')] - if filename_cc.endswith('_unittest'): - filename_cc = filename_cc[:-len('_unittest')] - elif filename_cc.endswith('_test'): - filename_cc = filename_cc[:-len('_test')] - filename_cc = filename_cc.replace('/public/', '/') - filename_cc = filename_cc.replace('/internal/', '/') - - if not filename_h.endswith('.h'): - return (False, '') - filename_h = filename_h[:-len('.h')] - if filename_h.endswith('-inl'): - filename_h = filename_h[:-len('-inl')] - filename_h = filename_h.replace('/public/', '/') - filename_h = filename_h.replace('/internal/', '/') - - files_belong_to_same_module = filename_cc.endswith(filename_h) - common_path = '' - if files_belong_to_same_module: - common_path = filename_cc[:-len(filename_h)] - return files_belong_to_same_module, common_path - - -def UpdateIncludeState(filename, include_state, io=codecs): - """Fill up the include_state with new includes found from the file. - - Args: - filename: the name of the header to read. - include_state: an _IncludeState instance in which the headers are inserted. - io: The io factory to use to read the file. Provided for testability. - - Returns: - True if a header was succesfully added. False otherwise. - """ - headerfile = None - try: - headerfile = io.open(filename, 'r', 'utf8', 'replace') - except IOError: - return False - linenum = 0 - for line in headerfile: - linenum += 1 - clean_line = CleanseComments(line) - match = _RE_PATTERN_INCLUDE.search(clean_line) - if match: - include = match.group(2) - # The value formatting is cute, but not really used right now. - # What matters here is that the key is in include_state. - include_state.setdefault(include, '%s:%d' % (filename, linenum)) - return True - - -def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, - io=codecs): - """Reports for missing stl includes. - - This function will output warnings to make sure you are including the headers - necessary for the stl containers and functions that you use. We only give one - reason to include a header. For example, if you use both equal_to<> and - less<> in a .h file, only one (the latter in the file) of these will be - reported as a reason to include the . - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - include_state: An _IncludeState instance. - error: The function to call with any errors found. - io: The IO factory to use to read the header file. Provided for unittest - injection. - """ - required = {} # A map of header name to linenumber and the template entity. - # Example of required: { '': (1219, 'less<>') } - - for linenum in xrange(clean_lines.NumLines()): - line = clean_lines.elided[linenum] - if not line or line[0] == '#': - continue - - # String is special -- it is a non-templatized type in STL. - matched = _RE_PATTERN_STRING.search(line) - if matched: - # Don't warn about strings in non-STL namespaces: - # (We check only the first match per line; good enough.) - prefix = line[:matched.start()] - if prefix.endswith('std::') or not prefix.endswith('::'): - required[''] = (linenum, 'string') - - for pattern, template, header in _re_pattern_algorithm_header: - if pattern.search(line): - required[header] = (linenum, template) - - # The following function is just a speed up, no semantics are changed. - if not '<' in line: # Reduces the cpu time usage by skipping lines. - continue - - for pattern, template, header in _re_pattern_templates: - if pattern.search(line): - required[header] = (linenum, template) - - # The policy is that if you #include something in foo.h you don't need to - # include it again in foo.cc. Here, we will look at possible includes. - # Let's copy the include_state so it is only messed up within this function. - include_state = include_state.copy() - - # Did we find the header for this file (if any) and succesfully load it? - header_found = False - - # Use the absolute path so that matching works properly. - abs_filename = FileInfo(filename).FullName() - - # For Emacs's flymake. - # If cpplint is invoked from Emacs's flymake, a temporary file is generated - # by flymake and that file name might end with '_flymake.cc'. In that case, - # restore original file name here so that the corresponding header file can be - # found. - # e.g. If the file name is 'foo_flymake.cc', we should search for 'foo.h' - # instead of 'foo_flymake.h' - abs_filename = re.sub(r'_flymake\.cc$', '.cc', abs_filename) - - # include_state is modified during iteration, so we iterate over a copy of - # the keys. - header_keys = include_state.keys() - for header in header_keys: - (same_module, common_path) = FilesBelongToSameModule(abs_filename, header) - fullpath = common_path + header - if same_module and UpdateIncludeState(fullpath, include_state, io): - header_found = True - - # If we can't find the header file for a .cc, assume it's because we don't - # know where to look. In that case we'll give up as we're not sure they - # didn't include it in the .h file. - # TODO(unknown): Do a better job of finding .h files so we are confident that - # not having the .h file means there isn't one. - if filename.endswith('.cc') and not header_found: - return - - # All the lines have been processed, report the errors found. - for required_header_unstripped in required: - template = required[required_header_unstripped][1] - if required_header_unstripped.strip('<>"') not in include_state: - error(filename, required[required_header_unstripped][0], - 'build/include_what_you_use', 4, - 'Add #include ' + required_header_unstripped + ' for ' + template) - - -_RE_PATTERN_EXPLICIT_MAKEPAIR = re.compile(r'\bmake_pair\s*<') - - -def CheckMakePairUsesDeduction(filename, clean_lines, linenum, error): - """Check that make_pair's template arguments are deduced. - - G++ 4.6 in C++0x mode fails badly if make_pair's template arguments are - specified explicitly, and such use isn't intended in any case. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - raw = clean_lines.raw_lines - line = raw[linenum] - match = _RE_PATTERN_EXPLICIT_MAKEPAIR.search(line) - if match: - error(filename, linenum, 'build/explicit_make_pair', - 4, # 4 = high confidence - 'Omit template arguments from make_pair OR use pair directly OR' - ' if appropriate, construct a pair directly') - - -def ProcessLine(filename, file_extension, - clean_lines, line, include_state, function_state, - class_state, error, extra_check_functions=[]): - """Processes a single line in the file. - - Args: - filename: Filename of the file that is being processed. - file_extension: The extension (dot not included) of the file. - clean_lines: An array of strings, each representing a line of the file, - with comments stripped. - line: Number of line being processed. - include_state: An _IncludeState instance in which the headers are inserted. - function_state: A _FunctionState instance which counts function lines, etc. - class_state: A _ClassState instance which maintains information about - the current stack of nested class declarations being parsed. - error: A callable to which errors are reported, which takes 4 arguments: - filename, line number, error level, and message - extra_check_functions: An array of additional check functions that will be - run on each source line. Each function takes 4 - arguments: filename, clean_lines, line, error - """ - raw_lines = clean_lines.raw_lines - ParseNolintSuppressions(filename, raw_lines[line], line, error) - CheckForFunctionLengths(filename, clean_lines, line, function_state, error) - CheckForMultilineCommentsAndStrings(filename, clean_lines, line, error) - CheckStyle(filename, clean_lines, line, file_extension, class_state, error) - CheckLanguage(filename, clean_lines, line, file_extension, include_state, - error) - CheckForNonStandardConstructs(filename, clean_lines, line, - class_state, error) - CheckPosixThreading(filename, clean_lines, line, error) - CheckInvalidIncrement(filename, clean_lines, line, error) - CheckMakePairUsesDeduction(filename, clean_lines, line, error) - for check_fn in extra_check_functions: - check_fn(filename, clean_lines, line, error) - -def ProcessFileData(filename, file_extension, lines, error, - extra_check_functions=[]): - """Performs lint checks and reports any errors to the given error function. - - Args: - filename: Filename of the file that is being processed. - file_extension: The extension (dot not included) of the file. - lines: An array of strings, each representing a line of the file, with the - last element being empty if the file is terminated with a newline. - error: A callable to which errors are reported, which takes 4 arguments: - filename, line number, error level, and message - extra_check_functions: An array of additional check functions that will be - run on each source line. Each function takes 4 - arguments: filename, clean_lines, line, error - """ - lines = (['// marker so line numbers and indices both start at 1'] + lines + - ['// marker so line numbers end in a known way']) - - include_state = _IncludeState() - function_state = _FunctionState() - class_state = _ClassState() - - ResetNolintSuppressions() - - CheckForCopyright(filename, lines, error) - - if file_extension == 'h': - CheckForHeaderGuard(filename, lines, error) - - RemoveMultiLineComments(filename, lines, error) - clean_lines = CleansedLines(lines) - for line in xrange(clean_lines.NumLines()): - ProcessLine(filename, file_extension, clean_lines, line, - include_state, function_state, class_state, error, - extra_check_functions) - class_state.CheckFinished(filename, error) - - CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error) - - # We check here rather than inside ProcessLine so that we see raw - # lines rather than "cleaned" lines. - CheckForUnicodeReplacementCharacters(filename, lines, error) - - CheckForNewlineAtEOF(filename, lines, error) - -def ProcessFile(filename, vlevel, extra_check_functions=[]): - """Does google-lint on a single file. - - Args: - filename: The name of the file to parse. - - vlevel: The level of errors to report. Every error of confidence - >= verbose_level will be reported. 0 is a good default. - - extra_check_functions: An array of additional check functions that will be - run on each source line. Each function takes 4 - arguments: filename, clean_lines, line, error - """ - - _SetVerboseLevel(vlevel) - - try: - # Support the UNIX convention of using "-" for stdin. Note that - # we are not opening the file with universal newline support - # (which codecs doesn't support anyway), so the resulting lines do - # contain trailing '\r' characters if we are reading a file that - # has CRLF endings. - # If after the split a trailing '\r' is present, it is removed - # below. If it is not expected to be present (i.e. os.linesep != - # '\r\n' as in Windows), a warning is issued below if this file - # is processed. - - if filename == '-': - lines = codecs.StreamReaderWriter(sys.stdin, - codecs.getreader('utf8'), - codecs.getwriter('utf8'), - 'replace').read().split('\n') - else: - lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n') - - carriage_return_found = False - # Remove trailing '\r'. - for linenum in range(len(lines)): - if lines[linenum].endswith('\r'): - lines[linenum] = lines[linenum].rstrip('\r') - carriage_return_found = True - - except IOError: - sys.stderr.write( - "Skipping input '%s': Can't open for reading\n" % filename) - return - - # Note, if no dot is found, this will give the entire filename as the ext. - file_extension = filename[filename.rfind('.') + 1:] - - # When reading from stdin, the extension is unknown, so no cpplint tests - # should rely on the extension. - if (filename != '-' and file_extension != 'cc' and file_extension != 'h' - and file_extension != 'cpp'): - sys.stderr.write('Ignoring %s; not a .cc or .h file\n' % filename) - else: - ProcessFileData(filename, file_extension, lines, Error, - extra_check_functions) - if carriage_return_found and os.linesep != '\r\n': - # Use 0 for linenum since outputting only one error for potentially - # several lines. - Error(filename, 0, 'whitespace/newline', 1, - 'One or more unexpected \\r (^M) found;' - 'better to use only a \\n') - - sys.stderr.write('Done processing %s\n' % filename) - - -def PrintUsage(message): - """Prints a brief usage string and exits, optionally with an error message. - - Args: - message: The optional error message. - """ - sys.stderr.write(_USAGE) - if message: - sys.exit('\nFATAL ERROR: ' + message) - else: - sys.exit(1) - - -def PrintCategories(): - """Prints a list of all the error-categories used by error messages. - - These are the categories used to filter messages via --filter. - """ - sys.stderr.write(''.join(' %s\n' % cat for cat in _ERROR_CATEGORIES)) - sys.exit(0) - - -def ParseArguments(args): - """Parses the command line arguments. - - This may set the output format and verbosity level as side-effects. - - Args: - args: The command line arguments: - - Returns: - The list of filenames to lint. - """ - try: - (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', - 'counting=', - 'filter=']) - except getopt.GetoptError: - PrintUsage('Invalid arguments.') - - verbosity = _VerboseLevel() - output_format = _OutputFormat() - filters = '' - counting_style = '' - - for (opt, val) in opts: - if opt == '--help': - PrintUsage(None) - elif opt == '--output': - if not val in ('emacs', 'vs7'): - PrintUsage('The only allowed output formats are emacs and vs7.') - output_format = val - elif opt == '--verbose': - verbosity = int(val) - elif opt == '--filter': - filters = val - if not filters: - PrintCategories() - elif opt == '--counting': - if val not in ('total', 'toplevel', 'detailed'): - PrintUsage('Valid counting options are total, toplevel, and detailed') - counting_style = val - - if not filenames: - PrintUsage('No files were specified.') - - _SetOutputFormat(output_format) - _SetVerboseLevel(verbosity) - _SetFilters(filters) - _SetCountingStyle(counting_style) - - return filenames - - -def main(): - filenames = ParseArguments(sys.argv[1:]) - - # Change stderr to write with replacement characters so we don't die - # if we try to print something containing non-ASCII characters. - sys.stderr = codecs.StreamReaderWriter(sys.stderr, - codecs.getreader('utf8'), - codecs.getwriter('utf8'), - 'replace') - - _cpplint_state.ResetErrorCounts() - for filename in filenames: - ProcessFile(filename, _cpplint_state.verbose_level) - _cpplint_state.PrintErrorCounts() - - sys.exit(_cpplint_state.error_count > 0) - - -if __name__ == '__main__': - main() diff --git a/resources/3rdparty/cpptemplate/LICENSE.txt b/resources/3rdparty/cpptemplate/LICENSE.txt new file mode 100755 index 000000000..e1b75021a --- /dev/null +++ b/resources/3rdparty/cpptemplate/LICENSE.txt @@ -0,0 +1,8 @@ +cpptempl +Copyright (c) Ryan Ginstrom + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/resources/3rdparty/cpptemplate/README.rst b/resources/3rdparty/cpptemplate/README.rst new file mode 100755 index 000000000..f323686ac --- /dev/null +++ b/resources/3rdparty/cpptemplate/README.rst @@ -0,0 +1,56 @@ +cpptempl +================= +This is a template engine for C++. + +Copyright +================== +Author: Ryan Ginstrom +MIT License + +Syntax +================= + +Variables:: + + {$variable_name} + +Loops:: + + {% for person in people %}Name: {$person.name}{% endfor %} + +If:: + + {% if person.name == "Bob" %}Full name: Robert{% endif %} + + +Usage +======================= + +Define a template:: + + string text = "{% if item %}{$item}{% endif %}\n" + "{% if thing %}{$thing}{% endif %}" ; + +Set up data:: + + cpptempl::data_map data ; + data["item"] = "aaa" ; + data["thing"] = "bbb" ; + +Parse the template and data:: + + string result = cpptempl::parse(text, data) ; + +Lists, nested maps +======================== + +Example:: + + cpptempl::data_map person_data ; + person_data["name"] = "Bob" ; + person_data["occupation"] = "Plumber" ; + + cpptempl::data_map content ; + content["person"] = person_data ; + content["friends"].push_back("Alice") ; + content["friends"].push_back("Bob") ; diff --git a/resources/3rdparty/cpptemplate/cpptempl.cpp b/resources/3rdparty/cpptemplate/cpptempl.cpp new file mode 100755 index 000000000..01cc630fa --- /dev/null +++ b/resources/3rdparty/cpptemplate/cpptempl.cpp @@ -0,0 +1,411 @@ +#ifdef _MSC_VER +#include "stdafx.h" +#endif + +#include "cpptempl.h" + +#include +#include +#include + +namespace cpptempl +{ + ////////////////////////////////////////////////////////////////////////// + // Data classes + ////////////////////////////////////////////////////////////////////////// + + // data_map + data_ptr& data_map::operator [](const std::string& key) { + return data[key]; + } + bool data_map::empty() { + return data.empty(); + } + bool data_map::has(const std::string& key) { + return data.find(key) != data.end(); + } + + // data_ptr + data_ptr::data_ptr(DataValue* data) : ptr(data) {} + data_ptr::data_ptr(DataList* data) : ptr(data) {} + data_ptr::data_ptr(DataMap* data) : ptr(data) {} + + template<> + inline void data_ptr::operator = (const data_ptr& data) { + ptr = data.ptr; + } + + template<> + void data_ptr::operator = (const std::string& data) { + ptr.reset(new DataValue(data)); + } + + template<> + void data_ptr::operator = (const data_map& data) { + ptr.reset(new DataMap(data)); + } + + void data_ptr::push_back(const data_ptr& data) { + if (!ptr) { + ptr.reset(new DataList(data_list())); + } + data_list& list = ptr->getlist(); + list.push_back(data); + } + + // base data + std::string Data::getvalue() + { + throw TemplateException("Data item is not a value") ; + } + + data_list& Data::getlist() + { + throw TemplateException("Data item is not a list") ; + } + data_map& Data::getmap() + { + throw TemplateException("Data item is not a dictionary") ; + } + // data value + std::string DataValue::getvalue() + { + return m_value ; + } + bool DataValue::empty() + { + return m_value.empty(); + } + // data list + data_list& DataList::getlist() + { + return m_items ; + } + + bool DataList::empty() + { + return m_items.empty(); + } + // data map + data_map& DataMap:: getmap() + { + return m_items ; + } + bool DataMap::empty() + { + return m_items.empty(); + } + ////////////////////////////////////////////////////////////////////////// + // parse_val + ////////////////////////////////////////////////////////////////////////// + data_ptr parse_val(std::string key, data_map &data) + { + // quoted string + if (key[0] == '\"') + { + return make_data(boost::trim_copy_if(key, boost::is_any_of("\""))) ; + } + // check for dotted notation, i.e [foo.bar] + size_t index = key.find(".") ; + if (index == std::string::npos) + { + if (!data.has(key)) + { + return make_data("{$" + key + "}") ; + } + return data[key] ; + } + + std::string sub_key = key.substr(0, index) ; + if (!data.has(sub_key)) + { + return make_data("{$" + key + "}") ; + } + data_ptr item = data[sub_key] ; + return parse_val(key.substr(index+1), item->getmap()) ; + } + + ////////////////////////////////////////////////////////////////////////// + // Token classes + ////////////////////////////////////////////////////////////////////////// + + // defaults, overridden by subclasses with children + void Token::set_children( token_vector & ) + { + throw TemplateException("This token type cannot have children") ; + } + + token_vector & Token::get_children() + { + throw TemplateException("This token type cannot have children") ; + } + + // TokenText + TokenType TokenText::gettype() + { + return TOKEN_TYPE_TEXT ; + } + + void TokenText::gettext( std::ostream &stream, data_map & ) + { + stream << m_text ; + } + + // TokenVar + TokenType TokenVar::gettype() + { + return TOKEN_TYPE_VAR ; + } + + void TokenVar::gettext( std::ostream &stream, data_map &data ) + { + stream << parse_val(m_key, data)->getvalue() ; + } + + // TokenFor + TokenFor::TokenFor(std::string expr) + { + std::vector elements ; + boost::split(elements, expr, boost::is_space()) ; + if (elements.size() != 4u) + { + throw TemplateException("Invalid syntax in for statement") ; + } + m_val = elements[1] ; + m_key = elements[3] ; + } + + TokenType TokenFor::gettype() + { + return TOKEN_TYPE_FOR ; + } + + void TokenFor::gettext( std::ostream &stream, data_map &data ) + { + data_ptr value = parse_val(m_key, data) ; + data_list &items = value->getlist() ; + for (size_t i = 0 ; i < items.size() ; ++i) + { + data_map loop ; + loop["index"] = make_data(boost::lexical_cast(i+1)) ; + loop["index0"] = make_data(boost::lexical_cast(i)) ; + data["loop"] = make_data(loop); + data[m_val] = items[i] ; + for(size_t j = 0 ; j < m_children.size() ; ++j) + { + m_children[j]->gettext(stream, data) ; + } + } + } + + void TokenFor::set_children( token_vector &children ) + { + m_children.assign(children.begin(), children.end()) ; + } + + token_vector & TokenFor::get_children() + { + return m_children; + } + + // TokenIf + TokenType TokenIf::gettype() + { + return TOKEN_TYPE_IF ; + } + + void TokenIf::gettext( std::ostream &stream, data_map &data ) + { + if (is_true(m_expr, data)) + { + for(size_t j = 0 ; j < m_children.size() ; ++j) + { + m_children[j]->gettext(stream, data) ; + } + } + } + + bool TokenIf::is_true( std::string expr, data_map &data ) + { + std::vector elements ; + boost::split(elements, expr, boost::is_space()) ; + + if (elements[1] == "not") + { + return parse_val(elements[2], data)->empty() ; + } + if (elements.size() == 2) + { + return ! parse_val(elements[1], data)->empty() ; + } + data_ptr lhs = parse_val(elements[1], data) ; + data_ptr rhs = parse_val(elements[3], data) ; + if (elements[2] == "==") + { + return lhs->getvalue() == rhs->getvalue() ; + } + return lhs->getvalue() != rhs->getvalue() ; + } + + void TokenIf::set_children( token_vector &children ) + { + m_children.assign(children.begin(), children.end()) ; + } + + token_vector & TokenIf::get_children() + { + return m_children; + } + + // TokenEnd + TokenType TokenEnd::gettype() + { + return m_type == "endfor" ? TOKEN_TYPE_ENDFOR : TOKEN_TYPE_ENDIF ; + } + + void TokenEnd::gettext( std::ostream &, data_map &) + { + throw TemplateException("End-of-control statements have no associated text") ; + } + + // gettext + // generic helper for getting text from tokens. + + std::string gettext(token_ptr token, data_map &data) + { + std::ostringstream stream ; + token->gettext(stream, data) ; + return stream.str() ; + } + ////////////////////////////////////////////////////////////////////////// + // parse_tree + // recursively parses list of tokens into a tree + ////////////////////////////////////////////////////////////////////////// + void parse_tree(token_vector &tokens, token_vector &tree, TokenType until) + { + while(! tokens.empty()) + { + // 'pops' first item off list + token_ptr token = tokens[0] ; + tokens.erase(tokens.begin()) ; + + if (token->gettype() == TOKEN_TYPE_FOR) + { + token_vector children ; + parse_tree(tokens, children, TOKEN_TYPE_ENDFOR) ; + token->set_children(children) ; + } + else if (token->gettype() == TOKEN_TYPE_IF) + { + token_vector children ; + parse_tree(tokens, children, TOKEN_TYPE_ENDIF) ; + token->set_children(children) ; + } + else if (token->gettype() == until) + { + return ; + } + tree.push_back(token) ; + } + } + ////////////////////////////////////////////////////////////////////////// + // tokenize + // parses a template into tokens (text, for, if, variable) + ////////////////////////////////////////////////////////////////////////// + token_vector & tokenize(std::string text, token_vector &tokens) + { + while(! text.empty()) + { + size_t pos = text.find("{") ; + if (pos == std::string::npos) + { + if (! text.empty()) + { + tokens.push_back(token_ptr(new TokenText(text))) ; + } + return tokens ; + } + std::string pre_text = text.substr(0, pos) ; + if (! pre_text.empty()) + { + tokens.push_back(token_ptr(new TokenText(pre_text))) ; + } + text = text.substr(pos+1) ; + if (text.empty()) + { + tokens.push_back(token_ptr(new TokenText("{"))) ; + return tokens ; + } + + // variable + if (text[0] == '$') + { + pos = text.find("}") ; + if (pos != std::string::npos) + { + tokens.push_back(token_ptr (new TokenVar(text.substr(1, pos-1)))) ; + text = text.substr(pos+1) ; + } + } + // control statement + else if (text[0] == '%') + { + pos = text.find("}") ; + if (pos != std::string::npos) + { + std::string expression = boost::trim_copy(text.substr(1, pos-2)) ; + text = text.substr(pos+1) ; + if (boost::starts_with(expression, "for")) + { + tokens.push_back(token_ptr (new TokenFor(expression))) ; + } + else if (boost::starts_with(expression, "if")) + { + tokens.push_back(token_ptr (new TokenIf(expression))) ; + } + else + { + tokens.push_back(token_ptr (new TokenEnd(boost::trim_copy(expression)))) ; + } + } + } + else + { + tokens.push_back(token_ptr(new TokenText("{"))) ; + } + } + return tokens ; + } + + /************************************************************************ + * parse + * + * 1. tokenizes template + * 2. parses tokens into tree + * 3. resolves template + * 4. returns converted text + ************************************************************************/ + std::string parse(std::string templ_text, data_map &data) + { + std::ostringstream stream ; + parse(stream, templ_text, data) ; + return stream.str() ; + } + void parse(std::ostream &stream, std::string templ_text, data_map &data) + { + token_vector tokens ; + tokenize(templ_text, tokens) ; + token_vector tree ; + parse_tree(tokens, tree) ; + + for (size_t i = 0 ; i < tree.size() ; ++i) + { + // Recursively calls gettext on each node in the tree. + // gettext returns the appropriate text for that node. + // for text, itself; + // for variable, substitution; + // for control statement, recursively gets kids + tree[i]->gettext(stream, data) ; + } + } +} diff --git a/resources/3rdparty/cpptemplate/cpptempl.h b/resources/3rdparty/cpptemplate/cpptempl.h new file mode 100755 index 000000000..b6a19d293 --- /dev/null +++ b/resources/3rdparty/cpptemplate/cpptempl.h @@ -0,0 +1,269 @@ +/* +cpptempl +================= +This is a template engine for C++. + +Syntax +================= +Variables: {$variable_name} +Loops: {% for person in people %}Name: {$person.name}{% endfor %} +If: {% for person.name == "Bob" %}Full name: Robert{% endif %} + +Copyright +================== +Author: Ryan Ginstrom +MIT License + +Usage +======================= + std::string text = "{% if item %}{$item}{% endif %}\n" + "{% if thing %}{$thing}{% endif %}" ; + cpptempl::data_map data ; + data["item"] = cpptempl::make_data("aaa") ; + data["thing"] = cpptempl::make_data("bbb") ; + + std::string result = cpptempl::parse(text, data) ; + +Handy Functions +======================== +make_data() : Feed it a string, data_map, or data_list to create a data entry. +Example: + data_map person ; + person["name"] = make_data("Bob") ; + person["occupation"] = make_data("Plumber") ; + data_map data ; + data["person"] = make_data(person) ; + std::string result = parse(templ_text, data) ; + +*/ +#pragma once + +#ifdef _WIN32 +#pragma warning( disable : 4996 ) // 'std::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' +#pragma warning( disable : 4512 ) // 'std::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' +#endif + +#include +#include +#include +#include +#include +#include + +#include + +namespace cpptempl +{ + // various typedefs + + // data classes + class Data ; + class DataValue ; + class DataList ; + class DataMap ; + + class data_ptr { + public: + data_ptr() {} + template data_ptr(const T& data) { + this->operator =(data); + } + data_ptr(DataValue* data); + data_ptr(DataList* data); + data_ptr(DataMap* data); + data_ptr(const data_ptr& data) { + ptr = data.ptr; + } + template void operator = (const T& data); + void push_back(const data_ptr& data); + virtual ~data_ptr() {} + Data* operator ->() { + return ptr.get(); + } + private: + std::shared_ptr ptr; + }; + typedef std::vector data_list ; + + class data_map { + public: + data_ptr& operator [](const std::string& key); + bool empty(); + bool has(const std::string& key); + private: + std::unordered_map data; + }; + + template<> inline void data_ptr::operator = (const data_ptr& data); + template<> void data_ptr::operator = (const std::string& data); + template<> void data_ptr::operator = (const std::string& data); + template<> void data_ptr::operator = (const data_map& data); + template + void data_ptr::operator = (const T& data) { + std::string data_str = boost::lexical_cast(data); + this->operator =(data_str); + } + + // token classes + class Token ; + typedef std::shared_ptr token_ptr ; + typedef std::vector token_vector ; + + // Custom exception class for library errors + class TemplateException : public std::exception + { + public: + TemplateException(std::string reason) : m_reason(reason){} + ~TemplateException() {} + const char* what() const noexcept { + return m_reason.c_str(); + } + private: + std::string m_reason; + }; + + // Data types used in templates + class Data + { + public: + virtual bool empty() = 0 ; + virtual std::string getvalue(); + virtual data_list& getlist(); + virtual data_map& getmap() ; + }; + + class DataValue : public Data + { + std::string m_value ; + public: + DataValue(std::string value) : m_value(value){} + std::string getvalue(); + bool empty(); + }; + + class DataList : public Data + { + data_list m_items ; + public: + DataList(const data_list &items) : m_items(items){} + data_list& getlist() ; + bool empty(); + }; + + class DataMap : public Data + { + data_map m_items ; + public: + DataMap(const data_map &items) : m_items(items){} + data_map& getmap(); + bool empty(); + }; + + // convenience functions for making data objects + inline data_ptr make_data(std::string val) + { + return data_ptr(new DataValue(val)) ; + } + inline data_ptr make_data(data_list &val) + { + return data_ptr(new DataList(val)) ; + } + inline data_ptr make_data(data_map &val) + { + return data_ptr(new DataMap(val)) ; + } + // get a data value from a data map + // e.g. foo.bar => data["foo"]["bar"] + data_ptr parse_val(std::string key, data_map &data) ; + + typedef enum + { + TOKEN_TYPE_NONE, + TOKEN_TYPE_TEXT, + TOKEN_TYPE_VAR, + TOKEN_TYPE_IF, + TOKEN_TYPE_FOR, + TOKEN_TYPE_ENDIF, + TOKEN_TYPE_ENDFOR, + } TokenType; + + // Template tokens + // base class for all token types + class Token + { + public: + virtual TokenType gettype() = 0 ; + virtual void gettext(std::ostream &stream, data_map &data) = 0 ; + virtual void set_children(token_vector &children); + virtual token_vector & get_children(); + }; + + // normal text + class TokenText : public Token + { + std::string m_text ; + public: + TokenText(std::string text) : m_text(text){} + TokenType gettype(); + void gettext(std::ostream &stream, data_map &data); + }; + + // variable + class TokenVar : public Token + { + std::string m_key ; + public: + TokenVar(std::string key) : m_key(key){} + TokenType gettype(); + void gettext(std::ostream &stream, data_map &data); + }; + + // for block + class TokenFor : public Token + { + public: + std::string m_key ; + std::string m_val ; + token_vector m_children ; + TokenFor(std::string expr); + TokenType gettype(); + void gettext(std::ostream &stream, data_map &data); + void set_children(token_vector &children); + token_vector &get_children(); + }; + + // if block + class TokenIf : public Token + { + public: + std::string m_expr ; + token_vector m_children ; + TokenIf(std::string expr) : m_expr(expr){} + TokenType gettype(); + void gettext(std::ostream &stream, data_map &data); + bool is_true(std::string expr, data_map &data); + void set_children(token_vector &children); + token_vector &get_children(); + }; + + // end of block + class TokenEnd : public Token // end of control block + { + std::string m_type ; + public: + TokenEnd(std::string text) : m_type(text){} + TokenType gettype(); + void gettext(std::ostream &stream, data_map &data); + }; + + std::string gettext(token_ptr token, data_map &data) ; + + void parse_tree(token_vector &tokens, token_vector &tree, TokenType until=TOKEN_TYPE_NONE) ; + token_vector & tokenize(std::string text, token_vector &tokens) ; + + // The big daddy. Pass in the template and data, + // and get out a completed doc. + void parse(std::ostream &stream, std::string templ_text, data_map &data) ; + std::string parse(std::string templ_text, data_map &data); + std::string parse(std::string templ_text, data_map &data); +} diff --git a/resources/3rdparty/cpptemplate/cpptempl_test.cpp b/resources/3rdparty/cpptemplate/cpptempl_test.cpp new file mode 100755 index 000000000..c7a22a6dd --- /dev/null +++ b/resources/3rdparty/cpptemplate/cpptempl_test.cpp @@ -0,0 +1,883 @@ + +#include "cpptempl.h" + +#ifdef UNIT_TEST + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE cpptemplTests +#endif + +#pragma warning( disable : 4996 ) // doesn't like wcstombs + +#include "unit_testing.h" + +using namespace std ; + +BOOST_AUTO_TEST_SUITE( TestCppData ) + + using namespace cpptempl ; + + // DataMap + BOOST_AUTO_TEST_CASE(test_DataMap_getvalue) + { + data_map items ; + data_ptr data(new DataMap(items)) ; + BOOST_CHECK_THROW( data->getvalue(), TemplateException ) ; + } + BOOST_AUTO_TEST_CASE(test_DataMap_getlist_throws) + { + data_map items ; + data_ptr data(new DataMap(items)) ; + + BOOST_CHECK_THROW( data->getlist(), TemplateException ) ; + } + BOOST_AUTO_TEST_CASE(test_DataMap_getitem_throws) + { + data_map items ; + items[L"key"] = data_ptr(new DataValue(L"foo")) ; + data_ptr data(new DataMap(items)) ; + + BOOST_CHECK_EQUAL( data->getmap()[L"key"]->getvalue(), L"foo" ) ; + } + // DataList + BOOST_AUTO_TEST_CASE(test_DataList_getvalue) + { + data_list items ; + data_ptr data(new DataList(items)) ; + + BOOST_CHECK_THROW( data->getvalue(), TemplateException ) ; + } + BOOST_AUTO_TEST_CASE(test_DataList_getlist_throws) + { + data_list items ; + items.push_back(make_data(L"bar")) ; + data_ptr data(new DataList(items)) ; + + BOOST_CHECK_EQUAL( data->getlist().size(), 1u ) ; + } + BOOST_AUTO_TEST_CASE(test_DataList_getitem_throws) + { + data_list items ; + data_ptr data(new DataList(items)) ; + + BOOST_CHECK_THROW( data->getmap(), TemplateException ) ; + } + // DataValue + BOOST_AUTO_TEST_CASE(test_DataValue_getvalue) + { + data_ptr data(new DataValue(L"foo")) ; + + BOOST_CHECK_EQUAL( data->getvalue(), L"foo" ) ; + } + BOOST_AUTO_TEST_CASE(test_DataValue_getlist_throws) + { + data_ptr data(new DataValue(L"foo")) ; + + BOOST_CHECK_THROW( data->getlist(), TemplateException ) ; + } + BOOST_AUTO_TEST_CASE(test_DataValue_getitem_throws) + { + data_ptr data(new DataValue(L"foo")) ; + + BOOST_CHECK_THROW( data->getmap(), TemplateException ) ; + } +BOOST_AUTO_TEST_SUITE_END() + + +BOOST_AUTO_TEST_SUITE( TestCppParseVal ) + + using namespace cpptempl ; + BOOST_AUTO_TEST_CASE(test_quoted) + { + data_map data ; + data[L"foo"] = make_data(L"bar") ; + data_ptr value = parse_val(L"\"foo\"", data) ; + + BOOST_CHECK_EQUAL( value->getvalue(), L"foo" ) ; + } + BOOST_AUTO_TEST_CASE(test_value) + { + data_map data ; + data[L"foo"] = make_data(L"bar") ; + data_ptr value = parse_val(L"foo", data) ; + + BOOST_CHECK_EQUAL( value->getvalue(), L"bar" ) ; + } + BOOST_AUTO_TEST_CASE(test_not_found) + { + data_map data ; + data[L"foo"] = make_data(L"bar") ; + data_ptr value = parse_val(L"kettle", data) ; + + BOOST_CHECK_EQUAL( value->getvalue(), L"{$kettle}" ) ; + } + BOOST_AUTO_TEST_CASE(test_not_found_dotted) + { + data_map data ; + data[L"foo"] = make_data(L"bar") ; + data_ptr value = parse_val(L"kettle.black", data) ; + + BOOST_CHECK_EQUAL( value->getvalue(), L"{$kettle.black}" ) ; + } + BOOST_AUTO_TEST_CASE(test_my_ax) + { + data_map data ; + data[L"item"] = make_data(L"my ax") ; + BOOST_CHECK_EQUAL( parse_val(L"item", data)->getvalue(), L"my ax" ) ; + } + BOOST_AUTO_TEST_CASE(test_list) + { + data_map data ; + data_list items ; + items.push_back(make_data(L"bar")) ; + data[L"foo"] = data_ptr(new DataList(items)) ; + data_ptr value = parse_val(L"foo", data) ; + + BOOST_CHECK_EQUAL( value->getlist().size(), 1u ) ; + } + BOOST_AUTO_TEST_CASE(test_dotted) + { + data_map data ; + data_map subdata ; + subdata[L"b"] = data_ptr(new DataValue(L"c")) ; + data[L"a"] = data_ptr(new DataMap(subdata)) ; + data_ptr value = parse_val(L"a.b", data) ; + + BOOST_CHECK_EQUAL( value->getvalue(), L"c" ) ; + } + BOOST_AUTO_TEST_CASE(test_double_dotted) + { + data_map data ; + data_map sub_data ; + data_map sub_sub_data ; + sub_sub_data[L"c"] = data_ptr(new DataValue(L"d")) ; + sub_data[L"b"] = data_ptr(new DataMap(sub_sub_data)) ; + data[L"a"] = data_ptr(new DataMap(sub_data)) ; + data_ptr value = parse_val(L"a.b.c", data) ; + + BOOST_CHECK_EQUAL( value->getvalue(), L"d" ) ; + } + BOOST_AUTO_TEST_CASE(test_dotted_to_list) + { + data_list friends ; + friends.push_back(make_data(L"Bob")) ; + data_map person ; + person[L"friends"] = make_data(friends) ; + data_map data ; + data[L"person"] = make_data(person) ; + data_ptr value = parse_val(L"person.friends", data) ; + + BOOST_CHECK_EQUAL( value->getlist().size(), 1u ) ; + } + BOOST_AUTO_TEST_CASE(test_dotted_to_dict_list) + { + data_map bob ; + bob[L"name"] = make_data(L"Bob") ; + data_map betty ; + betty[L"name"] = make_data(L"Betty") ; + data_list friends ; + friends.push_back(make_data(bob)) ; + friends.push_back(make_data(betty)) ; + data_map person ; + person[L"friends"] = make_data(friends) ; + data_map data ; + data[L"person"] = make_data(person) ; + data_ptr value = parse_val(L"person.friends", data) ; + + BOOST_CHECK_EQUAL( value->getlist()[0]->getmap()[L"name"]->getvalue(), L"Bob" ) ; + } +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE( TestCppToken ) + + using namespace cpptempl ; + + // TokenVar + BOOST_AUTO_TEST_CASE(TestTokenVarType) + { + TokenVar token(L"foo") ; + BOOST_CHECK_EQUAL( token.gettype(), TOKEN_TYPE_VAR ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenVar) + { + token_ptr token(new TokenVar(L"foo")) ; + data_map data ; + data[L"foo"] = make_data(L"bar") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"bar" ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenVarCantHaveChildren) + { + TokenVar token(L"foo") ; + token_vector children ; + BOOST_CHECK_THROW(token.set_children(children), TemplateException) ; + } + // TokenText + BOOST_AUTO_TEST_CASE(TestTokenTextType) + { + TokenText token(L"foo") ; + BOOST_CHECK_EQUAL( token.gettype(), TOKEN_TYPE_TEXT ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenText) + { + token_ptr token(new TokenText(L"foo")) ; + data_map data ; + data[L"foo"] = make_data(L"bar") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"foo" ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenTextCantHaveChildrenSet) + { + TokenText token(L"foo") ; + token_vector children ; + BOOST_CHECK_THROW(token.set_children(children), TemplateException) ; + } + BOOST_AUTO_TEST_CASE(TestTokenTextCantHaveChildrenGet) + { + TokenText token(L"foo") ; + token_vector children ; + BOOST_CHECK_THROW(token.get_children(), TemplateException) ; + } + // TokenFor + BOOST_AUTO_TEST_CASE(TestTokenForBadSyntax) + { + BOOST_CHECK_THROW(TokenFor token(L"foo"), TemplateException ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenForType) + { + TokenFor token(L"for item in items") ; + BOOST_CHECK_EQUAL( token.gettype(), TOKEN_TYPE_FOR ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenForTextEmpty) + { + token_ptr token(new TokenFor(L"for item in items")) ; + data_map data ; + data_list items ; + items.push_back(make_data(L"first")); + data[L"items"] = make_data(items) ; + BOOST_CHECK_EQUAL( gettext(token, data), L"" ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenForTextOneVar) + { + token_vector children ; + children.push_back(token_ptr(new TokenVar(L"item"))) ; + token_ptr token(new TokenFor(L"for item in items")) ; + token->set_children(children) ; + data_map data ; + data_list items ; + items.push_back(make_data(L"first ")); + items.push_back(make_data(L"second ")); + data[L"items"] = make_data(items) ; + BOOST_CHECK_EQUAL( gettext(token, data), L"first second " ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenForTextOneVarLoop) + { + token_vector children ; + children.push_back(token_ptr(new TokenVar(L"loop.index"))) ; + token_ptr token(new TokenFor(L"for item in items")) ; + token->set_children(children) ; + data_map data ; + data_list items ; + items.push_back(make_data(L"first ")); + items.push_back(make_data(L"second ")); + data[L"items"] = make_data(items) ; + BOOST_CHECK_EQUAL( gettext(token, data), L"12" ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenForLoopTextVar) + { + token_vector children ; + children.push_back(token_ptr(new TokenVar(L"loop.index"))) ; + children.push_back(token_ptr(new TokenText(L". "))) ; + children.push_back(token_ptr(new TokenVar(L"item"))) ; + children.push_back(token_ptr(new TokenText(L" "))) ; + token_ptr token(new TokenFor(L"for item in items")) ; + token->set_children(children) ; + data_map data ; + data_list items ; + items.push_back(make_data(L"first")); + items.push_back(make_data(L"second")); + data[L"items"] = make_data(items) ; + BOOST_CHECK_EQUAL( gettext(token, data), L"1. first 2. second " ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenForLoopTextVarDottedKeyAndVal) + { + TokenFor token(L"for friend in person.friends") ; + BOOST_CHECK_EQUAL( token.m_key, L"person.friends" ) ; + BOOST_CHECK_EQUAL( token.m_val, L"friend" ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenForLoopTextVarDotted) + { + token_vector children ; + children.push_back(token_ptr(new TokenVar(L"loop.index"))) ; + children.push_back(token_ptr(new TokenText(L". "))) ; + children.push_back(token_ptr(new TokenVar(L"friend.name"))) ; + children.push_back(token_ptr(new TokenText(L" "))) ; + token_ptr token(new TokenFor(L"for friend in person.friends")) ; + token->set_children(children) ; + + data_map bob ; + bob[L"name"] = make_data(L"Bob") ; + data_map betty ; + betty[L"name"] = make_data(L"Betty") ; + data_list friends ; + friends.push_back(make_data(bob)) ; + friends.push_back(make_data(betty)) ; + data_map person ; + person[L"friends"] = make_data(friends) ; + data_map data ; + data[L"person"] = make_data(person) ; + + BOOST_CHECK_EQUAL( gettext(token, data), L"1. Bob 2. Betty " ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenForTextOneText) + { + token_vector children ; + children.push_back(token_ptr(new TokenText(L"{--}"))) ; + token_ptr token(new TokenFor(L"for item in items")) ; + token->set_children(children) ; + data_map data ; + data_list items ; + items.push_back(make_data(L"first ")); + items.push_back(make_data(L"second ")); + data[L"items"] = make_data(items) ; + BOOST_CHECK_EQUAL( gettext(token, data), L"{--}{--}" ) ; + } + + ////////////////////////////////////////////////////////////////////////// + // TokenIf + ////////////////////////////////////////////////////////////////////////// + + BOOST_AUTO_TEST_CASE(TestTokenIfType) + { + TokenIf token(L"if items") ; + BOOST_CHECK_EQUAL( token.gettype(), TOKEN_TYPE_IF ) ; + } + // if not empty + BOOST_AUTO_TEST_CASE(TestTokenIfTrueText) + { + token_vector children ; + children.push_back(token_ptr(new TokenText(L"{--}"))) ; + token_ptr token(new TokenIf(L"if item")) ; + token->set_children(children) ; + data_map data ; + data[L"item"] = make_data(L"foo") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"{--}" ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenIfTrueVar) + { + token_vector children ; + children.push_back(token_ptr(new TokenVar(L"item"))) ; + token_ptr token(new TokenIf(L"if item")) ; + token->set_children(children) ; + data_map data ; + data[L"item"] = make_data(L"foo") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"foo" ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenIfFalse) + { + token_vector children ; + children.push_back(token_ptr(new TokenText(L"{--}"))) ; + token_ptr token(new TokenIf(L"if item")) ; + token->set_children(children) ; + data_map data ; + data[L"item"] = make_data(L"") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"") ; + } + + + + // == + BOOST_AUTO_TEST_CASE(TestTokenIfEqualsTrue) + { + token_vector children ; + children.push_back(token_ptr(new TokenVar(L"item"))) ; + token_ptr token(new TokenIf(L"if item == \"foo\"")) ; + token->set_children(children) ; + data_map data ; + data[L"item"] = make_data(L"foo") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"foo" ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenIfEqualsFalse) + { + token_vector children ; + children.push_back(token_ptr(new TokenVar(L"item"))) ; + token_ptr token(new TokenIf(L"if item == \"bar\"")) ; + token->set_children(children) ; + data_map data ; + data[L"item"] = make_data(L"foo") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"" ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenIfEqualsTwoVarsTrue) + { + token_vector children ; + children.push_back(token_ptr(new TokenVar(L"item"))) ; + token_ptr token(new TokenIf(L"if item == foo")) ; + token->set_children(children) ; + data_map data ; + data[L"item"] = make_data(L"x") ; + data[L"foo"] = make_data(L"x") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"x" ) ; + } + + // != + BOOST_AUTO_TEST_CASE(TestTokenIfNotEqualsTrue) + { + token_vector children ; + children.push_back(token_ptr(new TokenVar(L"item"))) ; + token_ptr token(new TokenIf(L"if item != \"foo\"")) ; + token->set_children(children) ; + data_map data ; + data[L"item"] = make_data(L"foo") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"" ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenIfNotEqualsFalse) + { + token_vector children ; + children.push_back(token_ptr(new TokenVar(L"item"))) ; + token_ptr token(new TokenIf(L"if item != \"bar\"")) ; + token->set_children(children) ; + data_map data ; + data[L"item"] = make_data(L"foo") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"foo" ) ; + } + + // not + BOOST_AUTO_TEST_CASE(TestTokenIfNotTrueText) + { + token_vector children ; + children.push_back(token_ptr(new TokenText(L"{--}"))) ; + token_ptr token(new TokenIf(L"if not item")) ; + token->set_children(children) ; + data_map data ; + data[L"item"] = make_data(L"foo") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"") ; + } + + BOOST_AUTO_TEST_CASE(TestTokenIfNotFalseText) + { + token_vector children ; + children.push_back(token_ptr(new TokenText(L"{--}"))) ; + token_ptr token(new TokenIf(L"if not item")) ; + token->set_children(children) ; + data_map data ; + data[L"item"] = make_data(L"") ; + BOOST_CHECK_EQUAL( gettext(token, data), L"{--}") ; + } + + // TokenEnd + BOOST_AUTO_TEST_CASE(TestTokenEndFor) + { + TokenEnd token(L"endfor") ; + BOOST_CHECK_EQUAL( token.gettype(), TOKEN_TYPE_ENDFOR ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenEndIf) + { + TokenEnd token(L"endif") ; + BOOST_CHECK_EQUAL( token.gettype(), TOKEN_TYPE_ENDIF ) ; + } + BOOST_AUTO_TEST_CASE(TestTokenEndIfCantHaveChildren) + { + TokenEnd token(L"endif") ; + token_vector children ; + BOOST_CHECK_THROW(token.set_children(children), TemplateException) ; + } + BOOST_AUTO_TEST_CASE(test_throws_on_gettext) + { + data_map data ; + token_ptr token(new TokenEnd(L"endif")) ; + + BOOST_CHECK_THROW(gettext(token, data), TemplateException) ; + } +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE( TestCppTokenize ) + + using namespace cpptempl ; + + BOOST_AUTO_TEST_CASE(test_empty) + { + wstring text = L"" ; + token_vector tokens ; + tokenize(text, tokens) ; + + BOOST_CHECK_EQUAL( 0u, tokens.size() ) ; + } + BOOST_AUTO_TEST_CASE(test_text_only) + { + wstring text = L"blah blah blah" ; + token_vector tokens ; + tokenize(text, tokens) ; + data_map data ; + + BOOST_CHECK_EQUAL( 1u, tokens.size() ) ; + BOOST_CHECK_EQUAL( gettext(tokens[0], data), L"blah blah blah" ) ; + } + BOOST_AUTO_TEST_CASE(test_brackets_no_var) + { + wstring text = L"{foo}" ; + token_vector tokens ; + tokenize(text, tokens) ; + data_map data ; + + BOOST_CHECK_EQUAL( 2u, tokens.size() ) ; + BOOST_CHECK_EQUAL( gettext(tokens[0], data), L"{" ) ; + BOOST_CHECK_EQUAL( gettext(tokens[1], data), L"foo}" ) ; + } + BOOST_AUTO_TEST_CASE(test_ends_with_bracket) + { + wstring text = L"blah blah blah{" ; + token_vector tokens ; + tokenize(text, tokens) ; + data_map data ; + + BOOST_CHECK_EQUAL( 2u, tokens.size() ) ; + BOOST_CHECK_EQUAL( gettext(tokens[0], data), L"blah blah blah" ) ; + BOOST_CHECK_EQUAL( gettext(tokens[1], data), L"{" ) ; + } + // var + BOOST_AUTO_TEST_CASE(test_var) + { + wstring text = L"{$foo}" ; + token_vector tokens ; + tokenize(text, tokens) ; + data_map data ; + data[L"foo"] = make_data(L"bar") ; + + BOOST_CHECK_EQUAL( 1u, tokens.size() ) ; + BOOST_CHECK_EQUAL( gettext(tokens[0], data), L"bar" ) ; + } + // for + BOOST_AUTO_TEST_CASE(test_for) + { + wstring text = L"{% for item in items %}" ; + token_vector tokens ; + tokenize(text, tokens) ; + + BOOST_CHECK_EQUAL( 1u, tokens.size() ) ; + BOOST_CHECK_EQUAL( tokens[0]->gettype(), TOKEN_TYPE_FOR ) ; + } + BOOST_AUTO_TEST_CASE(test_for_full) + { + wstring text = L"{% for item in items %}{$item}{% endfor %}" ; + token_vector tokens ; + tokenize(text, tokens) ; + + BOOST_CHECK_EQUAL( 3u, tokens.size() ) ; + BOOST_CHECK_EQUAL( tokens[0]->gettype(), TOKEN_TYPE_FOR ) ; + BOOST_CHECK_EQUAL( tokens[1]->gettype(), TOKEN_TYPE_VAR ) ; + BOOST_CHECK_EQUAL( tokens[2]->gettype(), TOKEN_TYPE_ENDFOR ) ; + } + BOOST_AUTO_TEST_CASE(test_for_full_with_text) + { + wstring text = L"{% for item in items %}*{$item}*{% endfor %}" ; + token_vector tokens ; + tokenize(text, tokens) ; + data_map data ; + data[L"item"] = make_data(L"my ax") ; + + BOOST_CHECK_EQUAL( 5u, tokens.size() ) ; + BOOST_CHECK_EQUAL( tokens[0]->gettype(), TOKEN_TYPE_FOR ) ; + BOOST_CHECK_EQUAL( gettext(tokens[1], data), L"*" ) ; + BOOST_CHECK_EQUAL( tokens[2]->gettype(), TOKEN_TYPE_VAR ) ; + BOOST_CHECK_EQUAL( gettext(tokens[2], data), L"my ax" ) ; + BOOST_CHECK_EQUAL( gettext(tokens[3], data), L"*" ) ; + BOOST_CHECK_EQUAL( tokens[4]->gettype(), TOKEN_TYPE_ENDFOR ) ; + } + // if + BOOST_AUTO_TEST_CASE(test_if) + { + wstring text = L"{% if foo %}" ; + token_vector tokens ; + tokenize(text, tokens) ; + + BOOST_CHECK_EQUAL( 1u, tokens.size() ) ; + BOOST_CHECK_EQUAL( tokens[0]->gettype(), TOKEN_TYPE_IF ) ; + } + BOOST_AUTO_TEST_CASE(test_if_full) + { + wstring text = L"{% if item %}{$item}{% endif %}" ; + token_vector tokens ; + tokenize(text, tokens) ; + + BOOST_CHECK_EQUAL( 3u, tokens.size() ) ; + BOOST_CHECK_EQUAL( tokens[0]->gettype(), TOKEN_TYPE_IF ) ; + BOOST_CHECK_EQUAL( tokens[1]->gettype(), TOKEN_TYPE_VAR ) ; + BOOST_CHECK_EQUAL( tokens[2]->gettype(), TOKEN_TYPE_ENDIF ) ; + } + BOOST_AUTO_TEST_CASE(test_if_full_with_text) + { + wstring text = L"{% if item %}{{$item}}{% endif %}" ; + token_vector tokens ; + tokenize(text, tokens) ; + data_map data ; + data[L"item"] = make_data(L"my ax") ; + + BOOST_CHECK_EQUAL( 5u, tokens.size() ) ; + BOOST_CHECK_EQUAL( tokens[0]->gettype(), TOKEN_TYPE_IF ) ; + BOOST_CHECK_EQUAL( gettext(tokens[1], data), L"{" ) ; + BOOST_CHECK_EQUAL( tokens[2]->gettype(), TOKEN_TYPE_VAR ) ; + BOOST_CHECK_EQUAL( gettext(tokens[2], data), L"my ax" ) ; + BOOST_CHECK_EQUAL( gettext(tokens[3], data), L"}" ) ; + BOOST_CHECK_EQUAL( tokens[4]->gettype(), TOKEN_TYPE_ENDIF ) ; + } + +BOOST_AUTO_TEST_SUITE_END() + + +BOOST_AUTO_TEST_SUITE( test_parse_tree ) + + using namespace cpptempl ; + + token_ptr make_tt(wstring text) + { + return token_ptr(new TokenText(text)) ; + } + token_ptr make_for(wstring text) + { + return token_ptr(new TokenFor(text)) ; + } + token_ptr make_if(wstring text) + { + return token_ptr(new TokenIf(text)) ; + } + token_ptr make_endfor() + { + return token_ptr(new TokenEnd(L"endfor")) ; + } + token_ptr make_endif() + { + return token_ptr(new TokenEnd(L"endif")) ; + } + BOOST_AUTO_TEST_CASE(test_empty) + { + token_vector tokens ; + token_vector tree ; + parse_tree(tokens, tree) ; + BOOST_CHECK_EQUAL( 0u, tree.size() ) ; + } + BOOST_AUTO_TEST_CASE(test_one) + { + token_vector tokens ; + tokens.push_back(make_tt(L"foo")) ; + token_vector tree ; + parse_tree(tokens, tree) ; + BOOST_CHECK_EQUAL( 1u, tree.size() ) ; + } + BOOST_AUTO_TEST_CASE(test_for) + { + token_vector tokens ; + tokens.push_back(make_for(L"for item in items")) ; + tokens.push_back(make_tt(L"foo")) ; + tokens.push_back(make_endfor()) ; + token_vector tree ; + parse_tree(tokens, tree) ; + BOOST_CHECK_EQUAL( 1u, tree.size() ) ; + BOOST_CHECK_EQUAL( 1u, tree[0]->get_children().size()) ; + } + BOOST_AUTO_TEST_CASE(test_if) + { + token_vector tokens ; + tokens.push_back(make_if(L"if insane")) ; + tokens.push_back(make_tt(L"foo")) ; + tokens.push_back(make_endif()) ; + token_vector tree ; + parse_tree(tokens, tree) ; + BOOST_CHECK_EQUAL( 1u, tree.size() ) ; + BOOST_CHECK_EQUAL( 1u, tree[0]->get_children().size()) ; + } +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(TestCppParse) + + using namespace cpptempl ; + + BOOST_AUTO_TEST_CASE(test_empty) + { + wstring text = L"" ; + data_map data ; + wstring actual = parse(text, data) ; + wstring expected = L"" ; + BOOST_CHECK_EQUAL( expected, actual ) ; + } + BOOST_AUTO_TEST_CASE(test_no_vars) + { + wstring text = L"foo" ; + data_map data ; + wstring actual = parse(text, data) ; + wstring expected = L"foo" ; + BOOST_CHECK_EQUAL( expected, actual ) ; + } + BOOST_AUTO_TEST_CASE(test_var) + { + wstring text = L"{$foo}" ; + data_map data ; + data[L"foo"] = make_data(L"bar") ; + wstring actual = parse(text, data) ; + wstring expected = L"bar" ; + BOOST_CHECK_EQUAL( expected, actual ) ; + } + BOOST_AUTO_TEST_CASE(test_var_surrounded) + { + wstring text = L"aaa{$foo}bbb" ; + data_map data ; + data[L"foo"] = make_data(L"---") ; + wstring actual = parse(text, data) ; + wstring expected = L"aaa---bbb" ; + BOOST_CHECK_EQUAL( expected, actual ) ; + } + BOOST_AUTO_TEST_CASE(test_for) + { + wstring text = L"{% for item in items %}{$item}{% endfor %}" ; + data_map data ; + data_list items ; + items.push_back(make_data(L"0")) ; + items.push_back(make_data(L"1")) ; + data[L"items"] = make_data(items) ; + wstring actual = parse(text, data) ; + wstring expected = L"01" ; + BOOST_CHECK_EQUAL( expected, actual ) ; + } + BOOST_AUTO_TEST_CASE(test_if_false) + { + wstring text = L"{% if item %}{$item}{% endif %}" ; + data_map data ; + data[L"item"] = make_data(L"") ; + wstring actual = parse(text, data) ; + wstring expected = L"" ; + BOOST_CHECK_EQUAL( expected, actual ) ; + } + BOOST_AUTO_TEST_CASE(test_if_true) + { + wstring text = L"{% if item %}{$item}{% endif %}" ; + data_map data ; + data[L"item"] = make_data(L"foo") ; + wstring actual = parse(text, data) ; + wstring expected = L"foo" ; + BOOST_CHECK_EQUAL( expected, actual ) ; + } + BOOST_AUTO_TEST_CASE(test_nested_for) + { + wstring text = L"{% for item in items %}{% for thing in things %}{$item}{$thing}{% endfor %}{% endfor %}" ; + data_map data ; + data_list items ; + items.push_back(make_data(L"0")) ; + items.push_back(make_data(L"1")) ; + data[L"items"] = make_data(items) ; + data_list things ; + things.push_back(make_data(L"a")) ; + things.push_back(make_data(L"b")) ; + data[L"things"] = make_data(things) ; + wstring actual = parse(text, data) ; + wstring expected = L"0a0b1a1b" ; + BOOST_CHECK_EQUAL( expected, actual ) ; + } + BOOST_AUTO_TEST_CASE(test_nested_if_false) + { + wstring text = L"{% if item %}{% if thing %}{$item}{$thing}{% endif %}{% endif %}" ; + data_map data ; + data[L"item"] = make_data(L"aaa") ; + data[L"thing"] = make_data(L"") ; + wstring actual = parse(text, data) ; + wstring expected = L"" ; + BOOST_CHECK_EQUAL( expected, actual ) ; + } + BOOST_AUTO_TEST_CASE(test_nested_if_true) + { + wstring text = L"{% if item %}{% if thing %}{$item}{$thing}{% endif %}{% endif %}" ; + data_map data ; + data[L"item"] = make_data(L"aaa") ; + data[L"thing"] = make_data(L"bbb") ; + wstring actual = parse(text, data) ; + wstring expected = L"aaabbb" ; + BOOST_CHECK_EQUAL( expected, actual ) ; + } + BOOST_AUTO_TEST_CASE(test_usage_example) + { + wstring text = L"{% if item %}{$item}{% endif %}\n" + L"{% if thing %}{$thing}{% endif %}" ; + cpptempl::data_map data ; + data[L"item"] = cpptempl::make_data(L"aaa") ; + data[L"thing"] = cpptempl::make_data(L"bbb") ; + + wstring result = cpptempl::parse(text, data) ; + + wstring expected = L"aaa\nbbb" ; + BOOST_CHECK_EQUAL( result, expected ) ; + } + BOOST_AUTO_TEST_CASE(test_syntax_if) + { + wstring text = L"{% if person.name == \"Bob\" %}Full name: Robert{% endif %}" ; + data_map person ; + person[L"name"] = make_data(L"Bob") ; + person[L"occupation"] = make_data(L"Plumber") ; + data_map data ; + data[L"person"] = make_data(person) ; + + wstring result = cpptempl::parse(text, data) ; + + wstring expected = L"Full name: Robert" ; + BOOST_CHECK_EQUAL( result, expected ) ; + } + BOOST_AUTO_TEST_CASE(test_syntax_dotted) + { + wstring text = L"{% for friend in person.friends %}" + L"{$loop.index}. {$friend.name} " + L"{% endfor %}" ; + + data_map bob ; + bob[L"name"] = make_data(L"Bob") ; + data_map betty ; + betty[L"name"] = make_data(L"Betty") ; + data_list friends ; + friends.push_back(make_data(bob)) ; + friends.push_back(make_data(betty)) ; + data_map person ; + person[L"friends"] = make_data(friends) ; + data_map data ; + data[L"person"] = make_data(person) ; + + wstring result = cpptempl::parse(text, data) ; + + wstring expected = L"1. Bob 2. Betty " ; + BOOST_CHECK_EQUAL( result, expected ) ; + } + BOOST_AUTO_TEST_CASE(test_example_okinawa) + { + // The text template + wstring text = L"I heart {$place}!" ; + // Data to feed the template engine + cpptempl::data_map data ; + // {$place} => Okinawa + data[L"place"] = cpptempl::make_data(L"Okinawa"); + // parse the template with the supplied data dictionary + wstring result = cpptempl::parse(text, data) ; + + wstring expected = L"I heart Okinawa!" ; + BOOST_CHECK_EQUAL( result, expected ) ; + } + BOOST_AUTO_TEST_CASE(test_example_ul) + { + wstring text = L"

Locations

    " + L"{% for place in places %}" + L"
  • {$place}
  • " + L"{% endfor %}" + L"
" ; + + // Create the list of items + cpptempl::data_list places; + places.push_back(cpptempl::make_data(L"Okinawa")); + places.push_back(cpptempl::make_data(L"San Francisco")); + // Now set this in the data map + cpptempl::data_map data ; + data[L"places"] = cpptempl::make_data(places); + // parse the template with the supplied data dictionary + wstring result = cpptempl::parse(text, data) ; + wstring expected = L"

Locations

    " + L"
  • Okinawa
  • " + L"
  • San Francisco
  • " + L"
" ; + BOOST_CHECK_EQUAL(result, expected) ; + } +BOOST_AUTO_TEST_SUITE_END() + +#endif \ No newline at end of file diff --git a/resources/3rdparty/cpptemplate/unit_testing.h b/resources/3rdparty/cpptemplate/unit_testing.h new file mode 100755 index 000000000..1ac551811 --- /dev/null +++ b/resources/3rdparty/cpptemplate/unit_testing.h @@ -0,0 +1,41 @@ +#pragma once + +#include +#include +#include +#ifndef _MSC_VER +#include +#else +#include +#include "windows.h" +#include "winnls.h" // unicode-multibyte conversion +#endif + +inline std::string wide2utf8(const std::wstring& text) { +#ifndef _MSC_VER + return boost::locale::conv::to_utf(text, "UTF-8"); +#else + const size_t len_needed = ::WideCharToMultiByte(CP_UTF8, 0, text.c_str(), (UINT)(text.length()) , NULL, 0, NULL, NULL) ; + boost::scoped_array buff(new char[len_needed+1]) ; + const size_t num_copied = ::WideCharToMultiByte(CP_UTF8, 0, text.c_str(), (UINT)(text.length()) , buff.get(), len_needed+1, NULL, NULL) ; + return std::string(buff.get(), num_copied) ; +#endif +} + +namespace std { + + inline ostream& operator<<(ostream& out, const wchar_t* value) + { + wstring text(value) ; + out << wide2utf8(text); + return out; + } + + inline ostream& operator<<(ostream& out, const wstring& value) + { + out << wide2utf8(value); + return out; + } +} + + diff --git a/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.cc b/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.cc index e1c9807d8..753a40b8a 100644 --- a/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.cc +++ b/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.cc @@ -566,7 +566,7 @@ BDD::operator+( const BDD& other) const { DdManager *mgr = checkSameManager(other); - DdNode *result = Cudd_bddOr(mgr,node,other.node); + DdNode *result = (mgr,node,other.node); checkReturnValue(result); return BDD(p, result); @@ -2648,7 +2648,16 @@ ADD::MinAbstract(const ADD& cube) const checkReturnValue(result); return ADD(p, result); } // ADD::MinAbstract - + +ADD +ADD::MinAbstractExcept0(const ADD& cube) const +{ + DdManager *mgr = checkSameManager(cube); + DdNode *result = Cudd_addMinExcept0Abstract(mgr, node, cube.node); + checkReturnValue(result); + return ADD(p, result); +} // ADD::MinAbstractExcept0 + ADD ADD::MaxAbstract(const ADD& cube) const { @@ -2658,6 +2667,24 @@ ADD::MaxAbstract(const ADD& cube) const return ADD(p, result); } // ADD::MaxAbstract +BDD +ADD::MinAbstractRepresentative(const ADD& cube) const +{ + DdManager *mgr = checkSameManager(cube); + DdNode *result = Cudd_addMinAbstractRepresentative(mgr, node, cube.node); + checkReturnValue(result); + return BDD(p, result); +} // ADD::MinRepresentative + +BDD +ADD::MaxAbstractRepresentative(const ADD& cube) const +{ + DdManager *mgr = checkSameManager(cube); + DdNode *result = Cudd_addMaxAbstractRepresentative(mgr, node, cube.node); + checkReturnValue(result); + return BDD(p, result); +} // ADD::MaxRepresentative + ADD ADD::Plus( const ADD& g) const @@ -3136,6 +3163,66 @@ ADD::GreaterThanOrEqual(const ADD& g) const } // ADD::GreaterThanOrEqual +BDD +ADD::EqualsBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddEquals, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::EqualsBdd + +BDD +ADD::NotEqualsBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddNotEquals, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::NotEqualsBdd + +BDD +ADD::LessThanBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddLessThan, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::LessThanBdd + +BDD +ADD::LessThanOrEqualBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddLessThanEquals, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::LessThanOrEqualBdd + +BDD +ADD::GreaterThanBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddGreaterThan, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::GreaterThanBdd + +BDD +ADD::GreaterThanOrEqualBdd(const ADD& g) const +{ + DdManager *mgr = checkSameManager(g); + DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddGreaterThanEquals, node, g.node); + checkReturnValue(result); + return BDD(p, result); + +} // ADD::GreaterThanOrEqualBdd + BDD BDD::AndAbstract( const BDD& g, @@ -3485,6 +3572,14 @@ BDD::ExistAbstract( } // BDD::ExistAbstract +BDD +BDD::ExistAbstractRepresentative(const BDD& cube) const { + DdManager *mgr = checkSameManager(cube); + DdNode *result; + result = Cudd_bddExistAbstractRepresentative(mgr, node, cube.node); + checkReturnValue(result); + return BDD(p, result); +} // BDD::ExistAbstractRepresentative BDD BDD::XorExistAbstract( diff --git a/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.hh b/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.hh index f180320bd..84018dc07 100644 --- a/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.hh +++ b/resources/3rdparty/cudd-3.0.0/cplusplus/cuddObj.hh @@ -213,6 +213,7 @@ public: BDD BiasedOverApprox(const BDD& bias, int numVars, int threshold = 0, double quality1 = 1.0, double quality0 = 1.0) const; BDD ExistAbstract(const BDD& cube, unsigned int limit = 0) const; + BDD ExistAbstractRepresentative(const BDD& cube) const; BDD XorExistAbstract(const BDD& g, const BDD& cube) const; BDD UnivAbstract(const BDD& cube) const; BDD BooleanDiff(int x) const; @@ -333,7 +334,10 @@ public: ADD UnivAbstract(const ADD& cube) const; ADD OrAbstract(const ADD& cube) const; ADD MinAbstract(const ADD& cube) const; + ADD MinAbstractExcept0(const ADD& cube) const; ADD MaxAbstract(const ADD& cube) const; + BDD MinAbstractRepresentative(const ADD& cube) const; + BDD MaxAbstractRepresentative(const ADD& cube) const; ADD Plus(const ADD& g) const; ADD Times(const ADD& g) const; ADD Threshold(const ADD& g) const; @@ -373,6 +377,12 @@ public: ADD LessThanOrEqual(const ADD& g) const; ADD GreaterThan(const ADD& g) const; ADD GreaterThanOrEqual(const ADD& g) const; + BDD EqualsBdd(const ADD& g) const; + BDD NotEqualsBdd(const ADD& g) const; + BDD LessThanBdd(const ADD& g) const; + BDD LessThanOrEqualBdd(const ADD& g) const; + BDD GreaterThanBdd(const ADD& g) const; + BDD GreaterThanOrEqualBdd(const ADD& g) const; BDD BddThreshold(CUDD_VALUE_TYPE value) const; BDD BddStrictThreshold(CUDD_VALUE_TYPE value) const; BDD BddInterval(CUDD_VALUE_TYPE lower, CUDD_VALUE_TYPE upper) const; diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cudd.h b/resources/3rdparty/cudd-3.0.0/cudd/cudd.h index e2447c878..20acf5854 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cudd.h +++ b/resources/3rdparty/cudd-3.0.0/cudd/cudd.h @@ -515,6 +515,7 @@ extern int Cudd_zddVarsFromBddVars(DdManager *dd, int multiplicity); extern unsigned int Cudd_ReadMaxIndex(void); extern DdNode * Cudd_addConst(DdManager *dd, CUDD_VALUE_TYPE c); extern int Cudd_IsConstant(DdNode *node); +extern int Cudd_IsConstant_const(DdNode const *node); extern int Cudd_IsNonConstant(DdNode *f); extern DdNode * Cudd_T(DdNode *node); extern DdNode * Cudd_E(DdNode *node); @@ -666,8 +667,12 @@ extern DdNode * Cudd_addExistAbstract(DdManager *manager, DdNode *f, DdNode *cub extern DdNode * Cudd_addUnivAbstract(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * Cudd_addOrAbstract(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * Cudd_addMinAbstract(DdManager * manager, DdNode * f, DdNode * cube); +extern DdNode * Cudd_addMinExcept0Abstract(DdManager * manager, DdNode * f, DdNode * cube); extern DdNode * Cudd_addMaxAbstract(DdManager * manager, DdNode * f, DdNode * cube); +extern DdNode * Cudd_addMinAbstractRepresentative(DdManager * manager, DdNode * f, DdNode * cube); +extern DdNode * Cudd_addMaxAbstractRepresentative(DdManager * manager, DdNode * f, DdNode * cube); extern DdNode * Cudd_addApply(DdManager *dd, DD_AOP op, DdNode *f, DdNode *g); +extern DdNode * Cudd_addToBddApply(DdManager *dd, DD_AOP op, DdNode *f, DdNode *g); extern DdNode * Cudd_addPlus(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addTimes(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addThreshold(DdManager *dd, DdNode **f, DdNode **g); @@ -675,6 +680,7 @@ extern DdNode * Cudd_addSetNZ(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addDivide(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addMinus(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addMinimum(DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addMinimumExcept0(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addMaximum(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addOneZeroMaximum(DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addDiff(DdManager *dd, DdNode **f, DdNode **g); @@ -690,6 +696,12 @@ extern DdNode * Cudd_addGreaterThan (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addGreaterThanEquals (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addLessThan (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addLessThanEquals (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddEquals (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddNotEquals (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddGreaterThan (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddGreaterThanEquals (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddLessThan (DdManager *dd, DdNode **f, DdNode **g); +extern DdNode * Cudd_addToBddLessThanEquals (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addPow (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addMod (DdManager *dd, DdNode **f, DdNode **g); extern DdNode * Cudd_addLogXY (DdManager *dd, DdNode **f, DdNode **g); @@ -740,6 +752,7 @@ extern DdNode * Cudd_RemapOverApprox(DdManager *dd, DdNode *f, int numVars, int extern DdNode * Cudd_BiasedUnderApprox(DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0); extern DdNode * Cudd_BiasedOverApprox(DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0); extern DdNode * Cudd_bddExistAbstract(DdManager *manager, DdNode *f, DdNode *cube); +extern DdNode * Cudd_bddExistAbstractRepresentative(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * Cudd_bddExistAbstractLimit(DdManager * manager, DdNode * f, DdNode * cube, unsigned int limit); extern DdNode * Cudd_bddXorExistAbstract(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube); extern DdNode * Cudd_bddUnivAbstract(DdManager *manager, DdNode *f, DdNode *cube); diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cuddAPI.c b/resources/3rdparty/cudd-3.0.0/cudd/cuddAPI.c index 78214567e..45cbc714a 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cuddAPI.c +++ b/resources/3rdparty/cudd-3.0.0/cudd/cuddAPI.c @@ -553,6 +553,20 @@ int Cudd_IsConstant(DdNode *node) } /* end of Cudd_IsConstant */ +/** + @brief Returns 1 if the node is a constant node. + + @details A constant node is not an internal node. The pointer + passed to Cudd_IsConstant may be either regular or complemented. + + @sideeffect none + + */ +int Cudd_IsConstant_const(DdNode const*node) +{ + return Cudd_Regular(node)->index == CUDD_CONST_INDEX; + +} /* end of Cudd_IsConstant_const */ /** @brief Returns 1 if a %DD node is not constant. @@ -576,7 +590,6 @@ Cudd_IsNonConstant( } /* end of Cudd_IsNonConstant */ - /** @brief Returns the then child of an internal node. diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cuddAddAbs.c b/resources/3rdparty/cudd-3.0.0/cudd/cuddAddAbs.c index db284f7b4..1f8414017 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cuddAddAbs.c +++ b/resources/3rdparty/cudd-3.0.0/cudd/cuddAddAbs.c @@ -243,6 +243,44 @@ Cudd_addMinAbstract( } /* end of Cudd_addMinAbstract */ +/**Function******************************************************************** + + Synopsis [Abstracts all the variables in cube from the + ADD f by taking the minimum.] + + Description [Abstracts all the variables in cube from the ADD f + by taking the minimum over all possible values taken by the + variables. Returns the abstracted ADD if successful; NULL + otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addUnivAbstract Cudd_addExistAbstract] + + Note: Added by Christian Dehnert 24/08/2016 + + ******************************************************************************/ +DdNode * +Cudd_addMinExcept0Abstract( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *res; + + if (addCheckPositiveCube(manager, cube) == 0) { + (void) fprintf(manager->err,"Error: Can only abstract cubes"); + return(NULL); + } + + do { + manager->reordered = 0; + res = cuddAddMinExcept0AbstractRecur(manager, f, cube); + } while (manager->reordered == 1); + return(res); + +} /* end of Cudd_addMinExcept0Abstract */ + /**Function******************************************************************** Synopsis [Abstracts all the variables in cube from the @@ -281,6 +319,78 @@ Cudd_addMaxAbstract( } /* end of Cudd_addMaxAbstract */ +/**Function******************************************************************** + + Synopsis [Just like Cudd_addMinAbstract, but instead of abstracting the + variables in the given cube, picks a unique representative that realizes th + minimal function value.] + + Description [Returns the resulting ADD if successful; NULL otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addMaxAbstractRepresentative] + + Note: Added by Christian Dehnert 8/5/14 + + ******************************************************************************/ +DdNode * +Cudd_addMinAbstractRepresentative( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *res; + + if (addCheckPositiveCube(manager, cube) == 0) { + (void) fprintf(manager->err,"Error: Can only abstract cubes"); + return(NULL); + } + + do { + manager->reordered = 0; + res = cuddAddMinAbstractRepresentativeRecur(manager, f, cube); + } while (manager->reordered == 1); + return(res); + +} /* end of Cudd_addMinRepresentative */ + +/**Function******************************************************************** + + Synopsis [Just like Cudd_addMaxAbstract, but instead of abstracting the + variables in the given cube, picks a unique representative that realizes th + maximal function value.] + + Description [Returns the resulting ADD if successful; NULL otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addMinAbstractRepresentative] + + Note: Added by Christian Dehnert 8/5/14 + + ******************************************************************************/ +DdNode * +Cudd_addMaxAbstractRepresentative( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *res; + + if (addCheckPositiveCube(manager, cube) == 0) { + (void) fprintf(manager->err,"Error: Can only abstract cubes"); + return(NULL); + } + + do { + manager->reordered = 0; + res = cuddAddMaxAbstractRepresentativeRecur(manager, f, cube); + } while (manager->reordered == 1); + return(res); + +} /* end of Cudd_addMaxRepresentative */ + /*---------------------------------------------------------------------------*/ /* Definition of internal functions */ /*---------------------------------------------------------------------------*/ @@ -678,6 +788,98 @@ cuddAddMinAbstractRecur( } /* end of cuddAddMinAbstractRecur */ +/**Function******************************************************************** + + Synopsis [Performs the recursive step of Cudd_addMinAbstract.] + + Description [Performs the recursive step of Cudd_addMinAbstract. + Returns the ADD obtained by abstracting the variables of cube from f, + if successful; NULL otherwise.] + + SideEffects [None] + + SeeAlso [] + + added 24/08/2016 by Christian Dehnert + + ******************************************************************************/ +DdNode * +cuddAddMinExcept0AbstractRecur( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *T, *E, *res, *res1, *res2, *zero; + + zero = DD_ZERO(manager); + + /* Cube is guaranteed to be a cube at this point. */ + if (f == zero || cuddIsConstant(cube)) { + return(f); + } + + /* Abstract a variable that does not appear in f. */ + if (cuddI(manager,f->index) > cuddI(manager,cube->index)) { + res = cuddAddMinAbstractRecur(manager, f, cuddT(cube)); + return(res); + } + + if ((res = cuddCacheLookup2(manager, Cudd_addMinAbstract, f, cube)) != NULL) { + return(res); + } + + + T = cuddT(f); + E = cuddE(f); + + /* If the two indices are the same, so are their levels. */ + if (f->index == cube->index) { + res1 = cuddAddMinAbstractRecur(manager, T, cuddT(cube)); + if (res1 == NULL) return(NULL); + cuddRef(res1); + res2 = cuddAddMinAbstractRecur(manager, E, cuddT(cube)); + if (res2 == NULL) { + Cudd_RecursiveDeref(manager,res1); + return(NULL); + } + cuddRef(res2); + res = cuddAddApplyRecur(manager, Cudd_addMinimumExcept0, res1, res2); + if (res == NULL) { + Cudd_RecursiveDeref(manager,res1); + Cudd_RecursiveDeref(manager,res2); + return(NULL); + } + cuddRef(res); + Cudd_RecursiveDeref(manager,res1); + Cudd_RecursiveDeref(manager,res2); + cuddCacheInsert2(manager, Cudd_addMinAbstract, f, cube, res); + cuddDeref(res); + return(res); + } + else { /* if (cuddI(manager,f->index) < cuddI(manager,cube->index)) */ + res1 = cuddAddMinAbstractRecur(manager, T, cube); + if (res1 == NULL) return(NULL); + cuddRef(res1); + res2 = cuddAddMinAbstractRecur(manager, E, cube); + if (res2 == NULL) { + Cudd_RecursiveDeref(manager,res1); + return(NULL); + } + cuddRef(res2); + res = (res1 == res2) ? res1 : + cuddUniqueInter(manager, (int) f->index, res1, res2); + if (res == NULL) { + Cudd_RecursiveDeref(manager,res1); + Cudd_RecursiveDeref(manager,res2); + return(NULL); + } + cuddDeref(res1); + cuddDeref(res2); + cuddCacheInsert2(manager, Cudd_addMinAbstract, f, cube, res); + return(res); + } + +} /* end of cuddAddMinAbstractRecur */ /**Function******************************************************************** @@ -774,6 +976,385 @@ cuddAddMaxAbstractRecur( /* Definition of static functions */ /*---------------------------------------------------------------------------*/ +/**Function******************************************************************** + + Synopsis [Performs the recursive step of Cudd_addMinAbstractRepresentative.] + + Description [Performs the recursive step of Cudd_addMinAbstractRepresentative. + Returns the ADD obtained by picking a representative over the variables in + the given cube for all other valuations. Returns the resulting ADD if successful; + NULL otherwise.] + + SideEffects [None] + + SeeAlso [] + + ******************************************************************************/ +DdNode * +cuddAddMinAbstractRepresentativeRecur( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *T, *E, *res, *res1, *res2, *zero, *one, *logicalZero, *res1Inf, *res2Inf, *left, *right, *tmp, *tmp2; + + zero = DD_ZERO(manager); + one = DD_ONE(manager); + logicalZero = Cudd_Not(one); + + /* Cube is guaranteed to be a cube at this point. */ + if (cuddIsConstant(cube)) { + return one; + } + if (cuddIsConstant(f)) { + res = cuddAddMinAbstractRepresentativeRecur(manager, f, cuddT(cube)); + if (res == NULL) { + return(NULL); + } + cuddRef(res); + + // We build in the negation ourselves. + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager,res); + return(NULL); + } + res1 = Cudd_Not(res1); + cuddDeref(res); + return(res1); + } + + /* Abstract a variable that does not appear in f. */ + if (cuddI(manager,f->index) > cuddI(manager,cube->index)) { + res = cuddAddMinAbstractRepresentativeRecur(manager, f, cuddT(cube)); + if (res == NULL) { + return(NULL); + } + + // Fill in the missing variables to make representative unique. + cuddRef(res); + // We build in the negation ourselves. + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager,res); + return(NULL); + } + res1 = Cudd_Not(res1); + cuddDeref(res); + return(res1); + } + + if ((res = cuddCacheLookup2(manager, Cudd_addMinAbstractRepresentative, f, cube)) != NULL) { + return(res); + } + + + E = cuddE(f); + T = cuddT(f); + + /* If the two indices are the same, so are their levels. */ + if (f->index == cube->index) { + res1 = cuddAddMinAbstractRepresentativeRecur(manager, E, cuddT(cube)); + if (res1 == NULL) { + return(NULL); + } + cuddRef(res1); + + res2 = cuddAddMinAbstractRepresentativeRecur(manager, T, cuddT(cube)); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager, res1); + return(NULL); + } + cuddRef(res2); + + left = cuddAddMinAbstractRecur(manager, E, cuddT(cube)); + if (left == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + return(NULL); + } + cuddRef(left); + right = cuddAddMinAbstractRecur(manager, T, cuddT(cube)); + if (right == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + Cudd_RecursiveDeref(manager, left); + return(NULL); + } + cuddRef(right); + + tmp = cuddAddToBddApplyRecur(manager, Cudd_addToBddLessThanEquals, left, right); + if (tmp == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_RecursiveDeref(manager,left); + Cudd_RecursiveDeref(manager,right); + return(NULL); + } + cuddRef(tmp); + + Cudd_RecursiveDeref(manager, left); + Cudd_RecursiveDeref(manager, right); + + res1Inf = cuddBddIteRecur(manager, tmp, res1, logicalZero); + if (res1Inf == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,tmp); + return(NULL); + } + cuddRef(res1Inf); + Cudd_IterDerefBdd(manager,res1); + + res2Inf = cuddBddIteRecur(manager, tmp, logicalZero, res2); + Cudd_IterDerefBdd(manager,tmp); + if (res2Inf == NULL) { + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,res1Inf); + return(NULL); + } + cuddRef(res2Inf); + Cudd_IterDerefBdd(manager,res2); + + int compl = (res1Inf == res2Inf) ? 1 : Cudd_IsComplement(res2Inf); + res = (res1Inf == res2Inf) ? cuddUniqueInter(manager, (int) f->index, one, Cudd_Not(res1Inf)) : cuddUniqueInter(manager, (int) f->index, Cudd_Regular(res2Inf), compl ? Cudd_Not(res1Inf) : res1Inf); + if (res == NULL) { + Cudd_IterDerefBdd(manager,res1Inf); + Cudd_IterDerefBdd(manager,res2Inf); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddRef(res); + cuddDeref(res1Inf); + cuddDeref(res2Inf); + cuddCacheInsert2(manager, Cudd_addMinAbstractRepresentative, f, cube, res); + cuddDeref(res); + return(res); + } + else { /* if (cuddI(manager,f->index) < cuddI(manager,cube->index)) */ + res1 = cuddAddMinAbstractRepresentativeRecur(manager, E, cube); + if (res1 == NULL) return(NULL); + cuddRef(res1); + res2 = cuddAddMinAbstractRepresentativeRecur(manager, T, cube); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager,res1); + return(NULL); + } + cuddRef(res2); + + int compl = (res1 == res2) ? 0 : Cudd_IsComplement(res2); + res = (res1 == res2) ? res1 : cuddUniqueInter(manager, (int) f->index, Cudd_Regular(res2), compl ? Cudd_Not(res1) : res1); + if (res == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddDeref(res1); + cuddDeref(res2); + cuddCacheInsert2(manager, Cudd_addMinAbstractRepresentative, f, cube, res); + return(res); + } + +} /* end of cuddAddMinAbstractRepresentativeRecur */ + +/**Function******************************************************************** + + Synopsis [Performs the recursive step of Cudd_addMaxAbstractRepresentative.] + + Description [Performs the recursive step of Cudd_addMaxAbstractRepresentative. + Returns the ADD obtained by picking a representative over the variables in + the given cube for all other valuations. Returns the resulting ADD if successful; + NULL otherwise.] + + SideEffects [None] + + SeeAlso [] + + ******************************************************************************/ +DdNode * +cuddAddMaxAbstractRepresentativeRecur( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *T, *E, *res, *res1, *res2, *zero, *one, *logicalZero, *res1Inf, *res2Inf, *left, *right, *tmp, *tmp2; + + zero = DD_ZERO(manager); + one = DD_ONE(manager); + logicalZero = Cudd_Not(one); + + /* Cube is guaranteed to be a cube at this point. */ + if (cuddIsConstant(cube)) { + return one; + } + if (cuddIsConstant(f)) { + res = cuddAddMaxAbstractRepresentativeRecur(manager, f, cuddT(cube)); + if (res == NULL) { + return(NULL); + } + cuddRef(res); + + // We build in the negation ourselves. + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager,res); + return(NULL); + } + res1 = Cudd_Not(res1); + cuddDeref(res); + return(res1); + + } + + /* Abstract a variable that does not appear in f. */ + if (cuddI(manager,f->index) > cuddI(manager,cube->index)) { + res = cuddAddMaxAbstractRepresentativeRecur(manager, f, cuddT(cube)); + + if (res == NULL) { + return(NULL); + } + + // Fill in the missing variables to make representative unique. + cuddRef(res); + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager, res); + return(NULL); + } + res1 = Cudd_Not(res1); + Cudd_IterDerefBdd(manager,res); + return(res1); + } + + if ((res = cuddCacheLookup2(manager, Cudd_addMaxAbstractRepresentative, f, cube)) != NULL) { + return(res); + } + + + E = cuddE(f); + T = cuddT(f); + + /* If the two indices are the same, so are their levels. */ + if (f->index == cube->index) { + res1 = cuddAddMaxAbstractRepresentativeRecur(manager, E, cuddT(cube)); + if (res1 == NULL) { + return(NULL); + } + cuddRef(res1); + + res2 = cuddAddMaxAbstractRepresentativeRecur(manager, T, cuddT(cube)); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager, res1); + return(NULL); + } + cuddRef(res2); + + left = cuddAddMaxAbstractRecur(manager, E, cuddT(cube)); + if (left == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + return(NULL); + } + cuddRef(left); + right = cuddAddMaxAbstractRecur(manager, T, cuddT(cube)); + if (right == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + Cudd_RecursiveDeref(manager, left); + return(NULL); + } + cuddRef(right); + + tmp = cuddAddToBddApplyRecur(manager, Cudd_addToBddGreaterThanEquals, left, right); + if (tmp == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_RecursiveDeref(manager,left); + Cudd_RecursiveDeref(manager,right); + return(NULL); + } + cuddRef(tmp); + + Cudd_RecursiveDeref(manager, left); + Cudd_RecursiveDeref(manager, right); + + cuddRef(zero); + res1Inf = cuddBddIteRecur(manager, tmp, res1, logicalZero); + if (res1Inf == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,tmp); + cuddDeref(zero); + return(NULL); + } + cuddRef(res1Inf); + Cudd_IterDerefBdd(manager,res1); + + cuddRef(zero); + res2Inf = cuddBddIteRecur(manager, tmp, logicalZero, res2); + if (res2Inf == NULL) { + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,res1Inf); + Cudd_IterDerefBdd(manager,tmp); + return(NULL); + } + cuddRef(res2Inf); + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,tmp); + + int compl = (res1Inf == res2Inf) ? 1 : Cudd_IsComplement(res2Inf); + res = (res1Inf == res2Inf) ? cuddUniqueInter(manager, (int) f->index, one, Cudd_Not(res1Inf)) : cuddUniqueInter(manager, (int) f->index, Cudd_Regular(res2Inf), compl ? Cudd_Not(res1Inf) : res1Inf); + if (res == NULL) { + Cudd_IterDerefBdd(manager,res1Inf); + Cudd_IterDerefBdd(manager,res2Inf); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddRef(res); + Cudd_IterDerefBdd(manager,res1Inf); + Cudd_IterDerefBdd(manager,res2Inf); + cuddCacheInsert2(manager, Cudd_addMaxAbstractRepresentative, f, cube, res); + cuddDeref(res); + return(res); + } + else { /* if (cuddI(manager,f->index) < cuddI(manager,cube->index)) */ + res1 = cuddAddMaxAbstractRepresentativeRecur(manager, E, cube); + if (res1 == NULL) return(NULL); + cuddRef(res1); + res2 = cuddAddMaxAbstractRepresentativeRecur(manager, T, cube); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager,res1); + return(NULL); + } + cuddRef(res2); + + int compl = (res1 == res2) ? 0 : Cudd_IsComplement(res2); + res = (res1 == res2) ? res1 : cuddUniqueInter(manager, (int) f->index, Cudd_Regular(res2), compl ? Cudd_Not(res1) : res1); + if (res == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddDeref(res1); + cuddDeref(res2); + cuddCacheInsert2(manager, Cudd_addMaxAbstractRepresentative, f, cube, res); + return(res); + } +} /* end of cuddAddMaxAbstractRepresentativeRecur */ + +/*---------------------------------------------------------------------------*/ +/* Definition of static functions */ +/*---------------------------------------------------------------------------*/ /** @brief Checks whether cube is an %ADD representing the product diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cuddAddApply.c b/resources/3rdparty/cudd-3.0.0/cudd/cuddAddApply.c index d7a3c71cc..01fc45fe6 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cuddAddApply.c +++ b/resources/3rdparty/cudd-3.0.0/cudd/cuddAddApply.c @@ -117,6 +117,41 @@ Cudd_addApply( } /* end of Cudd_addApply */ +/** + @brief Applies op to the corresponding discriminants of f and g and produces a BDD as a result. + + @return a pointer to the result if succssful; NULL otherwise. + + @sideeffect None + + @see Cudd_addMonadicApply Cudd_addPlus Cudd_addTimes + Cudd_addThreshold Cudd_addSetNZ Cudd_addDivide Cudd_addMinus Cudd_addMinimum + Cudd_addMaximum Cudd_addOneZeroMaximum Cudd_addDiff Cudd_addAgreement + Cudd_addOr Cudd_addNand Cudd_addNor Cudd_addXor Cudd_addXnor + + added 23/08/2016 by Christian Dehnert + + */ +DdNode * +Cudd_addToBddApply( + DdManager * dd /**< manager */, + DD_AOP op /**< operator */, + DdNode * f /**< first operand */, + DdNode * g /**< second operand */) +{ + DdNode *res; + + do { + dd->reordered = 0; + res = cuddAddToBddApplyRecur(dd,op,f,g); + } while (dd->reordered == 1); + if (dd->errorCode == CUDD_TIMEOUT_EXPIRED && dd->timeoutHandler) { + dd->timeoutHandler(dd, dd->tohArg); + } + + return(res); + +} /* end of Cudd_addToBddApply */ /** @brief Integer and floating point addition. @@ -371,6 +406,53 @@ Cudd_addMinimum( } /* end of Cudd_addMinimum */ +/** + @brief Integer and floating point min. + + @details Integer and floating point min for Cudd_addApply. + + @return NULL if not a terminal case; min(f,g) otherwise. + + @sideeffect None + + @see Cudd_addApply + + added 24/08/2016 + + */ +DdNode * +Cudd_addMinimumExcept0( + DdManager * dd, + DdNode ** f, + DdNode ** g) +{ + DdNode *F, *G; + + F = *f; G = *g; + if (F == DD_ZERO(dd)) return(G); + if (G == DD_ZERO(dd)) return(F); + if (F == DD_PLUS_INFINITY(dd)) return(G); + if (G == DD_PLUS_INFINITY(dd)) return(F); + if (F == G) return(F); +#if 0 + /* These special cases probably do not pay off. */ + if (F == DD_MINUS_INFINITY(dd)) return(F); + if (G == DD_MINUS_INFINITY(dd)) return(G); +#endif + if (cuddIsConstant(F) && cuddIsConstant(G)) { + if (cuddV(F) <= cuddV(G)) { + return(F); + } else { + return(G); + } + } + if (F > G) { /* swap f and g */ + *f = G; + *g = F; + } + return(NULL); + +} /* end of Cudd_addMinimumExcept0 */ /** @brief Integer and floating point max. @@ -817,6 +899,38 @@ Cudd_addEquals( } /* end of Cudd_addEquals */ +/**Function******************************************************************** + + Synopsis [1 if f==g; 0 otherwise.] + + Description [Returns NULL if not a terminal case; f op g otherwise, + where f op g is 1 if f==g; 0 otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addApply] + + Added 23/08/2016 by Christian Dehnert + + ******************************************************************************/ +DdNode * +Cudd_addToBddEquals( + DdManager * dd, + DdNode ** f, + DdNode ** g) +{ + DdNode *F, *G; + + F = *f; G = *g; + if (F == G) return(DD_ONE(dd)); + if (cuddIsConstant(F) && cuddIsConstant(G)) return(Cudd_Not(DD_ONE(dd))); + if (F > G) { /* swap f and g */ + *f = G; + *g = F; + } + return(NULL); + +} /* end of Cudd_addToBddEquals */ /**Function******************************************************************** @@ -849,6 +963,39 @@ Cudd_addNotEquals( } /* end of Cudd_addNotEquals */ +/**Function******************************************************************** + + Synopsis [1 if f!=g; 0 otherwise.] + + Description [Returns NULL if not a terminal case; f op g otherwise, + where f op g is 1 if f!=g; 0 otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addApply] + + Added 23/08/2016 by Christian Dehnert + + ******************************************************************************/ +DdNode * +Cudd_addToBddNotEquals( + DdManager * dd, + DdNode ** f, + DdNode ** g) +{ + DdNode *F, *G; + + F = *f; G = *g; + if (F == G) return(Cudd_Not(DD_ONE(dd))); + if (cuddIsConstant(F) && cuddIsConstant(G)) return(DD_ONE(dd)); + if (F > G) { /* swap f and g */ + *f = G; + *g = F; + } + return(NULL); + +} /* end of Cudd_addToBddNotEquals */ + /**Function******************************************************************** Synopsis [1 if f>g; 0 otherwise.] @@ -878,6 +1025,37 @@ Cudd_addGreaterThan( } /* end of Cudd_addGreaterThan */ +/**Function******************************************************************** + + Synopsis [1 if f>g; 0 otherwise.] + + Description [Returns NULL if not a terminal case; f op g otherwise, + where f op g is 1 if f>g; 0 otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addApply] + + Added 23/08/2016 by Christian Dehnert + + ******************************************************************************/ +DdNode * +Cudd_addToBddGreaterThan( + DdManager * dd, + DdNode ** f, + DdNode ** g) +{ + DdNode *F, *G; + + F = *f; G = *g; + if (F == G) return(Cudd_Not(DD_ONE(dd))); + if (cuddIsConstant(F) && cuddIsConstant(G)) { + if (cuddV(F)>cuddV(G)) return (DD_ONE(dd)); else return (Cudd_Not(DD_ONE(dd))); + } + return(NULL); + +} /* end of Cudd_addToBddGreaterThan */ + /**Function******************************************************************** @@ -908,6 +1086,36 @@ Cudd_addGreaterThanEquals( } /* end of Cudd_addGreaterThanEquals */ +/**Function******************************************************************** + + Synopsis [1 if f>=g; 0 otherwise.] + + Description [Returns NULL if not a terminal case; f op g otherwise, + where f op g is 1 if f>=g; 0 otherwise.] + + SideEffects [None] + + SeeAlso [Cudd_addApply] + + Added 23/08/2016 by Christian Dehnert + + ******************************************************************************/ +DdNode * +Cudd_addToBddGreaterThanEquals( + DdManager * dd, + DdNode ** f, + DdNode ** g) +{ + DdNode *F, *G; + + F = *f; G = *g; + if (F == G) return(DD_ONE(dd)); + if (cuddIsConstant(F) && cuddIsConstant(G)) { + if (cuddV(F)>=cuddV(G)) return (DD_ONE(dd)); else return (Cudd_Not(DD_ONE(dd))); + } + return(NULL); + +} /* end of Cudd_addToBddGreaterThanEquals */ /**Function******************************************************************** @@ -938,6 +1146,36 @@ Cudd_addLessThan( } /* end of Cudd_addLessThan */ +/**Function******************************************************************** + + Synopsis [1 if findex); + gord = cuddI(dd,g->index); + if (ford <= gord) { + index = f->index; + fv = cuddT(f); + fvn = cuddE(f); + } else { + index = g->index; + fv = fvn = f; + } + if (gord <= ford) { + gv = cuddT(g); + gvn = cuddE(g); + } else { + gv = gvn = g; + } + + T = cuddAddToBddApplyRecur(dd,op,fv,gv); + if (T == NULL) return(NULL); + cuddRef(T); + + E = cuddAddToBddApplyRecur(dd,op,fvn,gvn); + if (E == NULL) { + Cudd_IterDerefBdd(dd,T); + return(NULL); + } + cuddRef(E); + + int complT = Cudd_IsComplement(T); + + if (T == E) { + res = T; + } else { + res = cuddUniqueInter(dd,(int)index,Cudd_Regular(T),complT ? Cudd_Not(E) : E); + if (complT) { + res = Cudd_Not(res); + } + } + if (res == NULL) { + Cudd_IterDerefBdd(dd, T); + Cudd_IterDerefBdd(dd, E); + return(NULL); + } + cuddRef(res); + cuddDeref(T); + cuddDeref(E); + + /* Store result. */ + cuddCacheInsert2(dd,cacheOp,f,g,res); + + cuddDeref(res); + return(res); + +} /* end of cuddAddToBddApplyRecur */ /** @brief Performs the recursive step of Cudd_addMonadicApply. diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cuddBddAbs.c b/resources/3rdparty/cudd-3.0.0/cudd/cuddBddAbs.c index 62170e3b2..8c3026b9d 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cuddBddAbs.c +++ b/resources/3rdparty/cudd-3.0.0/cudd/cuddBddAbs.c @@ -124,6 +124,42 @@ Cudd_bddExistAbstract( } /* end of Cudd_bddExistAbstract */ +/**Function******************************************************************** + + Synopsis [Just like Cudd_bddExistAbstract, but instead of abstracting the + variables in the given cube, picks a unique representative that realizes the + existential truth value.] + + Description [Returns the resulting BDD if successful; NULL otherwise.] + + SideEffects [None] + + SeeAlso [] + + Note: Added by Christian Dehnert 9/21/15 + + ******************************************************************************/ +DdNode * +Cudd_bddExistAbstractRepresentative( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *res; + + if (bddCheckPositiveCube(manager, cube) == 0) { + (void) fprintf(manager->err,"Error: Can only abstract positive cubes\n"); + manager->errorCode = CUDD_INVALID_ARG; + return(NULL); + } + + do { + manager->reordered = 0; + res = cuddBddExistAbstractRepresentativeRecur(manager, f, cube); + } while (manager->reordered == 1); + return(res); + +} /* end of Cudd_bddExistAbstractRepresentative */ /** @brief Existentially abstracts all the variables in cube from f. @@ -465,6 +501,209 @@ cuddBddExistAbstractRecur( } /* end of cuddBddExistAbstractRecur */ +/**Function******************************************************************** + + Synopsis [Performs the recursive steps of Cudd_bddExistAbstractRepresentative.] + + Description [Performs the recursive steps of Cudd_bddExistAbstractRepresentative. + Returns the BDD obtained by picking a representative over the variables in + the given cube for all other valuations. Returns the resulting BDD if successful; + NULL otherwise.] + + SideEffects [None] + + SeeAlso [] + + ******************************************************************************/ +DdNode * +cuddBddExistAbstractRepresentativeRecur( + DdManager * manager, + DdNode * f, + DdNode * cube) +{ + DdNode *F, *T, *E, *res, *res1, *res2, *one, *zero, *left, *right, *tmp, *res1Inf, *res2Inf; + + statLine(manager); + one = DD_ONE(manager); + zero = Cudd_Not(one); + F = Cudd_Regular(f); + + // Store whether f is negated. + int fIsNegated = f != F; + + /* Cube is guaranteed to be a cube at this point. */ + if (F == one) { + if (fIsNegated) { + return f; + } + + if (cube == one) { + return one; + } else { + res = cuddBddExistAbstractRepresentativeRecur(manager, f, cuddT(cube)); + if (res == NULL) { + return(NULL); + } + cuddRef(res); + +// res1 = cuddUniqueInter(manager, (int) cube->index, zero, res); + + // We now build in the necessary negation ourselves. + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager,res); + return(NULL); + } + res1 = Cudd_Not(res1); + cuddDeref(res); + return(res1); + } + } else if (cube == one) { + return f; + } + /* From now on, cube and f are non-constant. */ + + + /* Abstract a variable that does not appear in f. */ + if (manager->perm[F->index] > manager->perm[cube->index]) { + res = cuddBddExistAbstractRepresentativeRecur(manager, f, cuddT(cube)); + if (res == NULL) { + return(NULL); + } + cuddRef(res); + +// res1 = cuddUniqueInter(manager, (int) cube->index, zero, res); + + // We now build in the necessary negation ourselves. + res1 = cuddUniqueInter(manager, (int) cube->index, one, Cudd_Not(res)); + if (res1 == NULL) { + Cudd_IterDerefBdd(manager,res); + return(NULL); + } + res1 = Cudd_Not(res1); + cuddDeref(res); + + return(res1); + } + + /* Check the cache. */ + if (F->ref != 1 && (res = cuddCacheLookup2(manager, Cudd_bddExistAbstractRepresentative, f, cube)) != NULL) { + return(res); + } + + /* Compute the cofactors of f. */ + T = cuddT(F); E = cuddE(F); + if (f != F) { + T = Cudd_Not(T); E = Cudd_Not(E); + } + + /* If the two indices are the same, so are their levels. */ + if (F->index == cube->index) { + res1 = cuddBddExistAbstractRepresentativeRecur(manager, E, cuddT(cube)); + if (res1 == NULL) { + return(NULL); + } + if (res1 == one) { + if (F->ref != 1) { + cuddCacheInsert2(manager, Cudd_bddExistAbstractRepresentative, f, cube, Cudd_Not(cube)); + } + return(Cudd_Not(cube)); + } + cuddRef(res1); + + res2 = cuddBddExistAbstractRepresentativeRecur(manager, T, cuddT(cube)); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager,res1); + return(NULL); + } + cuddRef(res2); + + left = cuddBddExistAbstractRecur(manager, E, cuddT(cube)); + if (left == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + return(NULL); + } + cuddRef(left); + + res1Inf = cuddBddIteRecur(manager, left, res1, zero); + if (res1Inf == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,left); + return(NULL); + } + cuddRef(res1Inf); + + Cudd_IterDerefBdd(manager,res1); + + res2Inf = cuddBddIteRecur(manager, left, zero, res2); + if (res2Inf == NULL) { + Cudd_IterDerefBdd(manager,res1); + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,left); + Cudd_IterDerefBdd(manager,res1Inf); + return(NULL); + } + cuddRef(res2Inf); + + Cudd_IterDerefBdd(manager,res2); + Cudd_IterDerefBdd(manager,left); + + assert(res1Inf != res2Inf); + int compl = Cudd_IsComplement(res2Inf); + res = cuddUniqueInter(manager, (int) F->index, Cudd_Regular(res2Inf), compl ? Cudd_Not(res1Inf) : res1Inf); + if (res == NULL) { + Cudd_IterDerefBdd(manager,res1Inf); + Cudd_IterDerefBdd(manager,res2Inf); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddRef(res); + + cuddDeref(res1Inf); + cuddDeref(res2Inf); + + cuddCacheInsert2(manager, Cudd_bddExistAbstractRepresentative, f, cube, res); + cuddDeref(res); + return(res); + } else { /* if (cuddI(manager,F->index) < cuddI(manager,cube->index)) */ + res1 = cuddBddExistAbstractRepresentativeRecur(manager, E, cube); + if (res1 == NULL){ + return(NULL); + } + cuddRef(res1); + + res2 = cuddBddExistAbstractRepresentativeRecur(manager, T, cube); + if (res2 == NULL) { + Cudd_IterDerefBdd(manager, res1); + return(NULL); + } + cuddRef(res2); + + /* ITE takes care of possible complementation of res1 and of the + ** case in which res1 == res2. */ + int compl = Cudd_IsComplement(res2); + res = cuddUniqueInter(manager, (int)F->index, Cudd_Regular(res2), compl ? Cudd_Not(res1) : res1); + if (res == NULL) { + Cudd_IterDerefBdd(manager, res1); + Cudd_IterDerefBdd(manager, res2); + return(NULL); + } + if (compl) { + res = Cudd_Not(res); + } + cuddDeref(res1); + cuddDeref(res2); + if (F->ref != 1) { + cuddCacheInsert2(manager, Cudd_bddExistAbstractRepresentative, f, cube, res); + } + return(res); + } + +} /* end of cuddBddExistAbstractRepresentativeRecur */ /** @brief Takes the exclusive OR of two BDDs and simultaneously abstracts the diff --git a/resources/3rdparty/cudd-3.0.0/cudd/cuddInt.h b/resources/3rdparty/cudd-3.0.0/cudd/cuddInt.h index ccb2a8f16..f5af25cd2 100644 --- a/resources/3rdparty/cudd-3.0.0/cudd/cuddInt.h +++ b/resources/3rdparty/cudd-3.0.0/cudd/cuddInt.h @@ -1062,8 +1062,12 @@ extern DdNode * cuddAddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode extern DdNode * cuddAddUnivAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * cuddAddOrAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * cuddAddMinAbstractRecur (DdManager *manager, DdNode *f, DdNode *cube); +extern DdNode * cuddAddMinExcept0AbstractRecur (DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * cuddAddMaxAbstractRecur (DdManager *manager, DdNode *f, DdNode *cube); +extern DdNode * cuddAddMinAbstractRepresentativeRecur(DdManager * manager, DdNode * f, DdNode * cube); +extern DdNode * cuddAddMaxAbstractRepresentativeRecur(DdManager * manager, DdNode * f, DdNode * cube); extern DdNode * cuddAddApplyRecur(DdManager *dd, DdNode * (*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g); +extern DdNode * cuddAddToBddApplyRecur(DdManager *dd, DdNode * (*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g); extern DdNode * cuddAddMonadicApplyRecur(DdManager * dd, DdNode * (*op)(DdManager *, DdNode *), DdNode * f); extern DdNode * cuddAddScalarInverseRecur(DdManager *dd, DdNode *f, DdNode *epsilon); extern DdNode * cuddAddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h); @@ -1076,6 +1080,7 @@ extern DdNode * cuddBiasedUnderApprox(DdManager *dd, DdNode *f, DdNode *b, int n extern DdNode * cuddBddAndAbstractRecur(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube); extern int cuddAnnealing(DdManager *table, int lower, int upper); extern DdNode * cuddBddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube); +extern DdNode * cuddBddExistAbstractRepresentativeRecur(DdManager *manager, DdNode *f, DdNode *cube); extern DdNode * cuddBddXorExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube); extern DdNode * cuddBddBooleanDiffRecur(DdManager *manager, DdNode *f, DdNode *var); extern DdNode * cuddBddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h); diff --git a/resources/3rdparty/exprtk/exprtk.hpp b/resources/3rdparty/exprtk/exprtk.hpp index 7581c4c8f..04f37d9a1 100755 --- a/resources/3rdparty/exprtk/exprtk.hpp +++ b/resources/3rdparty/exprtk/exprtk.hpp @@ -2,7 +2,7 @@ ****************************************************************** * C++ Mathematical Expression Toolkit Library * * * - * Author: Arash Partow (1999-2015) * + * Author: Arash Partow (1999-2016) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -27,7 +27,7 @@ * (12) (x ilike 's*ri?g') and [y < (3 z^7 + w)] * * * ****************************************************************** -*/ + */ #ifndef INCLUDE_EXPRTK_HPP @@ -37,8 +37,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -53,29986 +55,34930 @@ #include #include +// If this is set, this puts in place our modifications to ExprTk. That is: case sensitive and underscore is a valid character. +#define MODIFICATION namespace exprtk { - #if exprtk_enable_debugging - #define exprtk_debug(params) printf params - #else - #define exprtk_debug(params) (void)0 - #endif - - namespace details - { - inline bool is_whitespace(const char c) - { - return (' ' == c) || ('\n' == c) || - ('\r' == c) || ('\t' == c) || - ('\b' == c) || ('\v' == c) || - ('\f' == c) ; - } - - inline bool is_operator_char(const char c) - { - return ('+' == c) || ('-' == c) || - ('*' == c) || ('/' == c) || - ('^' == c) || ('<' == c) || - ('>' == c) || ('=' == c) || - (',' == c) || ('!' == c) || - ('(' == c) || (')' == c) || - ('[' == c) || (']' == c) || - ('{' == c) || ('}' == c) || - ('%' == c) || (':' == c) || - ('?' == c) || ('&' == c) || - ('|' == c) || (';' == c) ; - } - - inline bool is_letter(const char c) - { - return (('a' <= c) && (c <= 'z')) || - (('A' <= c) && (c <= 'Z')) ; - } - - inline bool is_digit(const char c) - { - return ('0' <= c) && (c <= '9'); - } - - inline bool is_letter_or_digit(const char c) - { - return is_letter(c) || is_digit(c); - } - - inline bool is_left_bracket(const char c) - { - return ('(' == c) || ('[' == c) || ('{' == c); - } - - inline bool is_right_bracket(const char c) - { - return (')' == c) || (']' == c) || ('}' == c); - } - - inline bool is_bracket(const char c) - { - return is_left_bracket(c) || is_right_bracket(c); - } - - inline bool is_sign(const char c) - { - return ('+' == c) || ('-' == c); - } - - inline bool is_invalid(const char c) - { - return !is_whitespace (c) && - !is_operator_char(c) && - !is_letter (c) && - !is_digit (c) && - ('.' != c) && - ('_' != c) && - ('$' != c) && - ('~' != c) && - ('\'' != c); - } - - inline bool imatch(const char c1, const char c2) - { - return std::tolower(c1) == std::tolower(c2); - } - - inline bool imatch(const std::string& s1, const std::string& s2) - { - if (s1.size() == s2.size()) - { - for (std::size_t i = 0; i < s1.size(); ++i) - { - if (std::tolower(s1[i]) != std::tolower(s2[i])) - { - return false; - } - } - - return true; - } - - return false; - } - - inline bool is_valid_sf_symbol(const std::string& symbol) - { - // Special function: $f12 or $F34 - return (4 == symbol.size()) && - ('$' == symbol[0]) && - imatch('f',symbol[1]) && - is_digit(symbol[2]) && - is_digit(symbol[3]); - } - - inline std::string to_str(int i) - { - if (0 == i) - return std::string("0"); - - std::string result; - bool negative = (i < 0); - - if (negative) i *= -1; - - while (i) - { - char digit = '0' + char(i % 10); - result = (digit + result); - i /= 10; - } - - if (negative) - result = "-" + result; - - return result; - } - - inline bool is_hex_digit(const std::string::value_type digit) - { - return (('0' <= digit) && (digit <= '9')) || - (('A' <= digit) && (digit <= 'F')) || - (('a' <= digit) && (digit <= 'f')) ; - } - - inline unsigned char hex_to_bin(unsigned char h) - { - if (('0' <= h) && (h <= '9')) - return (h - '0'); - else - return (std::toupper(h) - 'A'); - } - - template - inline void parse_hex(Iterator& itr, Iterator end, std::string::value_type& result) - { - if ( - (end != (itr )) && - (end != (itr + 1)) && - (end != (itr + 2)) && - (end != (itr + 3)) && - ('0' == *(itr )) && - ( - ('x' == *(itr + 1)) || - ('X' == *(itr + 1)) - ) && - (is_hex_digit(*(itr + 2))) && - (is_hex_digit(*(itr + 3))) - ) - { - result = hex_to_bin(*(itr + 2)) << 4 | hex_to_bin(*(itr + 3)); - itr += 3; - } - else - result = '\0'; - } - - inline void cleanup_escapes(std::string& s) - { - std::string::iterator itr1 = s.begin(); - std::string::iterator itr2 = s.begin(); - std::string::iterator end = s.end (); - std::size_t removal_count = 0; - - while (end != itr1) - { - if ('\\' == (*itr1)) - { - ++removal_count; - - if (end == ++itr1) - break; - else if ('\\' != (*itr1)) - { - switch (*itr1) - { - case 'n' : (*itr1) = '\n'; break; - case 'r' : (*itr1) = '\r'; break; - case 't' : (*itr1) = '\t'; break; - case '0' : parse_hex(itr1,end,(*itr1)); - removal_count += 3; - break; - } - - continue; - } - } - - if (itr1 != itr2) - { - (*itr2) = (*itr1); - } - - ++itr1; - ++itr2; - } - - s.resize(s.size() - removal_count); - } - - class build_string - { - public: - - build_string(const std::size_t& initial_size = 64) - { - data_.reserve(initial_size); - } - - inline build_string& operator << (const std::string& s) - { - data_ += s; - return (*this); - } - - inline build_string& operator << (const char* s) - { - data_ += std::string(s); - return (*this); - } - - inline operator std::string () const - { - return data_; - } - - inline std::string as_string() const - { - return data_; - } - - private: - - std::string data_; - }; - - struct ilesscompare - { - inline bool operator()(const std::string& s1, const std::string& s2) const - { - const std::size_t length = std::min(s1.size(),s2.size()); - - for (std::size_t i = 0; i < length; ++i) - { - const char c1 = static_cast(std::tolower(s1[i])); - const char c2 = static_cast(std::tolower(s2[i])); - - if (c1 > c2) - return false; - else if (c1 < c2) - return true; - } - - return s1.size() < s2.size(); - } - }; - - static const std::string reserved_words[] = - { - "break", "case", "continue", "default", "false", "for", - "if", "else", "ilike", "in", "like", "and", "nand", "nor", - "not", "null", "or", "repeat", "shl", "shr", "swap", - "switch", "true", "until", "var", "while", "xnor", "xor", - "&", "|" - }; - - static const std::size_t reserved_words_size = sizeof(reserved_words) / sizeof(std::string); - - static const std::string reserved_symbols[] = - { - "abs", "acos", "acosh", "and", "asin", "asinh", "atan", - "atanh", "atan2", "avg", "break", "case", "ceil", "clamp", - "continue", "cos", "cosh", "cot", "csc", "default", - "deg2grad", "deg2rad", "equal", "erf", "erfc", "exp", - "expm1", "false", "floor", "for", "frac", "grad2deg", - "hypot", "iclamp", "if", "else", "ilike", "in", "inrange", - "like", "log", "log10", "log2", "logn", "log1p", "mand", - "max", "min", "mod", "mor", "mul", "ncdf", "nand", "nor", - "not", "not_equal", "null", "or", "pow", "rad2deg", - "repeat", "root", "round", "roundn", "sec", "sgn", "shl", - "shr", "sin", "sinc", "sinh", "sqrt", "sum", "swap", - "switch", "tan", "tanh", "true", "trunc", "until", "var", - "while", "xnor", "xor", "&", "|" - }; - - static const std::size_t reserved_symbols_size = sizeof(reserved_symbols) / sizeof(std::string); - - inline bool is_reserved_word(const std::string& symbol) - { - for (std::size_t i = 0; i < reserved_words_size; ++i) - { - if (imatch(symbol,reserved_words[i])) - { - return true; - } - } - - return false; - } - - inline bool is_reserved_symbol(const std::string& symbol) - { - for (std::size_t i = 0; i < reserved_symbols_size; ++i) - { - if (imatch(symbol,reserved_symbols[i])) - { - return true; +#ifdef exprtk_enable_debugging +#define exprtk_debug(params) printf params +#else +#define exprtk_debug(params) (void)0 +#endif + + namespace details + { + typedef unsigned char uchar_t; + typedef char char_t; + + inline bool is_whitespace(const char_t c) + { + return (' ' == c) || ('\n' == c) || + ('\r' == c) || ('\t' == c) || + ('\b' == c) || ('\v' == c) || + ('\f' == c) ; + } + + inline bool is_operator_char(const char_t c) + { + return ('+' == c) || ('-' == c) || + ('*' == c) || ('/' == c) || + ('^' == c) || ('<' == c) || + ('>' == c) || ('=' == c) || + (',' == c) || ('!' == c) || + ('(' == c) || (')' == c) || + ('[' == c) || (']' == c) || + ('{' == c) || ('}' == c) || + ('%' == c) || (':' == c) || + ('?' == c) || ('&' == c) || + ('|' == c) || (';' == c) ; + } + + inline bool is_letter(const char_t c) + { + return (('a' <= c) && (c <= 'z')) || + (('A' <= c) && (c <= 'Z')) ; + } + + inline bool is_digit(const char_t c) + { + return ('0' <= c) && (c <= '9'); + } + + inline bool is_letter_or_digit(const char_t c) + { + return is_letter(c) || is_digit(c); + } + + inline bool is_left_bracket(const char_t c) + { + return ('(' == c) || ('[' == c) || ('{' == c); + } + + inline bool is_right_bracket(const char_t c) + { + return (')' == c) || (']' == c) || ('}' == c); + } + + inline bool is_bracket(const char_t c) + { + return is_left_bracket(c) || is_right_bracket(c); + } + + inline bool is_sign(const char_t c) + { + return ('+' == c) || ('-' == c); + } + + inline bool is_invalid(const char_t c) + { + return !is_whitespace (c) && + !is_operator_char(c) && + !is_letter (c) && + !is_digit (c) && +#ifndef MODIFICATION + ('.' != c) && + ('_' != c) && +#endif + ('$' != c) && + ('~' != c) && + ('\'' != c); + } + + inline bool imatch(const char_t c1, const char_t c2) + { +#ifdef MODIFICATION + return c1 == c2; +#else + return std::tolower(c1) == std::tolower(c2); +#endif + } + + inline bool imatch(const std::string& s1, const std::string& s2) + { + if (s1.size() == s2.size()) + { + for (std::size_t i = 0; i < s1.size(); ++i) + { +#ifdef MODIFICATION + if (s1[i] != s2[i]) +#else + if (std::tolower(s1[i]) != std::tolower(s2[i])) +#endif + { + return false; + } + } + + return true; } - } - - return false; - } - - struct cs_match - { - static inline bool cmp(const char c0, const char c1) - { - return (c0 == c1); - } - }; - - struct cis_match - { - static inline bool cmp(const char c0, const char c1) - { - return (std::tolower(c0) == std::tolower(c1)); - } - }; - - template - inline bool match_impl(const Iterator pattern_begin, - const Iterator pattern_end, - const Iterator data_begin, - const Iterator data_end, - const typename std::iterator_traits::value_type& zero_or_more, - const typename std::iterator_traits::value_type& zero_or_one) - { - if (0 == std::distance(data_begin,data_end)) - { + return false; - } - - Iterator d_itr = data_begin; - Iterator p_itr = pattern_begin; - Iterator c_itr = data_begin; - Iterator m_itr = data_begin; - - while ((data_end != d_itr) && (zero_or_more != (*p_itr))) - { - if ((!Compare::cmp((*p_itr),(*d_itr))) && (zero_or_one != (*p_itr))) - { - return false; - } - - ++p_itr; - ++d_itr; - } - - while (data_end != d_itr) - { - if (zero_or_more == (*p_itr)) - { - if (pattern_end == (++p_itr)) - { - return true; - } - - m_itr = p_itr; - c_itr = d_itr; - ++c_itr; + } + + inline bool is_valid_sf_symbol(const std::string& symbol) + { + // Special function: $f12 or $F34 + return (4 == symbol.size()) && + ('$' == symbol[0]) && + imatch('f',symbol[1]) && + is_digit(symbol[2]) && + is_digit(symbol[3]); + } + + inline const char& front(const std::string& s) + { + return s[0]; + } + + inline const char& back(const std::string& s) + { + return s[s.size() - 1]; + } + + inline std::string to_str(int i) + { + if (0 == i) + return std::string("0"); + + std::string result; + + if (i < 0) + { + for ( ; i; i /= 10) + { + result += '0' + char(-(i % 10)); + } + + result += '-'; } - else if ((Compare::cmp((*p_itr),(*d_itr))) || (zero_or_one == (*p_itr))) + else { - ++p_itr; - ++d_itr; + for ( ; i; i /= 10) + { + result += '0' + char(i % 10); + } } + + std::reverse(result.begin(), result.end()); + + return result; + } + + inline bool is_hex_digit(const std::string::value_type digit) + { + return (('0' <= digit) && (digit <= '9')) || + (('A' <= digit) && (digit <= 'F')) || + (('a' <= digit) && (digit <= 'f')) ; + } + + inline uchar_t hex_to_bin(uchar_t h) + { + if (('0' <= h) && (h <= '9')) + return (h - '0'); else + return static_cast(std::toupper(h) - 'A'); + } + + template + inline void parse_hex(Iterator& itr, Iterator end, std::string::value_type& result) + { + if ( + (end != (itr )) && + (end != (itr + 1)) && + (end != (itr + 2)) && + (end != (itr + 3)) && + ('0' == *(itr )) && + ( + ('x' == *(itr + 1)) || + ('X' == *(itr + 1)) + ) && + (is_hex_digit(*(itr + 2))) && + (is_hex_digit(*(itr + 3))) + ) { - p_itr = m_itr; - d_itr = c_itr++; + result = hex_to_bin(*(itr + 2)) << 4 | hex_to_bin(*(itr + 3)); + itr += 3; } - } - - while ((p_itr != pattern_end) && (zero_or_more == (*p_itr))) { ++p_itr; } - - return (p_itr == pattern_end); - } - - inline bool wc_match(const std::string& wild_card, - const std::string& str) - { - return match_impl(wild_card.data(), - wild_card.data() + wild_card.size(), - str.data(), - str.data() + str.size(), - '*', - '?'); - } - - inline bool wc_imatch(const std::string& wild_card, - const std::string& str) - { - return match_impl(wild_card.data(), - wild_card.data() + wild_card.size(), - str.data(), - str.data() + str.size(), - '*', - '?'); - } - - inline bool sequence_match(const std::string& pattern, - const std::string& str, - std::size_t& diff_index, - char& diff_value) - { - if (str.empty() || pattern.empty()) + else + result = '\0'; + } + + inline void cleanup_escapes(std::string& s) + { + typedef std::string::iterator str_itr_t; + + str_itr_t itr1 = s.begin(); + str_itr_t itr2 = s.begin(); + str_itr_t end = s.end (); + + std::size_t removal_count = 0; + + while (end != itr1) + { + if ('\\' == (*itr1)) + { + ++removal_count; + + if (end == ++itr1) + break; + else if ('\\' != (*itr1)) + { + switch (*itr1) + { + case 'n' : (*itr1) = '\n'; break; + case 'r' : (*itr1) = '\r'; break; + case 't' : (*itr1) = '\t'; break; + case '0' : parse_hex(itr1, end, (*itr1)); + removal_count += 3; + break; + } + + continue; + } + } + + if (itr1 != itr2) + { + (*itr2) = (*itr1); + } + + ++itr1; + ++itr2; + } + + s.resize(s.size() - removal_count); + } + + class build_string + { + public: + + build_string(const std::size_t& initial_size = 64) + { + data_.reserve(initial_size); + } + + inline build_string& operator << (const std::string& s) + { + data_ += s; + return (*this); + } + + inline build_string& operator << (const char* s) + { + data_ += std::string(s); + return (*this); + } + + inline operator std::string () const + { + return data_; + } + + inline std::string as_string() const + { + return data_; + } + + private: + + std::string data_; + }; + + struct ilesscompare + { + inline bool operator()(const std::string& s1, const std::string& s2) const + { + const std::size_t length = std::min(s1.size(),s2.size()); + + for (std::size_t i = 0; i < length; ++i) + { +#ifdef MODIFICATION + const char_t c1 = static_cast(s1[i]); + const char_t c2 = static_cast(s2[i]); +#else + const char_t c1 = static_cast(std::tolower(s1[i])); + const char_t c2 = static_cast(std::tolower(s2[i])); +#endif + + if (c1 > c2) + return false; + else if (c1 < c2) + return true; + } + + return s1.size() < s2.size(); + } + }; + + static const std::string reserved_words[] = + { + "break", "case", "continue", "default", "false", "for", + "if", "else", "ilike", "in", "like", "and", "nand", "nor", + "not", "null", "or", "repeat", "return", "shl", "shr", + "swap", "switch", "true", "until", "var", "while", "xnor", + "xor", "&", "|" + }; + + static const std::size_t reserved_words_size = sizeof(reserved_words) / sizeof(std::string); + + static const std::string reserved_symbols[] = + { + "abs", "acos", "acosh", "and", "asin", "asinh", "atan", + "atanh", "atan2", "avg", "break", "case", "ceil", "clamp", + "continue", "cos", "cosh", "cot", "csc", "default", + "deg2grad", "deg2rad", "equal", "erf", "erfc", "exp", + "expm1", "false", "floor", "for", "frac", "grad2deg", + "hypot", "iclamp", "if", "else", "ilike", "in", "inrange", + "like", "log", "log10", "log2", "logn", "log1p", "mand", + "max", "min", "mod", "mor", "mul", "ncdf", "nand", "nor", + "not", "not_equal", "null", "or", "pow", "rad2deg", + "repeat", "return", "root", "round", "roundn", "sec", "sgn", + "shl", "shr", "sin", "sinc", "sinh", "sqrt", "sum", "swap", + "switch", "tan", "tanh", "true", "trunc", "until", "var", + "while", "xnor", "xor", "&", "|" + }; + + static const std::size_t reserved_symbols_size = sizeof(reserved_symbols) / sizeof(std::string); + + static const std::string base_function_list[] = + { + "abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", + "atan2", "avg", "ceil", "clamp", "cos", "cosh", "cot", + "csc", "equal", "erf", "erfc", "exp", "expm1", "floor", + "frac", "hypot", "iclamp", "like", "log", "log10", "log2", + "logn", "log1p", "mand", "max", "min", "mod", "mor", "mul", + "ncdf", "pow", "root", "round", "roundn", "sec", "sgn", + "sin", "sinc", "sinh", "sqrt", "sum", "swap", "tan", "tanh", + "trunc", "not_equal", "inrange", "deg2grad", "deg2rad", + "rad2deg", "grad2deg" + }; + + static const std::size_t base_function_list_size = sizeof(base_function_list) / sizeof(std::string); + + static const std::string logic_ops_list[] = + { + "and", "nand", "nor", "not", "or", "xnor", "xor", "&", "|" + }; + + static const std::size_t logic_ops_list_size = sizeof(logic_ops_list) / sizeof(std::string); + + static const std::string cntrl_struct_list[] = + { + "if", "switch", "for", "while", "repeat" + }; + + static const std::size_t cntrl_struct_list_size = sizeof(cntrl_struct_list) / sizeof(std::string); + + static const std::string arithmetic_ops_list[] = + { + "+", "-", "*", "/", "%", "^" + }; + + static const std::size_t arithmetic_ops_list_size = sizeof(arithmetic_ops_list) / sizeof(std::string); + + static const std::string assignment_ops_list[] = + { + ":=", "+=", "-=", + "*=", "/=", "%=" + }; + + static const std::size_t assignment_ops_list_size = sizeof(assignment_ops_list) / sizeof(std::string); + + static const std::string inequality_ops_list[] = + { + "<", "<=", "==", + "=", "!=", "<>", + ">=", ">" + }; + + static const std::size_t inequality_ops_list_size = sizeof(inequality_ops_list) / sizeof(std::string); + + inline bool is_reserved_word(const std::string& symbol) + { + for (std::size_t i = 0; i < reserved_words_size; ++i) + { + if (imatch(symbol,reserved_words[i])) + { + return true; + } + } + return false; - else if ('*' == pattern[0]) + } + + inline bool is_reserved_symbol(const std::string& symbol) + { + for (std::size_t i = 0; i < reserved_symbols_size; ++i) + { + if (imatch(symbol,reserved_symbols[i])) + { + return true; + } + } + return false; - - typedef std::string::const_iterator itr_t; - - itr_t p_itr = pattern.begin(); - itr_t s_itr = str .begin(); - - itr_t p_end = pattern.end(); - itr_t s_end = str .end(); - - while ((s_end != s_itr) && (p_end != p_itr)) - { - if ('*' == (*p_itr)) + } + + inline bool is_base_function(const std::string& function_name) + { + for (std::size_t i = 0; i < base_function_list_size; ++i) + { + if (imatch(function_name,base_function_list[i])) + { + return true; + } + } + + return false; + } + + inline bool is_control_struct(const std::string& cntrl_strct) + { + for (std::size_t i = 0; i < cntrl_struct_list_size; ++i) + { + if (imatch(cntrl_strct,cntrl_struct_list[i])) + { + return true; + } + } + + return false; + } + + inline bool is_logic_opr(const std::string& lgc_opr) + { + for (std::size_t i = 0; i < logic_ops_list_size; ++i) + { + if (imatch(lgc_opr,logic_ops_list[i])) + { + return true; + } + } + + return false; + } + + struct cs_match + { + static inline bool cmp(const char_t c0, const char_t c1) { - const char target = std::toupper(*(p_itr - 1)); - - if ('*' == target) - { - diff_index = std::distance(str.begin(),s_itr); - diff_value = std::toupper(*p_itr); - - return false; - } - else - ++p_itr; - - while (s_itr != s_end) - { - if (target != std::toupper(*s_itr)) - break; - else - ++s_itr; - } - - continue; + return (c0 == c1); } - else if ( - ('?' != *p_itr) && - std::toupper(*p_itr) != std::toupper(*s_itr) - ) + }; + + struct cis_match + { + static inline bool cmp(const char_t c0, const char_t c1) { - diff_index = std::distance(str.begin(),s_itr); - diff_value = std::toupper(*p_itr); - - return false; +#ifdef MODIFICATION + return (c0 == c1); +#else + return (std::tolower(c0) == std::tolower(c1)); +#endif } - - ++p_itr; - ++s_itr; - } - - return ( - (s_end == s_itr) && - ( - (p_end == p_itr) || - ('*' == *p_itr) - ) - ); - } - - static const double pow10[] = { - 1.0, - 1.0E+001, 1.0E+002, 1.0E+003, 1.0E+004, - 1.0E+005, 1.0E+006, 1.0E+007, 1.0E+008, - 1.0E+009, 1.0E+010, 1.0E+011, 1.0E+012, - 1.0E+013, 1.0E+014, 1.0E+015, 1.0E+016 - }; - - static const std::size_t pow10_size = sizeof(pow10) / sizeof(double); - - namespace numeric - { - namespace constant - { - static const double e = 2.718281828459045235360; - static const double pi = 3.141592653589793238462; - static const double pi_2 = 1.570796326794896619231; - static const double pi_4 = 0.785398163397448309616; - static const double pi_180 = 0.017453292519943295769; - static const double _1_pi = 0.318309886183790671538; - static const double _2_pi = 0.636619772367581343076; - static const double _180_pi = 57.295779513082320876798; - static const double log2 = 0.693147180559945309417; - static const double sqrt2 = 1.414213562373095048801; - } - - namespace details - { - struct unknown_type_tag {}; - struct real_type_tag {}; - struct int_type_tag {}; - - template - struct number_type { typedef unknown_type_tag type; }; - - #define exprtk_register_real_type_tag(T) \ - template<> struct number_type { typedef real_type_tag type; }; \ - - #define exprtk_register_int_type_tag(T) \ - template<> struct number_type { typedef int_type_tag type; }; \ - - exprtk_register_real_type_tag(double ) - exprtk_register_real_type_tag(long double) - exprtk_register_real_type_tag(float ) - - exprtk_register_int_type_tag(short ) - exprtk_register_int_type_tag(int ) - exprtk_register_int_type_tag(long long int ) - exprtk_register_int_type_tag(unsigned short ) - exprtk_register_int_type_tag(unsigned int ) - exprtk_register_int_type_tag(unsigned long long int) - - #undef exprtk_register_real_type_tag - #undef exprtk_register_int_type_tag - + }; + + template + inline bool match_impl(const Iterator pattern_begin, + const Iterator pattern_end, + const Iterator data_begin, + const Iterator data_end, + const typename std::iterator_traits::value_type& zero_or_more, + const typename std::iterator_traits::value_type& zero_or_one) + { + if (0 == std::distance(data_begin,data_end)) + { + return false; + } + + Iterator d_itr = data_begin; + Iterator p_itr = pattern_begin; + Iterator c_itr = data_begin; + Iterator m_itr = data_begin; + + while ((data_end != d_itr) && (zero_or_more != (*p_itr))) + { + if ((!Compare::cmp((*p_itr),(*d_itr))) && (zero_or_one != (*p_itr))) + { + return false; + } + + ++p_itr; + ++d_itr; + } + + while (data_end != d_itr) + { + if (zero_or_more == (*p_itr)) + { + if (pattern_end == (++p_itr)) + { + return true; + } + + m_itr = p_itr; + c_itr = d_itr; + ++c_itr; + } + else if ((Compare::cmp((*p_itr),(*d_itr))) || (zero_or_one == (*p_itr))) + { + ++p_itr; + ++d_itr; + } + else + { + p_itr = m_itr; + d_itr = c_itr++; + } + } + + while ((p_itr != pattern_end) && (zero_or_more == (*p_itr))) { ++p_itr; } + + return (p_itr == pattern_end); + } + + inline bool wc_match(const std::string& wild_card, + const std::string& str) + { + return match_impl(wild_card.data(), + wild_card.data() + wild_card.size(), + str.data(), + str.data() + str.size(), + '*', + '?'); + } + + inline bool wc_imatch(const std::string& wild_card, + const std::string& str) + { + return match_impl(wild_card.data(), + wild_card.data() + wild_card.size(), + str.data(), + str.data() + str.size(), + '*', + '?'); + } + + inline bool sequence_match(const std::string& pattern, + const std::string& str, + std::size_t& diff_index, + char& diff_value) + { + if (str.empty()) + { + return ("Z" == pattern); + } + else if ('*' == pattern[0]) + return false; + + typedef std::string::const_iterator itr_t; + + itr_t p_itr = pattern.begin(); + itr_t s_itr = str .begin(); + + itr_t p_end = pattern.end(); + itr_t s_end = str .end(); + + while ((s_end != s_itr) && (p_end != p_itr)) + { + if ('*' == (*p_itr)) + { + const char_t target = static_cast(std::toupper(*(p_itr - 1))); + + if ('*' == target) + { + diff_index = std::distance(str.begin(),s_itr); + diff_value = static_cast(std::toupper(*p_itr)); + + return false; + } + else + ++p_itr; + + while (s_itr != s_end) + { + if (target != std::toupper(*s_itr)) + break; + else + ++s_itr; + } + + continue; + } + else if ( + ('?' != *p_itr) && + std::toupper(*p_itr) != std::toupper(*s_itr) + ) + { + diff_index = std::distance(str.begin(),s_itr); + diff_value = static_cast(std::toupper(*p_itr)); + + return false; + } + + ++p_itr; + ++s_itr; + } + + return ( + (s_end == s_itr) && + ( + (p_end == p_itr) || + ('*' == *p_itr) + ) + ); + } + + static const double pow10[] = { + 1.0, + 1.0E+001, 1.0E+002, 1.0E+003, 1.0E+004, + 1.0E+005, 1.0E+006, 1.0E+007, 1.0E+008, + 1.0E+009, 1.0E+010, 1.0E+011, 1.0E+012, + 1.0E+013, 1.0E+014, 1.0E+015, 1.0E+016 + }; + + static const std::size_t pow10_size = sizeof(pow10) / sizeof(double); + + namespace numeric + { + namespace constant + { + static const double e = 2.71828182845904523536028747135266249775724709369996; + static const double pi = 3.14159265358979323846264338327950288419716939937510; + static const double pi_2 = 1.57079632679489661923132169163975144209858469968755; + static const double pi_4 = 0.78539816339744830961566084581987572104929234984378; + static const double pi_180 = 0.01745329251994329576923690768488612713442871888542; + static const double _1_pi = 0.31830988618379067153776752674502872406891929148091; + static const double _2_pi = 0.63661977236758134307553505349005744813783858296183; + static const double _180_pi = 57.29577951308232087679815481410517033240547246656443; + static const double log2 = 0.69314718055994530941723212145817656807550013436026; + static const double sqrt2 = 1.41421356237309504880168872420969807856967187537695; + } + + namespace details + { + struct unknown_type_tag {}; + struct real_type_tag {}; + struct complex_type_tag {}; + struct int_type_tag {}; + + template + struct number_type { typedef unknown_type_tag type; }; + +#define exprtk_register_real_type_tag(T) \ +template<> struct number_type { typedef real_type_tag type; }; \ + +#define exprtk_register_complex_type_tag(T) \ +template<> struct number_type > \ +{ typedef complex_type_tag type; }; \ + +#define exprtk_register_int_type_tag(T) \ +template<> struct number_type { typedef int_type_tag type; }; \ + + exprtk_register_real_type_tag(double ) + exprtk_register_real_type_tag(long double) + exprtk_register_real_type_tag(float ) + + exprtk_register_complex_type_tag(double ) + exprtk_register_complex_type_tag(long double) + exprtk_register_complex_type_tag(float ) + + exprtk_register_int_type_tag(short ) + exprtk_register_int_type_tag(int ) + exprtk_register_int_type_tag(long long int ) + exprtk_register_int_type_tag(unsigned short ) + exprtk_register_int_type_tag(unsigned int ) + exprtk_register_int_type_tag(unsigned long long int) + +#undef exprtk_register_real_type_tag +#undef exprtk_register_int_type_tag + + template + struct epsilon_type + { + static inline T value() + { + const T epsilon = T(0.0000000001); + return epsilon; + } + }; + + template <> + struct epsilon_type + { + static inline float value() + { + const float epsilon = float(0.000001f); + return epsilon; + } + }; + + template <> + struct epsilon_type + { + static inline long double value() + { + const long double epsilon = (long double)(0.000000000001); + return epsilon; + } + }; + + template + inline bool is_nan_impl(const T v, real_type_tag) + { + return std::not_equal_to()(v,v); + } + + template + inline int to_int32_impl(const T v, real_type_tag) + { + return static_cast(v); + } + + template + inline long long int to_int64_impl(const T v, real_type_tag) + { + return static_cast(v); + } + + template + inline bool is_true_impl(const T v) + { + return std::not_equal_to()(T(0),v); + } + + template + inline bool is_false_impl(const T v) + { + return std::equal_to()(T(0),v); + } + + template + inline T abs_impl(const T v, real_type_tag) + { + return ((v < T(0)) ? -v : v); + } + + template + inline T min_impl(const T v0, const T v1, real_type_tag) + { + return std::min(v0,v1); + } + + template + inline T max_impl(const T v0, const T v1, real_type_tag) + { + return std::max(v0,v1); + } + + template + inline T equal_impl(const T v0, const T v1, real_type_tag) + { + const T epsilon = epsilon_type::value(); + return (abs_impl(v0 - v1,real_type_tag()) <= (std::max(T(1),std::max(abs_impl(v0,real_type_tag()),abs_impl(v1,real_type_tag()))) * epsilon)) ? T(1) : T(0); + } + + inline float equal_impl(const float v0, const float v1, real_type_tag) + { + const float epsilon = epsilon_type::value(); + return (abs_impl(v0 - v1,real_type_tag()) <= (std::max(1.0f,std::max(abs_impl(v0,real_type_tag()),abs_impl(v1,real_type_tag()))) * epsilon)) ? 1.0f : 0.0f; + } + + template + inline T equal_impl(const T v0, const T v1, int_type_tag) + { + return (v0 == v1) ? 1 : 0; + } + + template + inline T expm1_impl(const T v, real_type_tag) + { + // return std::expm1(v); + if (abs_impl(v,real_type_tag()) < T(0.00001)) + return v + (T(0.5) * v * v); + else + return std::exp(v) - T(1); + } + + template + inline T expm1_impl(const T v, int_type_tag) + { + return T(std::exp(v)) - T(1); + } + + template + inline T nequal_impl(const T v0, const T v1, real_type_tag) + { + typedef real_type_tag rtg; + const T epsilon = epsilon_type::value(); + return (abs_impl(v0 - v1,rtg()) > (std::max(T(1),std::max(abs_impl(v0,rtg()),abs_impl(v1,rtg()))) * epsilon)) ? T(1) : T(0); + } + + inline float nequal_impl(const float v0, const float v1, real_type_tag) + { + typedef real_type_tag rtg; + const float epsilon = epsilon_type::value(); + return (abs_impl(v0 - v1,rtg()) > (std::max(1.0f,std::max(abs_impl(v0,rtg()),abs_impl(v1,rtg()))) * epsilon)) ? 1.0f : 0.0f; + } + + template + inline T nequal_impl(const T v0, const T v1, int_type_tag) + { + return (v0 != v1) ? 1 : 0; + } + + template + inline T modulus_impl(const T v0, const T v1, real_type_tag) + { + return std::fmod(v0,v1); + } + + template + inline T modulus_impl(const T v0, const T v1, int_type_tag) + { + return v0 % v1; + } + + template + inline T pow_impl(const T v0, const T v1, real_type_tag) + { + return std::pow(v0,v1); + } + + template + inline T pow_impl(const T v0, const T v1, int_type_tag) + { + return std::pow(static_cast(v0),static_cast(v1)); + } + + template + inline T logn_impl(const T v0, const T v1, real_type_tag) + { + return std::log(v0) / std::log(v1); + } + + template + inline T logn_impl(const T v0, const T v1, int_type_tag) + { + return static_cast(logn_impl(static_cast(v0),static_cast(v1),real_type_tag())); + } + + template + inline T log1p_impl(const T v, real_type_tag) + { + if (v > T(-1)) + { + if (abs_impl(v,real_type_tag()) > T(0.0001)) + { + return std::log(T(1) + v); + } + else + return (T(-0.5) * v + T(1)) * v; + } + else + return std::numeric_limits::quiet_NaN(); + } + + template + inline T log1p_impl(const T v, int_type_tag) + { + if (v > T(-1)) + { + return std::log(T(1) + v); + } + else + return std::numeric_limits::quiet_NaN(); + } + + template + inline T root_impl(const T v0, const T v1, real_type_tag) + { + return std::pow(v0,T(1) / v1); + } + + template + inline T root_impl(const T v0, const T v1, int_type_tag) + { + return root_impl(static_cast(v0),static_cast(v1),real_type_tag()); + } + + template + inline T round_impl(const T v, real_type_tag) + { + return ((v < T(0)) ? std::ceil(v - T(0.5)) : std::floor(v + T(0.5))); + } + + template + inline T roundn_impl(const T v0, const T v1, real_type_tag) + { + const int index = std::max(0, std::min(pow10_size - 1, (int)std::floor(v1))); + const T p10 = T(pow10[index]); + + if (v0 < T(0)) + return T(std::ceil ((v0 * p10) - T(0.5)) / p10); + else + return T(std::floor((v0 * p10) + T(0.5)) / p10); + } + + template + inline T roundn_impl(const T v0, const T, int_type_tag) + { + return v0; + } + + template + inline T hypot_impl(const T v0, const T v1, real_type_tag) + { + return std::sqrt((v0 * v0) + (v1 * v1)); + } + + template + inline T hypot_impl(const T v0, const T v1, int_type_tag) + { + return static_cast(std::sqrt(static_cast((v0 * v0) + (v1 * v1)))); + } + + template + inline T atan2_impl(const T v0, const T v1, real_type_tag) + { + return std::atan2(v0,v1); + } + + template + inline T atan2_impl(const T, const T, int_type_tag) + { + return 0; + } + + template + inline T shr_impl(const T v0, const T v1, real_type_tag) + { + return v0 * (T(1) / std::pow(T(2),static_cast(static_cast(v1)))); + } + + template + inline T shr_impl(const T v0, const T v1, int_type_tag) + { + return v0 >> v1; + } + + template + inline T shl_impl(const T v0, const T v1, real_type_tag) + { + return v0 * std::pow(T(2),static_cast(static_cast(v1))); + } + + template + inline T shl_impl(const T v0, const T v1, int_type_tag) + { + return v0 << v1; + } + + template + inline T sgn_impl(const T v, real_type_tag) + { + if (v > T(0)) return T(+1); + else if (v < T(0)) return T(-1); + else return T( 0); + } + + template + inline T sgn_impl(const T v, int_type_tag) + { + if (v > T(0)) return T(+1); + else if (v < T(0)) return T(-1); + else return T( 0); + } + + template + inline T and_impl(const T v0, const T v1, real_type_tag) + { + return (is_true_impl(v0) && is_true_impl(v1)) ? T(1) : T(0); + } + + template + inline T and_impl(const T v0, const T v1, int_type_tag) + { + return v0 && v1; + } + + template + inline T nand_impl(const T v0, const T v1, real_type_tag) + { + return (is_false_impl(v0) || is_false_impl(v1)) ? T(1) : T(0); + } + + template + inline T nand_impl(const T v0, const T v1, int_type_tag) + { + return !(v0 && v1); + } + + template + inline T or_impl(const T v0, const T v1, real_type_tag) + { + return (is_true_impl(v0) || is_true_impl(v1)) ? T(1) : T(0); + } + + template + inline T or_impl(const T v0, const T v1, int_type_tag) + { + return (v0 || v1); + } + + template + inline T nor_impl(const T v0, const T v1, real_type_tag) + { + return (is_false_impl(v0) && is_false_impl(v1)) ? T(1) : T(0); + } + + template + inline T nor_impl(const T v0, const T v1, int_type_tag) + { + return !(v0 || v1); + } + + template + inline T xor_impl(const T v0, const T v1, real_type_tag) + { + return (is_false_impl(v0) != is_false_impl(v1)) ? T(1) : T(0); + } + + template + inline T xor_impl(const T v0, const T v1, int_type_tag) + { + return v0 ^ v1; + } + + template + inline T xnor_impl(const T v0, const T v1, real_type_tag) + { + const bool v0_true = is_true_impl(v0); + const bool v1_true = is_true_impl(v1); + + if ((v0_true && v1_true) || (!v0_true && !v1_true)) + return T(1); + else + return T(0); + } + + template + inline T xnor_impl(const T v0, const T v1, int_type_tag) + { + const bool v0_true = is_true_impl(v0); + const bool v1_true = is_true_impl(v1); + + if ((v0_true && v1_true) || (!v0_true && !v1_true)) + return T(1); + else + return T(0); + } + +#if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER) +#define exprtk_define_erf(TT,impl) \ +inline TT erf_impl(TT v) { return impl(v); } \ + + exprtk_define_erf( float,::erff) + exprtk_define_erf( double,::erf ) + exprtk_define_erf(long double,::erfl) +#undef exprtk_define_erf +#endif + + template + inline T erf_impl(T v, real_type_tag) + { +#if defined(_MSC_VER) && (_MSC_VER < 1900) + // Credits: Abramowitz & Stegun Equations 7.1.25-28 + static const T c[] = { + T( 1.26551223), T(1.00002368), + T( 0.37409196), T(0.09678418), + T(-0.18628806), T(0.27886807), + T(-1.13520398), T(1.48851587), + T(-0.82215223), T(0.17087277) + }; + + const T t = T(1) / (T(1) + T(0.5) * abs_impl(v,real_type_tag())); + + T result = T(1) - t * std::exp((-v * v) - + c[0] + t * (c[1] + t * + (c[2] + t * (c[3] + t * + (c[4] + t * (c[5] + t * + (c[6] + t * (c[7] + t * + (c[8] + t * (c[9])))))))))); + + return (v >= T(0)) ? result : -result; +#else + return erf_impl(v); +#endif + } + + template + inline T erf_impl(T v, int_type_tag) + { + return erf_impl(static_cast(v),real_type_tag()); + } + +#if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER) +#define exprtk_define_erfc(TT,impl) \ +inline TT erfc_impl(TT v) { return impl(v); } \ + + exprtk_define_erfc( float,::erfcf) + exprtk_define_erfc( double,::erfc ) + exprtk_define_erfc(long double,::erfcl) +#undef exprtk_define_erfc +#endif + + template + inline T erfc_impl(T v, real_type_tag) + { +#if defined(_MSC_VER) && (_MSC_VER < 1900) + return T(1) - erf_impl(v,real_type_tag()); +#else + return erfc_impl(v); +#endif + } + + template + inline T erfc_impl(T v, int_type_tag) + { + return erfc_impl(static_cast(v),real_type_tag()); + } + + template + inline T ncdf_impl(T v, real_type_tag) + { + T cnd = T(0.5) * (T(1) + erf_impl( + abs_impl(v,real_type_tag()) / + T(numeric::constant::sqrt2),real_type_tag())); + return (v < T(0)) ? (T(1) - cnd) : cnd; + } + + template + inline T ncdf_impl(T v, int_type_tag) + { + return ncdf_impl(static_cast(v),real_type_tag()); + } + + template + inline T sinc_impl(T v, real_type_tag) + { + if (std::abs(v) >= std::numeric_limits::epsilon()) + return(std::sin(v) / v); + else + return T(1); + } + + template + inline T sinc_impl(T v, int_type_tag) + { + return sinc_impl(static_cast(v),real_type_tag()); + } + + template inline T acos_impl(const T v, real_type_tag) { return std::acos (v); } + template inline T acosh_impl(const T v, real_type_tag) { return std::log(v + std::sqrt((v * v) - T(1))); } + template inline T asin_impl(const T v, real_type_tag) { return std::asin (v); } + template inline T asinh_impl(const T v, real_type_tag) { return std::log(v + std::sqrt((v * v) + T(1))); } + template inline T atan_impl(const T v, real_type_tag) { return std::atan (v); } + template inline T atanh_impl(const T v, real_type_tag) { return (std::log(T(1) + v) - std::log(T(1) - v)) / T(2); } + template inline T ceil_impl(const T v, real_type_tag) { return std::ceil (v); } + template inline T cos_impl(const T v, real_type_tag) { return std::cos (v); } + template inline T cosh_impl(const T v, real_type_tag) { return std::cosh (v); } + template inline T exp_impl(const T v, real_type_tag) { return std::exp (v); } + template inline T floor_impl(const T v, real_type_tag) { return std::floor(v); } + template inline T log_impl(const T v, real_type_tag) { return std::log (v); } + template inline T log10_impl(const T v, real_type_tag) { return std::log10(v); } + template inline T log2_impl(const T v, real_type_tag) { return std::log(v)/T(numeric::constant::log2); } + template inline T neg_impl(const T v, real_type_tag) { return -v; } + template inline T pos_impl(const T v, real_type_tag) { return +v; } + template inline T sin_impl(const T v, real_type_tag) { return std::sin (v); } + template inline T sinh_impl(const T v, real_type_tag) { return std::sinh (v); } + template inline T sqrt_impl(const T v, real_type_tag) { return std::sqrt (v); } + template inline T tan_impl(const T v, real_type_tag) { return std::tan (v); } + template inline T tanh_impl(const T v, real_type_tag) { return std::tanh (v); } + template inline T cot_impl(const T v, real_type_tag) { return T(1) / std::tan(v); } + template inline T sec_impl(const T v, real_type_tag) { return T(1) / std::cos(v); } + template inline T csc_impl(const T v, real_type_tag) { return T(1) / std::sin(v); } + template inline T r2d_impl(const T v, real_type_tag) { return (v * T(numeric::constant::_180_pi)); } + template inline T d2r_impl(const T v, real_type_tag) { return (v * T(numeric::constant::pi_180)); } + template inline T d2g_impl(const T v, real_type_tag) { return (v * T(20.0/9.0)); } + template inline T g2d_impl(const T v, real_type_tag) { return (v * T(9.0/20.0)); } + template inline T notl_impl(const T v, real_type_tag) { return (std::not_equal_to()(T(0),v) ? T(0) : T(1)); } + template inline T frac_impl(const T v, real_type_tag) { return (v - static_cast(v)); } + template inline T trunc_impl(const T v, real_type_tag) { return T(static_cast(v)); } + + template inline T abs_impl(const T v, int_type_tag) { return ((v >= T(0)) ? v : -v); } + template inline T exp_impl(const T v, int_type_tag) { return std::exp (v); } + template inline T log_impl(const T v, int_type_tag) { return std::log (v); } + template inline T log10_impl(const T v, int_type_tag) { return std::log10(v); } + template inline T log2_impl(const T v, int_type_tag) { return std::log(v)/T(numeric::constant::log2); } + template inline T neg_impl(const T v, int_type_tag) { return -v; } + template inline T pos_impl(const T v, int_type_tag) { return +v; } + template inline T ceil_impl(const T v, int_type_tag) { return v; } + template inline T floor_impl(const T v, int_type_tag) { return v; } + template inline T round_impl(const T v, int_type_tag) { return v; } + template inline T notl_impl(const T v, int_type_tag) { return !v; } + template inline T sqrt_impl(const T v, int_type_tag) { return std::sqrt (v); } + template inline T frac_impl(const T , int_type_tag) { return T(0); } + template inline T trunc_impl(const T v, int_type_tag) { return v; } + template inline T acos_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T acosh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T asin_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T asinh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T atan_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T atanh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T cos_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T cosh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T sin_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T sinh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T tan_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T tanh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T cot_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T sec_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + template inline T csc_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } + + template + inline bool is_integer_impl(const T& v, real_type_tag) + { + return std::equal_to()(T(0),std::fmod(v,T(1))); + } + + template + inline bool is_integer_impl(const T&, int_type_tag) + { + return true; + } + } + + template + struct numeric_info { enum { length = 0, size = 32, bound_length = 0, min_exp = 0, max_exp = 0 }; }; + + template<> struct numeric_info { enum { length = 10, size = 16, bound_length = 9}; }; + template<> struct numeric_info { enum { min_exp = -38, max_exp = +38}; }; + template<> struct numeric_info { enum { min_exp = -308, max_exp = +308}; }; + template<> struct numeric_info { enum { min_exp = -308, max_exp = +308}; }; + template - struct epsilon_type + inline int to_int32(const T v) { - static inline T value() - { - const T epsilon = T(0.0000000001); - return epsilon; - } - }; - - template <> - struct epsilon_type - { - static inline float value() - { - const float epsilon = float(0.000001f); - return epsilon; - } - }; - - template <> - struct epsilon_type - { - static inline long double value() - { - const long double epsilon = (long double)(0.000000000001); - return epsilon; - } - }; - + typename details::number_type::type num_type; + return to_int32_impl(v,num_type); + } + template - inline bool is_nan_impl(const T v, real_type_tag) + inline long long int to_int64(const T v) { - return std::not_equal_to()(v,v); + typename details::number_type::type num_type; + return to_int64_impl(v,num_type); } - + template - inline int to_int32_impl(const T v, real_type_tag) + inline bool is_nan(const T v) { - return static_cast(v); + typename details::number_type::type num_type; + return is_nan_impl(v,num_type); } - + template - inline long long int to_int64_impl(const T v, real_type_tag) + inline T min(const T v0, const T v1) { - return static_cast(v); + typename details::number_type::type num_type; + return min_impl(v0,v1,num_type); } - + template - inline bool is_true_impl(const T v) + inline T max(const T v0, const T v1) { - return std::not_equal_to()(T(0),v); + typename details::number_type::type num_type; + return max_impl(v0,v1,num_type); } - + template - inline bool is_false_impl(const T v) + inline T equal(const T v0, const T v1) { - return std::equal_to()(T(0),v); + typename details::number_type::type num_type; + return equal_impl(v0,v1,num_type); } - + template - inline T abs_impl(const T v, real_type_tag) + inline T nequal(const T v0, const T v1) { - return ((v >= T(0)) ? v : -v); + typename details::number_type::type num_type; + return nequal_impl(v0,v1,num_type); } - + template - inline T min_impl(const T v0, const T v1, real_type_tag) + inline T modulus(const T v0, const T v1) { - return std::min(v0,v1); + typename details::number_type::type num_type; + return modulus_impl(v0,v1,num_type); } - + template - inline T max_impl(const T v0, const T v1, real_type_tag) + inline T pow(const T v0, const T v1) { - return std::max(v0,v1); + typename details::number_type::type num_type; + return pow_impl(v0,v1,num_type); } - + template - inline T equal_impl(const T v0, const T v1, real_type_tag) + inline T logn(const T v0, const T v1) { - const T epsilon = epsilon_type::value(); - return (abs_impl(v0 - v1,real_type_tag()) <= (std::max(T(1),std::max(abs_impl(v0,real_type_tag()),abs_impl(v1,real_type_tag()))) * epsilon)) ? T(1) : T(0); + typename details::number_type::type num_type; + return logn_impl(v0,v1,num_type); } - - inline float equal_impl(const float v0, const float v1, real_type_tag) + + template + inline T root(const T v0, const T v1) { - const float epsilon = epsilon_type::value(); - return (abs_impl(v0 - v1,real_type_tag()) <= (std::max(1.0f,std::max(abs_impl(v0,real_type_tag()),abs_impl(v1,real_type_tag()))) * epsilon)) ? 1.0f : 0.0f; + typename details::number_type::type num_type; + return root_impl(v0,v1,num_type); } - + template - inline T equal_impl(const T v0, const T v1, int_type_tag) + inline T roundn(const T v0, const T v1) { - return (v0 == v1) ? 1 : 0; + typename details::number_type::type num_type; + return roundn_impl(v0,v1,num_type); } - + template - inline T expm1_impl(const T v, real_type_tag) + inline T hypot(const T v0, const T v1) { - // return std::expm1(v); - if (abs_impl(v,real_type_tag()) < T(0.00001)) - return v + (T(0.5) * v * v); - else - return std::exp(v) - T(1); + typename details::number_type::type num_type; + return hypot_impl(v0,v1,num_type); } - + template - inline T expm1_impl(const T v, int_type_tag) + inline T atan2(const T v0, const T v1) { - return T(std::exp(v)) - T(1); + typename details::number_type::type num_type; + return atan2_impl(v0,v1,num_type); } - + template - inline T nequal_impl(const T v0, const T v1, real_type_tag) + inline T shr(const T v0, const T v1) { - const T epsilon = epsilon_type::value(); - return (abs_impl(v0 - v1,real_type_tag()) > (std::max(T(1),std::max(abs_impl(v0,real_type_tag()),abs_impl(v1,real_type_tag()))) * epsilon)) ? T(1) : T(0); + typename details::number_type::type num_type; + return shr_impl(v0,v1,num_type); } - - inline float nequal_impl(const float v0, const float v1, real_type_tag) + + template + inline T shl(const T v0, const T v1) { - const float epsilon = epsilon_type::value(); - return (abs_impl(v0 - v1,real_type_tag()) > (std::max(1.0f,std::max(abs_impl(v0,real_type_tag()),abs_impl(v1,real_type_tag()))) * epsilon)) ? 1.0f : 0.0f; + typename details::number_type::type num_type; + return shl_impl(v0,v1,num_type); } - + template - inline T nequal_impl(const T v0, const T v1, int_type_tag) + inline T and_opr(const T v0, const T v1) { - return (v0 != v1) ? 1 : 0; + typename details::number_type::type num_type; + return and_impl(v0,v1,num_type); } - + template - inline T modulus_impl(const T v0, const T v1, real_type_tag) + inline T nand_opr(const T v0, const T v1) { - return std::fmod(v0,v1); + typename details::number_type::type num_type; + return nand_impl(v0,v1,num_type); } - + template - inline T modulus_impl(const T v0, const T v1, int_type_tag) + inline T or_opr(const T v0, const T v1) { - return v0 % v1; + typename details::number_type::type num_type; + return or_impl(v0,v1,num_type); } - + template - inline T pow_impl(const T v0, const T v1, real_type_tag) + inline T nor_opr(const T v0, const T v1) { - return std::pow(v0,v1); + typename details::number_type::type num_type; + return nor_impl(v0,v1,num_type); } - + template - inline T pow_impl(const T v0, const T v1, int_type_tag) + inline T xor_opr(const T v0, const T v1) { - return std::pow(static_cast(v0),static_cast(v1)); + typename details::number_type::type num_type; + return xor_impl(v0,v1,num_type); } - + template - inline T logn_impl(const T v0, const T v1, real_type_tag) + inline T xnor_opr(const T v0, const T v1) { - return std::log(v0) / std::log(v1); + typename details::number_type::type num_type; + return xnor_impl(v0,v1,num_type); } - + template - inline T logn_impl(const T v0, const T v1, int_type_tag) + inline bool is_integer(const T v) + { + typename details::number_type::type num_type; + return is_integer_impl(v,num_type); + } + + template + struct fast_exp + { + static inline T result(T v) + { + unsigned int k = N; + T l = T(1); + + while (k) + { + if (k & 1) + { + l *= v; + --k; + } + + v *= v; + k >>= 1; + } + + return l; + } + }; + + template struct fast_exp { static inline T result(T v) { T v_5 = fast_exp::result(v); return v_5 * v_5; } }; + template struct fast_exp { static inline T result(T v) { return fast_exp::result(v) * v; } }; + template struct fast_exp { static inline T result(T v) { T v_4 = fast_exp::result(v); return v_4 * v_4; } }; + template struct fast_exp { static inline T result(T v) { return fast_exp::result(v) * v; } }; + template struct fast_exp { static inline T result(T v) { T v_3 = fast_exp::result(v); return v_3 * v_3; } }; + template struct fast_exp { static inline T result(T v) { return fast_exp::result(v) * v; } }; + template struct fast_exp { static inline T result(T v) { T v_2 = v * v; return v_2 * v_2; } }; + template struct fast_exp { static inline T result(T v) { return v * v * v; } }; + template struct fast_exp { static inline T result(T v) { return v * v; } }; + template struct fast_exp { static inline T result(T v) { return v; } }; + template struct fast_exp { static inline T result(T ) { return T(1); } }; + +#define exprtk_define_unary_function(FunctionName) \ +template \ +inline T FunctionName (const T v) \ +{ \ +typename details::number_type::type num_type; \ +return FunctionName##_impl(v,num_type); \ +} \ + + exprtk_define_unary_function(abs ) + exprtk_define_unary_function(acos ) + exprtk_define_unary_function(acosh) + exprtk_define_unary_function(asin ) + exprtk_define_unary_function(asinh) + exprtk_define_unary_function(atan ) + exprtk_define_unary_function(atanh) + exprtk_define_unary_function(ceil ) + exprtk_define_unary_function(cos ) + exprtk_define_unary_function(cosh ) + exprtk_define_unary_function(exp ) + exprtk_define_unary_function(expm1) + exprtk_define_unary_function(floor) + exprtk_define_unary_function(log ) + exprtk_define_unary_function(log10) + exprtk_define_unary_function(log2 ) + exprtk_define_unary_function(log1p) + exprtk_define_unary_function(neg ) + exprtk_define_unary_function(pos ) + exprtk_define_unary_function(round) + exprtk_define_unary_function(sin ) + exprtk_define_unary_function(sinc ) + exprtk_define_unary_function(sinh ) + exprtk_define_unary_function(sqrt ) + exprtk_define_unary_function(tan ) + exprtk_define_unary_function(tanh ) + exprtk_define_unary_function(cot ) + exprtk_define_unary_function(sec ) + exprtk_define_unary_function(csc ) + exprtk_define_unary_function(r2d ) + exprtk_define_unary_function(d2r ) + exprtk_define_unary_function(d2g ) + exprtk_define_unary_function(g2d ) + exprtk_define_unary_function(notl ) + exprtk_define_unary_function(sgn ) + exprtk_define_unary_function(erf ) + exprtk_define_unary_function(erfc ) + exprtk_define_unary_function(ncdf ) + exprtk_define_unary_function(frac ) + exprtk_define_unary_function(trunc) +#undef exprtk_define_unary_function + } + + template + inline T compute_pow10(T d, const int exponent) + { + static const double fract10[] = + { + 0.0, + 1.0E+001, 1.0E+002, 1.0E+003, 1.0E+004, 1.0E+005, 1.0E+006, 1.0E+007, 1.0E+008, 1.0E+009, 1.0E+010, + 1.0E+011, 1.0E+012, 1.0E+013, 1.0E+014, 1.0E+015, 1.0E+016, 1.0E+017, 1.0E+018, 1.0E+019, 1.0E+020, + 1.0E+021, 1.0E+022, 1.0E+023, 1.0E+024, 1.0E+025, 1.0E+026, 1.0E+027, 1.0E+028, 1.0E+029, 1.0E+030, + 1.0E+031, 1.0E+032, 1.0E+033, 1.0E+034, 1.0E+035, 1.0E+036, 1.0E+037, 1.0E+038, 1.0E+039, 1.0E+040, + 1.0E+041, 1.0E+042, 1.0E+043, 1.0E+044, 1.0E+045, 1.0E+046, 1.0E+047, 1.0E+048, 1.0E+049, 1.0E+050, + 1.0E+051, 1.0E+052, 1.0E+053, 1.0E+054, 1.0E+055, 1.0E+056, 1.0E+057, 1.0E+058, 1.0E+059, 1.0E+060, + 1.0E+061, 1.0E+062, 1.0E+063, 1.0E+064, 1.0E+065, 1.0E+066, 1.0E+067, 1.0E+068, 1.0E+069, 1.0E+070, + 1.0E+071, 1.0E+072, 1.0E+073, 1.0E+074, 1.0E+075, 1.0E+076, 1.0E+077, 1.0E+078, 1.0E+079, 1.0E+080, + 1.0E+081, 1.0E+082, 1.0E+083, 1.0E+084, 1.0E+085, 1.0E+086, 1.0E+087, 1.0E+088, 1.0E+089, 1.0E+090, + 1.0E+091, 1.0E+092, 1.0E+093, 1.0E+094, 1.0E+095, 1.0E+096, 1.0E+097, 1.0E+098, 1.0E+099, 1.0E+100, + 1.0E+101, 1.0E+102, 1.0E+103, 1.0E+104, 1.0E+105, 1.0E+106, 1.0E+107, 1.0E+108, 1.0E+109, 1.0E+110, + 1.0E+111, 1.0E+112, 1.0E+113, 1.0E+114, 1.0E+115, 1.0E+116, 1.0E+117, 1.0E+118, 1.0E+119, 1.0E+120, + 1.0E+121, 1.0E+122, 1.0E+123, 1.0E+124, 1.0E+125, 1.0E+126, 1.0E+127, 1.0E+128, 1.0E+129, 1.0E+130, + 1.0E+131, 1.0E+132, 1.0E+133, 1.0E+134, 1.0E+135, 1.0E+136, 1.0E+137, 1.0E+138, 1.0E+139, 1.0E+140, + 1.0E+141, 1.0E+142, 1.0E+143, 1.0E+144, 1.0E+145, 1.0E+146, 1.0E+147, 1.0E+148, 1.0E+149, 1.0E+150, + 1.0E+151, 1.0E+152, 1.0E+153, 1.0E+154, 1.0E+155, 1.0E+156, 1.0E+157, 1.0E+158, 1.0E+159, 1.0E+160, + 1.0E+161, 1.0E+162, 1.0E+163, 1.0E+164, 1.0E+165, 1.0E+166, 1.0E+167, 1.0E+168, 1.0E+169, 1.0E+170, + 1.0E+171, 1.0E+172, 1.0E+173, 1.0E+174, 1.0E+175, 1.0E+176, 1.0E+177, 1.0E+178, 1.0E+179, 1.0E+180, + 1.0E+181, 1.0E+182, 1.0E+183, 1.0E+184, 1.0E+185, 1.0E+186, 1.0E+187, 1.0E+188, 1.0E+189, 1.0E+190, + 1.0E+191, 1.0E+192, 1.0E+193, 1.0E+194, 1.0E+195, 1.0E+196, 1.0E+197, 1.0E+198, 1.0E+199, 1.0E+200, + 1.0E+201, 1.0E+202, 1.0E+203, 1.0E+204, 1.0E+205, 1.0E+206, 1.0E+207, 1.0E+208, 1.0E+209, 1.0E+210, + 1.0E+211, 1.0E+212, 1.0E+213, 1.0E+214, 1.0E+215, 1.0E+216, 1.0E+217, 1.0E+218, 1.0E+219, 1.0E+220, + 1.0E+221, 1.0E+222, 1.0E+223, 1.0E+224, 1.0E+225, 1.0E+226, 1.0E+227, 1.0E+228, 1.0E+229, 1.0E+230, + 1.0E+231, 1.0E+232, 1.0E+233, 1.0E+234, 1.0E+235, 1.0E+236, 1.0E+237, 1.0E+238, 1.0E+239, 1.0E+240, + 1.0E+241, 1.0E+242, 1.0E+243, 1.0E+244, 1.0E+245, 1.0E+246, 1.0E+247, 1.0E+248, 1.0E+249, 1.0E+250, + 1.0E+251, 1.0E+252, 1.0E+253, 1.0E+254, 1.0E+255, 1.0E+256, 1.0E+257, 1.0E+258, 1.0E+259, 1.0E+260, + 1.0E+261, 1.0E+262, 1.0E+263, 1.0E+264, 1.0E+265, 1.0E+266, 1.0E+267, 1.0E+268, 1.0E+269, 1.0E+270, + 1.0E+271, 1.0E+272, 1.0E+273, 1.0E+274, 1.0E+275, 1.0E+276, 1.0E+277, 1.0E+278, 1.0E+279, 1.0E+280, + 1.0E+281, 1.0E+282, 1.0E+283, 1.0E+284, 1.0E+285, 1.0E+286, 1.0E+287, 1.0E+288, 1.0E+289, 1.0E+290, + 1.0E+291, 1.0E+292, 1.0E+293, 1.0E+294, 1.0E+295, 1.0E+296, 1.0E+297, 1.0E+298, 1.0E+299, 1.0E+300, + 1.0E+301, 1.0E+302, 1.0E+303, 1.0E+304, 1.0E+305, 1.0E+306, 1.0E+307, 1.0E+308 + }; + + static const int fract10_size = static_cast(sizeof(fract10) / sizeof(double)); + + const int e = std::abs(exponent); + + if (exponent >= std::numeric_limits::min_exponent10) + { + if (e < fract10_size) + { + if (exponent > 0) + return T(d * fract10[e]); + else + return T(d / fract10[e]); + } + else + return T(d * std::pow(10.0, 10.0 * exponent)); + } + else { - return static_cast(logn_impl(static_cast(v0),static_cast(v1),real_type_tag())); + d /= T(fract10[ -std::numeric_limits::min_exponent10]); + return T(d / fract10[-exponent + std::numeric_limits::min_exponent10]); + } + } + + template + inline bool string_to_type_converter_impl_ref(Iterator& itr, const Iterator end, T& result) + { + if (itr == end) + return false; + + bool negative = ('-' == (*itr)); + + if (negative || ('+' == (*itr))) + { + if (end == ++itr) + return false; + } + + while ((end != itr) && ('0' == (*itr))) ++itr; + + bool return_result = true; + unsigned int digit = 0; + const std::size_t length = std::distance(itr,end); + + if (length <= 4) + { + switch (length) + { +#ifdef exprtk_use_lut + +#define exprtk_process_digit \ +if ((digit = details::digit_table[(int)*itr++]) < 10) result = result * 10 + (digit); else { return_result = false; break; } + +#else +#define exprtk_process_digit \ +if ((digit = (*itr++ - '0')) < 10) result = result * 10 + (digit); else { return_result = false; break; } + +#endif + + case 4 : exprtk_process_digit + case 3 : exprtk_process_digit + case 2 : exprtk_process_digit + case 1 : if ((digit = (*itr - '0'))>= 10) { digit = 0; return_result = false; } + +#undef exprtk_process_digit + } } - - template - inline T log1p_impl(const T v, real_type_tag) - { - if (v > T(-1)) - { - if (abs_impl(v,real_type_tag()) > T(0.0001)) - { - return std::log(T(1) + v); - } - else - return (T(-0.5) * v + T(1)) * v; - } - else - return std::numeric_limits::quiet_NaN(); + else + return_result = false; + + if (length && return_result) + { + result = result * 10 + static_cast(digit); + ++itr; + } + + result = negative ? -result : result; + return return_result; + } + + template + static inline bool parse_nan(Iterator& itr, const Iterator end, T& t) + { + typedef typename std::iterator_traits::value_type type; + + static const std::size_t nan_length = 3; + + if (std::distance(itr,end) != static_cast(nan_length)) + return false; + + if (static_cast('n') == (*itr)) + { + if ( + (static_cast('a') != *(itr + 1)) || + (static_cast('n') != *(itr + 2)) + ) + { + return false; + } } - - template - inline T log1p_impl(const T v, int_type_tag) + else if ( + (static_cast('A') != *(itr + 1)) || + (static_cast('N') != *(itr + 2)) + ) { - if (v > T(-1)) - { - return std::log(T(1) + v); - } - else - return std::numeric_limits::quiet_NaN(); + return false; } - - template - inline T root_impl(const T v0, const T v1, real_type_tag) + + t = std::numeric_limits::quiet_NaN(); + + return true; + } + + template + static inline bool parse_inf(Iterator& itr, const Iterator end, T& t, bool negative) + { + static const char_t inf_uc[] = "INFINITY"; + static const char_t inf_lc[] = "infinity"; + static const std::size_t inf_length = 8; + + const std::size_t length = std::distance(itr,end); + + if ((3 != length) && (inf_length != length)) + return false; + + const char* inf_itr = ('i' == (*itr)) ? inf_lc : inf_uc; + + while (end != itr) + { + if (*inf_itr == static_cast(*itr)) + { + ++itr; + ++inf_itr; + continue; + } + else + return false; + } + + if (negative) + t = -std::numeric_limits::infinity(); + else + t = std::numeric_limits::infinity(); + + return true; + } + + template + inline bool string_to_real(Iterator& itr_external, const Iterator end, T& t, numeric::details::real_type_tag) + { + if (end == itr_external) return false; + + Iterator itr = itr_external; + + T d = T(0); + + bool negative = ('-' == (*itr)); + + if (negative || '+' == (*itr)) + { + if (end == ++itr) + return false; + } + + bool instate = false; + +#define parse_digit_1(d) \ +if ((digit = (*itr - '0')) < 10) \ +{ d = d * T(10) + digit; } \ +else \ +{ break; } \ +if (end == ++itr) break; \ + +#define parse_digit_2(d) \ +if ((digit = (*itr - '0')) < 10) \ +{ d = d * T(10) + digit; } \ +else { break; } \ +++itr; \ + + if ('.' != (*itr)) + { + const Iterator curr = itr; + while ((end != itr) && ('0' == (*itr))) ++itr; + unsigned int digit; + + while (end != itr) + { + // Note: For 'physical' superscalar architectures it + // is advised that the following loop be: 4xPD1 and 1xPD2 +#ifdef exprtk_enable_superscalar + parse_digit_1(d) + parse_digit_1(d) +#endif + parse_digit_1(d) + parse_digit_1(d) + parse_digit_2(d) + } + + if (curr != itr) instate = true; + } + + int exponent = 0; + + if (end != itr) + { + if ('.' == (*itr)) + { + const Iterator curr = ++itr; + unsigned int digit; + T tmp_d = T(0); + + while (end != itr) + { +#ifdef exprtk_enable_superscalar + parse_digit_1(tmp_d) + parse_digit_1(tmp_d) + parse_digit_1(tmp_d) +#endif + parse_digit_1(tmp_d) + parse_digit_1(tmp_d) + parse_digit_2(tmp_d) + } + + if (curr != itr) + { + instate = true; + d += compute_pow10(tmp_d,static_cast(-std::distance(curr,itr))); + } + +#undef parse_digit_1 +#undef parse_digit_2 + } + + if (end != itr) + { + typename std::iterator_traits::value_type c = (*itr); + + if (('e' == c) || ('E' == c)) + { + int exp = 0; + + if (!details::string_to_type_converter_impl_ref(++itr,end,exp)) + { + if (end == itr) + return false; + else + c = (*itr); + } + + exponent += exp; + } + + if (end != itr) + { + if (('f' == c) || ('F' == c) || ('l' == c) || ('L' == c)) + ++itr; + else if ('#' == c) + { + if (end == ++itr) + return false; + else if (('I' <= (*itr)) && ((*itr) <= 'n')) + { + if (('i' == (*itr)) || ('I' == (*itr))) + { + return parse_inf(itr,end,t,negative); + } + else if (('n' == (*itr)) || ('N' == (*itr))) + { + return parse_nan(itr,end,t); + } + else + return false; + } + else + return false; + } + else if (('I' <= (*itr)) && ((*itr) <= 'n')) + { + if (('i' == (*itr)) || ('I' == (*itr))) + { + return parse_inf(itr,end,t,negative); + } + else if (('n' == (*itr)) || ('N' == (*itr))) + { + return parse_nan(itr,end,t); + } + else + return false; + } + else + return false; + } + } + } + + if ((end != itr) || (!instate)) + return false; + else if (exponent) + d = compute_pow10(d,exponent); + + t = static_cast((negative) ? -d : d); + return true; + } + + template + inline bool string_to_real(const std::string& s, T& t) + { + const char* begin = s.data(); + const char* end = s.data() + s.size(); + typename numeric::details::number_type::type num_type; + return string_to_real(begin,end,t,num_type); + } + + template + struct functor_t + { + /* + Note: The following definitions for Type, may require tweaking + based on the compiler and target architecture. The benchmark + should provide enough information to make the right choice. + */ + //typedef T Type; + //typedef const T Type; + typedef const T& Type; + typedef T& RefType; + typedef T (*qfunc_t)(Type t0, Type t1, Type t2, Type t3); + typedef T (*tfunc_t)(Type t0, Type t1, Type t2); + typedef T (*bfunc_t)(Type t0, Type t1); + typedef T (*ufunc_t)(Type t0); + }; + + } // namespace details + + namespace lexer + { + struct token + { + enum token_type + { + e_none = 0, e_error = 1, e_err_symbol = 2, + e_err_number = 3, e_err_string = 4, e_err_sfunc = 5, + e_eof = 6, e_number = 7, e_symbol = 8, + e_string = 9, e_assign = 10, e_addass = 11, + e_subass = 12, e_mulass = 13, e_divass = 14, + e_modass = 15, e_shr = 16, e_shl = 17, + e_lte = 18, e_ne = 19, e_gte = 20, + e_swap = 21, e_lt = '<', e_gt = '>', + e_eq = '=', e_rbracket = ')', e_lbracket = '(', + e_rsqrbracket = ']', e_lsqrbracket = '[', e_rcrlbracket = '}', + e_lcrlbracket = '{', e_comma = ',', e_add = '+', + e_sub = '-', e_div = '/', e_mul = '*', + e_mod = '%', e_pow = '^', e_colon = ':', + e_ternary = '?' + }; + + token() + : type(e_none), + value(""), + position(std::numeric_limits::max()) + {} + + void clear() { - return std::pow(v0,T(1) / v1); + type = e_none; + value = ""; + position = std::numeric_limits::max(); + } + + template + inline token& set_operator(const token_type tt, const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) + { + type = tt; + value.assign(begin,end); + if (base_begin) + position = std::distance(base_begin,begin); + return *this; + } + + template + inline token& set_symbol(const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) + { + type = e_symbol; + value.assign(begin,end); + if (base_begin) + position = std::distance(base_begin,begin); + return *this; + } + + template + inline token& set_numeric(const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) + { + type = e_number; + value.assign(begin,end); + if (base_begin) + position = std::distance(base_begin,begin); + return *this; + } + + template + inline token& set_string(const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) + { + type = e_string; + value.assign(begin,end); + if (base_begin) + position = std::distance(base_begin,begin); + return *this; + } + + inline token& set_string(const std::string& s, const std::size_t p) + { + type = e_string; + value = s; + position = p; + return *this; + } + + template + inline token& set_error(const token_type et, const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) + { + if ( + (e_error == et) || + (e_err_symbol == et) || + (e_err_number == et) || + (e_err_string == et) || + (e_err_sfunc == et) + ) + { + type = et; + } + else + type = e_error; + + value.assign(begin,end); + + if (base_begin) + position = std::distance(base_begin,begin); + + return *this; + } + + static inline std::string to_str(token_type t) + { + switch (t) + { + case e_none : return "NONE"; + case e_error : return "ERROR"; + case e_err_symbol : return "ERROR_SYMBOL"; + case e_err_number : return "ERROR_NUMBER"; + case e_err_string : return "ERROR_STRING"; + case e_eof : return "EOF"; + case e_number : return "NUMBER"; + case e_symbol : return "SYMBOL"; + case e_string : return "STRING"; + case e_assign : return ":="; + case e_addass : return "+="; + case e_subass : return "-="; + case e_mulass : return "*="; + case e_divass : return "/="; + case e_modass : return "%="; + case e_shr : return ">>"; + case e_shl : return "<<"; + case e_lte : return "<="; + case e_ne : return "!="; + case e_gte : return ">="; + case e_lt : return "<"; + case e_gt : return ">"; + case e_eq : return "="; + case e_rbracket : return ")"; + case e_lbracket : return "("; + case e_rsqrbracket : return "]"; + case e_lsqrbracket : return "["; + case e_rcrlbracket : return "}"; + case e_lcrlbracket : return "{"; + case e_comma : return ","; + case e_add : return "+"; + case e_sub : return "-"; + case e_div : return "/"; + case e_mul : return "*"; + case e_mod : return "%"; + case e_pow : return "^"; + case e_colon : return ":"; + case e_ternary : return "?"; + case e_swap : return "<=>"; + default : return "UNKNOWN"; + } + } + + inline bool is_error() const + { + return ( + (e_error == type) || + (e_err_symbol == type) || + (e_err_number == type) || + (e_err_string == type) || + (e_err_sfunc == type) + ); + } + + token_type type; + std::string value; + std::size_t position; + }; + + class generator + { + public: + + typedef token token_t; + typedef std::vector token_list_t; + typedef std::vector::iterator token_list_itr_t; + typedef details::char_t char_t; + + generator() + : base_itr_(0), + s_itr_ (0), + s_end_ (0) + { + clear(); + } + + inline void clear() + { + base_itr_ = 0; + s_itr_ = 0; + s_end_ = 0; + token_list_.clear(); + token_itr_ = token_list_.end(); + store_token_itr_ = token_list_.end(); + } + + inline bool process(const std::string& str) + { + base_itr_ = str.data(); + s_itr_ = str.data(); + s_end_ = str.data() + str.size(); + + eof_token_.set_operator(token_t::e_eof,s_end_,s_end_,base_itr_); + token_list_.clear(); + + while (!is_end(s_itr_)) + { + scan_token(); + + if (token_list_.empty()) + return true; + else if (token_list_.back().is_error()) + return false; + } + + return true; } - - template - inline T root_impl(const T v0, const T v1, int_type_tag) + + inline bool empty() const { - return root_impl(static_cast(v0),static_cast(v1),real_type_tag()); + return token_list_.empty(); } - - template - inline T round_impl(const T v, real_type_tag) + + inline std::size_t size() const { - return ((v < T(0)) ? std::ceil(v - T(0.5)) : std::floor(v + T(0.5))); + return token_list_.size(); } - - template - inline T roundn_impl(const T v0, const T v1, real_type_tag) + + inline void begin() { - const int index = std::max(0, std::min(pow10_size - 1, (int)std::floor(v1))); - const T p10 = T(pow10[index]); - if (v0 < T(0)) - return T(std::ceil ((v0 * p10) - T(0.5)) / p10); - else - return T(std::floor((v0 * p10) + T(0.5)) / p10); + token_itr_ = token_list_.begin(); + store_token_itr_ = token_list_.begin(); } - - template - inline T roundn_impl(const T v0, const T, int_type_tag) + + inline void store() { - return v0; + store_token_itr_ = token_itr_; } - - template - inline T hypot_impl(const T v0, const T v1, real_type_tag) + + inline void restore() { - return std::sqrt((v0 * v0) + (v1 * v1)); + token_itr_ = store_token_itr_; } - - template - inline T hypot_impl(const T v0, const T v1, int_type_tag) + + inline token_t& next_token() { - return static_cast(std::sqrt(static_cast((v0 * v0) + (v1 * v1)))); + if (token_list_.end() != token_itr_) + { + return *token_itr_++; + } + else + return eof_token_; } - - template - inline T atan2_impl(const T v0, const T v1, real_type_tag) + + inline token_t& peek_next_token() { - return std::atan2(v0,v1); + if (token_list_.end() != token_itr_) + { + return *token_itr_; + } + else + return eof_token_; } - - template - inline T atan2_impl(const T, const T, int_type_tag) + + inline token_t& operator[](const std::size_t& index) { - return 0; + if (index < token_list_.size()) + return token_list_[index]; + else + return eof_token_; } - - template - inline T shr_impl(const T v0, const T v1, real_type_tag) + + inline token_t operator[](const std::size_t& index) const { - return v0 * (T(1) / std::pow(T(2),static_cast(static_cast(v1)))); + if (index < token_list_.size()) + return token_list_[index]; + else + return eof_token_; } - - template - inline T shr_impl(const T v0, const T v1, int_type_tag) + + inline bool finished() const { - return v0 >> v1; + return (token_list_.end() == token_itr_); } - - template - inline T shl_impl(const T v0, const T v1, real_type_tag) + + inline void insert_front(token_t::token_type tk_type) { - return v0 * std::pow(T(2),static_cast(static_cast(v1))); + if ( + !token_list_.empty() && + (token_list_.end() != token_itr_) + ) + { + token_t t = *token_itr_; + + t.type = tk_type; + token_itr_ = token_list_.insert(token_itr_,t); + } + } + + inline std::string substr(const std::size_t& begin, const std::size_t& end) + { + const char* begin_itr = ((base_itr_ + begin) < s_end_) ? (base_itr_ + begin) : s_end_; + const char* end_itr = ((base_itr_ + end) < s_end_) ? (base_itr_ + end) : s_end_; + + return std::string(begin_itr,end_itr); + } + + inline std::string remaining() const + { + if (finished()) + return ""; + else if (token_list_.begin() != token_itr_) + return std::string(base_itr_ + (token_itr_ - 1)->position,s_end_); + else + return std::string(base_itr_ + token_itr_->position,s_end_); + } + + private: + + inline bool is_end(const char* itr) + { + return (s_end_ == itr); + } + + inline void skip_whitespace() + { + while (!is_end(s_itr_) && details::is_whitespace(*s_itr_)) + { + ++s_itr_; + } + } + + inline void skip_comments() + { +#ifndef exprtk_disable_comments + // The following comment styles are supported: + // 1. // .... \n + // 2. # .... \n + // 3. /* .... */ + struct test + { + static inline bool comment_start(const char_t c0, const char_t c1, int& mode, int& incr) + { + mode = 0; + if ('#' == c0) { mode = 1; incr = 1; } + else if ('/' == c0) + { + if ('/' == c1) { mode = 1; incr = 2; } + else if ('*' == c1) { mode = 2; incr = 2; } + } + return (0 != mode); + } + + static inline bool comment_end(const char_t c0, const char_t c1, const int mode) + { + return ( + ((1 == mode) && ('\n' == c0)) || + ((2 == mode) && ( '*' == c0) && ('/' == c1)) + ); + } + }; + + int mode = 0; + int increment = 0; + + if (is_end(s_itr_) || is_end((s_itr_ + 1))) + return; + else if (!test::comment_start(*s_itr_,*(s_itr_ + 1),mode,increment)) + return; + + s_itr_ += increment; + + while (!is_end(s_itr_) && !test::comment_end(*s_itr_,*(s_itr_ + 1),mode)) + { + ++s_itr_; + } + + if (!is_end(s_itr_)) + { + s_itr_ += mode; + skip_whitespace(); + skip_comments(); + } +#endif } - - template - inline T shl_impl(const T v0, const T v1, int_type_tag) - { - return v0 << v1; + + inline void scan_token() + { + skip_whitespace(); + + skip_comments(); + + if (is_end(s_itr_)) + { + return; + } + else if (details::is_operator_char(*s_itr_)) + { + scan_operator(); + return; + } + else if (details::is_letter(*s_itr_)) + { + scan_symbol(); + return; + } + else if (details::is_digit((*s_itr_)) || ('.' == (*s_itr_))) + { + scan_number(); + return; + } + else if ('$' == (*s_itr_)) + { + scan_special_function(); + return; + } +#ifndef exprtk_disable_string_capabilities + else if ('\'' == (*s_itr_)) + { + scan_string(); + return; + } +#endif + else if ('~' == (*s_itr_)) + { + token_t t; + t.set_symbol(s_itr_,s_itr_ + 1,base_itr_); + token_list_.push_back(t); + ++s_itr_; + return; + } + else + { + token_t t; + t.set_error(token::e_error,s_itr_,s_itr_ + 2,base_itr_); + token_list_.push_back(t); + ++s_itr_; + } + } + + inline void scan_operator() + { + token_t t; + + const char_t c0 = s_itr_[0]; + + if (!is_end(s_itr_ + 1)) + { + const char_t c1 = s_itr_[1]; + + if (!is_end(s_itr_ + 2)) + { + const char_t c2 = s_itr_[2]; + + if ((c0 == '<') && (c1 == '=') && (c2 == '>')) + { + t.set_operator(token_t::e_swap,s_itr_,s_itr_ + 3,base_itr_); + token_list_.push_back(t); + s_itr_ += 3; + return; + } + } + + token_t::token_type ttype = token_t::e_none; + + if ((c0 == '<') && (c1 == '=')) ttype = token_t::e_lte; + else if ((c0 == '>') && (c1 == '=')) ttype = token_t::e_gte; + else if ((c0 == '<') && (c1 == '>')) ttype = token_t::e_ne; + else if ((c0 == '!') && (c1 == '=')) ttype = token_t::e_ne; + else if ((c0 == '=') && (c1 == '=')) ttype = token_t::e_eq; + else if ((c0 == ':') && (c1 == '=')) ttype = token_t::e_assign; + else if ((c0 == '<') && (c1 == '<')) ttype = token_t::e_shl; + else if ((c0 == '>') && (c1 == '>')) ttype = token_t::e_shr; + else if ((c0 == '+') && (c1 == '=')) ttype = token_t::e_addass; + else if ((c0 == '-') && (c1 == '=')) ttype = token_t::e_subass; + else if ((c0 == '*') && (c1 == '=')) ttype = token_t::e_mulass; + else if ((c0 == '/') && (c1 == '=')) ttype = token_t::e_divass; + else if ((c0 == '%') && (c1 == '=')) ttype = token_t::e_modass; + + if (token_t::e_none != ttype) + { + t.set_operator(ttype,s_itr_,s_itr_ + 2,base_itr_); + token_list_.push_back(t); + s_itr_ += 2; + return; + } + } + + if ('<' == c0) + t.set_operator(token_t::e_lt ,s_itr_,s_itr_ + 1,base_itr_); + else if ('>' == c0) + t.set_operator(token_t::e_gt ,s_itr_,s_itr_ + 1,base_itr_); + else if (';' == c0) + t.set_operator(token_t::e_eof,s_itr_,s_itr_ + 1,base_itr_); + else if ('&' == c0) + t.set_symbol(s_itr_,s_itr_ + 1,base_itr_); + else if ('|' == c0) + t.set_symbol(s_itr_,s_itr_ + 1,base_itr_); + else + t.set_operator(token_t::token_type(c0),s_itr_,s_itr_ + 1,base_itr_); + + token_list_.push_back(t); + ++s_itr_; + } + + inline void scan_symbol() + { + const char* initial_itr = s_itr_; + + while (!is_end(s_itr_)) + { + if (!details::is_letter_or_digit(*s_itr_) && ('_' != (*s_itr_))) + { + if ('.' != (*s_itr_)) + break; + /* + Permit symbols that contain a 'dot' + Allowed : abc.xyz, a123.xyz, abc.123, abc_.xyz a123_.xyz abc._123 + Disallowed: .abc, abc., abc., abc. + */ + if ( + (s_itr_ != initial_itr) && + !is_end(s_itr_ + 1) && + details::is_letter_or_digit(*s_itr_ + 1) && + ('_' != (*s_itr_ + 1)) + ) + break; + } + + ++s_itr_; + } + + token_t t; + t.set_symbol(initial_itr,s_itr_,base_itr_); + token_list_.push_back(t); + } + + inline void scan_number() + { + /* + Attempt to match a valid numeric value in one of the following formats: + 01. 123456 + 02. 123.456 + 03. 123.456e3 + 04. 123.456E3 + 05. 123.456e+3 + 06. 123.456E+3 + 07. 123.456e-3 + 08. 123.456E-3 + 09. .1234 + 10. .1234e3 + 11. .1234E+3 + 12. .1234e+3 + 13. .1234E-3 + 14. .1234e-3 + */ + const char* initial_itr = s_itr_; + bool dot_found = false; + bool e_found = false; + bool post_e_sign_found = false; + bool post_e_digit_found = false; + token_t t; + + while (!is_end(s_itr_)) + { + if ('.' == (*s_itr_)) + { + if (dot_found) + { + t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); + token_list_.push_back(t); + return; + } + + dot_found = true; + ++s_itr_; + + continue; + } + else if (details::imatch('e',(*s_itr_))) + { + const char& c = *(s_itr_ + 1); + + if (is_end(s_itr_ + 1)) + { + t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); + token_list_.push_back(t); + + return; + } + else if ( + ('+' != c) && + ('-' != c) && + !details::is_digit(c) + ) + { + t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); + token_list_.push_back(t); + + return; + } + + e_found = true; + ++s_itr_; + + continue; + } + else if (e_found && details::is_sign(*s_itr_) && !post_e_digit_found) + { + if (post_e_sign_found) + { + t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); + token_list_.push_back(t); + + return; + } + + post_e_sign_found = true; + ++s_itr_; + + continue; + } + else if (e_found && details::is_digit(*s_itr_)) + { + post_e_digit_found = true; + ++s_itr_; + + continue; + } + else if (('.' != (*s_itr_)) && !details::is_digit(*s_itr_)) + break; + else + ++s_itr_; + } + + t.set_numeric(initial_itr,s_itr_,base_itr_); + token_list_.push_back(t); + + return; + } + + inline void scan_special_function() + { + const char* initial_itr = s_itr_; + token_t t; + + // $fdd(x,x,x) = at least 11 chars + if (std::distance(s_itr_,s_end_) < 11) + { + t.set_error(token::e_err_sfunc,initial_itr,s_itr_,base_itr_); + token_list_.push_back(t); + + return; + } + + if ( + !(('$' == *s_itr_) && + (details::imatch ('f',*(s_itr_ + 1))) && + (details::is_digit(*(s_itr_ + 2))) && + (details::is_digit(*(s_itr_ + 3)))) + ) + { + t.set_error(token::e_err_sfunc,initial_itr,s_itr_,base_itr_); + token_list_.push_back(t); + + return; + } + + s_itr_ += 4; // $fdd = 4chars + + t.set_symbol(initial_itr,s_itr_,base_itr_); + token_list_.push_back(t); + + return; + } + +#ifndef exprtk_disable_string_capabilities + inline void scan_string() + { + const char* initial_itr = s_itr_ + 1; + token_t t; + + if (std::distance(s_itr_,s_end_) < 2) + { + t.set_error(token::e_err_string,s_itr_,s_end_,base_itr_); + token_list_.push_back(t); + return; + } + + ++s_itr_; + + bool escaped_found = false; + bool escaped = false; + + while (!is_end(s_itr_)) + { + if (!escaped && ('\\' == *s_itr_)) + { + escaped_found = true; + escaped = true; + ++s_itr_; + + continue; + } + else if (!escaped) + { + if ('\'' == *s_itr_) + break; + } + else if (escaped) + { + if (!is_end(s_itr_) && ('0' == *(s_itr_))) + { + /* + Note: The following 'awkward' conditional is + due to various broken msvc compilers. + */ +#if _MSC_VER == 1600 + const bool within_range = !is_end(s_itr_ + 2) && + !is_end(s_itr_ + 3) ; +#else + const bool within_range = !is_end(s_itr_ + 1) && + !is_end(s_itr_ + 2) && + !is_end(s_itr_ + 3) ; +#endif + + const bool x_seperator = ('x' == *(s_itr_ + 1)) || + ('X' == *(s_itr_ + 1)) ; + + const bool both_digits = details::is_hex_digit(*(s_itr_ + 2)) && + details::is_hex_digit(*(s_itr_ + 3)) ; + + if (!within_range || !x_seperator || !both_digits) + { + t.set_error(token::e_err_string,initial_itr,s_itr_,base_itr_); + token_list_.push_back(t); + + return; + } + else + s_itr_ += 3; + } + + escaped = false; + } + + ++s_itr_; + } + + if (is_end(s_itr_)) + { + t.set_error(token::e_err_string,initial_itr,s_itr_,base_itr_); + token_list_.push_back(t); + + return; + } + + if (!escaped_found) + t.set_string(initial_itr,s_itr_,base_itr_); + else + { + std::string parsed_string(initial_itr,s_itr_); + details::cleanup_escapes(parsed_string); + t.set_string(parsed_string, std::distance(base_itr_,initial_itr)); + } + + token_list_.push_back(t); + ++s_itr_; + + return; } - - template - inline T sgn_impl(const T v, real_type_tag) - { - if (v > T(0)) return T(+1); - else if (v < T(0)) return T(-1); - else return T( 0); +#endif + + private: + + token_list_t token_list_; + token_list_itr_t token_itr_; + token_list_itr_t store_token_itr_; + token_t eof_token_; + const char* base_itr_; + const char* s_itr_; + const char* s_end_; + + friend class token_scanner; + friend class token_modifier; + friend class token_inserter; + friend class token_joiner; + }; + + class helper_interface + { + public: + + virtual void init() { } + virtual void reset() { } + virtual bool result() { return true; } + virtual std::size_t process(generator&) { return 0; } + virtual ~helper_interface() { } + }; + + class token_scanner : public helper_interface + { + public: + + virtual ~token_scanner() + {} + + explicit token_scanner(const std::size_t& stride) + : stride_(stride) + { + if (stride > 4) + { + throw std::invalid_argument("token_scanner() - Invalid stride value"); + } + } + + inline std::size_t process(generator& g) + { + if (g.token_list_.size() >= stride_) + { + for (std::size_t i = 0; i < (g.token_list_.size() - stride_ + 1); ++i) + { + token t; + + switch (stride_) + { + case 1 : + { + const token& t0 = g.token_list_[i]; + + if (!operator()(t0)) + { + return i; + } + } + break; + + case 2 : + { + const token& t0 = g.token_list_[i ]; + const token& t1 = g.token_list_[i + 1]; + + if (!operator()(t0,t1)) + { + return i; + } + } + break; + + case 3 : + { + const token& t0 = g.token_list_[i ]; + const token& t1 = g.token_list_[i + 1]; + const token& t2 = g.token_list_[i + 2]; + + if (!operator()(t0,t1,t2)) + { + return i; + } + } + break; + + case 4 : + { + const token& t0 = g.token_list_[i ]; + const token& t1 = g.token_list_[i + 1]; + const token& t2 = g.token_list_[i + 2]; + const token& t3 = g.token_list_[i + 3]; + + if (!operator()(t0,t1,t2,t3)) + { + return i; + } + } + break; + } + } + } + + return (g.token_list_.size() - stride_ + 1); } - - template - inline T sgn_impl(const T v, int_type_tag) + + virtual bool operator()(const token&) { - if (v > T(0)) return T(+1); - else if (v < T(0)) return T(-1); - else return T( 0); + return false; } - - template - inline T and_impl(const T v0, const T v1, real_type_tag) + + virtual bool operator()(const token&, const token&) { - return (is_true_impl(v0) && is_true_impl(v1)) ? T(1) : T(0); + return false; } - - template - inline T and_impl(const T v0, const T v1, int_type_tag) + + virtual bool operator()(const token&, const token&, const token&) { - return v0 && v1; + return false; } - - template - inline T nand_impl(const T v0, const T v1, real_type_tag) + + virtual bool operator()(const token&, const token&, const token&, const token&) { - return (is_false_impl(v0) || is_false_impl(v1)) ? T(1) : T(0); + return false; } - - template - inline T nand_impl(const T v0, const T v1, int_type_tag) + + private: + + std::size_t stride_; + }; + + class token_modifier : public helper_interface + { + public: + + inline std::size_t process(generator& g) + { + std::size_t changes = 0; + + for (std::size_t i = 0; i < g.token_list_.size(); ++i) + { + if (modify(g.token_list_[i])) changes++; + } + + return changes; + } + + virtual bool modify(token& t) = 0; + }; + + class token_inserter : public helper_interface + { + public: + + explicit token_inserter(const std::size_t& stride) + : stride_(stride) + { + if (stride > 5) + { + throw std::invalid_argument("token_inserter() - Invalid stride value"); + } + } + + inline std::size_t process(generator& g) + { + if (g.token_list_.empty()) + return 0; + else if (g.token_list_.size() < stride_) + return 0; + + std::size_t changes = 0; + + for (std::size_t i = 0; i < (g.token_list_.size() - stride_ + 1); ++i) + { + int insert_index = -1; + token t; + + switch (stride_) + { + case 1 : insert_index = insert(g.token_list_[i],t); + break; + + case 2 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],t); + break; + + case 3 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],g.token_list_[i + 2],t); + break; + + case 4 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],g.token_list_[i + 2],g.token_list_[i + 3],t); + break; + + case 5 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],g.token_list_[i + 2],g.token_list_[i + 3],g.token_list_[i + 4],t); + break; + } + + if ((insert_index >= 0) && (insert_index <= (static_cast(stride_) + 1))) + { + g.token_list_.insert(g.token_list_.begin() + (i + insert_index),t); + changes++; + } + } + + return changes; + } + +#define token_inserter_empty_body \ +{ \ +return -1; \ +} \ + + inline virtual int insert(const token&, token&) + token_inserter_empty_body + + inline virtual int insert(const token&, const token&, token&) + token_inserter_empty_body + + inline virtual int insert(const token&, const token&, const token&, token&) + token_inserter_empty_body + + inline virtual int insert(const token&, const token&, const token&, const token&, token&) + token_inserter_empty_body + + inline virtual int insert(const token&, const token&, const token&, const token&, const token&, token&) + token_inserter_empty_body + +#undef token_inserter_empty_body + + private: + + std::size_t stride_; + }; + + class token_joiner : public helper_interface + { + public: + + token_joiner(const std::size_t& stride) + : stride_(stride) + {} + + inline std::size_t process(generator& g) + { + if (g.token_list_.empty()) + return 0; + + switch (stride_) + { + case 2 : return process_stride_2(g); + case 3 : return process_stride_3(g); + default : return 0; + } + } + + virtual bool join(const token&, const token&, token&) { return false; } + virtual bool join(const token&, const token&, const token&, token&) { return false; } + + private: + + inline std::size_t process_stride_2(generator& g) + { + if (g.token_list_.size() < 2) + return 0; + + std::size_t changes = 0; + + for (std::size_t i = 0; i < (g.token_list_.size() - 1); ++i) + { + token t; + + while (join(g[i],g[i + 1],t)) + { + g.token_list_[i] = t; + + g.token_list_.erase(g.token_list_.begin() + (i + 1)); + + ++changes; + } + } + + return changes; + } + + inline std::size_t process_stride_3(generator& g) + { + if (g.token_list_.size() < 3) + return 0; + + std::size_t changes = 0; + + for (std::size_t i = 0; i < (g.token_list_.size() - 2); ++i) + { + token t; + + while (join(g[i],g[i + 1],g[i + 2],t)) + { + g.token_list_[i] = t; + + g.token_list_.erase(g.token_list_.begin() + (i + 1), + g.token_list_.begin() + (i + 3)); + ++changes; + } + } + + return changes; + } + + std::size_t stride_; + }; + + namespace helper + { + + inline void dump(lexer::generator& generator) + { + for (std::size_t i = 0; i < generator.size(); ++i) + { + lexer::token t = generator[i]; + printf("Token[%02d] @ %03d %6s --> '%s'\n", + static_cast(i), + static_cast(t.position), + t.to_str(t.type).c_str(), + t.value.c_str()); + } + } + + class commutative_inserter : public lexer::token_inserter + { + public: + + using lexer::token_inserter::insert; + + commutative_inserter() + : lexer::token_inserter(2) + {} + + inline void ignore_symbol(const std::string& symbol) + { + ignore_set_.insert(symbol); + } + + inline int insert(const lexer::token& t0, const lexer::token& t1, lexer::token& new_token) + { + bool match = false; + new_token.type = lexer::token::e_mul; + new_token.value = "*"; + new_token.position = t1.position; + + if (t0.type == lexer::token::e_symbol) + { + if (ignore_set_.end() != ignore_set_.find(t0.value)) + { + return -1; + } + else if (!t0.value.empty() && ('$' == t0.value[0])) + { + return -1; + } + } + + if (t1.type == lexer::token::e_symbol) + { + if (ignore_set_.end() != ignore_set_.find(t1.value)) + { + return -1; + } + } + if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_symbol )) match = true; + else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lbracket )) match = true; + else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lcrlbracket)) match = true; + else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lsqrbracket)) match = true; + else if ((t0.type == lexer::token::e_symbol ) && (t1.type == lexer::token::e_number )) match = true; + else if ((t0.type == lexer::token::e_rbracket ) && (t1.type == lexer::token::e_number )) match = true; + else if ((t0.type == lexer::token::e_rcrlbracket) && (t1.type == lexer::token::e_number )) match = true; + else if ((t0.type == lexer::token::e_rsqrbracket) && (t1.type == lexer::token::e_number )) match = true; + else if ((t0.type == lexer::token::e_rbracket ) && (t1.type == lexer::token::e_symbol )) match = true; + else if ((t0.type == lexer::token::e_rcrlbracket) && (t1.type == lexer::token::e_symbol )) match = true; + else if ((t0.type == lexer::token::e_rsqrbracket) && (t1.type == lexer::token::e_symbol )) match = true; + + return (match) ? 1 : -1; + } + + private: + + std::set ignore_set_; + }; + + class operator_joiner : public token_joiner + { + public: + + operator_joiner(const std::size_t& stride) + : token_joiner(stride) + {} + + inline bool join(const lexer::token& t0, const lexer::token& t1, lexer::token& t) + { + // ': =' --> ':=' + if ((t0.type == lexer::token::e_colon) && (t1.type == lexer::token::e_eq)) + { + t.type = lexer::token::e_assign; + t.value = ":="; + t.position = t0.position; + + return true; + } + // '+ =' --> '+=' + else if ((t0.type == lexer::token::e_add) && (t1.type == lexer::token::e_eq)) + { + t.type = lexer::token::e_addass; + t.value = "+="; + t.position = t0.position; + + return true; + } + // '- =' --> '-=' + else if ((t0.type == lexer::token::e_sub) && (t1.type == lexer::token::e_eq)) + { + t.type = lexer::token::e_subass; + t.value = "-="; + t.position = t0.position; + + return true; + } + // '* =' --> '*=' + else if ((t0.type == lexer::token::e_mul) && (t1.type == lexer::token::e_eq)) + { + t.type = lexer::token::e_mulass; + t.value = "*="; + t.position = t0.position; + + return true; + } + // '/ =' --> '/=' + else if ((t0.type == lexer::token::e_div) && (t1.type == lexer::token::e_eq)) + { + t.type = lexer::token::e_divass; + t.value = "/="; + t.position = t0.position; + + return true; + } + // '% =' --> '%=' + else if ((t0.type == lexer::token::e_mod) && (t1.type == lexer::token::e_eq)) + { + t.type = lexer::token::e_modass; + t.value = "%="; + t.position = t0.position; + + return true; + } + // '> =' --> '>=' + else if ((t0.type == lexer::token::e_gt) && (t1.type == lexer::token::e_eq)) + { + t.type = lexer::token::e_gte; + t.value = ">="; + t.position = t0.position; + + return true; + } + // '< =' --> '<=' + else if ((t0.type == lexer::token::e_lt) && (t1.type == lexer::token::e_eq)) + { + t.type = lexer::token::e_lte; + t.value = "<="; + t.position = t0.position; + + return true; + } + // '= =' --> '==' + else if ((t0.type == lexer::token::e_eq) && (t1.type == lexer::token::e_eq)) + { + t.type = lexer::token::e_eq; + t.value = "=="; + t.position = t0.position; + + return true; + } + // '! =' --> '!=' + else if ((static_cast(t0.type) == '!') && (t1.type == lexer::token::e_eq)) + { + t.type = lexer::token::e_ne; + t.value = "!="; + t.position = t0.position; + + return true; + } + // '< >' --> '<>' + else if ((t0.type == lexer::token::e_lt) && (t1.type == lexer::token::e_gt)) + { + t.type = lexer::token::e_ne; + t.value = "<>"; + t.position = t0.position; + + return true; + } + // '<= >' --> '<=>' + else if ((t0.type == lexer::token::e_lte) && (t1.type == lexer::token::e_gt)) + { + t.type = lexer::token::e_swap; + t.value = "<=>"; + t.position = t0.position; + + return true; + } + // '+ -' --> '-' + else if ((t0.type == lexer::token::e_add) && (t1.type == lexer::token::e_sub)) + { + t.type = lexer::token::e_sub; + t.value = "-"; + t.position = t0.position; + + return true; + } + // '- +' --> '-' + else if ((t0.type == lexer::token::e_sub) && (t1.type == lexer::token::e_add)) + { + t.type = lexer::token::e_sub; + t.value = "-"; + t.position = t0.position; + + return true; + } + // '- -' --> '-' + else if ((t0.type == lexer::token::e_sub) && (t1.type == lexer::token::e_sub)) + { + /* + Note: May need to reconsider this when wanting to implement + pre/postfix decrement operator + */ + t.type = lexer::token::e_add; + t.value = "+"; + t.position = t0.position; + + return true; + } + else + return false; + } + + inline bool join(const lexer::token& t0, const lexer::token& t1, const lexer::token& t2, lexer::token& t) + { + // '[ * ]' --> '[*]' + if ( + (t0.type == lexer::token::e_lsqrbracket) && + (t1.type == lexer::token::e_mul ) && + (t2.type == lexer::token::e_rsqrbracket) + ) + { + t.type = lexer::token::e_symbol; + t.value = "[*]"; + t.position = t0.position; + + return true; + } + else + return false; + } + }; + + class bracket_checker : public lexer::token_scanner + { + public: + + using lexer::token_scanner::operator(); + + bracket_checker() + : token_scanner(1), + state_(true) + {} + + bool result() + { + if (!stack_.empty()) + { + lexer::token t; + t.value = stack_.top().first; + t.position = stack_.top().second; + error_token_ = t; + state_ = false; + + return false; + } + else + return state_; + } + + lexer::token error_token() + { + return error_token_; + } + + void reset() + { + // Why? because msvc doesn't support swap properly. + stack_ = std::stack >(); + state_ = true; + error_token_.clear(); + } + + bool operator()(const lexer::token& t) + { + if ( + !t.value.empty() && + (lexer::token::e_string != t.type) && + (lexer::token::e_symbol != t.type) && + exprtk::details::is_bracket(t.value[0]) + ) + { + details::char_t c = t.value[0]; + + if (t.type == lexer::token::e_lbracket) stack_.push(std::make_pair(')',t.position)); + else if (t.type == lexer::token::e_lcrlbracket) stack_.push(std::make_pair('}',t.position)); + else if (t.type == lexer::token::e_lsqrbracket) stack_.push(std::make_pair(']',t.position)); + else if (exprtk::details::is_right_bracket(c)) + { + if (stack_.empty()) + { + state_ = false; + error_token_ = t; + + return false; + } + else if (c != stack_.top().first) + { + state_ = false; + error_token_ = t; + + return false; + } + else + stack_.pop(); + } + } + + return true; + } + + private: + + bool state_; + std::stack > stack_; + lexer::token error_token_; + }; + + class numeric_checker : public lexer::token_scanner + { + public: + + using lexer::token_scanner::operator(); + + numeric_checker() + : token_scanner (1), + current_index_(0) + {} + + bool result() + { + return error_list_.empty(); + } + + void reset() + { + error_list_.clear(); + current_index_ = 0; + } + + bool operator()(const lexer::token& t) + { + if (token::e_number == t.type) + { + double v; + + if (!exprtk::details::string_to_real(t.value,v)) + { + error_list_.push_back(current_index_); + } + } + + ++current_index_; + + return true; + } + + std::size_t error_count() const + { + return error_list_.size(); + } + + std::size_t error_index(const std::size_t& i) + { + if (i < error_list_.size()) + return error_list_[i]; + else + return std::numeric_limits::max(); + } + + void clear_errors() + { + error_list_.clear(); + } + + private: + + std::size_t current_index_; + std::vector error_list_; + }; + + class symbol_replacer : public lexer::token_modifier + { + private: + + typedef std::map,details::ilesscompare> replace_map_t; + + public: + + bool remove(const std::string& target_symbol) + { + replace_map_t::iterator itr = replace_map_.find(target_symbol); + + if (replace_map_.end() == itr) + return false; + + replace_map_.erase(itr); + + return true; + } + + bool add_replace(const std::string& target_symbol, + const std::string& replace_symbol, + const lexer::token::token_type token_type = lexer::token::e_symbol) + { + replace_map_t::iterator itr = replace_map_.find(target_symbol); + + if (replace_map_.end() != itr) + { + return false; + } + + replace_map_[target_symbol] = std::make_pair(replace_symbol,token_type); + + return true; + } + + void clear() + { + replace_map_.clear(); + } + + private: + + bool modify(lexer::token& t) + { + if (lexer::token::e_symbol == t.type) + { + if (replace_map_.empty()) + return false; + + replace_map_t::iterator itr = replace_map_.find(t.value); + + if (replace_map_.end() != itr) + { + t.value = itr->second.first; + t.type = itr->second.second; + + return true; + } + } + + return false; + } + + replace_map_t replace_map_; + }; + + class sequence_validator : public lexer::token_scanner + { + private: + + typedef std::pair token_pair_t; + typedef std::set set_t; + + public: + + using lexer::token_scanner::operator(); + + sequence_validator() + : lexer::token_scanner(2) + { + add_invalid(lexer::token::e_number ,lexer::token::e_number ); + add_invalid(lexer::token::e_string ,lexer::token::e_string ); + add_invalid(lexer::token::e_number ,lexer::token::e_string ); + add_invalid(lexer::token::e_string ,lexer::token::e_number ); + add_invalid(lexer::token::e_string ,lexer::token::e_ternary); + add_invalid_set1(lexer::token::e_assign ); + add_invalid_set1(lexer::token::e_shr ); + add_invalid_set1(lexer::token::e_shl ); + add_invalid_set1(lexer::token::e_lte ); + add_invalid_set1(lexer::token::e_ne ); + add_invalid_set1(lexer::token::e_gte ); + add_invalid_set1(lexer::token::e_lt ); + add_invalid_set1(lexer::token::e_gt ); + add_invalid_set1(lexer::token::e_eq ); + add_invalid_set1(lexer::token::e_comma ); + add_invalid_set1(lexer::token::e_add ); + add_invalid_set1(lexer::token::e_sub ); + add_invalid_set1(lexer::token::e_div ); + add_invalid_set1(lexer::token::e_mul ); + add_invalid_set1(lexer::token::e_mod ); + add_invalid_set1(lexer::token::e_pow ); + add_invalid_set1(lexer::token::e_colon ); + add_invalid_set1(lexer::token::e_ternary); + } + + bool result() + { + return error_list_.empty(); + } + + bool operator()(const lexer::token& t0, const lexer::token& t1) + { + set_t::value_type p = std::make_pair(t0.type,t1.type); + + if (invalid_bracket_check(t0.type,t1.type)) + { + error_list_.push_back(std::make_pair(t0,t1)); + } + else if (invalid_comb_.find(p) != invalid_comb_.end()) + { + error_list_.push_back(std::make_pair(t0,t1)); + } + + return true; + } + + std::size_t error_count() + { + return error_list_.size(); + } + + std::pair error(const std::size_t index) + { + if (index < error_list_.size()) + { + return error_list_[index]; + } + else + { + static const lexer::token error_token; + return std::make_pair(error_token,error_token); + } + } + + void clear_errors() + { + error_list_.clear(); + } + + private: + + void add_invalid(lexer::token::token_type base, lexer::token::token_type t) + { + invalid_comb_.insert(std::make_pair(base,t)); + } + + void add_invalid_set1(lexer::token::token_type t) + { + add_invalid(t,lexer::token::e_assign); + add_invalid(t,lexer::token::e_shr ); + add_invalid(t,lexer::token::e_shl ); + add_invalid(t,lexer::token::e_lte ); + add_invalid(t,lexer::token::e_ne ); + add_invalid(t,lexer::token::e_gte ); + add_invalid(t,lexer::token::e_lt ); + add_invalid(t,lexer::token::e_gt ); + add_invalid(t,lexer::token::e_eq ); + add_invalid(t,lexer::token::e_comma ); + add_invalid(t,lexer::token::e_div ); + add_invalid(t,lexer::token::e_mul ); + add_invalid(t,lexer::token::e_mod ); + add_invalid(t,lexer::token::e_pow ); + add_invalid(t,lexer::token::e_colon ); + } + + bool invalid_bracket_check(lexer::token::token_type base, lexer::token::token_type t) + { + if (details::is_right_bracket(static_cast(base))) + { + switch (t) + { + case lexer::token::e_assign : return (']' != base); + case lexer::token::e_string : return true; + default : return false; + } + } + else if (details::is_left_bracket(static_cast(base))) + { + if (details::is_right_bracket(static_cast(t))) + return false; + else if (details::is_left_bracket(static_cast(t))) + return false; + else + { + switch (t) + { + case lexer::token::e_number : return false; + case lexer::token::e_symbol : return false; + case lexer::token::e_string : return false; + case lexer::token::e_add : return false; + case lexer::token::e_sub : return false; + case lexer::token::e_colon : return false; + case lexer::token::e_ternary : return false; + default : return true; + } + } + } + else if (details::is_right_bracket(static_cast(t))) + { + switch (base) + { + case lexer::token::e_number : return false; + case lexer::token::e_symbol : return false; + case lexer::token::e_string : return false; + case lexer::token::e_eof : return false; + case lexer::token::e_colon : return false; + case lexer::token::e_ternary : return false; + default : return true; + } + } + else if (details::is_left_bracket(static_cast(t))) + { + switch (base) + { + case lexer::token::e_rbracket : return true; + case lexer::token::e_rsqrbracket : return true; + case lexer::token::e_rcrlbracket : return true; + default : return false; + } + } + + return false; + } + + set_t invalid_comb_; + std::vector > error_list_; + }; + + struct helper_assembly + { + inline bool register_scanner(lexer::token_scanner* scanner) + { + if (token_scanner_list.end() != std::find(token_scanner_list.begin(), + token_scanner_list.end(), + scanner)) + { + return false; + } + + token_scanner_list.push_back(scanner); + + return true; + } + + inline bool register_modifier(lexer::token_modifier* modifier) + { + if (token_modifier_list.end() != std::find(token_modifier_list.begin(), + token_modifier_list.end(), + modifier)) + { + return false; + } + + token_modifier_list.push_back(modifier); + + return true; + } + + inline bool register_joiner(lexer::token_joiner* joiner) + { + if (token_joiner_list.end() != std::find(token_joiner_list.begin(), + token_joiner_list.end(), + joiner)) + { + return false; + } + + token_joiner_list.push_back(joiner); + + return true; + } + + inline bool register_inserter(lexer::token_inserter* inserter) + { + if (token_inserter_list.end() != std::find(token_inserter_list.begin(), + token_inserter_list.end(), + inserter)) + { + return false; + } + + token_inserter_list.push_back(inserter); + + return true; + } + + inline bool run_modifiers(lexer::generator& g) + { + error_token_modifier = reinterpret_cast(0); + + for (std::size_t i = 0; i < token_modifier_list.size(); ++i) + { + lexer::token_modifier& modifier = (*token_modifier_list[i]); + + modifier.reset(); + modifier.process(g); + + if (!modifier.result()) + { + error_token_modifier = token_modifier_list[i]; + + return false; + } + } + + return true; + } + + inline bool run_joiners(lexer::generator& g) + { + error_token_joiner = reinterpret_cast(0); + + for (std::size_t i = 0; i < token_joiner_list.size(); ++i) + { + lexer::token_joiner& joiner = (*token_joiner_list[i]); + + joiner.reset(); + joiner.process(g); + + if (!joiner.result()) + { + error_token_joiner = token_joiner_list[i]; + + return false; + } + } + + return true; + } + + inline bool run_inserters(lexer::generator& g) + { + error_token_inserter = reinterpret_cast(0); + + for (std::size_t i = 0; i < token_inserter_list.size(); ++i) + { + lexer::token_inserter& inserter = (*token_inserter_list[i]); + + inserter.reset(); + inserter.process(g); + + if (!inserter.result()) + { + error_token_inserter = token_inserter_list[i]; + + return false; + } + } + + return true; + } + + inline bool run_scanners(lexer::generator& g) + { + error_token_scanner = reinterpret_cast(0); + + for (std::size_t i = 0; i < token_scanner_list.size(); ++i) + { + lexer::token_scanner& scanner = (*token_scanner_list[i]); + + scanner.reset(); + scanner.process(g); + + if (!scanner.result()) + { + error_token_scanner = token_scanner_list[i]; + + return false; + } + } + + return true; + } + + std::vector token_scanner_list; + std::vector token_modifier_list; + std::vector token_joiner_list; + std::vector token_inserter_list; + + lexer::token_scanner* error_token_scanner; + lexer::token_modifier* error_token_modifier; + lexer::token_joiner* error_token_joiner; + lexer::token_inserter* error_token_inserter; + }; + } + + class parser_helper + { + public: + + typedef token token_t; + typedef generator generator_t; + + inline bool init(const std::string& str) { - return !(v0 && v1); + if (!lexer_.process(str)) + { + return false; + } + + lexer_.begin(); + + next_token(); + + return true; } - - template - inline T or_impl(const T v0, const T v1, real_type_tag) + + inline generator_t& lexer() { - return (is_true_impl(v0) || is_true_impl(v1)) ? T(1) : T(0); + return lexer_; } - - template - inline T or_impl(const T v0, const T v1, int_type_tag) + + inline const generator_t& lexer() const { - return (v0 || v1); + return lexer_; } - - template - inline T nor_impl(const T v0, const T v1, real_type_tag) + + inline void store_token() { - return (is_false_impl(v0) && is_false_impl(v1)) ? T(1) : T(0); + lexer_.store(); + store_current_token_ = current_token_; } - - template - inline T nor_impl(const T v0, const T v1, int_type_tag) + + inline void restore_token() { - return !(v0 || v1); + lexer_.restore(); + current_token_ = store_current_token_; } - - template - inline T xor_impl(const T v0, const T v1, real_type_tag) + + inline void next_token() { - return (is_false_impl(v0) != is_false_impl(v1)) ? T(1) : T(0); + current_token_ = lexer_.next_token(); } - - template - inline T xor_impl(const T v0, const T v1, int_type_tag) + + inline const token_t& current_token() const { - return v0 ^ v1; + return current_token_; } - - template - inline T xnor_impl(const T v0, const T v1, real_type_tag) + + enum token_advance_mode { - const bool v0_true = is_true_impl(v0); - const bool v1_true = is_true_impl(v1); - if ((v0_true && v1_true) || (!v0_true && !v1_true)) - return T(1); - else - return T(0); - } - - template - inline T xnor_impl(const T v0, const T v1, int_type_tag) + e_hold = 0, + e_advance = 1 + }; + + inline void advance_token(const token_advance_mode mode) + { + if (e_advance == mode) + { + next_token(); + } + } + + inline bool token_is(const token_t::token_type& ttype, const token_advance_mode mode = e_advance) + { + if (current_token().type != ttype) + { + return false; + } + + advance_token(mode); + + return true; + } + + inline bool token_is(const token_t::token_type& ttype, + const std::string& value, + const token_advance_mode mode = e_advance) + { + if ( + (current_token().type != ttype) || + !exprtk::details::imatch(value,current_token().value) + ) + { + return false; + } + + advance_token(mode); + + return true; + } + + inline bool token_is_then_assign(const token_t::token_type& ttype, + std::string& token, + const token_advance_mode mode = e_advance) + { + if (current_token_.type != ttype) + { + return false; + } + + token = current_token_.value; + + advance_token(mode); + + return true; + } + + template class Container> + inline bool token_is_then_assign(const token_t::token_type& ttype, + Container& token_list, + const token_advance_mode mode = e_advance) + { + if (current_token_.type != ttype) + { + return false; + } + + token_list.push_back(current_token_.value); + + advance_token(mode); + + return true; + } + + inline bool peek_token_is(const token_t::token_type& ttype) + { + return (lexer_.peek_next_token().type == ttype); + } + + inline bool peek_token_is(const std::string& s) + { + return (exprtk::details::imatch(lexer_.peek_next_token().value,s)); + } + + private: + + generator_t lexer_; + token_t current_token_; + token_t store_current_token_; + }; + } + + template + class vector_view + { + public: + + typedef T* data_ptr_t; + + vector_view(data_ptr_t data, const std::size_t& size) + : size_(size), + data_(data), + data_ref_(0) + {} + + vector_view(const vector_view& vv) + : size_(vv.size_), + data_(vv.data_), + data_ref_(0) + {} + + inline void rebase(data_ptr_t data) + { + data_ = data; + + if (!data_ref_.empty()) + { + for (std::size_t i = 0; i < data_ref_.size(); ++i) + { + (*data_ref_[i]) = data; + } + } + } + + inline data_ptr_t data() const + { + return data_; + } + + inline std::size_t size() const + { + return size_; + } + + inline const T& operator[](const std::size_t index) const + { + return data_[index]; + } + + inline T& operator[](const std::size_t index) + { + return data_[index]; + } + + void set_ref(data_ptr_t* data_ref) + { + data_ref_.push_back(data_ref); + } + + private: + + std::size_t size_; + data_ptr_t data_; + std::vector data_ref_; + }; + + template + inline vector_view make_vector_view(T* data, + const std::size_t size, const std::size_t offset = 0) + { + return vector_view(data + offset,size); + } + + template + inline vector_view make_vector_view(std::vector& v, + const std::size_t size, const std::size_t offset = 0) + { + return vector_view(v.data() + offset,size); + } + + template class results_context; + + template + struct type_store + { + enum store_type + { + e_unknown, + e_scalar, + e_vector, + e_string + }; + + type_store() + : size(0), + data(0), + type(e_unknown) + {} + + std::size_t size; + void* data; + store_type type; + + class parameter_list + { + public: + + parameter_list(std::vector& pl) + : parameter_list_(pl) + {} + + inline bool empty() const { - const bool v0_true = is_true_impl(v0); - const bool v1_true = is_true_impl(v1); - if ((v0_true && v1_true) || (!v0_true && !v1_true)) - return T(1); - else - return T(0); + return parameter_list_.empty(); } - - template - inline T erf_impl(T v, real_type_tag) - { - #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) - // Credits: Abramowitz & Stegun Equations 7.1.25-28 - const T t = T(1) / (T(1) + T(0.5) * abs_impl(v,real_type_tag())); - static const T c[] = { - T( 1.26551223), T(1.00002368), - T( 0.37409196), T(0.09678418), - T(-0.18628806), T(0.27886807), - T(-1.13520398), T(1.48851587), - T(-0.82215223), T(0.17087277) - }; - T result = T(1) - t * std::exp((-v * v) - - c[0] + t * (c[1] + t * - (c[2] + t * (c[3] + t * - (c[4] + t * (c[5] + t * - (c[6] + t * (c[7] + t * - (c[8] + t * (c[9])))))))))); - return (v >= T(0)) ? result : -result; - #else - return ::erf(v); - #endif + + inline std::size_t size() const + { + return parameter_list_.size(); } - - template - inline T erf_impl(T v, int_type_tag) + + inline type_store& operator[](const std::size_t& index) { - return erf_impl(static_cast(v),real_type_tag()); + return parameter_list_[index]; } - - template - inline T erfc_impl(T v, real_type_tag) + + inline const type_store& operator[](const std::size_t& index) const { - #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) - return T(1) - erf_impl(v,real_type_tag()); - #else - return ::erfc(v); - #endif + return parameter_list_[index]; } - - template - inline T erfc_impl(T v, int_type_tag) + + inline type_store& front() { - return erfc_impl(static_cast(v),real_type_tag()); + return parameter_list_[0]; } - - template - inline T ncdf_impl(T v, real_type_tag) + + inline const type_store& front() const { - T cnd = T(0.5) * (T(1) + erf_impl( - abs_impl(v,real_type_tag()) / - T(numeric::constant::sqrt2),real_type_tag())); - return (v < T(0)) ? (T(1) - cnd) : cnd; + return parameter_list_[0]; } - - template - inline T ncdf_impl(T v, int_type_tag) + + inline type_store& back() { - return ncdf_impl(static_cast(v),real_type_tag()); + return parameter_list_.back(); } - - template - inline T sinc_impl(T v, real_type_tag) + + inline const type_store& back() const { - if (std::abs(v) >= std::numeric_limits::epsilon()) - return(std::sin(v) / v); - else - return T(1); + return parameter_list_.back(); } - - template - inline T sinc_impl(T v, int_type_tag) + + private: + + std::vector& parameter_list_; + + friend class results_context; + }; + + template + struct type_view + { + typedef type_store type_store_t; + typedef ViewType value_t; + + type_view(type_store_t& ts) + : ts_(ts), + data_(reinterpret_cast(ts_.data)) + {} + + inline std::size_t size() const { - return sinc_impl(static_cast(v),real_type_tag()); + return ts_.size; } - - template inline T acos_impl(const T v, real_type_tag) { return std::acos (v); } - template inline T acosh_impl(const T v, real_type_tag) { return std::log(v + std::sqrt((v * v) - T(1))); } - template inline T asin_impl(const T v, real_type_tag) { return std::asin (v); } - template inline T asinh_impl(const T v, real_type_tag) { return std::log(v + std::sqrt((v * v) + T(1))); } - template inline T atan_impl(const T v, real_type_tag) { return std::atan (v); } - template inline T atanh_impl(const T v, real_type_tag) { return (std::log(T(1) + v) - log(T(1) - v)) / T(2); } - template inline T ceil_impl(const T v, real_type_tag) { return std::ceil (v); } - template inline T cos_impl(const T v, real_type_tag) { return std::cos (v); } - template inline T cosh_impl(const T v, real_type_tag) { return std::cosh (v); } - template inline T exp_impl(const T v, real_type_tag) { return std::exp (v); } - template inline T floor_impl(const T v, real_type_tag) { return std::floor(v); } - template inline T log_impl(const T v, real_type_tag) { return std::log (v); } - template inline T log10_impl(const T v, real_type_tag) { return std::log10(v); } - template inline T log2_impl(const T v, real_type_tag) { return std::log(v)/T(numeric::constant::log2); } - template inline T neg_impl(const T v, real_type_tag) { return -v; } - template inline T pos_impl(const T v, real_type_tag) { return +v; } - template inline T sin_impl(const T v, real_type_tag) { return std::sin (v); } - template inline T sinh_impl(const T v, real_type_tag) { return std::sinh (v); } - template inline T sqrt_impl(const T v, real_type_tag) { return std::sqrt (v); } - template inline T tan_impl(const T v, real_type_tag) { return std::tan (v); } - template inline T tanh_impl(const T v, real_type_tag) { return std::tanh (v); } - template inline T cot_impl(const T v, real_type_tag) { return T(1) / std::tan(v); } - template inline T sec_impl(const T v, real_type_tag) { return T(1) / std::cos(v); } - template inline T csc_impl(const T v, real_type_tag) { return T(1) / std::sin(v); } - template inline T r2d_impl(const T v, real_type_tag) { return (v * T(numeric::constant::_180_pi)); } - template inline T d2r_impl(const T v, real_type_tag) { return (v * T(numeric::constant::pi_180)); } - template inline T d2g_impl(const T v, real_type_tag) { return (v * T(20.0/9.0)); } - template inline T g2d_impl(const T v, real_type_tag) { return (v * T(9.0/20.0)); } - template inline T notl_impl(const T v, real_type_tag) { return (std::not_equal_to()(T(0),v) ? T(0) : T(1)); } - template inline T frac_impl(const T v, real_type_tag) { return (v - static_cast(v)); } - template inline T trunc_impl(const T v, real_type_tag) { return T(static_cast(v)); } - - template inline T abs_impl(const T v, int_type_tag) { return ((v >= T(0)) ? v : -v); } - template inline T exp_impl(const T v, int_type_tag) { return std::exp (v); } - template inline T log_impl(const T v, int_type_tag) { return std::log (v); } - template inline T log10_impl(const T v, int_type_tag) { return std::log10(v); } - template inline T log2_impl(const T v, int_type_tag) { return std::log(v)/T(numeric::constant::log2); } - template inline T neg_impl(const T v, int_type_tag) { return -v; } - template inline T pos_impl(const T v, int_type_tag) { return +v; } - template inline T ceil_impl(const T v, int_type_tag) { return v; } - template inline T floor_impl(const T v, int_type_tag) { return v; } - template inline T round_impl(const T v, int_type_tag) { return v; } - template inline T notl_impl(const T v, int_type_tag) { return !v; } - template inline T sqrt_impl(const T v, int_type_tag) { return std::sqrt (v); } - template inline T frac_impl(const T , int_type_tag) { return T(0); } - template inline T trunc_impl(const T v, int_type_tag) { return v; } - template inline T acos_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T acosh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T asin_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T asinh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T atan_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T atanh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T cos_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T cosh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T sin_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T sinh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T tan_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T tanh_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T cot_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T sec_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - template inline T csc_impl(const T , int_type_tag) { return std::numeric_limits::quiet_NaN(); } - - template - inline bool is_integer_impl(const T& v, real_type_tag) + + inline value_t& operator[](const std::size_t& i) { - return std::equal_to()(T(0),std::fmod(v,T(1))); + return data_[i]; } - - template - inline bool is_integer_impl(const T&, int_type_tag) + + inline const value_t& operator[](const std::size_t& i) const { - return true; + return data_[i]; } - } - - template - struct numeric_info { enum { length = 0, size = 32, bound_length = 0, min_exp = 0, max_exp = 0 }; }; - - template<> struct numeric_info { enum { length = 10, size = 16, bound_length = 9}; }; - template<> struct numeric_info { enum { min_exp = -38, max_exp = +38}; }; - template<> struct numeric_info { enum { min_exp = -308, max_exp = +308}; }; - template<> struct numeric_info { enum { min_exp = -308, max_exp = +308}; }; - - template - inline int to_int32(const T v) - { - typename details::number_type::type num_type; - return to_int32_impl(v,num_type); - } - - template - inline long long int to_int64(const T v) - { - typename details::number_type::type num_type; - return to_int64_impl(v,num_type); - } - - template - inline bool is_nan(const T v) - { - typename details::number_type::type num_type; - return is_nan_impl(v,num_type); - } - - template - inline T min(const T v0, const T v1) - { - typename details::number_type::type num_type; - return min_impl(v0,v1,num_type); - } - - template - inline T max(const T v0, const T v1) - { - typename details::number_type::type num_type; - return max_impl(v0,v1,num_type); - } - - template - inline T equal(const T v0, const T v1) - { - typename details::number_type::type num_type; - return equal_impl(v0,v1,num_type); - } - - template - inline T nequal(const T v0, const T v1) - { - typename details::number_type::type num_type; - return nequal_impl(v0,v1,num_type); - } - - template - inline T modulus(const T v0, const T v1) - { - typename details::number_type::type num_type; - return modulus_impl(v0,v1,num_type); - } - - template - inline T pow(const T v0, const T v1) - { - typename details::number_type::type num_type; - return pow_impl(v0,v1,num_type); - } - - template - inline T logn(const T v0, const T v1) - { - typename details::number_type::type num_type; - return logn_impl(v0,v1,num_type); - } - - template - inline T root(const T v0, const T v1) - { - typename details::number_type::type num_type; - return root_impl(v0,v1,num_type); - } - - template - inline T roundn(const T v0, const T v1) - { - typename details::number_type::type num_type; - return roundn_impl(v0,v1,num_type); - } - - template - inline T hypot(const T v0, const T v1) - { - typename details::number_type::type num_type; - return hypot_impl(v0,v1,num_type); - } - - template - inline T atan2(const T v0, const T v1) - { - typename details::number_type::type num_type; - return atan2_impl(v0,v1,num_type); - } - - template - inline T shr(const T v0, const T v1) - { - typename details::number_type::type num_type; - return shr_impl(v0,v1,num_type); - } - - template - inline T shl(const T v0, const T v1) - { - typename details::number_type::type num_type; - return shl_impl(v0,v1,num_type); - } - - template - inline T and_opr(const T v0, const T v1) - { - typename details::number_type::type num_type; - return and_impl(v0,v1,num_type); - } - - template - inline T nand_opr(const T v0, const T v1) - { - typename details::number_type::type num_type; - return nand_impl(v0,v1,num_type); - } - - template - inline T or_opr(const T v0, const T v1) - { - typename details::number_type::type num_type; - return or_impl(v0,v1,num_type); - } - - template - inline T nor_opr(const T v0, const T v1) - { - typename details::number_type::type num_type; - return nor_impl(v0,v1,num_type); - } - - template - inline T xor_opr(const T v0, const T v1) - { - typename details::number_type::type num_type; - return xor_impl(v0,v1,num_type); - } - - template - inline T xnor_opr(const T v0, const T v1) - { - typename details::number_type::type num_type; - return xnor_impl(v0,v1,num_type); - } - - template - inline bool is_integer(const T v) - { - typename details::number_type::type num_type; - return is_integer_impl(v,num_type); - } - - template - struct fast_exp - { - static inline T result(T v) + + inline const value_t* begin() const { return data_; } + inline value_t* begin() { return data_; } + + inline const value_t* end() const { - unsigned int k = N; - T l = T(1); - - while (k) - { - if (k & 1) - { - l *= v; - --k; - } - - v *= v; - k >>= 1; - } - - return l; + return static_cast(data_ + ts_.size); } - }; - - template struct fast_exp { static inline T result(T v) { T v_5 = fast_exp::result(v); return v_5 * v_5; } }; - template struct fast_exp { static inline T result(T v) { return fast_exp::result(v) * v; } }; - template struct fast_exp { static inline T result(T v) { T v_4 = fast_exp::result(v); return v_4 * v_4; } }; - template struct fast_exp { static inline T result(T v) { return fast_exp::result(v) * v; } }; - template struct fast_exp { static inline T result(T v) { T v_3 = fast_exp::result(v); return v_3 * v_3; } }; - template struct fast_exp { static inline T result(T v) { return fast_exp::result(v) * v; } }; - template struct fast_exp { static inline T result(T v) { T v_2 = v * v; return v_2 * v_2; } }; - template struct fast_exp { static inline T result(T v) { return v * v * v; } }; - template struct fast_exp { static inline T result(T v) { return v * v; } }; - template struct fast_exp { static inline T result(T v) { return v; } }; - template struct fast_exp { static inline T result(T ) { return T(1); } }; - - #define exprtk_define_unary_function(FunctionName) \ - template \ - inline T FunctionName (const T v) \ - { \ - typename details::number_type::type num_type; \ - return FunctionName##_impl(v,num_type); \ - } \ - - exprtk_define_unary_function(abs ) - exprtk_define_unary_function(acos ) - exprtk_define_unary_function(acosh) - exprtk_define_unary_function(asin ) - exprtk_define_unary_function(asinh) - exprtk_define_unary_function(atan ) - exprtk_define_unary_function(atanh) - exprtk_define_unary_function(ceil ) - exprtk_define_unary_function(cos ) - exprtk_define_unary_function(cosh ) - exprtk_define_unary_function(exp ) - exprtk_define_unary_function(expm1) - exprtk_define_unary_function(floor) - exprtk_define_unary_function(log ) - exprtk_define_unary_function(log10) - exprtk_define_unary_function(log2 ) - exprtk_define_unary_function(log1p) - exprtk_define_unary_function(neg ) - exprtk_define_unary_function(pos ) - exprtk_define_unary_function(round) - exprtk_define_unary_function(sin ) - exprtk_define_unary_function(sinc ) - exprtk_define_unary_function(sinh ) - exprtk_define_unary_function(sqrt ) - exprtk_define_unary_function(tan ) - exprtk_define_unary_function(tanh ) - exprtk_define_unary_function(cot ) - exprtk_define_unary_function(sec ) - exprtk_define_unary_function(csc ) - exprtk_define_unary_function(r2d ) - exprtk_define_unary_function(d2r ) - exprtk_define_unary_function(d2g ) - exprtk_define_unary_function(g2d ) - exprtk_define_unary_function(notl ) - exprtk_define_unary_function(sgn ) - exprtk_define_unary_function(erf ) - exprtk_define_unary_function(erfc ) - exprtk_define_unary_function(ncdf ) - exprtk_define_unary_function(frac ) - exprtk_define_unary_function(trunc) - #undef exprtk_define_unary_function - } - - template - inline T compute_pow10(T d, const int exponent) - { - static const double fract10[] = - { - 0.0, - 1.0E+001, 1.0E+002, 1.0E+003, 1.0E+004, 1.0E+005, 1.0E+006, 1.0E+007, 1.0E+008, 1.0E+009, 1.0E+010, - 1.0E+011, 1.0E+012, 1.0E+013, 1.0E+014, 1.0E+015, 1.0E+016, 1.0E+017, 1.0E+018, 1.0E+019, 1.0E+020, - 1.0E+021, 1.0E+022, 1.0E+023, 1.0E+024, 1.0E+025, 1.0E+026, 1.0E+027, 1.0E+028, 1.0E+029, 1.0E+030, - 1.0E+031, 1.0E+032, 1.0E+033, 1.0E+034, 1.0E+035, 1.0E+036, 1.0E+037, 1.0E+038, 1.0E+039, 1.0E+040, - 1.0E+041, 1.0E+042, 1.0E+043, 1.0E+044, 1.0E+045, 1.0E+046, 1.0E+047, 1.0E+048, 1.0E+049, 1.0E+050, - 1.0E+051, 1.0E+052, 1.0E+053, 1.0E+054, 1.0E+055, 1.0E+056, 1.0E+057, 1.0E+058, 1.0E+059, 1.0E+060, - 1.0E+061, 1.0E+062, 1.0E+063, 1.0E+064, 1.0E+065, 1.0E+066, 1.0E+067, 1.0E+068, 1.0E+069, 1.0E+070, - 1.0E+071, 1.0E+072, 1.0E+073, 1.0E+074, 1.0E+075, 1.0E+076, 1.0E+077, 1.0E+078, 1.0E+079, 1.0E+080, - 1.0E+081, 1.0E+082, 1.0E+083, 1.0E+084, 1.0E+085, 1.0E+086, 1.0E+087, 1.0E+088, 1.0E+089, 1.0E+090, - 1.0E+091, 1.0E+092, 1.0E+093, 1.0E+094, 1.0E+095, 1.0E+096, 1.0E+097, 1.0E+098, 1.0E+099, 1.0E+100, - 1.0E+101, 1.0E+102, 1.0E+103, 1.0E+104, 1.0E+105, 1.0E+106, 1.0E+107, 1.0E+108, 1.0E+109, 1.0E+110, - 1.0E+111, 1.0E+112, 1.0E+113, 1.0E+114, 1.0E+115, 1.0E+116, 1.0E+117, 1.0E+118, 1.0E+119, 1.0E+120, - 1.0E+121, 1.0E+122, 1.0E+123, 1.0E+124, 1.0E+125, 1.0E+126, 1.0E+127, 1.0E+128, 1.0E+129, 1.0E+130, - 1.0E+131, 1.0E+132, 1.0E+133, 1.0E+134, 1.0E+135, 1.0E+136, 1.0E+137, 1.0E+138, 1.0E+139, 1.0E+140, - 1.0E+141, 1.0E+142, 1.0E+143, 1.0E+144, 1.0E+145, 1.0E+146, 1.0E+147, 1.0E+148, 1.0E+149, 1.0E+150, - 1.0E+151, 1.0E+152, 1.0E+153, 1.0E+154, 1.0E+155, 1.0E+156, 1.0E+157, 1.0E+158, 1.0E+159, 1.0E+160, - 1.0E+161, 1.0E+162, 1.0E+163, 1.0E+164, 1.0E+165, 1.0E+166, 1.0E+167, 1.0E+168, 1.0E+169, 1.0E+170, - 1.0E+171, 1.0E+172, 1.0E+173, 1.0E+174, 1.0E+175, 1.0E+176, 1.0E+177, 1.0E+178, 1.0E+179, 1.0E+180, - 1.0E+181, 1.0E+182, 1.0E+183, 1.0E+184, 1.0E+185, 1.0E+186, 1.0E+187, 1.0E+188, 1.0E+189, 1.0E+190, - 1.0E+191, 1.0E+192, 1.0E+193, 1.0E+194, 1.0E+195, 1.0E+196, 1.0E+197, 1.0E+198, 1.0E+199, 1.0E+200, - 1.0E+201, 1.0E+202, 1.0E+203, 1.0E+204, 1.0E+205, 1.0E+206, 1.0E+207, 1.0E+208, 1.0E+209, 1.0E+210, - 1.0E+211, 1.0E+212, 1.0E+213, 1.0E+214, 1.0E+215, 1.0E+216, 1.0E+217, 1.0E+218, 1.0E+219, 1.0E+220, - 1.0E+221, 1.0E+222, 1.0E+223, 1.0E+224, 1.0E+225, 1.0E+226, 1.0E+227, 1.0E+228, 1.0E+229, 1.0E+230, - 1.0E+231, 1.0E+232, 1.0E+233, 1.0E+234, 1.0E+235, 1.0E+236, 1.0E+237, 1.0E+238, 1.0E+239, 1.0E+240, - 1.0E+241, 1.0E+242, 1.0E+243, 1.0E+244, 1.0E+245, 1.0E+246, 1.0E+247, 1.0E+248, 1.0E+249, 1.0E+250, - 1.0E+251, 1.0E+252, 1.0E+253, 1.0E+254, 1.0E+255, 1.0E+256, 1.0E+257, 1.0E+258, 1.0E+259, 1.0E+260, - 1.0E+261, 1.0E+262, 1.0E+263, 1.0E+264, 1.0E+265, 1.0E+266, 1.0E+267, 1.0E+268, 1.0E+269, 1.0E+270, - 1.0E+271, 1.0E+272, 1.0E+273, 1.0E+274, 1.0E+275, 1.0E+276, 1.0E+277, 1.0E+278, 1.0E+279, 1.0E+280, - 1.0E+281, 1.0E+282, 1.0E+283, 1.0E+284, 1.0E+285, 1.0E+286, 1.0E+287, 1.0E+288, 1.0E+289, 1.0E+290, - 1.0E+291, 1.0E+292, 1.0E+293, 1.0E+294, 1.0E+295, 1.0E+296, 1.0E+297, 1.0E+298, 1.0E+299, 1.0E+300, - 1.0E+301, 1.0E+302, 1.0E+303, 1.0E+304, 1.0E+305, 1.0E+306, 1.0E+307, 1.0E+308 - }; - - static const int fract10_size = static_cast(sizeof(fract10) / sizeof(double)); - - const int e = std::abs(exponent); - - if (exponent >= std::numeric_limits::min_exponent10) - { - if (e < fract10_size) + + inline value_t* end() { - if (exponent > 0) - return T(d * fract10[e]); - else - return T(d / fract10[e]); + return static_cast(data_ + ts_.size); } + + type_store_t& ts_; + value_t* data_; + }; + + typedef type_view vector_view; + typedef type_view string_view; + + struct scalar_view + { + typedef type_store type_store_t; + typedef T value_t; + + scalar_view(type_store_t& ts) + : v_(*reinterpret_cast(ts.data)) + {} + + scalar_view(const type_store_t& ts) + : v_(*reinterpret_cast(const_cast(ts).data)) + {} + + inline value_t& operator()() + { + return v_; + } + + inline const value_t& operator()() const + { + return v_; + } + + template + inline bool to_int(IntType& i) const + { + if (!exprtk::details::numeric::is_integer(v_)) + return false; + + i = static_cast(v_); + + return true; + } + + template + inline bool to_uint(UIntType& u) const + { + if (v_ < T(0)) + return false; + else if (!exprtk::details::numeric::is_integer(v_)) + return false; + + u = static_cast(v_); + + return true; + } + + T& v_; + }; + }; + + template + inline std::string to_str(const StringView& view) + { + return std::string(view.begin(),view.size()); + } + + namespace details + { + template class return_node; + template class return_envelope_node; + } + + template + class results_context + { + public: + + typedef type_store type_store_t; + + results_context() + : results_available_(false) + {} + + inline std::size_t count() const + { + if (results_available_) + return parameter_list_.size(); else - return T(d * std::pow(10.0, 10.0 * exponent)); - } - else - { - d /= T(fract10[ -std::numeric_limits::min_exponent10]); - return T(d / fract10[-exponent + std::numeric_limits::min_exponent10]); - } - } - - template - inline bool string_to_type_converter_impl_ref(Iterator& itr, const Iterator end, T& result) - { - if (itr == end) - return false; - - bool negative = ('-' == (*itr)); - - if (negative || ('+' == (*itr))) - { - if (end == ++itr) - return false; - } - - while ((end != itr) && ('0' == (*itr))) ++itr; - - bool return_result = true; - unsigned int digit = 0; - const std::size_t length = std::distance(itr,end); - - if (length <= 4) - { - switch (length) - { - #ifdef exprtk_use_lut - - #define exprtk_process_digit \ - if ((digit = details::digit_table[(int)*itr++]) < 10) result = result * 10 + (digit); else { return_result = false; break; } - - #else - #define exprtk_process_digit \ - if ((digit = (*itr++ - '0')) < 10) result = result * 10 + (digit); else { return_result = false; break; } - - #endif - - case 4 : exprtk_process_digit - case 3 : exprtk_process_digit - case 2 : exprtk_process_digit - case 1 : if ((digit = (*itr - '0'))>= 10) { digit = 0; return_result = false; } - - #undef exprtk_process_digit + return 0; + } + + inline type_store_t& operator[](const std::size_t& index) + { + return parameter_list_[index]; + } + + inline const type_store_t& operator[](const std::size_t& index) const + { + return parameter_list_[index]; + } + + private: + + inline void clear() + { + results_available_ = false; + } + + typedef std::vector ts_list_t; + typedef typename type_store_t::parameter_list parameter_list_t; + + inline void assign(const parameter_list_t& pl) + { + parameter_list_ = pl.parameter_list_; + results_available_ = true; + } + + bool results_available_; + ts_list_t parameter_list_; + + friend class details::return_node; + friend class details::return_envelope_node; + }; + + namespace details + { + enum operator_type + { + e_default , e_null , e_add , e_sub , + e_mul , e_div , e_mod , e_pow , + e_atan2 , e_min , e_max , e_avg , + e_sum , e_prod , e_lt , e_lte , + e_eq , e_equal , e_ne , e_nequal , + e_gte , e_gt , e_and , e_nand , + e_or , e_nor , e_xor , e_xnor , + e_mand , e_mor , e_scand , e_scor , + e_shr , e_shl , e_abs , e_acos , + e_acosh , e_asin , e_asinh , e_atan , + e_atanh , e_ceil , e_cos , e_cosh , + e_exp , e_expm1 , e_floor , e_log , + e_log10 , e_log2 , e_log1p , e_logn , + e_neg , e_pos , e_round , e_roundn , + e_root , e_sqrt , e_sin , e_sinc , + e_sinh , e_sec , e_csc , e_tan , + e_tanh , e_cot , e_clamp , e_iclamp , + e_inrange , e_sgn , e_r2d , e_d2r , + e_d2g , e_g2d , e_hypot , e_notl , + e_erf , e_erfc , e_ncdf , e_frac , + e_trunc , e_assign , e_addass , e_subass , + e_mulass , e_divass , e_modass , e_in , + e_like , e_ilike , e_multi , e_swap , + + // Do not add new functions/operators after this point. + e_sf00 = 1000, e_sf01 = 1001, e_sf02 = 1002, e_sf03 = 1003, + e_sf04 = 1004, e_sf05 = 1005, e_sf06 = 1006, e_sf07 = 1007, + e_sf08 = 1008, e_sf09 = 1009, e_sf10 = 1010, e_sf11 = 1011, + e_sf12 = 1012, e_sf13 = 1013, e_sf14 = 1014, e_sf15 = 1015, + e_sf16 = 1016, e_sf17 = 1017, e_sf18 = 1018, e_sf19 = 1019, + e_sf20 = 1020, e_sf21 = 1021, e_sf22 = 1022, e_sf23 = 1023, + e_sf24 = 1024, e_sf25 = 1025, e_sf26 = 1026, e_sf27 = 1027, + e_sf28 = 1028, e_sf29 = 1029, e_sf30 = 1030, e_sf31 = 1031, + e_sf32 = 1032, e_sf33 = 1033, e_sf34 = 1034, e_sf35 = 1035, + e_sf36 = 1036, e_sf37 = 1037, e_sf38 = 1038, e_sf39 = 1039, + e_sf40 = 1040, e_sf41 = 1041, e_sf42 = 1042, e_sf43 = 1043, + e_sf44 = 1044, e_sf45 = 1045, e_sf46 = 1046, e_sf47 = 1047, + e_sf48 = 1048, e_sf49 = 1049, e_sf50 = 1050, e_sf51 = 1051, + e_sf52 = 1052, e_sf53 = 1053, e_sf54 = 1054, e_sf55 = 1055, + e_sf56 = 1056, e_sf57 = 1057, e_sf58 = 1058, e_sf59 = 1059, + e_sf60 = 1060, e_sf61 = 1061, e_sf62 = 1062, e_sf63 = 1063, + e_sf64 = 1064, e_sf65 = 1065, e_sf66 = 1066, e_sf67 = 1067, + e_sf68 = 1068, e_sf69 = 1069, e_sf70 = 1070, e_sf71 = 1071, + e_sf72 = 1072, e_sf73 = 1073, e_sf74 = 1074, e_sf75 = 1075, + e_sf76 = 1076, e_sf77 = 1077, e_sf78 = 1078, e_sf79 = 1079, + e_sf80 = 1080, e_sf81 = 1081, e_sf82 = 1082, e_sf83 = 1083, + e_sf84 = 1084, e_sf85 = 1085, e_sf86 = 1086, e_sf87 = 1087, + e_sf88 = 1088, e_sf89 = 1089, e_sf90 = 1090, e_sf91 = 1091, + e_sf92 = 1092, e_sf93 = 1093, e_sf94 = 1094, e_sf95 = 1095, + e_sf96 = 1096, e_sf97 = 1097, e_sf98 = 1098, e_sf99 = 1099, + e_sffinal = 1100, + e_sf4ext00 = 2000, e_sf4ext01 = 2001, e_sf4ext02 = 2002, e_sf4ext03 = 2003, + e_sf4ext04 = 2004, e_sf4ext05 = 2005, e_sf4ext06 = 2006, e_sf4ext07 = 2007, + e_sf4ext08 = 2008, e_sf4ext09 = 2009, e_sf4ext10 = 2010, e_sf4ext11 = 2011, + e_sf4ext12 = 2012, e_sf4ext13 = 2013, e_sf4ext14 = 2014, e_sf4ext15 = 2015, + e_sf4ext16 = 2016, e_sf4ext17 = 2017, e_sf4ext18 = 2018, e_sf4ext19 = 2019, + e_sf4ext20 = 2020, e_sf4ext21 = 2021, e_sf4ext22 = 2022, e_sf4ext23 = 2023, + e_sf4ext24 = 2024, e_sf4ext25 = 2025, e_sf4ext26 = 2026, e_sf4ext27 = 2027, + e_sf4ext28 = 2028, e_sf4ext29 = 2029, e_sf4ext30 = 2030, e_sf4ext31 = 2031, + e_sf4ext32 = 2032, e_sf4ext33 = 2033, e_sf4ext34 = 2034, e_sf4ext35 = 2035, + e_sf4ext36 = 2036, e_sf4ext37 = 2037, e_sf4ext38 = 2038, e_sf4ext39 = 2039, + e_sf4ext40 = 2040, e_sf4ext41 = 2041, e_sf4ext42 = 2042, e_sf4ext43 = 2043, + e_sf4ext44 = 2044, e_sf4ext45 = 2045, e_sf4ext46 = 2046, e_sf4ext47 = 2047, + e_sf4ext48 = 2048, e_sf4ext49 = 2049, e_sf4ext50 = 2050, e_sf4ext51 = 2051, + e_sf4ext52 = 2052, e_sf4ext53 = 2053, e_sf4ext54 = 2054, e_sf4ext55 = 2055, + e_sf4ext56 = 2056, e_sf4ext57 = 2057, e_sf4ext58 = 2058, e_sf4ext59 = 2059, + e_sf4ext60 = 2060 + }; + + inline std::string to_str(const operator_type opr) + { + switch (opr) + { + case e_add : return "+"; + case e_sub : return "-"; + case e_mul : return "*"; + case e_div : return "/"; + case e_mod : return "%"; + case e_pow : return "^"; + case e_assign : return ":="; + case e_addass : return "+="; + case e_subass : return "-="; + case e_mulass : return "*="; + case e_divass : return "/="; + case e_modass : return "%="; + case e_lt : return "<"; + case e_lte : return "<="; + case e_eq : return "=="; + case e_equal : return "="; + case e_ne : return "!="; + case e_nequal : return "<>"; + case e_gte : return ">="; + case e_gt : return ">"; + default : return"N/A"; + } + } + + struct base_operation_t + { + base_operation_t(const operator_type t, const unsigned int& np) + : type(t), + num_params(np) + {} + + operator_type type; + unsigned int num_params; + }; + + namespace loop_unroll + { +#ifndef exprtk_disable_superscalar_unroll + const unsigned int global_loop_batch_size = 16; +#else + const unsigned int global_loop_batch_size = 4; +#endif + + struct details + { + details(const std::size_t& vsize, + const unsigned int loop_batch_size = global_loop_batch_size) + : batch_size(loop_batch_size), + remainder (vsize % batch_size), + upper_bound(static_cast(vsize) - (remainder ? loop_batch_size : 0)) + {} + + int batch_size; + int remainder; + int upper_bound; + }; + } + +#ifdef exprtk_enable_debugging + inline void dump_ptr(const std::string& s, const void* ptr, const std::size_t size = 0) + { + if (size) + exprtk_debug(("%s - addr: %p\n",s.c_str(),ptr)); + else + exprtk_debug(("%s - addr: %p size: %d\n", + s.c_str(), + ptr, + static_cast(size))); + } +#else + inline void dump_ptr(const std::string&, const void*) {} + inline void dump_ptr(const std::string&, const void*, const std::size_t) {} +#endif + + template + class vec_data_store + { + public: + + typedef vec_data_store type; + typedef T* data_t; + + private: + + struct control_block + { + control_block() + : ref_count(1), + size (0), + data (0), + destruct (true) + {} + + control_block(const std::size_t& dsize) + : ref_count(1), + size (dsize), + data (0), + destruct (true) + { create_data(); } + + control_block(const std::size_t& dsize, data_t dptr, bool dstrct = false) + : ref_count(1), + size (dsize), + data (dptr ), + destruct (dstrct) + {} + + ~control_block() + { + if (data && destruct && (0 == ref_count)) + { + dump_ptr("~control_block() data",data); + delete[] data; + data = 0; + } + } + + static inline control_block* create(const std::size_t& size, data_t data_ptr = data_t(0), bool dstrct = false) + { + if (size) + { + if (0 == data_ptr) + return new control_block(size); + else + return new control_block(size, data_ptr, dstrct); + } + else + return new control_block; + } + + static inline void destroy(control_block*& cntrl_blck) + { + if (cntrl_blck) + { + if ( + (0 != cntrl_blck->ref_count) && + (0 == --cntrl_blck->ref_count) + ) + { + delete cntrl_blck; + } + + cntrl_blck = 0; + } + } + + std::size_t ref_count; + std::size_t size; + data_t data; + bool destruct; + + private: + + control_block(const control_block&); + control_block& operator=(const control_block&); + + inline void create_data() + { + destruct = true; + data = new T[size]; + std::fill_n(data,size,T(0)); + dump_ptr("control_block::create_data() - data",data,size); + } + }; + + public: + + vec_data_store() + : control_block_(control_block::create(0)) + {} + + vec_data_store(const std::size_t& size) + : control_block_(control_block::create(size,(data_t)(0),true)) + {} + + vec_data_store(const std::size_t& size, data_t data, bool dstrct = false) + : control_block_(control_block::create(size, data, dstrct)) + {} + + vec_data_store(const type& vds) + { + control_block_ = vds.control_block_; + control_block_->ref_count++; } - } - else - return_result = false; - - if (length && return_result) - { - result = result * 10 + static_cast(digit); - ++itr; - } - - result = negative ? -result : result; - return return_result; - } - - template - static inline bool parse_nan(Iterator& itr, const Iterator end, T& t) - { - typedef typename std::iterator_traits::value_type type; - static const std::size_t nan_length = 3; - if (std::distance(itr,end) != static_cast(nan_length)) - return false; - if (static_cast('n') == (*itr)) - { - if ( - (static_cast('a') != *(itr + 1)) || - (static_cast('n') != *(itr + 2)) - ) + + ~vec_data_store() { - return false; + control_block::destroy(control_block_); } - } - else if ( - (static_cast('A') != *(itr + 1)) || - (static_cast('N') != *(itr + 2)) - ) - { - return false; - } - t = std::numeric_limits::quiet_NaN(); - return true; - } - - template - static inline bool parse_inf(Iterator& itr, const Iterator end, T& t, bool negative) - { - static const char inf_uc[] = "INFINITY"; - static const char inf_lc[] = "infinity"; - static const std::size_t inf_length = 8; - const std::size_t length = std::distance(itr,end); - if ((3 != length) && (inf_length != length)) - return false; - const char* inf_itr = ('i' == (*itr)) ? inf_lc : inf_uc; - while (end != itr) - { - if (*inf_itr == static_cast(*itr)) + + type& operator=(const type& vds) { - ++itr; - ++inf_itr; - continue; + if (this != &vds) + { + std::size_t final_size = min_size(control_block_, vds.control_block_); + + vds.control_block_->size = final_size; + control_block_->size = final_size; + + if (control_block_->destruct || (0 == control_block_->data)) + { + control_block::destroy(control_block_); + + control_block_ = vds.control_block_; + control_block_->ref_count++; + } + } + + return *this; } - else - return false; - } - if (negative) - t = -std::numeric_limits::infinity(); - else - t = std::numeric_limits::infinity(); - return true; - } - - template - inline bool string_to_real(Iterator& itr_external, const Iterator end, T& t, numeric::details::real_type_tag) - { - if (end == itr_external) return false; - - Iterator itr = itr_external; - - T d = T(0); - - bool negative = ('-' == (*itr)); - - if (negative || '+' == (*itr)) - { - if (end == ++itr) - return false; - } - - bool instate = false; - - #define parse_digit_1(d) \ - if ((digit = (*itr - '0')) < 10) { d = d * T(10) + digit; } else break; if (end == ++itr) break; \ - - #define parse_digit_2(d) \ - if ((digit = (*itr - '0')) < 10) { d = d * T(10) + digit; } else break; ++itr; \ - - if ('.' != (*itr)) - { - const Iterator curr = itr; - while ((end != itr) && ('0' == (*itr))) ++itr; - unsigned int digit; - - while (end != itr) + + inline data_t data() { - // Note: For 'physical' superscalar architectures it - // is advised that the following loop be: 4xPD1 and 1xPD2 - #ifdef exprtk_enable_superscalar - parse_digit_1(d) - parse_digit_1(d) - #endif - parse_digit_1(d) - parse_digit_1(d) - parse_digit_2(d) + return control_block_->data; } - - if (curr != itr) instate = true; - } - - int exponent = 0; - - if (end != itr) - { - if ('.' == (*itr)) + + inline data_t data() const { - const Iterator curr = ++itr; - unsigned int digit; - T tmp_d = T(0); - - while (end != itr) - { - #ifdef exprtk_enable_superscalar - parse_digit_1(tmp_d) - parse_digit_1(tmp_d) - parse_digit_1(tmp_d) - #endif - parse_digit_1(tmp_d) - parse_digit_1(tmp_d) - parse_digit_2(tmp_d) - } - - if (curr != itr) - { - instate = true; - d += compute_pow10(tmp_d,-std::distance(curr,itr)); - } - - #undef parse_digit_1 - #undef parse_digit_2 + return control_block_->data; } - - if (end != itr) + + inline std::size_t size() { - typename std::iterator_traits::value_type c = (*itr); - - if (('e' == c) || ('E' == c)) - { - int exp = 0; - - if (!details::string_to_type_converter_impl_ref(++itr,end,exp)) - { - if (end == itr) - return false; - else - c = (*itr); - } - - exponent += exp; - } - - if (end != itr) - { - if (('f' == c) || ('F' == c) || ('l' == c) || ('L' == c)) - ++itr; - else if ('#' == c) - { - if (end == ++itr) - return false; - else if (('I' <= (*itr)) && ((*itr) <= 'n')) - { - if (('i' == (*itr)) || ('I' == (*itr))) - { - return parse_inf(itr,end,t,negative); - } - else if (('n' == (*itr)) || ('N' == (*itr))) - { - return parse_nan(itr,end,t); - } - else - return false; - } - else - return false; - } - else if (('I' <= (*itr)) && ((*itr) <= 'n')) - { - if (('i' == (*itr)) || ('I' == (*itr))) - { - return parse_inf(itr,end,t,negative); - } - else if (('n' == (*itr)) || ('N' == (*itr))) - { - return parse_nan(itr,end,t); - } - else - return false; - } - else - return false; - } + return control_block_->size; } - } - - if ((end != itr) || (!instate)) - return false; - else if (exponent) - d = compute_pow10(d,exponent); - - t = static_cast((negative) ? -d : d); - return true; - } - - template - inline bool string_to_real(const std::string& s, T& t) - { - const char* begin = s.data(); - const char* end = s.data() + s.size(); - typename numeric::details::number_type::type num_type; - return string_to_real(begin,end,t,num_type); - } - - template - struct functor_t - { - /* - Note: The following definitions for Type, may require tweaking - based on the compiler and target architecture. The benchmark - should provide enough information to make the right choice. - */ - //typedef T Type; - //typedef const T Type; - typedef const T& Type; - typedef T (*qfunc_t)(Type t0, Type t1, Type t2, Type t3); - typedef T (*tfunc_t)(Type t0, Type t1, Type t2); - typedef T (*bfunc_t)(Type t0, Type t1); - typedef T (*ufunc_t)(Type t0); - }; - - } // namespace details - - namespace lexer - { - struct token - { - enum token_type - { - e_none = 0, e_error = 1, e_err_symbol = 2, - e_err_number = 3, e_err_string = 4, e_err_sfunc = 5, - e_eof = 6, e_number = 7, e_symbol = 8, - e_string = 9, e_assign = 10, e_addass = 11, - e_subass = 12, e_mulass = 13, e_divass = 14, - e_modass = 15, e_shr = 16, e_shl = 17, - e_lte = 18, e_ne = 19, e_gte = 20, - e_swap = 21, e_lt = '<', e_gt = '>', - e_eq = '=', e_rbracket = ')', e_lbracket = '(', - e_rsqrbracket = ']', e_lsqrbracket = '[', e_rcrlbracket = '}', - e_lcrlbracket = '{', e_comma = ',', e_add = '+', - e_sub = '-', e_div = '/', e_mul = '*', - e_mod = '%', e_pow = '^', e_colon = ':', - e_ternary = '?' - }; - - token() - : type(e_none), - value(""), - position(std::numeric_limits::max()) - {} - - void clear() - { - type = e_none; - value = ""; - position = std::numeric_limits::max(); - } - - template - inline token& set_operator(const token_type tt, const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) - { - type = tt; - value.assign(begin,end); - if (base_begin) - position = std::distance(base_begin,begin); - return *this; - } - - template - inline token& set_symbol(const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) - { - type = e_symbol; - value.assign(begin,end); - if (base_begin) - position = std::distance(base_begin,begin); - return *this; - } - - template - inline token& set_numeric(const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) - { - type = e_number; - value.assign(begin,end); - if (base_begin) - position = std::distance(base_begin,begin); - return *this; - } - - template - inline token& set_string(const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) - { - type = e_string; - value.assign(begin,end); - if (base_begin) - position = std::distance(base_begin,begin); - return *this; - } - - inline token& set_string(const std::string& s, const std::size_t p) - { - type = e_string; - value = s; - position = p; - return *this; - } - - template - inline token& set_error(const token_type et, const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) - { - if ( - (e_error == et) || - (e_err_symbol == et) || - (e_err_number == et) || - (e_err_string == et) || - (e_err_sfunc == et) - ) + + inline std::size_t size() const { - type = et; + return control_block_->size; + } + + inline data_t& ref() + { + return control_block_->data; + } + + inline void dump() const + { +#ifdef exprtk_enable_debugging + exprtk_debug(("size: %d\taddress:%p\tdestruct:%c\n", + size(), + data(), + (control_block_->destruct ? 'T' : 'F'))); + + for (std::size_t i = 0; i < size(); ++i) + { + if (5 == i) + exprtk_debug(("\n")); + + exprtk_debug(("%15.10f ",data()[i])); + } + exprtk_debug(("\n")); +#endif } - else - type = e_error; - - value.assign(begin,end); - - if (base_begin) - position = std::distance(base_begin,begin); - - return *this; - } - - static inline std::string to_str(token_type t) - { - switch (t) - { - case e_none : return "NONE"; - case e_error : return "ERROR"; - case e_err_symbol : return "ERROR_SYMBOL"; - case e_err_number : return "ERROR_NUMBER"; - case e_err_string : return "ERROR_STRING"; - case e_eof : return "EOF"; - case e_number : return "NUMBER"; - case e_symbol : return "SYMBOL"; - case e_string : return "STRING"; - case e_assign : return ":="; - case e_addass : return "+="; - case e_subass : return "-="; - case e_mulass : return "*="; - case e_divass : return "/="; - case e_modass : return "%="; - case e_shr : return ">>"; - case e_shl : return "<<"; - case e_lte : return "<="; - case e_ne : return "!="; - case e_gte : return ">="; - case e_lt : return "<"; - case e_gt : return ">"; - case e_eq : return "="; - case e_rbracket : return ")"; - case e_lbracket : return "("; - case e_rsqrbracket : return "]"; - case e_lsqrbracket : return "["; - case e_rcrlbracket : return "}"; - case e_lcrlbracket : return "{"; - case e_comma : return ","; - case e_add : return "+"; - case e_sub : return "-"; - case e_div : return "/"; - case e_mul : return "*"; - case e_mod : return "%"; - case e_pow : return "^"; - case e_colon : return ":"; - case e_ternary : return "?"; - case e_swap : return "<=>"; - default : return "UNKNOWN"; - } - } - - inline bool is_error() const - { - return ( - (e_error == type) || - (e_err_symbol == type) || - (e_err_number == type) || - (e_err_string == type) || - (e_err_sfunc == type) - ); - } - - token_type type; - std::string value; - std::size_t position; - }; - - class generator - { - public: - - typedef token token_t; - typedef std::vector token_list_t; - typedef std::vector::iterator token_list_itr_t; - - generator() - : base_itr_(0), - s_itr_ (0), - s_end_ (0) - { - clear(); - } - - inline void clear() - { - base_itr_ = 0; - s_itr_ = 0; - s_end_ = 0; - token_list_.clear(); - token_itr_ = token_list_.end(); - store_token_itr_ = token_list_.end(); - } - - inline bool process(const std::string& str) - { - base_itr_ = str.data(); - s_itr_ = str.data(); - s_end_ = str.data() + str.size(); - - eof_token_.set_operator(token_t::e_eof,s_end_,s_end_,base_itr_); - token_list_.clear(); - - while (!is_end(s_itr_)) + + static inline void match_sizes(type& vds0, type& vds1) { - scan_token(); - - if (token_list_.empty()) - return true; - else if (token_list_.back().is_error()) - { - return false; - } + std::size_t size = min_size(vds0.control_block_,vds1.control_block_); + vds0.control_block_->size = size; + vds1.control_block_->size = size; } - - return true; - } - - inline bool empty() const - { - return token_list_.empty(); - } - - inline std::size_t size() const - { - return token_list_.size(); - } - - inline void begin() - { - token_itr_ = token_list_.begin(); - store_token_itr_ = token_list_.begin(); - } - - inline void store() - { - store_token_itr_ = token_itr_; - } - - inline void restore() - { - token_itr_ = store_token_itr_; - } - - inline token_t& next_token() - { - if (token_list_.end() != token_itr_) + + private: + + static inline std::size_t min_size(control_block* cb0, control_block* cb1) { - return *token_itr_++; + std::size_t size0 = cb0->size; + std::size_t size1 = cb1->size; + + if (size0 && size1) + return std::min(size0,size1); + else + return (size0) ? size0 : size1; } - else - return eof_token_; - } - - inline token_t& peek_next_token() - { - if (token_list_.end() != token_itr_) + + control_block* control_block_; + }; + + namespace numeric + { + namespace details + { + template + inline T process_impl(const operator_type operation, const T arg) + { + switch (operation) + { + case e_abs : return numeric::abs (arg); + case e_acos : return numeric::acos (arg); + case e_acosh : return numeric::acosh(arg); + case e_asin : return numeric::asin (arg); + case e_asinh : return numeric::asinh(arg); + case e_atan : return numeric::atan (arg); + case e_atanh : return numeric::atanh(arg); + case e_ceil : return numeric::ceil (arg); + case e_cos : return numeric::cos (arg); + case e_cosh : return numeric::cosh (arg); + case e_exp : return numeric::exp (arg); + case e_expm1 : return numeric::expm1(arg); + case e_floor : return numeric::floor(arg); + case e_log : return numeric::log (arg); + case e_log10 : return numeric::log10(arg); + case e_log2 : return numeric::log2 (arg); + case e_log1p : return numeric::log1p(arg); + case e_neg : return numeric::neg (arg); + case e_pos : return numeric::pos (arg); + case e_round : return numeric::round(arg); + case e_sin : return numeric::sin (arg); + case e_sinc : return numeric::sinc (arg); + case e_sinh : return numeric::sinh (arg); + case e_sqrt : return numeric::sqrt (arg); + case e_tan : return numeric::tan (arg); + case e_tanh : return numeric::tanh (arg); + case e_cot : return numeric::cot (arg); + case e_sec : return numeric::sec (arg); + case e_csc : return numeric::csc (arg); + case e_r2d : return numeric::r2d (arg); + case e_d2r : return numeric::d2r (arg); + case e_d2g : return numeric::d2g (arg); + case e_g2d : return numeric::g2d (arg); + case e_notl : return numeric::notl (arg); + case e_sgn : return numeric::sgn (arg); + case e_erf : return numeric::erf (arg); + case e_erfc : return numeric::erfc (arg); + case e_ncdf : return numeric::ncdf (arg); + case e_frac : return numeric::frac (arg); + case e_trunc : return numeric::trunc(arg); + default : return std::numeric_limits::quiet_NaN(); + } + } + + template + inline T process_impl(const operator_type operation, const T arg0, const T arg1) + { + switch (operation) + { + case e_add : return (arg0 + arg1); + case e_sub : return (arg0 - arg1); + case e_mul : return (arg0 * arg1); + case e_div : return (arg0 / arg1); + case e_mod : return modulus(arg0,arg1); + case e_pow : return pow(arg0,arg1); + case e_atan2 : return atan2(arg0,arg1); + case e_min : return std::min(arg0,arg1); + case e_max : return std::max(arg0,arg1); + case e_logn : return logn(arg0,arg1); + case e_lt : return (arg0 < arg1) ? T(1) : T(0); + case e_lte : return (arg0 <= arg1) ? T(1) : T(0); + case e_eq : return std::equal_to()(arg0,arg1) ? T(1) : T(0); + case e_ne : return std::not_equal_to()(arg0,arg1) ? T(1) : T(0); + case e_gte : return (arg0 >= arg1) ? T(1) : T(0); + case e_gt : return (arg0 > arg1) ? T(1) : T(0); + case e_and : return and_opr (arg0,arg1); + case e_nand : return nand_opr(arg0,arg1); + case e_or : return or_opr (arg0,arg1); + case e_nor : return nor_opr (arg0,arg1); + case e_xor : return xor_opr (arg0,arg1); + case e_xnor : return xnor_opr(arg0,arg1); + case e_root : return root (arg0,arg1); + case e_roundn : return roundn (arg0,arg1); + case e_equal : return equal (arg0,arg1); + case e_nequal : return nequal (arg0,arg1); + case e_hypot : return hypot (arg0,arg1); + case e_shr : return shr (arg0,arg1); + case e_shl : return shl (arg0,arg1); + default : return std::numeric_limits::quiet_NaN(); + } + } + + template + inline T process_impl(const operator_type operation, const T arg0, const T arg1, int_type_tag) + { + switch (operation) + { + case e_add : return (arg0 + arg1); + case e_sub : return (arg0 - arg1); + case e_mul : return (arg0 * arg1); + case e_div : return (arg0 / arg1); + case e_mod : return arg0 % arg1; + case e_pow : return pow(arg0,arg1); + case e_min : return std::min(arg0,arg1); + case e_max : return std::max(arg0,arg1); + case e_logn : return logn(arg0,arg1); + case e_lt : return (arg0 < arg1) ? T(1) : T(0); + case e_lte : return (arg0 <= arg1) ? T(1) : T(0); + case e_eq : return (arg0 == arg1) ? T(1) : T(0); + case e_ne : return (arg0 != arg1) ? T(1) : T(0); + case e_gte : return (arg0 >= arg1) ? T(1) : T(0); + case e_gt : return (arg0 > arg1) ? T(1) : T(0); + case e_and : return ((arg0 != T(0)) && (arg1 != T(0))) ? T(1) : T(0); + case e_nand : return ((arg0 != T(0)) && (arg1 != T(0))) ? T(0) : T(1); + case e_or : return ((arg0 != T(0)) || (arg1 != T(0))) ? T(1) : T(0); + case e_nor : return ((arg0 != T(0)) || (arg1 != T(0))) ? T(0) : T(1); + case e_xor : return arg0 ^ arg1; + case e_xnor : return !(arg0 ^ arg1); + case e_root : return root(arg0,arg1); + case e_equal : return arg0 == arg1; + case e_nequal : return arg0 != arg1; + case e_hypot : return hypot(arg0,arg1); + case e_shr : return arg0 >> arg1; + case e_shl : return arg0 << arg1; + default : return std::numeric_limits::quiet_NaN(); + } + } + } + + template + inline T process(const operator_type operation, const T arg) { - return *token_itr_; + return exprtk::details::numeric::details::process_impl(operation,arg); + } + + template + inline T process(const operator_type operation, const T arg0, const T arg1) + { + return exprtk::details::numeric::details::process_impl(operation,arg0,arg1); + } + } + + template + class expression_node + { + public: + + enum node_type + { + e_none , e_null , e_constant , e_unary , + e_binary , e_binary_ext , e_trinary , e_quaternary , + e_vararg , e_conditional , e_while , e_repeat , + e_for , e_switch , e_mswitch , e_return , + e_retenv , e_variable , e_stringvar , e_stringconst , + e_stringvarrng , e_cstringvarrng, e_strgenrange , e_strconcat , + e_stringvarsize, e_strswap , e_stringsize , e_function , + e_vafunction , e_genfunction , e_strfunction , e_strcondition , + e_strccondition, e_add , e_sub , e_mul , + e_div , e_mod , e_pow , e_lt , + e_lte , e_gt , e_gte , e_eq , + e_ne , e_and , e_nand , e_or , + e_nor , e_xor , e_xnor , e_in , + e_like , e_ilike , e_inranges , e_ipow , + e_ipowinv , e_abs , e_acos , e_acosh , + e_asin , e_asinh , e_atan , e_atanh , + e_ceil , e_cos , e_cosh , e_exp , + e_expm1 , e_floor , e_log , e_log10 , + e_log2 , e_log1p , e_neg , e_pos , + e_round , e_sin , e_sinc , e_sinh , + e_sqrt , e_tan , e_tanh , e_cot , + e_sec , e_csc , e_r2d , e_d2r , + e_d2g , e_g2d , e_notl , e_sgn , + e_erf , e_erfc , e_ncdf , e_frac , + e_trunc , e_uvouv , e_vov , e_cov , + e_voc , e_vob , e_bov , e_cob , + e_boc , e_vovov , e_vovoc , e_vocov , + e_covov , e_covoc , e_vovovov , e_vovovoc , + e_vovocov , e_vocovov , e_covovov , e_covocov , + e_vocovoc , e_covovoc , e_vococov , e_sf3ext , + e_sf4ext , e_nulleq , e_strass , e_vector , + e_vecelem , e_rbvecelem , e_rbveccelem , e_vecdefass , + e_vecvalass , e_vecvecass , e_vecopvalass , e_vecopvecass , + e_vecfunc , e_vecvecswap , e_vecvecineq , e_vecvalineq , + e_valvecineq , e_vecvecarith , e_vecvalarith , e_valvecarith , + e_vecunaryop , e_break , e_continue , e_swap + }; + + typedef T value_type; + typedef expression_node* expression_ptr; + + virtual ~expression_node() + {} + + inline virtual T value() const + { + return std::numeric_limits::quiet_NaN(); + } + + inline virtual expression_node* branch(const std::size_t& index = 0) const + { + return reinterpret_cast(index * 0); + } + + inline virtual node_type type() const + { + return e_none; + } + }; + + template + inline bool is_generally_string_node(const expression_node* node); + + inline bool is_true(const double v) + { + return std::not_equal_to()(0.0,v); + } + + inline bool is_true(const long double v) + { + return std::not_equal_to()(0.0L,v); + } + + inline bool is_true(const float v) + { + return std::not_equal_to()(0.0f,v); + } + + template + inline bool is_true(const std::complex& v) + { + return std::not_equal_to >()(std::complex(0),v); + } + + template + inline bool is_true(const expression_node* node) + { + return std::not_equal_to()(T(0),node->value()); + } + + template + inline bool is_false(const expression_node* node) + { + return std::equal_to()(T(0),node->value()); + } + + template + inline bool is_unary_node(const expression_node* node) + { + return node && (details::expression_node::e_unary == node->type()); + } + + template + inline bool is_neg_unary_node(const expression_node* node) + { + return node && (details::expression_node::e_neg == node->type()); + } + + template + inline bool is_binary_node(const expression_node* node) + { + return node && (details::expression_node::e_binary == node->type()); + } + + template + inline bool is_variable_node(const expression_node* node) + { + return node && (details::expression_node::e_variable == node->type()); + } + + template + inline bool is_ivariable_node(const expression_node* node) + { + return node && + ( + details::expression_node::e_variable == node->type() || + details::expression_node::e_vecelem == node->type() || + details::expression_node::e_rbvecelem == node->type() || + details::expression_node::e_rbveccelem == node->type() + ); + } + + template + inline bool is_vector_elem_node(const expression_node* node) + { + return node && (details::expression_node::e_vecelem == node->type()); + } + + template + inline bool is_rebasevector_elem_node(const expression_node* node) + { + return node && (details::expression_node::e_rbvecelem == node->type()); + } + + template + inline bool is_rebasevector_celem_node(const expression_node* node) + { + return node && (details::expression_node::e_rbveccelem == node->type()); + } + + template + inline bool is_vector_node(const expression_node* node) + { + return node && (details::expression_node::e_vector == node->type()); + } + + template + inline bool is_ivector_node(const expression_node* node) + { + if (node) + { + switch (node->type()) + { + case details::expression_node::e_vector : + case details::expression_node::e_vecvalass : + case details::expression_node::e_vecvecass : + case details::expression_node::e_vecopvalass : + case details::expression_node::e_vecopvecass : + case details::expression_node::e_vecvecswap : + case details::expression_node::e_vecvecarith : + case details::expression_node::e_vecvalarith : + case details::expression_node::e_valvecarith : + case details::expression_node::e_vecunaryop : return true; + default : return false; + } } else - return eof_token_; - } - - inline token_t& operator[](const std::size_t& index) - { - if (index < token_list_.size()) - return token_list_[index]; - else - return eof_token_; - } - - inline token_t operator[](const std::size_t& index) const - { - if (index < token_list_.size()) - return token_list_[index]; + return false; + } + + template + inline bool is_constant_node(const expression_node* node) + { + return node && (details::expression_node::e_constant == node->type()); + } + + template + inline bool is_null_node(const expression_node* node) + { + return node && (details::expression_node::e_null == node->type()); + } + + template + inline bool is_break_node(const expression_node* node) + { + return node && (details::expression_node::e_break == node->type()); + } + + template + inline bool is_continue_node(const expression_node* node) + { + return node && (details::expression_node::e_continue == node->type()); + } + + template + inline bool is_swap_node(const expression_node* node) + { + return node && (details::expression_node::e_swap == node->type()); + } + + template + inline bool is_function(const expression_node* node) + { + return node && (details::expression_node::e_function == node->type()); + } + + template + inline bool is_return_node(const expression_node* node) + { + return node && (details::expression_node::e_return == node->type()); + } + + template class unary_node; + + template + inline bool is_negate_node(const expression_node* node) + { + if (node && is_unary_node(node)) + { + return (details::e_neg == static_cast*>(node)->operation()); + } else - return eof_token_; - } - - inline bool finished() const - { - return (token_list_.end() == token_itr_); - } - - inline void insert_front(token_t::token_type tk_type) - { - if ( - !token_list_.empty() && - (token_list_.end() != token_itr_) - ) + return false; + } + + template + inline bool branch_deletable(expression_node* node) + { + return !is_variable_node(node) && + !is_string_node (node) ; + } + + template + inline bool all_nodes_valid(expression_node* (&b)[N]) + { + for (std::size_t i = 0; i < N; ++i) { - token_t t = *token_itr_; - - t.type = tk_type; - token_itr_ = token_list_.insert(token_itr_,t); + if (0 == b[i]) return false; } - } - - private: - - inline bool is_end(const char* itr) - { - return (s_end_ == itr); - } - - inline void skip_whitespace() - { - while (!is_end(s_itr_) && details::is_whitespace(*s_itr_)) + + return true; + } + + template class Sequence> + inline bool all_nodes_valid(const Sequence*,Allocator>& b) + { + for (std::size_t i = 0; i < b.size(); ++i) { - ++s_itr_; + if (0 == b[i]) return false; } - } - - inline void skip_comments() - { - #ifndef exprtk_disable_comments - // The following comment styles are supported: - // 1. // .... \n - // 2. # .... \n - // 3. /* .... */ - struct test - { - static inline bool comment_start(const char c0, const char c1, int& mode, int& incr) - { - mode = 0; - if ('#' == c0) { mode = 1; incr = 1; } - else if ('/' == c0) - { - if ('/' == c1) { mode = 1; incr = 2; } - else if ('*' == c1) { mode = 2; incr = 2; } - } - return (0 != mode); - } - - static inline bool comment_end(const char c0, const char c1, const int mode) - { - return ( - ((1 == mode) && ('\n' == c0)) || - ((2 == mode) && ( '*' == c0) && ('/' == c1)) - ); - } - }; - - int mode = 0; - int increment = 0; - - if (is_end(s_itr_) || is_end((s_itr_ + 1))) - return; - else if (!test::comment_start(*s_itr_,*(s_itr_ + 1),mode,increment)) - return; - - s_itr_ += increment; - - while (!is_end(s_itr_) && !test::comment_end(*s_itr_,*(s_itr_ + 1),mode)) + + return true; + } + + template + inline bool all_nodes_variables(expression_node* (&b)[N]) + { + for (std::size_t i = 0; i < N; ++i) { - ++s_itr_; + if (0 == b[i]) + return false; + else if (!is_variable_node(b[i])) + return false; } - - if (!is_end(s_itr_)) + + return true; + } + + template class Sequence> + inline bool all_nodes_variables(Sequence*,Allocator>& b) + { + for (std::size_t i = 0; i < b.size(); ++i) { - s_itr_ += mode; - skip_whitespace(); - skip_comments(); + if (0 == b[i]) + return false; + else if (!is_variable_node(b[i])) + return false; } - #endif - } - - inline void scan_token() - { - skip_whitespace(); - skip_comments(); - if (is_end(s_itr_)) + + return true; + } + + template + inline void free_all_nodes(NodeAllocator& node_allocator, expression_node* (&b)[N]) + { + for (std::size_t i = 0; i < N; ++i) { - return; + free_node(node_allocator,b[i]); } - else if (details::is_operator_char(*s_itr_)) + } + + template class Sequence> + inline void free_all_nodes(NodeAllocator& node_allocator, Sequence*,Allocator>& b) + { + for (std::size_t i = 0; i < b.size(); ++i) { - scan_operator(); - return; + free_node(node_allocator,b[i]); } - else if (details::is_letter(*s_itr_)) + + b.clear(); + } + + template + inline void free_node(NodeAllocator& node_allocator, expression_node*& node, const bool force_delete = false) + { + if (0 != node) + { + if ( + (is_variable_node(node) || is_string_node(node)) || + force_delete + ) + return; + + node_allocator.free(node); + node = 0; + } + } + + template + class vector_holder + { + private: + + typedef Type value_type; + typedef value_type* value_ptr; + typedef const value_ptr const_value_ptr; + + class vector_holder_base + { + public: + + virtual ~vector_holder_base(){} + + inline value_ptr operator[](const std::size_t& index) const + { + return value_at(index); + } + + inline std::size_t size() const + { + return vector_size(); + } + + inline value_ptr data() const + { + return value_at(0); + } + + virtual inline bool rebaseable() const + { + return false; + } + + virtual void set_ref(value_ptr*) {} + + protected: + + virtual value_ptr value_at(const std::size_t&) const = 0; + virtual std::size_t vector_size() const = 0; + }; + + class array_vector_impl : public vector_holder_base + { + public: + + array_vector_impl(const Type* vec, const std::size_t& vec_size) + : vec_(vec), + size_(vec_size) + {} + + protected: + + value_ptr value_at(const std::size_t& index) const + { + if (index < size_) + return const_cast(vec_ + index); + else + return const_value_ptr(0); + } + + std::size_t vector_size() const + { + return size_; + } + + private: + + array_vector_impl operator=(const array_vector_impl&); + + const Type* vec_; + const std::size_t size_; + }; + + template class Sequence> + class sequence_vector_impl : public vector_holder_base + { + public: + + typedef Sequence sequence_t; + + sequence_vector_impl(sequence_t& seq) + : sequence_(seq) + {} + + protected: + + value_ptr value_at(const std::size_t& index) const + { + return (index < sequence_.size()) ? (&sequence_[index]) : const_value_ptr(0); + } + + std::size_t vector_size() const + { + return sequence_.size(); + } + + private: + + sequence_vector_impl operator=(const sequence_vector_impl&); + + sequence_t& sequence_; + }; + + class vector_view_impl : public vector_holder_base + { + public: + + typedef exprtk::vector_view vector_view_t; + + vector_view_impl(vector_view_t& vec_view) + : vec_view_(vec_view) + {} + + void set_ref(value_ptr* ref) + { + vec_view_.set_ref(ref); + } + + virtual inline bool rebaseable() const + { + return true; + } + + protected: + + value_ptr value_at(const std::size_t& index) const + { + return (index < vec_view_.size()) ? (&vec_view_[index]) : const_value_ptr(0); + } + + std::size_t vector_size() const + { + return vec_view_.size(); + } + + private: + + vector_view_impl operator=(const vector_view_impl&); + + vector_view_t& vec_view_; + }; + + public: + + typedef typename details::vec_data_store vds_t; + + vector_holder(Type* vec, const std::size_t& vec_size) + : vector_holder_base_(new(buffer)array_vector_impl(vec,vec_size)) + {} + + vector_holder(const vds_t& vds) + : vector_holder_base_(new(buffer)array_vector_impl(vds.data(),vds.size())) + {} + + template + vector_holder(std::vector& vec) + : vector_holder_base_(new(buffer)sequence_vector_impl(vec)) + {} + + vector_holder(exprtk::vector_view& vec) + : vector_holder_base_(new(buffer)vector_view_impl(vec)) + {} + + inline value_ptr operator[](const std::size_t& index) const { - scan_symbol(); - return; + return (*vector_holder_base_)[index]; } - else if (details::is_digit((*s_itr_)) || ('.' == (*s_itr_))) + + inline std::size_t size() const { - scan_number(); - return; + return vector_holder_base_->size(); } - else if ('$' == (*s_itr_)) + + inline value_ptr data() const { - scan_special_function(); - return; + return vector_holder_base_->data(); } - #ifndef exprtk_disable_string_capabilities - else if ('\'' == (*s_itr_)) + + void set_ref(value_ptr* ref) { - scan_string(); - return; + return vector_holder_base_->set_ref(ref); } - #endif - else if ('~' == (*s_itr_)) + + bool rebaseable() const { - token_t t; - t.set_symbol(s_itr_,s_itr_ + 1,base_itr_); - token_list_.push_back(t); - ++s_itr_; - return; + return vector_holder_base_->rebaseable(); } - else + + private: + + mutable vector_holder_base* vector_holder_base_; + uchar_t buffer[64]; + }; + + template + class null_node : public expression_node + { + public: + + inline T value() const { - token_t t; - t.set_error(token::e_error,s_itr_,s_itr_ + 2,base_itr_); - token_list_.push_back(t); - ++s_itr_; + return std::numeric_limits::quiet_NaN(); } - } - - inline void scan_operator() - { - token_t t; - - const char c0 = s_itr_[0]; - - if (!is_end(s_itr_ + 1)) + + inline typename expression_node::node_type type() const { - const char c1 = s_itr_[1]; - - if (!is_end(s_itr_ + 2)) - { - const char c2 = s_itr_[2]; - - if ((c0 == '<') && (c1 == '=') && (c2 == '>')) - { - t.set_operator(token_t::e_swap,s_itr_,s_itr_ + 3,base_itr_); - token_list_.push_back(t); - s_itr_ += 3; - return; - } - } - - token_t::token_type ttype = token_t::e_none; - - if ((c0 == '<') && (c1 == '=')) ttype = token_t::e_lte; - else if ((c0 == '>') && (c1 == '=')) ttype = token_t::e_gte; - else if ((c0 == '<') && (c1 == '>')) ttype = token_t::e_ne; - else if ((c0 == '!') && (c1 == '=')) ttype = token_t::e_ne; - else if ((c0 == '=') && (c1 == '=')) ttype = token_t::e_eq; - else if ((c0 == ':') && (c1 == '=')) ttype = token_t::e_assign; - else if ((c0 == '<') && (c1 == '<')) ttype = token_t::e_shl; - else if ((c0 == '>') && (c1 == '>')) ttype = token_t::e_shr; - else if ((c0 == '+') && (c1 == '=')) ttype = token_t::e_addass; - else if ((c0 == '-') && (c1 == '=')) ttype = token_t::e_subass; - else if ((c0 == '*') && (c1 == '=')) ttype = token_t::e_mulass; - else if ((c0 == '/') && (c1 == '=')) ttype = token_t::e_divass; - else if ((c0 == '%') && (c1 == '=')) ttype = token_t::e_modass; - - if (token_t::e_none != ttype) - { - t.set_operator(ttype,s_itr_,s_itr_ + 2,base_itr_); - token_list_.push_back(t); - s_itr_ += 2; - return; - } + return expression_node::e_null; } - - if ('<' == c0) - t.set_operator(token_t::e_lt ,s_itr_,s_itr_ + 1,base_itr_); - else if ('>' == c0) - t.set_operator(token_t::e_gt ,s_itr_,s_itr_ + 1,base_itr_); - else if (';' == c0) - t.set_operator(token_t::e_eof,s_itr_,s_itr_ + 1,base_itr_); - else if ('&' == c0) - t.set_symbol(s_itr_,s_itr_ + 1,base_itr_); - else if ('|' == c0) - t.set_symbol(s_itr_,s_itr_ + 1,base_itr_); - else - t.set_operator(token_t::token_type(c0),s_itr_,s_itr_ + 1,base_itr_); - - token_list_.push_back(t); - ++s_itr_; - } - - inline void scan_symbol() - { - const char* initial_itr = s_itr_; - - while ( - (!is_end(s_itr_)) && - (details::is_letter_or_digit(*s_itr_) || ((*s_itr_) == '_')) - ) + }; + + template + class null_eq_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + null_eq_node(expression_ptr brnch, const bool equality = true) + : branch_(brnch), + branch_deletable_(branch_deletable(branch_)), + equality_(equality) + {} + + ~null_eq_node() { - ++s_itr_; + if (branch_ && branch_deletable_) + { + delete branch_; + branch_ = 0; + } } - - token_t t; - t.set_symbol(initial_itr,s_itr_,base_itr_); - token_list_.push_back(t); - } - - inline void scan_number() - { - /* - Attempt to match a valid numeric value in one of the following formats: - 1. 123456 - 2. 123.456 - 3. 123.456e3 - 4. 123.456E3 - 5. 123.456e+3 - 6. 123.456E+3 - 7. 123.456e-3 - 8. 123.456E-3 - */ - const char* initial_itr = s_itr_; - bool dot_found = false; - bool e_found = false; - bool post_e_sign_found = false; - token_t t; - - while (!is_end(s_itr_)) - { - if ('.' == (*s_itr_)) - { - if (dot_found) - { - t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); - token_list_.push_back(t); - return; - } - - dot_found = true; - ++s_itr_; - - continue; - } - else if (details::imatch('e',(*s_itr_))) - { - const char& c = *(s_itr_ + 1); - - if (is_end(s_itr_ + 1)) - { - t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); - token_list_.push_back(t); - - return; - } - else if ( - ('+' != c) && - ('-' != c) && - !details::is_digit(c) - ) - { - t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); - token_list_.push_back(t); - - return; - } - - e_found = true; - ++s_itr_; - continue; - } - else if (e_found && details::is_sign(*s_itr_)) - { - if (post_e_sign_found) - { - t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); - token_list_.push_back(t); - - return; - } - - post_e_sign_found = true; - ++s_itr_; - continue; - } - else if (('.' != (*s_itr_)) && !details::is_digit(*s_itr_)) - break; - else - ++s_itr_; + + inline T value() const + { + const T v = branch_->value(); + const bool result = details::numeric::is_nan(v); + + if (result) + return (equality_) ? T(1) : T(0); + else + return (equality_) ? T(0) : T(1); } - - t.set_numeric(initial_itr,s_itr_,base_itr_); - token_list_.push_back(t); - - return; - } - - inline void scan_special_function() - { - const char* initial_itr = s_itr_; - token_t t; - - // $fdd(x,x,x) = at least 11 chars - if (std::distance(s_itr_,s_end_) < 11) + + inline typename expression_node::node_type type() const { - t.set_error(token::e_err_sfunc,initial_itr,s_itr_,base_itr_); - token_list_.push_back(t); - - return; + return expression_node::e_nulleq; } - - if ( - !(('$' == *s_itr_) && - (details::imatch ('f',*(s_itr_ + 1))) && - (details::is_digit(*(s_itr_ + 2))) && - (details::is_digit(*(s_itr_ + 3)))) - ) - { - t.set_error(token::e_err_sfunc,initial_itr,s_itr_,base_itr_); - token_list_.push_back(t); - - return; + + inline operator_type operation() const + { + return details::e_eq; } - - s_itr_ += 4; // $fdd = 4chars - - t.set_symbol(initial_itr,s_itr_,base_itr_); - token_list_.push_back(t); - - return; - } - - #ifndef exprtk_disable_string_capabilities - inline void scan_string() - { - const char* initial_itr = s_itr_ + 1; - token_t t; - - if (std::distance(s_itr_,s_end_) < 2) + + inline expression_node* branch(const std::size_t&) const { - t.set_error(token::e_err_string,s_itr_,s_end_,base_itr_); - token_list_.push_back(t); - return; + return branch_; } - - ++s_itr_; - - bool escaped_found = false; - bool escaped = false; - - while (!is_end(s_itr_)) + + private: + + expression_ptr branch_; + bool branch_deletable_; + bool equality_; + }; + + template + class literal_node : public expression_node + { + public: + + explicit literal_node(const T& v) + : value_(v) + {} + + inline T value() const { - if ('\\' == *s_itr_) - { - escaped_found = true; - escaped = true; - ++s_itr_; - - continue; - } - else if (!escaped) - { - if ('\'' == *s_itr_) - break; - } - else if (escaped) - { - if (!is_end(s_itr_) && ('0' == *(s_itr_))) - { - if ( - is_end(s_itr_ + 1) || - is_end(s_itr_ + 2) || - is_end(s_itr_ + 3) || - ( - ('x' != *(s_itr_ + 1)) && - ('X' != *(s_itr_ + 1)) - ) || - (!details::is_hex_digit(*(s_itr_ + 2))) || - (!details::is_hex_digit(*(s_itr_ + 3))) - ) - { - t.set_error(token::e_err_string,initial_itr,s_itr_,base_itr_); - token_list_.push_back(t); - return; - } - else - s_itr_ += 3; - } - - escaped = false; - } - - ++s_itr_; + return value_; } - - if (is_end(s_itr_)) + + inline typename expression_node::node_type type() const { - t.set_error(token::e_err_string,initial_itr,s_itr_,base_itr_); - token_list_.push_back(t); - - return; + return expression_node::e_constant; } - - if (!escaped_found) - t.set_string(initial_itr,s_itr_,base_itr_); - else + + inline expression_node* branch(const std::size_t&) const { - std::string parsed_string(initial_itr,s_itr_); - details::cleanup_escapes(parsed_string); - t.set_string(parsed_string, std::distance(base_itr_,initial_itr)); + return reinterpret_cast*>(0); } - - token_list_.push_back(t); - ++s_itr_; - - return; - } - #endif - - private: - - token_list_t token_list_; - token_list_itr_t token_itr_; - token_list_itr_t store_token_itr_; - token_t eof_token_; - const char* base_itr_; - const char* s_itr_; - const char* s_end_; - - friend class token_scanner; - friend class token_modifier; - friend class token_inserter; - friend class token_joiner; - }; - - class helper_interface - { - public: - - virtual void init() { } - virtual void reset() { } - virtual bool result() { return true; } - virtual std::size_t process(generator&) { return 0; } - virtual ~helper_interface() { } - }; - - class token_scanner : public helper_interface - { - public: - - virtual ~token_scanner() - {} - - explicit token_scanner(const std::size_t& stride) - : stride_(stride) - { - if (stride > 4) + + private: + + literal_node(literal_node&) {} + literal_node& operator=(literal_node&) { return *this; } + + const T value_; + }; + + template + struct range_pack; + + template + struct range_data_type; + + template + class range_interface + { + public: + + typedef range_pack range_t; + + virtual ~range_interface() + {} + + virtual range_t& range_ref() = 0; + + virtual const range_t& range_ref() const = 0; + }; + + template + class string_base_node + { + public: + + typedef range_data_type range_data_type_t; + + virtual ~string_base_node() + {} + + virtual std::string str () const = 0; + + virtual const char* base() const = 0; + + virtual std::size_t size() const = 0; + }; + + template + class string_literal_node : public expression_node , + public string_base_node, + public range_interface + { + public: + + typedef range_pack range_t; + + explicit string_literal_node(const std::string& v) + : value_(v) { - throw std::invalid_argument("token_scanner() - Invalid stride value"); + rp_.n0_c = std::make_pair(true,0); + rp_.n1_c = std::make_pair(true,v.size() - 1); + rp_.cache.first = rp_.n0_c.second; + rp_.cache.second = rp_.n1_c.second; } - } - - inline std::size_t process(generator& g) - { - if (g.token_list_.size() >= stride_) + + inline T value() const { - for (std::size_t i = 0; i < (g.token_list_.size() - stride_ + 1); ++i) - { - token t; - - switch (stride_) - { - case 1 : - { - const token& t0 = g.token_list_[i]; - - if (!operator()(t0)) - { - return i; - } - } - break; - - case 2 : - { - const token& t0 = g.token_list_[i ]; - const token& t1 = g.token_list_[i + 1]; - - if (!operator()(t0,t1)) - { - return i; - } - } - break; - - case 3 : - { - const token& t0 = g.token_list_[i ]; - const token& t1 = g.token_list_[i + 1]; - const token& t2 = g.token_list_[i + 2]; - - if (!operator()(t0,t1,t2)) - { - return i; - } - } - break; - - case 4 : - { - const token& t0 = g.token_list_[i ]; - const token& t1 = g.token_list_[i + 1]; - const token& t2 = g.token_list_[i + 2]; - const token& t3 = g.token_list_[i + 3]; - - if (!operator()(t0,t1,t2,t3)) - { - return i; - } - } - break; - } - } - } - - return (g.token_list_.size() - stride_ + 1); - } - - virtual bool operator()(const token&) - { - return false; - } - - virtual bool operator()(const token&, const token&) - { - return false; - } - - virtual bool operator()(const token&, const token&, const token&) - { - return false; - } - - virtual bool operator()(const token&, const token&, const token&, const token&) - { - return false; - } - - private: - - std::size_t stride_; - }; - - class token_modifier : public helper_interface - { - public: - - inline std::size_t process(generator& g) - { - std::size_t changes = 0; - - for (std::size_t i = 0; i < g.token_list_.size(); ++i) - { - if (modify(g.token_list_[i])) changes++; + return std::numeric_limits::quiet_NaN(); } - - return changes; - } - - virtual bool modify(token& t) = 0; - }; - - class token_inserter : public helper_interface - { - public: - - explicit token_inserter(const std::size_t& stride) - : stride_(stride) - { - if (stride > 5) + + inline typename expression_node::node_type type() const { - throw std::invalid_argument("token_inserter() - Invalid stride value"); + return expression_node::e_stringconst; } - } - - inline std::size_t process(generator& g) - { - if (g.token_list_.empty()) - return 0; - else if (g.token_list_.size() < stride_) - return 0; - - std::size_t changes = 0; - - for (std::size_t i = 0; i < (g.token_list_.size() - stride_ + 1); ++i) + + inline expression_node* branch(const std::size_t&) const { - int insert_index = -1; - token t; - - switch (stride_) - { - case 1 : insert_index = insert(g.token_list_[i],t); - break; - - case 2 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],t); - break; - - case 3 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],g.token_list_[i + 2],t); - break; - - case 4 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],g.token_list_[i + 2],g.token_list_[i + 3],t); - break; - - case 5 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],g.token_list_[i + 2],g.token_list_[i + 3],g.token_list_[i + 4],t); - break; - } - - if ((insert_index >= 0) && (insert_index <= (static_cast(stride_) + 1))) - { - g.token_list_.insert(g.token_list_.begin() + (i + insert_index),t); - changes++; - } + return reinterpret_cast*>(0); } - - return changes; - } - - inline virtual int insert(const token&, token& ) - { - return -1; - } - - inline virtual int insert(const token&, const token&, token&) - { - return -1; - } - - inline virtual int insert(const token&, const token&, const token&, token&) - { - return -1; - } - - inline virtual int insert(const token&, const token&, const token&, const token&, token&) - { - return -1; - } - - inline virtual int insert(const token&, const token&, const token&, const token&, const token&, token&) - { - return -1; - } - - private: - - std::size_t stride_; - }; - - class token_joiner : public helper_interface - { - public: - - token_joiner(const std::size_t& stride) - : stride_(stride) - {} - - inline std::size_t process(generator& g) - { - if (g.token_list_.empty()) - return 0; - - switch (stride_) + + std::string str() const { - case 2 : return process_stride_2(g); - case 3 : return process_stride_3(g); - default : return 0; + return value_; } - } - - virtual bool join(const token&, const token&, token&) { return false; } - virtual bool join(const token&, const token&, const token&, token&) { return false; } - - private: - - inline std::size_t process_stride_2(generator& g) - { - if (g.token_list_.size() < 2) - return 0; - - std::size_t changes = 0; - - for (std::size_t i = 0; i < g.token_list_.size() - 1; ++i) + + const char* base() const { - token t; - - while (join(g.token_list_[i],g.token_list_[i + 1],t)) - { - g.token_list_[i] = t; - g.token_list_.erase(g.token_list_.begin() + (i + 1)); - ++changes; - } + return value_.data(); } - - return changes; - } - - inline std::size_t process_stride_3(generator& g) - { - if (g.token_list_.size() < 3) - return 0; - - std::size_t changes = 0; - - for (std::size_t i = 0; i < g.token_list_.size() - 2; ++i) + + std::size_t size() const { - token t; - - while (join(g.token_list_[i],g.token_list_[i + 1],g.token_list_[i + 2],t)) - { - g.token_list_[i] = t; - g.token_list_.erase(g.token_list_.begin() + (i + 1), - g.token_list_.begin() + (i + 3)); - ++changes; - } + return value_.size(); } - - return changes; - } - - std::size_t stride_; - }; - - namespace helper - { - - inline void dump(lexer::generator& generator) - { - for (std::size_t i = 0; i < generator.size(); ++i) - { - lexer::token t = generator[i]; - printf("Token[%02d] @ %03d %6s --> '%s'\n", - static_cast(i), - static_cast(t.position), - t.to_str(t.type).c_str(), - t.value.c_str()); - } - } - - class commutative_inserter : public lexer::token_inserter - { - public: - - commutative_inserter() - : lexer::token_inserter(2) - {} - - inline void ignore_symbol(const std::string& symbol) + + range_t& range_ref() { - ignore_set_.insert(symbol); + return rp_; } - - inline int insert(const lexer::token& t0, const lexer::token& t1, lexer::token& new_token) + + const range_t& range_ref() const { - bool match = false; - new_token.type = lexer::token::e_mul; - new_token.value = "*"; - new_token.position = t1.position; - - if (t0.type == lexer::token::e_symbol) - { - if (ignore_set_.end() != ignore_set_.find(t0.value)) - { - return -1; - } - else if (!t0.value.empty() && ('$' == t0.value[0])) - { - return -1; - } - } - - if (t1.type == lexer::token::e_symbol) - { - if (ignore_set_.end() != ignore_set_.find(t1.value)) - { - return -1; - } - } - if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_symbol )) match = true; - else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lbracket )) match = true; - else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lcrlbracket)) match = true; - else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lsqrbracket)) match = true; - else if ((t0.type == lexer::token::e_symbol ) && (t1.type == lexer::token::e_number )) match = true; - else if ((t0.type == lexer::token::e_rbracket ) && (t1.type == lexer::token::e_number )) match = true; - else if ((t0.type == lexer::token::e_rcrlbracket) && (t1.type == lexer::token::e_number )) match = true; - else if ((t0.type == lexer::token::e_rsqrbracket) && (t1.type == lexer::token::e_number )) match = true; - else if ((t0.type == lexer::token::e_rbracket ) && (t1.type == lexer::token::e_symbol )) match = true; - else if ((t0.type == lexer::token::e_rcrlbracket) && (t1.type == lexer::token::e_symbol )) match = true; - else if ((t0.type == lexer::token::e_rsqrbracket) && (t1.type == lexer::token::e_symbol )) match = true; - - return (match) ? 1 : -1; + return rp_; } - - private: - - std::set ignore_set_; - }; - - class operator_joiner : public token_joiner - { - public: - - operator_joiner(const std::size_t& stride) - : token_joiner(stride) + + private: + + string_literal_node(const string_literal_node&); + string_literal_node& operator=(const string_literal_node&); + + const std::string value_; + range_t rp_; + }; + + template + class unary_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + unary_node(const operator_type& opr, + expression_ptr brnch) + : operation_(opr), + branch_(brnch), + branch_deletable_(branch_deletable(branch_)) {} - - inline bool join(const lexer::token& t0, const lexer::token& t1, lexer::token& t) - { - // ': =' --> ':=' - if ((t0.type == lexer::token::e_colon) && (t1.type == lexer::token::e_eq)) - { - t.type = lexer::token::e_assign; - t.value = ":="; - t.position = t0.position; - return true; - } - // '+ =' --> '+=' - else if ((t0.type == lexer::token::e_add) && (t1.type == lexer::token::e_eq)) - { - t.type = lexer::token::e_addass; - t.value = "+="; - t.position = t0.position; - return true; - } - // '- =' --> '-=' - else if ((t0.type == lexer::token::e_sub) && (t1.type == lexer::token::e_eq)) - { - t.type = lexer::token::e_subass; - t.value = "-="; - t.position = t0.position; - return true; - } - // '* =' --> '*=' - else if ((t0.type == lexer::token::e_mul) && (t1.type == lexer::token::e_eq)) - { - t.type = lexer::token::e_mulass; - t.value = "*="; - t.position = t0.position; - return true; - } - // '/ =' --> '/=' - else if ((t0.type == lexer::token::e_div) && (t1.type == lexer::token::e_eq)) - { - t.type = lexer::token::e_divass; - t.value = "/="; - t.position = t0.position; - return true; - } - // '% =' --> '%=' - else if ((t0.type == lexer::token::e_mod) && (t1.type == lexer::token::e_eq)) - { - t.type = lexer::token::e_modass; - t.value = "%="; - t.position = t0.position; - return true; - } - // '> =' --> '>=' - else if ((t0.type == lexer::token::e_gt) && (t1.type == lexer::token::e_eq)) - { - t.type = lexer::token::e_gte; - t.value = ">="; - t.position = t0.position; - return true; - } - // '< =' --> '<=' - else if ((t0.type == lexer::token::e_lt) && (t1.type == lexer::token::e_eq)) - { - t.type = lexer::token::e_lte; - t.value = "<="; - t.position = t0.position; - return true; - } - // '= =' --> '==' - else if ((t0.type == lexer::token::e_eq) && (t1.type == lexer::token::e_eq)) - { - t.type = lexer::token::e_eq; - t.value = "=="; - t.position = t0.position; - return true; - } - // '! =' --> '!=' - else if ((static_cast(t0.type) == '!') && (t1.type == lexer::token::e_eq)) - { - t.type = lexer::token::e_ne; - t.value = "!="; - t.position = t0.position; - return true; - } - // '< >' --> '<>' - else if ((t0.type == lexer::token::e_lt) && (t1.type == lexer::token::e_gt)) - { - t.type = lexer::token::e_ne; - t.value = "<>"; - t.position = t0.position; - return true; - } - // '<= >' --> '<=>' - else if ((t0.type == lexer::token::e_lte) && (t1.type == lexer::token::e_gt)) - { - t.type = lexer::token::e_swap; - t.value = "<=>"; - t.position = t0.position; - return true; - } - else - return false; + + ~unary_node() + { + if (branch_ && branch_deletable_) + { + delete branch_; + branch_ = 0; + } } - - inline bool join(const lexer::token& t0, const lexer::token& t1, const lexer::token& t2, lexer::token& t) - { - // '[ * ]' --> '[*]' - if ( - (t0.type == lexer::token::e_lsqrbracket) && - (t1.type == lexer::token::e_mul ) && - (t2.type == lexer::token::e_rsqrbracket) - ) - { - t.type = lexer::token::e_symbol; - t.value = "[*]"; - t.position = t0.position; - - return true; - } - else - return false; + + inline T value() const + { + const T arg = branch_->value(); + return numeric::process(operation_,arg); } - }; - - class bracket_checker : public lexer::token_scanner - { - public: - - bracket_checker() - : token_scanner(1), - state_(true) - {} - - bool result() - { - if (!stack_.empty()) - { - lexer::token t; - t.value = stack_.top().first; - t.position = stack_.top().second; - error_token_ = t; - state_ = false; - - return false; - } - else - return state_; + + inline typename expression_node::node_type type() const + { + return expression_node::e_unary; } - - lexer::token error_token() + + inline operator_type operation() const { - return error_token_; + return operation_; } - - void reset() + + inline expression_node* branch(const std::size_t&) const { - // Why? because msvc doesn't support swap properly. - stack_ = std::stack >(); - state_ = true; - error_token_.clear(); + return branch_; } - - bool operator()(const lexer::token& t) - { - if ( - !t.value.empty() && - (lexer::token::e_string != t.type) && - (lexer::token::e_symbol != t.type) && - exprtk::details::is_bracket(t.value[0]) - ) - { - char c = t.value[0]; - - if (t.type == lexer::token::e_lbracket) stack_.push(std::make_pair(')',t.position)); - else if (t.type == lexer::token::e_lcrlbracket) stack_.push(std::make_pair('}',t.position)); - else if (t.type == lexer::token::e_lsqrbracket) stack_.push(std::make_pair(']',t.position)); - else if (exprtk::details::is_right_bracket(c)) - { - if (stack_.empty()) - { - state_ = false; - error_token_ = t; - - return false; - } - else if (c != stack_.top().first) - { - state_ = false; - error_token_ = t; - - return false; - } - else - stack_.pop(); - } - } - - return true; + + inline void release() + { + branch_deletable_ = false; } - - private: - - bool state_; - std::stack > stack_; - lexer::token error_token_; - }; - - class numeric_checker : public lexer::token_scanner - { - public: - - numeric_checker() - : token_scanner (1), - current_index_(0) + + protected: + + operator_type operation_; + expression_ptr branch_; + bool branch_deletable_; + }; + + template + struct construct_branch_pair + { + template + static inline void process(std::pair*,bool> (&)[N], expression_node*) {} - - bool result() - { - return error_list_.empty(); + }; + + template + struct construct_branch_pair + { + template + static inline void process(std::pair*,bool> (&branch)[N], expression_node* b) + { + if (b) + { + branch[D] = std::make_pair(b,branch_deletable(b)); + } } - - void reset() + }; + + template + inline void init_branches(std::pair*,bool> (&branch)[N], + expression_node* b0, + expression_node* b1 = reinterpret_cast*>(0), + expression_node* b2 = reinterpret_cast*>(0), + expression_node* b3 = reinterpret_cast*>(0), + expression_node* b4 = reinterpret_cast*>(0), + expression_node* b5 = reinterpret_cast*>(0), + expression_node* b6 = reinterpret_cast*>(0), + expression_node* b7 = reinterpret_cast*>(0), + expression_node* b8 = reinterpret_cast*>(0), + expression_node* b9 = reinterpret_cast*>(0)) + { + construct_branch_pair 0)>::process(branch,b0); + construct_branch_pair 1)>::process(branch,b1); + construct_branch_pair 2)>::process(branch,b2); + construct_branch_pair 3)>::process(branch,b3); + construct_branch_pair 4)>::process(branch,b4); + construct_branch_pair 5)>::process(branch,b5); + construct_branch_pair 6)>::process(branch,b6); + construct_branch_pair 7)>::process(branch,b7); + construct_branch_pair 8)>::process(branch,b8); + construct_branch_pair 9)>::process(branch,b9); + } + + struct cleanup_branches + { + template + static inline void execute(std::pair*,bool> (&branch)[N]) + { + for (std::size_t i = 0; i < N; ++i) + { + if (branch[i].first && branch[i].second) + { + delete branch[i].first; + branch[i].first = 0; + } + } + } + + template class Sequence> + static inline void execute(Sequence*,bool>,Allocator>& branch) + { + for (std::size_t i = 0; i < branch.size(); ++i) + { + if (branch[i].first && branch[i].second) + { + delete branch[i].first; + branch[i].first = 0; + } + } + } + }; + + template + class binary_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef std::pair branch_t; + + binary_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : operation_(opr) + { + init_branches<2>(branch_,branch0,branch1); + } + + ~binary_node() + { + cleanup_branches::execute(branch_); + } + + inline T value() const + { + const T arg0 = branch_[0].first->value(); + const T arg1 = branch_[1].first->value(); + return numeric::process(operation_,arg0,arg1); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_binary; + } + + inline operator_type operation() + { + return operation_; + } + + inline expression_node* branch(const std::size_t& index = 0) const + { + if (0 == index) + return branch_[0].first; + else if (1 == index) + return branch_[1].first; + else + return reinterpret_cast(0); + } + + protected: + + operator_type operation_; + branch_t branch_[2]; + }; + + template + class binary_ext_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef std::pair branch_t; + + binary_ext_node(expression_ptr branch0, expression_ptr branch1) { - error_list_.clear(); - current_index_ = 0; + init_branches<2>(branch_,branch0,branch1); } - - bool operator()(const lexer::token& t) + + ~binary_ext_node() { - if (token::e_number == t.type) - { - double v; - - if (!exprtk::details::string_to_real(t.value,v)) - { - error_list_.push_back(current_index_); - } - } - - ++current_index_; - - return true; + cleanup_branches::execute(branch_); } - - std::size_t error_count() const + + inline T value() const { - return error_list_.size(); + const T arg0 = branch_[0].first->value(); + const T arg1 = branch_[1].first->value(); + + return Operation::process(arg0,arg1); } - - std::size_t error_index(const std::size_t& i) + + inline typename expression_node::node_type type() const { - if (i < error_list_.size()) - return error_list_[i]; - else - return std::numeric_limits::max(); + return expression_node::e_binary_ext; } - - void clear_errors() + + inline operator_type operation() { - error_list_.clear(); + return Operation::operation(); } - - private: - - std::size_t current_index_; - std::vector error_list_; - }; - - class symbol_replacer : public lexer::token_modifier - { - private: - - typedef std::map,details::ilesscompare> replace_map_t; - - public: - - bool remove(const std::string& target_symbol) + + inline expression_node* branch(const std::size_t& index = 0) const { - replace_map_t::iterator itr = replace_map_.find(target_symbol); - - if (replace_map_.end() == itr) - return false; - - replace_map_.erase(itr); - - return true; + if (0 == index) + return branch_[0].first; + else if (1 == index) + return branch_[1].first; + else + return reinterpret_cast(0); } - - bool add_replace(const std::string& target_symbol, - const std::string& replace_symbol, - const lexer::token::token_type token_type = lexer::token::e_symbol) + + protected: + + branch_t branch_[2]; + }; + + template + class trinary_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef std::pair branch_t; + + trinary_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1, + expression_ptr branch2) + : operation_(opr) + { + init_branches<3>(branch_,branch0,branch1,branch2); + } + + ~trinary_node() + { + cleanup_branches::execute(branch_); + } + + inline T value() const + { + const T arg0 = branch_[0].first->value(); + const T arg1 = branch_[1].first->value(); + const T arg2 = branch_[2].first->value(); + + switch (operation_) + { + case e_inrange : return (arg1 < arg0) ? T(0) : ((arg1 > arg2) ? T(0) : T(1)); + + case e_clamp : return (arg1 < arg0) ? arg0 : (arg1 > arg2 ? arg2 : arg1); + + case e_iclamp : if ((arg1 <= arg0) || (arg1 >= arg2)) + return arg1; + else + return ((T(2) * arg1 <= (arg2 + arg0)) ? arg0 : arg2); + + default : { + exprtk_debug(("trinary_node::value() - Error: Invalid operation\n")); + return std::numeric_limits::quiet_NaN(); + } + } + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_trinary; + } + + protected: + + operator_type operation_; + branch_t branch_[3]; + }; + + template + class quaternary_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef std::pair branch_t; + + quaternary_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1, + expression_ptr branch2, + expression_ptr branch3) + : operation_(opr) { - replace_map_t::iterator itr = replace_map_.find(target_symbol); - - if (replace_map_.end() != itr) - { - return false; - } - - replace_map_[target_symbol] = std::make_pair(replace_symbol,token_type); - - return true; + init_branches<4>(branch_,branch0,branch1,branch2,branch3); } - - void clear() + + ~quaternary_node() { - replace_map_.clear(); + cleanup_branches::execute(branch_); } - - private: - - bool modify(lexer::token& t) + + inline T value() const { - if (lexer::token::e_symbol == t.type) - { - if (replace_map_.empty()) - return false; - - replace_map_t::iterator itr = replace_map_.find(t.value); - - if (replace_map_.end() != itr) - { - t.value = itr->second.first; - t.type = itr->second.second; - - return true; - } - } - - return false; + return std::numeric_limits::quiet_NaN(); } - - replace_map_t replace_map_; - }; - - class sequence_validator : public lexer::token_scanner - { - private: - - typedef std::pair token_pair_t; - typedef std::set set_t; - - public: - - sequence_validator() - : lexer::token_scanner(2) - { - add_invalid(lexer::token::e_number ,lexer::token::e_number ); - add_invalid(lexer::token::e_string ,lexer::token::e_string ); - add_invalid(lexer::token::e_number ,lexer::token::e_string ); - add_invalid(lexer::token::e_string ,lexer::token::e_number ); - add_invalid(lexer::token::e_string ,lexer::token::e_colon ); - add_invalid(lexer::token::e_string ,lexer::token::e_ternary); - add_invalid(lexer::token::e_colon ,lexer::token::e_string ); - add_invalid(lexer::token::e_ternary,lexer::token::e_string ); - add_invalid_set1(lexer::token::e_assign ); - add_invalid_set1(lexer::token::e_shr ); - add_invalid_set1(lexer::token::e_shl ); - add_invalid_set1(lexer::token::e_lte ); - add_invalid_set1(lexer::token::e_ne ); - add_invalid_set1(lexer::token::e_gte ); - add_invalid_set1(lexer::token::e_lt ); - add_invalid_set1(lexer::token::e_gt ); - add_invalid_set1(lexer::token::e_eq ); - add_invalid_set1(lexer::token::e_comma ); - add_invalid_set1(lexer::token::e_add ); - add_invalid_set1(lexer::token::e_sub ); - add_invalid_set1(lexer::token::e_div ); - add_invalid_set1(lexer::token::e_mul ); - add_invalid_set1(lexer::token::e_mod ); - add_invalid_set1(lexer::token::e_pow ); - add_invalid_set1(lexer::token::e_colon ); - add_invalid_set1(lexer::token::e_ternary); + + inline typename expression_node::node_type type() const + { + return expression_node::e_quaternary; } - - bool result() + + protected: + + operator_type operation_; + branch_t branch_[4]; + }; + + template + class conditional_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + conditional_node(expression_ptr test, + expression_ptr consequent, + expression_ptr alternative) + : test_(test), + consequent_(consequent), + alternative_(alternative), + test_deletable_(branch_deletable(test_)), + consequent_deletable_(branch_deletable(consequent_)), + alternative_deletable_(branch_deletable(alternative_)) + {} + + ~conditional_node() + { + if (test_ && test_deletable_ ) delete test_; + if (consequent_ && consequent_deletable_ ) delete consequent_; + if (alternative_ && alternative_deletable_) delete alternative_; + } + + inline T value() const + { + if (is_true(test_)) + return consequent_->value(); + else + return alternative_->value(); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_conditional; + } + + private: + + expression_ptr test_; + expression_ptr consequent_; + expression_ptr alternative_; + bool test_deletable_; + bool consequent_deletable_; + bool alternative_deletable_; + }; + + template + class cons_conditional_node : public expression_node + { + public: + + // Consequent only conditional statement node + typedef expression_node* expression_ptr; + + cons_conditional_node(expression_ptr test, + expression_ptr consequent) + : test_(test), + consequent_(consequent), + test_deletable_(branch_deletable(test_)), + consequent_deletable_(branch_deletable(consequent_)) + {} + + ~cons_conditional_node() { - return error_list_.empty(); + if (test_ && test_deletable_ ) delete test_; + if (consequent_ && consequent_deletable_) delete consequent_; } - - bool operator()(const lexer::token& t0, const lexer::token& t1) + + inline T value() const { - set_t::value_type p = std::make_pair(t0.type,t1.type); - - if (invalid_bracket_check(t0.type,t1.type)) - { - error_list_.push_back(std::make_pair(t0,t1)); - } - else if (invalid_comb_.find(p) != invalid_comb_.end()) - { - error_list_.push_back(std::make_pair(t0,t1)); - } - - return true; + if (is_true(test_)) + return consequent_->value(); + else + return std::numeric_limits::quiet_NaN(); } - - std::size_t error_count() + + inline typename expression_node::node_type type() const { - return error_list_.size(); + return expression_node::e_conditional; } - - std::pair error(const std::size_t index) - { - if (index < error_list_.size()) - { - return error_list_[index]; - } - else - { - static const lexer::token error_token; - return std::make_pair(error_token,error_token); - } + + private: + + expression_ptr test_; + expression_ptr consequent_; + bool test_deletable_; + bool consequent_deletable_; + }; + +#ifndef exprtk_disable_break_continue + template + class break_exception + { + public: + + break_exception(const T& v) + : value(v) + {} + + T value; + }; + + class continue_exception + {}; + + template + class break_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + break_node(expression_ptr ret = expression_ptr(0)) + : return_(ret), + return_deletable_(branch_deletable(return_)) + {} + + ~break_node() + { + if (return_deletable_) + { + delete return_; + } } - - void clear_errors() + + inline T value() const { - error_list_.clear(); + throw break_exception(return_ ? return_->value() : std::numeric_limits::quiet_NaN()); +#ifndef _MSC_VER + return std::numeric_limits::quiet_NaN(); +#endif } - - private: - - void add_invalid(lexer::token::token_type base, lexer::token::token_type t) + + inline typename expression_node::node_type type() const { - invalid_comb_.insert(std::make_pair(base,t)); + return expression_node::e_break; } - - void add_invalid_set1(lexer::token::token_type t) - { - add_invalid(t,lexer::token::e_assign); - add_invalid(t,lexer::token::e_shr ); - add_invalid(t,lexer::token::e_shl ); - add_invalid(t,lexer::token::e_lte ); - add_invalid(t,lexer::token::e_ne ); - add_invalid(t,lexer::token::e_gte ); - add_invalid(t,lexer::token::e_lt ); - add_invalid(t,lexer::token::e_gt ); - add_invalid(t,lexer::token::e_eq ); - add_invalid(t,lexer::token::e_comma ); - add_invalid(t,lexer::token::e_div ); - add_invalid(t,lexer::token::e_mul ); - add_invalid(t,lexer::token::e_mod ); - add_invalid(t,lexer::token::e_pow ); - add_invalid(t,lexer::token::e_colon ); + + private: + + expression_ptr return_; + bool return_deletable_; + }; + + template + class continue_node : public expression_node + { + public: + + inline T value() const + { + throw continue_exception(); +#ifndef _MSC_VER + return std::numeric_limits::quiet_NaN(); +#endif } - - bool invalid_bracket_check(lexer::token::token_type base, lexer::token::token_type t) - { - if (details::is_right_bracket(static_cast(base))) - { - switch (t) - { - case lexer::token::e_assign : return (']' != base); - case lexer::token::e_string : return true; - default : return false; - } - } - else if (details::is_left_bracket(static_cast(base))) - { - if (details::is_right_bracket(static_cast(t))) - return false; - else if (details::is_left_bracket(static_cast(t))) - return false; - else - { - switch (t) - { - case lexer::token::e_number : return false; - case lexer::token::e_symbol : return false; - case lexer::token::e_string : return false; - case lexer::token::e_add : return false; - case lexer::token::e_sub : return false; - case lexer::token::e_colon : return false; - case lexer::token::e_ternary : return false; - default : return true; - } - } - } - else if (details::is_right_bracket(static_cast(t))) - { - switch (base) - { - case lexer::token::e_number : return false; - case lexer::token::e_symbol : return false; - case lexer::token::e_string : return false; - case lexer::token::e_eof : return false; - case lexer::token::e_colon : return false; - case lexer::token::e_ternary : return false; - default : return true; - } - } - else if (details::is_left_bracket(static_cast(t))) - { - switch (base) - { - case lexer::token::e_rbracket : return true; - case lexer::token::e_rsqrbracket : return true; - case lexer::token::e_rcrlbracket : return true; - default : return false; - } - } - - return false; + + inline typename expression_node::node_type type() const + { + return expression_node::e_break; } - - set_t invalid_comb_; - std::vector > error_list_; - }; - - struct helper_assembly - { - inline bool register_scanner(lexer::token_scanner* scanner) - { - if (token_scanner_list.end() != std::find(token_scanner_list.begin(), - token_scanner_list.end(), - scanner)) - { - return false; - } - - token_scanner_list.push_back(scanner); - return true; + }; +#endif + + template + class while_loop_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + while_loop_node(expression_ptr condition, expression_ptr loop_body) + : condition_(condition), + loop_body_(loop_body), + condition_deletable_(branch_deletable(condition_)), + loop_body_deletable_(branch_deletable(loop_body_)) + {} + + ~while_loop_node() + { + if (condition_ && condition_deletable_) + { + delete condition_; + } + + if (loop_body_ && loop_body_deletable_) + { + delete loop_body_; + } + } + + inline T value() const + { + T result = T(0); + + while (is_true(condition_)) + { + result = loop_body_->value(); + } + + return result; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_while; + } + + private: + + expression_ptr condition_; + expression_ptr loop_body_; + bool condition_deletable_; + bool loop_body_deletable_; + }; + + template + class repeat_until_loop_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + repeat_until_loop_node(expression_ptr condition, expression_ptr loop_body) + : condition_(condition), + loop_body_(loop_body), + condition_deletable_(branch_deletable(condition_)), + loop_body_deletable_(branch_deletable(loop_body_)) + {} + + ~repeat_until_loop_node() + { + if (condition_ && condition_deletable_) + { + delete condition_; + } + + if (loop_body_ && loop_body_deletable_) + { + delete loop_body_; + } + } + + inline T value() const + { + T result = T(0); + + do + { + result = loop_body_->value(); + } + while (is_false(condition_)); + + return result; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_repeat; + } + + private: + + expression_ptr condition_; + expression_ptr loop_body_; + bool condition_deletable_; + bool loop_body_deletable_; + }; + + template + class for_loop_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + for_loop_node(expression_ptr initialiser, + expression_ptr condition, + expression_ptr incrementor, + expression_ptr loop_body) + : initialiser_(initialiser), + condition_ (condition), + incrementor_(incrementor), + loop_body_ (loop_body), + initialiser_deletable_(branch_deletable(initialiser_)), + condition_deletable_ (branch_deletable(condition_ )), + incrementor_deletable_(branch_deletable(incrementor_)), + loop_body_deletable_ (branch_deletable(loop_body_ )) + {} + + ~for_loop_node() + { + if (initialiser_ && initialiser_deletable_) + { + delete initialiser_; + } + + if (condition_ && condition_deletable_) + { + delete condition_; + } + + if (incrementor_ && incrementor_deletable_) + { + delete incrementor_; + } + + if (loop_body_ && loop_body_deletable_) + { + delete loop_body_; + } + } + + inline T value() const + { + T result = T(0); + + if (initialiser_) + initialiser_->value(); + + if (incrementor_) + { + while (is_true(condition_)) + { + result = loop_body_->value(); + incrementor_->value(); + } + } + else + { + while (is_true(condition_)) + { + result = loop_body_->value(); + } + } + + return result; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_for; + } + + private: + + expression_ptr initialiser_; + expression_ptr condition_ ; + expression_ptr incrementor_; + expression_ptr loop_body_ ; + bool initialiser_deletable_; + bool condition_deletable_ ; + bool incrementor_deletable_; + bool loop_body_deletable_ ; + }; + +#ifndef exprtk_disable_break_continue + template + class while_loop_bc_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + while_loop_bc_node(expression_ptr condition, expression_ptr loop_body) + : condition_(condition), + loop_body_(loop_body), + condition_deletable_(branch_deletable(condition_)), + loop_body_deletable_(branch_deletable(loop_body_)) + {} + + ~while_loop_bc_node() + { + if (condition_ && condition_deletable_) + { + delete condition_; + } + + if (loop_body_ && loop_body_deletable_) + { + delete loop_body_; + } + } + + inline T value() const + { + T result = T(0); + while (is_true(condition_)) + { + try + { + result = loop_body_->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + return result; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_while; + } + + private: + + expression_ptr condition_; + expression_ptr loop_body_; + bool condition_deletable_; + bool loop_body_deletable_; + }; + + template + class repeat_until_loop_bc_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + repeat_until_loop_bc_node(expression_ptr condition, expression_ptr loop_body) + : condition_(condition), + loop_body_(loop_body), + condition_deletable_(branch_deletable(condition_)), + loop_body_deletable_(branch_deletable(loop_body_)) + {} + + ~repeat_until_loop_bc_node() + { + if (condition_ && condition_deletable_) + { + delete condition_; + } + + if (loop_body_ && loop_body_deletable_) + { + delete loop_body_; + } + } + + inline T value() const + { + T result = T(0); + + do + { + try + { + result = loop_body_->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + while (is_false(condition_)); + + return result; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_repeat; + } + + private: + + expression_ptr condition_; + expression_ptr loop_body_; + bool condition_deletable_; + bool loop_body_deletable_; + }; + + template + class for_loop_bc_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + for_loop_bc_node(expression_ptr initialiser, + expression_ptr condition, + expression_ptr incrementor, + expression_ptr loop_body) + : initialiser_(initialiser), + condition_ (condition ), + incrementor_(incrementor), + loop_body_ (loop_body ), + initialiser_deletable_(branch_deletable(initialiser_)), + condition_deletable_ (branch_deletable(condition_ )), + incrementor_deletable_(branch_deletable(incrementor_)), + loop_body_deletable_ (branch_deletable(loop_body_ )) + {} + + ~for_loop_bc_node() + { + if (initialiser_ && initialiser_deletable_) + { + delete initialiser_; + } + + if (condition_ && condition_deletable_) + { + delete condition_; + } + + if (incrementor_ && incrementor_deletable_) + { + delete incrementor_; + } + + if (loop_body_ && loop_body_deletable_) + { + delete loop_body_; + } + } + + inline T value() const + { + T result = T(0); + + if (initialiser_) + initialiser_->value(); + + if (incrementor_) + { + while (is_true(condition_)) + { + try + { + result = loop_body_->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + + incrementor_->value(); + } + } + else + { + while (is_true(condition_)) + { + try + { + result = loop_body_->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + } + + return result; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_for; + } + + private: + + expression_ptr initialiser_; + expression_ptr condition_ ; + expression_ptr incrementor_; + expression_ptr loop_body_ ; + bool initialiser_deletable_; + bool condition_deletable_ ; + bool incrementor_deletable_; + bool loop_body_deletable_ ; + }; +#endif + + template + class switch_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + template class Sequence> + switch_node(const Sequence& arg_list) + { + if (1 != (arg_list.size() & 1)) + return; + + arg_list_.resize(arg_list.size()); + delete_branch_.resize(arg_list.size()); + + for (std::size_t i = 0; i < arg_list.size(); ++i) + { + if (arg_list[i]) + { + arg_list_[i] = arg_list[i]; + delete_branch_[i] = static_cast(branch_deletable(arg_list_[i]) ? 1 : 0); + } + else + { + arg_list_.clear(); + delete_branch_.clear(); + return; + } + } + } + + ~switch_node() + { + for (std::size_t i = 0; i < arg_list_.size(); ++i) + { + if (arg_list_[i] && delete_branch_[i]) + { + delete arg_list_[i]; + arg_list_[i] = 0; + } + } + } + + inline T value() const + { + if (!arg_list_.empty()) + { + const std::size_t upper_bound = (arg_list_.size() - 1); + + for (std::size_t i = 0; i < upper_bound; i += 2) + { + expression_ptr condition = arg_list_[i ]; + expression_ptr consequent = arg_list_[i + 1]; + + if (is_true(condition)) + { + return consequent->value(); + } + } + + return arg_list_[upper_bound]->value(); + } + else + return std::numeric_limits::quiet_NaN(); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_switch; + } + + protected: + + std::vector arg_list_; + std::vector delete_branch_; + }; + + template + class switch_n_node : public switch_node + { + public: + + typedef expression_node* expression_ptr; + + template class Sequence> + switch_n_node(const Sequence& arg_list) + : switch_node(arg_list) + {} + + inline T value() const + { + return Switch_N::process(switch_node::arg_list_); } - - inline bool register_modifier(lexer::token_modifier* modifier) - { - if (token_modifier_list.end() != std::find(token_modifier_list.begin(), - token_modifier_list.end(), - modifier)) - { - return false; - } - - token_modifier_list.push_back(modifier); - return true; + }; + + template + class multi_switch_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + template class Sequence> + multi_switch_node(const Sequence& arg_list) + { + if (0 != (arg_list.size() & 1)) + return; + + arg_list_.resize(arg_list.size()); + delete_branch_.resize(arg_list.size()); + + for (std::size_t i = 0; i < arg_list.size(); ++i) + { + if (arg_list[i]) + { + arg_list_[i] = arg_list[i]; + delete_branch_[i] = static_cast(branch_deletable(arg_list_[i]) ? 1 : 0); + } + else + { + arg_list_.clear(); + delete_branch_.clear(); + return; + } + } + } + + ~multi_switch_node() + { + for (std::size_t i = 0; i < arg_list_.size(); ++i) + { + if (arg_list_[i] && delete_branch_[i]) + { + delete arg_list_[i]; + arg_list_[i] = 0; + } + } + } + + inline T value() const + { + T result = T(0); + + if (arg_list_.empty()) + { + return std::numeric_limits::quiet_NaN(); + } + + const std::size_t upper_bound = (arg_list_.size() - 1); + + for (std::size_t i = 0; i < upper_bound; i += 2) + { + expression_ptr condition = arg_list_[i ]; + expression_ptr consequent = arg_list_[i + 1]; + + if (is_true(condition)) + { + result = consequent->value(); + } + } + + return result; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_mswitch; + } + + private: + + std::vector arg_list_; + std::vector delete_branch_; + }; + + template + class ivariable + { + public: + + virtual ~ivariable() + {} + + virtual T& ref() = 0; + virtual const T& ref() const = 0; + }; + + template + class variable_node : public expression_node, + public ivariable + { + public: + + static T null_value; + + explicit variable_node() + : value_(&null_value), + delete_value_(false) + {} + + variable_node(T& v) + : value_(&v), + delete_value_(false) + {} + + ~variable_node() + { + if (delete_value_) + { + delete value_; + } } - - inline bool register_joiner(lexer::token_joiner* joiner) - { - if (token_joiner_list.end() != std::find(token_joiner_list.begin(), - token_joiner_list.end(), - joiner)) - { - return false; - } - - token_joiner_list.push_back(joiner); - return true; + + inline bool operator <(const variable_node& v) const + { + return this < (&v); } - - inline bool register_inserter(lexer::token_inserter* inserter) - { - if (token_inserter_list.end() != std::find(token_inserter_list.begin(), - token_inserter_list.end(), - inserter)) - { - return false; - } - - token_inserter_list.push_back(inserter); - return true; + + inline T value() const + { + return (*value_); } - - inline bool run_modifiers(lexer::generator& g) + + inline T& ref() { - error_token_modifier = reinterpret_cast(0); - bool result = true; - - for (std::size_t i = 0; i < token_modifier_list.size(); ++i) - { - lexer::token_modifier& modifier = (*token_modifier_list[i]); - - modifier.reset(); - modifier.process(g); - - if (!modifier.result()) - { - error_token_modifier = token_modifier_list[i]; - return false; - } - } - - return result; + return (*value_); } - - inline bool run_joiners(lexer::generator& g) + + inline const T& ref() const { - error_token_joiner = reinterpret_cast(0); - bool result = true; - - for (std::size_t i = 0; i < token_joiner_list.size(); ++i) - { - lexer::token_joiner& joiner = (*token_joiner_list[i]); - - joiner.reset(); - joiner.process(g); - - if (!joiner.result()) - { - error_token_joiner = token_joiner_list[i]; - return false; - } - } - - return result; + return (*value_); } - - inline bool run_inserters(lexer::generator& g) + + inline typename expression_node::node_type type() const { - error_token_inserter = reinterpret_cast(0); - bool result = true; - - for (std::size_t i = 0; i < token_inserter_list.size(); ++i) - { - lexer::token_inserter& inserter = (*token_inserter_list[i]); - - inserter.reset(); - inserter.process(g); - - if (!inserter.result()) - { - error_token_inserter = token_inserter_list[i]; - return false; - } - } - - return result; + return expression_node::e_variable; } - - inline bool run_scanners(lexer::generator& g) + + inline bool& delete_value() { - error_token_scanner = reinterpret_cast(0); - bool result = true; - - for (std::size_t i = 0; i < token_scanner_list.size(); ++i) - { - lexer::token_scanner& scanner = (*token_scanner_list[i]); - - scanner.reset(); - scanner.process(g); - - if (!scanner.result()) - { - error_token_scanner = token_scanner_list[i]; - return false; - } - } - - return result; + return delete_value_; } - - std::vector token_scanner_list; - std::vector token_modifier_list; - std::vector token_joiner_list; - std::vector token_inserter_list; - - lexer::token_scanner* error_token_scanner; - lexer::token_modifier* error_token_modifier; - lexer::token_joiner* error_token_joiner; - lexer::token_inserter* error_token_inserter; - }; - } - } - - template - struct type_store - { - enum store_type - { - e_unknown, - e_scalar, - e_vector, - e_string - }; - - type_store() - : size(0), - data(0), - type(e_unknown) - {} - - std::size_t size; - void* data; - store_type type; - - class parameter_list - { - public: - - parameter_list(std::vector& pl) - : parameter_list_(pl) - {} - - inline bool empty() const - { - return parameter_list_.empty(); - } - - inline std::size_t size() const - { - return parameter_list_.size(); - } - - inline type_store& operator[](const std::size_t& index) - { - return parameter_list_[index]; - } - - inline const type_store& operator[](const std::size_t& index) const - { - return parameter_list_[index]; - } - - inline type_store& front() - { - return parameter_list_[0]; - } - - inline const type_store& front() const - { - return parameter_list_[0]; - } - - inline type_store& back() - { - return parameter_list_[size() - 1]; - } - - inline const type_store& back() const - { - return parameter_list_[size() - 1]; - } - - private: - - std::vector& parameter_list_; - }; - - template - struct type_view - { - typedef type_store type_store_t; - typedef ViewType value_t; - - type_view(type_store_t& ts) - : ts_(ts), - data_(reinterpret_cast(ts_.data)) - {} - - inline std::size_t size() const - { - return ts_.size; - } - - inline value_t& operator[](const std::size_t& i) - { - return data_[i]; - } - - inline const value_t& operator[](const std::size_t& i) const - { - return data_[i]; - } - - inline const value_t* begin() const { return data_; } - inline value_t* begin() { return data_; } - - inline const value_t* end() const { return data_ + ts_.size; } - inline value_t* end() { return data_ + ts_.size; } - - type_store_t& ts_; - value_t* data_; - }; - - typedef type_view vector_view; - typedef type_view string_view; - - struct scalar_view - { - typedef type_store type_store_t; - typedef T value_t; - - scalar_view(type_store_t& ts) - : v_(*reinterpret_cast(ts.data)) - {} - - value_t& operator()() - { - return v_; - } - - const value_t& operator()() const - { - return v_; - } - - T& v_; - }; - }; - - template - inline std::string to_str(const StringView& view) - { - return std::string(view.begin(),view.size()); - } - - namespace details - { - enum operator_type - { - e_default , e_null , e_add , e_sub , - e_mul , e_div , e_mod , e_pow , - e_atan2 , e_min , e_max , e_avg , - e_sum , e_prod , e_lt , e_lte , - e_eq , e_equal , e_ne , e_nequal , - e_gte , e_gt , e_and , e_nand , - e_or , e_nor , e_xor , e_xnor , - e_mand , e_mor , e_scand , e_scor , - e_shr , e_shl , e_abs , e_acos , - e_acosh , e_asin , e_asinh , e_atan , - e_atanh , e_ceil , e_cos , e_cosh , - e_exp , e_expm1 , e_floor , e_log , - e_log10 , e_log2 , e_log1p , e_logn , - e_neg , e_pos , e_round , e_roundn , - e_root , e_sqrt , e_sin , e_sinc , - e_sinh , e_sec , e_csc , e_tan , - e_tanh , e_cot , e_clamp , e_iclamp , - e_inrange , e_sgn , e_r2d , e_d2r , - e_d2g , e_g2d , e_hypot , e_notl , - e_erf , e_erfc , e_ncdf , e_frac , - e_trunc , e_assign , e_addass , e_subass , - e_mulass , e_divass , e_modass , e_in , - e_like , e_ilike , e_multi , e_swap , - - // Do not add new functions/operators after this point. - e_sf00 = 1000, e_sf01 = 1001, e_sf02 = 1002, e_sf03 = 1003, - e_sf04 = 1004, e_sf05 = 1005, e_sf06 = 1006, e_sf07 = 1007, - e_sf08 = 1008, e_sf09 = 1009, e_sf10 = 1010, e_sf11 = 1011, - e_sf12 = 1012, e_sf13 = 1013, e_sf14 = 1014, e_sf15 = 1015, - e_sf16 = 1016, e_sf17 = 1017, e_sf18 = 1018, e_sf19 = 1019, - e_sf20 = 1020, e_sf21 = 1021, e_sf22 = 1022, e_sf23 = 1023, - e_sf24 = 1024, e_sf25 = 1025, e_sf26 = 1026, e_sf27 = 1027, - e_sf28 = 1028, e_sf29 = 1029, e_sf30 = 1030, e_sf31 = 1031, - e_sf32 = 1032, e_sf33 = 1033, e_sf34 = 1034, e_sf35 = 1035, - e_sf36 = 1036, e_sf37 = 1037, e_sf38 = 1038, e_sf39 = 1039, - e_sf40 = 1040, e_sf41 = 1041, e_sf42 = 1042, e_sf43 = 1043, - e_sf44 = 1044, e_sf45 = 1045, e_sf46 = 1046, e_sf47 = 1047, - e_sf48 = 1048, e_sf49 = 1049, e_sf50 = 1050, e_sf51 = 1051, - e_sf52 = 1052, e_sf53 = 1053, e_sf54 = 1054, e_sf55 = 1055, - e_sf56 = 1056, e_sf57 = 1057, e_sf58 = 1058, e_sf59 = 1059, - e_sf60 = 1060, e_sf61 = 1061, e_sf62 = 1062, e_sf63 = 1063, - e_sf64 = 1064, e_sf65 = 1065, e_sf66 = 1066, e_sf67 = 1067, - e_sf68 = 1068, e_sf69 = 1069, e_sf70 = 1070, e_sf71 = 1071, - e_sf72 = 1072, e_sf73 = 1073, e_sf74 = 1074, e_sf75 = 1075, - e_sf76 = 1076, e_sf77 = 1077, e_sf78 = 1078, e_sf79 = 1079, - e_sf80 = 1080, e_sf81 = 1081, e_sf82 = 1082, e_sf83 = 1083, - e_sf84 = 1084, e_sf85 = 1085, e_sf86 = 1086, e_sf87 = 1087, - e_sf88 = 1088, e_sf89 = 1089, e_sf90 = 1090, e_sf91 = 1091, - e_sf92 = 1092, e_sf93 = 1093, e_sf94 = 1094, e_sf95 = 1095, - e_sf96 = 1096, e_sf97 = 1097, e_sf98 = 1098, e_sf99 = 1099, - e_sffinal = 1100, - e_sf4ext00 = 2000, e_sf4ext01 = 2001, e_sf4ext02 = 2002, e_sf4ext03 = 2003, - e_sf4ext04 = 2004, e_sf4ext05 = 2005, e_sf4ext06 = 2006, e_sf4ext07 = 2007, - e_sf4ext08 = 2008, e_sf4ext09 = 2009, e_sf4ext10 = 2010, e_sf4ext11 = 2011, - e_sf4ext12 = 2012, e_sf4ext13 = 2013, e_sf4ext14 = 2014, e_sf4ext15 = 2015, - e_sf4ext16 = 2016, e_sf4ext17 = 2017, e_sf4ext18 = 2018, e_sf4ext19 = 2019, - e_sf4ext20 = 2020, e_sf4ext21 = 2021, e_sf4ext22 = 2022, e_sf4ext23 = 2023, - e_sf4ext24 = 2024, e_sf4ext25 = 2025, e_sf4ext26 = 2026, e_sf4ext27 = 2027, - e_sf4ext28 = 2028, e_sf4ext29 = 2029, e_sf4ext30 = 2030, e_sf4ext31 = 2031, - e_sf4ext32 = 2032, e_sf4ext33 = 2033, e_sf4ext34 = 2034, e_sf4ext35 = 2035, - e_sf4ext36 = 2036, e_sf4ext37 = 2037, e_sf4ext38 = 2038, e_sf4ext39 = 2039, - e_sf4ext40 = 2040, e_sf4ext41 = 2041, e_sf4ext42 = 2042, e_sf4ext43 = 2043, - e_sf4ext44 = 2044, e_sf4ext45 = 2045, e_sf4ext46 = 2046, e_sf4ext47 = 2047, - e_sf4ext48 = 2048, e_sf4ext49 = 2049, e_sf4ext50 = 2050, e_sf4ext51 = 2051, - e_sf4ext52 = 2052, e_sf4ext53 = 2053, e_sf4ext54 = 2054, e_sf4ext55 = 2055, - e_sf4ext56 = 2056, e_sf4ext57 = 2057, e_sf4ext58 = 2058, e_sf4ext59 = 2059 - }; - - struct base_operation_t - { - base_operation_t(const operator_type t, const unsigned int& np) - : type(t), - num_params(np) - {} - - operator_type type; - unsigned int num_params; - }; - - namespace numeric - { - namespace details - { - template - inline T process_impl(const operator_type operation, const T arg) - { - switch (operation) - { - case e_abs : return numeric::abs (arg); - case e_acos : return numeric::acos (arg); - case e_acosh : return numeric::acosh(arg); - case e_asin : return numeric::asin (arg); - case e_asinh : return numeric::asinh(arg); - case e_atan : return numeric::atan (arg); - case e_atanh : return numeric::atanh(arg); - case e_ceil : return numeric::ceil (arg); - case e_cos : return numeric::cos (arg); - case e_cosh : return numeric::cosh (arg); - case e_exp : return numeric::exp (arg); - case e_expm1 : return numeric::expm1(arg); - case e_floor : return numeric::floor(arg); - case e_log : return numeric::log (arg); - case e_log10 : return numeric::log10(arg); - case e_log2 : return numeric::log2 (arg); - case e_log1p : return numeric::log1p(arg); - case e_neg : return numeric::neg (arg); - case e_pos : return numeric::pos (arg); - case e_round : return numeric::round(arg); - case e_sin : return numeric::sin (arg); - case e_sinc : return numeric::sinc (arg); - case e_sinh : return numeric::sinh (arg); - case e_sqrt : return numeric::sqrt (arg); - case e_tan : return numeric::tan (arg); - case e_tanh : return numeric::tanh (arg); - case e_cot : return numeric::cot (arg); - case e_sec : return numeric::sec (arg); - case e_csc : return numeric::csc (arg); - case e_r2d : return numeric::r2d (arg); - case e_d2r : return numeric::d2r (arg); - case e_d2g : return numeric::d2g (arg); - case e_g2d : return numeric::g2d (arg); - case e_notl : return numeric::notl (arg); - case e_sgn : return numeric::sgn (arg); - case e_erf : return numeric::erf (arg); - case e_erfc : return numeric::erfc (arg); - case e_ncdf : return numeric::ncdf (arg); - case e_frac : return numeric::frac (arg); - case e_trunc : return numeric::trunc(arg); - default : return std::numeric_limits::quiet_NaN(); - } + + private: + + T* value_; + bool delete_value_; + }; + + template + T variable_node::null_value = T(std::numeric_limits::quiet_NaN()); + + template + struct range_pack + { + typedef expression_node* expression_node_ptr; + typedef std::pair cached_range_t; + + range_pack() + : n0_e (std::make_pair(false,expression_node_ptr(0))), + n1_e (std::make_pair(false,expression_node_ptr(0))), + n0_c (std::make_pair(false,0)), + n1_c (std::make_pair(false,0)), + cache(std::make_pair(0,0)) + {} + + void clear() + { + n0_e = std::make_pair(false,expression_node_ptr(0)); + n1_e = std::make_pair(false,expression_node_ptr(0)); + n0_c = std::make_pair(false,0); + n1_c = std::make_pair(false,0); + cache = std::make_pair(0,0); + } + + void free() + { + if (n0_e.first && n0_e.second) + { + n0_e.first = false; + + if ( + !is_variable_node(n0_e.second) && + !is_string_node (n0_e.second) + ) + { + delete n0_e.second; + n0_e.second = expression_node_ptr(0); + } + } + + if (n1_e.first && n1_e.second) + { + n1_e.first = false; + + if ( + !is_variable_node(n1_e.second) && + !is_string_node (n1_e.second) + ) + { + delete n1_e.second; + n1_e.second = expression_node_ptr(0); + } + } + } + + bool const_range() + { + return ( n0_c.first && n1_c.first) && + (!n0_e.first && !n1_e.first); + } + + bool var_range() + { + return ( n0_e.first && n1_e.first) && + (!n0_c.first && !n1_c.first); + } + + bool operator()(std::size_t& r0, std::size_t& r1, const std::size_t& size = std::numeric_limits::max()) const + { + if (n0_c.first) + r0 = n0_c.second; + else if (n0_e.first) + { + T r0_value = n0_e.second->value(); + + if (r0_value < 0) + return false; + else + r0 = static_cast(details::numeric::to_int64(r0_value)); + } + else + return false; + + if (n1_c.first) + r1 = n1_c.second; + else if (n1_e.first) + { + T r1_value = n1_e.second->value(); + + if (r1_value < 0) + return false; + else + r1 = static_cast(details::numeric::to_int64(r1_value)); + } + else + return false; + + if ( + (std::numeric_limits::max() != size) && + (std::numeric_limits::max() == r1 ) + ) + { + r1 = size - 1; + } + + cache.first = r0; + cache.second = r1; + + return (r0 <= r1); + } + + inline std::size_t const_size() const + { + return (n1_c.second - n0_c.second + 1); + } + + inline std::size_t cache_size() const + { + return (cache.second - cache.first + 1); + } + + std::pair n0_e; + std::pair n1_e; + std::pair n0_c; + std::pair n1_c; + mutable cached_range_t cache; + }; + + template + class string_base_node; + + template + struct range_data_type + { + typedef range_pack range_t; + typedef string_base_node* strbase_ptr_t; + + range_data_type() + : range(0), + data (0), + size (0), + type_size(0), + str_node (0) + {} + + range_t* range; + void* data; + std::size_t size; + std::size_t type_size; + strbase_ptr_t str_node; + }; + + template class vector_node; + + template + class vector_interface + { + public: + + typedef vector_node* vector_node_ptr; + typedef vec_data_store vds_t; + + virtual ~vector_interface() + {} + + virtual std::size_t size () const = 0; + + virtual vector_node_ptr vec() const = 0; + + virtual vector_node_ptr vec() = 0; + + virtual vds_t& vds () = 0; + + virtual const vds_t& vds () const = 0; + + virtual bool side_effect () const { return false; } + }; + + template + class vector_node : public expression_node , + public vector_interface + { + public: + + typedef expression_node* expression_ptr; + typedef vector_holder vector_holder_t; + typedef vector_node* vector_node_ptr; + typedef vec_data_store vds_t; + + vector_node(vector_holder_t* vh) + : vector_holder_(vh), + vds_((*vector_holder_).size(),(*vector_holder_)[0]) + { + vector_holder_->set_ref(&vds_.ref()); + } + + vector_node(const vds_t& vds, vector_holder_t* vh) + : vector_holder_(vh), + vds_(vds) + {} + + inline T value() const + { + return vds().data()[0]; } - - template - inline T process_impl(const operator_type operation, const T arg0, const T arg1) - { - switch (operation) - { - case e_add : return (arg0 + arg1); - case e_sub : return (arg0 - arg1); - case e_mul : return (arg0 * arg1); - case e_div : return (arg0 / arg1); - case e_mod : return modulus(arg0,arg1); - case e_pow : return pow(arg0,arg1); - case e_atan2 : return atan2(arg0,arg1); - case e_min : return std::min(arg0,arg1); - case e_max : return std::max(arg0,arg1); - case e_logn : return logn(arg0,arg1); - case e_lt : return (arg0 < arg1) ? T(1) : T(0); - case e_lte : return (arg0 <= arg1) ? T(1) : T(0); - case e_eq : return std::equal_to()(arg0,arg1) ? T(1) : T(0); - case e_ne : return std::not_equal_to()(arg0,arg1) ? T(1) : T(0); - case e_gte : return (arg0 >= arg1) ? T(1) : T(0); - case e_gt : return (arg0 > arg1) ? T(1) : T(0); - case e_and : return and_opr (arg0,arg1); - case e_nand : return nand_opr(arg0,arg1); - case e_or : return or_opr (arg0,arg1); - case e_nor : return nor_opr (arg0,arg1); - case e_xor : return xor_opr (arg0,arg1); - case e_xnor : return xnor_opr(arg0,arg1); - case e_root : return root (arg0,arg1); - case e_roundn : return roundn (arg0,arg1); - case e_equal : return equal (arg0,arg1); - case e_nequal : return nequal (arg0,arg1); - case e_hypot : return hypot (arg0,arg1); - case e_shr : return shr (arg0,arg1); - case e_shl : return shl (arg0,arg1); - default : return std::numeric_limits::quiet_NaN(); - } + + vector_node_ptr vec() const + { + return const_cast(this); } - - template - inline T process_impl(const operator_type operation, const T arg0, const T arg1, int_type_tag) - { - switch (operation) - { - case e_add : return (arg0 + arg1); - case e_sub : return (arg0 - arg1); - case e_mul : return (arg0 * arg1); - case e_div : return (arg0 / arg1); - case e_mod : return arg0 % arg1; - case e_pow : return pow(arg0,arg1); - case e_min : return std::min(arg0,arg1); - case e_max : return std::max(arg0,arg1); - case e_logn : return logn(arg0,arg1); - case e_lt : return (arg0 < arg1) ? T(1) : T(0); - case e_lte : return (arg0 <= arg1) ? T(1) : T(0); - case e_eq : return (arg0 == arg1) ? T(1) : T(0); - case e_ne : return (arg0 != arg1) ? T(1) : T(0); - case e_gte : return (arg0 >= arg1) ? T(1) : T(0); - case e_gt : return (arg0 > arg1) ? T(1) : T(0); - case e_and : return ((arg0 != T(0)) && (arg1 != T(0))) ? T(1) : T(0); - case e_nand : return ((arg0 != T(0)) && (arg1 != T(0))) ? T(0) : T(1); - case e_or : return ((arg0 != T(0)) || (arg1 != T(0))) ? T(1) : T(0); - case e_nor : return ((arg0 != T(0)) || (arg1 != T(0))) ? T(0) : T(1); - case e_xor : return arg0 ^ arg1; - case e_xnor : return !(arg0 ^ arg1); - case e_root : return root(arg0,arg1); - case e_equal : return arg0 == arg1; - case e_nequal : return arg0 != arg1; - case e_hypot : return hypot(arg0,arg1); - case e_shr : return arg0 >> arg1; - case e_shl : return arg0 << arg1; - default : return std::numeric_limits::quiet_NaN(); - } - } - } - - template - inline T process(const operator_type operation, const T arg) - { - return exprtk::details::numeric::details::process_impl(operation,arg); - } - - template - inline T process(const operator_type operation, const T arg0, const T arg1) - { - return exprtk::details::numeric::details::process_impl(operation,arg0,arg1); - } - } - - template - class expression_node - { - public: - - enum node_type - { - e_none , e_null , e_constant , e_unary , - e_binary , e_binary_ext , e_trinary , e_quaternary , - e_quinary , e_senary , e_vararg , e_conditional , - e_while , e_repeat , e_for , e_switch , - e_mswitch , e_variable , e_stringvar , e_stringconst , - e_stringvarrng , e_cstringvarrng, e_strgenrange , e_strconcat , - e_stringvarsize, e_strswap , e_stringsize , e_function , - e_vafunction , e_genfunction , e_strfunction , e_add , - e_sub , e_mul , e_div , e_mod , - e_pow , e_lt , e_lte , e_gt , - e_gte , e_eq , e_ne , e_and , - e_nand , e_or , e_nor , e_xor , - e_xnor , e_in , e_like , e_ilike , - e_inranges , e_ipow , e_ipowinv , e_abs , - e_acos , e_acosh , e_asin , e_asinh , - e_atan , e_atanh , e_ceil , e_cos , - e_cosh , e_exp , e_expm1 , e_floor , - e_log , e_log10 , e_log2 , e_log1p , - e_neg , e_pos , e_round , e_sin , - e_sinc , e_sinh , e_sqrt , e_tan , - e_tanh , e_cot , e_sec , e_csc , - e_r2d , e_d2r , e_d2g , e_g2d , - e_notl , e_sgn , e_erf , e_erfc , - e_ncdf , e_frac , e_trunc , e_uvouv , - e_vov , e_cov , e_voc , e_vob , - e_bov , e_cob , e_boc , e_vovov , - e_vovoc , e_vocov , e_covov , e_covoc , - e_vovovov , e_vovovoc , e_vovocov , e_vocovov , - e_covovov , e_covocov , e_vocovoc , e_covovoc , - e_vococov , e_sf3ext , e_sf4ext , e_nulleq , - e_strass , e_vector , e_vecelem , e_vecdefass , - e_vecvalass , e_vecvecass , e_vecopvalass , e_vecopvecass , - e_vecfunc , e_vecvecswap , e_vecvecineq , e_vecvalineq , - e_valvecineq , e_vecvecarith , e_vecvalarith , e_valvecarith , - e_vecunaryop , e_break , e_continue , e_swap - }; - - typedef T value_type; - typedef expression_node* expression_ptr; - - virtual ~expression_node() - {} - - inline virtual T value() const - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual expression_node* branch(const std::size_t& index = 0) const - { - return reinterpret_cast(index * 0); - } - - inline virtual node_type type() const - { - return e_none; - } - }; - - template - inline bool is_generally_string_node(const expression_node* node); - - inline bool is_true(const double v) - { - return std::not_equal_to()(0.0,v); - } - - inline bool is_true(const long double v) - { - return std::not_equal_to()(0.0L,v); - } - - inline bool is_true(const float v) - { - return std::not_equal_to()(0.0f,v); - } - - template - inline bool is_true(const expression_node* node) - { - return std::not_equal_to()(T(0),node->value()); - } - - template - inline bool is_false(const expression_node* node) - { - return std::equal_to()(T(0),node->value()); - } - - template - inline bool is_unary_node(const expression_node* node) - { - return node && (details::expression_node::e_unary == node->type()); - } - - template - inline bool is_neg_unary_node(const expression_node* node) - { - return node && (details::expression_node::e_neg == node->type()); - } - - template - inline bool is_binary_node(const expression_node* node) - { - return node && (details::expression_node::e_binary == node->type()); - } - - template - inline bool is_variable_node(const expression_node* node) - { - return node && (details::expression_node::e_variable == node->type()); - } - - template - inline bool is_ivariable_node(const expression_node* node) - { - return node && - ( - details::expression_node::e_variable == node->type() || - details::expression_node::e_vecelem == node->type() - ); - } - - template - inline bool is_vector_elem_node(const expression_node* node) - { - return node && (details::expression_node::e_vecelem == node->type()); - } - - template - inline bool is_vector_node(const expression_node* node) - { - return node && (details::expression_node::e_vector == node->type()); - } - - template - inline bool is_ivector_node(const expression_node* node) - { - if (node) - { - switch (node->type()) - { - case details::expression_node::e_vector : - case details::expression_node::e_vecvalass : - case details::expression_node::e_vecvecass : - case details::expression_node::e_vecopvalass : - case details::expression_node::e_vecopvecass : - case details::expression_node::e_vecvecswap : - case details::expression_node::e_vecvecarith : - case details::expression_node::e_vecvalarith : - case details::expression_node::e_valvecarith : - case details::expression_node::e_vecunaryop : return true; - default : return false; - } - } - else - return false; - } - - template - inline bool is_constant_node(const expression_node* node) - { - return node && (details::expression_node::e_constant == node->type()); - } - - template - inline bool is_null_node(const expression_node* node) - { - return node && (details::expression_node::e_null == node->type()); - } - - template - inline bool is_break_node(const expression_node* node) - { - return node && (details::expression_node::e_break == node->type()); - } - - template - inline bool is_continue_node(const expression_node* node) - { - return node && (details::expression_node::e_continue == node->type()); - } - - template - inline bool is_swap_node(const expression_node* node) - { - return node && (details::expression_node::e_swap == node->type()); - } - - template - inline bool is_function(const expression_node* node) - { - return node && (details::expression_node::e_function == node->type()); - } - - template class unary_node; - - template - inline bool is_negate_node(const expression_node* node) - { - if (node && is_unary_node(node)) - { - return (details::e_neg == static_cast*>(node)->operation()); - } - else - return false; - } - - template - inline bool branch_deletable(expression_node* node) - { - return !is_variable_node(node) && - !is_string_node (node) ; - } - - template - inline bool all_nodes_valid(expression_node* (&b)[N]) - { - for (std::size_t i = 0; i < N; ++i) - { - if (0 == b[i]) return false; - } - - return true; - } - - template class Sequence> - inline bool all_nodes_valid(const Sequence*,Allocator>& b) - { - for (std::size_t i = 0; i < b.size(); ++i) - { - if (0 == b[i]) return false; - } - - return true; - } - - template - inline bool all_nodes_variables(expression_node* (&b)[N]) - { - for (std::size_t i = 0; i < N; ++i) - { - if (0 == b[i]) - return false; - else if (!is_variable_node(b[i])) - return false; - } - - return true; - } - - template class Sequence> - inline bool all_nodes_variables(Sequence*,Allocator>& b) - { - for (std::size_t i = 0; i < b.size(); ++i) - { - if (0 == b[i]) - return false; - else if (!is_variable_node(b[i])) - return false; - } - - return true; - } - - template - inline void free_all_nodes(NodeAllocator& node_allocator, expression_node* (&b)[N]) - { - for (std::size_t i = 0; i < N; ++i) - { - free_node(node_allocator,b[i]); - } - } - - template class Sequence> - inline void free_all_nodes(NodeAllocator& node_allocator, Sequence*,Allocator>& b) - { - for (std::size_t i = 0; i < b.size(); ++i) - { - free_node(node_allocator,b[i]); - } - - b.clear(); - } - - template - inline void free_node(NodeAllocator& node_allocator, expression_node*& node, const bool force_delete = false) - { - if (0 != node) - { - if ( - (is_variable_node(node) || is_string_node(node)) || - force_delete - ) - return; - - node_allocator.free(node); - node = 0; - } - } - - template - class vector_holder - { - private: - - typedef Type value_type; - typedef value_type* value_ptr; - typedef const value_ptr const_value_ptr; - - class vector_holder_base - { - public: - - virtual ~vector_holder_base(){} - - inline value_ptr operator[](const std::size_t& index) const + + vector_node_ptr vec() { - return value_at(index); + return this; } - - inline std::size_t size() const + + inline typename expression_node::node_type type() const { - return vector_size(); + return expression_node::e_vector; } - - protected: - - virtual value_ptr value_at(const std::size_t&) const = 0; - virtual std::size_t vector_size() const = 0; - }; - - class array_vector_impl : public vector_holder_base - { - public: - - array_vector_impl(const Type* vec, const std::size_t& vec_size) - : vec_(vec), - size_(vec_size) + + std::size_t size() const + { + return vds().size(); + } + + vds_t& vds() + { + return vds_; + } + + const vds_t& vds() const + { + return vds_; + } + + inline vector_holder_t& vec_holder() + { + return (*vector_holder_); + } + + private: + + vector_holder_t* vector_holder_; + vds_t vds_; + }; + + template + class vector_elem_node : public expression_node, + public ivariable + { + public: + + typedef expression_node* expression_ptr; + typedef vector_holder vector_holder_t; + typedef vector_holder_t* vector_holder_ptr; + + vector_elem_node(expression_ptr index, vector_holder_ptr vec_holder) + : index_(index), + vec_holder_(vec_holder), + vector_base_((*vec_holder)[0]), + index_deletable_(branch_deletable(index_)) {} - - protected: - - value_ptr value_at(const std::size_t& index) const + + ~vector_elem_node() { - if (index < size_) - return const_cast(vec_ + index); - else - return const_value_ptr(0); + if (index_ && index_deletable_) + { + delete index_; + } } - - std::size_t vector_size() const + + inline T value() const { - return size_; + return *(vector_base_ + static_cast(details::numeric::to_int64(index_->value()))); } - - private: - - array_vector_impl operator=(const array_vector_impl&); - - const Type* vec_; + + inline T& ref() + { + return *(vector_base_ + static_cast(details::numeric::to_int64(index_->value()))); + } + + inline const T& ref() const + { + return *(vector_base_ + static_cast(details::numeric::to_int64(index_->value()))); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_vecelem; + } + + inline vector_holder_t& vec_holder() + { + return (*vec_holder_); + } + + private: + + expression_ptr index_; + vector_holder_ptr vec_holder_; + T* vector_base_; + bool index_deletable_; + }; + + template + class rebasevector_elem_node : public expression_node, + public ivariable + { + public: + + typedef expression_node* expression_ptr; + typedef vector_holder vector_holder_t; + typedef vector_holder_t* vector_holder_ptr; + typedef vec_data_store vds_t; + + rebasevector_elem_node(expression_ptr index, vector_holder_ptr vec_holder) + : index_(index), + index_deletable_(branch_deletable(index_)), + vector_holder_(vec_holder), + vds_((*vector_holder_).size(),(*vector_holder_)[0]) + { + vector_holder_->set_ref(&vds_.ref()); + } + + ~rebasevector_elem_node() + { + if (index_ && index_deletable_) + { + delete index_; + } + } + + inline T value() const + { + return *(vds_.data() + static_cast(details::numeric::to_int64(index_->value()))); + } + + inline T& ref() + { + return *(vds_.data() + static_cast(details::numeric::to_int64(index_->value()))); + } + + inline const T& ref() const + { + return *(vds_.data() + static_cast(details::numeric::to_int64(index_->value()))); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_rbvecelem; + } + + inline vector_holder_t& vec_holder() + { + return (*vector_holder_); + } + + private: + + expression_ptr index_; + bool index_deletable_; + vector_holder_ptr vector_holder_; + vds_t vds_; + }; + + template + class rebasevector_celem_node : public expression_node, + public ivariable + { + public: + + typedef expression_node* expression_ptr; + typedef vector_holder vector_holder_t; + typedef vector_holder_t* vector_holder_ptr; + typedef vec_data_store vds_t; + + rebasevector_celem_node(const std::size_t index, vector_holder_ptr vec_holder) + : index_(index), + vector_holder_(vec_holder), + vds_((*vector_holder_).size(),(*vector_holder_)[0]) + { + vector_holder_->set_ref(&vds_.ref()); + } + + inline T value() const + { + return *(vds_.data() + index_); + } + + inline T& ref() + { + return *(vds_.data() + index_); + } + + inline const T& ref() const + { + return *(vds_.data() + index_); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_rbveccelem; + } + + inline vector_holder_t& vec_holder() + { + return (*vector_holder_); + } + + private: + + std::size_t index_; + vector_holder_ptr vector_holder_; + vds_t vds_; + }; + + template + class vector_assignment_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + vector_assignment_node(T* vector_base, + const std::size_t& size, + const std::vector& initialiser_list, + const bool single_value_initialse) + : vector_base_(vector_base), + initialiser_list_(initialiser_list), + size_(size), + single_value_initialse_(single_value_initialse) + {} + + ~vector_assignment_node() + { + for (std::size_t i = 0; i < initialiser_list_.size(); ++i) + { + if (branch_deletable(initialiser_list_[i])) + { + delete initialiser_list_[i]; + } + } + } + + inline T value() const + { + if (single_value_initialse_) + { + for (std::size_t i = 0; i < size_; ++i) + { + *(vector_base_ + i) = initialiser_list_[0]->value(); + } + } + else + { + std::size_t il_size = initialiser_list_.size(); + + for (std::size_t i = 0; i < il_size; ++i) + { + *(vector_base_ + i) = initialiser_list_[i]->value(); + } + + if (il_size < size_) + { + for (std::size_t i = il_size; i < size_; ++i) + { + *(vector_base_ + i) = T(0); + } + } + } + + return *(vector_base_); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_vecdefass; + } + + private: + + vector_assignment_node& operator=(const vector_assignment_node&); + + mutable T* vector_base_; + std::vector initialiser_list_; const std::size_t size_; - }; - - template class Sequence> - class sequence_vector_impl : public vector_holder_base - { - public: - - typedef Sequence sequence_t; - - sequence_vector_impl(sequence_t& seq) - : sequence_(seq) + const bool single_value_initialse_; + }; + + template + class swap_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef variable_node* variable_node_ptr; + + swap_node(variable_node_ptr var0, variable_node_ptr var1) + : var0_(var0), + var1_(var1) {} - - protected: - - value_ptr value_at(const std::size_t& index) const + + inline T value() const { - return (index < sequence_.size()) ? (&sequence_[index]) : const_value_ptr(0); + std::swap(var0_->ref(),var1_->ref()); + return var1_->ref(); } - - std::size_t vector_size() const + + inline typename expression_node::node_type type() const { - return sequence_.size(); + return expression_node::e_swap; } - - private: - - sequence_vector_impl operator=(const sequence_vector_impl&); - - sequence_t& sequence_; - }; - - public: - - vector_holder(Type* vec, const std::size_t& vec_size) - : vector_holder_base_(new(buffer)array_vector_impl(vec,vec_size)) - {} - - template - vector_holder(std::vector& vec) - : vector_holder_base_(new(buffer)sequence_vector_impl(vec)) - {} - - template - vector_holder(std::deque& deq) - : vector_holder_base_(new(buffer)sequence_vector_impl(deq)) - {} - - inline value_ptr operator[](const std::size_t& index) const - { - return (*vector_holder_base_)[index]; - } - - inline std::size_t size() const - { - return vector_holder_base_->size(); - } - - private: - - mutable vector_holder_base* vector_holder_base_; - unsigned char buffer[64]; - }; - - template - class null_node : public expression_node - { - public: - - inline T value() const - { - return std::numeric_limits::quiet_NaN(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_null; - } - }; - - template - class null_eq_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - null_eq_node(expression_ptr brnch, const bool equality = true) - : branch_(brnch), - branch_deletable_(branch_deletable(branch_)), - equality_(equality) - {} - - ~null_eq_node() - { - if (branch_ && branch_deletable_) + + private: + + variable_node_ptr var0_; + variable_node_ptr var1_; + }; + + template + class swap_generic_node : public binary_node + { + public: + + typedef expression_node* expression_ptr; + typedef ivariable* ivariable_ptr; + + swap_generic_node(expression_ptr var0, expression_ptr var1) + : binary_node(details::e_swap,var0,var1), + var0_(dynamic_cast(var0)), + var1_(dynamic_cast(var1)) + {} + + inline T value() const { - delete branch_; - branch_ = 0; + std::swap(var0_->ref(),var1_->ref()); + return var1_->ref(); } - } - - inline T value() const - { - const T v = branch_->value(); - const bool result = details::numeric::is_nan(v); - - if (result) - return (equality_) ? T(1) : T(0); - else - return (equality_) ? T(0) : T(1); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_nulleq; - } - - inline operator_type operation() const - { - return details::e_eq; - } - - inline expression_node* branch(const std::size_t&) const - { - return branch_; - } - - private: - - expression_ptr branch_; - bool branch_deletable_; - bool equality_; - }; - - template - class literal_node : public expression_node - { - public: - - explicit literal_node(const T& v) - : value_(v) - {} - - inline T value() const - { - return value_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_constant; - } - - inline expression_node* branch(const std::size_t&) const - { - return reinterpret_cast*>(0); - } - - private: - - literal_node(literal_node&) {} - literal_node& operator=(literal_node&) { return *this; } - - const T value_; - }; - - template - struct range_pack; - - template - struct range_data_type; - - template - class range_interface - { - public: - - typedef range_pack range_t; - - virtual range_t& range_ref() = 0; - - virtual const range_t& range_ref() const = 0; - }; - - template - class string_base_node - { - public: - - typedef range_data_type range_data_type_t; - - virtual std::string str () const = 0; - - virtual const char* base() const = 0; - - virtual std::size_t size() const = 0; - }; - - template - class string_literal_node : public expression_node , - public string_base_node, - public range_interface - { - public: - - typedef range_pack range_t; - - explicit string_literal_node(const std::string& v) - : value_(v) - { - rp_.n0_c = std::make_pair(true,0); - rp_.n1_c = std::make_pair(true,v.size() - 1); - rp_.cache.first = rp_.n0_c.second; - rp_.cache.second = rp_.n1_c.second; - } - - inline T value() const - { - return std::numeric_limits::quiet_NaN(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_stringconst; - } - - inline expression_node* branch(const std::size_t&) const - { - return reinterpret_cast*>(0); - } - - std::string str() const - { - return value_; - } - - const char* base() const - { - return value_.data(); - } - - std::size_t size() const - { - return value_.size(); - } - - range_t& range_ref() - { - return rp_; - } - - const range_t& range_ref() const - { - return rp_; - } - - private: - - string_literal_node(const string_literal_node&); - string_literal_node& operator=(const string_literal_node&); - - const std::string value_; - range_t rp_; - }; - - template - class unary_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - unary_node(const operator_type& opr, - expression_ptr brnch) - : operation_(opr), - branch_(brnch), - branch_deletable_(branch_deletable(branch_)) - {} - - ~unary_node() - { - if (branch_ && branch_deletable_) + + inline typename expression_node::node_type type() const { - delete branch_; - branch_ = 0; + return expression_node::e_swap; } - } - - inline T value() const - { - const T arg = branch_->value(); - return numeric::process(operation_,arg); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_unary; - } - - inline operator_type operation() const - { - return operation_; - } - - inline expression_node* branch(const std::size_t&) const - { - return branch_; - } - - inline void release() - { - branch_deletable_ = false; - } - - protected: - - operator_type operation_; - expression_ptr branch_; - bool branch_deletable_; - }; - - template - struct construct_branch_pair - { - template - static inline void process(std::pair*,bool> (&)[N], expression_node*) - {} - }; - - template - struct construct_branch_pair - { - template - static inline void process(std::pair*,bool> (&branch)[N], expression_node* b) - { - if (b) - { - branch[D] = std::make_pair(b,branch_deletable(b)); - } - } - }; - - template - inline void init_branches(std::pair*,bool> (&branch)[N], - expression_node* b0, - expression_node* b1 = reinterpret_cast*>(0), - expression_node* b2 = reinterpret_cast*>(0), - expression_node* b3 = reinterpret_cast*>(0), - expression_node* b4 = reinterpret_cast*>(0), - expression_node* b5 = reinterpret_cast*>(0), - expression_node* b6 = reinterpret_cast*>(0), - expression_node* b7 = reinterpret_cast*>(0), - expression_node* b8 = reinterpret_cast*>(0), - expression_node* b9 = reinterpret_cast*>(0)) - { - construct_branch_pair 0)>::process(branch,b0); - construct_branch_pair 1)>::process(branch,b1); - construct_branch_pair 2)>::process(branch,b2); - construct_branch_pair 3)>::process(branch,b3); - construct_branch_pair 4)>::process(branch,b4); - construct_branch_pair 5)>::process(branch,b5); - construct_branch_pair 6)>::process(branch,b6); - construct_branch_pair 7)>::process(branch,b7); - construct_branch_pair 8)>::process(branch,b8); - construct_branch_pair 9)>::process(branch,b9); - } - - struct cleanup_branches - { - template - static inline void execute(std::pair*,bool> (&branch)[N]) - { - for (std::size_t i = 0; i < N; ++i) + + private: + + ivariable_ptr var0_; + ivariable_ptr var1_; + }; + + template + class swap_vecvec_node : public binary_node , + public vector_interface + { + public: + + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; + typedef vec_data_store vds_t; + + swap_vecvec_node(expression_ptr branch0, + expression_ptr branch1) + : binary_node(details::e_swap,branch0,branch1), + vec0_node_ptr_(0), + vec1_node_ptr_(0), + vec_size_ (0), + initialised_ (false) + { + if (is_ivector_node(binary_node::branch_[0].first)) + { + vector_interface* vi = reinterpret_cast*>(0); + + if (0 != (vi = dynamic_cast*>(binary_node::branch_[0].first))) + { + vec0_node_ptr_ = vi->vec(); + vds() = vi->vds(); + } + } + + if (is_ivector_node(binary_node::branch_[1].first)) + { + vector_interface* vi = reinterpret_cast*>(0); + + if (0 != (vi = dynamic_cast*>(binary_node::branch_[1].first))) + { + vec1_node_ptr_ = vi->vec(); + } + } + + if (vec0_node_ptr_ && vec1_node_ptr_) + { + vec_size_ = std::min(vec0_node_ptr_->vds().size(), + vec1_node_ptr_->vds().size()); + + initialised_ = true; + } + } + + inline T value() const + { + if (initialised_) + { + binary_node::branch_[0].first->value(); + binary_node::branch_[1].first->value(); + + T* vec0 = vec0_node_ptr_->vds().data(); + T* vec1 = vec1_node_ptr_->vds().data(); + + for (std::size_t i = 0; i < vec_size_; ++i) + { + std::swap(vec0[i],vec1[i]); + } + + return vec1_node_ptr_->value(); + } + else + return std::numeric_limits::quiet_NaN(); + } + + vector_node_ptr vec() const + { + return vec0_node_ptr_; + } + + vector_node_ptr vec() + { + return vec0_node_ptr_; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_vecvecswap; + } + + std::size_t size() const + { + return vec_size_; + } + + vds_t& vds() + { + return vds_; + } + + const vds_t& vds() const + { + return vds_; + } + + private: + + vector_node* vec0_node_ptr_; + vector_node* vec1_node_ptr_; + std::size_t vec_size_; + bool initialised_; + vds_t vds_; + }; + +#ifndef exprtk_disable_string_capabilities + template + class stringvar_node : public expression_node , + public string_base_node, + public range_interface + { + public: + + typedef range_pack range_t; + + static std::string null_value; + + explicit stringvar_node() + : value_(&null_value) + {} + + explicit stringvar_node(std::string& v) + : value_(&v) { - if (branch[i].first && branch[i].second) - { - delete branch[i].first; - branch[i].first = 0; - } + rp_.n0_c = std::make_pair(true,0); + rp_.n1_c = std::make_pair(true,v.size() - 1); + rp_.cache.first = rp_.n0_c.second; + rp_.cache.second = rp_.n1_c.second; } - } - - template class Sequence> - static inline void execute(Sequence*,bool>,Allocator>& branch) - { - for (std::size_t i = 0; i < branch.size(); ++i) - { - if (branch[i].first && branch[i].second) - { - delete branch[i].first; - branch[i].first = 0; - } - } - } - }; - - template - class binary_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - typedef std::pair branch_t; - - binary_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : operation_(opr) - { - init_branches<2>(branch_,branch0,branch1); - } - - ~binary_node() - { - cleanup_branches::execute(branch_); - } - - inline T value() const - { - const T arg0 = branch_[0].first->value(); - const T arg1 = branch_[1].first->value(); - return numeric::process(operation_,arg0,arg1); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_binary; - } - - inline operator_type operation() - { - return operation_; - } - - inline expression_node* branch(const std::size_t& index = 0) const - { - if (0 == index) - return branch_[0].first; - else if (1 == index) - return branch_[1].first; - else - return reinterpret_cast(0); - } - - protected: - - operator_type operation_; - branch_t branch_[2]; - }; - - template - class binary_ext_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - typedef std::pair branch_t; - - binary_ext_node(expression_ptr branch0, expression_ptr branch1) - { - init_branches<2>(branch_,branch0,branch1); - } - - ~binary_ext_node() - { - cleanup_branches::execute(branch_); - } - - inline T value() const - { - const T arg0 = branch_[0].first->value(); - const T arg1 = branch_[1].first->value(); - return Operation::process(arg0,arg1); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_binary_ext; - } - - inline operator_type operation() - { - return Operation::operation(); - } - - inline expression_node* branch(const std::size_t& index = 0) const - { - if (0 == index) - return branch_[0].first; - else if (1 == index) - return branch_[1].first; - else - return reinterpret_cast(0); - } - - protected: - - branch_t branch_[2]; - }; - - template - class trinary_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - typedef std::pair branch_t; - - trinary_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1, - expression_ptr branch2) - : operation_(opr) - { - init_branches<3>(branch_,branch0,branch1,branch2); - } - - ~trinary_node() - { - cleanup_branches::execute(branch_); - } - - inline T value() const - { - const T arg0 = branch_[0].first->value(); - const T arg1 = branch_[1].first->value(); - const T arg2 = branch_[2].first->value(); - - switch (operation_) - { - case e_inrange : return (arg1 < arg0) ? T(0) : ((arg1 > arg2) ? T(0) : T(1)); - case e_min : return std::min(std::min(arg0,arg1),arg2); - case e_max : return std::max(std::max(arg0,arg1),arg2); - case e_clamp : return (arg1 < arg0) ? arg0 : (arg1 > arg2 ? arg2 : arg1); - case e_iclamp : if ((arg1 <= arg0) || (arg1 >= arg2)) - return arg1; - else - return ((T(2) * arg1 <= (arg2 + arg0)) ? arg0 : arg2); - default : return std::numeric_limits::quiet_NaN(); - } - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_trinary; - } - - protected: - - operator_type operation_; - branch_t branch_[3]; - }; - - template - class quaternary_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - typedef std::pair branch_t; - - quaternary_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1, - expression_ptr branch2, - expression_ptr branch3) - : operation_(opr) - { - init_branches<4>(branch_,branch0,branch1,branch2,branch3); - } - - ~quaternary_node() - { - cleanup_branches::execute(branch_); - } - - inline T value() const - { - const T arg0 = branch_[0].first->value(); - const T arg1 = branch_[1].first->value(); - const T arg2 = branch_[2].first->value(); - const T arg3 = branch_[3].first->value(); - - switch (operation_) + + inline bool operator <(const stringvar_node& v) const { - case e_min : return std::min(std::min(arg0,arg1),std::min(arg2,arg3)); - case e_max : return std::max(std::max(arg0,arg1),std::max(arg2,arg3)); - default : return std::numeric_limits::quiet_NaN(); + return this < (&v); } - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_quaternary; - } - - protected: - - operator_type operation_; - branch_t branch_[4]; - }; - - template - class quinary_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - typedef std::pair branch_t; - - quinary_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1, - expression_ptr branch2, - expression_ptr branch3, - expression_ptr branch4) - : operation_(opr) - { - init_branches<5>(branch_,branch0,branch1,branch2,branch3,branch4); - } - - ~quinary_node() - { - cleanup_branches::execute(branch_); - } - - inline T value() const - { - const T arg0 = branch_[0].first->value(); - const T arg1 = branch_[1].first->value(); - const T arg2 = branch_[2].first->value(); - const T arg3 = branch_[3].first->value(); - const T arg4 = branch_[4].first->value(); - - switch (operation_) + + inline T value() const { - case e_min : return std::min(std::min(std::min(arg0,arg1),std::min(arg2,arg3)),arg4); - case e_max : return std::max(std::max(std::max(arg0,arg1),std::max(arg2,arg3)),arg4); - default : return std::numeric_limits::quiet_NaN(); + rp_.n1_c.second = (*value_).size() - 1; + rp_.cache.second = rp_.n1_c.second; + return std::numeric_limits::quiet_NaN(); } - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_quinary; - } - - private: - - operator_type operation_; - branch_t branch_[5]; - }; - - template - class senary_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - typedef std::pair branch_t; - - senary_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1, - expression_ptr branch2, - expression_ptr branch3, - expression_ptr branch4, - expression_ptr branch5) - : operation_(opr) - { - init_branches<6>(branch_,branch0,branch1,branch2,branch3,branch4,branch5); - } - - ~senary_node() - { - cleanup_branches::execute(branch_); - } - - inline T value() const - { - const T arg0 = branch_[0].first->value(); - const T arg1 = branch_[1].first->value(); - const T arg2 = branch_[2].first->value(); - const T arg3 = branch_[3].first->value(); - const T arg4 = branch_[4].first->value(); - const T arg5 = branch_[5].first->value(); - - switch (operation_) + + std::string str() const { - case e_min : return std::min(std::min(std::min(arg0,arg1),std::min(arg2,arg3)),std::min(arg4,arg5)); - case e_max : return std::max(std::max(std::max(arg0,arg1),std::max(arg2,arg3)),std::max(arg4,arg5)); - case e_default : - default : return std::numeric_limits::quiet_NaN(); + return ref(); } - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_senary; - } - - private: - - operator_type operation_; - branch_t branch_[6]; - }; - - template - class conditional_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - conditional_node(expression_ptr test, - expression_ptr consequent, - expression_ptr alternative) - : test_(test), - consequent_(consequent), - alternative_(alternative), - test_deletable_(branch_deletable(test_)), - consequent_deletable_(branch_deletable(consequent_)), - alternative_deletable_(branch_deletable(alternative_)) - {} - - ~conditional_node() - { - if (test_ && test_deletable_ ) delete test_; - if (consequent_ && consequent_deletable_ ) delete consequent_; - if (alternative_ && alternative_deletable_) delete alternative_; - } - - inline T value() const - { - if (is_true(test_)) - return consequent_->value(); - else - return alternative_->value(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_conditional; - } - - private: - - expression_ptr test_; - expression_ptr consequent_; - expression_ptr alternative_; - bool test_deletable_; - bool consequent_deletable_; - bool alternative_deletable_; - }; - - template - class cons_conditional_node : public expression_node - { - public: - - // Consequent only conditional statement node - typedef expression_node* expression_ptr; - - cons_conditional_node(expression_ptr test, - expression_ptr consequent) - : test_(test), - consequent_(consequent), - test_deletable_(branch_deletable(test_)), - consequent_deletable_(branch_deletable(consequent_)) - {} - - ~cons_conditional_node() - { - if (test_ && test_deletable_ ) delete test_; - if (consequent_ && consequent_deletable_) delete consequent_; - } - - inline T value() const - { - if (is_true(test_)) - return consequent_->value(); - else - return std::numeric_limits::quiet_NaN(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_conditional; - } - - private: - - expression_ptr test_; - expression_ptr consequent_; - bool test_deletable_; - bool consequent_deletable_; - }; - - #ifndef exprtk_disable_break_continue - template - class break_exception : public std::exception - { - public: - - break_exception(const T& v) - : value(v) - {} - - T value; - }; - - class continue_exception : public std::exception - {}; - - template - class break_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - break_node(expression_ptr ret = expression_ptr(0)) - : return_(ret), - return_deletable_(branch_deletable(return_)) - {} - - ~break_node() - { - if (return_deletable_) + + const char* base() const { - delete return_; + return &(*value_)[0]; } - } - - inline T value() const - { - throw break_exception(return_ ? return_->value() : std::numeric_limits::quiet_NaN()); - #ifndef _MSC_VER - return std::numeric_limits::quiet_NaN(); - #endif - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_break; - } - - private: - - expression_ptr return_; - bool return_deletable_; - }; - - template - class continue_node : public expression_node - { - public: - - inline T value() const - { - throw continue_exception(); - #ifndef _MSC_VER - return std::numeric_limits::quiet_NaN(); - #endif - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_break; - } - }; - #endif - - template - class while_loop_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - while_loop_node(expression_ptr condition, expression_ptr loop_body) - : condition_(condition), - loop_body_(loop_body), - condition_deletable_(branch_deletable(condition_)), - loop_body_deletable_(branch_deletable(loop_body_)) - {} - - ~while_loop_node() - { - if (condition_ && condition_deletable_) + + std::size_t size() const { - delete condition_; + return ref().size(); } - - if (loop_body_ && loop_body_deletable_) + + std::string& ref() { - delete loop_body_; + return (*value_); } - } - - inline T value() const - { - T result = T(0); - - while (is_true(condition_)) + + const std::string& ref() const { - result = loop_body_->value(); + return (*value_); } - - return result; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_while; - } - - private: - - expression_ptr condition_; - expression_ptr loop_body_; - bool condition_deletable_; - bool loop_body_deletable_; - }; - - template - class repeat_until_loop_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - repeat_until_loop_node(expression_ptr condition, expression_ptr loop_body) - : condition_(condition), - loop_body_(loop_body), - condition_deletable_(branch_deletable(condition_)), - loop_body_deletable_(branch_deletable(loop_body_)) - {} - - ~repeat_until_loop_node() - { - if (condition_ && condition_deletable_) + + range_t& range_ref() { - delete condition_; + return rp_; } - - if (loop_body_ && loop_body_deletable_) + + const range_t& range_ref() const { - delete loop_body_; + return rp_; } - } - - inline T value() const - { - T result = T(0); - - do + + inline typename expression_node::node_type type() const { - result = loop_body_->value(); + return expression_node::e_stringvar; } - while (is_false(condition_)); - - return result; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_repeat; - } - - private: - - expression_ptr condition_; - expression_ptr loop_body_; - bool condition_deletable_; - bool loop_body_deletable_; - }; - - template - class for_loop_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - for_loop_node(expression_ptr initialiser, - expression_ptr condition, - expression_ptr incrementor, - expression_ptr loop_body) - : initialiser_(initialiser), - condition_ (condition), - incrementor_(incrementor), - loop_body_ (loop_body), - initialiser_deletable_(branch_deletable(initialiser_)), - condition_deletable_ (branch_deletable(condition_ )), - incrementor_deletable_(branch_deletable(incrementor_)), - loop_body_deletable_ (branch_deletable(loop_body_ )) - {} - - ~for_loop_node() - { - if (initialiser_ && initialiser_deletable_) + + private: + + std::string* value_; + mutable range_t rp_; + }; + + template + std::string stringvar_node::null_value = std::string(""); + + template + class string_range_node : public expression_node , + public string_base_node, + public range_interface + { + public: + + typedef range_pack range_t; + + static std::string null_value; + + explicit string_range_node(std::string& v, const range_t& rp) + : value_(&v), + rp_(rp) + {} + + virtual ~string_range_node() { - delete initialiser_; + rp_.free(); } - - if (condition_ && condition_deletable_) + + inline bool operator <(const string_range_node& v) const { - delete condition_; + return this < (&v); } - - if (incrementor_ && incrementor_deletable_) + + inline T value() const { - delete incrementor_; + return std::numeric_limits::quiet_NaN(); } - - if (loop_body_ && loop_body_deletable_) + + inline std::string str() const { - delete loop_body_; + return (*value_); } - } - - inline T value() const - { - T result = T(0); - - if (initialiser_) - initialiser_->value(); - - if (incrementor_) + + const char* base() const { - while (is_true(condition_)) - { - result = loop_body_->value(); - incrementor_->value(); - } + return &(*value_)[0]; } - else + + std::size_t size() const { - while (is_true(condition_)) - { - result = loop_body_->value(); - } + return ref().size(); } - - return result; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_for; - } - - private: - - expression_ptr initialiser_; - expression_ptr condition_ ; - expression_ptr incrementor_; - expression_ptr loop_body_ ; - bool initialiser_deletable_; - bool condition_deletable_ ; - bool incrementor_deletable_; - bool loop_body_deletable_ ; - }; - - #ifndef exprtk_disable_break_continue - template - class while_loop_bc_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - while_loop_bc_node(expression_ptr condition, expression_ptr loop_body) - : condition_(condition), - loop_body_(loop_body), - condition_deletable_(branch_deletable(condition_)), - loop_body_deletable_(branch_deletable(loop_body_)) - {} - - ~while_loop_bc_node() - { - if (condition_ && condition_deletable_) + + inline range_t range() const { - delete condition_; + return rp_; } - - if (loop_body_ && loop_body_deletable_) + + inline virtual std::string& ref() { - delete loop_body_; - } - } - - inline T value() const - { - T result = T(0); - while (is_true(condition_)) - { - try - { - result = loop_body_->value(); - } - catch(const break_exception& e) - { - return e.value; - } - catch(const continue_exception&) - {} + return (*value_); } - return result; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_while; - } - - private: - - expression_ptr condition_; - expression_ptr loop_body_; - bool condition_deletable_; - bool loop_body_deletable_; - }; - - template - class repeat_until_loop_bc_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - repeat_until_loop_bc_node(expression_ptr condition, expression_ptr loop_body) - : condition_(condition), - loop_body_(loop_body), - condition_deletable_(branch_deletable(condition_)), - loop_body_deletable_(branch_deletable(loop_body_)) - {} - - ~repeat_until_loop_bc_node() - { - if (condition_ && condition_deletable_) + + inline virtual const std::string& ref() const { - delete condition_; + return (*value_); } - - if (loop_body_ && loop_body_deletable_) + + inline range_t& range_ref() { - delete loop_body_; + return rp_; } - } - - inline T value() const - { - T result = T(0); - - do - { - try - { - result = loop_body_->value(); - } - catch(const break_exception& e) - { - return e.value; - } - catch(const continue_exception&) - {} - } - while (is_false(condition_)); - - return result; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_repeat; - } - - private: - - expression_ptr condition_; - expression_ptr loop_body_; - bool condition_deletable_; - bool loop_body_deletable_; - }; - - template - class for_loop_bc_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - for_loop_bc_node(expression_ptr initialiser, - expression_ptr condition, - expression_ptr incrementor, - expression_ptr loop_body) - : initialiser_(initialiser), - condition_ (condition ), - incrementor_(incrementor), - loop_body_ (loop_body ), - initialiser_deletable_(branch_deletable(initialiser_)), - condition_deletable_ (branch_deletable(condition_ )), - incrementor_deletable_(branch_deletable(incrementor_)), - loop_body_deletable_ (branch_deletable(loop_body_ )) - {} - - ~for_loop_bc_node() - { - if (initialiser_ && initialiser_deletable_) + + inline const range_t& range_ref() const { - delete initialiser_; + return rp_; } - - if (condition_ && condition_deletable_) + + inline typename expression_node::node_type type() const { - delete condition_; + return expression_node::e_stringvarrng; } - - if (incrementor_ && incrementor_deletable_) + + private: + + std::string* value_; + range_t rp_; + }; + + template + std::string string_range_node::null_value = std::string(""); + + template + class const_string_range_node : public expression_node , + public string_base_node, + public range_interface + { + public: + + typedef range_pack range_t; + + explicit const_string_range_node(const std::string& v, const range_t& rp) + : value_(v), + rp_(rp) + {} + + ~const_string_range_node() { - delete incrementor_; + rp_.free(); } - - if (loop_body_ && loop_body_deletable_) + + inline T value() const { - delete loop_body_; - } - } - - inline T value() const - { - T result = T(0); - - if (initialiser_) - initialiser_->value(); - - if (incrementor_) - { - while (is_true(condition_)) - { - try - { - result = loop_body_->value(); - } - catch(const break_exception& e) - { - return e.value; - } - catch(const continue_exception&) - {} - - incrementor_->value(); - } + return std::numeric_limits::quiet_NaN(); } - else + + std::string str() const { - while (is_true(condition_)) - { - try - { - result = loop_body_->value(); - } - catch(const break_exception& e) - { - return e.value; - } - catch(const continue_exception&) - {} - } + return value_; } - - return result; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_for; - } - - private: - - expression_ptr initialiser_; - expression_ptr condition_ ; - expression_ptr incrementor_; - expression_ptr loop_body_ ; - bool initialiser_deletable_; - bool condition_deletable_ ; - bool incrementor_deletable_; - bool loop_body_deletable_ ; - }; - #endif - - template - class switch_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - template class Sequence> - switch_node(const Sequence& arg_list) - { - if (1 != (arg_list.size() & 1)) - return; - - arg_list_.resize(arg_list.size()); - delete_branch_.resize(arg_list.size()); - - for (std::size_t i = 0; i < arg_list.size(); ++i) + + const char* base() const { - if (arg_list[i]) - { - arg_list_[i] = arg_list[i]; - delete_branch_[i] = static_cast(branch_deletable(arg_list_[i]) ? 1 : 0); - } - else - { - arg_list_.clear(); - delete_branch_.clear(); - return; - } - } - } - - ~switch_node() - { - for (std::size_t i = 0; i < arg_list_.size(); ++i) + return value_.data(); + } + + std::size_t size() const { - if (arg_list_[i] && delete_branch_[i]) - { - delete arg_list_[i]; - arg_list_[i] = 0; - } + return value_.size(); } - } - - inline T value() const - { - if (!arg_list_.empty()) + + range_t range() const { - const std::size_t upper_bound = (arg_list_.size() - 1); - - for (std::size_t i = 0; i < upper_bound; i += 2) - { - expression_ptr condition = arg_list_[i ]; - expression_ptr consequent = arg_list_[i + 1]; - - if (is_true(condition)) - { - return consequent->value(); - } - } - - return arg_list_[upper_bound]->value(); + return rp_; } - else - return std::numeric_limits::quiet_NaN(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_switch; - } - - private: - - std::vector arg_list_; - std::vector delete_branch_; - }; - - template - class multi_switch_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - template class Sequence> - multi_switch_node(const Sequence& arg_list) - { - if (0 != (arg_list.size() & 1)) - return; - - arg_list_.resize(arg_list.size()); - delete_branch_.resize(arg_list.size()); - - for (std::size_t i = 0; i < arg_list.size(); ++i) + + range_t& range_ref() { - if (arg_list[i]) - { - arg_list_[i] = arg_list[i]; - delete_branch_[i] = static_cast(branch_deletable(arg_list_[i]) ? 1 : 0); - } - else - { - arg_list_.clear(); - delete_branch_.clear(); - return; - } - } - } - - ~multi_switch_node() - { - for (std::size_t i = 0; i < arg_list_.size(); ++i) + return rp_; + } + + const range_t& range_ref() const { - if (arg_list_[i] && delete_branch_[i]) - { - delete arg_list_[i]; - arg_list_[i] = 0; - } + return rp_; } - } - - inline T value() const - { - T result = T(0); - - if (arg_list_.empty()) + + inline typename expression_node::node_type type() const { - return std::numeric_limits::quiet_NaN(); + return expression_node::e_cstringvarrng; } - - const std::size_t upper_bound = (arg_list_.size() - 1); - - for (std::size_t i = 0; i < upper_bound; i += 2) + + private: + + const_string_range_node& operator=(const const_string_range_node&); + + const std::string value_; + range_t rp_; + }; + + template + class generic_string_range_node : public expression_node , + public string_base_node, + public range_interface + { + public: + + typedef expression_node * expression_ptr; + typedef stringvar_node * strvar_node_ptr; + typedef string_base_node* str_base_ptr; + typedef range_pack range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + + generic_string_range_node(expression_ptr str_branch, const range_t& brange) + : initialised_(false), + branch_(str_branch), + branch_deletable_(branch_deletable(branch_)), + str_base_ptr_ (0), + str_range_ptr_(0), + base_range_(brange) + { + range_.n0_c = std::make_pair(true,0); + range_.n1_c = std::make_pair(true,0); + range_.cache.first = range_.n0_c.second; + range_.cache.second = range_.n1_c.second; + + if (is_generally_string_node(branch_)) + { + str_base_ptr_ = dynamic_cast(branch_); + + if (0 == str_base_ptr_) + return; + + str_range_ptr_ = dynamic_cast(branch_); + + if (0 == str_range_ptr_) + return; + } + + initialised_ = (str_base_ptr_ && str_range_ptr_); + } + + ~generic_string_range_node() + { + base_range_.free(); + + if (branch_ && branch_deletable_) + { + delete branch_; + branch_ = 0; + } + } + + inline T value() const + { + if (initialised_) + { + branch_->value(); + + std::size_t str_r0 = 0; + std::size_t str_r1 = 0; + + std::size_t r0 = 0; + std::size_t r1 = 0; + + range_t& range = str_range_ptr_->range_ref(); + + const std::size_t base_str_size = str_base_ptr_->size(); + + if ( + range (str_r0,str_r1,base_str_size) && + base_range_( r0, r1,base_str_size) + ) + { + const std::size_t size = (r1 - r0) + 1; + + range_.n1_c.second = size - 1; + range_.cache.second = range_.n1_c.second; + + value_.assign(str_base_ptr_->base() + str_r0 + r0, size); + } + } + + return std::numeric_limits::quiet_NaN(); + } + + std::string str() const { - expression_ptr condition = arg_list_[i ]; - expression_ptr consequent = arg_list_[i + 1]; - - if (is_true(condition)) - { - result = consequent->value(); - } + return value_; } - - return result; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_mswitch; - } - - private: - - std::vector arg_list_; - std::vector delete_branch_; - }; - - template - class ivariable - { - public: - - virtual T& ref() = 0; - virtual const T& ref() const = 0; - }; - - template - class variable_node : public expression_node, - public ivariable - { - public: - - static T null_value; - - explicit variable_node() - : value_(&null_value), - delete_value_(false) - {} - - variable_node(T& v) - : value_(&v), - delete_value_(false) - {} - - ~variable_node() - { - if (delete_value_) + + const char* base() const { - delete value_; + return &value_[0]; } - } - - inline bool operator <(const variable_node& v) const - { - return this < (&v); - } - - inline T value() const - { - return (*value_); - } - - inline T& ref() - { - return (*value_); - } - - inline const T& ref() const - { - return (*value_); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_variable; - } - - inline bool& delete_value() - { - return delete_value_; - } - - private: - - T* value_; - bool delete_value_; - }; - - template - T variable_node::null_value = T(std::numeric_limits::quiet_NaN()); - - template - struct range_pack - { - typedef expression_node* expression_node_ptr; - typedef std::pair cached_range_t; - - range_pack() - : n0_e (std::make_pair(false,expression_node_ptr(0))), - n1_e (std::make_pair(false,expression_node_ptr(0))), - n0_c (std::make_pair(false,0)), - n1_c (std::make_pair(false,0)), - cache(std::make_pair(0,0)) - {} - - void clear() - { - n0_e = std::make_pair(false,expression_node_ptr(0)); - n1_e = std::make_pair(false,expression_node_ptr(0)); - n0_c = std::make_pair(false,0); - n1_c = std::make_pair(false,0); - cache = std::make_pair(0,0); - } - - void free() - { - if (n0_e.first && n0_e.second) + + std::size_t size() const { - n0_e.first = false; - - if ( - !is_variable_node(n0_e.second) && - !is_string_node (n0_e.second) - ) - { - delete n0_e.second; - n0_e.second = expression_node_ptr(0); - } + return value_.size(); } - - if (n1_e.first && n1_e.second) + + range_t& range_ref() { - n1_e.first = false; - - if ( - !is_variable_node(n1_e.second) && - !is_string_node (n1_e.second) - ) - { - delete n1_e.second; - n1_e.second = expression_node_ptr(0); - } - } - } - - bool const_range() - { - return ( n0_c.first && n1_c.first) && - (!n0_e.first && !n1_e.first); - } - - bool var_range() - { - return ( n0_e.first && n1_e.first) && - (!n0_c.first && !n1_c.first); - } - - bool operator()(std::size_t& r0, std::size_t& r1, const std::size_t& size = std::numeric_limits::max()) const - { - if (n0_c.first) - r0 = n0_c.second; - else if (n0_e.first) + return range_; + } + + const range_t& range_ref() const { - T r0_value = n0_e.second->value(); - - if (r0_value < 0) - return false; - else - r0 = static_cast(details::numeric::to_int64(r0_value)); + return range_; } - else - return false; - - if (n1_c.first) - r1 = n1_c.second; - else if (n1_e.first) + + inline typename expression_node::node_type type() const { - T r1_value = n1_e.second->value(); - - if (r1_value < 0) - return false; - else - r1 = static_cast(details::numeric::to_int64(r1_value)); + return expression_node::e_strgenrange; } - else - return false; - - if ( - (std::numeric_limits::max() != size) && - (std::numeric_limits::max() == r1 ) - ) + + private: + + bool initialised_; + expression_ptr branch_; + bool branch_deletable_; + str_base_ptr str_base_ptr_; + irange_ptr str_range_ptr_; + mutable range_t base_range_; + mutable range_t range_; + mutable std::string value_; + }; + + template + class string_concat_node : public binary_node , + public string_base_node, + public range_interface + { + public: + + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; + typedef range_pack range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + + string_concat_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + initialised_(false), + str0_base_ptr_ (0), + str1_base_ptr_ (0), + str0_range_ptr_(0), + str1_range_ptr_(0) + { + range_.n0_c = std::make_pair(true,0); + range_.n1_c = std::make_pair(true,0); + + range_.cache.first = range_.n0_c.second; + range_.cache.second = range_.n1_c.second; + + if (is_generally_string_node(binary_node::branch_[0].first)) + { + str0_base_ptr_ = dynamic_cast(binary_node::branch_[0].first); + + if (0 == str0_base_ptr_) + return; + + str0_range_ptr_ = dynamic_cast(binary_node::branch_[0].first); + + if (0 == str0_range_ptr_) + return; + } + + if (is_generally_string_node(binary_node::branch_[1].first)) + { + str1_base_ptr_ = dynamic_cast(binary_node::branch_[1].first); + + if (0 == str1_base_ptr_) + return; + + str1_range_ptr_ = dynamic_cast(binary_node::branch_[1].first); + + if (0 == str1_range_ptr_) + return; + } + + initialised_ = str0_base_ptr_ && + str1_base_ptr_ && + str0_range_ptr_ && + str1_range_ptr_ ; + } + + inline T value() const + { + if (initialised_) + { + binary_node::branch_[0].first->value(); + binary_node::branch_[1].first->value(); + + std::size_t str0_r0 = 0; + std::size_t str0_r1 = 0; + + std::size_t str1_r0 = 0; + std::size_t str1_r1 = 0; + + range_t& range0 = str0_range_ptr_->range_ref(); + range_t& range1 = str1_range_ptr_->range_ref(); + + if ( + range0(str0_r0,str0_r1,str0_base_ptr_->size()) && + range1(str1_r0,str1_r1,str1_base_ptr_->size()) + ) + { + const std::size_t size0 = (str0_r1 - str0_r0) + 1; + const std::size_t size1 = (str1_r1 - str1_r0) + 1; + + value_.assign(str0_base_ptr_->base() + str0_r0, size0); + value_.append(str1_base_ptr_->base() + str1_r0, size1); + + range_.n1_c.second = value_.size() - 1; + range_.cache.second = range_.n1_c.second; + } + } + + return std::numeric_limits::quiet_NaN(); + } + + std::string str() const { - r1 = size - 1; + return value_; } - - cache.first = r0; - cache.second = r1; - - return (r0 <= r1); - } - - inline std::size_t const_size() const - { - return (n1_c.second - n0_c.second + 1); - } - - inline std::size_t cache_size() const - { - return (cache.second - cache.first + 1); - } - - std::pair n0_e; - std::pair n1_e; - std::pair n0_c; - std::pair n1_c; - mutable cached_range_t cache; - }; - - template - class string_base_node; - - template - struct range_data_type - { - typedef range_pack range_t; - typedef string_base_node* strbase_ptr_t; - - range_data_type() - : range(0), - data (0), - size (0), - type_size(0), - str_node (0) - {} - - range_t* range; - void* data; - std::size_t size; - std::size_t type_size; - strbase_ptr_t str_node; - }; - - template class vector_node; - - template - class vector_interface - { - public: - - typedef vector_node* vector_node_ptr; - - virtual ~vector_interface() - {} - - virtual vector_node_ptr vec() const = 0; - - virtual vector_node_ptr vec() = 0; - - virtual std::size_t size() const = 0; - }; - - template - class vector_node : public expression_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_holder vector_holder_t; - typedef vector_node* vector_node_ptr; - - vector_node(vector_holder_t* vh) - : vector_holder_(vh) - {} - - inline T value() const - { - return *(ref()[0]); - } - - inline const vector_holder_t& ref() const - { - return (*vector_holder_); - } - - inline vector_holder_t& ref() - { - return (*vector_holder_); - } - - vector_node_ptr vec() const - { - return const_cast(this); - } - - vector_node_ptr vec() - { - return this; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vector; - } - - std::size_t size() const - { - return ref().size(); - } - - private: - - vector_holder_t* vector_holder_; - }; - - template - class vector_elem_node : public expression_node, - public ivariable - { - public: - - typedef expression_node* expression_ptr; - - vector_elem_node(expression_ptr index, T* vector_base) - : index_(index), - vector_base_(vector_base), - index_deletable_(branch_deletable(index_)) - {} - - ~vector_elem_node() - { - if (index_ && index_deletable_) + + const char* base() const { - delete index_; + return &value_[0]; } - } - - inline T value() const - { - return *(vector_base_ + static_cast(details::numeric::to_int64(index_->value()))); - } - - inline T& ref() - { - return *(vector_base_ + static_cast(details::numeric::to_int64(index_->value()))); - } - - inline const T& ref() const - { - return *(vector_base_ + static_cast(details::numeric::to_int64(index_->value()))); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecelem; - } - - private: - - expression_ptr index_; - T* vector_base_; - bool index_deletable_; - }; - - template - class vector_assignment_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - vector_assignment_node(T* vector_base, - const std::size_t& size, - const std::vector& initialiser_list, - const bool single_value_initialse) - : vector_base_(vector_base), - initialiser_list_(initialiser_list), - size_(size), - single_value_initialse_(single_value_initialse) - {} - - ~vector_assignment_node() - { - for (std::size_t i = 0; i < initialiser_list_.size(); ++i) + + std::size_t size() const { - if (branch_deletable(initialiser_list_[i])) - { - delete initialiser_list_[i]; - } + return value_.size(); } - } - - inline T value() const - { - if (single_value_initialse_) + + range_t& range_ref() { - for (std::size_t i = 0; i < size_; ++i) - { - *(vector_base_ + i) = initialiser_list_[0]->value(); - } + return range_; } - else + + const range_t& range_ref() const { - std::size_t il_size = initialiser_list_.size(); - - for (std::size_t i = 0; i < il_size; ++i) - { - *(vector_base_ + i) = initialiser_list_[i]->value(); - } - - if (il_size < size_) - { - for (std::size_t i = il_size; i < size_; ++i) - { - *(vector_base_ + i) = T(0); - } - } + return range_; } - - return *(vector_base_); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecdefass; - } - - private: - - vector_assignment_node& operator=(const vector_assignment_node&); - - mutable T* vector_base_; - std::vector initialiser_list_; - const std::size_t size_; - const bool single_value_initialse_; - }; - - template - class swap_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - typedef variable_node* variable_node_ptr; - - swap_node(variable_node_ptr var0, variable_node_ptr var1) - : var0_(var0), - var1_(var1) - {} - - inline T value() const - { - std::swap(var0_->ref(),var1_->ref()); - return var1_->ref(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_swap; - } - - private: - - variable_node_ptr var0_; - variable_node_ptr var1_; - }; - - template - class swap_generic_node : public binary_node - { - public: - - typedef expression_node* expression_ptr; - typedef ivariable* ivariable_ptr; - - swap_generic_node(expression_ptr var0, expression_ptr var1) - : binary_node(details::e_swap,var0,var1), - var0_(dynamic_cast(var0)), - var1_(dynamic_cast(var1)) - {} - - inline T value() const - { - std::swap(var0_->ref(),var1_->ref()); - return var1_->ref(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_swap; - } - - private: - - ivariable_ptr var0_; - ivariable_ptr var1_; - }; - - template - class swap_vecvec_node : public binary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - - swap_vecvec_node(expression_ptr branch0, - expression_ptr branch1) - : binary_node(details::e_swap,branch0,branch1), - vec0_node_ptr_(0), - vec1_node_ptr_(0), - vec_size_ (0) - { - if (is_ivector_node(binary_node::branch_[0].first)) - { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[0].first))) - { - vec0_node_ptr_ = vi->vec(); - } + + inline typename expression_node::node_type type() const + { + return expression_node::e_strconcat; } - - if (is_ivector_node(binary_node::branch_[1].first)) + + private: + + bool initialised_; + str_base_ptr str0_base_ptr_; + str_base_ptr str1_base_ptr_; + irange_ptr str0_range_ptr_; + irange_ptr str1_range_ptr_; + mutable range_t range_; + mutable std::string value_; + }; + + template + class swap_string_node : public binary_node , + public string_base_node, + public range_interface + { + public: + + typedef expression_node * expression_ptr; + typedef stringvar_node * strvar_node_ptr; + typedef string_base_node* str_base_ptr; + typedef range_pack range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + + swap_string_node(expression_ptr branch0, expression_ptr branch1) + : binary_node(details::e_swap,branch0,branch1), + initialised_(false), + str0_node_ptr_(0), + str1_node_ptr_(0) + { + if (is_string_node(binary_node::branch_[0].first)) + { + str0_node_ptr_ = static_cast(binary_node::branch_[0].first); + } + + if (is_string_node(binary_node::branch_[1].first)) + { + str1_node_ptr_ = static_cast(binary_node::branch_[1].first); + } + + initialised_ = (str0_node_ptr_ && str1_node_ptr_); + } + + inline T value() const + { + if (initialised_) + { + binary_node::branch_[0].first->value(); + binary_node::branch_[1].first->value(); + + std::swap(str0_node_ptr_->ref(),str1_node_ptr_->ref()); + } + + return std::numeric_limits::quiet_NaN(); + } + + std::string str() const + { + return str0_node_ptr_->str(); + } + + const char* base() const + { + return str0_node_ptr_->base(); + } + + std::size_t size() const + { + return str0_node_ptr_->size(); + } + + range_t& range_ref() + { + return str0_node_ptr_->range_ref(); + } + + const range_t& range_ref() const + { + return str0_node_ptr_->range_ref(); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_strswap; + } + + private: + + bool initialised_; + strvar_node_ptr str0_node_ptr_; + strvar_node_ptr str1_node_ptr_; + }; + + template + class swap_genstrings_node : public binary_node + { + public: + + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; + typedef range_pack range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + + swap_genstrings_node(expression_ptr branch0, + expression_ptr branch1) + : binary_node(details::e_default,branch0,branch1), + str0_base_ptr_ (0), + str1_base_ptr_ (0), + str0_range_ptr_(0), + str1_range_ptr_(0), + initialised_(false) + { + if (is_generally_string_node(binary_node::branch_[0].first)) + { + str0_base_ptr_ = dynamic_cast(binary_node::branch_[0].first); + + if (0 == str0_base_ptr_) + return; + + irange_ptr range_ptr = dynamic_cast(binary_node::branch_[0].first); + + if (0 == range_ptr) + return; + + str0_range_ptr_ = &(range_ptr->range_ref()); + } + + if (is_generally_string_node(binary_node::branch_[1].first)) + { + str1_base_ptr_ = dynamic_cast(binary_node::branch_[1].first); + + if (0 == str1_base_ptr_) + return; + + irange_ptr range_ptr = dynamic_cast(binary_node::branch_[1].first); + + if (0 == range_ptr) + return; + + str1_range_ptr_ = &(range_ptr->range_ref()); + } + + initialised_ = str0_base_ptr_ && + str1_base_ptr_ && + str0_range_ptr_ && + str1_range_ptr_ ; + } + + inline T value() const + { + if (initialised_) + { + binary_node::branch_[0].first->value(); + binary_node::branch_[1].first->value(); + + std::size_t str0_r0 = 0; + std::size_t str0_r1 = 0; + + std::size_t str1_r0 = 0; + std::size_t str1_r1 = 0; + + range_t& range0 = (*str0_range_ptr_); + range_t& range1 = (*str1_range_ptr_); + + if ( + range0(str0_r0,str0_r1,str0_base_ptr_->size()) && + range1(str1_r0,str1_r1,str1_base_ptr_->size()) + ) + { + const std::size_t size0 = range0.cache_size(); + const std::size_t size1 = range1.cache_size(); + const std::size_t max_size = std::min(size0,size1); + + char* s0 = const_cast(str0_base_ptr_->base() + str0_r0); + char* s1 = const_cast(str1_base_ptr_->base() + str1_r0); + + loop_unroll::details lud(max_size); + const char* upper_bound = s0 + lud.upper_bound; + + while (s0 < upper_bound) + { +#define exprtk_loop(N) \ +std::swap(s0[N], s1[N]); \ + + exprtk_loop( 0) exprtk_loop( 1) + exprtk_loop( 2) exprtk_loop( 3) +#ifndef exprtk_disable_superscalar_unroll + exprtk_loop( 4) exprtk_loop( 5) + exprtk_loop( 6) exprtk_loop( 7) + exprtk_loop( 8) exprtk_loop( 9) + exprtk_loop(10) exprtk_loop(11) + exprtk_loop(12) exprtk_loop(13) + exprtk_loop(14) exprtk_loop(15) +#endif + + s0 += lud.batch_size; + s1 += lud.batch_size; + } + + int i = 0; + + switch (lud.remainder) + { +#define case_stmt(N) \ +case N : { std::swap(s0[i],s1[i]); ++i; } \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(15) case_stmt(14) + case_stmt(13) case_stmt(12) + case_stmt(11) case_stmt(10) + case_stmt( 9) case_stmt( 8) + case_stmt( 7) case_stmt( 6) + case_stmt( 5) case_stmt( 4) +#endif + case_stmt( 3) case_stmt( 2) + case_stmt( 1) + } + +#undef exprtk_loop +#undef case_stmt + } + } + + return std::numeric_limits::quiet_NaN(); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_strswap; + } + + private: + + swap_genstrings_node(swap_genstrings_node&); + swap_genstrings_node& operator=(swap_genstrings_node&); + + str_base_ptr str0_base_ptr_; + str_base_ptr str1_base_ptr_; + range_ptr str0_range_ptr_; + range_ptr str1_range_ptr_; + bool initialised_; + }; + + template + class stringvar_size_node : public expression_node + { + public: + + static std::string null_value; + + explicit stringvar_size_node() + : value_(&null_value) + {} + + explicit stringvar_size_node(std::string& v) + : value_(&v) + {} + + inline T value() const { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[1].first))) - { - vec1_node_ptr_ = vi->vec(); - } + return T((*value_).size()); } - - if (vec0_node_ptr_ && vec1_node_ptr_) + + inline typename expression_node::node_type type() const { - vec_size_ = std::min(vec0_node_ptr_->ref().size(), - vec1_node_ptr_->ref().size()); + return expression_node::e_stringvarsize; } - } - - inline T value() const - { - if (vec0_node_ptr_ && vec1_node_ptr_) + + private: + + std::string* value_; + }; + + template + std::string stringvar_size_node::null_value = std::string(""); + + template + class string_size_node : public expression_node + { + public: + + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; + + string_size_node(expression_ptr brnch) + : branch_(brnch), + branch_deletable_(branch_deletable(branch_)), + str_base_ptr_(0) + { + if (is_generally_string_node(branch_)) + { + str_base_ptr_ = dynamic_cast(branch_); + + if (0 == str_base_ptr_) + return; + } + } + + ~string_size_node() + { + if (branch_ && branch_deletable_) + { + delete branch_; + branch_ = 0; + } + } + + inline T value() const + { + T result = std::numeric_limits::quiet_NaN(); + + if (str_base_ptr_) + { + branch_->value(); + result = T(str_base_ptr_->size()); + } + + return result; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_stringsize; + } + + private: + + expression_ptr branch_; + bool branch_deletable_; + str_base_ptr str_base_ptr_; + }; + + struct asn_assignment + { + static inline void execute(std::string& s, const char* data, const std::size_t size) + { s.assign(data,size); } + }; + + struct asn_addassignment + { + static inline void execute(std::string& s, const char* data, const std::size_t size) + { s.append(data,size); } + }; + + template + class assignment_string_node : public binary_node , + public string_base_node, + public range_interface + { + public: + + typedef expression_node * expression_ptr; + typedef stringvar_node * strvar_node_ptr; + typedef string_base_node* str_base_ptr; + typedef range_pack range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + + assignment_string_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + initialised_(false), + str0_base_ptr_ (0), + str1_base_ptr_ (0), + str0_node_ptr_ (0), + str1_range_ptr_(0) + { + if (is_string_node(binary_node::branch_[0].first)) + { + str0_node_ptr_ = static_cast(binary_node::branch_[0].first); + + str0_base_ptr_ = dynamic_cast(binary_node::branch_[0].first); + } + + if (is_generally_string_node(binary_node::branch_[1].first)) + { + str1_base_ptr_ = dynamic_cast(binary_node::branch_[1].first); + + if (0 == str1_base_ptr_) + return; + + irange_ptr range_ptr = dynamic_cast(binary_node::branch_[1].first); + + if (0 == range_ptr) + return; + + str1_range_ptr_ = &(range_ptr->range_ref()); + } + + initialised_ = str0_base_ptr_ && + str1_base_ptr_ && + str0_node_ptr_ && + str1_range_ptr_ ; + } + + inline T value() const + { + if (initialised_) + { + binary_node::branch_[1].first->value(); + + std::size_t r0 = 0; + std::size_t r1 = 0; + + range_t& range = (*str1_range_ptr_); + + if (range(r0,r1,str1_base_ptr_->size())) + { + AssignmentProcess::execute(str0_node_ptr_->ref(), + str1_base_ptr_->base() + r0, + (r1 - r0) + 1); + + binary_node::branch_[0].first->value(); + } + } + + return std::numeric_limits::quiet_NaN(); + } + + std::string str() const + { + return str0_node_ptr_->str(); + } + + const char* base() const + { + return str0_node_ptr_->base(); + } + + std::size_t size() const + { + return str0_node_ptr_->size(); + } + + range_t& range_ref() + { + return str0_node_ptr_->range_ref(); + } + + const range_t& range_ref() const + { + return str0_node_ptr_->range_ref(); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_strass; + } + + private: + + bool initialised_; + str_base_ptr str0_base_ptr_; + str_base_ptr str1_base_ptr_; + strvar_node_ptr str0_node_ptr_; + range_ptr str1_range_ptr_; + }; + + template + class assignment_string_range_node : public binary_node , + public string_base_node, + public range_interface + { + public: + + typedef expression_node * expression_ptr; + typedef stringvar_node * strvar_node_ptr; + typedef string_base_node* str_base_ptr; + typedef range_pack range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + + assignment_string_range_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + initialised_(false), + str0_base_ptr_ (0), + str1_base_ptr_ (0), + str0_node_ptr_ (0), + str0_range_ptr_(0), + str1_range_ptr_(0) + { + if (is_string_range_node(binary_node::branch_[0].first)) + { + str0_node_ptr_ = static_cast(binary_node::branch_[0].first); + + str0_base_ptr_ = dynamic_cast(binary_node::branch_[0].first); + + irange_ptr range_ptr = dynamic_cast(binary_node::branch_[0].first); + + if (0 == range_ptr) + return; + + str0_range_ptr_ = &(range_ptr->range_ref()); + } + + if (is_generally_string_node(binary_node::branch_[1].first)) + { + str1_base_ptr_ = dynamic_cast(binary_node::branch_[1].first); + + if (0 == str1_base_ptr_) + return; + + irange_ptr range_ptr = dynamic_cast(binary_node::branch_[1].first); + + if (0 == range_ptr) + return; + + str1_range_ptr_ = &(range_ptr->range_ref()); + } + + initialised_ = str0_base_ptr_ && + str1_base_ptr_ && + str0_node_ptr_ && + str0_range_ptr_ && + str1_range_ptr_ ; + } + + inline T value() const + { + if (initialised_) + { + binary_node::branch_[0].first->value(); + binary_node::branch_[1].first->value(); + + std::size_t s0_r0 = 0; + std::size_t s0_r1 = 0; + + std::size_t s1_r0 = 0; + std::size_t s1_r1 = 0; + + range_t& range0 = (*str0_range_ptr_); + range_t& range1 = (*str1_range_ptr_); + + if ( + range0(s0_r0,s0_r1,str0_base_ptr_->size()) && + range1(s1_r0,s1_r1,str1_base_ptr_->size()) + ) + { + std::size_t size = std::min((s0_r1 - s0_r0),(s1_r1 - s1_r0)) + 1; + + std::copy(str1_base_ptr_->base() + s1_r0, + str1_base_ptr_->base() + s1_r0 + size, + const_cast(base() + s0_r0)); + } + } + + return std::numeric_limits::quiet_NaN(); + } + + std::string str() const { - binary_node::branch_[0].first->value(); - binary_node::branch_[1].first->value(); - - vector_holder& vec0 = vec0_node_ptr_->ref(); - vector_holder& vec1 = vec1_node_ptr_->ref(); - - for (std::size_t i = 0; i < vec_size_; ++i) - { - std::swap((*vec0[i]),(*vec1[i])); - } - - return vec1_node_ptr_->value(); + return str0_node_ptr_->str(); } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return vec0_node_ptr_; - } - - vector_node_ptr vec() - { - return vec0_node_ptr_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecvecswap; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node* vec0_node_ptr_; - vector_node* vec1_node_ptr_; - std::size_t vec_size_; - }; - - #ifndef exprtk_disable_string_capabilities - template - class stringvar_node : public expression_node , - public string_base_node, - public range_interface - { - public: - - typedef range_pack range_t; - - static std::string null_value; - - explicit stringvar_node() - : value_(&null_value) - {} - - explicit stringvar_node(std::string& v) - : value_(&v) - { - rp_.n0_c = std::make_pair(true,0); - rp_.n1_c = std::make_pair(true,v.size() - 1); - rp_.cache.first = rp_.n0_c.second; - rp_.cache.second = rp_.n1_c.second; - } - - inline bool operator <(const stringvar_node& v) const - { - return this < (&v); - } - - inline T value() const - { - rp_.n1_c.second = (*value_).size() - 1; - rp_.cache.second = rp_.n1_c.second; - return std::numeric_limits::quiet_NaN(); - } - - std::string str() const - { - return ref(); - } - - const char* base() const - { - return (*value_).data(); - } - - std::size_t size() const - { - return ref().size(); - } - - std::string& ref() - { - return (*value_); - } - - const std::string& ref() const - { - return (*value_); - } - - range_t& range_ref() - { - return rp_; - } - - const range_t& range_ref() const - { - return rp_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_stringvar; - } - - private: - - std::string* value_; - mutable range_t rp_; - }; - - template - std::string stringvar_node::null_value = std::string(""); - - template - class string_range_node : public expression_node , - public string_base_node, - public range_interface - { - public: - - typedef range_pack range_t; - - static std::string null_value; - - explicit string_range_node(std::string& v, range_t rp) - : value_(&v), - rp_(rp) - {} - - ~string_range_node() - { - rp_.free(); - } - - inline bool operator <(const string_range_node& v) const - { - return this < (&v); - } - - inline T value() const - { - return std::numeric_limits::quiet_NaN(); - } - - inline std::string str() const - { - return (*value_); - } - - const char* base() const - { - return (*value_).data(); - } - - std::size_t size() const - { - return ref().size(); - } - - inline range_t range() const - { - return rp_; - } - - inline virtual std::string& ref() - { - return (*value_); - } - - inline virtual const std::string& ref() const - { - return (*value_); - } - - inline range_t& range_ref() - { - return rp_; - } - - inline const range_t& range_ref() const - { - return rp_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_stringvarrng; - } - - private: - - std::string* value_; - range_t rp_; - }; - - template - std::string string_range_node::null_value = std::string(""); - - template - class const_string_range_node : public expression_node , - public string_base_node, - public range_interface - { - public: - - typedef range_pack range_t; - - explicit const_string_range_node(const std::string& v, range_t rp) - : value_(v), - rp_(rp) - {} - - ~const_string_range_node() - { - rp_.free(); - } - - inline T value() const - { - return std::numeric_limits::quiet_NaN(); - } - - std::string str() const - { - return value_; - } - - const char* base() const - { - return value_.data(); - } - - std::size_t size() const - { - return value_.size(); - } - - range_t range() const - { - return rp_; - } - - range_t& range_ref() - { - return rp_; - } - - const range_t& range_ref() const - { - return rp_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_cstringvarrng; - } - - private: - - const_string_range_node& operator=(const const_string_range_node&); - - const std::string value_; - range_t rp_; - }; - - template - class generic_string_range_node : public expression_node , - public string_base_node, - public range_interface - { - public: - - typedef expression_node * expression_ptr; - typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; - typedef typename range_t::cached_range_t cached_range_t; - - generic_string_range_node(expression_ptr str_branch, range_t brange) - : initialised_(false), - branch_(str_branch), - branch_deletable_(branch_deletable(branch_)), - str_base_ptr_ (0), - str_range_ptr_(0), - base_range_(brange) - { - range_.n0_c = std::make_pair(true,0); - range_.n1_c = std::make_pair(true,0); - range_.cache.first = range_.n0_c.second; - range_.cache.second = range_.n1_c.second; - - if (is_generally_string_node(branch_)) + + const char* base() const { - str_base_ptr_ = dynamic_cast(branch_); - - if (0 == str_base_ptr_) - return; - - str_range_ptr_ = dynamic_cast(branch_); - - if (0 == str_range_ptr_) - return; + return str0_node_ptr_->base(); } - - initialised_ = (str_base_ptr_ && str_range_ptr_); - } - - ~generic_string_range_node() - { - base_range_.free(); - - if (branch_ && branch_deletable_) + + std::size_t size() const { - delete branch_; - branch_ = 0; + return str0_node_ptr_->size(); } - } - - inline T value() const - { - if (initialised_) + + range_t& range_ref() { - branch_->value(); - - std::size_t str_r0 = 0; - std::size_t str_r1 = 0; - - std::size_t r0 = 0; - std::size_t r1 = 0; - - range_t& range = str_range_ptr_->range_ref(); - - const std::size_t base_str_size = str_base_ptr_->size(); - - if ( - range (str_r0,str_r1,base_str_size) && - base_range_( r0, r1,base_str_size) - ) - { - const std::size_t size = (r1 - r0) + 1; - - range_.n1_c.second = size - 1; - range_.cache.second = range_.n1_c.second; - - value_.assign(str_base_ptr_->base() + str_r0 + r0, size); - } + return str0_node_ptr_->range_ref(); } - - return std::numeric_limits::quiet_NaN(); - } - - std::string str() const - { - return value_; - } - - const char* base() const - { - return value_.data(); - } - - std::size_t size() const - { - return value_.size(); - } - - range_t& range_ref() - { - return range_; - } - - const range_t& range_ref() const - { - return range_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_strgenrange; - } - - private: - - bool initialised_; - expression_ptr branch_; - bool branch_deletable_; - str_base_ptr str_base_ptr_; - irange_ptr str_range_ptr_; - mutable range_t base_range_; - mutable range_t range_; - mutable std::string value_; - }; - - template - class string_concat_node : public binary_node , - public string_base_node, - public range_interface - { - public: - - typedef expression_node * expression_ptr; - typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; - typedef typename range_t::cached_range_t cached_range_t; - - string_concat_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - initialised_(false), - str0_base_ptr_ (0), - str1_base_ptr_ (0), - str0_range_ptr_(0), - str1_range_ptr_(0) - { - range_.n0_c = std::make_pair(true,0); - range_.n1_c = std::make_pair(true,0); - range_.cache.first = range_.n0_c.second; - range_.cache.second = range_.n1_c.second; - - if (is_generally_string_node(binary_node::branch_[0].first)) + + const range_t& range_ref() const { - str0_base_ptr_ = dynamic_cast(binary_node::branch_[0].first); - - if (0 == str0_base_ptr_) - return; - - str0_range_ptr_ = dynamic_cast(binary_node::branch_[0].first); - - if (0 == str0_range_ptr_) - return; + return str0_node_ptr_->range_ref(); } - - if (is_generally_string_node(binary_node::branch_[1].first)) + + inline typename expression_node::node_type type() const { - str1_base_ptr_ = dynamic_cast(binary_node::branch_[1].first); - - if (0 == str1_base_ptr_) - return; - - str1_range_ptr_ = dynamic_cast(binary_node::branch_[1].first); - - if (0 == str1_range_ptr_) - return; + return expression_node::e_strass; } - - initialised_ = str0_base_ptr_ && - str1_base_ptr_ && - str0_range_ptr_ && - str1_range_ptr_ ; - } - - inline T value() const - { - if (initialised_) + + private: + + bool initialised_; + str_base_ptr str0_base_ptr_; + str_base_ptr str1_base_ptr_; + strvar_node_ptr str0_node_ptr_; + range_ptr str0_range_ptr_; + range_ptr str1_range_ptr_; + }; + + template + class conditional_string_node : public trinary_node , + public string_base_node, + public range_interface + { + public: + + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; + typedef range_pack range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + + conditional_string_node(expression_ptr test, + expression_ptr consequent, + expression_ptr alternative) + : trinary_node(details::e_default,consequent,alternative,test), + initialised_(false), + str0_base_ptr_ (0), + str1_base_ptr_ (0), + str0_range_ptr_(0), + str1_range_ptr_(0), + test_ (test), + consequent_ (consequent), + alternative_(alternative) + { + range_.n0_c = std::make_pair(true,0); + range_.n1_c = std::make_pair(true,0); + + range_.cache.first = range_.n0_c.second; + range_.cache.second = range_.n1_c.second; + + if (is_generally_string_node(trinary_node::branch_[0].first)) + { + str0_base_ptr_ = dynamic_cast(trinary_node::branch_[0].first); + + if (0 == str0_base_ptr_) + return; + + str0_range_ptr_ = dynamic_cast(trinary_node::branch_[0].first); + + if (0 == str0_range_ptr_) + return; + } + + if (is_generally_string_node(trinary_node::branch_[1].first)) + { + str1_base_ptr_ = dynamic_cast(trinary_node::branch_[1].first); + + if (0 == str1_base_ptr_) + return; + + str1_range_ptr_ = dynamic_cast(trinary_node::branch_[1].first); + + if (0 == str1_range_ptr_) + return; + } + + initialised_ = str0_base_ptr_ && + str1_base_ptr_ && + str0_range_ptr_ && + str1_range_ptr_ ; + + } + + inline T value() const + { + if (initialised_) + { + std::size_t r0 = 0; + std::size_t r1 = 0; + + if (is_true(test_)) + { + consequent_->value(); + + range_t& range = str0_range_ptr_->range_ref(); + + if (range(r0,r1,str0_base_ptr_->size())) + { + const std::size_t size = (r1 - r0) + 1; + + value_.assign(str0_base_ptr_->base() + r0, size); + + range_.n1_c.second = value_.size() - 1; + range_.cache.second = range_.n1_c.second; + + return T(1); + } + } + else + { + alternative_->value(); + + range_t& range = str1_range_ptr_->range_ref(); + + if (range(r0,r1,str1_base_ptr_->size())) + { + const std::size_t size = (r1 - r0) + 1; + + value_.assign(str1_base_ptr_->base() + r0, size); + + range_.n1_c.second = value_.size() - 1; + range_.cache.second = range_.n1_c.second; + + return T(0); + } + } + } + + return std::numeric_limits::quiet_NaN(); + } + + std::string str() const { - binary_node::branch_[0].first->value(); - binary_node::branch_[1].first->value(); - - std::size_t str0_r0 = 0; - std::size_t str0_r1 = 0; - - std::size_t str1_r0 = 0; - std::size_t str1_r1 = 0; - - range_t& range0 = str0_range_ptr_->range_ref(); - range_t& range1 = str1_range_ptr_->range_ref(); - - if ( - range0(str0_r0,str0_r1,str0_base_ptr_->size()) && - range1(str1_r0,str1_r1,str1_base_ptr_->size()) - ) - { - const std::size_t size0 = (str0_r1 - str0_r0) + 1; - const std::size_t size1 = (str1_r1 - str1_r0) + 1; - - value_.assign(str0_base_ptr_->base() + str0_r0, size0); - value_.append(str1_base_ptr_->base() + str1_r0, size1); - - range_.n1_c.second = value_.size() - 1; - range_.cache.second = range_.n1_c.second; - } + return value_; } - - return std::numeric_limits::quiet_NaN(); - } - - std::string str() const - { - return value_; - } - - const char* base() const - { - return value_.data(); - } - - std::size_t size() const - { - return value_.size(); - } - - range_t& range_ref() - { - return range_; - } - - const range_t& range_ref() const - { - return range_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_strconcat; - } - - private: - - bool initialised_; - str_base_ptr str0_base_ptr_; - str_base_ptr str1_base_ptr_; - irange_ptr str0_range_ptr_; - irange_ptr str1_range_ptr_; - mutable range_t range_; - mutable std::string value_; - }; - - template - class swap_string_node : public binary_node , - public string_base_node, - public range_interface - { - public: - - typedef expression_node * expression_ptr; - typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; - typedef typename range_t::cached_range_t cached_range_t; - - swap_string_node(expression_ptr branch0, expression_ptr branch1) - : binary_node(details::e_swap,branch0,branch1), - initialised_(false), - str0_node_ptr_(0), - str1_node_ptr_(0) - { - if (is_string_node(binary_node::branch_[0].first)) + + const char* base() const { - str0_node_ptr_ = static_cast(binary_node::branch_[0].first); + return &value_[0]; } - - if (is_string_node(binary_node::branch_[1].first)) + + std::size_t size() const { - str1_node_ptr_ = static_cast(binary_node::branch_[1].first); + return value_.size(); } - - initialised_ = (str0_node_ptr_ && str1_node_ptr_); - } - - inline T value() const - { - if (initialised_) + + range_t& range_ref() { - binary_node::branch_[0].first->value(); - binary_node::branch_[1].first->value(); - - std::swap(str0_node_ptr_->ref(),str1_node_ptr_->ref()); + return range_; } - - return std::numeric_limits::quiet_NaN(); - } - - std::string str() const - { - return str0_node_ptr_->str(); - } - - const char* base() const - { - return str0_node_ptr_->base(); - } - - std::size_t size() const - { - return str0_node_ptr_->size(); - } - - range_t& range_ref() - { - return str0_node_ptr_->range_ref(); - } - - const range_t& range_ref() const - { - return str0_node_ptr_->range_ref(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_strswap; - } - - private: - - bool initialised_; - strvar_node_ptr str0_node_ptr_; - strvar_node_ptr str1_node_ptr_; - }; - - template - class stringvar_size_node : public expression_node - { - public: - - static std::string null_value; - - explicit stringvar_size_node() - : value_(&null_value) - {} - - explicit stringvar_size_node(std::string& v) - : value_(&v) - {} - - inline T value() const - { - return T((*value_).size()); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_stringvarsize; - } - - private: - - std::string* value_; - }; - - template - std::string stringvar_size_node::null_value = std::string(""); - - template - class string_size_node : public expression_node - { - public: - - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - - string_size_node(expression_ptr brnch) - : branch_(brnch), - branch_deletable_(branch_deletable(branch_)), - str_base_ptr_(0) - { - if (is_generally_string_node(branch_)) - { - str_base_ptr_ = dynamic_cast(branch_); - - if (0 == str_base_ptr_) - return; + + const range_t& range_ref() const + { + return range_; } - } - - ~string_size_node() - { - if (branch_ && branch_deletable_) + + inline typename expression_node::node_type type() const { - delete branch_; - branch_ = 0; + return expression_node::e_strcondition; } - } - - inline T value() const - { - T result = std::numeric_limits::quiet_NaN(); - - if (str_base_ptr_) + + private: + + bool initialised_; + str_base_ptr str0_base_ptr_; + str_base_ptr str1_base_ptr_; + irange_ptr str0_range_ptr_; + irange_ptr str1_range_ptr_; + mutable range_t range_; + mutable std::string value_; + + expression_ptr test_; + expression_ptr consequent_; + expression_ptr alternative_; + }; + + template + class cons_conditional_str_node : public binary_node , + public string_base_node, + public range_interface + { + public: + + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; + typedef range_pack range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + + cons_conditional_str_node(expression_ptr test, + expression_ptr consequent) + : binary_node(details::e_default,consequent,test), + initialised_(false), + str0_base_ptr_ (0), + str0_range_ptr_(0), + test_ (test), + consequent_(consequent) + { + range_.n0_c = std::make_pair(true,0); + range_.n1_c = std::make_pair(true,0); + + range_.cache.first = range_.n0_c.second; + range_.cache.second = range_.n1_c.second; + + if (is_generally_string_node(binary_node::branch_[0].first)) + { + str0_base_ptr_ = dynamic_cast(binary_node::branch_[0].first); + + if (0 == str0_base_ptr_) + return; + + str0_range_ptr_ = dynamic_cast(binary_node::branch_[0].first); + + if (0 == str0_range_ptr_) + return; + } + + initialised_ = str0_base_ptr_ && str0_range_ptr_ ; + } + + inline T value() const + { + if (initialised_) + { + if (is_true(test_)) + { + consequent_->value(); + + range_t& range = str0_range_ptr_->range_ref(); + + std::size_t r0 = 0; + std::size_t r1 = 0; + + if (range(r0,r1,str0_base_ptr_->size())) + { + const std::size_t size = (r1 - r0) + 1; + + value_.assign(str0_base_ptr_->base() + r0, size); + + range_.n1_c.second = value_.size() - 1; + range_.cache.second = range_.n1_c.second; + + return T(1); + } + } + } + + return std::numeric_limits::quiet_NaN(); + } + + std::string str() const { - branch_->value(); - result = T(str_base_ptr_->size()); + return value_; } - - return result; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_stringsize; - } - - private: - - expression_ptr branch_; - bool branch_deletable_; - str_base_ptr str_base_ptr_; - }; - - struct asn_assignment - { - static inline void execute(std::string& s, const char* data, const std::size_t size) - { s.assign(data,size); } - }; - - struct asn_addassignment - { - static inline void execute(std::string& s, const char* data, const std::size_t size) - { s.append(data,size); } - }; - - template - class assignment_string_node : public binary_node , - public string_base_node, - public range_interface - { - public: - - typedef expression_node * expression_ptr; - typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; - typedef typename range_t::cached_range_t cached_range_t; - - assignment_string_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - initialised_(false), - str0_base_ptr_ (0), - str1_base_ptr_ (0), - str0_node_ptr_ (0), - str1_range_ptr_(0) - { - if (is_string_node(binary_node::branch_[0].first)) - { - str0_node_ptr_ = static_cast(binary_node::branch_[0].first); - - str0_base_ptr_ = dynamic_cast(binary_node::branch_[0].first); + + const char* base() const + { + return &value_[0]; } - - if (is_generally_string_node(binary_node::branch_[1].first)) + + std::size_t size() const { - str1_base_ptr_ = dynamic_cast(binary_node::branch_[1].first); - - if (0 == str1_base_ptr_) - return; - - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[1].first); - - if (0 == range_ptr) - return; - - str1_range_ptr_ = &(range_ptr->range_ref()); + return value_.size(); } - - initialised_ = str0_base_ptr_ && - str1_base_ptr_ && - str0_node_ptr_ && - str1_range_ptr_ ; - } - - inline T value() const - { - if (initialised_) + + range_t& range_ref() { - binary_node::branch_[1].first->value(); - - std::size_t r0 = 0; - std::size_t r1 = 0; - - range_t& range = (*str1_range_ptr_); - - if (range(r0,r1,str1_base_ptr_->size())) - { - AssignmentProcess::execute(str0_node_ptr_->ref(), - str1_base_ptr_->base() + r0, - (r1 - r0) + 1); - - binary_node::branch_[0].first->value(); - } + return range_; } - - return std::numeric_limits::quiet_NaN(); - } - - std::string str() const - { - return str0_node_ptr_->str(); - } - - const char* base() const - { - return str0_node_ptr_->base(); - } - - std::size_t size() const - { - return str0_node_ptr_->size(); - } - - range_t& range_ref() - { - return str0_node_ptr_->range_ref(); - } - - const range_t& range_ref() const - { - return str0_node_ptr_->range_ref(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_strass; - } - - private: - - bool initialised_; - str_base_ptr str0_base_ptr_; - str_base_ptr str1_base_ptr_; - strvar_node_ptr str0_node_ptr_; - range_ptr str1_range_ptr_; - }; - - template - class assignment_string_range_node : public binary_node , - public string_base_node, - public range_interface - { - public: - - typedef expression_node * expression_ptr; - typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; - typedef typename range_t::cached_range_t cached_range_t; - - assignment_string_range_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - initialised_(false), - str0_base_ptr_ (0), - str1_base_ptr_ (0), - str0_node_ptr_ (0), - str0_range_ptr_(0), - str1_range_ptr_(0) - { - if (is_string_range_node(binary_node::branch_[0].first)) - { - str0_node_ptr_ = static_cast(binary_node::branch_[0].first); - - str0_base_ptr_ = dynamic_cast(binary_node::branch_[0].first); - - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[0].first); - - if (0 == range_ptr) - return; - - str0_range_ptr_ = &(range_ptr->range_ref()); + + const range_t& range_ref() const + { + return range_; } - - if (is_generally_string_node(binary_node::branch_[1].first)) + + inline typename expression_node::node_type type() const { - str1_base_ptr_ = dynamic_cast(binary_node::branch_[1].first); - - if (0 == str1_base_ptr_) - return; - - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[1].first); - - if (0 == range_ptr) - return; - - str1_range_ptr_ = &(range_ptr->range_ref()); + return expression_node::e_strccondition; } - - initialised_ = str0_base_ptr_ && - str1_base_ptr_ && - str0_node_ptr_ && - str0_range_ptr_ && - str1_range_ptr_ ; - } - - inline T value() const - { - if (initialised_) + + private: + + bool initialised_; + str_base_ptr str0_base_ptr_; + irange_ptr str0_range_ptr_; + mutable range_t range_; + mutable std::string value_; + + expression_ptr test_; + expression_ptr consequent_; + }; +#endif + + template + inline T axn(T a, T x) + { + // a*x^n + return a * exprtk::details::numeric::fast_exp::result(x); + } + + template + inline T axnb(T a, T x, T b) + { + // a*x^n+b + return a * exprtk::details::numeric::fast_exp::result(x) + b; + } + + template + struct sf_base + { + typedef typename details::functor_t::Type Type; + typedef typename details::functor_t functor_t; + typedef typename functor_t::qfunc_t quaternary_functor_t; + typedef typename functor_t::tfunc_t trinary_functor_t; + typedef typename functor_t::bfunc_t binary_functor_t; + typedef typename functor_t::ufunc_t unary_functor_t; + }; + +#define define_sfop3(NN,OP0,OP1) \ +template \ +struct sf##NN##_op : public sf_base \ +{ \ +typedef typename sf_base::Type Type; \ +static inline T process(Type x, Type y, Type z) \ +{ \ +return (OP0); \ +} \ +static inline std::string id() \ +{ \ +return OP1; \ +} \ +}; \ + + define_sfop3(00,(x + y) / z ,"(t+t)/t") + define_sfop3(01,(x + y) * z ,"(t+t)*t") + define_sfop3(02,(x + y) - z ,"(t+t)-t") + define_sfop3(03,(x + y) + z ,"(t+t)+t") + define_sfop3(04,(x - y) + z ,"(t-t)+t") + define_sfop3(05,(x - y) / z ,"(t-t)/t") + define_sfop3(06,(x - y) * z ,"(t-t)*t") + define_sfop3(07,(x * y) + z ,"(t*t)+t") + define_sfop3(08,(x * y) - z ,"(t*t)-t") + define_sfop3(09,(x * y) / z ,"(t*t)/t") + define_sfop3(10,(x * y) * z ,"(t*t)*t") + define_sfop3(11,(x / y) + z ,"(t/t)+t") + define_sfop3(12,(x / y) - z ,"(t/t)-t") + define_sfop3(13,(x / y) / z ,"(t/t)/t") + define_sfop3(14,(x / y) * z ,"(t/t)*t") + define_sfop3(15,x / (y + z) ,"t/(t+t)") + define_sfop3(16,x / (y - z) ,"t/(t-t)") + define_sfop3(17,x / (y * z) ,"t/(t*t)") + define_sfop3(18,x / (y / z) ,"t/(t/t)") + define_sfop3(19,x * (y + z) ,"t*(t+t)") + define_sfop3(20,x * (y - z) ,"t*(t-t)") + define_sfop3(21,x * (y * z) ,"t*(t*t)") + define_sfop3(22,x * (y / z) ,"t*(t/t)") + define_sfop3(23,x - (y + z) ,"t-(t+t)") + define_sfop3(24,x - (y - z) ,"t-(t-t)") + define_sfop3(25,x - (y / z) ,"t-(t/t)") + define_sfop3(26,x - (y * z) ,"t-(t*t)") + define_sfop3(27,x + (y * z) ,"t+(t*t)") + define_sfop3(28,x + (y / z) ,"t+(t/t)") + define_sfop3(29,x + (y + z) ,"t+(t+t)") + define_sfop3(30,x + (y - z) ,"t+(t-t)") + define_sfop3(31,(axnb(x,y,z))," ") + define_sfop3(32,(axnb(x,y,z))," ") + define_sfop3(33,(axnb(x,y,z))," ") + define_sfop3(34,(axnb(x,y,z))," ") + define_sfop3(35,(axnb(x,y,z))," ") + define_sfop3(36,(axnb(x,y,z))," ") + define_sfop3(37,(axnb(x,y,z))," ") + define_sfop3(38,(axnb(x,y,z))," ") + define_sfop3(39,x * numeric::log(y) + z,"") + define_sfop3(40,x * numeric::log(y) - z,"") + define_sfop3(41,x * numeric::log10(y) + z,"") + define_sfop3(42,x * numeric::log10(y) - z,"") + define_sfop3(43,x * numeric::sin(y) + z ,"") + define_sfop3(44,x * numeric::sin(y) - z ,"") + define_sfop3(45,x * numeric::cos(y) + z ,"") + define_sfop3(46,x * numeric::cos(y) - z ,"") + define_sfop3(47,details::is_true(x) ? y : z,"") + +#define define_sfop4(NN,OP0,OP1) \ +template \ +struct sf##NN##_op : public sf_base \ +{ \ +typedef typename sf_base::Type Type; \ +static inline T process(Type x, Type y, Type z, Type w) \ +{ \ +return (OP0); \ +} \ +static inline std::string id() { return OP1; } \ +}; \ + + define_sfop4(48,(x + ((y + z) / w)),"t+((t+t)/t)") + define_sfop4(49,(x + ((y + z) * w)),"t+((t+t)*t)") + define_sfop4(50,(x + ((y - z) / w)),"t+((t-t)/t)") + define_sfop4(51,(x + ((y - z) * w)),"t+((t-t)*t)") + define_sfop4(52,(x + ((y * z) / w)),"t+((t*t)/t)") + define_sfop4(53,(x + ((y * z) * w)),"t+((t*t)*t)") + define_sfop4(54,(x + ((y / z) + w)),"t+((t/t)+t)") + define_sfop4(55,(x + ((y / z) / w)),"t+((t/t)/t)") + define_sfop4(56,(x + ((y / z) * w)),"t+((t/t)*t)") + define_sfop4(57,(x - ((y + z) / w)),"t-((t+t)/t)") + define_sfop4(58,(x - ((y + z) * w)),"t-((t+t)*t)") + define_sfop4(59,(x - ((y - z) / w)),"t-((t-t)/t)") + define_sfop4(60,(x - ((y - z) * w)),"t-((t-t)*t)") + define_sfop4(61,(x - ((y * z) / w)),"t-((t*t)/t)") + define_sfop4(62,(x - ((y * z) * w)),"t-((t*t)*t)") + define_sfop4(63,(x - ((y / z) / w)),"t-((t/t)/t)") + define_sfop4(64,(x - ((y / z) * w)),"t-((t/t)*t)") + define_sfop4(65,(((x + y) * z) - w),"((t+t)*t)-t") + define_sfop4(66,(((x - y) * z) - w),"((t-t)*t)-t") + define_sfop4(67,(((x * y) * z) - w),"((t*t)*t)-t") + define_sfop4(68,(((x / y) * z) - w),"((t/t)*t)-t") + define_sfop4(69,(((x + y) / z) - w),"((t+t)/t)-t") + define_sfop4(70,(((x - y) / z) - w),"((t-t)/t)-t") + define_sfop4(71,(((x * y) / z) - w),"((t*t)/t)-t") + define_sfop4(72,(((x / y) / z) - w),"((t/t)/t)-t") + define_sfop4(73,((x * y) + (z * w)),"(t*t)+(t*t)") + define_sfop4(74,((x * y) - (z * w)),"(t*t)-(t*t)") + define_sfop4(75,((x * y) + (z / w)),"(t*t)+(t/t)") + define_sfop4(76,((x * y) - (z / w)),"(t*t)-(t/t)") + define_sfop4(77,((x / y) + (z / w)),"(t/t)+(t/t)") + define_sfop4(78,((x / y) - (z / w)),"(t/t)-(t/t)") + define_sfop4(79,((x / y) - (z * w)),"(t/t)-(t*t)") + define_sfop4(80,(x / (y + (z * w))),"t/(t+(t*t))") + define_sfop4(81,(x / (y - (z * w))),"t/(t-(t*t))") + define_sfop4(82,(x * (y + (z * w))),"t*(t+(t*t))") + define_sfop4(83,(x * (y - (z * w))),"t*(t-(t*t))") + + define_sfop4(84,(axn(x,y) + axn(z,w)),"") + define_sfop4(85,(axn(x,y) + axn(z,w)),"") + define_sfop4(86,(axn(x,y) + axn(z,w)),"") + define_sfop4(87,(axn(x,y) + axn(z,w)),"") + define_sfop4(88,(axn(x,y) + axn(z,w)),"") + define_sfop4(89,(axn(x,y) + axn(z,w)),"") + define_sfop4(90,(axn(x,y) + axn(z,w)),"") + define_sfop4(91,(axn(x,y) + axn(z,w)),"") + define_sfop4(92,((details::is_true(x) && details::is_true(y)) ? z : w),"") + define_sfop4(93,((details::is_true(x) || details::is_true(y)) ? z : w),"") + define_sfop4(94,((x < y) ? z : w),"") + define_sfop4(95,((x <= y) ? z : w),"") + define_sfop4(96,((x > y) ? z : w),"") + define_sfop4(97,((x >= y) ? z : w),"") + define_sfop4(98,(details::is_true(numeric::equal(x,y)) ? z : w),"") + define_sfop4(99,(x * numeric::sin(y) + z * numeric::cos(w)),"") + + define_sfop4(ext00,((x + y) - (z * w)),"(t+t)-(t*t)") + define_sfop4(ext01,((x + y) - (z / w)),"(t+t)-(t/t)") + define_sfop4(ext02,((x + y) + (z * w)),"(t+t)+(t*t)") + define_sfop4(ext03,((x + y) + (z / w)),"(t+t)+(t/t)") + define_sfop4(ext04,((x - y) + (z * w)),"(t-t)+(t*t)") + define_sfop4(ext05,((x - y) + (z / w)),"(t-t)+(t/t)") + define_sfop4(ext06,((x - y) - (z * w)),"(t-t)-(t*t)") + define_sfop4(ext07,((x - y) - (z / w)),"(t-t)-(t/t)") + define_sfop4(ext08,((x + y) - (z - w)),"(t+t)-(t-t)") + define_sfop4(ext09,((x + y) + (z - w)),"(t+t)+(t-t)") + define_sfop4(ext10,((x + y) * (z - w)),"(t+t)*(t-t)") + define_sfop4(ext11,((x + y) / (z - w)),"(t+t)/(t-t)") + define_sfop4(ext12,((x - y) - (z + w)),"(t-t)-(t+t)") + define_sfop4(ext13,((x - y) + (z + w)),"(t-t)+(t+t)") + define_sfop4(ext14,((x - y) * (z + w)),"(t-t)*(t+t)") + define_sfop4(ext15,((x - y) / (z + w)),"(t-t)/(t+t)") + define_sfop4(ext16,((x * y) - (z + w)),"(t*t)-(t+t)") + define_sfop4(ext17,((x / y) - (z + w)),"(t/t)-(t+t)") + define_sfop4(ext18,((x * y) + (z + w)),"(t*t)+(t+t)") + define_sfop4(ext19,((x / y) + (z + w)),"(t/t)+(t+t)") + define_sfop4(ext20,((x * y) + (z - w)),"(t*t)+(t-t)") + define_sfop4(ext21,((x / y) + (z - w)),"(t/t)+(t-t)") + define_sfop4(ext22,((x * y) - (z - w)),"(t*t)-(t-t)") + define_sfop4(ext23,((x / y) - (z - w)),"(t/t)-(t-t)") + define_sfop4(ext24,((x + y) * (z * w)),"(t+t)*(t*t)") + define_sfop4(ext25,((x + y) * (z / w)),"(t+t)*(t/t)") + define_sfop4(ext26,((x + y) / (z * w)),"(t+t)/(t*t)") + define_sfop4(ext27,((x + y) / (z / w)),"(t+t)/(t/t)") + define_sfop4(ext28,((x - y) / (z * w)),"(t-t)/(t*t)") + define_sfop4(ext29,((x - y) / (z / w)),"(t-t)/(t/t)") + define_sfop4(ext30,((x - y) * (z * w)),"(t-t)*(t*t)") + define_sfop4(ext31,((x - y) * (z / w)),"(t-t)*(t/t)") + define_sfop4(ext32,((x * y) * (z + w)),"(t*t)*(t+t)") + define_sfop4(ext33,((x / y) * (z + w)),"(t/t)*(t+t)") + define_sfop4(ext34,((x * y) / (z + w)),"(t*t)/(t+t)") + define_sfop4(ext35,((x / y) / (z + w)),"(t/t)/(t+t)") + define_sfop4(ext36,((x * y) / (z - w)),"(t*t)/(t-t)") + define_sfop4(ext37,((x / y) / (z - w)),"(t/t)/(t-t)") + define_sfop4(ext38,((x * y) * (z - w)),"(t*t)*(t-t)") + define_sfop4(ext39,((x * y) / (z * w)),"(t*t)/(t*t)") + define_sfop4(ext40,((x / y) * (z / w)),"(t/t)*(t/t)") + define_sfop4(ext41,((x / y) * (z - w)),"(t/t)*(t-t)") + define_sfop4(ext42,((x * y) * (z * w)),"(t*t)*(t*t)") + define_sfop4(ext43,(x + (y * (z / w))),"t+(t*(t/t))") + define_sfop4(ext44,(x - (y * (z / w))),"t-(t*(t/t))") + define_sfop4(ext45,(x + (y / (z * w))),"t+(t/(t*t))") + define_sfop4(ext46,(x - (y / (z * w))),"t-(t/(t*t))") + define_sfop4(ext47,(((x - y) - z) * w),"((t-t)-t)*t") + define_sfop4(ext48,(((x - y) - z) / w),"((t-t)-t)/t") + define_sfop4(ext49,(((x - y) + z) * w),"((t-t)+t)*t") + define_sfop4(ext50,(((x - y) + z) / w),"((t-t)+t)/t") + define_sfop4(ext51,((x + (y - z)) * w),"(t+(t-t))*t") + define_sfop4(ext52,((x + (y - z)) / w),"(t+(t-t))/t") + define_sfop4(ext53,((x + y) / (z + w)),"(t+t)/(t+t)") + define_sfop4(ext54,((x - y) / (z - w)),"(t-t)/(t-t)") + define_sfop4(ext55,((x + y) * (z + w)),"(t+t)*(t+t)") + define_sfop4(ext56,((x - y) * (z - w)),"(t-t)*(t-t)") + define_sfop4(ext57,((x - y) + (z - w)),"(t-t)+(t-t)") + define_sfop4(ext58,((x - y) - (z - w)),"(t-t)-(t-t)") + define_sfop4(ext59,((x / y) + (z * w)),"(t/t)+(t*t)") + define_sfop4(ext60,(((x * y) * z) / w),"((t*t)*t)/t") + +#undef define_sfop3 +#undef define_sfop4 + + template + class sf3_node : public trinary_node + { + public: + + typedef expression_node* expression_ptr; + + sf3_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1, + expression_ptr branch2) + : trinary_node(opr,branch0,branch1,branch2) + {} + + inline T value() const { - binary_node::branch_[0].first->value(); - binary_node::branch_[1].first->value(); - - std::size_t s0_r0 = 0; - std::size_t s0_r1 = 0; - - std::size_t s1_r0 = 0; - std::size_t s1_r1 = 0; - - range_t& range0 = (*str0_range_ptr_); - range_t& range1 = (*str1_range_ptr_); - - if ( - range0(s0_r0,s0_r1,str0_base_ptr_->size()) && - range1(s1_r0,s1_r1,str1_base_ptr_->size()) - ) - { - std::size_t size = std::min((s0_r1 - s0_r0),(s1_r1 - s1_r0)) + 1; - - std::copy(str1_base_ptr_->base() + s1_r0, - str1_base_ptr_->base() + s1_r0 + size, - const_cast(base() + s0_r0)); - } + const T x = trinary_node::branch_[0].first->value(); + const T y = trinary_node::branch_[1].first->value(); + const T z = trinary_node::branch_[2].first->value(); + + return SpecialFunction::process(x,y,z); } - - return std::numeric_limits::quiet_NaN(); - } - - std::string str() const - { - return str0_node_ptr_->str(); - } - - const char* base() const - { - return str0_node_ptr_->base(); - } - - std::size_t size() const - { - return str0_node_ptr_->size(); - } - - range_t& range_ref() - { - return str0_node_ptr_->range_ref(); - } - - const range_t& range_ref() const - { - return str0_node_ptr_->range_ref(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_strass; - } - - private: - - bool initialised_; - str_base_ptr str0_base_ptr_; - str_base_ptr str1_base_ptr_; - strvar_node_ptr str0_node_ptr_; - range_ptr str0_range_ptr_; - range_ptr str1_range_ptr_; - }; - #endif - - template - inline T axn(T a, T x) - { - // a*x^n - return a * exprtk::details::numeric::fast_exp::result(x); - } - - template - inline T axnb(T a, T x, T b) - { - // a*x^n+b - return a * exprtk::details::numeric::fast_exp::result(x) + b; - } - - template - struct sf_base - { - typedef typename details::functor_t::Type Type; - typedef typename details::functor_t functor_t; - typedef typename functor_t::qfunc_t quaternary_functor_t; - typedef typename functor_t::tfunc_t trinary_functor_t; - typedef typename functor_t::bfunc_t binary_functor_t; - typedef typename functor_t::ufunc_t unary_functor_t; - }; - - #define define_sfop3(NN,OP0,OP1) \ - template \ - struct sf##NN##_op : public sf_base \ - { \ - typedef typename sf_base::Type Type; \ - static inline T process(Type x, Type y, Type z) \ - { \ - return (OP0); \ - } \ - static inline std::string id() \ - { \ - return OP1; \ - } \ - }; \ - - define_sfop3(00,(x + y) / z ,"(t+t)/t") - define_sfop3(01,(x + y) * z ,"(t+t)*t") - define_sfop3(02,(x + y) - z ,"(t+t)-t") - define_sfop3(03,(x + y) + z ,"(t+t)+t") - define_sfop3(04,(x - y) + z ,"(t-t)+t") - define_sfop3(05,(x - y) / z ,"(t-t)/t") - define_sfop3(06,(x - y) * z ,"(t-t)*t") - define_sfop3(07,(x * y) + z ,"(t*t)+t") - define_sfop3(08,(x * y) - z ,"(t*t)-t") - define_sfop3(09,(x * y) / z ,"(t*t)/t") - define_sfop3(10,(x * y) * z ,"(t*t)*t") - define_sfop3(11,(x / y) + z ,"(t/t)+t") - define_sfop3(12,(x / y) - z ,"(t/t)-t") - define_sfop3(13,(x / y) / z ,"(t/t)/t") - define_sfop3(14,(x / y) * z ,"(t/t)*t") - define_sfop3(15,x / (y + z) ,"t/(t+t)") - define_sfop3(16,x / (y - z) ,"t/(t-t)") - define_sfop3(17,x / (y * z) ,"t/(t*t)") - define_sfop3(18,x / (y / z) ,"t/(t/t)") - define_sfop3(19,x * (y + z) ,"t*(t+t)") - define_sfop3(20,x * (y - z) ,"t*(t-t)") - define_sfop3(21,x * (y * z) ,"t*(t*t)") - define_sfop3(22,x * (y / z) ,"t*(t/t)") - define_sfop3(23,x - (y + z) ,"t-(t+t)") - define_sfop3(24,x - (y - z) ,"t-(t-t)") - define_sfop3(25,x - (y / z) ,"t-(t/t)") - define_sfop3(26,x - (y * z) ,"t-(t*t)") - define_sfop3(27,x + (y * z) ,"t+(t*t)") - define_sfop3(28,x + (y / z) ,"t+(t/t)") - define_sfop3(29,x + (y + z) ,"t+(t+t)") - define_sfop3(30,x + (y - z) ,"t+(t-t)") - define_sfop3(31,(axnb(x,y,z))," ") - define_sfop3(32,(axnb(x,y,z))," ") - define_sfop3(33,(axnb(x,y,z))," ") - define_sfop3(34,(axnb(x,y,z))," ") - define_sfop3(35,(axnb(x,y,z))," ") - define_sfop3(36,(axnb(x,y,z))," ") - define_sfop3(37,(axnb(x,y,z))," ") - define_sfop3(38,(axnb(x,y,z))," ") - define_sfop3(39,x * numeric::log(y) + z,"") - define_sfop3(40,x * numeric::log(y) - z,"") - define_sfop3(41,x * numeric::log10(y) + z,"") - define_sfop3(42,x * numeric::log10(y) - z,"") - define_sfop3(43,x * numeric::sin(y) + z ,"") - define_sfop3(44,x * numeric::sin(y) - z ,"") - define_sfop3(45,x * numeric::cos(y) + z ,"") - define_sfop3(46,x * numeric::cos(y) - z ,"") - define_sfop3(47,details::is_true(x) ? y : z,"") - - #define define_sfop4(NN,OP0,OP1) \ - template \ - struct sf##NN##_op : public sf_base \ - { \ - typedef typename sf_base::Type Type; \ - static inline T process(Type x, Type y, Type z, Type w) \ - { \ - return (OP0); \ - } \ - static inline std::string id() { return OP1; } \ - }; \ - - define_sfop4(48,(x + ((y + z) / w)),"t+((t+t)/t)") - define_sfop4(49,(x + ((y + z) * w)),"t+((t+t)*t)") - define_sfop4(50,(x + ((y - z) / w)),"t+((t-t)/t)") - define_sfop4(51,(x + ((y - z) * w)),"t+((t-t)*t)") - define_sfop4(52,(x + ((y * z) / w)),"t+((t*t)/t)") - define_sfop4(53,(x + ((y * z) * w)),"t+((t*t)*t)") - define_sfop4(54,(x + ((y / z) + w)),"t+((t/t)+t)") - define_sfop4(55,(x + ((y / z) / w)),"t+((t/t)/t)") - define_sfop4(56,(x + ((y / z) * w)),"t+((t/t)*t)") - define_sfop4(57,(x - ((y + z) / w)),"t-((t+t)/t)") - define_sfop4(58,(x - ((y + z) * w)),"t-((t+t)*t)") - define_sfop4(59,(x - ((y - z) / w)),"t-((t-t)/t)") - define_sfop4(60,(x - ((y - z) * w)),"t-((t-t)*t)") - define_sfop4(61,(x - ((y * z) / w)),"t-((t*t)/t)") - define_sfop4(62,(x - ((y * z) * w)),"t-((t*t)*t)") - define_sfop4(63,(x - ((y / z) / w)),"t-((t/t)/t)") - define_sfop4(64,(x - ((y / z) * w)),"t-((t/t)*t)") - define_sfop4(65,(((x + y) * z) - w),"((t+t)*t)-t") - define_sfop4(66,(((x - y) * z) - w),"((t-t)*t)-t") - define_sfop4(67,(((x * y) * z) - w),"((t*t)*t)-t") - define_sfop4(68,(((x / y) * z) - w),"((t/t)*t)-t") - define_sfop4(69,(((x + y) / z) - w),"((t+t)/t)-t") - define_sfop4(70,(((x - y) / z) - w),"((t-t)/t)-t") - define_sfop4(71,(((x * y) / z) - w),"((t*t)/t)-t") - define_sfop4(72,(((x / y) / z) - w),"((t/t)/t)-t") - define_sfop4(73,((x * y) + (z * w)),"(t*t)+(t*t)") - define_sfop4(74,((x * y) - (z * w)),"(t*t)-(t*t)") - define_sfop4(75,((x * y) + (z / w)),"(t*t)+(t/t)") - define_sfop4(76,((x * y) - (z / w)),"(t*t)-(t/t)") - define_sfop4(77,((x / y) + (z / w)),"(t/t)+(t/t)") - define_sfop4(78,((x / y) - (z / w)),"(t/t)-(t/t)") - define_sfop4(79,((x / y) - (z * w)),"(t/t)-(t*t)") - define_sfop4(80,(x / (y + (z * w))),"t/(t+(t*t))") - define_sfop4(81,(x / (y - (z * w))),"t/(t-(t*t))") - define_sfop4(82,(x * (y + (z * w))),"t*(t+(t*t))") - define_sfop4(83,(x * (y - (z * w))),"t*(t-(t*t))") - - define_sfop4(84,(axn(x,y) + axn(z,w)),"") - define_sfop4(85,(axn(x,y) + axn(z,w)),"") - define_sfop4(86,(axn(x,y) + axn(z,w)),"") - define_sfop4(87,(axn(x,y) + axn(z,w)),"") - define_sfop4(88,(axn(x,y) + axn(z,w)),"") - define_sfop4(89,(axn(x,y) + axn(z,w)),"") - define_sfop4(90,(axn(x,y) + axn(z,w)),"") - define_sfop4(91,(axn(x,y) + axn(z,w)),"") - define_sfop4(92,((details::is_true(x) && details::is_true(y)) ? z : w),"") - define_sfop4(93,((details::is_true(x) || details::is_true(y)) ? z : w),"") - define_sfop4(94,((x < y) ? z : w),"") - define_sfop4(95,((x <= y) ? z : w),"") - define_sfop4(96,((x > y) ? z : w),"") - define_sfop4(97,((x >= y) ? z : w),"") - define_sfop4(98,(details::is_true(numeric::equal(x,y)) ? z : w),"") - define_sfop4(99,(x * numeric::sin(y) + z * numeric::cos(w)),"") - - define_sfop4(ext00,((x + y) - (z * w)),"(t+t)-(t*t)") - define_sfop4(ext01,((x + y) - (z / w)),"(t+t)-(t/t)") - define_sfop4(ext02,((x + y) + (z * w)),"(t+t)+(t*t)") - define_sfop4(ext03,((x + y) + (z / w)),"(t+t)+(t/t)") - define_sfop4(ext04,((x - y) + (z * w)),"(t-t)+(t*t)") - define_sfop4(ext05,((x - y) + (z / w)),"(t-t)+(t/t)") - define_sfop4(ext06,((x - y) - (z * w)),"(t-t)-(t*t)") - define_sfop4(ext07,((x - y) - (z / w)),"(t-t)-(t/t)") - define_sfop4(ext08,((x + y) - (z - w)),"(t+t)-(t-t)") - define_sfop4(ext09,((x + y) + (z - w)),"(t+t)+(t-t)") - define_sfop4(ext10,((x + y) * (z - w)),"(t+t)*(t-t)") - define_sfop4(ext11,((x + y) / (z - w)),"(t+t)/(t-t)") - define_sfop4(ext12,((x - y) - (z + w)),"(t-t)-(t+t)") - define_sfop4(ext13,((x - y) + (z + w)),"(t-t)+(t+t)") - define_sfop4(ext14,((x - y) * (z + w)),"(t-t)*(t+t)") - define_sfop4(ext15,((x - y) / (z + w)),"(t-t)/(t+t)") - define_sfop4(ext16,((x * y) - (z + w)),"(t*t)-(t+t)") - define_sfop4(ext17,((x / y) - (z + w)),"(t/t)-(t+t)") - define_sfop4(ext18,((x * y) + (z + w)),"(t*t)+(t+t)") - define_sfop4(ext19,((x / y) + (z + w)),"(t/t)+(t+t)") - define_sfop4(ext20,((x * y) + (z - w)),"(t*t)+(t-t)") - define_sfop4(ext21,((x / y) + (z - w)),"(t/t)+(t-t)") - define_sfop4(ext22,((x * y) - (z - w)),"(t*t)-(t-t)") - define_sfop4(ext23,((x / y) - (z - w)),"(t/t)-(t-t)") - define_sfop4(ext24,((x + y) * (z * w)),"(t+t)*(t*t)") - define_sfop4(ext25,((x + y) * (z / w)),"(t+t)*(t/t)") - define_sfop4(ext26,((x + y) / (z * w)),"(t+t)/(t*t)") - define_sfop4(ext27,((x + y) / (z / w)),"(t+t)/(t/t)") - define_sfop4(ext28,((x - y) / (z * w)),"(t-t)/(t*t)") - define_sfop4(ext29,((x - y) / (z / w)),"(t-t)/(t/t)") - define_sfop4(ext30,((x - y) * (z * w)),"(t-t)*(t*t)") - define_sfop4(ext31,((x - y) * (z / w)),"(t-t)*(t/t)") - define_sfop4(ext32,((x * y) * (z + w)),"(t*t)*(t+t)") - define_sfop4(ext33,((x / y) * (z + w)),"(t/t)*(t+t)") - define_sfop4(ext34,((x * y) / (z + w)),"(t*t)/(t+t)") - define_sfop4(ext35,((x / y) / (z + w)),"(t/t)/(t+t)") - define_sfop4(ext36,((x * y) / (z - w)),"(t*t)/(t-t)") - define_sfop4(ext37,((x / y) / (z - w)),"(t/t)/(t-t)") - define_sfop4(ext38,((x * y) * (z - w)),"(t*t)*(t-t)") - define_sfop4(ext39,((x * y) / (z * w)),"(t*t)/(t*t)") - define_sfop4(ext40,((x / y) * (z / w)),"(t/t)*(t/t)") - define_sfop4(ext41,((x / y) * (z - w)),"(t/t)*(t-t)") - define_sfop4(ext42,((x * y) * (z * w)),"(t*t)*(t*t)") - define_sfop4(ext43,(x + (y * (z / w))),"t+(t*(t/t))") - define_sfop4(ext44,(x - (y * (z / w))),"t-(t*(t/t))") - define_sfop4(ext45,(x + (y / (z * w))),"t+(t/(t*t))") - define_sfop4(ext46,(x - (y / (z * w))),"t-(t/(t*t))") - define_sfop4(ext47,(((x - y) - z) * w),"((t-t)-t)*t") - define_sfop4(ext48,(((x - y) - z) / w),"((t-t)-t)/t") - define_sfop4(ext49,(((x - y) + z) * w),"((t-t)+t)*t") - define_sfop4(ext50,(((x - y) + z) / w),"((t-t)+t)/t") - define_sfop4(ext51,((x + (y - z)) * w),"(t+(t-t))*t") - define_sfop4(ext52,((x + (y - z)) / w),"(t+(t-t))/t") - define_sfop4(ext53,((x + y) / (z + w)),"(t+t)/(t+t)") - define_sfop4(ext54,((x - y) / (z - w)),"(t-t)/(t-t)") - define_sfop4(ext55,((x + y) * (z + w)),"(t+t)*(t+t)") - define_sfop4(ext56,((x - y) * (z - w)),"(t-t)*(t-t)") - define_sfop4(ext57,((x - y) + (z - w)),"(t-t)+(t-t)") - define_sfop4(ext58,((x - y) - (z - w)),"(t-t)-(t-t)") - define_sfop4(ext59,((x / y) + (z * w)),"(t/t)+(t*t)") - - #undef define_sfop3 - #undef define_sfop4 - - template - class sf3_node : public trinary_node - { - public: - - typedef expression_node* expression_ptr; - - sf3_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1, - expression_ptr branch2) - : trinary_node(opr,branch0,branch1,branch2) - {} - - inline T value() const - { - const T x = trinary_node::branch_[0].first->value(); - const T y = trinary_node::branch_[1].first->value(); - const T z = trinary_node::branch_[2].first->value(); - - return SpecialFunction::process(x,y,z); - } - }; - - template - class sf4_node : public quaternary_node - { - public: - - typedef expression_node* expression_ptr; - - sf4_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1, - expression_ptr branch2, - expression_ptr branch3) - : quaternary_node(opr,branch0,branch1,branch2,branch3) - {} - - inline T value() const - { - const T x = quaternary_node::branch_[0].first->value(); - const T y = quaternary_node::branch_[1].first->value(); - const T z = quaternary_node::branch_[2].first->value(); - const T w = quaternary_node::branch_[3].first->value(); - - return SpecialFunction::process(x,y,z,w); - } - }; - - template - class sf3_var_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - sf3_var_node(const T& v0, const T& v1, const T& v2) - : v0_(v0), - v1_(v1), - v2_(v2) - {} - - inline T value() const - { - return SpecialFunction::process(v0_,v1_,v2_); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_trinary; - } - - private: - - sf3_var_node(sf3_var_node&); - sf3_var_node& operator=(sf3_var_node&); - - const T& v0_; - const T& v1_; - const T& v2_; - }; - - template - class sf4_var_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - sf4_var_node(const T& v0, const T& v1, const T& v2, const T& v3) - : v0_(v0), - v1_(v1), - v2_(v2), - v3_(v3) - {} - - inline T value() const - { - return SpecialFunction::process(v0_,v1_,v2_,v3_); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_trinary; - } - - private: - - sf4_var_node(sf4_var_node&); - sf4_var_node& operator=(sf4_var_node&); - - const T& v0_; - const T& v1_; - const T& v2_; - const T& v3_; - }; - - template - class vararg_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - template class Sequence> - vararg_node(const Sequence& arg_list) - { - arg_list_.resize(arg_list.size()); - delete_branch_.resize(arg_list.size()); - - for (std::size_t i = 0; i < arg_list.size(); ++i) + }; + + template + class sf4_node : public quaternary_node + { + public: + + typedef expression_node* expression_ptr; + + sf4_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1, + expression_ptr branch2, + expression_ptr branch3) + : quaternary_node(opr,branch0,branch1,branch2,branch3) + {} + + inline T value() const { - if (arg_list[i]) - { - arg_list_[i] = arg_list[i]; - delete_branch_[i] = static_cast(branch_deletable(arg_list_[i]) ? 1 : 0); - } - else - { - arg_list_.clear(); - delete_branch_.clear(); - return; - } - } - } - - ~vararg_node() - { - for (std::size_t i = 0; i < arg_list_.size(); ++i) + const T x = quaternary_node::branch_[0].first->value(); + const T y = quaternary_node::branch_[1].first->value(); + const T z = quaternary_node::branch_[2].first->value(); + const T w = quaternary_node::branch_[3].first->value(); + + return SpecialFunction::process(x,y,z,w); + } + }; + + template + class sf3_var_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + sf3_var_node(const T& v0, const T& v1, const T& v2) + : v0_(v0), + v1_(v1), + v2_(v2) + {} + + inline T value() const { - if (arg_list_[i] && delete_branch_[i]) - { - delete arg_list_[i]; - arg_list_[i] = 0; - } + return SpecialFunction::process(v0_,v1_,v2_); } - } - - inline T value() const - { - if (!arg_list_.empty()) - return VarArgFunction::process(arg_list_); - else - return std::numeric_limits::quiet_NaN(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vararg; - } - - private: - - std::vector arg_list_; - std::vector delete_branch_; - }; - - template - class vararg_varnode : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - template class Sequence> - vararg_varnode(const Sequence& arg_list) - { - arg_list_.resize(arg_list.size()); - - for (std::size_t i = 0; i < arg_list.size(); ++i) + + inline typename expression_node::node_type type() const { - if (arg_list[i] && is_variable_node(arg_list[i])) - { - variable_node* var_node_ptr = static_cast*>(arg_list[i]); - arg_list_[i] = (&var_node_ptr->ref()); - } - else - { - arg_list_.clear(); - return; - } - } - } - - inline T value() const - { - if (!arg_list_.empty()) - return VarArgFunction::process(arg_list_); - else - return std::numeric_limits::quiet_NaN(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vararg; - } - - private: - - std::vector arg_list_; - }; - - template - class vectorize_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - vectorize_node(const expression_ptr v) - : ivec_ptr_(0), - v_(v), - v_deletable_(branch_deletable(v_)) - { - if (is_ivector_node(v)) + return expression_node::e_trinary; + } + + private: + + sf3_var_node(sf3_var_node&); + sf3_var_node& operator=(sf3_var_node&); + + const T& v0_; + const T& v1_; + const T& v2_; + }; + + template + class sf4_var_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + sf4_var_node(const T& v0, const T& v1, const T& v2, const T& v3) + : v0_(v0), + v1_(v1), + v2_(v2), + v3_(v3) + {} + + inline T value() const + { + return SpecialFunction::process(v0_,v1_,v2_,v3_); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_trinary; + } + + private: + + sf4_var_node(sf4_var_node&); + sf4_var_node& operator=(sf4_var_node&); + + const T& v0_; + const T& v1_; + const T& v2_; + const T& v3_; + }; + + template + class vararg_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + template class Sequence> + vararg_node(const Sequence& arg_list) + { + arg_list_.resize(arg_list.size()); + delete_branch_.resize(arg_list.size()); + + for (std::size_t i = 0; i < arg_list.size(); ++i) + { + if (arg_list[i]) + { + arg_list_[i] = arg_list[i]; + delete_branch_[i] = static_cast(branch_deletable(arg_list_[i]) ? 1 : 0); + } + else + { + arg_list_.clear(); + delete_branch_.clear(); + return; + } + } + } + + ~vararg_node() + { + for (std::size_t i = 0; i < arg_list_.size(); ++i) + { + if (arg_list_[i] && delete_branch_[i]) + { + delete arg_list_[i]; + arg_list_[i] = 0; + } + } + } + + inline T value() const + { + if (!arg_list_.empty()) + return VarArgFunction::process(arg_list_); + else + return std::numeric_limits::quiet_NaN(); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_vararg; + } + + private: + + std::vector arg_list_; + std::vector delete_branch_; + }; + + template + class vararg_varnode : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + template class Sequence> + vararg_varnode(const Sequence& arg_list) + { + arg_list_.resize(arg_list.size()); + + for (std::size_t i = 0; i < arg_list.size(); ++i) + { + if (arg_list[i] && is_variable_node(arg_list[i])) + { + variable_node* var_node_ptr = static_cast*>(arg_list[i]); + arg_list_[i] = (&var_node_ptr->ref()); + } + else + { + arg_list_.clear(); + return; + } + } + } + + inline T value() const { - ivec_ptr_ = dynamic_cast*>(v); + if (!arg_list_.empty()) + return VarArgFunction::process(arg_list_); + else + return std::numeric_limits::quiet_NaN(); } - else - ivec_ptr_ = 0; - } - - ~vectorize_node() - { - if (v_ && v_deletable_) + + inline typename expression_node::node_type type() const { - delete v_; + return expression_node::e_vararg; } - } - - inline T value() const - { - if (ivec_ptr_) + + private: + + std::vector arg_list_; + }; + + template + class vectorize_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + vectorize_node(const expression_ptr v) + : ivec_ptr_(0), + v_(v), + v_deletable_(branch_deletable(v_)) + { + if (is_ivector_node(v)) + { + ivec_ptr_ = dynamic_cast*>(v); + } + else + ivec_ptr_ = 0; + } + + ~vectorize_node() + { + if (v_ && v_deletable_) + { + delete v_; + } + } + + inline T value() const + { + if (ivec_ptr_) + { + v_->value(); + return VecFunction::process(ivec_ptr_); + } + else + return std::numeric_limits::quiet_NaN(); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_vecfunc; + } + + private: + + vector_interface* ivec_ptr_; + expression_ptr v_; + bool v_deletable_; + }; + + template + class assignment_node : public binary_node + { + public: + + typedef expression_node* expression_ptr; + + assignment_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + var_node_ptr_(0) + { + if (is_variable_node(binary_node::branch_[0].first)) + { + var_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + } + } + + inline T value() const + { + if (var_node_ptr_) + { + T& result = var_node_ptr_->ref(); + + result = binary_node::branch_[1].first->value(); + + return result; + } + else + return std::numeric_limits::quiet_NaN(); + } + + private: + + variable_node* var_node_ptr_; + }; + + template + class assignment_vec_elem_node : public binary_node + { + public: + + typedef expression_node* expression_ptr; + + assignment_vec_elem_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + vec_node_ptr_(0) + { + if (is_vector_elem_node(binary_node::branch_[0].first)) + { + vec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + } + } + + inline T value() const + { + if (vec_node_ptr_) + { + T& result = vec_node_ptr_->ref(); + + result = binary_node::branch_[1].first->value(); + + return result; + } + else + return std::numeric_limits::quiet_NaN(); + } + + private: + + vector_elem_node* vec_node_ptr_; + }; + + template + class assignment_rebasevec_elem_node : public binary_node + { + public: + + typedef expression_node* expression_ptr; + + assignment_rebasevec_elem_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + rbvec_node_ptr_(0) + { + if (is_rebasevector_elem_node(binary_node::branch_[0].first)) + { + rbvec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + } + } + + inline T value() const + { + if (rbvec_node_ptr_) + { + T& result = rbvec_node_ptr_->ref(); + + result = binary_node::branch_[1].first->value(); + + return result; + } + else + return std::numeric_limits::quiet_NaN(); + } + + private: + + rebasevector_elem_node* rbvec_node_ptr_; + }; + + template + class assignment_rebasevec_celem_node : public binary_node + { + public: + + typedef expression_node* expression_ptr; + + assignment_rebasevec_celem_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + rbvec_node_ptr_(0) + { + if (is_rebasevector_celem_node(binary_node::branch_[0].first)) + { + rbvec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + } + } + + inline T value() const + { + if (rbvec_node_ptr_) + { + T& result = rbvec_node_ptr_->ref(); + + result = binary_node::branch_[1].first->value(); + + return result; + } + else + return std::numeric_limits::quiet_NaN(); + } + + private: + + rebasevector_celem_node* rbvec_node_ptr_; + }; + + template + class assignment_vec_node : public binary_node , + public vector_interface + { + public: + + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; + typedef vec_data_store vds_t; + + assignment_vec_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + vec_node_ptr_(0) + { + if (is_vector_node(binary_node::branch_[0].first)) + { + vec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + vds() = vec_node_ptr_->vds(); + } + } + + inline T value() const + { + if (vec_node_ptr_) + { + const T v = binary_node::branch_[1].first->value(); + + T* vec = vds().data(); + + loop_unroll::details lud(size()); + const T* upper_bound = vec + lud.upper_bound; + + while (vec < upper_bound) + { +#define exprtk_loop(N) \ +vec[N] = v; \ + + exprtk_loop( 0) exprtk_loop( 1) + exprtk_loop( 2) exprtk_loop( 3) +#ifndef exprtk_disable_superscalar_unroll + exprtk_loop( 4) exprtk_loop( 5) + exprtk_loop( 6) exprtk_loop( 7) + exprtk_loop( 8) exprtk_loop( 9) + exprtk_loop(10) exprtk_loop(11) + exprtk_loop(12) exprtk_loop(13) + exprtk_loop(14) exprtk_loop(15) +#endif + + vec += lud.batch_size; + } + + switch (lud.remainder) + { +#define case_stmt(N) \ +case N : *vec++ = v; \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(15) case_stmt(14) + case_stmt(13) case_stmt(12) + case_stmt(11) case_stmt(10) + case_stmt( 9) case_stmt( 8) + case_stmt( 7) case_stmt( 6) + case_stmt( 5) case_stmt( 4) +#endif + case_stmt( 3) case_stmt( 2) + case_stmt( 1) + } + +#undef exprtk_loop +#undef case_stmt + + return vec_node_ptr_->value(); + } + else + return std::numeric_limits::quiet_NaN(); + } + + vector_node_ptr vec() const { - v_->value(); - return VecFunction::process(ivec_ptr_); + return vec_node_ptr_; } - else - return std::numeric_limits::quiet_NaN(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecfunc; - } - - private: - - vector_interface* ivec_ptr_; - expression_ptr v_; - bool v_deletable_; - }; - - template - class assignment_node : public binary_node - { - public: - - typedef expression_node* expression_ptr; - - assignment_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - var_node_ptr_(0) - { - if (is_variable_node(binary_node::branch_[0].first)) + + vector_node_ptr vec() { - var_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + return vec_node_ptr_; } - } - - inline T value() const - { - if (var_node_ptr_) + + inline typename expression_node::node_type type() const { - T& result = var_node_ptr_->ref(); - result = binary_node::branch_[1].first->value(); - - return result; + return expression_node::e_vecvalass; } - else - return std::numeric_limits::quiet_NaN(); - } - - private: - - variable_node* var_node_ptr_; - }; - - template - class assignment_vec_elem_node : public binary_node - { - public: - - typedef expression_node* expression_ptr; - - assignment_vec_elem_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec_node_ptr_(0) - { - if (is_vector_elem_node(binary_node::branch_[0].first)) + + std::size_t size() const { - vec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + return vds().size(); } - } - - inline T value() const - { - if (vec_node_ptr_) + + vds_t& vds() { - T& result = vec_node_ptr_->ref(); - result = binary_node::branch_[1].first->value(); - - return result; + return vds_; } - else - return std::numeric_limits::quiet_NaN(); - } - - private: - - vector_elem_node* vec_node_ptr_; - }; - - template - class assignment_vec_node : public binary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - - assignment_vec_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec_node_ptr_(0), - vec_size_ (0) - { - if (is_vector_node(binary_node::branch_[0].first)) + + const vds_t& vds() const { - vec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); - vec_size_ = vec_node_ptr_->ref().size(); + return vds_; } - } - - inline T value() const - { - if (vec_node_ptr_) + + private: + + vector_node* vec_node_ptr_; + vds_t vds_; + }; + + template + class assignment_vecvec_node : public binary_node , + public vector_interface + { + public: + + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; + typedef vec_data_store vds_t; + + assignment_vecvec_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + vec0_node_ptr_(0), + vec1_node_ptr_(0), + initialised_(false), + src_is_ivec_(false) + { + if (is_vector_node(binary_node::branch_[0].first)) + { + vec0_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + vds() = vec0_node_ptr_->vds(); + } + + if (is_vector_node(binary_node::branch_[1].first)) + { + vec1_node_ptr_ = static_cast*>(binary_node::branch_[1].first); + vds_t::match_sizes(vds(),vec1_node_ptr_->vds()); + } + else if (is_ivector_node(binary_node::branch_[1].first)) + { + vector_interface* vi = reinterpret_cast*>(0); + + if (0 != (vi = dynamic_cast*>(binary_node::branch_[1].first))) + { + vec1_node_ptr_ = vi->vec(); + + if (!vi->side_effect()) + { + vi->vds() = vds(); + src_is_ivec_ = true; + } + else + vds_t::match_sizes(vds(),vi->vds()); + } + } + + initialised_ = (vec0_node_ptr_ && vec1_node_ptr_); + } + + inline T value() const + { + if (initialised_) + { + binary_node::branch_[1].first->value(); + + if (src_is_ivec_) + return vec0_node_ptr_->value(); + + T* vec0 = vec0_node_ptr_->vds().data(); + T* vec1 = vec1_node_ptr_->vds().data(); + + loop_unroll::details lud(size()); + const T* upper_bound = vec0 + lud.upper_bound; + + while (vec0 < upper_bound) + { +#define exprtk_loop(N) \ +vec0[N] = vec1[N]; \ + + exprtk_loop( 0) exprtk_loop( 1) + exprtk_loop( 2) exprtk_loop( 3) +#ifndef exprtk_disable_superscalar_unroll + exprtk_loop( 4) exprtk_loop( 5) + exprtk_loop( 6) exprtk_loop( 7) + exprtk_loop( 8) exprtk_loop( 9) + exprtk_loop(10) exprtk_loop(11) + exprtk_loop(12) exprtk_loop(13) + exprtk_loop(14) exprtk_loop(15) +#endif + + vec0 += lud.batch_size; + vec1 += lud.batch_size; + } + + switch (lud.remainder) + { +#define case_stmt(N) \ +case N : *vec0++ = *vec1++; \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(15) case_stmt(14) + case_stmt(13) case_stmt(12) + case_stmt(11) case_stmt(10) + case_stmt( 9) case_stmt( 8) + case_stmt( 7) case_stmt( 6) + case_stmt( 5) case_stmt( 4) +#endif + case_stmt( 3) case_stmt( 2) + case_stmt( 1) + } + +#undef exprtk_loop +#undef case_stmt + + return vec0_node_ptr_->value(); + } + else + return std::numeric_limits::quiet_NaN(); + } + + vector_node_ptr vec() const { - vector_holder& vec_hldr = vec_node_ptr_->ref(); - const T v = binary_node::branch_[1].first->value(); - - for (std::size_t i = 0; i < vec_size_; ++i) - { - (*vec_hldr[i]) = v; - } - - return vec_node_ptr_->value(); + return vec0_node_ptr_; } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return vec_node_ptr_; - } - - vector_node_ptr vec() - { - return vec_node_ptr_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecvalass; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node* vec_node_ptr_; - std::size_t vec_size_; - }; - - template - class assignment_vecvec_node : public binary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - - assignment_vecvec_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec0_node_ptr_(0), - vec1_node_ptr_(0), - vec_size_ (0) - { - if (is_vector_node(binary_node::branch_[0].first)) + + vector_node_ptr vec() { - vec0_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + return vec0_node_ptr_; } - - if (is_vector_node(binary_node::branch_[1].first)) + + inline typename expression_node::node_type type() const { - vec1_node_ptr_ = static_cast*>(binary_node::branch_[1].first); + return expression_node::e_vecvecass; } - else if (is_ivector_node(binary_node::branch_[1].first)) + + std::size_t size() const { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[1].first))) - { - vec1_node_ptr_ = vi->vec(); - } + return vds().size(); } - - if (vec0_node_ptr_ && vec1_node_ptr_) + + vds_t& vds() { - vec_size_ = std::min(vec0_node_ptr_->ref().size(), - vec1_node_ptr_->ref().size()); + return vds_; } - } - - inline T value() const - { - binary_node::branch_[1].first->value(); - - if (vec0_node_ptr_ && vec1_node_ptr_) + + const vds_t& vds() const { - vector_holder& vec0 = vec0_node_ptr_->ref(); - vector_holder& vec1 = vec1_node_ptr_->ref(); - - for (std::size_t i = 0; i < vec_size_; ++i) - { - (*vec0[i]) = (*vec1[i]); - } - - return vec0_node_ptr_->value(); + return vds_; } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return vec0_node_ptr_; - } - - vector_node_ptr vec() - { - return vec0_node_ptr_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecvecass; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node* vec0_node_ptr_; - vector_node* vec1_node_ptr_; - std::size_t vec_size_; - }; - - template - class assignment_op_node : public binary_node - { - public: - - typedef expression_node* expression_ptr; - - assignment_op_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - var_node_ptr_(0) - { - if (is_variable_node(binary_node::branch_[0].first)) - { - var_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + + private: + + vector_node* vec0_node_ptr_; + vector_node* vec1_node_ptr_; + bool initialised_; + bool src_is_ivec_; + vds_t vds_; + }; + + template + class assignment_op_node : public binary_node + { + public: + + typedef expression_node* expression_ptr; + + assignment_op_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + var_node_ptr_(0) + { + if (is_variable_node(binary_node::branch_[0].first)) + { + var_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + } + } + + inline T value() const + { + if (var_node_ptr_) + { + T& v = var_node_ptr_->ref(); + v = Operation::process(v,binary_node::branch_[1].first->value()); + + return v; + } + else + return std::numeric_limits::quiet_NaN(); + } + + private: + + variable_node* var_node_ptr_; + }; + + template + class assignment_vec_elem_op_node : public binary_node + { + public: + + typedef expression_node* expression_ptr; + + assignment_vec_elem_op_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + vec_node_ptr_(0) + { + if (is_vector_elem_node(binary_node::branch_[0].first)) + { + vec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + } + } + + inline T value() const + { + if (vec_node_ptr_) + { + T& v = vec_node_ptr_->ref(); + v = Operation::process(v,binary_node::branch_[1].first->value()); + + return v; + } + else + return std::numeric_limits::quiet_NaN(); + } + + private: + + vector_elem_node* vec_node_ptr_; + }; + + template + class assignment_rebasevec_elem_op_node : public binary_node + { + public: + + typedef expression_node* expression_ptr; + + assignment_rebasevec_elem_op_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + rbvec_node_ptr_(0) + { + if (is_rebasevector_elem_node(binary_node::branch_[0].first)) + { + rbvec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + } + } + + inline T value() const + { + if (rbvec_node_ptr_) + { + T& v = rbvec_node_ptr_->ref(); + v = Operation::process(v,binary_node::branch_[1].first->value()); + + return v; + } + else + return std::numeric_limits::quiet_NaN(); + } + + private: + + rebasevector_elem_node* rbvec_node_ptr_; + }; + + template + class assignment_rebasevec_celem_op_node : public binary_node + { + public: + + typedef expression_node* expression_ptr; + + assignment_rebasevec_celem_op_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + rbvec_node_ptr_(0) + { + if (is_rebasevector_celem_node(binary_node::branch_[0].first)) + { + rbvec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + } + } + + inline T value() const + { + if (rbvec_node_ptr_) + { + T& v = rbvec_node_ptr_->ref(); + v = Operation::process(v,binary_node::branch_[1].first->value()); + + return v; + } + else + return std::numeric_limits::quiet_NaN(); + } + + private: + + rebasevector_celem_node* rbvec_node_ptr_; + }; + + template + class assignment_vec_op_node : public binary_node , + public vector_interface + { + public: + + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; + typedef vec_data_store vds_t; + + assignment_vec_op_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + vec_node_ptr_(0) + { + if (is_vector_node(binary_node::branch_[0].first)) + { + vec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + vds() = vec_node_ptr_->vds(); + } + } + + inline T value() const + { + if (vec_node_ptr_) + { + const T v = binary_node::branch_[1].first->value(); + + T* vec = vds().data(); + + loop_unroll::details lud(size()); + const T* upper_bound = vec + lud.upper_bound; + + while (vec < upper_bound) + { +#define exprtk_loop(N) \ +Operation::assign(vec[N],v); \ + + exprtk_loop( 0) exprtk_loop( 1) + exprtk_loop( 2) exprtk_loop( 3) +#ifndef exprtk_disable_superscalar_unroll + exprtk_loop( 4) exprtk_loop( 5) + exprtk_loop( 6) exprtk_loop( 7) + exprtk_loop( 8) exprtk_loop( 9) + exprtk_loop(10) exprtk_loop(11) + exprtk_loop(12) exprtk_loop(13) + exprtk_loop(14) exprtk_loop(15) +#endif + + vec += lud.batch_size; + } + + switch (lud.remainder) + { +#define case_stmt(N) \ +case N : Operation::assign(*vec++,v); \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(15) case_stmt(14) + case_stmt(13) case_stmt(12) + case_stmt(11) case_stmt(10) + case_stmt( 9) case_stmt( 8) + case_stmt( 7) case_stmt( 6) + case_stmt( 5) case_stmt( 4) +#endif + case_stmt( 3) case_stmt( 2) + case_stmt( 1) + } + +#undef exprtk_loop +#undef case_stmt + + return vec_node_ptr_->value(); + } + else + return std::numeric_limits::quiet_NaN(); } - } - - inline T value() const - { - if (var_node_ptr_) + + vector_node_ptr vec() const { - T& v = var_node_ptr_->ref(); - v = Operation::process(v,binary_node::branch_[1].first->value()); - - return v; + return vec_node_ptr_; } - else - return std::numeric_limits::quiet_NaN(); - } - - private: - - variable_node* var_node_ptr_; - }; - - template - class assignment_vec_elem_op_node : public binary_node - { - public: - - typedef expression_node* expression_ptr; - - assignment_vec_elem_op_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec_node_ptr_(0) - { - if (is_vector_elem_node(binary_node::branch_[0].first)) + + vector_node_ptr vec() { - vec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + return vec_node_ptr_; } - } - - inline T value() const - { - if (vec_node_ptr_) + + inline typename expression_node::node_type type() const { - T& v = vec_node_ptr_->ref(); - v = Operation::process(v,binary_node::branch_[1].first->value()); - - return v; + return expression_node::e_vecopvalass; } - else - return std::numeric_limits::quiet_NaN(); - } - - private: - - vector_elem_node* vec_node_ptr_; - }; - - template - class assignment_vec_op_node : public binary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - - assignment_vec_op_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec_node_ptr_(0), - vec_size_ (0) - { - if (is_vector_node(binary_node::branch_[0].first)) + + std::size_t size() const { - vec_node_ptr_ = static_cast*>(binary_node::branch_[0].first); - vec_size_ = vec_node_ptr_->ref().size(); + return vds().size(); } - } - - inline T value() const - { - if (vec_node_ptr_) + + vds_t& vds() { - vector_holder& vec_hldr = vec_node_ptr_->ref(); - const T v = binary_node::branch_[1].first->value(); - - for (std::size_t i = 0; i < vec_size_; ++i) - { - T& vec_i = *vec_hldr[i]; - vec_i = Operation::process(vec_i,v); - } - - return vec_node_ptr_->value(); + return vds_; } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return vec_node_ptr_; - } - - vector_node_ptr vec() - { - return vec_node_ptr_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecopvalass; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node* vec_node_ptr_; - std::size_t vec_size_; - }; - - template - class assignment_vecvec_op_node : public binary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - - assignment_vecvec_op_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec0_node_ptr_(0), - vec1_node_ptr_(0), - vec_size_ (0) - { - if (is_vector_node(binary_node::branch_[0].first)) + + const vds_t& vds() const { - vec0_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + return vds_; } - - if (is_vector_node(binary_node::branch_[1].first)) + + bool side_effect() const { - vec1_node_ptr_ = static_cast*>(binary_node::branch_[1].first); + return true; + } + + private: + + vector_node* vec_node_ptr_; + vds_t vds_; + }; + + template + class assignment_vecvec_op_node : public binary_node , + public vector_interface + { + public: + + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; + typedef vec_data_store vds_t; + + assignment_vecvec_op_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + vec0_node_ptr_(0), + vec1_node_ptr_(0), + initialised_(false) + { + if (is_vector_node(binary_node::branch_[0].first)) + { + vec0_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + vds() = vec0_node_ptr_->vds(); + } + + if (is_vector_node(binary_node::branch_[1].first)) + { + vec1_node_ptr_ = static_cast*>(binary_node::branch_[1].first); + vec1_node_ptr_->vds() = vds(); + } + else if (is_ivector_node(binary_node::branch_[1].first)) + { + vector_interface* vi = reinterpret_cast*>(0); + + if (0 != (vi = dynamic_cast*>(binary_node::branch_[1].first))) + { + vec1_node_ptr_ = vi->vec(); + vec1_node_ptr_->vds() = vds(); + } + else + vds_t::match_sizes(vds(),vec1_node_ptr_->vds()); + } + + initialised_ = (vec0_node_ptr_ && vec1_node_ptr_); + } + + inline T value() const + { + if (initialised_) + { + binary_node::branch_[0].first->value(); + binary_node::branch_[1].first->value(); + + T* vec0 = vec0_node_ptr_->vds().data(); + T* vec1 = vec1_node_ptr_->vds().data(); + + loop_unroll::details lud(size()); + const T* upper_bound = vec0 + lud.upper_bound; + + while (vec0 < upper_bound) + { +#define exprtk_loop(N) \ +vec0[N] = Operation::process(vec0[N],vec1[N]); \ + + exprtk_loop( 0) exprtk_loop( 1) + exprtk_loop( 2) exprtk_loop( 3) +#ifndef exprtk_disable_superscalar_unroll + exprtk_loop( 4) exprtk_loop( 5) + exprtk_loop( 6) exprtk_loop( 7) + exprtk_loop( 8) exprtk_loop( 9) + exprtk_loop(10) exprtk_loop(11) + exprtk_loop(12) exprtk_loop(13) + exprtk_loop(14) exprtk_loop(15) +#endif + + vec0 += lud.batch_size; + vec1 += lud.batch_size; + } + + int i = 0; + + switch (lud.remainder) + { +#define case_stmt(N) \ +case N : { vec0[i] = Operation::process(vec0[i],vec1[i]); ++i; } \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(15) case_stmt(14) + case_stmt(13) case_stmt(12) + case_stmt(11) case_stmt(10) + case_stmt( 9) case_stmt( 8) + case_stmt( 7) case_stmt( 6) + case_stmt( 5) case_stmt( 4) +#endif + case_stmt( 3) case_stmt( 2) + case_stmt( 1) + } + +#undef exprtk_loop +#undef case_stmt + + return vec0_node_ptr_->value(); + } + else + return std::numeric_limits::quiet_NaN(); } - else if (is_ivector_node(binary_node::branch_[1].first)) + + vector_node_ptr vec() const { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[1].first))) - { - vec1_node_ptr_ = vi->vec(); - } + return vec0_node_ptr_; } - - if (vec0_node_ptr_ && vec1_node_ptr_) + + vector_node_ptr vec() { - vec_size_ = std::min(vec0_node_ptr_->ref().size(), - vec1_node_ptr_->ref().size()); + return vec0_node_ptr_; } - } - - inline T value() const - { - if (vec0_node_ptr_ && vec1_node_ptr_) + + inline typename expression_node::node_type type() const { - binary_node::branch_[0].first->value(); - binary_node::branch_[1].first->value(); - - vector_holder& vec0 = vec0_node_ptr_->ref(); - vector_holder& vec1 = vec1_node_ptr_->ref(); - - for (std::size_t i = 0; i < vec_size_; ++i) - { - T& vec0_i = *vec0[i]; - T& vec1_i = *vec1[i]; - vec0_i = Operation::process(vec0_i,vec1_i); - } - - return vec0_node_ptr_->value(); + return expression_node::e_vecopvecass; } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return vec0_node_ptr_; - } - - vector_node_ptr vec() - { - return vec0_node_ptr_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecopvecass; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node* vec0_node_ptr_; - vector_node* vec1_node_ptr_; - std::size_t vec_size_; - }; - - template - class eqineq_vecvec_node : public binary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - - eqineq_vecvec_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec0_node_ptr_(0), - vec1_node_ptr_(0), - vec_size_ (0) - { - - if (is_vector_node(binary_node::branch_[0].first)) + + std::size_t size() const { - vec0_node_ptr_ = static_cast*>(binary_node::branch_[0].first); + return vds().size(); } - else if (is_ivector_node(binary_node::branch_[0].first)) + + vds_t& vds() { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[0].first))) - { - vec0_node_ptr_ = vi->vec(); - } + return vds_; } - - if (is_vector_node(binary_node::branch_[1].first)) + + const vds_t& vds() const { - vec1_node_ptr_ = static_cast*>(binary_node::branch_[1].first); + return vds_; } - else if (is_ivector_node(binary_node::branch_[1].first)) + + bool side_effect() const { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[1].first))) - { - vec1_node_ptr_ = vi->vec(); - } + return true; } - - if (vec0_node_ptr_ && vec1_node_ptr_) + + private: + + vector_node* vec0_node_ptr_; + vector_node* vec1_node_ptr_; + bool initialised_; + vds_t vds_; + }; + + template + class vec_binop_vecvec_node : public binary_node , + public vector_interface + { + public: + + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; + typedef vector_holder* vector_holder_ptr; + typedef vec_data_store vds_t; + + vec_binop_vecvec_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + vec0_node_ptr_(0), + vec1_node_ptr_(0), + temp_ (0), + temp_vec_node_(0), + initialised_(false) + { + bool v0_is_ivec = false; + bool v1_is_ivec = false; + + if (is_vector_node(binary_node::branch_[0].first)) + { + vec0_node_ptr_ = static_cast(binary_node::branch_[0].first); + } + else if (is_ivector_node(binary_node::branch_[0].first)) + { + vector_interface* vi = reinterpret_cast*>(0); + + if (0 != (vi = dynamic_cast*>(binary_node::branch_[0].first))) + { + vec0_node_ptr_ = vi->vec(); + v0_is_ivec = true; + } + } + + if (is_vector_node(binary_node::branch_[1].first)) + { + vec1_node_ptr_ = static_cast(binary_node::branch_[1].first); + } + else if (is_ivector_node(binary_node::branch_[1].first)) + { + vector_interface* vi = reinterpret_cast*>(0); + + if (0 != (vi = dynamic_cast*>(binary_node::branch_[1].first))) + { + vec1_node_ptr_ = vi->vec(); + v1_is_ivec = true; + } + } + + if (vec0_node_ptr_ && vec1_node_ptr_) + { + vector_holder& vec0 = vec0_node_ptr_->vec_holder(); + vector_holder& vec1 = vec1_node_ptr_->vec_holder(); + + if (v0_is_ivec && (vec0.size() <= vec1.size())) + vds_ = vds_t(vec0_node_ptr_->vds()); + else if (v1_is_ivec && (vec1.size() <= vec0.size())) + vds_ = vds_t(vec1_node_ptr_->vds()); + else + vds_ = vds_t(std::min(vec0.size(),vec1.size())); + + temp_ = new vector_holder(vds().data(),vds().size()); + temp_vec_node_ = new vector_node (vds(),temp_); + + initialised_ = true; + } + } + + ~vec_binop_vecvec_node() + { + delete temp_; + delete temp_vec_node_; + } + + inline T value() const + { + if (initialised_) + { + binary_node::branch_[0].first->value(); + binary_node::branch_[1].first->value(); + + T* vec0 = vec0_node_ptr_->vds().data(); + T* vec1 = vec1_node_ptr_->vds().data(); + T* vec2 = vds().data(); + + loop_unroll::details lud(size()); + const T* upper_bound = vec2 + lud.upper_bound; + + while (vec2 < upper_bound) + { +#define exprtk_loop(N) \ +vec2[N] = Operation::process(vec0[N],vec1[N]); \ + + exprtk_loop( 0) exprtk_loop( 1) + exprtk_loop( 2) exprtk_loop( 3) +#ifndef exprtk_disable_superscalar_unroll + exprtk_loop( 4) exprtk_loop( 5) + exprtk_loop( 6) exprtk_loop( 7) + exprtk_loop( 8) exprtk_loop( 9) + exprtk_loop(10) exprtk_loop(11) + exprtk_loop(12) exprtk_loop(13) + exprtk_loop(14) exprtk_loop(15) +#endif + + vec0 += lud.batch_size; + vec1 += lud.batch_size; + vec2 += lud.batch_size; + } + + int i = 0; + + switch (lud.remainder) + { +#define case_stmt(N) \ +case N : { vec2[i] = Operation::process(vec0[i],vec1[i]); ++i; } \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(15) case_stmt(14) + case_stmt(13) case_stmt(12) + case_stmt(11) case_stmt(10) + case_stmt( 9) case_stmt( 8) + case_stmt( 7) case_stmt( 6) + case_stmt( 5) case_stmt( 4) +#endif + case_stmt( 3) case_stmt( 2) + case_stmt( 1) + } + +#undef exprtk_loop +#undef case_stmt + + return (vds().data())[0]; + } + else + return std::numeric_limits::quiet_NaN(); + } + + vector_node_ptr vec() const { - vec_size_ = std::min(vec0_node_ptr_->ref().size(), - vec1_node_ptr_->ref().size()); + return temp_vec_node_; } - } - - inline T value() const - { - if (vec0_node_ptr_ && vec1_node_ptr_) + + vector_node_ptr vec() { - binary_node::branch_[0].first->value(); - binary_node::branch_[1].first->value(); - - vector_holder& vec0 = vec0_node_ptr_->ref(); - vector_holder& vec1 = vec1_node_ptr_->ref(); - - for (std::size_t i = 0; i < vec_size_; ++i) - { - if (std::equal_to()(T(0),Operation::process(*vec0[i],*vec1[i]))) - { - return T(0); - } - } - - return T(1); + return temp_vec_node_; } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return vec0_node_ptr_; - } - - vector_node_ptr vec() - { - return vec0_node_ptr_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecvecineq; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node* vec0_node_ptr_; - vector_node* vec1_node_ptr_; - std::size_t vec_size_; - }; - - template - class eqineq_vecval_node : public binary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - - eqineq_vecval_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec_node_ptr_(0), - vec_size_ (0) - { - if (is_vector_node(binary_node::branch_[0].first)) + + inline typename expression_node::node_type type() const { - vec_node_ptr_ = static_cast(binary_node::branch_[0].first); + return expression_node::e_vecvecarith; } - else if (is_ivector_node(binary_node::branch_[0].first)) + + std::size_t size() const { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[0].first))) - { - vec_node_ptr_ = vi->vec(); - } + return vds_.size(); } - - if (vec_node_ptr_) + + vds_t& vds() { - vec_size_ = vec_node_ptr_->ref().size(); + return vds_; } - } - - inline T value() const - { - if (vec_node_ptr_) + + const vds_t& vds() const { - binary_node::branch_[0].first->value(); - T v = binary_node::branch_[1].first->value(); - - vector_holder& vec_hldr = vec_node_ptr_->ref(); - - for (std::size_t i = 0; i < vec_size_; ++i) - { - if (std::equal_to()(T(0),Operation::process(*vec_hldr[i],v))) - { - return T(0); - } - } - - return T(1); + return vds_; } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return vec_node_ptr_; - } - - vector_node_ptr vec() - { - return vec_node_ptr_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecvalineq; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node* vec_node_ptr_; - std::size_t vec_size_; - }; - - template - class eqineq_valvec_node : public binary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - - eqineq_valvec_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec_node_ptr_(0), - vec_size_ (0) - { - if (is_vector_node(binary_node::branch_[1].first)) + + private: + + vector_node_ptr vec0_node_ptr_; + vector_node_ptr vec1_node_ptr_; + vector_holder_ptr temp_; + vector_node_ptr temp_vec_node_; + bool initialised_; + vds_t vds_; + }; + + template + class vec_binop_vecval_node : public binary_node , + public vector_interface + { + public: + + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; + typedef vector_holder* vector_holder_ptr; + typedef vec_data_store vds_t; + + vec_binop_vecval_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + vec0_node_ptr_(0), + temp_ (0), + temp_vec_node_(0) + { + bool v0_is_ivec = false; + + if (is_vector_node(binary_node::branch_[0].first)) + { + vec0_node_ptr_ = static_cast(binary_node::branch_[0].first); + } + else if (is_ivector_node(binary_node::branch_[0].first)) + { + vector_interface* vi = reinterpret_cast*>(0); + + if (0 != (vi = dynamic_cast*>(binary_node::branch_[0].first))) + { + vec0_node_ptr_ = vi->vec(); + v0_is_ivec = true; + } + } + + if (vec0_node_ptr_) + { + if (v0_is_ivec) + vds() = vec0_node_ptr_->vds(); + else + vds() = vds_t(vec0_node_ptr_->size()); + + temp_ = new vector_holder(vds()); + temp_vec_node_ = new vector_node (vds(),temp_); + } + } + + ~vec_binop_vecval_node() + { + delete temp_; + delete temp_vec_node_; + } + + inline T value() const + { + if (vec0_node_ptr_) + { + binary_node::branch_[0].first->value(); + const T v = binary_node::branch_[1].first->value(); + + T* vec0 = vec0_node_ptr_->vds().data(); + T* vec1 = vds().data(); + + loop_unroll::details lud(size()); + const T* upper_bound = vec0 + lud.upper_bound; + + while (vec0 < upper_bound) + { +#define exprtk_loop(N) \ +vec1[N] = Operation::process(vec0[N],v); \ + + exprtk_loop( 0) exprtk_loop( 1) + exprtk_loop( 2) exprtk_loop( 3) +#ifndef exprtk_disable_superscalar_unroll + exprtk_loop( 4) exprtk_loop( 5) + exprtk_loop( 6) exprtk_loop( 7) + exprtk_loop( 8) exprtk_loop( 9) + exprtk_loop(10) exprtk_loop(11) + exprtk_loop(12) exprtk_loop(13) + exprtk_loop(14) exprtk_loop(15) +#endif + + vec0 += lud.batch_size; + vec1 += lud.batch_size; + } + + int i = 0; + + switch (lud.remainder) + { +#define case_stmt(N) \ +case N : { vec1[i] = Operation::process(vec0[i],v); ++i; } \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(15) case_stmt(14) + case_stmt(13) case_stmt(12) + case_stmt(11) case_stmt(10) + case_stmt( 9) case_stmt( 8) + case_stmt( 7) case_stmt( 6) + case_stmt( 5) case_stmt( 4) +#endif + case_stmt( 3) case_stmt( 2) + case_stmt( 1) + } + +#undef exprtk_loop +#undef case_stmt + + return (vds().data())[0]; + } + else + return std::numeric_limits::quiet_NaN(); + } + + vector_node_ptr vec() const { - vec_node_ptr_ = static_cast(binary_node::branch_[1].first); + return temp_vec_node_; } - else if (is_ivector_node(binary_node::branch_[1].first)) + + vector_node_ptr vec() { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[1].first))) - { - vec_node_ptr_ = vi->vec(); - } + return temp_vec_node_; } - - if (vec_node_ptr_) + + inline typename expression_node::node_type type() const { - vec_size_ = vec_node_ptr_->ref().size(); + return expression_node::e_vecvalarith; } - } - - inline T value() const - { - if (vec_node_ptr_) + + std::size_t size() const { - T v = binary_node::branch_[0].first->value(); - binary_node::branch_[1].first->value(); - - vector_holder& vec_hldr = vec_node_ptr_->ref(); - - for (std::size_t i = 0; i < vec_size_; ++i) - { - if (std::equal_to()(T(0),Operation::process(v,*vec_hldr[i]))) - { - return T(0); - } - } - - return T(1); + return vds().size(); } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return vec_node_ptr_; - } - - vector_node_ptr vec() - { - return vec_node_ptr_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_valvecineq; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node* vec_node_ptr_; - std::size_t vec_size_; - }; - - template - class vecarith_vecvec_node : public binary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - typedef vector_holder* vector_holder_ptr; - - vecarith_vecvec_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec0_node_ptr_(0), - vec1_node_ptr_(0), - vec_size_ (0), - data_ (0), - temp_ (0), - temp_vec_node_(0) - { - if (is_vector_node(binary_node::branch_[0].first)) - { - vec0_node_ptr_ = static_cast(binary_node::branch_[0].first); - } - else if (is_ivector_node(binary_node::branch_[0].first)) - { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[0].first))) - { - vec0_node_ptr_ = vi->vec(); - } + + vds_t& vds() + { + return vds_; } - - if (is_vector_node(binary_node::branch_[1].first)) + + const vds_t& vds() const { - vec1_node_ptr_ = static_cast(binary_node::branch_[1].first); + return vds_; + } + + private: + + vector_node_ptr vec0_node_ptr_; + vector_holder_ptr temp_; + vector_node_ptr temp_vec_node_; + vds_t vds_; + }; + + template + class vec_binop_valvec_node : public binary_node , + public vector_interface + { + public: + + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; + typedef vector_holder* vector_holder_ptr; + typedef vec_data_store vds_t; + + vec_binop_valvec_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + vec1_node_ptr_(0), + temp_ (0), + temp_vec_node_(0) + { + bool v1_is_ivec = false; + + if (is_vector_node(binary_node::branch_[1].first)) + { + vec1_node_ptr_ = static_cast(binary_node::branch_[1].first); + } + else if (is_ivector_node(binary_node::branch_[1].first)) + { + vector_interface* vi = reinterpret_cast*>(0); + + if (0 != (vi = dynamic_cast*>(binary_node::branch_[1].first))) + { + vec1_node_ptr_ = vi->vec(); + v1_is_ivec = true; + } + } + + if (vec1_node_ptr_) + { + if (v1_is_ivec) + vds() = vec1_node_ptr_->vds(); + else + vds() = vds_t(vec1_node_ptr_->size()); + + temp_ = new vector_holder(vds()); + temp_vec_node_ = new vector_node (vds(),temp_); + } + } + + ~vec_binop_valvec_node() + { + delete temp_; + delete temp_vec_node_; + } + + inline T value() const + { + if (vec1_node_ptr_) + { + const T v = binary_node::branch_[0].first->value(); + binary_node::branch_[1].first->value(); + + T* vec0 = vds().data(); + T* vec1 = vec1_node_ptr_->vds().data(); + + loop_unroll::details lud(size()); + const T* upper_bound = vec0 + lud.upper_bound; + + while (vec0 < upper_bound) + { +#define exprtk_loop(N) \ +vec0[N] = Operation::process(v,vec1[N]); \ + + exprtk_loop( 0) exprtk_loop( 1) + exprtk_loop( 2) exprtk_loop( 3) +#ifndef exprtk_disable_superscalar_unroll + exprtk_loop( 4) exprtk_loop( 5) + exprtk_loop( 6) exprtk_loop( 7) + exprtk_loop( 8) exprtk_loop( 9) + exprtk_loop(10) exprtk_loop(11) + exprtk_loop(12) exprtk_loop(13) + exprtk_loop(14) exprtk_loop(15) +#endif + + vec0 += lud.batch_size; + vec1 += lud.batch_size; + } + + int i = 0; + + switch (lud.remainder) + { +#define case_stmt(N) \ +case N : { vec0[i] = Operation::process(v,vec1[i]); ++i; } \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(15) case_stmt(14) + case_stmt(13) case_stmt(12) + case_stmt(11) case_stmt(10) + case_stmt( 9) case_stmt( 8) + case_stmt( 7) case_stmt( 6) + case_stmt( 5) case_stmt( 4) +#endif + case_stmt( 3) case_stmt( 2) + case_stmt( 1) + } + +#undef exprtk_loop +#undef case_stmt + + return (vds().data())[0]; + } + else + return std::numeric_limits::quiet_NaN(); } - else if (is_ivector_node(binary_node::branch_[1].first)) + + vector_node_ptr vec() const { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[1].first))) - { - vec1_node_ptr_ = vi->vec(); - } + return temp_vec_node_; } - - if (vec0_node_ptr_ && vec1_node_ptr_) + + vector_node_ptr vec() { - vector_holder& vec0 = vec0_node_ptr_->ref(); - vector_holder& vec1 = vec1_node_ptr_->ref(); - - vec_size_ = std::min(vec0.size(),vec1.size()); - data_ = new T[vec_size_]; - temp_ = new vector_holder(data_,vec_size_); - temp_vec_node_ = new vector_node (temp_); + return temp_vec_node_; } - } - - ~vecarith_vecvec_node() - { - delete[] data_; - delete temp_; - delete temp_vec_node_; - } - - inline T value() const - { - if (vec0_node_ptr_ && vec1_node_ptr_) + + inline typename expression_node::node_type type() const { - binary_node::branch_[0].first->value(); - binary_node::branch_[1].first->value(); - - vector_holder& vec0 = vec0_node_ptr_->ref(); - vector_holder& vec1 = vec1_node_ptr_->ref(); - vector_holder& vec2 = *temp_; - - for (std::size_t i = 0; i < vec_size_; ++i) - { - - T& vec0_i = *vec0[i]; - T& vec1_i = *vec1[i]; - T& vec2_i = *vec2[i]; - - vec2_i = Operation::process(vec0_i,vec1_i); - } - - return *vec2[0]; + return expression_node::e_vecvalarith; } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return temp_vec_node_; - } - - vector_node_ptr vec() - { - return temp_vec_node_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecvecarith; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node_ptr vec0_node_ptr_; - vector_node_ptr vec1_node_ptr_; - std::size_t vec_size_; - T* data_; - vector_holder_ptr temp_; - vector_node_ptr temp_vec_node_; - }; - - template - class vecarith_vecval_node : public binary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - typedef vector_holder* vector_holder_ptr; - - vecarith_vecval_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec0_node_ptr_(0), - vec_size_ (0), - data_ (0), - temp_ (0), - temp_vec_node_(0) - { - if (is_vector_node(binary_node::branch_[0].first)) - { - vec0_node_ptr_ = static_cast(binary_node::branch_[0].first); - } - else if (is_ivector_node(binary_node::branch_[0].first)) - { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[0].first))) - { - vec0_node_ptr_ = vi->vec(); - } + + std::size_t size() const + { + return vds().size(); } - - if (vec0_node_ptr_) + + vds_t& vds() { - vector_holder& vec0 = vec0_node_ptr_->ref(); - - vec_size_ = vec0.size(); - data_ = new T[vec_size_]; - temp_ = new vector_holder(data_,vec_size_); - temp_vec_node_ = new vector_node (temp_); + return vds_; } - } - - ~vecarith_vecval_node() - { - delete[] data_; - delete temp_; - delete temp_vec_node_; - } - - inline T value() const - { - if (vec0_node_ptr_) + + const vds_t& vds() const { - binary_node::branch_[0].first->value(); - const T v = binary_node::branch_[1].first->value(); - - vector_holder& vec0 = vec0_node_ptr_->ref(); - vector_holder& vec1 = *temp_; - - for (std::size_t i = 0; i < vec_size_; ++i) - { - T& vec0_i = *vec0[i]; - T& vec1_i = *vec1[i]; - - vec1_i = Operation::process(vec0_i,v); - } - - return *vec1[0]; + return vds_; } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return temp_vec_node_; - } - - vector_node_ptr vec() - { - return temp_vec_node_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecvalarith; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node_ptr vec0_node_ptr_; - std::size_t vec_size_; - T* data_; - vector_holder_ptr temp_; - vector_node_ptr temp_vec_node_; - }; - - template - class vecarith_valvec_node : public binary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - typedef vector_holder* vector_holder_ptr; - - vecarith_valvec_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - vec1_node_ptr_(0), - vec_size_ (0), - data_ (0), - temp_ (0), - temp_vec_node_(0) - { - if (is_vector_node(binary_node::branch_[1].first)) - { - vec1_node_ptr_ = static_cast(binary_node::branch_[1].first); - } - else if (is_ivector_node(binary_node::branch_[1].first)) - { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(binary_node::branch_[1].first))) - { - vec1_node_ptr_ = vi->vec(); - } + + private: + + vector_node_ptr vec1_node_ptr_; + vector_holder_ptr temp_; + vector_node_ptr temp_vec_node_; + vds_t vds_; + }; + + template + class unary_vector_node : public unary_node , + public vector_interface + { + public: + + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; + typedef vector_holder* vector_holder_ptr; + typedef vec_data_store vds_t; + + unary_vector_node(const operator_type& opr, expression_ptr branch0) + : unary_node(opr,branch0), + vec0_node_ptr_(0), + temp_ (0), + temp_vec_node_(0) + { + bool vec0_is_ivec = false; + + if (is_vector_node(unary_node::branch_)) + { + vec0_node_ptr_ = static_cast(unary_node::branch_); + } + else if (is_ivector_node(unary_node::branch_)) + { + vector_interface* vi = reinterpret_cast*>(0); + + if (0 != (vi = dynamic_cast*>(unary_node::branch_))) + { + vec0_node_ptr_ = vi->vec(); + vec0_is_ivec = true; + } + } + + if (vec0_node_ptr_) + { + if (vec0_is_ivec) + vds_ = vec0_node_ptr_->vds(); + else + vds_ = vds_t(vec0_node_ptr_->size()); + + temp_ = new vector_holder(vds()); + temp_vec_node_ = new vector_node (vds(),temp_); + } + } + + ~unary_vector_node() + { + delete temp_; + delete temp_vec_node_; + } + + inline T value() const + { + unary_node::branch_->value(); + + if (vec0_node_ptr_) + { + T* vec0 = vec0_node_ptr_->vds().data(); + T* vec1 = vds().data(); + + loop_unroll::details lud(size()); + const T* upper_bound = vec0 + lud.upper_bound; + + while (vec0 < upper_bound) + { +#define exprtk_loop(N) \ +vec1[N] = Operation::process(vec0[N]); \ + + exprtk_loop( 0) exprtk_loop( 1) + exprtk_loop( 2) exprtk_loop( 3) +#ifndef exprtk_disable_superscalar_unroll + exprtk_loop( 4) exprtk_loop( 5) + exprtk_loop( 6) exprtk_loop( 7) + exprtk_loop( 8) exprtk_loop( 9) + exprtk_loop(10) exprtk_loop(11) + exprtk_loop(12) exprtk_loop(13) + exprtk_loop(14) exprtk_loop(15) +#endif + + vec0 += lud.batch_size; + vec1 += lud.batch_size; + } + + int i = 0; + + switch (lud.remainder) + { +#define case_stmt(N) \ +case N : { vec1[i] = Operation::process(vec0[i]); ++i; } \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(15) case_stmt(14) + case_stmt(13) case_stmt(12) + case_stmt(11) case_stmt(10) + case_stmt( 9) case_stmt( 8) + case_stmt( 7) case_stmt( 6) + case_stmt( 5) case_stmt( 4) +#endif + case_stmt( 3) case_stmt( 2) + case_stmt( 1) + } + +#undef exprtk_loop +#undef case_stmt + + return (vds().data())[0]; + } + else + return std::numeric_limits::quiet_NaN(); } - - if (vec1_node_ptr_) + + vector_node_ptr vec() const { - vector_holder& vec0 = vec1_node_ptr_->ref(); - - vec_size_ = vec0.size(); - data_ = new T[vec_size_]; - temp_ = new vector_holder(data_,vec_size_); - temp_vec_node_ = new vector_node (temp_); + return temp_vec_node_; } - } - - ~vecarith_valvec_node() - { - delete[] data_; - delete temp_; - delete temp_vec_node_; - } - - inline T value() const - { - if (vec1_node_ptr_) + + vector_node_ptr vec() { - const T v = binary_node::branch_[0].first->value(); - binary_node::branch_[1].first->value(); - - vector_holder& vec1 = vec1_node_ptr_->ref(); - vector_holder& vec2 = *temp_; - - for (std::size_t i = 0; i < vec_size_; ++i) - { - T& vec1_i = *vec1[i]; - T& vec2_i = *vec2[i]; - - vec2_i = Operation::process(v,vec1_i); - } - - return *vec2[0]; + return temp_vec_node_; } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return temp_vec_node_; - } - - vector_node_ptr vec() - { - return temp_vec_node_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecvalarith; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node_ptr vec1_node_ptr_; - std::size_t vec_size_; - T* data_; - vector_holder_ptr temp_; - vector_node_ptr temp_vec_node_; - }; - - template - class unary_vector_node : public unary_node, - public vector_interface - { - public: - - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - typedef vector_holder* vector_holder_ptr; - - unary_vector_node(const operator_type& opr, expression_ptr branch0) - : unary_node(opr,branch0), - vec0_node_ptr_(0), - vec_size_ (0), - data_ (0), - temp_ (0), - temp_vec_node_(0) - { - if (is_vector_node(unary_node::branch_)) + + inline typename expression_node::node_type type() const { - vec0_node_ptr_ = static_cast(unary_node::branch_); + return expression_node::e_vecunaryop; } - else if (is_ivector_node(unary_node::branch_)) + + std::size_t size() const { - vector_interface* vi = reinterpret_cast*>(0); - - if ((vi = dynamic_cast*>(unary_node::branch_))) - { - vec0_node_ptr_ = vi->vec(); - } + return vds().size(); } - - if (vec0_node_ptr_) + + vds_t& vds() { - vector_holder& vec0 = vec0_node_ptr_->ref(); - - vec_size_ = vec0.size(); - data_ = new T[vec_size_]; - temp_ = new vector_holder(data_,vec_size_); - temp_vec_node_ = new vector_node (temp_); + return vds_; } - } - - ~unary_vector_node() - { - delete[] data_; - delete temp_; - delete temp_vec_node_; - } - - inline T value() const - { - unary_node::branch_->value(); - - if (vec0_node_ptr_) + + const vds_t& vds() const { - vector_holder& vec0 = vec0_node_ptr_->ref(); - vector_holder& vec1 = *temp_; - - for (std::size_t i = 0; i < vec_size_; ++i) - { - T& vec0_i = *vec0[i]; - T& vec1_i = *vec1[i]; - - vec1_i = Operation::process(vec0_i); - } - - return *vec1[0]; + return vds_; } - else - return std::numeric_limits::quiet_NaN(); - } - - vector_node_ptr vec() const - { - return temp_vec_node_; - } - - vector_node_ptr vec() - { - return temp_vec_node_; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vecunaryop; - } - - std::size_t size() const - { - return vec_size_; - } - - private: - - vector_node_ptr vec0_node_ptr_; - std::size_t vec_size_; - T* data_; - vector_holder_ptr temp_; - vector_node_ptr temp_vec_node_; - }; - - template - class scand_node : public binary_node - { - public: - - typedef expression_node* expression_ptr; - - scand_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1) - {} - - inline T value() const - { - return ( - std::not_equal_to() + + private: + + vector_node_ptr vec0_node_ptr_; + vector_holder_ptr temp_; + vector_node_ptr temp_vec_node_; + vds_t vds_; + }; + + template + class scand_node : public binary_node + { + public: + + typedef expression_node* expression_ptr; + + scand_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1) + {} + + inline T value() const + { + return ( + std::not_equal_to() (T(0),binary_node::branch_[0].first->value()) && - std::not_equal_to() + std::not_equal_to() (T(0),binary_node::branch_[1].first->value()) - ) ? T(1) : T(0); - } - }; - - template - class scor_node : public binary_node - { - public: - - typedef expression_node* expression_ptr; - - scor_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1) - {} - - inline T value() const - { - return ( - std::not_equal_to() + ) ? T(1) : T(0); + } + }; + + template + class scor_node : public binary_node + { + public: + + typedef expression_node* expression_ptr; + + scor_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1) + {} + + inline T value() const + { + return ( + std::not_equal_to() (T(0),binary_node::branch_[0].first->value()) || - std::not_equal_to() + std::not_equal_to() (T(0),binary_node::branch_[1].first->value()) - ) ? T(1) : T(0); - } - }; - - template - class function_N_node : public expression_node - { - public: - - // Function of N paramters. - typedef expression_node* expression_ptr; - typedef std::pair branch_t; - typedef IFunction ifunction; - - function_N_node(ifunction* func) - : function_((N == func->param_count) ? func : reinterpret_cast(0)), - parameter_count_(func->param_count) - {} - - ~function_N_node() - { - cleanup_branches::execute(branch_); - } - - template - bool init_branches(expression_ptr (&b)[NumBranches]) - { - // Needed for incompetent and broken msvc compiler versions - #ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable: 4127) - #endif - if (N != NumBranches) - return false; - else + ) ? T(1) : T(0); + } + }; + + template + class function_N_node : public expression_node + { + public: + + // Function of N paramters. + typedef expression_node* expression_ptr; + typedef std::pair branch_t; + typedef IFunction ifunction; + + function_N_node(ifunction* func) + : function_((N == func->param_count) ? func : reinterpret_cast(0)), + parameter_count_(func->param_count) + {} + + ~function_N_node() { - for (std::size_t i = 0; i < NumBranches; ++i) - { - if (b[i]) - branch_[i] = std::make_pair(b[i],branch_deletable(b[i])); - else - return false; - } - return true; - } - #ifdef _MSC_VER - #pragma warning(pop) - #endif - } - - inline bool operator <(const function_N_node& fn) const - { - return this < (&fn); - } - - inline T value() const - { - // Needed for incompetent and broken msvc compiler versions - #ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable: 4127) - #endif - if ((0 == function_) || (0 == N)) - return std::numeric_limits::quiet_NaN(); - else + cleanup_branches::execute(branch_); + } + + template + bool init_branches(expression_ptr (&b)[NumBranches]) { - T v[N]; - evaluate_branches::execute(v,branch_); - return invoke::execute(*function_,v); + // Needed for incompetent and broken msvc compiler versions +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4127) +#endif + if (N != NumBranches) + return false; + else + { + for (std::size_t i = 0; i < NumBranches; ++i) + { + if (b[i]) + branch_[i] = std::make_pair(b[i],branch_deletable(b[i])); + else + return false; + } + return true; + } +#ifdef _MSC_VER +#pragma warning(pop) +#endif } - #ifdef _MSC_VER - #pragma warning(pop) - #endif - } - - template - struct evaluate_branches - { - static inline void execute(T_ (&v)[BranchCount], const branch_t (&b)[BranchCount]) + + inline bool operator <(const function_N_node& fn) const { - for (std::size_t i = 0; i < BranchCount; ++i) - { - v[i] = b[i].first->value(); - } + return this < (&fn); } - }; - - template - struct evaluate_branches - { - static inline void execute(T_ (&v)[5], const branch_t (&b)[5]) - { - v[0] = b[0].first->value(); - v[1] = b[1].first->value(); - v[2] = b[2].first->value(); - v[3] = b[3].first->value(); - v[4] = b[4].first->value(); - } - }; - - template - struct evaluate_branches - { - static inline void execute(T_ (&v)[4], const branch_t (&b)[4]) + + inline T value() const { - v[0] = b[0].first->value(); - v[1] = b[1].first->value(); - v[2] = b[2].first->value(); - v[3] = b[3].first->value(); + // Needed for incompetent and broken msvc compiler versions +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4127) +#endif + if ((0 == function_) || (0 == N)) + return std::numeric_limits::quiet_NaN(); + else + { + T v[N]; + evaluate_branches::execute(v,branch_); + return invoke::execute(*function_,v); + } +#ifdef _MSC_VER +#pragma warning(pop) +#endif } - }; - - template - struct evaluate_branches - { - static inline void execute(T_ (&v)[3], const branch_t (&b)[3]) + + template + struct evaluate_branches + { + static inline void execute(T_ (&v)[BranchCount], const branch_t (&b)[BranchCount]) + { + for (std::size_t i = 0; i < BranchCount; ++i) + { + v[i] = b[i].first->value(); + } + } + }; + + template + struct evaluate_branches + { + static inline void execute(T_ (&v)[5], const branch_t (&b)[5]) + { + v[0] = b[0].first->value(); + v[1] = b[1].first->value(); + v[2] = b[2].first->value(); + v[3] = b[3].first->value(); + v[4] = b[4].first->value(); + } + }; + + template + struct evaluate_branches + { + static inline void execute(T_ (&v)[4], const branch_t (&b)[4]) + { + v[0] = b[0].first->value(); + v[1] = b[1].first->value(); + v[2] = b[2].first->value(); + v[3] = b[3].first->value(); + } + }; + + template + struct evaluate_branches + { + static inline void execute(T_ (&v)[3], const branch_t (&b)[3]) + { + v[0] = b[0].first->value(); + v[1] = b[1].first->value(); + v[2] = b[2].first->value(); + } + }; + + template + struct evaluate_branches + { + static inline void execute(T_ (&v)[2], const branch_t (&b)[2]) + { + v[0] = b[0].first->value(); + v[1] = b[1].first->value(); + } + }; + + template + struct evaluate_branches + { + static inline void execute(T_ (&v)[1], const branch_t (&b)[1]) + { + v[0] = b[0].first->value(); + } + }; + + template + struct invoke { static inline T execute(ifunction&, branch_t (&)[ParamCount]) { return std::numeric_limits::quiet_NaN(); } }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[20]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15],v[16],v[17],v[18],v[19]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[19]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15],v[16],v[17],v[18]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[18]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15],v[16],v[17]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[17]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15],v[16]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[16]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15]); } + }; + + template + struct invoke { - v[0] = b[0].first->value(); - v[1] = b[1].first->value(); - v[2] = b[2].first->value(); + static inline T_ execute(ifunction& f, T_ (&v)[15]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[14]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[13]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[12]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[11]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[10]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[9]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[8]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[7]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[6]) + { return f(v[0],v[1],v[2],v[3],v[4],v[5]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[5]) + { return f(v[0],v[1],v[2],v[3],v[4]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[4]) + { return f(v[0],v[1],v[2],v[3]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[3]) + { return f(v[0],v[1],v[2]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[2]) + { return f(v[0],v[1]); } + }; + + template + struct invoke + { + static inline T_ execute(ifunction& f, T_ (&v)[1]) + { return f(v[0]); } + }; + + inline typename expression_node::node_type type() const + { + return expression_node::e_function; } - }; - - template - struct evaluate_branches - { - static inline void execute(T_ (&v)[2], const branch_t (&b)[2]) + + private: + + ifunction* function_; + std::size_t parameter_count_; + branch_t branch_[N]; + }; + + template + class function_N_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef IFunction ifunction; + + function_N_node(ifunction* func) + : function_((0 == func->param_count) ? func : reinterpret_cast(0)) + {} + + inline bool operator <(const function_N_node& fn) const { - v[0] = b[0].first->value(); - v[1] = b[1].first->value(); + return this < (&fn); } - }; - - template - struct evaluate_branches - { - static inline void execute(T_ (&v)[1], const branch_t (&b)[1]) + + inline T value() const { - v[0] = b[0].first->value(); + if (function_) + return (*function_)(); + else + return std::numeric_limits::quiet_NaN(); } - }; - - template - struct invoke { static inline T execute(ifunction&, branch_t (&)[ParamCount]) { return std::numeric_limits::quiet_NaN(); } }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[20]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15],v[16],v[17],v[18],v[19]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[19]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15],v[16],v[17],v[18]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[18]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15],v[16],v[17]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[17]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15],v[16]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[16]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[15]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[14]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[13]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[12]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[11]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[10]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[9]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[8]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[7]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[6]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[5]) - { return f(v[0],v[1],v[2],v[3],v[4]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[4]) - { return f(v[0],v[1],v[2],v[3]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[3]) - { return f(v[0],v[1],v[2]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[2]) - { return f(v[0],v[1]); } - }; - - template - struct invoke - { - static inline T_ execute(ifunction& f, T_ (&v)[1]) - { return f(v[0]); } - }; - - inline typename expression_node::node_type type() const - { - return expression_node::e_function; - } - - private: - - ifunction* function_; - std::size_t parameter_count_; - branch_t branch_[N]; - }; - - template - class function_N_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - typedef IFunction ifunction; - - function_N_node(ifunction* func) - : function_((0 == func->param_count) ? func : reinterpret_cast(0)) - {} - - inline bool operator <(const function_N_node& fn) const - { - return this < (&fn); - } - - inline T value() const - { - if (function_) - return (*function_)(); - else - return std::numeric_limits::quiet_NaN(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_function; - } - - private: - - ifunction* function_; - }; - - template - class vararg_function_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - - vararg_function_node(VarArgFunction* func, - const std::vector& arg_list) - : function_(func), - arg_list_(arg_list) - { - value_list_.resize(arg_list.size(),std::numeric_limits::quiet_NaN()); - } - - ~vararg_function_node() - { - for (std::size_t i = 0; i < arg_list_.size(); ++i) + + inline typename expression_node::node_type type() const { - if (arg_list_[i] && !details::is_variable_node(arg_list_[i])) - { - delete arg_list_[i]; - arg_list_[i] = 0; - } + return expression_node::e_function; } - } - - inline bool operator <(const vararg_function_node& fn) const - { - return this < (&fn); - } - - inline T value() const - { - if (function_) + + private: + + ifunction* function_; + }; + + template + class vararg_function_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + + vararg_function_node(VarArgFunction* func, + const std::vector& arg_list) + : function_(func), + arg_list_(arg_list) + { + value_list_.resize(arg_list.size(),std::numeric_limits::quiet_NaN()); + } + + ~vararg_function_node() + { + for (std::size_t i = 0; i < arg_list_.size(); ++i) + { + if (arg_list_[i] && !details::is_variable_node(arg_list_[i])) + { + delete arg_list_[i]; + arg_list_[i] = 0; + } + } + } + + inline bool operator <(const vararg_function_node& fn) const + { + return this < (&fn); + } + + inline T value() const + { + if (function_) + { + populate_value_list(); + return (*function_)(value_list_); + } + else + return std::numeric_limits::quiet_NaN(); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_vafunction; + } + + private: + + inline void populate_value_list() const + { + for (std::size_t i = 0; i < arg_list_.size(); ++i) + { + value_list_[i] = arg_list_[i]->value(); + } + } + + VarArgFunction* function_; + std::vector arg_list_; + mutable std::vector value_list_; + }; + + template + class generic_function_node : public expression_node + { + public: + + typedef type_store type_store_t; + typedef expression_node* expression_ptr; + typedef variable_node variable_node_t; + typedef vector_node vector_node_t; + typedef variable_node_t* variable_node_ptr_t; + typedef vector_node_t* vector_node_ptr_t; + typedef range_interface range_interface_t; + typedef range_data_type range_data_type_t; + typedef range_pack range_t; + typedef std::pair branch_t; + typedef std::pair void_t; + typedef std::vector tmp_vs_t; + typedef std::vector typestore_list_t; + typedef std::vector range_list_t; + + generic_function_node(const std::vector& arg_list, + GenericFunction* func = (GenericFunction*)(0)) + : function_(func), + arg_list_(arg_list) + {} + + virtual ~generic_function_node() + { + cleanup_branches::execute(branch_); + } + + virtual bool init_branches() + { + expr_as_vec1_store_.resize(arg_list_.size(),T(0) ); + typestore_list_ .resize(arg_list_.size(),type_store_t() ); + range_list_ .resize(arg_list_.size(),range_data_type_t()); + branch_ .resize(arg_list_.size(),branch_t((expression_ptr)0,false)); + + for (std::size_t i = 0; i < arg_list_.size(); ++i) + { + type_store_t& ts = typestore_list_[i]; + + if (0 == arg_list_[i]) + return false; + else if (is_ivector_node(arg_list_[i])) + { + vector_interface* vi = reinterpret_cast*>(0); + + if (0 == (vi = dynamic_cast*>(arg_list_[i]))) + return false; + + ts.size = vi->size(); + ts.data = vi->vds().data(); + ts.type = type_store_t::e_vector; + } + else if (is_generally_string_node(arg_list_[i])) + { + string_base_node* sbn = reinterpret_cast*>(0); + + if (0 == (sbn = dynamic_cast*>(arg_list_[i]))) + return false; + + ts.size = sbn->size(); + ts.data = reinterpret_cast(const_cast(sbn->base())); + ts.type = type_store_t::e_string; + + range_list_[i].data = ts.data; + range_list_[i].size = ts.size; + range_list_[i].type_size = sizeof(char); + range_list_[i].str_node = sbn; + + range_interface_t* ri = reinterpret_cast(0); + + if (0 == (ri = dynamic_cast(arg_list_[i]))) + return false; + + range_t& rp = ri->range_ref(); + + if ( + rp.const_range() && + is_const_string_range_node(arg_list_[i]) + ) + { + ts.size = rp.const_size(); + ts.data = static_cast(ts.data) + rp.n0_c.second; + range_list_[i].range = reinterpret_cast(0); + } + else + range_list_[i].range = &(ri->range_ref()); + } + else if (is_variable_node(arg_list_[i])) + { + variable_node_ptr_t var = variable_node_ptr_t(0); + + if (0 == (var = dynamic_cast(arg_list_[i]))) + return false; + + ts.size = 1; + ts.data = &var->ref(); + ts.type = type_store_t::e_scalar; + } + else + { + ts.size = 1; + ts.data = reinterpret_cast(&expr_as_vec1_store_[i]); + ts.type = type_store_t::e_scalar; + } + + branch_[i] = std::make_pair(arg_list_[i],branch_deletable(arg_list_[i])); + } + + return true; + } + + inline bool operator <(const generic_function_node& fn) const + { + return this < (&fn); + } + + inline T value() const + { + if (function_) + { + if (populate_value_list()) + { + typedef typename GenericFunction::parameter_list_t parameter_list_t; + + return (*function_)(parameter_list_t(typestore_list_)); + } + } + + return std::numeric_limits::quiet_NaN(); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_genfunction; + } + + protected: + + inline virtual bool populate_value_list() const + { + for (std::size_t i = 0; i < branch_.size(); ++i) + { + expr_as_vec1_store_[i] = branch_[i].first->value(); + } + + for (std::size_t i = 0; i < branch_.size(); ++i) + { + range_data_type_t& rdt = range_list_[i]; + + if (rdt.range) + { + range_t& rp = (*rdt.range); + std::size_t r0 = 0; + std::size_t r1 = 0; + + if (rp(r0,r1,rdt.size)) + { + type_store_t& ts = typestore_list_[i]; + + ts.size = rp.cache_size(); + + if (ts.type == type_store_t::e_string) + ts.data = const_cast(rdt.str_node->base()) + rp.cache.first; + else + ts.data = static_cast(rdt.data) + (rp.cache.first * rdt.type_size); + } + else + return false; + } + } + + return true; + } + + GenericFunction* function_; + mutable typestore_list_t typestore_list_; + + private: + + std::vector arg_list_; + std::vector branch_; + mutable tmp_vs_t expr_as_vec1_store_; + mutable range_list_t range_list_; + }; + + template + class string_function_node : public generic_function_node, + public string_base_node, + public range_interface + { + public: + + typedef generic_function_node gen_function_t; + typedef range_pack range_t; + + string_function_node(StringFunction* func, + const std::vector& arg_list) + : gen_function_t(arg_list,func) + { + range_.n0_c = std::make_pair(true,0); + range_.n1_c = std::make_pair(true,0); + range_.cache.first = range_.n0_c.second; + range_.cache.second = range_.n1_c.second; + } + + inline bool operator <(const string_function_node& fn) const + { + return this < (&fn); + } + + inline T value() const + { + T result = std::numeric_limits::quiet_NaN(); + + if (gen_function_t::function_) + { + if (gen_function_t::populate_value_list()) + { + typedef typename StringFunction::parameter_list_t parameter_list_t; + + result = (*gen_function_t::function_)(ret_string_, + parameter_list_t(gen_function_t::typestore_list_)); + + range_.n1_c.second = ret_string_.size() - 1; + range_.cache.second = range_.n1_c.second; + + return result; + } + } + + return result; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_strfunction; + } + + std::string str() const + { + return ret_string_; + } + + const char* base() const + { + return &ret_string_[0]; + } + + std::size_t size() const + { + return ret_string_.size(); + } + + range_t& range_ref() + { + return range_; + } + + const range_t& range_ref() const + { + return range_; + } + + protected: + + mutable range_t range_; + mutable std::string ret_string_; + }; + + template + class multimode_genfunction_node : public generic_function_node + { + public: + + typedef generic_function_node gen_function_t; + typedef range_pack range_t; + + multimode_genfunction_node(GenericFunction* func, + const std::size_t& param_seq_index, + const std::vector& arg_list) + : gen_function_t(arg_list,func), + param_seq_index_(param_seq_index) + {} + + inline T value() const + { + T result = std::numeric_limits::quiet_NaN(); + + if (gen_function_t::function_) + { + if (gen_function_t::populate_value_list()) + { + typedef typename GenericFunction::parameter_list_t parameter_list_t; + + return (*gen_function_t::function_)(param_seq_index_, + parameter_list_t(gen_function_t::typestore_list_)); + } + } + + return result; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_genfunction; + } + + private: + + std::size_t param_seq_index_; + }; + + template + class multimode_strfunction_node : public string_function_node + { + public: + + typedef string_function_node str_function_t; + typedef range_pack range_t; + + multimode_strfunction_node(StringFunction* func, + const std::size_t& param_seq_index, + const std::vector& arg_list) + : str_function_t(func,arg_list), + param_seq_index_(param_seq_index) + {} + + inline T value() const + { + T result = std::numeric_limits::quiet_NaN(); + + if (str_function_t::function_) + { + if (str_function_t::populate_value_list()) + { + typedef typename StringFunction::parameter_list_t parameter_list_t; + + result = (*str_function_t::function_)(param_seq_index_, + str_function_t::ret_string_, + parameter_list_t(str_function_t::typestore_list_)); + + str_function_t::range_.n1_c.second = str_function_t::ret_string_.size() - 1; + str_function_t::range_.cache.second = str_function_t::range_.n1_c.second; + + return result; + } + } + + return result; + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_strfunction; + } + + private: + + std::size_t param_seq_index_; + }; + + class return_exception + {}; + + template + class null_igenfunc + { + public: + + virtual ~null_igenfunc() + {} + + typedef type_store generic_type; + typedef typename generic_type::parameter_list parameter_list_t; + + inline virtual T operator()(parameter_list_t) { - populate_value_list(); - return (*function_)(value_list_); + return std::numeric_limits::quiet_NaN(); } - else - return std::numeric_limits::quiet_NaN(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_vafunction; - } - - private: - - inline void populate_value_list() const - { - for (std::size_t i = 0; i < arg_list_.size(); ++i) + }; + + template + class return_node : public generic_function_node > + { + public: + + typedef null_igenfunc igeneric_function_t; + typedef igeneric_function_t* igeneric_function_ptr; + typedef generic_function_node gen_function_t; + typedef results_context results_context_t; + + return_node(const std::vector& arg_list, + results_context_t& rc) + : gen_function_t (arg_list), + results_context_(&rc) + {} + + inline T value() const { - value_list_[i] = arg_list_[i]->value(); + if ( + (0 != results_context_) && + gen_function_t::populate_value_list() + ) + { + typedef typename type_store::parameter_list parameter_list_t; + + results_context_-> + assign(parameter_list_t(gen_function_t::typestore_list_)); + + throw return_exception(); + } + + return std::numeric_limits::quiet_NaN(); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_return; + } + + private: + + results_context_t* results_context_; + }; + + template + class return_envelope_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef results_context results_context_t; + + return_envelope_node(expression_ptr body, results_context_t& rc) + : results_context_(&rc), + return_invoked_ (false), + body_ (body), + body_deletable_ (branch_deletable(body_)) + {} + + ~return_envelope_node() + { + if (body_ && body_deletable_) + { + delete body_; + } + } + + inline T value() const + { + try + { + return_invoked_ = false; + results_context_->clear(); + + return body_->value(); + } + catch(const return_exception&) + { + return_invoked_ = true; + return std::numeric_limits::quiet_NaN(); + } + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_retenv; + } + + inline bool* retinvk_ptr() + { + return &return_invoked_; + } + + private: + + results_context_t* results_context_; + mutable bool return_invoked_; + expression_ptr body_; + bool body_deletable_; + }; + +#define exprtk_define_unary_op(OpName) \ +template \ +struct OpName##_op \ +{ \ +typedef typename functor_t::Type Type; \ +typedef typename expression_node::node_type node_t; \ +\ +static inline T process(Type v) \ +{ \ +return numeric:: OpName (v); \ +} \ +\ +static inline node_t type() \ +{ \ +return expression_node::e_##OpName; \ +} \ +\ +static inline details::operator_type operation() \ +{ \ +return details::e_##OpName; \ +} \ +}; \ + + exprtk_define_unary_op(abs ) + exprtk_define_unary_op(acos ) + exprtk_define_unary_op(acosh) + exprtk_define_unary_op(asin ) + exprtk_define_unary_op(asinh) + exprtk_define_unary_op(atan ) + exprtk_define_unary_op(atanh) + exprtk_define_unary_op(ceil ) + exprtk_define_unary_op(cos ) + exprtk_define_unary_op(cosh ) + exprtk_define_unary_op(cot ) + exprtk_define_unary_op(csc ) + exprtk_define_unary_op(d2g ) + exprtk_define_unary_op(d2r ) + exprtk_define_unary_op(erf ) + exprtk_define_unary_op(erfc ) + exprtk_define_unary_op(exp ) + exprtk_define_unary_op(expm1) + exprtk_define_unary_op(floor) + exprtk_define_unary_op(frac ) + exprtk_define_unary_op(g2d ) + exprtk_define_unary_op(log ) + exprtk_define_unary_op(log10) + exprtk_define_unary_op(log2 ) + exprtk_define_unary_op(log1p) + exprtk_define_unary_op(ncdf ) + exprtk_define_unary_op(neg ) + exprtk_define_unary_op(notl ) + exprtk_define_unary_op(pos ) + exprtk_define_unary_op(r2d ) + exprtk_define_unary_op(round) + exprtk_define_unary_op(sec ) + exprtk_define_unary_op(sgn ) + exprtk_define_unary_op(sin ) + exprtk_define_unary_op(sinc ) + exprtk_define_unary_op(sinh ) + exprtk_define_unary_op(sqrt ) + exprtk_define_unary_op(tan ) + exprtk_define_unary_op(tanh ) + exprtk_define_unary_op(trunc) +#undef exprtk_define_unary_op + + template + struct opr_base + { + typedef typename details::functor_t::Type Type; + typedef typename details::functor_t::RefType RefType; + typedef typename details::functor_t functor_t; + typedef typename functor_t::qfunc_t quaternary_functor_t; + typedef typename functor_t::tfunc_t trinary_functor_t; + typedef typename functor_t::bfunc_t binary_functor_t; + typedef typename functor_t::ufunc_t unary_functor_t; + }; + + template + struct add_op : public opr_base + { + typedef typename opr_base::Type Type; + typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return t1 + t2; } + static inline T process(Type t1, Type t2, Type t3) { return t1 + t2 + t3; } + static inline void assign(RefType t1, Type t2) { t1 += t2; } + static inline typename expression_node::node_type type() { return expression_node::e_add; } + static inline details::operator_type operation() { return details::e_add; } + }; + + template + struct mul_op : public opr_base + { + typedef typename opr_base::Type Type; + typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return t1 * t2; } + static inline T process(Type t1, Type t2, Type t3) { return t1 * t2 * t3; } + static inline void assign(RefType t1, Type t2) { t1 *= t2; } + static inline typename expression_node::node_type type() { return expression_node::e_mul; } + static inline details::operator_type operation() { return details::e_mul; } + }; + + template + struct sub_op : public opr_base + { + typedef typename opr_base::Type Type; + typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return t1 - t2; } + static inline T process(Type t1, Type t2, Type t3) { return t1 - t2 - t3; } + static inline void assign(RefType t1, Type t2) { t1 -= t2; } + static inline typename expression_node::node_type type() { return expression_node::e_sub; } + static inline details::operator_type operation() { return details::e_sub; } + }; + + template + struct div_op : public opr_base + { + typedef typename opr_base::Type Type; + typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return t1 / t2; } + static inline T process(Type t1, Type t2, Type t3) { return t1 / t2 / t3; } + static inline void assign(RefType t1, Type t2) { t1 /= t2; } + static inline typename expression_node::node_type type() { return expression_node::e_div; } + static inline details::operator_type operation() { return details::e_div; } + }; + + template + struct mod_op : public opr_base + { + typedef typename opr_base::Type Type; + typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return numeric::modulus(t1,t2); } + static inline void assign(RefType t1, Type t2) { t1 = numeric::modulus(t1,t2); } + static inline typename expression_node::node_type type() { return expression_node::e_mod; } + static inline details::operator_type operation() { return details::e_mod; } + }; + + template + struct pow_op : public opr_base + { + typedef typename opr_base::Type Type; + typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return numeric::pow(t1,t2); } + static inline void assign(RefType t1, Type t2) { t1 = numeric::pow(t1,t2); } + static inline typename expression_node::node_type type() { return expression_node::e_pow; } + static inline details::operator_type operation() { return details::e_pow; } + }; + + template + struct lt_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return ((t1 < t2) ? T(1) : T(0)); } + static inline T process(const std::string& t1, const std::string& t2) { return ((t1 < t2) ? T(1) : T(0)); } + static inline typename expression_node::node_type type() { return expression_node::e_lt; } + static inline details::operator_type operation() { return details::e_lt; } + }; + + template + struct lte_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return ((t1 <= t2) ? T(1) : T(0)); } + static inline T process(const std::string& t1, const std::string& t2) { return ((t1 <= t2) ? T(1) : T(0)); } + static inline typename expression_node::node_type type() { return expression_node::e_lte; } + static inline details::operator_type operation() { return details::e_lte; } + }; + + template + struct gt_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return ((t1 > t2) ? T(1) : T(0)); } + static inline T process(const std::string& t1, const std::string& t2) { return ((t1 > t2) ? T(1) : T(0)); } + static inline typename expression_node::node_type type() { return expression_node::e_gt; } + static inline details::operator_type operation() { return details::e_gt; } + }; + + template + struct gte_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return ((t1 >= t2) ? T(1) : T(0)); } + static inline T process(const std::string& t1, const std::string& t2) { return ((t1 >= t2) ? T(1) : T(0)); } + static inline typename expression_node::node_type type() { return expression_node::e_gte; } + static inline details::operator_type operation() { return details::e_gte; } + }; + + template + struct eq_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (std::equal_to()(t1,t2) ? T(1) : T(0)); } + static inline T process(const std::string& t1, const std::string& t2) { return ((t1 == t2) ? T(1) : T(0)); } + static inline typename expression_node::node_type type() { return expression_node::e_eq; } + static inline details::operator_type operation() { return details::e_eq; } + }; + + template + struct equal_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (numeric::equal(t1,t2) ? T(1) : T(0)); } + static inline T process(const std::string& t1, const std::string& t2) { return ((t1 == t2) ? T(1) : T(0)); } + static inline typename expression_node::node_type type() { return expression_node::e_eq; } + static inline details::operator_type operation() { return details::e_equal; } + }; + + template + struct ne_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (std::not_equal_to()(t1,t2) ? T(1) : T(0)); } + static inline T process(const std::string& t1, const std::string& t2) { return ((t1 != t2) ? T(1) : T(0)); } + static inline typename expression_node::node_type type() { return expression_node::e_ne; } + static inline details::operator_type operation() { return details::e_ne; } + }; + + template + struct and_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (details::is_true(t1) && details::is_true(t2)) ? T(1) : T(0); } + static inline typename expression_node::node_type type() { return expression_node::e_and; } + static inline details::operator_type operation() { return details::e_and; } + }; + + template + struct nand_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (details::is_true(t1) && details::is_true(t2)) ? T(0) : T(1); } + static inline typename expression_node::node_type type() { return expression_node::e_nand; } + static inline details::operator_type operation() { return details::e_nand; } + }; + + template + struct or_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (details::is_true(t1) || details::is_true(t2)) ? T(1) : T(0); } + static inline typename expression_node::node_type type() { return expression_node::e_or; } + static inline details::operator_type operation() { return details::e_or; } + }; + + template + struct nor_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (details::is_true(t1) || details::is_true(t2)) ? T(0) : T(1); } + static inline typename expression_node::node_type type() { return expression_node::e_nor; } + static inline details::operator_type operation() { return details::e_nor; } + }; + + template + struct xor_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return numeric::xor_opr(t1,t2); } + static inline typename expression_node::node_type type() { return expression_node::e_nor; } + static inline details::operator_type operation() { return details::e_xor; } + }; + + template + struct xnor_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return numeric::xnor_opr(t1,t2); } + static inline typename expression_node::node_type type() { return expression_node::e_nor; } + static inline details::operator_type operation() { return details::e_xnor; } + }; + + template + struct in_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(const T&, const T&) { return std::numeric_limits::quiet_NaN(); } + static inline T process(const std::string& t1, const std::string& t2) { return ((std::string::npos != t2.find(t1)) ? T(1) : T(0)); } + static inline typename expression_node::node_type type() { return expression_node::e_in; } + static inline details::operator_type operation() { return details::e_in; } + }; + + template + struct like_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(const T&, const T&) { return std::numeric_limits::quiet_NaN(); } + static inline T process(const std::string& t1, const std::string& t2) { return (details::wc_match(t2,t1) ? T(1) : T(0)); } + static inline typename expression_node::node_type type() { return expression_node::e_like; } + static inline details::operator_type operation() { return details::e_like; } + }; + + template + struct ilike_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(const T&, const T&) { return std::numeric_limits::quiet_NaN(); } + static inline T process(const std::string& t1, const std::string& t2) { return (details::wc_imatch(t2,t1) ? T(1) : T(0)); } + static inline typename expression_node::node_type type() { return expression_node::e_ilike; } + static inline details::operator_type operation() { return details::e_ilike; } + }; + + template + struct inrange_op : public opr_base + { + typedef typename opr_base::Type Type; + static inline T process(const T& t0, const T& t1, const T& t2) { return ((t0 <= t1) && (t1 <= t2)) ? T(1) : T(0); } + static inline T process(const std::string& t0, const std::string& t1, const std::string& t2) + { + return ((t0 <= t1) && (t1 <= t2)) ? T(1) : T(0); + } + static inline typename expression_node::node_type type() { return expression_node::e_inranges; } + static inline details::operator_type operation() { return details::e_inrange; } + }; + + template + inline T value(details::expression_node* n) + { + return n->value(); + } + + template + inline T value(T* t) + { + return (*t); + } + + template + struct vararg_add_op : public opr_base + { + typedef typename opr_base::Type Type; + + template class Sequence> + static inline T process(const Sequence& arg_list) + { + switch (arg_list.size()) + { + case 0 : return T(0); + case 1 : return process_1(arg_list); + case 2 : return process_2(arg_list); + case 3 : return process_3(arg_list); + case 4 : return process_4(arg_list); + case 5 : return process_5(arg_list); + default : + { + T result = T(0); + + for (std::size_t i = 0; i < arg_list.size(); ++i) + { + result += value(arg_list[i]); + } + + return result; + } + } } - } - - VarArgFunction* function_; - std::vector arg_list_; - mutable std::vector value_list_; - }; - - template - class generic_function_node : public expression_node - { - public: - - typedef type_store type_store_t; - typedef expression_node* expression_ptr; - typedef variable_node variable_node_t; - typedef vector_elem_node vector_elem_node_t; - typedef vector_node vector_node_t; - typedef variable_node_t* variable_node_ptr_t; - typedef vector_elem_node_t* vector_elem_node_ptr_t; - typedef vector_node_t* vector_node_ptr_t; - typedef range_interface range_interface_t; - typedef range_data_type range_data_type_t; - typedef range_pack range_t; - typedef std::pair branch_t; - typedef std::pair void_t; - typedef std::vector tmp_vs_t; - typedef std::vector typestore_list_t; - typedef std::vector range_list_t; - - generic_function_node(GenericFunction* func, - const std::vector& arg_list) - : function_(func), - arg_list_(arg_list) - {} - - ~generic_function_node() - { - cleanup_branches::execute(branch_); - } - - virtual bool init_branches() - { - expr_as_vec1_store_.resize(arg_list_.size(),T(0) ); - typestore_list_ .resize(arg_list_.size(),type_store_t() ); - range_list_ .resize(arg_list_.size(),range_data_type_t()); - branch_ .resize(arg_list_.size(),branch_t((expression_ptr)0,false)); - - for (std::size_t i = 0; i < arg_list_.size(); ++i) + + template + static inline T process_1(const Sequence& arg_list) { - type_store_t& ts = typestore_list_[i]; - - if (0 == arg_list_[i]) - return false; - else if (is_ivector_node(arg_list_[i])) - { - vector_interface* vi = reinterpret_cast*>(0); - - if (0 == (vi = dynamic_cast*>(arg_list_[i]))) - return false; - - ts.size = vi->size(); - ts.data = vi->vec()->ref()[0]; - ts.type = type_store_t::e_vector; - } - else if (is_generally_string_node(arg_list_[i])) - { - string_base_node* sbn = reinterpret_cast*>(0); - - if (0 == (sbn = dynamic_cast*>(arg_list_[i]))) - return false; - - ts.size = sbn->size(); - ts.data = reinterpret_cast(const_cast(sbn->base())); - ts.type = type_store_t::e_string; - - range_list_[i].data = ts.data; - range_list_[i].size = ts.size; - range_list_[i].type_size = sizeof(char); - range_list_[i].str_node = sbn; - - if (is_generally_string_node(arg_list_[i])) - { - range_interface_t* ri = reinterpret_cast(0); - - if (0 == (ri = dynamic_cast(arg_list_[i]))) - return false; - - range_t& rp = ri->range_ref(); - - if ( - rp.const_range() && - is_const_string_range_node(arg_list_[i]) - ) - { - ts.size = rp.const_size(); - ts.data = static_cast(ts.data) + rp.n0_c.second; - range_list_[i].range = reinterpret_cast(0); - } - else - range_list_[i].range = &(ri->range_ref()); - } - } - else if (is_variable_node(arg_list_[i])) - { - variable_node_ptr_t var = variable_node_ptr_t(0); - - if (0 == (var = dynamic_cast(arg_list_[i]))) - return false; - - ts.size = 1; - ts.data = &var->ref(); - ts.type = type_store_t::e_scalar; - } - else if (is_vector_elem_node(arg_list_[i])) - { - vector_elem_node_ptr_t var = vector_elem_node_ptr_t(0); - - if (0 == (var = dynamic_cast(arg_list_[i]))) - return false; - - ts.size = 1; - ts.data = reinterpret_cast(&var->ref()); - ts.type = type_store_t::e_scalar; - } - else - { - ts.size = 1; - ts.data = reinterpret_cast(&expr_as_vec1_store_[i]); - ts.type = type_store_t::e_scalar; - } - - branch_[i] = std::make_pair(arg_list_[i],branch_deletable(arg_list_[i])); + return value(arg_list[0]); } - - return true; - } - - inline bool operator <(const generic_function_node& fn) const - { - return this < (&fn); - } - - inline T value() const - { - if (function_) + + template + static inline T process_2(const Sequence& arg_list) { - if (populate_value_list()) - { - typedef typename GenericFunction::parameter_list_t parameter_list_t; - - return (*function_)(parameter_list_t(typestore_list_)); - } + return value(arg_list[0]) + value(arg_list[1]); } - - return std::numeric_limits::quiet_NaN(); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_genfunction; - } - - protected: - - inline virtual bool populate_value_list() const - { - for (std::size_t i = 0; i < branch_.size(); ++i) + + template + static inline T process_3(const Sequence& arg_list) { - expr_as_vec1_store_[i] = branch_[i].first->value(); + return value(arg_list[0]) + value(arg_list[1]) + + value(arg_list[2]); } - - for (std::size_t i = 0; i < branch_.size(); ++i) + + template + static inline T process_4(const Sequence& arg_list) { - range_data_type_t& rdt = range_list_[i]; - - if (rdt.range) - { - range_t& rp = (*rdt.range); - std::size_t r0 = 0; - std::size_t r1 = 0; - - if (rp(r0,r1,rdt.size)) - { - type_store_t& ts = typestore_list_[i]; - - ts.size = rp.cache_size(); - - if (ts.type == type_store_t::e_string) - ts.data = const_cast(rdt.str_node->base()) + rp.cache.first; - else - ts.data = static_cast(rdt.data) + (rp.cache.first * rdt.type_size); - } - else - return false; - } + return value(arg_list[0]) + value(arg_list[1]) + + value(arg_list[2]) + value(arg_list[3]); } - - return true; - } - - GenericFunction* function_; - mutable typestore_list_t typestore_list_; - - private: - - std::vector arg_list_; - std::vector branch_; - mutable tmp_vs_t expr_as_vec1_store_; - mutable range_list_t range_list_; - }; - - template - class string_function_node : public generic_function_node, - public string_base_node, - public range_interface - { - public: - - typedef generic_function_node gen_function_t; - typedef range_pack range_t; - - string_function_node(StringFunction* func, - const std::vector& arg_list) - : gen_function_t(func,arg_list) - { - range_.n0_c = std::make_pair(true,0); - range_.n1_c = std::make_pair(true,0); - range_.cache.first = range_.n0_c.second; - range_.cache.second = range_.n1_c.second; - } - - inline bool operator <(const string_function_node& fn) const - { - return this < (&fn); - } - - inline T value() const - { - T result = std::numeric_limits::quiet_NaN(); - - if (gen_function_t::function_) + + template + static inline T process_5(const Sequence& arg_list) { - if (gen_function_t::populate_value_list()) - { - typedef typename StringFunction::parameter_list_t parameter_list_t; - - result = (*gen_function_t::function_)(ret_string_, - parameter_list_t(gen_function_t::typestore_list_)); - - range_.n1_c.second = ret_string_.size() - 1; - range_.cache.second = range_.n1_c.second; - - return result; - } + return value(arg_list[0]) + value(arg_list[1]) + + value(arg_list[2]) + value(arg_list[3]) + + value(arg_list[4]); } - - return result; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_strfunction; - } - - std::string str() const - { - return ret_string_; - } - - const char* base() const - { - return ret_string_.data(); - } - - std::size_t size() const - { - return ret_string_.size(); - } - - range_t& range_ref() - { - return range_; - } - - const range_t& range_ref() const - { - return range_; - } - - protected: - - mutable range_t range_; - mutable std::string ret_string_; - }; - - template - class multimode_genfunction_node : public generic_function_node - { - public: - - typedef generic_function_node gen_function_t; - typedef range_pack range_t; - - multimode_genfunction_node(GenericFunction* func, - const std::size_t& param_seq_index, - const std::vector& arg_list) - : gen_function_t(func,arg_list), - param_seq_index_(param_seq_index) - {} - - inline T value() const - { - T result = std::numeric_limits::quiet_NaN(); - - if (gen_function_t::function_) + }; + + template + struct vararg_mul_op : public opr_base + { + typedef typename opr_base::Type Type; + + template class Sequence> + static inline T process(const Sequence& arg_list) + { + switch (arg_list.size()) + { + case 0 : return T(0); + case 1 : return process_1(arg_list); + case 2 : return process_2(arg_list); + case 3 : return process_3(arg_list); + case 4 : return process_4(arg_list); + case 5 : return process_5(arg_list); + default : + { + T result = T(value(arg_list[0])); + + for (std::size_t i = 1; i < arg_list.size(); ++i) + { + result *= value(arg_list[i]); + } + + return result; + } + } + } + + template + static inline T process_1(const Sequence& arg_list) { - if (gen_function_t::populate_value_list()) - { - typedef typename GenericFunction::parameter_list_t parameter_list_t; - - return (*gen_function_t::function_)(param_seq_index_, - parameter_list_t(gen_function_t::typestore_list_)); - } + return value(arg_list[0]); } - - return result; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_genfunction; - } - - private: - - std::size_t param_seq_index_; - }; - - template - class multimode_strfunction_node : public string_function_node - { - public: - - typedef string_function_node str_function_t; - typedef range_pack range_t; - - multimode_strfunction_node(StringFunction* func, - const std::size_t& param_seq_index, - const std::vector& arg_list) - : str_function_t(func,arg_list), - param_seq_index_(param_seq_index) - {} - - inline T value() const - { - T result = std::numeric_limits::quiet_NaN(); - - if (str_function_t::function_) + + template + static inline T process_2(const Sequence& arg_list) { - if (str_function_t::populate_value_list()) - { - typedef typename StringFunction::parameter_list_t parameter_list_t; - - result = (*str_function_t::function_)(param_seq_index_, - str_function_t::ret_string_, - parameter_list_t(str_function_t::typestore_list_)); - - str_function_t::range_.n1_c.second = str_function_t::ret_string_.size() - 1; - str_function_t::range_.cache.second = str_function_t::range_.n1_c.second; - - return result; - } + return value(arg_list[0]) * value(arg_list[1]); } - - return result; - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_strfunction; - } - - private: - - std::size_t param_seq_index_; - }; - - #define exprtk_define_unary_op(OpName) \ - template \ - struct OpName##_op \ - { \ - typedef typename functor_t::Type Type; \ - \ - static inline T process(Type v) \ - { \ - return numeric:: OpName (v); \ - } \ - \ - static inline typename expression_node::node_type type() \ - { \ - return expression_node::e_##OpName; \ - } \ - \ - static inline details::operator_type operation() \ - { \ - return details::e_##OpName; \ - } \ - }; \ - - exprtk_define_unary_op(abs ) - exprtk_define_unary_op(acos ) - exprtk_define_unary_op(acosh) - exprtk_define_unary_op(asin ) - exprtk_define_unary_op(asinh) - exprtk_define_unary_op(atan ) - exprtk_define_unary_op(atanh) - exprtk_define_unary_op(ceil ) - exprtk_define_unary_op(cos ) - exprtk_define_unary_op(cosh ) - exprtk_define_unary_op(cot ) - exprtk_define_unary_op(csc ) - exprtk_define_unary_op(d2g ) - exprtk_define_unary_op(d2r ) - exprtk_define_unary_op(erf ) - exprtk_define_unary_op(erfc ) - exprtk_define_unary_op(exp ) - exprtk_define_unary_op(expm1) - exprtk_define_unary_op(floor) - exprtk_define_unary_op(frac ) - exprtk_define_unary_op(g2d ) - exprtk_define_unary_op(log ) - exprtk_define_unary_op(log10) - exprtk_define_unary_op(log2 ) - exprtk_define_unary_op(log1p) - exprtk_define_unary_op(ncdf ) - exprtk_define_unary_op(neg ) - exprtk_define_unary_op(notl ) - exprtk_define_unary_op(pos ) - exprtk_define_unary_op(r2d ) - exprtk_define_unary_op(round) - exprtk_define_unary_op(sec ) - exprtk_define_unary_op(sgn ) - exprtk_define_unary_op(sin ) - exprtk_define_unary_op(sinc ) - exprtk_define_unary_op(sinh ) - exprtk_define_unary_op(sqrt ) - exprtk_define_unary_op(tan ) - exprtk_define_unary_op(tanh ) - exprtk_define_unary_op(trunc) - #undef exprtk_define_unary_op - - template - struct opr_base - { - typedef typename details::functor_t::Type Type; - typedef typename details::functor_t functor_t; - typedef typename functor_t::qfunc_t quaternary_functor_t; - typedef typename functor_t::tfunc_t trinary_functor_t; - typedef typename functor_t::bfunc_t binary_functor_t; - typedef typename functor_t::ufunc_t unary_functor_t; - }; - - template - struct add_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return t1 + t2; } - static inline T process(Type t1, Type t2, Type t3) { return t1 + t2 + t3; } - static inline typename expression_node::node_type type() { return expression_node::e_add; } - static inline details::operator_type operation() { return details::e_add; } - }; - - template - struct mul_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return t1 * t2; } - static inline T process(Type t1, Type t2, Type t3) { return t1 * t2 * t3; } - static inline typename expression_node::node_type type() { return expression_node::e_mul; } - static inline details::operator_type operation() { return details::e_mul; } - }; - - template - struct sub_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return t1 - t2; } - static inline T process(Type t1, Type t2, Type t3) { return t1 - t2 - t3; } - static inline typename expression_node::node_type type() { return expression_node::e_sub; } - static inline details::operator_type operation() { return details::e_sub; } - }; - - template - struct div_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return t1 / t2; } - static inline T process(Type t1, Type t2, Type t3) { return t1 / t2 / t3; } - static inline typename expression_node::node_type type() { return expression_node::e_div; } - static inline details::operator_type operation() { return details::e_div; } - }; - - template - struct mod_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return numeric::modulus(t1,t2); } - static inline typename expression_node::node_type type() { return expression_node::e_mod; } - static inline details::operator_type operation() { return details::e_mod; } - }; - - template - struct pow_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return numeric::pow(t1,t2); } - static inline typename expression_node::node_type type() { return expression_node::e_pow; } - static inline details::operator_type operation() { return details::e_pow; } - }; - - template - struct lt_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return ((t1 < t2) ? T(1) : T(0)); } - static inline T process(const std::string& t1, const std::string& t2) { return ((t1 < t2) ? T(1) : T(0)); } - static inline typename expression_node::node_type type() { return expression_node::e_lt; } - static inline details::operator_type operation() { return details::e_lt; } - }; - - template - struct lte_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return ((t1 <= t2) ? T(1) : T(0)); } - static inline T process(const std::string& t1, const std::string& t2) { return ((t1 <= t2) ? T(1) : T(0)); } - static inline typename expression_node::node_type type() { return expression_node::e_lte; } - static inline details::operator_type operation() { return details::e_lte; } - }; - - template - struct gt_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return ((t1 > t2) ? T(1) : T(0)); } - static inline T process(const std::string& t1, const std::string& t2) { return ((t1 > t2) ? T(1) : T(0)); } - static inline typename expression_node::node_type type() { return expression_node::e_gt; } - static inline details::operator_type operation() { return details::e_gt; } - }; - - template - struct gte_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return ((t1 >= t2) ? T(1) : T(0)); } - static inline T process(const std::string& t1, const std::string& t2) { return ((t1 >= t2) ? T(1) : T(0)); } - static inline typename expression_node::node_type type() { return expression_node::e_gte; } - static inline details::operator_type operation() { return details::e_gte; } - }; - - template - struct eq_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return (std::equal_to()(t1,t2) ? T(1) : T(0)); } - static inline T process(const std::string& t1, const std::string& t2) { return ((t1 == t2) ? T(1) : T(0)); } - static inline typename expression_node::node_type type() { return expression_node::e_eq; } - static inline details::operator_type operation() { return details::e_eq; } - }; - - template - struct ne_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return (std::not_equal_to()(t1,t2) ? T(1) : T(0)); } - static inline T process(const std::string& t1, const std::string& t2) { return ((t1 != t2) ? T(1) : T(0)); } - static inline typename expression_node::node_type type() { return expression_node::e_ne; } - static inline details::operator_type operation() { return details::e_ne; } - }; - - template - struct and_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return (details::is_true(t1) && details::is_true(t2)) ? T(1) : T(0); } - static inline typename expression_node::node_type type() { return expression_node::e_and; } - static inline details::operator_type operation() { return details::e_and; } - }; - - template - struct nand_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return (details::is_true(t1) && details::is_true(t2)) ? T(0) : T(1); } - static inline typename expression_node::node_type type() { return expression_node::e_nand; } - static inline details::operator_type operation() { return details::e_nand; } - }; - - template - struct or_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return (details::is_true(t1) || details::is_true(t2)) ? T(1) : T(0); } - static inline typename expression_node::node_type type() { return expression_node::e_or; } - static inline details::operator_type operation() { return details::e_or; } - }; - - template - struct nor_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return (details::is_true(t1) || details::is_true(t2)) ? T(0) : T(1); } - static inline typename expression_node::node_type type() { return expression_node::e_nor; } - static inline details::operator_type operation() { return details::e_nor; } - }; - - template - struct xor_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return numeric::xor_opr(t1,t2); } - static inline typename expression_node::node_type type() { return expression_node::e_nor; } - static inline details::operator_type operation() { return details::e_xor; } - }; - - template - struct xnor_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return numeric::xnor_opr(t1,t2); } - static inline typename expression_node::node_type type() { return expression_node::e_nor; } - static inline details::operator_type operation() { return details::e_xnor; } - }; - - template - struct in_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(const T&, const T&) { return std::numeric_limits::quiet_NaN(); } - static inline T process(const std::string& t1, const std::string& t2) { return ((std::string::npos != t2.find(t1)) ? T(1) : T(0)); } - static inline typename expression_node::node_type type() { return expression_node::e_in; } - static inline details::operator_type operation() { return details::e_in; } - }; - - template - struct like_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(const T&, const T&) { return std::numeric_limits::quiet_NaN(); } - static inline T process(const std::string& t1, const std::string& t2) { return (details::wc_match(t2,t1) ? T(1) : T(0)); } - static inline typename expression_node::node_type type() { return expression_node::e_like; } - static inline details::operator_type operation() { return details::e_like; } - }; - - template - struct ilike_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(const T&, const T&) { return std::numeric_limits::quiet_NaN(); } - static inline T process(const std::string& t1, const std::string& t2) { return (details::wc_imatch(t2,t1) ? T(1) : T(0)); } - static inline typename expression_node::node_type type() { return expression_node::e_ilike; } - static inline details::operator_type operation() { return details::e_ilike; } - }; - - template - struct inrange_op : public opr_base - { - typedef typename opr_base::Type Type; - static inline T process(const T& t0, const T& t1, const T& t2) { return ((t0 <= t1) && (t1 <= t2)) ? T(1) : T(0); } - static inline T process(const std::string& t0, const std::string& t1, const std::string& t2) - { - return ((t0 <= t1) && (t1 <= t2)) ? T(1) : T(0); - } - static inline typename expression_node::node_type type() { return expression_node::e_inranges; } - static inline details::operator_type operation() { return details::e_inrange; } - }; - - template - inline T value(details::expression_node* n) - { - return n->value(); - } - - template - inline T value(T* t) - { - return (*t); - } - - template - struct vararg_add_op : public opr_base - { - typedef typename opr_base::Type Type; - - template class Sequence> - static inline T process(const Sequence& arg_list) - { - switch (arg_list.size()) - { - case 0 : return T(0); - case 1 : return process_1(arg_list); - case 2 : return process_2(arg_list); - case 3 : return process_3(arg_list); - case 4 : return process_4(arg_list); - case 5 : return process_5(arg_list); - default : - { - T result = T(0); - - for (std::size_t i = 0; i < arg_list.size(); ++i) - { - result += value(arg_list[i]); - } - - return result; - } - } - } - - template - static inline T process_1(const Sequence& arg_list) - { - return value(arg_list[0]); - } - - template - static inline T process_2(const Sequence& arg_list) - { - return value(arg_list[0]) + value(arg_list[1]); - } - - template - static inline T process_3(const Sequence& arg_list) - { - return value(arg_list[0]) + value(arg_list[1]) + - value(arg_list[2]); - } - - template - static inline T process_4(const Sequence& arg_list) - { - return value(arg_list[0]) + value(arg_list[1]) + - value(arg_list[2]) + value(arg_list[3]); - } - - template - static inline T process_5(const Sequence& arg_list) - { - return value(arg_list[0]) + value(arg_list[1]) + - value(arg_list[2]) + value(arg_list[3]) + - value(arg_list[4]); - } - }; - - template - struct vararg_mul_op : public opr_base - { - typedef typename opr_base::Type Type; - - template class Sequence> - static inline T process(const Sequence& arg_list) - { - switch (arg_list.size()) - { - case 0 : return T(0); - case 1 : return process_1(arg_list); - case 2 : return process_2(arg_list); - case 3 : return process_3(arg_list); - case 4 : return process_4(arg_list); - case 5 : return process_5(arg_list); - default : - { - T result = T(value(arg_list[0])); - - for (std::size_t i = 1; i < arg_list.size(); ++i) - { - result *= value(arg_list[i]); - } - - return result; - } - } - } - - template - static inline T process_1(const Sequence& arg_list) - { - return value(arg_list[0]); - } - - template - static inline T process_2(const Sequence& arg_list) - { - return value(arg_list[0]) * value(arg_list[1]); - } - - template - static inline T process_3(const Sequence& arg_list) - { - return value(arg_list[0]) * value(arg_list[1]) * - value(arg_list[2]); - } - - template - static inline T process_4(const Sequence& arg_list) - { - return value(arg_list[0]) * value(arg_list[1]) * - value(arg_list[2]) * value(arg_list[3]); - } - - template - static inline T process_5(const Sequence& arg_list) - { - return value(arg_list[0]) * value(arg_list[1]) * - value(arg_list[2]) * value(arg_list[3]) * - value(arg_list[4]); - } - }; - - template - struct vararg_avg_op : public opr_base - { - typedef typename opr_base::Type Type; - - template class Sequence> - static inline T process(const Sequence& arg_list) - { - switch (arg_list.size()) - { - case 0 : return T(0); - case 1 : return process_1(arg_list); - case 2 : return process_2(arg_list); - case 3 : return process_3(arg_list); - case 4 : return process_4(arg_list); - case 5 : return process_5(arg_list); - default : return vararg_add_op::process(arg_list) / arg_list.size(); - } - } - - template - static inline T process_1(const Sequence& arg_list) - { - return value(arg_list[0]); - } - - template - static inline T process_2(const Sequence& arg_list) - { - return (value(arg_list[0]) + value(arg_list[1])) / T(2); - } - - template - static inline T process_3(const Sequence& arg_list) - { - return (value(arg_list[0]) + value(arg_list[1]) + value(arg_list[2])) / T(3); - } - - template - static inline T process_4(const Sequence& arg_list) - { - return (value(arg_list[0]) + value(arg_list[1]) + - value(arg_list[2]) + value(arg_list[3])) / T(4); - } - - template - static inline T process_5(const Sequence& arg_list) - { - return (value(arg_list[0]) + value(arg_list[1]) + - value(arg_list[2]) + value(arg_list[3]) + - value(arg_list[4])) / T(5); - } - }; - - template - struct vararg_min_op : public opr_base - { - typedef typename opr_base::Type Type; - - template class Sequence> - static inline T process(const Sequence& arg_list) - { - switch (arg_list.size()) - { - case 0 : return T(0); - case 1 : return process_1(arg_list); - case 2 : return process_2(arg_list); - case 3 : return process_3(arg_list); - case 4 : return process_4(arg_list); - case 5 : return process_5(arg_list); - default : - { - T result = T(value(arg_list[0])); - - for (std::size_t i = 1; i < arg_list.size(); ++i) - { - const T v = value(arg_list[i]); - - if (v < result) - result = v; - } - - return result; - } + + template + static inline T process_3(const Sequence& arg_list) + { + return value(arg_list[0]) * value(arg_list[1]) * + value(arg_list[2]); } - } - - template - static inline T process_1(const Sequence& arg_list) - { - return value(arg_list[0]); - } - - template - static inline T process_2(const Sequence& arg_list) - { - return std::min(value(arg_list[0]),value(arg_list[1])); - } - - template - static inline T process_3(const Sequence& arg_list) - { - return std::min(std::min(value(arg_list[0]),value(arg_list[1])),value(arg_list[2])); - } - - template - static inline T process_4(const Sequence& arg_list) - { - return std::min( - std::min(value(arg_list[0]),value(arg_list[1])), - std::min(value(arg_list[2]),value(arg_list[3]))); - } - - template - static inline T process_5(const Sequence& arg_list) - { - return std::min( - std::min(std::min(value(arg_list[0]),value(arg_list[1])), - std::min(value(arg_list[2]),value(arg_list[3]))), - value(arg_list[4])); - } - }; - - template - struct vararg_max_op : public opr_base - { - typedef typename opr_base::Type Type; - - template class Sequence> - static inline T process(const Sequence& arg_list) - { - switch (arg_list.size()) - { - case 0 : return T(0); - case 1 : return process_1(arg_list); - case 2 : return process_2(arg_list); - case 3 : return process_3(arg_list); - case 4 : return process_4(arg_list); - case 5 : return process_5(arg_list); - default : - { - T result = T(value(arg_list[0])); - - for (std::size_t i = 1; i < arg_list.size(); ++i) - { - const T v = value(arg_list[i]); - if (v > result) - result = v; - } - - return result; - } + + template + static inline T process_4(const Sequence& arg_list) + { + return value(arg_list[0]) * value(arg_list[1]) * + value(arg_list[2]) * value(arg_list[3]); } - } - - template - static inline T process_1(const Sequence& arg_list) - { - return value(arg_list[0]); - } - - template - static inline T process_2(const Sequence& arg_list) - { - return std::max(value(arg_list[0]),value(arg_list[1])); - } - - template - static inline T process_3(const Sequence& arg_list) - { - return std::max(std::max(value(arg_list[0]),value(arg_list[1])),value(arg_list[2])); - } - - template - static inline T process_4(const Sequence& arg_list) - { - return std::max( - std::max(value(arg_list[0]),value(arg_list[1])), - std::max(value(arg_list[2]),value(arg_list[3]))); - } - - template - static inline T process_5(const Sequence& arg_list) - { - return std::max( - std::max(std::max(value(arg_list[0]),value(arg_list[1])), - std::max(value(arg_list[2]),value(arg_list[3]))), - value(arg_list[4])); - } - }; - - template - struct vararg_mand_op : public opr_base - { - typedef typename opr_base::Type Type; - - template class Sequence> - static inline T process(const Sequence& arg_list) - { - switch (arg_list.size()) - { - case 1 : return process_1(arg_list); - case 2 : return process_2(arg_list); - case 3 : return process_3(arg_list); - case 4 : return process_4(arg_list); - case 5 : return process_5(arg_list); - default : - { - for (std::size_t i = 0; i < arg_list.size(); ++i) - { - if (std::equal_to()(T(0),value(arg_list[i]))) - return T(0); - } - - return T(1); - } + + template + static inline T process_5(const Sequence& arg_list) + { + return value(arg_list[0]) * value(arg_list[1]) * + value(arg_list[2]) * value(arg_list[3]) * + value(arg_list[4]); } - } - - template - static inline T process_1(const Sequence& arg_list) - { - return std::not_equal_to() - (T(0),value(arg_list[0])) ? T(1) : T(0); - } - - template - static inline T process_2(const Sequence& arg_list) - { - return ( - std::not_equal_to()(T(0),value(arg_list[0])) && - std::not_equal_to()(T(0),value(arg_list[1])) - ) ? T(1) : T(0); - } - - template - static inline T process_3(const Sequence& arg_list) - { - return ( - std::not_equal_to()(T(0),value(arg_list[0])) && - std::not_equal_to()(T(0),value(arg_list[1])) && - std::not_equal_to()(T(0),value(arg_list[2])) - ) ? T(1) : T(0); - } - - template - static inline T process_4(const Sequence& arg_list) - { - return ( - std::not_equal_to()(T(0),value(arg_list[0])) && - std::not_equal_to()(T(0),value(arg_list[1])) && - std::not_equal_to()(T(0),value(arg_list[2])) && - std::not_equal_to()(T(0),value(arg_list[3])) - ) ? T(1) : T(0); - } - - template - static inline T process_5(const Sequence& arg_list) - { - return ( - std::not_equal_to()(T(0),value(arg_list[0])) && - std::not_equal_to()(T(0),value(arg_list[1])) && - std::not_equal_to()(T(0),value(arg_list[2])) && - std::not_equal_to()(T(0),value(arg_list[3])) && - std::not_equal_to()(T(0),value(arg_list[4])) - ) ? T(1) : T(0); - } - }; - - template - struct vararg_mor_op : public opr_base - { - typedef typename opr_base::Type Type; - - template class Sequence> - static inline T process(const Sequence& arg_list) - { - switch (arg_list.size()) - { - case 1 : return process_1(arg_list); - case 2 : return process_2(arg_list); - case 3 : return process_3(arg_list); - case 4 : return process_4(arg_list); - case 5 : return process_5(arg_list); - default : - { - for (std::size_t i = 0; i < arg_list.size(); ++i) - { - if (std::not_equal_to()(T(0),value(arg_list[i]))) - return T(1); - } - - return T(0); - } + }; + + template + struct vararg_avg_op : public opr_base + { + typedef typename opr_base::Type Type; + + template class Sequence> + static inline T process(const Sequence& arg_list) + { + switch (arg_list.size()) + { + case 0 : return T(0); + case 1 : return process_1(arg_list); + case 2 : return process_2(arg_list); + case 3 : return process_3(arg_list); + case 4 : return process_4(arg_list); + case 5 : return process_5(arg_list); + default : return vararg_add_op::process(arg_list) / arg_list.size(); + } + } + + template + static inline T process_1(const Sequence& arg_list) + { + return value(arg_list[0]); + } + + template + static inline T process_2(const Sequence& arg_list) + { + return (value(arg_list[0]) + value(arg_list[1])) / T(2); + } + + template + static inline T process_3(const Sequence& arg_list) + { + return (value(arg_list[0]) + value(arg_list[1]) + value(arg_list[2])) / T(3); + } + + template + static inline T process_4(const Sequence& arg_list) + { + return (value(arg_list[0]) + value(arg_list[1]) + + value(arg_list[2]) + value(arg_list[3])) / T(4); + } + + template + static inline T process_5(const Sequence& arg_list) + { + return (value(arg_list[0]) + value(arg_list[1]) + + value(arg_list[2]) + value(arg_list[3]) + + value(arg_list[4])) / T(5); } - } - - template - static inline T process_1(const Sequence& arg_list) - { - return std::not_equal_to() - (T(0),value(arg_list[0])) ? T(1) : T(0); - } - - template - static inline T process_2(const Sequence& arg_list) - { - return ( - std::not_equal_to()(T(0),value(arg_list[0])) || - std::not_equal_to()(T(0),value(arg_list[1])) - ) ? T(1) : T(0); - } - - template - static inline T process_3(const Sequence& arg_list) - { - return ( - std::not_equal_to()(T(0),value(arg_list[0])) || - std::not_equal_to()(T(0),value(arg_list[1])) || - std::not_equal_to()(T(0),value(arg_list[2])) - ) ? T(1) : T(0); - } - - template - static inline T process_4(const Sequence& arg_list) - { - return ( - std::not_equal_to()(T(0),value(arg_list[0])) || - std::not_equal_to()(T(0),value(arg_list[1])) || - std::not_equal_to()(T(0),value(arg_list[2])) || - std::not_equal_to()(T(0),value(arg_list[3])) - ) ? T(1) : T(0); - } - - template - static inline T process_5(const Sequence& arg_list) - { - return ( - std::not_equal_to()(T(0),value(arg_list[0])) || - std::not_equal_to()(T(0),value(arg_list[1])) || - std::not_equal_to()(T(0),value(arg_list[2])) || - std::not_equal_to()(T(0),value(arg_list[3])) || - std::not_equal_to()(T(0),value(arg_list[4])) - ) ? T(1) : T(0); - } - }; - - template - struct vararg_multi_op : public opr_base - { - typedef typename opr_base::Type Type; - - template class Sequence> - static inline T process(const Sequence& arg_list) - { - switch (arg_list.size()) - { - case 0 : return std::numeric_limits::quiet_NaN(); - case 1 : return process_1(arg_list); - case 2 : return process_2(arg_list); - case 3 : return process_3(arg_list); - case 4 : return process_4(arg_list); - case 5 : return process_5(arg_list); - case 6 : return process_6(arg_list); - case 7 : return process_7(arg_list); - case 8 : return process_8(arg_list); - default : - { - for (std::size_t i = 0; i < (arg_list.size() - 1); ++i) - { - value(arg_list[i]); - } - - return value(arg_list.back()); - } + }; + + template + struct vararg_min_op : public opr_base + { + typedef typename opr_base::Type Type; + + template class Sequence> + static inline T process(const Sequence& arg_list) + { + switch (arg_list.size()) + { + case 0 : return T(0); + case 1 : return process_1(arg_list); + case 2 : return process_2(arg_list); + case 3 : return process_3(arg_list); + case 4 : return process_4(arg_list); + case 5 : return process_5(arg_list); + default : + { + T result = T(value(arg_list[0])); + + for (std::size_t i = 1; i < arg_list.size(); ++i) + { + const T v = value(arg_list[i]); + + if (v < result) + result = v; + } + + return result; + } + } } - } - - template - static inline T process_1(const Sequence& arg_list) - { - return value(arg_list[0]); - } - - template - static inline T process_2(const Sequence& arg_list) - { - value(arg_list[0]); - return value(arg_list[1]); - } - - template - static inline T process_3(const Sequence& arg_list) - { - value(arg_list[0]); - value(arg_list[1]); - return value(arg_list[2]); - } - - template - static inline T process_4(const Sequence& arg_list) - { - value(arg_list[0]); - value(arg_list[1]); - value(arg_list[2]); - return value(arg_list[3]); - } - - template - static inline T process_5(const Sequence& arg_list) - { - value(arg_list[0]); - value(arg_list[1]); - value(arg_list[2]); - value(arg_list[3]); - return value(arg_list[4]); - } - - template - static inline T process_6(const Sequence& arg_list) - { - value(arg_list[0]); - value(arg_list[1]); - value(arg_list[2]); - value(arg_list[3]); - value(arg_list[4]); - return value(arg_list[5]); - } - - template - static inline T process_7(const Sequence& arg_list) - { - value(arg_list[0]); - value(arg_list[1]); - value(arg_list[2]); - value(arg_list[3]); - value(arg_list[4]); - value(arg_list[5]); - return value(arg_list[6]); - } - - template - static inline T process_8(const Sequence& arg_list) - { - value(arg_list[0]); - value(arg_list[1]); - value(arg_list[2]); - value(arg_list[3]); - value(arg_list[4]); - value(arg_list[5]); - value(arg_list[6]); - return value(arg_list[7]); - } - }; - - template - struct vec_add_op - { - typedef vector_interface* ivector_ptr; - - static inline T process(const ivector_ptr v) - { - vector_holder& vec = v->vec()->ref(); - - T result = T(0); - - for (std::size_t i = 0; i < vec.size(); ++i) + + template + static inline T process_1(const Sequence& arg_list) { - result += (*vec[i]); + return value(arg_list[0]); } - - return result; - } - }; - - template - struct vec_mul_op - { - typedef vector_interface* ivector_ptr; - - static inline T process(const ivector_ptr v) - { - vector_holder& vec = v->vec()->ref(); - - T result = (*vec[0]); - - for (std::size_t i = 1; i < vec.size(); ++i) + + template + static inline T process_2(const Sequence& arg_list) { - result *= (*vec[i]); + return std::min(value(arg_list[0]),value(arg_list[1])); } - - return result; - } - }; - - template - struct vec_avg_op - { - typedef vector_interface* ivector_ptr; - - static inline T process(const ivector_ptr v) - { - vector_holder& vec = v->vec()->ref(); - - T result = T(0); - - for (std::size_t i = 0; i < vec.size(); ++i) + + template + static inline T process_3(const Sequence& arg_list) { - result += (*vec[i]); + return std::min(std::min(value(arg_list[0]),value(arg_list[1])),value(arg_list[2])); } - - return result / vec.size(); - } - }; - - template - struct vec_min_op - { - typedef vector_interface* ivector_ptr; - - static inline T process(const ivector_ptr v) - { - vector_holder& vec = v->vec()->ref(); - - T result = (*vec[0]); - - for (std::size_t i = 1; i < vec.size(); ++i) + + template + static inline T process_4(const Sequence& arg_list) { - T v_i = (*vec[i]); - - if (v_i < result) - result = v_i; + return std::min( + std::min(value(arg_list[0]),value(arg_list[1])), + std::min(value(arg_list[2]),value(arg_list[3]))); } - - return result; - } - }; - - template - struct vec_max_op - { - typedef vector_interface* ivector_ptr; - - static inline T process(const ivector_ptr v) - { - vector_holder& vec = v->vec()->ref(); - - T result = (*vec[0]); - - for (std::size_t i = 1; i < vec.size(); ++i) + + template + static inline T process_5(const Sequence& arg_list) { - T v_i = (*vec[i]); - if (v_i > result) - result = v_i; + return std::min( + std::min(std::min(value(arg_list[0]),value(arg_list[1])), + std::min(value(arg_list[2]),value(arg_list[3]))), + value(arg_list[4])); } - - return result; - } - }; - - template - class vov_base_node : public expression_node - { - public: - - inline virtual operator_type operation() const - { - return details::e_default; - } - - virtual const T& v0() const = 0; - - virtual const T& v1() const = 0; - }; - - template - class cov_base_node : public expression_node - { - public: - - inline virtual operator_type operation() const - { - return details::e_default; - } - - virtual const T c() const = 0; - - virtual const T& v() const = 0; - }; - - template - class voc_base_node : public expression_node - { - public: - - inline virtual operator_type operation() const - { - return details::e_default; - } - - virtual const T c() const = 0; - - virtual const T& v() const = 0; - }; - - template - class vob_base_node : public expression_node - { - public: - - virtual const T& v() const = 0; - }; - - template - class bov_base_node : public expression_node - { - public: - - virtual const T& v() const = 0; - }; - - template - class cob_base_node : public expression_node - { - public: - - inline virtual operator_type operation() const - { - return details::e_default; - } - - virtual const T c() const = 0; - - virtual void set_c(const T) = 0; - - virtual expression_node* move_branch(const std::size_t& index) = 0; - }; - - template - class boc_base_node : public expression_node - { - public: - - inline virtual operator_type operation() const - { - return details::e_default; - } - - virtual const T c() const = 0; - - virtual void set_c(const T) = 0; - - virtual expression_node* move_branch(const std::size_t& index) = 0; - }; - - template - class uv_base_node : public expression_node - { - public: - - inline virtual operator_type operation() const - { - return details::e_default; - } - - virtual const T& v() const = 0; - }; - - template - class sos_base_node : public expression_node - { - public: - - inline virtual operator_type operation() const - { - return details::e_default; - } - }; - - template - class sosos_base_node : public expression_node - { - public: - - inline virtual operator_type operation() const - { - return details::e_default; - } - }; - - template - class T0oT1oT2_base_node : public expression_node - { - public: - - virtual std::string type_id() const = 0; - }; - - template - class T0oT1oT2oT3_base_node : public expression_node - { - public: - - virtual std::string type_id() const = 0; - }; - - template - class unary_variable_node : public uv_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef Operation operation_t; - - explicit unary_variable_node(const T& var) - : v_(var) - {} - - inline T value() const - { - return Operation::process(v_); - } - - inline typename expression_node::node_type type() const - { - return Operation::type(); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T& v() const - { - return v_; - } - - private: - - unary_variable_node(unary_variable_node&); - unary_variable_node& operator=(unary_variable_node&); - - const T& v_; - }; - - template - class uvouv_node : public expression_node - { - public: - - // UOpr1(v0) Op UOpr2(v1) - - typedef expression_node* expression_ptr; - typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; - typedef typename functor_t::ufunc_t ufunc_t; - - explicit uvouv_node(const T& var0,const T& var1, - ufunc_t uf0, ufunc_t uf1, bfunc_t bf) - : v0_(var0), - v1_(var1), - u0_(uf0), - u1_(uf1), - f_ (bf) - {} - - inline T value() const - { - return f_(u0_(v0_),u1_(v1_)); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_uvouv; - } - - inline operator_type operation() const - { - return details::e_default; - } - - inline const T& v0() - { - return v0_; - } - - inline const T& v1() - { - return v1_; - } - - inline ufunc_t u0() - { - return u0_; - } - - inline ufunc_t u1() - { - return u1_; - } - - inline ufunc_t f() - { - return f_; - } - - private: - - uvouv_node(uvouv_node&); - uvouv_node& operator=(uvouv_node&); - - const T& v0_; - const T& v1_; - const ufunc_t u0_; - const ufunc_t u1_; - const bfunc_t f_; - }; - - template - class unary_branch_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - typedef Operation operation_t; - - explicit unary_branch_node(expression_ptr brnch) - : branch_(brnch), - branch_deletable_(branch_deletable(branch_)) - {} - - ~unary_branch_node() - { - if (branch_ && branch_deletable_) - { - delete branch_; - branch_ = 0; + }; + + template + struct vararg_max_op : public opr_base + { + typedef typename opr_base::Type Type; + + template class Sequence> + static inline T process(const Sequence& arg_list) + { + switch (arg_list.size()) + { + case 0 : return T(0); + case 1 : return process_1(arg_list); + case 2 : return process_2(arg_list); + case 3 : return process_3(arg_list); + case 4 : return process_4(arg_list); + case 5 : return process_5(arg_list); + default : + { + T result = T(value(arg_list[0])); + + for (std::size_t i = 1; i < arg_list.size(); ++i) + { + const T v = value(arg_list[i]); + + if (v > result) + result = v; + } + + return result; + } + } } - } - - inline T value() const - { - return Operation::process(branch_->value()); - } - - inline typename expression_node::node_type type() const - { - return Operation::type(); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline expression_node* branch(const std::size_t&) const - { - return branch_; - } - - inline void release() - { - branch_deletable_ = false; - } - - private: - - unary_branch_node(unary_branch_node&); - unary_branch_node& operator=(unary_branch_node&); - - expression_ptr branch_; - bool branch_deletable_; - }; - - template struct is_const { enum {result = 0}; }; - template struct is_const { enum {result = 1}; }; - template struct is_const_ref { enum {result = 0}; }; - template struct is_const_ref { enum {result = 1}; }; - template struct is_ref { enum {result = 0}; }; - template struct is_ref { enum {result = 1}; }; - template struct is_ref { enum {result = 0}; }; - - template - struct param_to_str { static std::string result() { static const std::string r("v"); return r; } }; - - template <> - struct param_to_str<0> { static std::string result() { static const std::string r("c"); return r; } }; - - #define exprtk_crtype(Type) \ - param_to_str::result>::result() \ - - template - struct T0oT1oT2process - { - typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; - - struct mode0 - { - static inline T process(const T& t0, const T& t1, const T& t2, const bfunc_t bf0, const bfunc_t bf1) + + template + static inline T process_1(const Sequence& arg_list) { - // (T0 o0 T1) o1 T2 - return bf1(bf0(t0,t1),t2); + return value(arg_list[0]); } - - template - static inline std::string id() + + template + static inline T process_2(const Sequence& arg_list) { - static const std::string result = "(" + exprtk_crtype(T0) + "o" + - exprtk_crtype(T1) + ")o(" + - exprtk_crtype(T2) + ")" ; - return result; + return std::max(value(arg_list[0]),value(arg_list[1])); } - }; - - struct mode1 - { - static inline T process(const T& t0, const T& t1, const T& t2, const bfunc_t bf0, const bfunc_t bf1) + + template + static inline T process_3(const Sequence& arg_list) { - // T0 o0 (T1 o1 T2) - return bf0(t0,bf1(t1,t2)); + return std::max(std::max(value(arg_list[0]),value(arg_list[1])),value(arg_list[2])); } - - template - static inline std::string id() + + template + static inline T process_4(const Sequence& arg_list) { - static const std::string result = "(" + exprtk_crtype(T0) + ")o(" + - exprtk_crtype(T1) + "o" + - exprtk_crtype(T2) + ")" ; - return result; + return std::max( + std::max(value(arg_list[0]),value(arg_list[1])), + std::max(value(arg_list[2]),value(arg_list[3]))); } - }; - }; - - template - struct T0oT1oT20T3process - { - typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; - - struct mode0 - { - static inline T process(const T& t0, const T& t1, - const T& t2, const T& t3, - const bfunc_t bf0, const bfunc_t bf1, const bfunc_t bf2) + + template + static inline T process_5(const Sequence& arg_list) { - // (T0 o0 T1) o1 (T2 o2 T3) - return bf1(bf0(t0,t1),bf2(t2,t3)); + return std::max( + std::max(std::max(value(arg_list[0]),value(arg_list[1])), + std::max(value(arg_list[2]),value(arg_list[3]))), + value(arg_list[4])); } - - template - static inline std::string id() - { - static const std::string result = "(" + exprtk_crtype(T0) + "o" + - exprtk_crtype(T1) + ")o" + - "(" + exprtk_crtype(T2) + "o" + - exprtk_crtype(T3) + ")" ; - return result; + }; + + template + struct vararg_mand_op : public opr_base + { + typedef typename opr_base::Type Type; + + template class Sequence> + static inline T process(const Sequence& arg_list) + { + switch (arg_list.size()) + { + case 1 : return process_1(arg_list); + case 2 : return process_2(arg_list); + case 3 : return process_3(arg_list); + case 4 : return process_4(arg_list); + case 5 : return process_5(arg_list); + default : + { + for (std::size_t i = 0; i < arg_list.size(); ++i) + { + if (std::equal_to()(T(0),value(arg_list[i]))) + return T(0); + } + + return T(1); + } + } + } + + template + static inline T process_1(const Sequence& arg_list) + { + return std::not_equal_to() + (T(0),value(arg_list[0])) ? T(1) : T(0); + } + + template + static inline T process_2(const Sequence& arg_list) + { + return ( + std::not_equal_to()(T(0),value(arg_list[0])) && + std::not_equal_to()(T(0),value(arg_list[1])) + ) ? T(1) : T(0); + } + + template + static inline T process_3(const Sequence& arg_list) + { + return ( + std::not_equal_to()(T(0),value(arg_list[0])) && + std::not_equal_to()(T(0),value(arg_list[1])) && + std::not_equal_to()(T(0),value(arg_list[2])) + ) ? T(1) : T(0); + } + + template + static inline T process_4(const Sequence& arg_list) + { + return ( + std::not_equal_to()(T(0),value(arg_list[0])) && + std::not_equal_to()(T(0),value(arg_list[1])) && + std::not_equal_to()(T(0),value(arg_list[2])) && + std::not_equal_to()(T(0),value(arg_list[3])) + ) ? T(1) : T(0); + } + + template + static inline T process_5(const Sequence& arg_list) + { + return ( + std::not_equal_to()(T(0),value(arg_list[0])) && + std::not_equal_to()(T(0),value(arg_list[1])) && + std::not_equal_to()(T(0),value(arg_list[2])) && + std::not_equal_to()(T(0),value(arg_list[3])) && + std::not_equal_to()(T(0),value(arg_list[4])) + ) ? T(1) : T(0); } - }; - - struct mode1 - { - static inline T process(const T& t0, const T& t1, - const T& t2, const T& t3, - const bfunc_t bf0, const bfunc_t bf1, const bfunc_t bf2) + }; + + template + struct vararg_mor_op : public opr_base + { + typedef typename opr_base::Type Type; + + template class Sequence> + static inline T process(const Sequence& arg_list) + { + switch (arg_list.size()) + { + case 1 : return process_1(arg_list); + case 2 : return process_2(arg_list); + case 3 : return process_3(arg_list); + case 4 : return process_4(arg_list); + case 5 : return process_5(arg_list); + default : + { + for (std::size_t i = 0; i < arg_list.size(); ++i) + { + if (std::not_equal_to()(T(0),value(arg_list[i]))) + return T(1); + } + + return T(0); + } + } + } + + template + static inline T process_1(const Sequence& arg_list) + { + return std::not_equal_to() + (T(0),value(arg_list[0])) ? T(1) : T(0); + } + + template + static inline T process_2(const Sequence& arg_list) + { + return ( + std::not_equal_to()(T(0),value(arg_list[0])) || + std::not_equal_to()(T(0),value(arg_list[1])) + ) ? T(1) : T(0); + } + + template + static inline T process_3(const Sequence& arg_list) + { + return ( + std::not_equal_to()(T(0),value(arg_list[0])) || + std::not_equal_to()(T(0),value(arg_list[1])) || + std::not_equal_to()(T(0),value(arg_list[2])) + ) ? T(1) : T(0); + } + + template + static inline T process_4(const Sequence& arg_list) + { + return ( + std::not_equal_to()(T(0),value(arg_list[0])) || + std::not_equal_to()(T(0),value(arg_list[1])) || + std::not_equal_to()(T(0),value(arg_list[2])) || + std::not_equal_to()(T(0),value(arg_list[3])) + ) ? T(1) : T(0); + } + + template + static inline T process_5(const Sequence& arg_list) + { + return ( + std::not_equal_to()(T(0),value(arg_list[0])) || + std::not_equal_to()(T(0),value(arg_list[1])) || + std::not_equal_to()(T(0),value(arg_list[2])) || + std::not_equal_to()(T(0),value(arg_list[3])) || + std::not_equal_to()(T(0),value(arg_list[4])) + ) ? T(1) : T(0); + } + }; + + template + struct vararg_multi_op : public opr_base + { + typedef typename opr_base::Type Type; + + template class Sequence> + static inline T process(const Sequence& arg_list) + { + switch (arg_list.size()) + { + case 0 : return std::numeric_limits::quiet_NaN(); + case 1 : return process_1(arg_list); + case 2 : return process_2(arg_list); + case 3 : return process_3(arg_list); + case 4 : return process_4(arg_list); + case 5 : return process_5(arg_list); + case 6 : return process_6(arg_list); + case 7 : return process_7(arg_list); + case 8 : return process_8(arg_list); + default : + { + for (std::size_t i = 0; i < (arg_list.size() - 1); ++i) + { + value(arg_list[i]); + } + + return value(arg_list.back()); + } + } + } + + template + static inline T process_1(const Sequence& arg_list) + { + return value(arg_list[0]); + } + + template + static inline T process_2(const Sequence& arg_list) + { + value(arg_list[0]); + return value(arg_list[1]); + } + + template + static inline T process_3(const Sequence& arg_list) + { + value(arg_list[0]); + value(arg_list[1]); + return value(arg_list[2]); + } + + template + static inline T process_4(const Sequence& arg_list) + { + value(arg_list[0]); + value(arg_list[1]); + value(arg_list[2]); + return value(arg_list[3]); + } + + template + static inline T process_5(const Sequence& arg_list) + { + value(arg_list[0]); + value(arg_list[1]); + value(arg_list[2]); + value(arg_list[3]); + return value(arg_list[4]); + } + + template + static inline T process_6(const Sequence& arg_list) + { + value(arg_list[0]); + value(arg_list[1]); + value(arg_list[2]); + value(arg_list[3]); + value(arg_list[4]); + return value(arg_list[5]); + } + + template + static inline T process_7(const Sequence& arg_list) + { + value(arg_list[0]); + value(arg_list[1]); + value(arg_list[2]); + value(arg_list[3]); + value(arg_list[4]); + value(arg_list[5]); + return value(arg_list[6]); + } + + template + static inline T process_8(const Sequence& arg_list) + { + value(arg_list[0]); + value(arg_list[1]); + value(arg_list[2]); + value(arg_list[3]); + value(arg_list[4]); + value(arg_list[5]); + value(arg_list[6]); + return value(arg_list[7]); + } + }; + + template + struct vec_add_op + { + typedef vector_interface* ivector_ptr; + + static inline T process(const ivector_ptr v) + { + const T* vec = v->vec()->vds().data(); + const std::size_t vec_size = v->vec()->vds().size(); + + loop_unroll::details lud(vec_size); + + if (vec_size <= static_cast(lud.batch_size)) + { + T result = T(0); + int i = 0; + + switch (vec_size) + { +#define case_stmt(N) \ +case N : result += vec[i++]; \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(16) case_stmt(15) + case_stmt(14) case_stmt(13) + case_stmt(12) case_stmt(11) + case_stmt(10) case_stmt( 9) + case_stmt( 8) case_stmt( 7) + case_stmt( 6) case_stmt( 5) +#endif + case_stmt( 4) case_stmt( 3) + case_stmt( 2) case_stmt( 1) + } + +#undef case_stmt + + return result; + } + + T r[] = { + T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), + T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0) + }; + + const T* upper_bound = vec + lud.upper_bound; + + while (vec < upper_bound) + { +#define exprtk_loop(N) \ +r[N] += vec[N]; \ + + exprtk_loop( 0) exprtk_loop( 1) + exprtk_loop( 2) exprtk_loop( 3) +#ifndef exprtk_disable_superscalar_unroll + exprtk_loop( 4) exprtk_loop( 5) + exprtk_loop( 6) exprtk_loop( 7) + exprtk_loop( 8) exprtk_loop( 9) + exprtk_loop(10) exprtk_loop(11) + exprtk_loop(12) exprtk_loop(13) + exprtk_loop(14) exprtk_loop(15) +#endif + + vec += lud.batch_size; + } + + int i = 0; + + switch (lud.remainder) + { +#define case_stmt(N) \ +case N : r[0] += vec[i++]; \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(15) case_stmt(14) + case_stmt(13) case_stmt(12) + case_stmt(11) case_stmt(10) + case_stmt( 9) case_stmt( 8) + case_stmt( 7) case_stmt( 6) + case_stmt( 5) case_stmt( 4) +#endif + case_stmt( 3) case_stmt( 2) + case_stmt( 1) + } + +#undef exprtk_loop +#undef case_stmt + + return (r[ 0] + r[ 1] + r[ 2] + r[ 3]) +#ifndef exprtk_disable_superscalar_unroll + + (r[ 4] + r[ 5] + r[ 6] + r[ 7]) + + (r[ 8] + r[ 9] + r[10] + r[11]) + + (r[12] + r[13] + r[14] + r[15]) +#endif + ; + } + }; + + template + struct vec_mul_op + { + typedef vector_interface* ivector_ptr; + + static inline T process(const ivector_ptr v) + { + const T* vec = v->vec()->vds().data(); + const std::size_t vec_size = v->vec()->vds().size(); + + loop_unroll::details lud(vec_size); + + if (vec_size <= static_cast(lud.batch_size)) + { + T result = T(1); + int i = 0; + + switch (vec_size) + { +#define case_stmt(N) \ +case N : result *= vec[i++]; \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(16) case_stmt(15) + case_stmt(14) case_stmt(13) + case_stmt(12) case_stmt(11) + case_stmt(10) case_stmt( 9) + case_stmt( 8) case_stmt( 7) + case_stmt( 6) case_stmt( 5) +#endif + case_stmt( 4) case_stmt( 3) + case_stmt( 2) case_stmt( 1) + } + +#undef case_stmt + + return result; + } + + T r[] = { + T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1), + T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1) + }; + + const T* upper_bound = vec + lud.upper_bound; + + while (vec < upper_bound) + { +#define exprtk_loop(N) \ +r[N] *= vec[N]; \ + + exprtk_loop( 0) exprtk_loop( 1) + exprtk_loop( 2) exprtk_loop( 3) +#ifndef exprtk_disable_superscalar_unroll + exprtk_loop( 4) exprtk_loop( 5) + exprtk_loop( 6) exprtk_loop( 7) + exprtk_loop( 8) exprtk_loop( 9) + exprtk_loop(10) exprtk_loop(11) + exprtk_loop(12) exprtk_loop(13) + exprtk_loop(14) exprtk_loop(15) +#endif + + vec += lud.batch_size; + } + + int i = 0; + + switch (lud.remainder) + { +#define case_stmt(N) \ +case N : r[0] *= vec[i++]; \ + +#ifndef exprtk_disable_superscalar_unroll + case_stmt(15) case_stmt(14) + case_stmt(13) case_stmt(12) + case_stmt(11) case_stmt(10) + case_stmt( 9) case_stmt( 8) + case_stmt( 7) case_stmt( 6) + case_stmt( 5) case_stmt( 4) +#endif + case_stmt( 3) case_stmt( 2) + case_stmt( 1) + } + +#undef exprtk_loop +#undef case_stmt + + return (r[ 0] * r[ 1] * r[ 2] * r[ 3]) +#ifndef exprtk_disable_superscalar_unroll + + (r[ 4] * r[ 5] * r[ 6] * r[ 7]) + + (r[ 8] * r[ 9] * r[10] * r[11]) + + (r[12] * r[13] * r[14] * r[15]) +#endif + ; + } + }; + + template + struct vec_avg_op + { + typedef vector_interface* ivector_ptr; + + static inline T process(const ivector_ptr v) + { + const std::size_t vec_size = v->vec()->vds().size(); + + return vec_add_op::process(v) / vec_size; + } + }; + + template + struct vec_min_op + { + typedef vector_interface* ivector_ptr; + + static inline T process(const ivector_ptr v) + { + const T* vec = v->vec()->vds().data(); + const std::size_t vec_size = v->vec()->vds().size(); + + T result = vec[0]; + + for (std::size_t i = 1; i < vec_size; ++i) + { + T v_i = vec[i]; + + if (v_i < result) + result = v_i; + } + + return result; + } + }; + + template + struct vec_max_op + { + typedef vector_interface* ivector_ptr; + + static inline T process(const ivector_ptr v) + { + const T* vec = v->vec()->vds().data(); + const std::size_t vec_size = v->vec()->vds().size(); + + T result = vec[0]; + + for (std::size_t i = 1; i < vec_size; ++i) + { + T v_i = vec[i]; + + if (v_i > result) + result = v_i; + } + + return result; + } + }; + + template + class vov_base_node : public expression_node + { + public: + + virtual ~vov_base_node() + {} + + inline virtual operator_type operation() const + { + return details::e_default; + } + + virtual const T& v0() const = 0; + + virtual const T& v1() const = 0; + }; + + template + class cov_base_node : public expression_node + { + public: + + virtual ~cov_base_node() + {} + + inline virtual operator_type operation() const + { + return details::e_default; + } + + virtual const T c() const = 0; + + virtual const T& v() const = 0; + }; + + template + class voc_base_node : public expression_node + { + public: + + virtual ~voc_base_node() + {} + + inline virtual operator_type operation() const + { + return details::e_default; + } + + virtual const T c() const = 0; + + virtual const T& v() const = 0; + }; + + template + class vob_base_node : public expression_node + { + public: + + virtual ~vob_base_node() + {} + + virtual const T& v() const = 0; + }; + + template + class bov_base_node : public expression_node + { + public: + + virtual ~bov_base_node() + {} + + virtual const T& v() const = 0; + }; + + template + class cob_base_node : public expression_node + { + public: + + virtual ~cob_base_node() + {} + + inline virtual operator_type operation() const + { + return details::e_default; + } + + virtual const T c() const = 0; + + virtual void set_c(const T) = 0; + + virtual expression_node* move_branch(const std::size_t& index) = 0; + }; + + template + class boc_base_node : public expression_node + { + public: + + virtual ~boc_base_node() + {} + + inline virtual operator_type operation() const + { + return details::e_default; + } + + virtual const T c() const = 0; + + virtual void set_c(const T) = 0; + + virtual expression_node* move_branch(const std::size_t& index) = 0; + }; + + template + class uv_base_node : public expression_node + { + public: + + virtual ~uv_base_node() + {} + + inline virtual operator_type operation() const + { + return details::e_default; + } + + virtual const T& v() const = 0; + }; + + template + class sos_base_node : public expression_node + { + public: + + virtual ~sos_base_node() + {} + + inline virtual operator_type operation() const + { + return details::e_default; + } + }; + + template + class sosos_base_node : public expression_node + { + public: + + virtual ~sosos_base_node() + {} + + inline virtual operator_type operation() const + { + return details::e_default; + } + }; + + template + class T0oT1oT2_base_node : public expression_node + { + public: + + virtual ~T0oT1oT2_base_node() + {} + + virtual std::string type_id() const = 0; + }; + + template + class T0oT1oT2oT3_base_node : public expression_node + { + public: + + virtual ~T0oT1oT2oT3_base_node() + {} + + virtual std::string type_id() const = 0; + }; + + template + class unary_variable_node : public uv_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef Operation operation_t; + + explicit unary_variable_node(const T& var) + : v_(var) + {} + + inline T value() const + { + return Operation::process(v_); + } + + inline typename expression_node::node_type type() const + { + return Operation::type(); + } + + inline operator_type operation() const + { + return Operation::operation(); + } + + inline const T& v() const + { + return v_; + } + + private: + + unary_variable_node(unary_variable_node&); + unary_variable_node& operator=(unary_variable_node&); + + const T& v_; + }; + + template + class uvouv_node : public expression_node + { + public: + + // UOpr1(v0) Op UOpr2(v1) + + typedef expression_node* expression_ptr; + typedef typename details::functor_t functor_t; + typedef typename functor_t::bfunc_t bfunc_t; + typedef typename functor_t::ufunc_t ufunc_t; + + explicit uvouv_node(const T& var0,const T& var1, + ufunc_t uf0, ufunc_t uf1, bfunc_t bf) + : v0_(var0), + v1_(var1), + u0_(uf0), + u1_(uf1), + f_ (bf) + {} + + inline T value() const + { + return f_(u0_(v0_),u1_(v1_)); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_uvouv; + } + + inline operator_type operation() const + { + return details::e_default; + } + + inline const T& v0() + { + return v0_; + } + + inline const T& v1() + { + return v1_; + } + + inline ufunc_t u0() + { + return u0_; + } + + inline ufunc_t u1() + { + return u1_; + } + + inline ufunc_t f() + { + return f_; + } + + private: + + uvouv_node(uvouv_node&); + uvouv_node& operator=(uvouv_node&); + + const T& v0_; + const T& v1_; + const ufunc_t u0_; + const ufunc_t u1_; + const bfunc_t f_; + }; + + template + class unary_branch_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef Operation operation_t; + + explicit unary_branch_node(expression_ptr brnch) + : branch_(brnch), + branch_deletable_(branch_deletable(branch_)) + {} + + ~unary_branch_node() + { + if (branch_ && branch_deletable_) + { + delete branch_; + branch_ = 0; + } + } + + inline T value() const + { + return Operation::process(branch_->value()); + } + + inline typename expression_node::node_type type() const + { + return Operation::type(); + } + + inline operator_type operation() const + { + return Operation::operation(); + } + + inline expression_node* branch(const std::size_t&) const + { + return branch_; + } + + inline void release() + { + branch_deletable_ = false; + } + + private: + + unary_branch_node(unary_branch_node&); + unary_branch_node& operator=(unary_branch_node&); + + expression_ptr branch_; + bool branch_deletable_; + }; + + template struct is_const { enum {result = 0}; }; + template struct is_const { enum {result = 1}; }; + template struct is_const_ref { enum {result = 0}; }; + template struct is_const_ref { enum {result = 1}; }; + template struct is_ref { enum {result = 0}; }; + template struct is_ref { enum {result = 1}; }; + template struct is_ref { enum {result = 0}; }; + + template + struct param_to_str { static std::string result() { static const std::string r("v"); return r; } }; + + template <> + struct param_to_str<0> { static std::string result() { static const std::string r("c"); return r; } }; + +#define exprtk_crtype(Type) \ +param_to_str::result>::result() \ + + template + struct T0oT1oT2process + { + typedef typename details::functor_t functor_t; + typedef typename functor_t::bfunc_t bfunc_t; + + struct mode0 + { + static inline T process(const T& t0, const T& t1, const T& t2, const bfunc_t bf0, const bfunc_t bf1) + { + // (T0 o0 T1) o1 T2 + return bf1(bf0(t0,t1),t2); + } + + template + static inline std::string id() + { + static const std::string result = "(" + exprtk_crtype(T0) + "o" + + exprtk_crtype(T1) + ")o(" + + exprtk_crtype(T2) + ")" ; + return result; + } + }; + + struct mode1 + { + static inline T process(const T& t0, const T& t1, const T& t2, const bfunc_t bf0, const bfunc_t bf1) + { + // T0 o0 (T1 o1 T2) + return bf0(t0,bf1(t1,t2)); + } + + template + static inline std::string id() + { + static const std::string result = "(" + exprtk_crtype(T0) + ")o(" + + exprtk_crtype(T1) + "o" + + exprtk_crtype(T2) + ")" ; + return result; + } + }; + }; + + template + struct T0oT1oT20T3process + { + typedef typename details::functor_t functor_t; + typedef typename functor_t::bfunc_t bfunc_t; + + struct mode0 + { + static inline T process(const T& t0, const T& t1, + const T& t2, const T& t3, + const bfunc_t bf0, const bfunc_t bf1, const bfunc_t bf2) + { + // (T0 o0 T1) o1 (T2 o2 T3) + return bf1(bf0(t0,t1),bf2(t2,t3)); + } + + template + static inline std::string id() + { + static const std::string result = "(" + exprtk_crtype(T0) + "o" + + exprtk_crtype(T1) + ")o" + + "(" + exprtk_crtype(T2) + "o" + + exprtk_crtype(T3) + ")" ; + return result; + } + }; + + struct mode1 + { + static inline T process(const T& t0, const T& t1, + const T& t2, const T& t3, + const bfunc_t bf0, const bfunc_t bf1, const bfunc_t bf2) + { + // (T0 o0 (T1 o1 (T2 o2 T3)) + return bf0(t0,bf1(t1,bf2(t2,t3))); + } + template + static inline std::string id() + { + static const std::string result = "(" + exprtk_crtype(T0) + ")o((" + + exprtk_crtype(T1) + ")o(" + + exprtk_crtype(T2) + "o" + + exprtk_crtype(T3) + "))" ; + return result; + } + }; + + struct mode2 + { + static inline T process(const T& t0, const T& t1, + const T& t2, const T& t3, + const bfunc_t bf0, const bfunc_t bf1, const bfunc_t bf2) + { + // (T0 o0 ((T1 o1 T2) o2 T3) + return bf0(t0,bf2(bf1(t1,t2),t3)); + } + + template + static inline std::string id() + { + static const std::string result = "(" + exprtk_crtype(T0) + ")o((" + + exprtk_crtype(T1) + "o" + + exprtk_crtype(T2) + ")o(" + + exprtk_crtype(T3) + "))" ; + return result; + } + }; + + struct mode3 + { + static inline T process(const T& t0, const T& t1, + const T& t2, const T& t3, + const bfunc_t bf0, const bfunc_t bf1, const bfunc_t bf2) + { + // (((T0 o0 T1) o1 T2) o2 T3) + return bf2(bf1(bf0(t0,t1),t2),t3); + } + + template + static inline std::string id() + { + static const std::string result = "((" + exprtk_crtype(T0) + "o" + + exprtk_crtype(T1) + ")o(" + + exprtk_crtype(T2) + "))o(" + + exprtk_crtype(T3) + ")"; + return result; + } + }; + + struct mode4 + { + static inline T process(const T& t0, const T& t1, + const T& t2, const T& t3, + const bfunc_t bf0, const bfunc_t bf1, const bfunc_t bf2) + { + // ((T0 o0 (T1 o1 T2)) o2 T3 + return bf2(bf0(t0,bf1(t1,t2)),t3); + } + + template + static inline std::string id() + { + static const std::string result = "((" + exprtk_crtype(T0) + ")o(" + + exprtk_crtype(T1) + "o" + + exprtk_crtype(T2) + "))o(" + + exprtk_crtype(T3) + ")" ; + return result; + } + }; + }; + +#undef exprtk_crtype + + template + struct nodetype_T0oT1 { static const typename expression_node::node_type result; }; + template + const typename expression_node::node_type nodetype_T0oT1::result = expression_node::e_none; + +#define synthesis_node_type_define(T0_,T1_,v_) \ +template \ +struct nodetype_T0oT1 { static const typename expression_node::node_type result; }; \ +template \ +const typename expression_node::node_type nodetype_T0oT1::result = expression_node:: v_; \ + + synthesis_node_type_define(const T0&,const T1&, e_vov) + synthesis_node_type_define(const T0&,const T1 , e_voc) + synthesis_node_type_define(const T0 ,const T1&, e_cov) + synthesis_node_type_define( T0&, T1&,e_none) + synthesis_node_type_define(const T0 ,const T1 ,e_none) + synthesis_node_type_define( T0&,const T1 ,e_none) + synthesis_node_type_define(const T0 , T1&,e_none) + synthesis_node_type_define(const T0&, T1&,e_none) + synthesis_node_type_define( T0&,const T1&,e_none) +#undef synthesis_node_type_define + + template + struct nodetype_T0oT1oT2 { static const typename expression_node::node_type result; }; + template + const typename expression_node::node_type nodetype_T0oT1oT2::result = expression_node::e_none; + +#define synthesis_node_type_define(T0_,T1_,T2_,v_) \ +template \ +struct nodetype_T0oT1oT2 { static const typename expression_node::node_type result; }; \ +template \ +const typename expression_node::node_type nodetype_T0oT1oT2::result = expression_node:: v_; \ + + synthesis_node_type_define(const T0&,const T1&,const T2&, e_vovov) + synthesis_node_type_define(const T0&,const T1&,const T2 , e_vovoc) + synthesis_node_type_define(const T0&,const T1 ,const T2&, e_vocov) + synthesis_node_type_define(const T0 ,const T1&,const T2&, e_covov) + synthesis_node_type_define(const T0 ,const T1&,const T2 , e_covoc) + synthesis_node_type_define(const T0 ,const T1 ,const T2 , e_none ) + synthesis_node_type_define(const T0 ,const T1 ,const T2&, e_none ) + synthesis_node_type_define(const T0&,const T1 ,const T2 , e_none ) + synthesis_node_type_define( T0&, T1&, T2&, e_none ) +#undef synthesis_node_type_define + + template + struct nodetype_T0oT1oT2oT3 { static const typename expression_node::node_type result; }; + template + const typename expression_node::node_type nodetype_T0oT1oT2oT3::result = expression_node::e_none; + +#define synthesis_node_type_define(T0_,T1_,T2_,T3_,v_) \ +template \ +struct nodetype_T0oT1oT2oT3 { static const typename expression_node::node_type result; }; \ +template \ +const typename expression_node::node_type nodetype_T0oT1oT2oT3::result = expression_node:: v_; \ + + synthesis_node_type_define(const T0&,const T1&,const T2&, const T3&,e_vovovov) + synthesis_node_type_define(const T0&,const T1&,const T2&, const T3 ,e_vovovoc) + synthesis_node_type_define(const T0&,const T1&,const T2 , const T3&,e_vovocov) + synthesis_node_type_define(const T0&,const T1 ,const T2&, const T3&,e_vocovov) + synthesis_node_type_define(const T0 ,const T1&,const T2&, const T3&,e_covovov) + synthesis_node_type_define(const T0 ,const T1&,const T2 , const T3&,e_covocov) + synthesis_node_type_define(const T0&,const T1 ,const T2&, const T3 ,e_vocovoc) + synthesis_node_type_define(const T0 ,const T1&,const T2&, const T3 ,e_covovoc) + synthesis_node_type_define(const T0&,const T1 ,const T2 , const T3&,e_vococov) + synthesis_node_type_define(const T0 ,const T1 ,const T2 , const T3 ,e_none ) + synthesis_node_type_define(const T0 ,const T1 ,const T2 , const T3&,e_none ) + synthesis_node_type_define(const T0 ,const T1 ,const T2&, const T3 ,e_none ) + synthesis_node_type_define(const T0 ,const T1&,const T2 , const T3 ,e_none ) + synthesis_node_type_define(const T0&,const T1 ,const T2 , const T3 ,e_none ) + synthesis_node_type_define(const T0 ,const T1 ,const T2&, const T3&,e_none ) + synthesis_node_type_define(const T0&,const T1&,const T2 , const T3 ,e_none ) +#undef synthesis_node_type_define + + template + class T0oT1 : public expression_node + { + public: + + typedef typename details::functor_t functor_t; + typedef typename functor_t::bfunc_t bfunc_t; + typedef T value_type; + typedef T0oT1 node_type; + + T0oT1(T0 p0, T1 p1, const bfunc_t p2) + : t0_(p0), + t1_(p1), + f_ (p2) + {} + + inline typename expression_node::node_type type() const + { + static const typename expression_node::node_type result = nodetype_T0oT1::result; + return result; + } + + inline operator_type operation() const + { + return e_default; + } + + inline T value() const + { + return f_(t0_,t1_); + } + + inline T0 t0() const + { + return t0_; + } + + inline T1 t1() const { - // (T0 o0 (T1 o1 (T2 o2 T3)) - return bf0(t0,bf1(t1,bf2(t2,t3))); + return t1_; } - template + + inline bfunc_t f() const + { + return f_; + } + + template + static inline expression_node* allocate(Allocator& allocator, + T0 p0, T1 p1, + bfunc_t p2) + { + return allocator.template allocate_type(p0,p1,p2); + } + + private: + + T0oT1(T0oT1&) {} + T0oT1& operator=(T0oT1&) { return *this; } + + T0 t0_; + T1 t1_; + const bfunc_t f_; + }; + + template + class T0oT1oT2 : public T0oT1oT2_base_node + { + public: + + typedef typename details::functor_t functor_t; + typedef typename functor_t::bfunc_t bfunc_t; + typedef T value_type; + typedef T0oT1oT2 node_type; + typedef ProcessMode process_mode_t; + + T0oT1oT2(T0 p0, T1 p1, T2 p2, const bfunc_t p3, const bfunc_t p4) + : t0_(p0), + t1_(p1), + t2_(p2), + f0_(p3), + f1_(p4) + {} + + inline typename expression_node::node_type type() const + { + static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; + return result; + } + + inline operator_type operation() const + { + return e_default; + } + + inline T value() const + { + return ProcessMode::process(t0_,t1_,t2_,f0_,f1_); + } + + inline T0 t0() const + { + return t0_; + } + + inline T1 t1() const + { + return t1_; + } + + inline T2 t2() const + { + return t2_; + } + + bfunc_t f0() const + { + return f0_; + } + + bfunc_t f1() const + { + return f1_; + } + + std::string type_id() const + { + return id(); + } + static inline std::string id() { - static const std::string result = "(" + exprtk_crtype(T0) + ")o((" + - exprtk_crtype(T1) + ")o(" + - exprtk_crtype(T2) + "o" + - exprtk_crtype(T3) + "))" ; - return result; + return process_mode_t::template id(); } - }; - - struct mode2 - { - static inline T process(const T& t0, const T& t1, - const T& t2, const T& t3, - const bfunc_t bf0, const bfunc_t bf1, const bfunc_t bf2) + + template + static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, bfunc_t p3, bfunc_t p4) + { + return allocator.template allocate_type(p0,p1,p2,p3,p4); + } + + private: + + T0oT1oT2(node_type&) {} + node_type& operator=(node_type&) { return *this; } + + T0 t0_; + T1 t1_; + T2 t2_; + const bfunc_t f0_; + const bfunc_t f1_; + }; + + template + class T0oT1oT2oT3 : public T0oT1oT2oT3_base_node + { + public: + + typedef typename details::functor_t functor_t; + typedef typename functor_t::bfunc_t bfunc_t; + typedef T value_type; + typedef T0_ T0; + typedef T1_ T1; + typedef T2_ T2; + typedef T3_ T3; + typedef T0oT1oT2oT3 node_type; + typedef ProcessMode process_mode_t; + + T0oT1oT2oT3(T0 p0, T1 p1, T2 p2, T3 p3, bfunc_t p4, bfunc_t p5, bfunc_t p6) + : t0_(p0), + t1_(p1), + t2_(p2), + t3_(p3), + f0_(p4), + f1_(p5), + f2_(p6) + {} + + inline T value() const { - // (T0 o0 ((T1 o1 T2) o2 T3) - return bf0(t0,bf2(bf1(t1,t2),t3)); + return ProcessMode::process(t0_,t1_,t2_,t3_,f0_,f1_,f2_); } - - template + + inline T0 t0() const + { + return t0_; + } + + inline T1 t1() const + { + return t1_; + } + + inline T2 t2() const + { + return t2_; + } + + inline T3 t3() const + { + return t3_; + } + + inline bfunc_t f0() const + { + return f0_; + } + + inline bfunc_t f1() const + { + return f1_; + } + + inline bfunc_t f2() const + { + return f2_; + } + + inline std::string type_id() const + { + return id(); + } + static inline std::string id() { - static const std::string result = "(" + exprtk_crtype(T0) + ")o((" + - exprtk_crtype(T1) + "o" + - exprtk_crtype(T2) + ")o(" + - exprtk_crtype(T3) + "))" ; - return result; + return process_mode_t::template id(); } - }; - - struct mode3 - { - static inline T process(const T& t0, const T& t1, - const T& t2, const T& t3, - const bfunc_t bf0, const bfunc_t bf1, const bfunc_t bf2) + + template + static inline expression_node* allocate(Allocator& allocator, + T0 p0, T1 p1, T2 p2, T3 p3, + bfunc_t p4, bfunc_t p5, bfunc_t p6) + { + return allocator.template allocate_type(p0,p1,p2,p3,p4,p5,p6); + } + + private: + + T0oT1oT2oT3(node_type&) {} + node_type& operator=(node_type&) { return *this; } + + T0 t0_; + T1 t1_; + T2 t2_; + T3 t3_; + const bfunc_t f0_; + const bfunc_t f1_; + const bfunc_t f2_; + }; + + template + class T0oT1oT2_sf3 : public T0oT1oT2_base_node + { + public: + + typedef typename details::functor_t functor_t; + typedef typename functor_t::tfunc_t tfunc_t; + typedef T value_type; + typedef T0oT1oT2_sf3 node_type; + + T0oT1oT2_sf3(T0 p0, T1 p1, T2 p2, const tfunc_t p3) + : t0_(p0), + t1_(p1), + t2_(p2), + f_ (p3) + {} + + inline typename expression_node::node_type type() const { - // (((T0 o0 T1) o1 T2) o2 T3) - return bf2(bf1(bf0(t0,t1),t2),t3); + static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; + return result; } - - template + + inline operator_type operation() const + { + return e_default; + } + + inline T value() const + { + return f_(t0_,t1_,t2_); + } + + inline T0 t0() const + { + return t0_; + } + + inline T1 t1() const + { + return t1_; + } + + inline T2 t2() const + { + return t2_; + } + + tfunc_t f() const + { + return f_; + } + + std::string type_id() const + { + return id(); + } + static inline std::string id() { - static const std::string result = "((" + exprtk_crtype(T0) + "o" + - exprtk_crtype(T1) + ")o(" + - exprtk_crtype(T2) + "))o(" + - exprtk_crtype(T3) + ")"; - return result; + return "sf3"; } - }; - - struct mode4 - { - static inline T process(const T& t0, const T& t1, - const T& t2, const T& t3, - const bfunc_t bf0, const bfunc_t bf1, const bfunc_t bf2) + + template + static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, tfunc_t p3) + { + return allocator.template allocate_type(p0,p1,p2,p3); + } + + private: + + T0oT1oT2_sf3(node_type&) {} + node_type& operator=(node_type&) { return *this; } + + T0 t0_; + T1 t1_; + T2 t2_; + const tfunc_t f_; + }; + + template + class sf3ext_type_node : public T0oT1oT2_base_node + { + public: + + virtual ~sf3ext_type_node() + {} + + virtual T0 t0() const = 0; + + virtual T1 t1() const = 0; + + virtual T2 t2() const = 0; + }; + + template + class T0oT1oT2_sf3ext : public sf3ext_type_node + { + public: + + typedef typename details::functor_t functor_t; + typedef typename functor_t::tfunc_t tfunc_t; + typedef T value_type; + typedef T0oT1oT2_sf3ext node_type; + + T0oT1oT2_sf3ext(T0 p0, T1 p1, T2 p2) + : t0_(p0), + t1_(p1), + t2_(p2) + {} + + inline typename expression_node::node_type type() const { - // ((T0 o0 (T1 o1 T2)) o2 T3 - return bf2(bf0(t0,bf1(t1,t2)),t3); + static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; + return result; } - - template + + inline operator_type operation() const + { + return e_default; + } + + inline T value() const + { + return SF3Operation::process(t0_,t1_,t2_); + } + + T0 t0() const + { + return t0_; + } + + T1 t1() const + { + return t1_; + } + + T2 t2() const + { + return t2_; + } + + std::string type_id() const + { + return id(); + } + static inline std::string id() { - static const std::string result = "((" + exprtk_crtype(T0) + ")o(" + - exprtk_crtype(T1) + "o" + - exprtk_crtype(T2) + "))o(" + - exprtk_crtype(T3) + ")" ; - return result; + return SF3Operation::id(); } - }; - }; - - #undef exprtk_crtype - - template - struct nodetype_T0oT1 { static const typename expression_node::node_type result; }; - template - const typename expression_node::node_type nodetype_T0oT1::result = expression_node::e_none; - - #define synthesis_node_type_define(T0_,T1_,v_) \ - template \ - struct nodetype_T0oT1 { static const typename expression_node::node_type result; }; \ - template \ - const typename expression_node::node_type nodetype_T0oT1::result = expression_node:: v_; \ - - synthesis_node_type_define(const T0&,const T1&, e_vov) - synthesis_node_type_define(const T0&,const T1 , e_voc) - synthesis_node_type_define(const T0 ,const T1&, e_cov) - synthesis_node_type_define( T0&, T1&,e_none) - synthesis_node_type_define(const T0 ,const T1 ,e_none) - synthesis_node_type_define( T0&,const T1 ,e_none) - synthesis_node_type_define(const T0 , T1&,e_none) - synthesis_node_type_define(const T0&, T1&,e_none) - synthesis_node_type_define( T0&,const T1&,e_none) - #undef synthesis_node_type_define - - template - struct nodetype_T0oT1oT2 { static const typename expression_node::node_type result; }; - template - const typename expression_node::node_type nodetype_T0oT1oT2::result = expression_node::e_none; - - #define synthesis_node_type_define(T0_,T1_,T2_,v_) \ - template \ - struct nodetype_T0oT1oT2 { static const typename expression_node::node_type result; }; \ - template \ - const typename expression_node::node_type nodetype_T0oT1oT2::result = expression_node:: v_; \ - - synthesis_node_type_define(const T0&,const T1&,const T2&, e_vovov) - synthesis_node_type_define(const T0&,const T1&,const T2 , e_vovoc) - synthesis_node_type_define(const T0&,const T1 ,const T2&, e_vocov) - synthesis_node_type_define(const T0 ,const T1&,const T2&, e_covov) - synthesis_node_type_define(const T0 ,const T1&,const T2 , e_covoc) - synthesis_node_type_define(const T0 ,const T1 ,const T2 , e_none ) - synthesis_node_type_define(const T0 ,const T1 ,const T2&, e_none ) - synthesis_node_type_define(const T0&,const T1 ,const T2 , e_none ) - synthesis_node_type_define( T0&, T1&, T2&, e_none ) - #undef synthesis_node_type_define - - template - struct nodetype_T0oT1oT2oT3 { static const typename expression_node::node_type result; }; - template - const typename expression_node::node_type nodetype_T0oT1oT2oT3::result = expression_node::e_none; - - #define synthesis_node_type_define(T0_,T1_,T2_,T3_,v_) \ - template \ - struct nodetype_T0oT1oT2oT3 { static const typename expression_node::node_type result; }; \ - template \ - const typename expression_node::node_type nodetype_T0oT1oT2oT3::result = expression_node:: v_; \ - - synthesis_node_type_define(const T0&,const T1&,const T2&, const T3&,e_vovovov) - synthesis_node_type_define(const T0&,const T1&,const T2&, const T3 ,e_vovovoc) - synthesis_node_type_define(const T0&,const T1&,const T2 , const T3&,e_vovocov) - synthesis_node_type_define(const T0&,const T1 ,const T2&, const T3&,e_vocovov) - synthesis_node_type_define(const T0 ,const T1&,const T2&, const T3&,e_covovov) - synthesis_node_type_define(const T0 ,const T1&,const T2 , const T3&,e_covocov) - synthesis_node_type_define(const T0&,const T1 ,const T2&, const T3 ,e_vocovoc) - synthesis_node_type_define(const T0 ,const T1&,const T2&, const T3 ,e_covovoc) - synthesis_node_type_define(const T0&,const T1 ,const T2 , const T3&,e_vococov) - synthesis_node_type_define(const T0 ,const T1 ,const T2 , const T3 ,e_none ) - synthesis_node_type_define(const T0 ,const T1 ,const T2 , const T3&,e_none ) - synthesis_node_type_define(const T0 ,const T1 ,const T2&, const T3 ,e_none ) - synthesis_node_type_define(const T0 ,const T1&,const T2 , const T3 ,e_none ) - synthesis_node_type_define(const T0&,const T1 ,const T2 , const T3 ,e_none ) - synthesis_node_type_define(const T0 ,const T1 ,const T2&, const T3&,e_none ) - synthesis_node_type_define(const T0&,const T1&,const T2 , const T3 ,e_none ) - #undef synthesis_node_type_define - - template - class T0oT1 : public expression_node - { - public: - - typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; - typedef T value_type; - typedef T0oT1 node_type; - - T0oT1(T0 p0, T1 p1, const bfunc_t p2) - : t0_(p0), - t1_(p1), - f_ (p2) - {} - - inline typename expression_node::node_type type() const - { - static const typename expression_node::node_type result = nodetype_T0oT1::result; - return result; - } - - inline operator_type operation() const - { - return e_default; - } - - inline T value() const - { - return f_(t0_,t1_); - } - - inline T0 t0() const - { - return t0_; - } - - inline T1 t1() const - { - return t1_; - } - - inline bfunc_t f() const - { - return f_; - } - - template - static inline expression_node* allocate(Allocator& allocator, - T0 p0, T1 p1, - bfunc_t p2) - { - return allocator.template allocate_type(p0,p1,p2); - } - - private: - - T0oT1(T0oT1&) {} - T0oT1& operator=(T0oT1&) { return *this; } - - T0 t0_; - T1 t1_; - const bfunc_t f_; - }; - - template - class T0oT1oT2 : public T0oT1oT2_base_node - { - public: - - typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; - typedef T value_type; - typedef T0oT1oT2 node_type; - typedef ProcessMode process_mode_t; - - T0oT1oT2(T0 p0, T1 p1, T2 p2, const bfunc_t p3, const bfunc_t p4) - : t0_(p0), - t1_(p1), - t2_(p2), - f0_(p3), - f1_(p4) - {} - - inline typename expression_node::node_type type() const - { - static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; - return result; - } - - inline operator_type operation() const - { - return e_default; - } - - inline T value() const - { - return ProcessMode::process(t0_,t1_,t2_,f0_,f1_); - } - - inline T0 t0() const - { - return t0_; - } - - inline T1 t1() const - { - return t1_; - } - - inline T2 t2() const - { - return t2_; - } - - bfunc_t f0() const - { - return f0_; - } - - bfunc_t f1() const - { - return f1_; - } - - std::string type_id() const - { - return id(); - } - - static inline std::string id() - { - return process_mode_t::template id(); - } - - template - static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, bfunc_t p3, bfunc_t p4) - { - return allocator.template allocate_type(p0,p1,p2,p3,p4); - } - - private: - - T0oT1oT2(node_type&) {} - node_type& operator=(node_type&) { return *this; } - - T0 t0_; - T1 t1_; - T2 t2_; - const bfunc_t f0_; - const bfunc_t f1_; - }; - - template - class T0oT1oT2oT3 : public T0oT1oT2oT3_base_node - { - public: - - typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; - typedef T value_type; - typedef T0_ T0; - typedef T1_ T1; - typedef T2_ T2; - typedef T3_ T3; - typedef T0oT1oT2oT3 node_type; - typedef ProcessMode process_mode_t; - - T0oT1oT2oT3(T0 p0, T1 p1, T2 p2, T3 p3, bfunc_t p4, bfunc_t p5, bfunc_t p6) - : t0_(p0), - t1_(p1), - t2_(p2), - t3_(p3), - f0_(p4), - f1_(p5), - f2_(p6) - {} - - inline T value() const - { - return ProcessMode::process(t0_,t1_,t2_,t3_,f0_,f1_,f2_); - } - - inline T0 t0() const - { - return t0_; - } - - inline T1 t1() const - { - return t1_; - } - - inline T2 t2() const - { - return t2_; - } - - inline T3 t3() const - { - return t3_; - } - - inline bfunc_t f0() const - { - return f0_; - } - - inline bfunc_t f1() const - { - return f1_; - } - - inline bfunc_t f2() const - { - return f2_; - } - - inline std::string type_id() const - { - return id(); - } - - static inline std::string id() - { - return process_mode_t::template id(); - } - - template - static inline expression_node* allocate(Allocator& allocator, - T0 p0, T1 p1, T2 p2, T3 p3, - bfunc_t p4, bfunc_t p5, bfunc_t p6) - { - return allocator.template allocate_type(p0,p1,p2,p3,p4,p5,p6); - } - - private: - - T0oT1oT2oT3(node_type&) {} - node_type& operator=(node_type&) { return *this; } - - T0 t0_; - T1 t1_; - T2 t2_; - T3 t3_; - const bfunc_t f0_; - const bfunc_t f1_; - const bfunc_t f2_; - }; - - template - class T0oT1oT2_sf3 : public T0oT1oT2_base_node - { - public: - - typedef typename details::functor_t functor_t; - typedef typename functor_t::tfunc_t tfunc_t; - typedef T value_type; - typedef T0oT1oT2_sf3 node_type; - - T0oT1oT2_sf3(T0 p0, T1 p1, T2 p2, const tfunc_t p3) - : t0_(p0), - t1_(p1), - t2_(p2), - f_ (p3) - {} - - inline typename expression_node::node_type type() const - { - static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; - return result; - } - - inline operator_type operation() const - { - return e_default; - } - - inline T value() const - { - return f_(t0_,t1_,t2_); - } - - inline T0 t0() const - { - return t0_; - } - - inline T1 t1() const - { - return t1_; - } - - inline T2 t2() const - { - return t2_; - } - - tfunc_t f() const - { - return f_; - } - - std::string type_id() const - { - return id(); - } - - static inline std::string id() - { - return "sf3"; - } - - template - static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, tfunc_t p3) - { - return allocator.template allocate_type(p0,p1,p2,p3); - } - - private: - - T0oT1oT2_sf3(node_type&) {} - node_type& operator=(node_type&) { return *this; } - - T0 t0_; - T1 t1_; - T2 t2_; - const tfunc_t f_; - }; - - template - class sf3ext_type_node : public T0oT1oT2_base_node - { - public: - - virtual T0 t0() const = 0; - - virtual T1 t1() const = 0; - - virtual T2 t2() const = 0; - }; - - template - class T0oT1oT2_sf3ext : public sf3ext_type_node - { - public: - - typedef typename details::functor_t functor_t; - typedef typename functor_t::tfunc_t tfunc_t; - typedef T value_type; - typedef T0oT1oT2_sf3ext node_type; - - T0oT1oT2_sf3ext(T0 p0, T1 p1, T2 p2) - : t0_(p0), - t1_(p1), - t2_(p2) - {} - - inline typename expression_node::node_type type() const - { - static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; - return result; - } - - inline operator_type operation() const - { - return e_default; - } - - inline T value() const - { - return SF3Operation::process(t0_,t1_,t2_); - } - - T0 t0() const - { - return t0_; - } - - T1 t1() const - { - return t1_; - } - - T2 t2() const - { - return t2_; - } - - std::string type_id() const - { - return id(); - } - - static inline std::string id() - { - return SF3Operation::id(); - } - - template - static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2) - { - return allocator.template allocate_type(p0,p1,p2); - } - - private: - - T0oT1oT2_sf3ext(node_type&) {} - node_type& operator=(node_type&) { return *this; } - - T0 t0_; - T1 t1_; - T2 t2_; - }; - - template - inline bool is_sf3ext_node(const expression_node* n) - { - switch (n->type()) - { - case expression_node::e_vovov : return true; - case expression_node::e_vovoc : return true; - case expression_node::e_vocov : return true; - case expression_node::e_covov : return true; - case expression_node::e_covoc : return true; - default : return false; - } - } - - template - class T0oT1oT2oT3_sf4 : public T0oT1oT2_base_node - { - public: - - typedef typename details::functor_t functor_t; - typedef typename functor_t::qfunc_t qfunc_t; - typedef T value_type; - typedef T0oT1oT2oT3_sf4 node_type; - - T0oT1oT2oT3_sf4(T0 p0, T1 p1, T2 p2, T3 p3, const qfunc_t p4) - : t0_(p0), - t1_(p1), - t2_(p2), - t3_(p3), - f_ (p4) - {} - - inline typename expression_node::node_type type() const - { - static const typename expression_node::node_type result = nodetype_T0oT1oT2oT3::result; - return result; - } - - inline operator_type operation() const - { - return e_default; - } - - inline T value() const - { - return f_(t0_,t1_,t2_,t3_); - } - - inline T0 t0() const - { - return t0_; - } - - inline T1 t1() const - { - return t1_; - } - - inline T2 t2() const - { - return t2_; - } - - inline T3 t3() const - { - return t3_; - } - - qfunc_t f() const - { - return f_; - } - - std::string type_id() const - { - return id(); - } - - static inline std::string id() - { - return "sf4"; - } - - template - static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, T3 p3, qfunc_t p4) - { - return allocator.template allocate_type(p0,p1,p2,p3,p4); - } - - private: - - T0oT1oT2oT3_sf4(node_type&) {} - node_type& operator=(node_type&) { return *this; } - - T0 t0_; - T1 t1_; - T2 t2_; - T3 t3_; - const qfunc_t f_; - }; - - template - class T0oT1oT2oT3_sf4ext : public T0oT1oT2oT3_base_node - { - public: - - typedef typename details::functor_t functor_t; - typedef typename functor_t::tfunc_t tfunc_t; - typedef T value_type; - typedef T0oT1oT2oT3_sf4ext node_type; - - T0oT1oT2oT3_sf4ext(T0 p0, T1 p1, T2 p2, T3 p3) - : t0_(p0), - t1_(p1), - t2_(p2), - t3_(p3) - {} - - inline typename expression_node::node_type type() const - { - static const typename expression_node::node_type result = nodetype_T0oT1oT2oT3::result; - return result; - } - - inline operator_type operation() const - { - return e_default; - } - - inline T value() const - { - return SF4Operation::process(t0_,t1_,t2_,t3_); - } - - inline T0 t0() const - { - return t0_; - } - - inline T1 t1() const - { - return t1_; - } - - inline T2 t2() const - { - return t2_; - } - - inline T3 t3() const - { - return t2_; - } - - std::string type_id() const - { - return id(); - } - - static inline std::string id() - { - return SF4Operation::id(); - } - - template - static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, T3 p3) - { - return allocator.template allocate_type(p0,p1,p2,p3); - } - - private: - - T0oT1oT2oT3_sf4ext(node_type&) {} - node_type& operator=(node_type&) { return *this; } - - T0 t0_; - T1 t1_; - T2 t2_; - T3 t3_; - }; - - template - inline bool is_sf4ext_node(const expression_node* n) - { - switch (n->type()) - { - case expression_node::e_vovovov : return true; - case expression_node::e_vovovoc : return true; - case expression_node::e_vovocov : return true; - case expression_node::e_vocovov : return true; - case expression_node::e_covovov : return true; - case expression_node::e_covocov : return true; - case expression_node::e_vocovoc : return true; - case expression_node::e_covovoc : return true; - case expression_node::e_vococov : return true; - default : return false; - } - } - - template - struct T0oT1_define - { - typedef details::T0oT1 type0; - }; - - template - struct T0oT1oT2_define - { - typedef details::T0oT1oT2::mode0> type0; - typedef details::T0oT1oT2::mode1> type1; - typedef details::T0oT1oT2_sf3 sf3_type; - typedef details::sf3ext_type_node sf3_type_node; - }; - - template - struct T0oT1oT2oT3_define - { - typedef details::T0oT1oT2oT3::mode0> type0; - typedef details::T0oT1oT2oT3::mode1> type1; - typedef details::T0oT1oT2oT3::mode2> type2; - typedef details::T0oT1oT2oT3::mode3> type3; - typedef details::T0oT1oT2oT3::mode4> type4; - typedef details::T0oT1oT2oT3_sf4 sf4_type; - }; - - template - class vov_node : public vov_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef Operation operation_t; - - // variable op variable node - explicit vov_node(const T& var0, const T& var1) - : v0_(var0), - v1_(var1) - {} - - inline T value() const - { - return Operation::process(v0_,v1_); - } - - inline typename expression_node::node_type type() const - { - return Operation::type(); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T& v0() const - { - return v0_; - } - - inline const T& v1() const - { - return v1_; - } - - protected: - - const T& v0_; - const T& v1_; - - private: - - vov_node(vov_node&); - vov_node& operator=(vov_node&); - }; - - template - class cov_node : public cov_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef Operation operation_t; - - // constant op variable node - explicit cov_node(const T& const_var, const T& var) - : c_(const_var), - v_(var) - {} - - inline T value() const - { - return Operation::process(c_,v_); - } - - inline typename expression_node::node_type type() const - { - return Operation::type(); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T c() const - { - return c_; - } - - inline const T& v() const - { - return v_; - } - - protected: - - const T c_; - const T& v_; - - private: - - cov_node(const cov_node&); - cov_node& operator=(const cov_node&); - }; - - template - class voc_node : public voc_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef Operation operation_t; - - // variable op constant node - explicit voc_node(const T& var, const T& const_var) - : v_(var), - c_(const_var) - {} - - inline T value() const - { - return Operation::process(v_,c_); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T c() const - { - return c_; - } - - inline const T& v() const - { - return v_; - } - - protected: - - const T& v_; - const T c_; - - private: - - voc_node(const voc_node&); - voc_node& operator=(const voc_node&); - }; - - template - class vob_node : public vob_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef std::pair branch_t; - typedef Operation operation_t; - - // variable op constant node - explicit vob_node(const T& var, const expression_ptr brnch) - : v_(var) - { - init_branches<1>(branch_,brnch); - } - - ~vob_node() - { - cleanup_branches::execute(branch_); - } - - inline T value() const - { - return Operation::process(v_,branch_[0].first->value()); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T& v() const - { - return v_; - } - - inline expression_node* branch(const std::size_t&) const - { - return branch_[0].first; - } - - private: - - vob_node(const vob_node&); - vob_node& operator=(const vob_node&); - - const T& v_; - branch_t branch_[1]; - }; - - template - class bov_node : public bov_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef std::pair branch_t; - typedef Operation operation_t; - - // variable op constant node - explicit bov_node(const expression_ptr brnch, const T& var) - : v_(var) - { - init_branches<1>(branch_,brnch); - } - - ~bov_node() - { - cleanup_branches::execute(branch_); - } - - inline T value() const - { - return Operation::process(branch_[0].first->value(),v_); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T& v() const - { - return v_; - } - - inline expression_node* branch(const std::size_t&) const - { - return branch_[0].first; - } - - private: - - bov_node(const bov_node&); - bov_node& operator=(const bov_node&); - - const T& v_; - branch_t branch_[1]; - }; - - template - class cob_node : public cob_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef std::pair branch_t; - typedef Operation operation_t; - - // variable op constant node - explicit cob_node(const T const_var, const expression_ptr brnch) - : c_(const_var) - { - init_branches<1>(branch_,brnch); - } - - ~cob_node() - { - cleanup_branches::execute(branch_); - } - - inline T value() const - { - return Operation::process(c_,branch_[0].first->value()); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T c() const - { - return c_; - } - - inline void set_c(const T new_c) - { - (*const_cast(&c_)) = new_c; - } - - inline expression_node* branch(const std::size_t&) const - { - return branch_[0].first; - } - - inline expression_node* move_branch(const std::size_t&) - { - branch_[0].second = false; - return branch_[0].first; - } - - private: - - cob_node(const cob_node&); - cob_node& operator=(const cob_node&); - - const T c_; - branch_t branch_[1]; - }; - - template - class boc_node : public boc_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef std::pair branch_t; - typedef Operation operation_t; - - // variable op constant node - explicit boc_node(const expression_ptr brnch, const T const_var) - : c_(const_var) - { - init_branches<1>(branch_,brnch); - } - - ~boc_node() - { - cleanup_branches::execute(branch_); - } - - inline T value() const - { - return Operation::process(branch_[0].first->value(),c_); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T c() const - { - return c_; - } - - inline void set_c(const T new_c) - { - (*const_cast(&c_)) = new_c; - } - - inline expression_node* branch(const std::size_t&) const - { - return branch_[0].first; - } - - inline expression_node* move_branch(const std::size_t&) - { - branch_[0].second = false; - return branch_[0].first; - } - - private: - - boc_node(const boc_node&); - boc_node& operator=(const boc_node&); - - const T c_; - branch_t branch_[1]; - }; - - #ifndef exprtk_disable_string_capabilities - template - class sos_node : public sos_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef Operation operation_t; - - // string op string node - explicit sos_node(SType0 p0, SType1 p1) - : s0_(p0), - s1_(p1) - {} - - inline T value() const - { - return Operation::process(s0_,s1_); - } - - inline typename expression_node::node_type type() const - { - return Operation::type(); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline std::string& s0() - { - return s0_; - } - - inline std::string& s1() - { - return s1_; - } - - protected: - - SType0 s0_; - SType1 s1_; - - private: - - sos_node(sos_node&); - sos_node& operator=(sos_node&); - }; - - template - class str_xrox_node : public sos_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef Operation operation_t; - - // string-range op string node - explicit str_xrox_node(SType0 p0, SType1 p1, RangePack rp0) - : s0_(p0), - s1_(p1), - rp0_(rp0) - {} - - ~str_xrox_node() - { - rp0_.free(); - } - - inline T value() const - { - std::size_t r0 = 0; - std::size_t r1 = 0; - - if (rp0_(r0,r1,s0_.size())) - return Operation::process(s0_.substr(r0,(r1 - r0) + 1),s1_); - else - return T(0); - } - - inline typename expression_node::node_type type() const - { - return Operation::type(); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline std::string& s0() - { - return s0_; - } - - inline std::string& s1() - { - return s1_; - } - - protected: - - SType0 s0_; - SType1 s1_; - RangePack rp0_; - - private: - - str_xrox_node(str_xrox_node&); - str_xrox_node& operator=(str_xrox_node&); - }; - - template - class str_xoxr_node : public sos_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef Operation operation_t; - - // string op string range node - explicit str_xoxr_node(SType0 p0, SType1 p1, RangePack rp1) - : s0_ (p0 ), - s1_ (p1 ), - rp1_(rp1) - {} - - ~str_xoxr_node() - { - rp1_.free(); - } - - inline T value() const - { - std::size_t r0 = 0; - std::size_t r1 = 0; - - if (rp1_(r0,r1,s1_.size())) - return Operation::process(s0_,s1_.substr(r0,(r1 - r0) + 1)); - else - return T(0); - } - - inline typename expression_node::node_type type() const - { - return Operation::type(); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline std::string& s0() - { - return s0_; - } - - inline std::string& s1() - { - return s1_; - } - - protected: - - SType0 s0_; - SType1 s1_; - RangePack rp1_; - - private: - - str_xoxr_node(str_xoxr_node&); - str_xoxr_node& operator=(str_xoxr_node&); - }; - - template - class str_xroxr_node : public sos_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef Operation operation_t; - - // string-range op string-range node - explicit str_xroxr_node(SType0 p0, SType1 p1, RangePack rp0, RangePack rp1) - : s0_ (p0 ), - s1_ (p1 ), - rp0_(rp0), - rp1_(rp1) - {} - - ~str_xroxr_node() - { - rp0_.free(); - rp1_.free(); - } - - inline T value() const - { - std::size_t r0_0 = 0; - std::size_t r0_1 = 0; - std::size_t r1_0 = 0; - std::size_t r1_1 = 0; - if ( - rp0_(r0_0,r1_0,s0_.size()) && - rp1_(r0_1,r1_1,s1_.size()) - ) + + template + static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2) + { + return allocator.template allocate_type(p0,p1,p2); + } + + private: + + T0oT1oT2_sf3ext(node_type&) {} + node_type& operator=(node_type&) { return *this; } + + T0 t0_; + T1 t1_; + T2 t2_; + }; + + template + inline bool is_sf3ext_node(const expression_node* n) + { + switch (n->type()) + { + case expression_node::e_vovov : return true; + case expression_node::e_vovoc : return true; + case expression_node::e_vocov : return true; + case expression_node::e_covov : return true; + case expression_node::e_covoc : return true; + default : return false; + } + } + + template + class T0oT1oT2oT3_sf4 : public T0oT1oT2_base_node + { + public: + + typedef typename details::functor_t functor_t; + typedef typename functor_t::qfunc_t qfunc_t; + typedef T value_type; + typedef T0oT1oT2oT3_sf4 node_type; + + T0oT1oT2oT3_sf4(T0 p0, T1 p1, T2 p2, T3 p3, const qfunc_t p4) + : t0_(p0), + t1_(p1), + t2_(p2), + t3_(p3), + f_ (p4) + {} + + inline typename expression_node::node_type type() const { - return Operation::process( - s0_.substr(r0_0,(r1_0 - r0_0) + 1), - s1_.substr(r0_1,(r1_1 - r0_1) + 1) - ); + static const typename expression_node::node_type result = nodetype_T0oT1oT2oT3::result; + return result; } - else - return T(0); - } - - inline typename expression_node::node_type type() const - { - return Operation::type(); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline std::string& s0() - { - return s0_; - } - - inline std::string& s1() - { - return s1_; - } - - protected: - - SType0 s0_; - SType1 s1_; - RangePack rp0_; - RangePack rp1_; - - private: - - str_xroxr_node(str_xroxr_node&); - str_xroxr_node& operator=(str_xroxr_node&); - }; - - template - class str_sogens_node : public binary_node - { - public: - - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; - - str_sogens_node(const operator_type& opr, - expression_ptr branch0, - expression_ptr branch1) - : binary_node(opr,branch0,branch1), - str0_base_ptr_ (0), - str1_base_ptr_ (0), - str0_range_ptr_(0), - str1_range_ptr_(0) - { - if (is_generally_string_node(binary_node::branch_[0].first)) - { - str0_base_ptr_ = dynamic_cast(binary_node::branch_[0].first); - - if (0 == str0_base_ptr_) - return; - - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[0].first); - - if (0 == range_ptr) - return; - - str0_range_ptr_ = &(range_ptr->range_ref()); + + inline operator_type operation() const + { + return e_default; } - - if (is_generally_string_node(binary_node::branch_[1].first)) + + inline T value() const { - str1_base_ptr_ = dynamic_cast(binary_node::branch_[1].first); - - if (0 == str1_base_ptr_) - return; - - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[1].first); - - if (0 == range_ptr) - return; - - str1_range_ptr_ = &(range_ptr->range_ref()); + return f_(t0_,t1_,t2_,t3_); } - } - - inline T value() const - { - if ( - str0_base_ptr_ && - str1_base_ptr_ && - str0_range_ptr_ && - str1_range_ptr_ - ) - { - binary_node::branch_[0].first->value(); - binary_node::branch_[1].first->value(); - - std::size_t str0_r0 = 0; - std::size_t str0_r1 = 0; - - std::size_t str1_r0 = 0; - std::size_t str1_r1 = 0; - - range_t& range0 = (*str0_range_ptr_); - range_t& range1 = (*str1_range_ptr_); - - if ( - range0(str0_r0,str0_r1,str0_base_ptr_->size()) && - range1(str1_r0,str1_r1,str1_base_ptr_->size()) - ) - { - return Operation::process( - str0_base_ptr_->str().substr(str0_r0,(str0_r1 - str0_r0) + 1), - str1_base_ptr_->str().substr(str1_r0,(str1_r1 - str1_r0) + 1) - ); - } + + inline T0 t0() const + { + return t0_; } - - return std::numeric_limits::quiet_NaN(); - } - - inline typename expression_node::node_type type() const - { - return Operation::type(); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - private: - - str_sogens_node(str_sogens_node&); - str_sogens_node& operator=(str_sogens_node&); - - str_base_ptr str0_base_ptr_; - str_base_ptr str1_base_ptr_; - range_ptr str0_range_ptr_; - range_ptr str1_range_ptr_; - }; - - template - class sosos_node : public sosos_base_node - { - public: - - typedef expression_node* expression_ptr; - typedef Operation operation_t; - - // variable op variable node - explicit sosos_node(SType0 p0, SType1 p1, SType2 p2) - : s0_(p0), - s1_(p1), - s2_(p2) - {} - - inline T value() const - { - return Operation::process(s0_,s1_,s2_); - } - - inline typename expression_node::node_type type() const - { - return Operation::type(); - } - - inline operator_type operation() const - { - return Operation::operation(); - } - - inline std::string& s0() - { - return s0_; - } - - inline std::string& s1() - { - return s1_; - } - - inline std::string& s2() - { - return s2_; - } - - protected: - - SType0 s0_; - SType1 s1_; - SType2 s2_; - - private: - - sosos_node(sosos_node&); - sosos_node& operator=(sosos_node&); - }; - #endif - - template - class ipow_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - typedef PowOp operation_t; - - explicit ipow_node(const T& v) - : v_(v) - {} - - inline T value() const - { - return PowOp::result(v_); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_ipow; - } - - private: - - ipow_node(const ipow_node&); - ipow_node& operator=(const ipow_node&); - - const T& v_; - }; - - template - class ipowinv_node : public expression_node - { - public: - - typedef expression_node* expression_ptr; - typedef PowOp operation_t; - - explicit ipowinv_node(const T& v) - : v_(v) - {} - - inline T value() const - { - return (T(1) / PowOp::result(v_)); - } - - inline typename expression_node::node_type type() const - { - return expression_node::e_ipowinv; - } - - private: - - ipowinv_node(const ipowinv_node&); - ipowinv_node& operator=(const ipowinv_node&); - - const T& v_; - }; - - template - inline bool is_vov_node(const expression_node* node) - { - return (0 != dynamic_cast*>(node)); - } - - template - inline bool is_cov_node(const expression_node* node) - { - return (0 != dynamic_cast*>(node)); - } - - template - inline bool is_voc_node(const expression_node* node) - { - return (0 != dynamic_cast*>(node)); - } - - template - inline bool is_cob_node(const expression_node* node) - { - return (0 != dynamic_cast*>(node)); - } - - template - inline bool is_boc_node(const expression_node* node) - { - return (0 != dynamic_cast*>(node)); - } - - template - inline bool is_t0ot1ot2_node(const expression_node* node) - { - return (0 != dynamic_cast*>(node)); - } - - template - inline bool is_t0ot1ot2ot3_node(const expression_node* node) - { - return (0 != dynamic_cast*>(node)); - } - - template - inline bool is_uv_node(const expression_node* node) - { - return (0 != dynamic_cast*>(node)); - } - - template - inline bool is_string_node(const expression_node* node) - { - return node && (expression_node::e_stringvar == node->type()); - } - - template - inline bool is_string_range_node(const expression_node* node) - { - return node && (expression_node::e_stringvarrng == node->type()); - } - - template - inline bool is_const_string_node(const expression_node* node) - { - return node && (expression_node::e_stringconst == node->type()); - } - - template - inline bool is_const_string_range_node(const expression_node* node) - { - return node && (expression_node::e_cstringvarrng == node->type()); - } - - template - inline bool is_string_assignment_node(const expression_node* node) - { - return node && (expression_node::e_strass == node->type()); - } - - template - inline bool is_string_concat_node(const expression_node* node) - { - return node && (expression_node::e_strconcat == node->type()); - } - - template - inline bool is_string_function_node(const expression_node* node) - { - return node && (expression_node::e_strfunction == node->type()); - } - - template - inline bool is_genricstring_range_node(const expression_node* node) - { - return node && (expression_node::e_strgenrange == node->type()); - } - - template - inline bool is_generally_string_node(const expression_node* node) - { - if (node) - { - switch (node->type()) - { - case expression_node::e_stringvar : - case expression_node::e_stringconst : - case expression_node::e_stringvarrng : - case expression_node::e_cstringvarrng : - case expression_node::e_strgenrange : - case expression_node::e_strass : - case expression_node::e_strconcat : - case expression_node::e_strfunction : return true; - default : return false; - } - } - - return false; - } - - class node_allocator - { - public: - - template - inline expression_node* allocate(OpType& operation, ExprNode (&branch)[1]) - { - return allocate(operation,branch[0]); - } - - template - inline expression_node* allocate(OpType& operation, ExprNode (&branch)[2]) - { - return allocate(operation,branch[0],branch[1]); - } - - template - inline expression_node* allocate(OpType& operation, ExprNode (&branch)[3]) - { - return allocate(operation,branch[0],branch[1],branch[2]); - } - - template - inline expression_node* allocate(OpType& operation, ExprNode (&branch)[4]) - { - return allocate(operation,branch[0],branch[1],branch[2],branch[3]); - } - - template - inline expression_node* allocate(OpType& operation, ExprNode (&branch)[5]) - { - return allocate(operation,branch[0],branch[1],branch[2],branch[3],branch[4]); - } - - template - inline expression_node* allocate(OpType& operation, ExprNode (&branch)[6]) - { - return allocate(operation,branch[0],branch[1],branch[2],branch[3],branch[4],branch[5]); - } - - template - inline expression_node* allocate() const - { - return new node_type(); - } - - template class Sequence> - inline expression_node* allocate(const Sequence& seq) const - { - return new node_type(seq); - } - - template - inline expression_node* allocate(T1& t1) const - { - return new node_type(t1); - } - - template - inline expression_node* allocate_c(const T1& t1) const - { - return new node_type(t1); - } - - template - inline expression_node* allocate(const T1& t1, const T2& t2) const - { - return new node_type(t1,t2); - } - - template - inline expression_node* allocate_cr(const T1& t1, T2& t2) const - { - return new node_type(t1,t2); - } - - template - inline expression_node* allocate_rc(T1& t1, const T2& t2) const - { - return new node_type(t1,t2); - } - - template - inline expression_node* allocate_rr(T1& t1, T2& t2) const - { - return new node_type(t1,t2); - } - - template - inline expression_node* allocate_tt(T1 t1, T2 t2) const - { - return new node_type(t1,t2); - } - - template - inline expression_node* allocate_ttt(T1 t1, T2 t2, T3 t3) const - { - return new node_type(t1,t2,t3); - } - - template - inline expression_node* allocate_tttt(T1 t1, T2 t2, T3 t3, T4 t4) const - { - return new node_type(t1,t2,t3,t4); - } - - template - inline expression_node* allocate_rrr(T1& t1, T2& t2, T3& t3) const - { - return new node_type(t1,t2,t3); - } - - template - inline expression_node* allocate_rrrr(T1& t1, T2& t2, T3& t3, T4& t4) const - { - return new node_type(t1,t2,t3,t4); - } - - template - inline expression_node* allocate_rrrrr(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5) const - { - return new node_type(t1,t2,t3,t4,t5); - } - - template - inline expression_node* allocate(const T1& t1, const T2& t2, - const T3& t3) const - { - return new node_type(t1,t2,t3); - } - - template - inline expression_node* allocate(const T1& t1, const T2& t2, - const T3& t3, const T4& t4) const - { - return new node_type(t1,t2,t3,t4); - } - - template - inline expression_node* allocate(const T1& t1, const T2& t2, - const T3& t3, const T4& t4, - const T5& t5) const - { - return new node_type(t1,t2,t3,t4,t5); - } - - template - inline expression_node* allocate(const T1& t1, const T2& t2, - const T3& t3, const T4& t4, - const T5& t5, const T6& t6) const - { - return new node_type(t1,t2,t3,t4,t5,t6); - } - - template - inline expression_node* allocate(const T1& t1, const T2& t2, - const T3& t3, const T4& t4, - const T5& t5, const T6& t6, - const T7& t7) const - { - return new node_type(t1,t2,t3,t4,t5,t6,t7); - } - - template - inline expression_node* allocate(const T1& t1, const T2& t2, - const T3& t3, const T4& t4, - const T5& t5, const T6& t6, - const T7& t7, const T8& t8) const - { - return new node_type(t1,t2,t3,t4,t5,t6,t7,t8); - } - - template - inline expression_node* allocate(const T1& t1, const T2& t2, - const T3& t3, const T4& t4, - const T5& t5, const T6& t6, - const T7& t7, const T8& t8, - const T9& t9) const - { - return new node_type(t1,t2,t3,t4,t5,t6,t7,t8,t9); - } - - template - inline expression_node* allocate(const T1& t1, const T2& t2, - const T3& t3, const T4& t4, - const T5& t5, const T6& t6, - const T7& t7, const T8& t8, - const T9& t9, const T10& t10) const - { - return new node_type(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10); - } - - template - inline expression_node* allocate_type(T1 t1, T2 t2, T3 t3) const - { - return new node_type(t1,t2,t3); - } - - template - inline expression_node* allocate_type(T1 t1, T2 t2, - T3 t3, T4 t4) const - { - return new node_type(t1,t2,t3,t4); - } - - template - inline expression_node* allocate_type(T1 t1, T2 t2, - T3 t3, T4 t4, - T5 t5) const - { - return new node_type(t1,t2,t3,t4,t5); - } - - template - inline expression_node* allocate_type(T1 t1, T2 t2, - T3 t3, T4 t4, - T5 t5, T6 t6, - T7 t7) const - { - return new node_type(t1,t2,t3,t4,t5,t6,t7); - } - - template - void inline free(expression_node*& e) const - { - delete e; - e = 0; - } - }; - - inline void load_operations_map(std::multimap& m) - { - #define register_op(Symbol,Type,Args) \ - m.insert(std::make_pair(std::string(Symbol),details::base_operation_t(Type,Args))); \ - - register_op( "abs",e_abs , 1) - register_op( "acos",e_acos , 1) - register_op( "acosh",e_acosh , 1) - register_op( "asin",e_asin , 1) - register_op( "asinh",e_asinh , 1) - register_op( "atan",e_atan , 1) - register_op( "atanh",e_atanh , 1) - register_op( "ceil",e_ceil , 1) - register_op( "cos",e_cos , 1) - register_op( "cosh",e_cosh , 1) - register_op( "exp",e_exp , 1) - register_op( "expm1",e_expm1 , 1) - register_op( "floor",e_floor , 1) - register_op( "log",e_log , 1) - register_op( "log10",e_log10 , 1) - register_op( "log2",e_log2 , 1) - register_op( "log1p",e_log1p , 1) - register_op( "round",e_round , 1) - register_op( "sin",e_sin , 1) - register_op( "sinc",e_sinc , 1) - register_op( "sinh",e_sinh , 1) - register_op( "sec",e_sec , 1) - register_op( "csc",e_csc , 1) - register_op( "sqrt",e_sqrt , 1) - register_op( "tan",e_tan , 1) - register_op( "tanh",e_tanh , 1) - register_op( "cot",e_cot , 1) - register_op( "rad2deg",e_r2d , 1) - register_op( "deg2rad",e_d2r , 1) - register_op( "deg2grad",e_d2g , 1) - register_op( "grad2deg",e_g2d , 1) - register_op( "sgn",e_sgn , 1) - register_op( "not",e_notl , 1) - register_op( "erf",e_erf , 1) - register_op( "erfc",e_erfc , 1) - register_op( "ncdf",e_ncdf , 1) - register_op( "frac",e_frac , 1) - register_op( "trunc",e_trunc , 1) - register_op( "atan2",e_atan2 , 2) - register_op( "mod",e_mod , 2) - register_op( "logn",e_logn , 2) - register_op( "pow",e_pow , 2) - register_op( "root",e_root , 2) - register_op( "roundn",e_roundn , 2) - register_op( "equal",e_equal , 2) - register_op("not_equal",e_nequal , 2) - register_op( "hypot",e_hypot , 2) - register_op( "shr",e_shr , 2) - register_op( "shl",e_shl , 2) - register_op( "clamp",e_clamp , 3) - register_op( "iclamp",e_iclamp , 3) - register_op( "inrange",e_inrange , 3) - #undef register_op - } - - } // namespace details - - template - class ifunction - { - public: - - explicit ifunction(const std::size_t& pc, const bool hse = true) - : param_count(pc), - has_side_effects(hse) - {} - - virtual ~ifunction() - {} - - inline virtual T operator()() - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&,const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) - { - return std::numeric_limits::quiet_NaN(); - } - - std::size_t param_count; - bool has_side_effects; - }; - - template - class ivararg_function - { - public: - - ivararg_function(const bool hse = true) - : has_side_effects(hse) - {} - - virtual ~ivararg_function() - {} - - inline virtual T operator()(const std::vector&) - { - exprtk_debug(("ivararg_function::operator() - Operator has not been overriden.\n")); - return std::numeric_limits::quiet_NaN(); - } - - bool has_side_effects; - }; - - template - class igeneric_function - { - public: - - typedef T type; - typedef type_store generic_type; - typedef typename generic_type::parameter_list parameter_list_t; - - igeneric_function(const std::string& param_seq = "", - const bool hse = true) - : has_side_effects(hse), - parameter_sequence(param_seq) - {} - - virtual ~igeneric_function() - {} - - // f(i_0,i_1,....,i_N) --> Number - inline virtual T operator()(parameter_list_t) - { - exprtk_debug(("igeneric_function::operator() - Operator has not been overriden. [1]\n")); - return std::numeric_limits::quiet_NaN(); - } - - // f(i_0,i_1,....,i_N) --> String - inline virtual T operator()(std::string&, parameter_list_t) - { - exprtk_debug(("igeneric_function::operator() - Operator has not been overriden. [2]\n")); - return std::numeric_limits::quiet_NaN(); - } - - // f(psi,i_0,i_1,....,i_N) --> Number - inline virtual T operator()(const std::size_t&, parameter_list_t) - { - exprtk_debug(("igeneric_function::operator() - Operator has not been overriden. [3]\n")); - return std::numeric_limits::quiet_NaN(); - } - - // f(psi,i_0,i_1,....,i_N) --> String - inline virtual T operator()(const std::size_t&, std::string&, parameter_list_t) - { - exprtk_debug(("igeneric_function::operator() - Operator has not been overriden. [4]\n")); - return std::numeric_limits::quiet_NaN(); - } - - bool has_side_effects; - std::string parameter_sequence; - }; - - template class parser; - template class expression_helper; - - template - class symbol_table - { - protected: - - template class parser; - - protected: - - template - struct type_store - { - typedef details::expression_node* expression_ptr; - typedef typename details::variable_node variable_node_t; - typedef ifunction ifunction_t; - typedef ivararg_function ivararg_function_t; - typedef igeneric_function igeneric_function_t; - typedef details::vector_holder vector_t; - #ifndef exprtk_disable_string_capabilities - typedef typename details::stringvar_node stringvar_node_t; - #endif - - typedef Type type_t; - typedef type_t* type_ptr; - typedef std::pair type_pair_t; - typedef std::map type_map_t; - typedef typename type_map_t::iterator tm_itr_t; - typedef typename type_map_t::const_iterator tm_const_itr_t; - - enum { lut_size = 256 }; - - type_map_t map; - std::size_t size; - - type_store() - : size(0) - {} - - inline bool symbol_exists(const std::string& symbol_name) const - { - if (symbol_name.empty()) - return false; - else if (map.end() != map.find(symbol_name)) - return true; - else - return false; - } - - template - inline std::string entity_name(const PtrType& ptr) const - { - if (map.empty()) - return std::string(); - - tm_const_itr_t itr = map.begin(); - - while (map.end() != itr) + + inline T1 t1() const { - if (itr->second.second == ptr) - { - return itr->first; - } - else - ++itr; + return t1_; } - - return std::string(); - } - - inline bool is_constant(const std::string& symbol_name) const - { - if (symbol_name.empty()) - return false; - else + + inline T2 t2() const { - tm_const_itr_t itr = map.find(symbol_name); - - if (map.end() == itr) - return false; - else - return (*itr).second.first; + return t2_; } - } - - template - inline bool add_impl(const std::string& symbol_name, RType t, const bool is_const) - { - if (symbol_name.size() > 1) - { - for (std::size_t i = 0; i < details::reserved_symbols_size; ++i) - { - if (details::imatch(symbol_name,details::reserved_symbols[i])) - { - return false; - } - } + + inline T3 t3() const + { + return t3_; } - - tm_itr_t itr = map.find(symbol_name); - - if (map.end() == itr) + + qfunc_t f() const { - map[symbol_name] = Tie::make(t,is_const); - ++size; + return f_; } - - return true; - } - - struct tie_array - { - static inline std::pair make(std::pair v, const bool is_const = false) + + std::string type_id() const { - return std::make_pair(is_const,new vector_t(v.first,v.second)); + return id(); } - }; - - struct tie_stdvec - { + + static inline std::string id() + { + return "sf4"; + } + template - static inline std::pair make(std::vector& v, const bool is_const = false) + static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, T3 p3, qfunc_t p4) + { + return allocator.template allocate_type(p0,p1,p2,p3,p4); + } + + private: + + T0oT1oT2oT3_sf4(node_type&) {} + node_type& operator=(node_type&) { return *this; } + + T0 t0_; + T1 t1_; + T2 t2_; + T3 t3_; + const qfunc_t f_; + }; + + template + class T0oT1oT2oT3_sf4ext : public T0oT1oT2oT3_base_node + { + public: + + typedef typename details::functor_t functor_t; + typedef typename functor_t::tfunc_t tfunc_t; + typedef T value_type; + typedef T0oT1oT2oT3_sf4ext node_type; + + T0oT1oT2oT3_sf4ext(T0 p0, T1 p1, T2 p2, T3 p3) + : t0_(p0), + t1_(p1), + t2_(p2), + t3_(p3) + {} + + inline typename expression_node::node_type type() const { - return std::make_pair(is_const,new vector_t(v)); + static const typename expression_node::node_type result = nodetype_T0oT1oT2oT3::result; + return result; } - }; - - struct tie_stddeq - { + + inline operator_type operation() const + { + return e_default; + } + + inline T value() const + { + return SF4Operation::process(t0_,t1_,t2_,t3_); + } + + inline T0 t0() const + { + return t0_; + } + + inline T1 t1() const + { + return t1_; + } + + inline T2 t2() const + { + return t2_; + } + + inline T3 t3() const + { + return t2_; + } + + std::string type_id() const + { + return id(); + } + + static inline std::string id() + { + return SF4Operation::id(); + } + template - static inline std::pair make(std::deque& v, const bool is_const = false) + static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, T3 p3) + { + return allocator.template allocate_type(p0,p1,p2,p3); + } + + private: + + T0oT1oT2oT3_sf4ext(node_type&) {} + node_type& operator=(node_type&) { return *this; } + + T0 t0_; + T1 t1_; + T2 t2_; + T3 t3_; + }; + + template + inline bool is_sf4ext_node(const expression_node* n) + { + switch (n->type()) + { + case expression_node::e_vovovov : return true; + case expression_node::e_vovovoc : return true; + case expression_node::e_vovocov : return true; + case expression_node::e_vocovov : return true; + case expression_node::e_covovov : return true; + case expression_node::e_covocov : return true; + case expression_node::e_vocovoc : return true; + case expression_node::e_covovoc : return true; + case expression_node::e_vococov : return true; + default : return false; + } + } + + template + struct T0oT1_define + { + typedef details::T0oT1 type0; + }; + + template + struct T0oT1oT2_define + { + typedef details::T0oT1oT2::mode0> type0; + typedef details::T0oT1oT2::mode1> type1; + typedef details::T0oT1oT2_sf3 sf3_type; + typedef details::sf3ext_type_node sf3_type_node; + }; + + template + struct T0oT1oT2oT3_define + { + typedef details::T0oT1oT2oT3::mode0> type0; + typedef details::T0oT1oT2oT3::mode1> type1; + typedef details::T0oT1oT2oT3::mode2> type2; + typedef details::T0oT1oT2oT3::mode3> type3; + typedef details::T0oT1oT2oT3::mode4> type4; + typedef details::T0oT1oT2oT3_sf4 sf4_type; + }; + + template + class vov_node : public vov_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef Operation operation_t; + + // variable op variable node + explicit vov_node(const T& var0, const T& var1) + : v0_(var0), + v1_(var1) + {} + + inline T value() const { - return std::make_pair(is_const,new vector_t(v)); + return Operation::process(v0_,v1_); } - }; - - template - inline bool add(const std::string& symbol_name, T (&v)[v_size], const bool is_const = false) - { - return add_impl >(symbol_name,std::make_pair(v,v_size),is_const); - } - - inline bool add(const std::string& symbol_name, T* v, const std::size_t v_size, const bool is_const = false) - { - return add_impl >(symbol_name,std::make_pair(v,v_size),is_const); - } - - template - inline bool add(const std::string& symbol_name, std::vector& v, const bool is_const = false) - { - return add_impl&>(symbol_name,v,is_const); - } - - template - inline bool add(const std::string& symbol_name, std::deque& v, const bool is_const = false) - { - return add_impl&>(symbol_name,v,is_const); - } - - inline bool add(const std::string& symbol_name, RawType& t, const bool is_const = false) - { - struct tie - { - static inline std::pair make(T& t,const bool is_const = false) - { - return std::make_pair(is_const,new variable_node_t(t)); - } - - #ifndef exprtk_disable_string_capabilities - static inline std::pair make(std::string& t,const bool is_const = false) - { - return std::make_pair(is_const,new stringvar_node_t(t)); - } - #endif - - static inline std::pair make(function_t& t, const bool is_constant = false) - { - return std::make_pair(is_constant,&t); - } - - static inline std::pair make(vararg_function_t& t, const bool is_const = false) - { - return std::make_pair(is_const,&t); - } - - static inline std::pair make(generic_function_t& t, const bool is_constant = false) - { - return std::make_pair(is_constant,&t); - } - }; - - if (symbol_name.size() > 1) + + inline typename expression_node::node_type type() const { - for (std::size_t i = 0; i < details::reserved_symbols_size; ++i) - { - if (details::imatch(symbol_name,details::reserved_symbols[i])) - { - return false; - } - } + return Operation::type(); } - - tm_itr_t itr = map.find(symbol_name); - - if (map.end() == itr) + + inline operator_type operation() const { - map[symbol_name] = tie::make(t,is_const); - ++size; + return Operation::operation(); } - - return true; - } - - inline type_ptr get(const std::string& symbol_name) const - { - tm_const_itr_t itr = map.find(symbol_name); - - if (map.end() == itr) - return reinterpret_cast(0); - else - return itr->second.second; - } - - template - struct ptr_match - { - static inline bool test(const PtrType, const void*) + + inline const T& v0() const { - return false; + return v0_; } - }; - - template - struct ptr_match - { - static inline bool test(const variable_node_t* p, const void* ptr) + + inline const T& v1() const { - exprtk_debug(("ptr_match::test() - %p <--> %p\n",(void*)(&(p->ref())),ptr)); - return (&(p->ref()) == ptr); + return v1_; } - }; - - inline type_ptr get_from_varptr(const void* ptr) const - { - tm_const_itr_t itr = map.begin(); - - while (map.end() != itr) + + protected: + + const T& v0_; + const T& v1_; + + private: + + vov_node(vov_node&); + vov_node& operator=(vov_node&); + }; + + template + class cov_node : public cov_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef Operation operation_t; + + // constant op variable node + explicit cov_node(const T& const_var, const T& var) + : c_(const_var), + v_(var) + {} + + inline T value() const { - type_ptr ret_ptr = itr->second.second; - - if (ptr_match::test(ret_ptr,ptr)) - { - return ret_ptr; - } - - ++itr; + return Operation::process(c_,v_); } - - return type_ptr(0); - } - - inline bool remove(const std::string& symbol_name, const bool delete_node = true) - { - tm_itr_t itr = map.find(symbol_name); - - if (map.end() != itr) - { - struct deleter - { - static inline void process(std::pair& n) { delete n.second; } - static inline void process(std::pair& n) { delete n.second; } - #ifndef exprtk_disable_string_capabilities - static inline void process(std::pair& n) { delete n.second; } - #endif - static inline void process(std::pair&) { } - }; - - if (delete_node) - { - deleter::process((*itr).second); - } - - map.erase(itr); - --size; - - return true; + + inline typename expression_node::node_type type() const + { + return Operation::type(); } - else - return false; - } - - inline RawType& type_ref(const std::string& symbol_name) - { - struct init_type - { - static inline double set(double) { return (0.0); } - static inline double set(long double) { return (0.0); } - static inline float set(float) { return (0.0f); } - static inline std::string set(std::string) { return std::string(""); } - }; - - static RawType null_type = init_type::set(RawType()); - - tm_const_itr_t itr = map.find(symbol_name); - if (map.end() == itr) - return null_type; - else - return itr->second.second->ref(); - } - - inline void clear(const bool delete_node = true) - { - struct deleter - { - static inline void process(std::pair& n) { delete n.second; } - static inline void process(std::pair& n) { delete n.second; } - static inline void process(std::pair&) { } - #ifndef exprtk_disable_string_capabilities - static inline void process(std::pair& n) { delete n.second; } - #endif - }; - - if (!map.empty()) + + inline operator_type operation() const { - if (delete_node) - { - tm_itr_t itr = map.begin(); - tm_itr_t end = map.end(); - - while (end != itr) - { - deleter::process((*itr).second); - ++itr; - } - } - - map.clear(); + return Operation::operation(); } - - size = 0; - } - - template class Sequence> - inline std::size_t get_list(Sequence,Allocator>& list) const - { - std::size_t count = 0; - - if (!map.empty()) + + inline const T c() const { - tm_const_itr_t itr = map.begin(); - tm_const_itr_t end = map.end(); - - while (end != itr) - { - list.push_back(std::make_pair((*itr).first,itr->second.second->ref())); - ++itr; - ++count; - } + return c_; } - - return count; - } - - template class Sequence> - inline std::size_t get_list(Sequence& vlist) const - { - std::size_t count = 0; - - if (!map.empty()) + + inline const T& v() const { - tm_const_itr_t itr = map.begin(); - tm_const_itr_t end = map.end(); - - while (end != itr) - { - vlist.push_back((*itr).first); - ++itr; - ++count; - } + return v_; } - - return count; - } - }; - - typedef details::expression_node* expression_ptr; - typedef typename details::variable_node variable_t; - typedef typename details::vector_holder vector_holder_t; - typedef variable_t* variable_ptr; - #ifndef exprtk_disable_string_capabilities - typedef typename details::stringvar_node stringvar_t; - typedef stringvar_t* stringvar_ptr; - #endif - typedef ifunction function_t; - typedef ivararg_function vararg_function_t; - typedef igeneric_function generic_function_t; - typedef function_t* function_ptr; - typedef vararg_function_t* vararg_function_ptr; - typedef generic_function_t* generic_function_ptr; - - static const std::size_t lut_size = 256; - - // Symbol Table Holder - struct st_holder - { - struct st_data - { - type_store,T> variable_store; - #ifndef exprtk_disable_string_capabilities - type_store,std::string> stringvar_store; - #endif - type_store,ifunction > function_store; - type_store,ivararg_function > vararg_function_store; - type_store,igeneric_function > generic_function_store; - type_store,igeneric_function > string_function_store; - type_store vector_store; - - st_data() + + protected: + + const T c_; + const T& v_; + + private: + + cov_node(const cov_node&); + cov_node& operator=(const cov_node&); + }; + + template + class voc_node : public voc_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef Operation operation_t; + + // variable op constant node + explicit voc_node(const T& var, const T& const_var) + : v_(var), + c_(const_var) + {} + + inline T value() const { - for (std::size_t i = 0; i < details::reserved_words_size; ++i) - { - reserved_symbol_table_.insert(details::reserved_words[i]); - } - - for (std::size_t i = 0; i < details::reserved_symbols_size; ++i) - { - reserved_symbol_table_.insert(details::reserved_symbols[i]); - } + return Operation::process(v_,c_); } - - inline bool is_reserved_symbol(const std::string& symbol) const + + inline operator_type operation() const { - return (reserved_symbol_table_.end() != reserved_symbol_table_.find(symbol)); + return Operation::operation(); } - - std::list local_symbol_list_; - std::list local_stringvar_list_; - std::set reserved_symbol_table_; - }; - - st_holder() - : ref_count(1), - data_(new st_data) - {} - - st_holder(st_data* data) - : ref_count(1), - data_(data) - {} - - ~st_holder() - { - if (data_ && (0 == ref_count)) + + inline const T c() const { - delete data_; - data_ = 0; + return c_; } - } - - std::size_t ref_count; - st_data* data_; - }; - - public: - - symbol_table() - : holder_(new st_holder) - { - clear(); - } - - ~symbol_table() - { - if (holder_) - { - if (0 == --holder_->ref_count) + + inline const T& v() const { - clear(); - delete holder_; + return v_; } - } - } - - symbol_table(const symbol_table& st) - { - holder_ = st.holder_; - holder_->ref_count++; - } - - inline symbol_table& operator=(const symbol_table& st) - { - if (holder_) - { - if (0 == --holder_->ref_count) + + protected: + + const T& v_; + const T c_; + + private: + + voc_node(const voc_node&); + voc_node& operator=(const voc_node&); + }; + + template + class vob_node : public vob_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef std::pair branch_t; + typedef Operation operation_t; + + // variable op constant node + explicit vob_node(const T& var, const expression_ptr brnch) + : v_(var) { - delete holder_; + init_branches<1>(branch_,brnch); } - - holder_ = 0; - } - - holder_ = st.holder_; - holder_->ref_count++; - - return *this; - } - - inline bool operator==(const symbol_table& st) - { - return (this == &st) || (holder_ == st.holder_); - } - - inline void clear_variables(const bool delete_node = true) - { - local_data().variable_store.clear(delete_node); - } - - inline void clear_functions() - { - local_data().function_store.clear(); - } - - inline void clear_strings() - { - #ifndef exprtk_disable_string_capabilities - local_data().stringvar_store.clear(); - #endif - } - - inline void clear_vectors() - { - local_data().vector_store.clear(); - } - - inline void clear() - { - if (!valid()) return; - clear_variables(); - clear_functions(); - clear_strings (); - clear_vectors (); - } - - inline std::size_t variable_count() const - { - if (valid()) - return local_data().variable_store.size; - else - return 0; - } - - #ifndef exprtk_disable_string_capabilities - inline std::size_t stringvar_count() const - { - if (valid()) - return local_data().stringvar_store.size; - else - return 0; - } - #endif - - inline std::size_t function_count() const - { - if (valid()) - return local_data().function_store.size; - else - return 0; - } - - inline std::size_t vector_count() const - { - if (valid()) - return local_data().vector_store.size; - else - return 0; - } - - inline variable_ptr get_variable(const std::string& variable_name) const - { - if (!valid()) - return reinterpret_cast(0); - else if (!valid_symbol(variable_name)) - return reinterpret_cast(0); - else - return local_data().variable_store.get(variable_name); - } - - inline variable_ptr get_variable(const T& var_ref) const - { - if (!valid()) - return reinterpret_cast(0); - else - return local_data().variable_store.get_from_varptr( - reinterpret_cast(&var_ref)); - } - - #ifndef exprtk_disable_string_capabilities - inline stringvar_ptr get_stringvar(const std::string& string_name) const - { - if (!valid()) - return reinterpret_cast(0); - else if (!valid_symbol(string_name)) - return reinterpret_cast(0); - else - return local_data().stringvar_store.get(string_name); - } - #endif - - inline function_ptr get_function(const std::string& function_name) const - { - if (!valid()) - return reinterpret_cast(0); - else if (!valid_symbol(function_name)) - return reinterpret_cast(0); - else - return local_data().function_store.get(function_name); - } - - inline vararg_function_ptr get_vararg_function(const std::string& vararg_function_name) const - { - if (!valid()) - return reinterpret_cast(0); - else if (!valid_symbol(vararg_function_name)) - return reinterpret_cast(0); - else - return local_data().vararg_function_store.get(vararg_function_name); - } - - inline generic_function_ptr get_generic_function(const std::string& function_name) const - { - if (!valid()) - return reinterpret_cast(0); - else if (!valid_symbol(function_name)) - return reinterpret_cast(0); - else - return local_data().generic_function_store.get(function_name); - } - - inline generic_function_ptr get_string_function(const std::string& function_name) const - { - if (!valid()) - return reinterpret_cast(0); - else if (!valid_symbol(function_name)) - return reinterpret_cast(0); - else - return local_data().string_function_store.get(function_name); - } - - typedef vector_holder_t* vector_holder_ptr; - - inline vector_holder_ptr get_vector(const std::string& vector_name) const - { - if (!valid()) - return reinterpret_cast(0); - else if (!valid_symbol(vector_name)) - return reinterpret_cast(0); - else - return local_data().vector_store.get(vector_name); - } - - inline T& variable_ref(const std::string& symbol_name) - { - static T null_var = T(0); - if (!valid()) - return null_var; - else if (!valid_symbol(symbol_name)) - return null_var; - else - return local_data().variable_store.type_ref(symbol_name); - } - - #ifndef exprtk_disable_string_capabilities - inline std::string& stringvar_ref(const std::string& symbol_name) - { - static std::string null_stringvar; - if (!valid()) - return null_stringvar; - else if (!valid_symbol(symbol_name)) - return null_stringvar; - else - return local_data().stringvar_store.type_ref(symbol_name); - } - #endif - - inline bool is_constant_node(const std::string& symbol_name) const - { - if (!valid()) - return false; - else if (!valid_symbol(symbol_name)) - return false; - else - return local_data().variable_store.is_constant(symbol_name); - } - - #ifndef exprtk_disable_string_capabilities - inline bool is_constant_string(const std::string& symbol_name) const - { - if (!valid()) - return false; - else if (!valid_symbol(symbol_name)) - return false; - else if (!local_data().stringvar_store.symbol_exists(symbol_name)) - return false; - else - return local_data().stringvar_store.is_constant(symbol_name); - } - #endif - - inline bool create_variable(const std::string& variable_name, const T& value = T(0)) - { - if (!valid()) - return false; - else if (!valid_symbol(variable_name)) - return false; - else if (symbol_exists(variable_name)) - return false; - - local_data().local_symbol_list_.push_back(value); - T& t = local_data().local_symbol_list_.back(); - - return add_variable(variable_name,t); - } - - #ifndef exprtk_disable_string_capabilities - inline bool create_stringvar(const std::string& stringvar_name, const std::string& value = std::string("")) - { - if (!valid()) - return false; - else if (!valid_symbol(stringvar_name)) - return false; - else if (symbol_exists(stringvar_name)) - return false; - - local_data().local_stringvar_list_.push_back(value); - std::string& s = local_data().local_stringvar_list_.back(); - - return add_stringvar(stringvar_name,s); - } - #endif - - inline bool add_variable(const std::string& variable_name, T& t, const bool is_constant = false) - { - if (!valid()) - return false; - else if (!valid_symbol(variable_name)) - return false; - else if (symbol_exists(variable_name)) - return false; - else - return local_data().variable_store.add(variable_name,t,is_constant); - } - - inline bool add_constant(const std::string& constant_name, const T& value) - { - if (!valid()) - return false; - else if (!valid_symbol(constant_name)) - return false; - else if (symbol_exists(constant_name)) - return false; - - local_data().local_symbol_list_.push_back(value); - T& t = local_data().local_symbol_list_.back(); - - return add_variable(constant_name,t,true); - } - - #ifndef exprtk_disable_string_capabilities - inline bool add_stringvar(const std::string& stringvar_name, std::string& s, const bool is_constant = false) - { - if (!valid()) - return false; - else if (!valid_symbol(stringvar_name)) - return false; - else if (symbol_exists(stringvar_name)) - return false; - else - return local_data().stringvar_store.add(stringvar_name,s,is_constant); - } - #endif - - inline bool add_function(const std::string& function_name, function_t& function) - { - if (!valid()) - return false; - else if (!valid_symbol(function_name)) - return false; - else if (symbol_exists(function_name)) - return false; - else - return local_data().function_store.add(function_name,function); - } - - inline bool add_function(const std::string& vararg_function_name, vararg_function_t& vararg_function) - { - if (!valid()) - return false; - else if (!valid_symbol(vararg_function_name)) - return false; - else if (symbol_exists(vararg_function_name)) - return false; - else - return local_data().vararg_function_store.add(vararg_function_name,vararg_function); - } - - enum func_type - { - e_ft_unknown = 0, - e_ft_basicfunc = 1, - e_ft_strfunc = 2 - }; - - inline bool add_function(const std::string& function_name, generic_function_t& function, const func_type ft = e_ft_basicfunc) - { - if (!valid()) - return false; - else if (!valid_symbol(function_name)) - return false; - else if (symbol_exists(function_name)) - return false; - else if (std::string::npos != function.parameter_sequence.find_first_not_of("STV*?|")) - return false; - else if (e_ft_basicfunc == ft) - return local_data().generic_function_store.add(function_name,function); - else if (e_ft_strfunc == ft) - return local_data().string_function_store.add(function_name, function); - else - return false; - } - - template - inline bool add_vector(const std::string& vector_name, T (&v)[N]) - { - if (!valid()) - return false; - else if (!valid_symbol(vector_name)) - return false; - else if (symbol_exists(vector_name)) - return false; - else - return local_data().vector_store.add(vector_name,v); - } - - inline bool add_vector(const std::string& vector_name, T* v, const std::size_t& v_size) - { - if (!valid()) - return false; - else if (!valid_symbol(vector_name)) - return false; - else if (symbol_exists(vector_name)) - return false; - else - return local_data().vector_store.add(vector_name,v,v_size); - } - - template - inline bool add_vector(const std::string& vector_name, std::vector& v) - { - if (!valid()) - return false; - else if (!valid_symbol(vector_name)) - return false; - else if (symbol_exists(vector_name)) - return false; - else - return local_data().vector_store.add(vector_name,v); - } - - template - inline bool add_vector(const std::string& vector_name, std::deque& v) - { - if (!valid()) - return false; - else if (!valid_symbol(vector_name)) - return false; - else if (symbol_exists(vector_name)) - return false; - else - return local_data().vector_store.add(vector_name,v); - } - - inline bool remove_variable(const std::string& variable_name, const bool delete_node = true) - { - if (!valid()) - return false; - else - return local_data().variable_store.remove(variable_name, delete_node); - } - - #ifndef exprtk_disable_string_capabilities - inline bool remove_stringvar(const std::string& string_name) - { - if (!valid()) - return false; - else - return local_data().stringvar_store.remove(string_name); - } - #endif - - inline bool remove_function(const std::string& function_name) - { - if (!valid()) - return false; - else - return local_data().function_store.remove(function_name); - } - - inline bool remove_vararg_function(const std::string& vararg_function_name) - { - if (!valid()) - return false; - else - return local_data().vararg_function_store.remove(vararg_function_name); - } - - inline bool remove_vector(const std::string& vector_name) - { - if (!valid()) - return false; - else - return local_data().vector_store.remove(vector_name); - } - - inline bool add_constants() - { - return add_pi () && - add_epsilon () && - add_infinity(); - } - - inline bool add_pi() - { - static const T local_pi = T(details::numeric::constant::pi); - return add_constant("pi",local_pi); - } - - inline bool add_epsilon() - { - static const T local_epsilon = details::numeric::details::epsilon_type::value(); - return add_constant("epsilon",local_epsilon); - } - - inline bool add_infinity() - { - static const T local_infinity = std::numeric_limits::infinity(); - return add_constant("inf",local_infinity); - } - - template class Sequence> - inline std::size_t get_variable_list(Sequence,Allocator>& vlist) const - { - if (!valid()) - return 0; - else - return local_data().variable_store.get_list(vlist); - } - - template class Sequence> - inline std::size_t get_variable_list(Sequence& vlist) const - { - if (!valid()) - return 0; - else - return local_data().variable_store.get_list(vlist); - } - - #ifndef exprtk_disable_string_capabilities - template class Sequence> - inline std::size_t get_stringvar_list(Sequence,Allocator>& svlist) const - { - if (!valid()) - return 0; - else - return local_data().stringvar_store.get_list(svlist); - } - - template class Sequence> - inline std::size_t get_stringvar_list(Sequence& svlist) const - { - if (!valid()) - return 0; - else - return local_data().stringvar_store.get_list(svlist); - } - #endif - - template class Sequence> - inline std::size_t get_vector_list(Sequence& vlist) const - { - if (!valid()) - return 0; - else - return local_data().vector_store.get_list(vlist); - } - - inline bool symbol_exists(const std::string& symbol_name) const - { - /* - Will return true if symbol_name exists as either a reserved symbol, - variable, stringvar or function name in any of the type stores. - */ - if (!valid()) - return false; - else if (local_data().variable_store.symbol_exists(symbol_name)) - return true; - #ifndef exprtk_disable_string_capabilities - else if (local_data().stringvar_store.symbol_exists(symbol_name)) - return true; - #endif - else if (local_data().function_store.symbol_exists(symbol_name)) - return true; - else if (local_data().is_reserved_symbol(symbol_name)) - return true; - else - return false; - } - - inline bool is_variable(const std::string& variable_name) const - { - if (!valid()) - return false; - else - return local_data().variable_store.symbol_exists(variable_name); - } - - #ifndef exprtk_disable_string_capabilities - inline bool is_stringvar(const std::string& stringvar_name) const - { - if (!valid()) - return false; - else - return local_data().stringvar_store.symbol_exists(stringvar_name); - } - - inline bool is_conststr_stringvar(const std::string& symbol_name) const - { - if (!valid()) - return false; - else if (!valid_symbol(symbol_name)) - return false; - else if (!local_data().stringvar_store.symbol_exists(symbol_name)) - return false; - - return ( - local_data().stringvar_store.symbol_exists(symbol_name) || - local_data().stringvar_store.is_constant (symbol_name) - ); - } - #endif - - inline bool is_function(const std::string& function_name) const - { - if (!valid()) - return false; - else - return local_data().function_store.symbol_exists(function_name); - } - - inline bool is_vararg_function(const std::string& vararg_function_name) const - { - if (!valid()) - return false; - else - return local_data().vararg_function_store.symbol_exists(vararg_function_name); - } - - inline bool is_vector(const std::string& vector_name) const - { - if (!valid()) - return false; - else - return local_data().vector_store.symbol_exists(vector_name); - } - - inline std::string get_variable_name(const expression_ptr& ptr) const - { - return local_data().variable_store.entity_name(ptr); - } - - inline std::string get_vector_name(const vector_holder_ptr& ptr) const - { - return local_data().vector_store.entity_name(ptr); - } - - #ifndef exprtk_disable_string_capabilities - inline std::string get_stringvar_name(const expression_ptr& ptr) const - { - return local_data().stringvar_store.entity_name(ptr); - } - - inline std::string get_conststr_stringvar_name(const expression_ptr& ptr) const - { - return local_data().stringvar_store.entity_name(ptr); - } - #endif - - inline bool valid() const - { - // Symbol table sanity check. - return holder_ && holder_->data_; - } - - inline void load_from(const symbol_table& st) - { - { - std::vector name_list; - - st.local_data().function_store.get_list(name_list); - - if (!name_list.empty()) + + ~vob_node() { - for (std::size_t i = 0; i < name_list.size(); ++i) - { - exprtk::ifunction& ifunc = *st.get_function(name_list[i]); - add_function(name_list[i],ifunc); - } + cleanup_branches::execute(branch_); } - } - - { - std::vector name_list; - - st.local_data().vararg_function_store.get_list(name_list); - - if (!name_list.empty()) + + inline T value() const { - for (std::size_t i = 0; i < name_list.size(); ++i) - { - exprtk::ivararg_function& ivafunc = *st.get_vararg_function(name_list[i]); - add_function(name_list[i],ivafunc); - } + return Operation::process(v_,branch_[0].first->value()); } - } - - { - std::vector name_list; - - st.local_data().generic_function_store.get_list(name_list); - - if (!name_list.empty()) + + inline operator_type operation() const { - for (std::size_t i = 0; i < name_list.size(); ++i) - { - exprtk::igeneric_function& ifunc = *st.get_generic_function(name_list[i]); - add_function(name_list[i],ifunc); - } + return Operation::operation(); } - } - - { - std::vector name_list; - - st.local_data().string_function_store.get_list(name_list); - - if (!name_list.empty()) + + inline const T& v() const { - for (std::size_t i = 0; i < name_list.size(); ++i) - { - exprtk::igeneric_function& ifunc = *st.get_string_function(name_list[i]); - add_function(name_list[i],ifunc,e_ft_strfunc); - } + return v_; } - } - } - - private: - - inline bool valid_symbol(const std::string& symbol) const - { - if (symbol.empty()) - return false; - if (!details::is_letter(symbol[0])) - return false; - else if (symbol.size() > 1) - { - for (std::size_t i = 1; i < symbol.size(); ++i) - { - if ( - (!details::is_letter(symbol[i])) && - (!details:: is_digit(symbol[i])) && - ('_' != symbol[i]) - ) - { - return false; - } - } - } - - return (!local_data().is_reserved_symbol(symbol)); - } - - inline typename st_holder::st_data& local_data() - { - return *(holder_->data_); - } - - inline const typename st_holder::st_data& local_data() const - { - return *(holder_->data_); - } - - st_holder* holder_; - }; - - template - class function_compositor; - - template - class expression - { - private: - - typedef details::expression_node* expression_ptr; - typedef details::vector_holder* vector_holder_ptr; - - struct expression_holder - { - enum data_type - { - e_unknown , - e_expr , - e_vecholder, - e_data , - e_vecdata , - e_string - }; - - struct data_pack - { - data_pack() - : pointer(0), - type(e_unknown), - size(0) - {} - - data_pack(void* ptr, data_type dt, std::size_t sz = 0) - : pointer(ptr), - type(dt), - size(sz) - {} - - void* pointer; - data_type type; - std::size_t size; - }; - - typedef std::vector local_data_list_t; - - expression_holder() - : ref_count(0), - expr(0) - {} - - expression_holder(expression_ptr e) - : ref_count(1), - expr(e) - {} - - ~expression_holder() - { - if (expr && details::branch_deletable(expr)) + + inline expression_node* branch(const std::size_t&) const { - delete expr; + return branch_[0].first; } - - if (!local_data_list.empty()) + + private: + + vob_node(const vob_node&); + vob_node& operator=(const vob_node&); + + const T& v_; + branch_t branch_[1]; + }; + + template + class bov_node : public bov_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef std::pair branch_t; + typedef Operation operation_t; + + // variable op constant node + explicit bov_node(const expression_ptr brnch, const T& var) + : v_(var) { - for (std::size_t i = 0; i < local_data_list.size(); ++i) - { - switch (local_data_list[i].type) - { - case e_expr : delete reinterpret_cast(local_data_list[i].pointer); - break; - - case e_vecholder : delete reinterpret_cast(local_data_list[i].pointer); - break; - - case e_data : delete (T*)(local_data_list[i].pointer); - break; - - case e_vecdata : delete [] (T*)(local_data_list[i].pointer); - break; - - case e_string : delete (std::string*)(local_data_list[i].pointer); - break; - - default : break; - } - } + init_branches<1>(branch_,brnch); } - } - - std::size_t ref_count; - expression_ptr expr; - local_data_list_t local_data_list; - - friend class function_compositor; - }; - - public: - - expression() - : expression_holder_(0) - { - set_expression(new details::null_node()); - } - - expression(const expression& e) - : expression_holder_(e.expression_holder_), - symbol_table_(e.symbol_table_) - { - expression_holder_->ref_count++; - } - - inline expression& operator=(const expression& e) - { - if (this != &e) - { - if (expression_holder_) - { - if (0 == --expression_holder_->ref_count) - { - delete expression_holder_; - } - - expression_holder_ = 0; + + ~bov_node() + { + cleanup_branches::execute(branch_); } - - expression_holder_ = e.expression_holder_; - expression_holder_->ref_count++; - symbol_table_ = e.symbol_table_; - } - - return *this; - } - - inline bool operator==(const expression& e) - { - return (this == &e); - } - - inline bool operator!() const - { - return ( - (0 == expression_holder_ ) || - (0 == expression_holder_->expr) - ); - } - - inline expression& release() - { - if (expression_holder_) - { - if (0 == --expression_holder_->ref_count) + + inline T value() const { - delete expression_holder_; + return Operation::process(branch_[0].first->value(),v_); } - - expression_holder_ = 0; - } - - return *this; - } - - ~expression() - { - if (expression_holder_) - { - if (0 == --expression_holder_->ref_count) + + inline operator_type operation() const { - delete expression_holder_; + return Operation::operation(); } - } - } - - inline T value() const - { - return expression_holder_->expr->value(); - } - - inline T operator()() const - { - return value(); - } - - inline operator T() const - { - return value(); - } - - inline operator bool() const - { - return details::is_true(value()); - } - - inline void register_symbol_table(symbol_table& st) - { - symbol_table_ = st; - } - - inline const symbol_table& get_symbol_table() const - { - return symbol_table_; - } - - inline symbol_table& get_symbol_table() - { - return symbol_table_; - } - - private: - - inline void set_expression(const expression_ptr expr) - { - if (expr) - { - if (expression_holder_) + + inline const T& v() const { - if (0 == --expression_holder_->ref_count) - { - delete expression_holder_; - } + return v_; } - - expression_holder_ = new expression_holder(expr); - } - } - - inline void register_local_var(expression_ptr expr) - { - if (expr) - { - if (expression_holder_) - { - expression_holder_-> - local_data_list.push_back( - typename expression::expression_holder:: - data_pack(reinterpret_cast(expr), - expression_holder::e_expr)); - } - } - } - - inline void register_local_var(vector_holder_ptr vec_holder) - { - if (vec_holder) - { - if (expression_holder_) - { - expression_holder_-> - local_data_list.push_back( - typename expression::expression_holder:: - data_pack(reinterpret_cast(vec_holder), - expression_holder::e_vecholder)); - } - } - } - - inline void register_local_data(void* data, const std::size_t& size = 0, const bool vectype = false) - { - if (data) - { - if (expression_holder_) - { - expression_holder_-> - local_data_list.push_back( - typename expression::expression_holder:: - data_pack(reinterpret_cast(data), - vectype ? expression_holder::e_vecdata : - expression_holder::e_data, - size)); - } - } - } - - inline const typename expression_holder::local_data_list_t& local_data_list() - { - if (expression_holder_) - { - return expression_holder_->local_data_list; - } - else - { - static typename expression_holder::local_data_list_t null_local_data_list; - return null_local_data_list; - } - } - - expression_holder* expression_holder_; - symbol_table symbol_table_; - - friend class parser; - friend class expression_helper; - friend class function_compositor; - }; - - template - class expression_helper - { - public: - - static inline bool is_constant(const expression& expr) - { - return details::is_constant_node(expr.expression_holder_->expr); - } - - static inline bool is_variable(const expression& expr) - { - return details::is_variable_node(expr.expression_holder_->expr); - } - - static inline bool is_unary(const expression& expr) - { - return details::is_unary_node(expr.expression_holder_->expr); - } - - static inline bool is_binary(const expression& expr) - { - return details::is_binary_node(expr.expression_holder_->expr); - } - - static inline bool is_function(const expression& expr) - { - return details::is_function(expr.expression_holder_->expr); - } - }; - - namespace parser_error - { - enum error_mode - { - e_unknown = 0, - e_syntax = 1, - e_token = 2, - e_numeric = 4, - e_symtab = 5, - e_lexer = 6, - e_helper = 7 - }; - - struct type - { - type() - : mode(parser_error::e_unknown), - line_no (0), - column_no(0) - {} - - lexer::token token; - error_mode mode; - std::string diagnostic; - std::string error_line; - std::size_t line_no; - std::size_t column_no; - }; - - inline type make_error(error_mode mode, const std::string& diagnostic = "") - { - type t; - t.mode = mode; - t.token.type = lexer::token::e_error; - t.diagnostic = diagnostic; - exprtk_debug(((diagnostic + "\n").c_str())); - return t; - } - - inline type make_error(error_mode mode, const lexer::token& tk, const std::string& diagnostic = "") - { - type t; - t.mode = mode; - t.token = tk; - t.diagnostic = diagnostic; - exprtk_debug(((diagnostic + "\n").c_str())); - return t; - } - - inline std::string to_str(error_mode mode) - { - switch (mode) - { - case e_unknown : return std::string("Unknown Error"); - case e_syntax : return std::string("Syntax Error" ); - case e_token : return std::string("Token Error" ); - case e_numeric : return std::string("Numeric Error"); - case e_symtab : return std::string("Symbol Error" ); - case e_lexer : return std::string("Lexer Error" ); - case e_helper : return std::string("Helper Error" ); - default : return std::string("Unknown Error"); - } - } - - inline bool update_error(type& error, const std::string& expression) - { - if ( - expression.empty() || - (error.token.position > expression.size()) || - (std::numeric_limits::max() == error.token.position) - ) - { - return false; - } - - std::size_t error_line_start = 0; - - for (std::size_t i = error.token.position; i > 0; --i) - { - const char c = expression[i]; - - if (('\n' == c) || ('\r' == c)) + + inline expression_node* branch(const std::size_t&) const { - error_line_start = i + 1; - break; + return branch_[0].first; } - } - - std::size_t next_nl_position = std::min(expression.size(), - expression.find_first_of('\n',error.token.position + 1)); - - error.column_no = error.token.position - error_line_start; - error.error_line = expression.substr(error_line_start, - next_nl_position - error_line_start); - - error.line_no = 0; - - for (std::size_t i = 0; i < next_nl_position; ++i) - { - if ('\n' == expression[i]) - ++error.line_no; - } - - return true; - } - - inline void dump_error(const type& error) - { - printf("Position: %02d Type: [%s] Msg: %s\n", - static_cast(error.token.position), - exprtk::parser_error::to_str(error.mode).c_str(), - error.diagnostic.c_str()); - } - } - - template - class parser - { - private: - - enum precedence_level - { - e_level00, - e_level01, - e_level02, - e_level03, - e_level04, - e_level05, - e_level06, - e_level07, - e_level08, - e_level09, - e_level10, - e_level11, - e_level12, - e_level13, - e_level14 - }; - - typedef const T& cref_t; - typedef const T const_t; - typedef ifunction F; - typedef ivararg_function VAF; - typedef igeneric_function GF; - typedef ifunction ifunction_t; - typedef ivararg_function ivararg_function_t; - typedef igeneric_function igeneric_function_t; - typedef details::expression_node expression_node_t; - typedef details::literal_node literal_node_t; - typedef details::unary_node unary_node_t; - typedef details::binary_node binary_node_t; - typedef details::trinary_node trinary_node_t; - typedef details::quaternary_node quaternary_node_t; - typedef details::quinary_node quinary_node_t; - typedef details::senary_node senary_node_t; - typedef details::conditional_node conditional_node_t; - typedef details::cons_conditional_node cons_conditional_node_t; - typedef details::while_loop_node while_loop_node_t; - typedef details::repeat_until_loop_node repeat_until_loop_node_t; - typedef details::for_loop_node for_loop_node_t; - #ifndef exprtk_disable_break_continue - typedef details::while_loop_bc_node while_loop_bc_node_t; - typedef details::repeat_until_loop_bc_node repeat_until_loop_bc_node_t; - typedef details::for_loop_bc_node for_loop_bc_node_t; - #endif - typedef details::switch_node switch_node_t; - typedef details::variable_node variable_node_t; - typedef details::vector_elem_node vector_elem_node_t; - typedef details::vector_node vector_node_t; - #ifndef exprtk_disable_string_capabilities - typedef details::range_pack range_t; - typedef details::stringvar_node stringvar_node_t; - typedef details::string_literal_node string_literal_node_t; - typedef details::string_range_node string_range_node_t; - typedef details::const_string_range_node const_string_range_node_t; - typedef details::generic_string_range_node generic_string_range_node_t; - typedef details::string_concat_node string_concat_node_t; - typedef details::assignment_string_node assignment_string_node_t; - typedef details::assignment_string_range_node assignment_string_range_node_t; - #endif - typedef details::assignment_node assignment_node_t; - typedef details::assignment_vec_elem_node assignment_vec_elem_node_t; - typedef details::assignment_vec_node assignment_vec_node_t; - typedef details::assignment_vecvec_node assignment_vecvec_node_t; - typedef details::scand_node scand_node_t; - typedef details::scor_node scor_node_t; - typedef lexer::token token_t; - typedef expression_node_t* expression_node_ptr; - typedef symbol_table symbol_table_t; - typedef details::vector_holder* vector_holder_ptr; - - typedef typename details::functor_t functor_t; - typedef typename functor_t::qfunc_t quaternary_functor_t; - typedef typename functor_t::tfunc_t trinary_functor_t; - typedef typename functor_t::bfunc_t binary_functor_t; - typedef typename functor_t::ufunc_t unary_functor_t; - - typedef details::operator_type operator_t; - - typedef std::map unary_op_map_t; - typedef std::map binary_op_map_t; - typedef std::map trinary_op_map_t; - - typedef std::map > sf3_map_t; - typedef std::map > sf4_map_t; - - typedef std::map inv_binary_op_map_t; - typedef std::multimap base_ops_map_t; - - typedef details::T0oT1_define vov_t; - typedef details::T0oT1_define cov_t; - typedef details::T0oT1_define voc_t; - - typedef details::T0oT1oT2_define vovov_t; - typedef details::T0oT1oT2_define vovoc_t; - typedef details::T0oT1oT2_define vocov_t; - typedef details::T0oT1oT2_define covov_t; - typedef details::T0oT1oT2_define covoc_t; - typedef details::T0oT1oT2_define cocov_t; - typedef details::T0oT1oT2_define vococ_t; - - typedef details::T0oT1oT2oT3_define vovovov_t; - typedef details::T0oT1oT2oT3_define vovovoc_t; - typedef details::T0oT1oT2oT3_define vovocov_t; - typedef details::T0oT1oT2oT3_define vocovov_t; - typedef details::T0oT1oT2oT3_define covovov_t; - - typedef details::T0oT1oT2oT3_define covocov_t; - typedef details::T0oT1oT2oT3_define vocovoc_t; - typedef details::T0oT1oT2oT3_define covovoc_t; - typedef details::T0oT1oT2oT3_define vococov_t; - - struct scope_element - { - enum element_type - { - e_none , - e_variable, - e_vector , - e_vecelem , - e_string - }; - - typedef variable_node_t* variable_node_ptr; - typedef details::vector_holder vector_holder_t; - typedef vector_holder_t* vector_holder_ptr; - - scope_element() - : name("???"), - size (std::numeric_limits::max()), - index(std::numeric_limits::max()), - depth(std::numeric_limits::max()), - ref_count(0), - ip_index (0), - type (e_none), - active(false), - data (0), - var_node(0), - vec_node(0) - {} - - bool operator < (const scope_element& se) const - { - if (ip_index < se.ip_index) - return true; - else if (ip_index > se.ip_index) - return false; - else if (depth < se.depth) - return true; - else if (depth > se.depth) - return false; - else if (index < se.index) - return true; - else if (index > se.index) - return false; - else - return (name < se.name); - } - - std::string name; - std::size_t size; - std::size_t index; - std::size_t depth; - std::size_t ref_count; - std::size_t ip_index; - element_type type; - bool active; - void* data; - variable_node_ptr var_node; - vector_holder_ptr vec_node; - }; - - class scope_element_manager - { - public: - - typedef variable_node_t* variable_node_ptr; - typedef parser parser_t; - - scope_element_manager(parser& p) - : parser_(p), - input_param_cnt_(0) - {} - - inline std::size_t size() const - { - return element_.size(); - } - - inline bool empty() const - { - return element_.empty(); - } - - inline scope_element& get_element(const std::size_t& index) - { - if (index < element_.size()) - return element_[index]; - else - return null_element_; - } - - inline scope_element& get_element(const std::string& var_name, - const std::size_t index = std::numeric_limits::max()) - { - for (std::size_t i = 0; i < element_.size(); ++i) + + private: + + bov_node(const bov_node&); + bov_node& operator=(const bov_node&); + + const T& v_; + branch_t branch_[1]; + }; + + template + class cob_node : public cob_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef std::pair branch_t; + typedef Operation operation_t; + + // variable op constant node + explicit cob_node(const T const_var, const expression_ptr brnch) + : c_(const_var) { - scope_element& se = element_[i]; - - if (se.depth > parser_.scope_depth_) - return null_element_; - else if ( - (se.name == var_name) && - (se.index == index) - ) - return se; + init_branches<1>(branch_,brnch); } - - return null_element_; - } - - inline bool add_element(const scope_element& se) - { - for (std::size_t j = 0; j < element_.size(); ++j) - { - if ( - (element_[j].name == se.name ) && - (element_[j].depth <= se.depth) && - (element_[j].index == se.index) && - (element_[j].size == se.size ) - ) - return false; + + ~cob_node() + { + cleanup_branches::execute(branch_); } - - element_.push_back(se); - std::sort(element_.begin(),element_.end()); - - return true; - } - - inline void deactivate(const std::size_t& scope_depth) - { - for (std::size_t j = 0; j < element_.size(); ++j) + + inline T value() const { - if (element_[j].depth >= scope_depth) - { - element_[j].active = false; - } + return Operation::process(c_,branch_[0].first->value()); } - } - - void cleanup() - { - for (std::size_t i = 0; i < element_.size(); ++i) - { - if (element_[i].var_node) - { - delete element_[i].var_node; - } - - if (element_[i].vec_node) - { - delete element_[i].vec_node; - } - - T* data = (T*)(element_[i].data); - - switch (element_[i].type) - { - case scope_element::e_variable : delete data; break; - case scope_element::e_vector : delete [] data; break; - default : break; - } + + inline operator_type operation() const + { + return Operation::operation(); } - - element_.clear(); - - input_param_cnt_ = 0; - } - - inline std::size_t next_ip_index() - { - return ++input_param_cnt_; - } - - inline variable_node_ptr get_variable(const T& v) - { - for (std::size_t i = 0; i < element_.size(); ++i) + + inline const T c() const { - scope_element& se = element_[i]; - - if (se.active && se.var_node) - { - if (&se.var_node->ref() == (&v)) - { - return se.var_node; - } - } + return c_; } - - return variable_node_ptr(0); - } - - private: - - scope_element_manager& operator=(const scope_element_manager&); - - parser_t& parser_; - std::vector element_; - scope_element null_element_; - std::size_t input_param_cnt_; - }; - - class scope_handler - { - public: - - typedef parser parser_t; - - scope_handler(parser& p) - : parser_(p) - { - parser_.scope_depth_++; - #ifdef exprtk_enable_debugging - std::string depth(2 * parser_.scope_depth_,'-'); - exprtk_debug(("%s> Scope Depth: %02d\n",depth.c_str(),static_cast(parser_.scope_depth_))); - #endif - } - - ~scope_handler() - { - parser_.scope_depth_--; - parser_.sem_.deactivate(parser_.scope_depth_); - #ifdef exprtk_enable_debugging - std::string depth(2 * parser_.scope_depth_,'-'); - exprtk_debug(("<%s Scope Depth: %02d\n",depth.c_str(),static_cast(parser_.scope_depth_))); - #endif - } - - private: - - scope_handler& operator=(const scope_handler&); - - parser_t& parser_; - }; - - public: - - enum compilation_options - { - e_unknown = 0, - e_replacer = 1, - e_joiner = 2, - e_numeric_check = 4, - e_bracket_check = 8, - e_sequence_check = 16, - e_commutative_check = 32, - e_strength_reduction = 64, - e_disable_vardef = 128, - e_collect_vars = 256, - e_collect_funcs = 512, - e_collect_assings = 1024 - }; - - struct unknown_symbol_resolver - { - - enum usr_symbol_type - { - e_usr_variable_type = 0, - e_usr_constant_type = 1 - }; - - virtual ~unknown_symbol_resolver() - {} - - virtual bool process(const std::string& /*unknown_symbol*/, - usr_symbol_type& st, - T& default_value, - std::string& error_message) - { - st = e_usr_variable_type; - default_value = T(0); - error_message = ""; - - return true; - } - }; - - enum collect_type - { - e_ct_none = 0, - e_ct_variables = 1, - e_ct_functions = 2, - e_ct_assignments = 4 - }; - - enum symbol_type - { - e_st_unknown = 0, - e_st_variable = 1, - e_st_vector = 2, - e_st_string = 3, - e_st_function = 4, - e_st_local_variable = 5, - e_st_local_vector = 6, - e_st_local_string = 7 - }; - - class dependent_entity_collector - { - public: - - typedef std::pair symbol_t; - typedef std::vector symbol_list_t; - - dependent_entity_collector(const std::size_t options = e_ct_none) - : options_(options), - collect_variables_ ((options_ & e_ct_variables ) == e_ct_variables ), - collect_functions_ ((options_ & e_ct_functions ) == e_ct_functions ), - collect_assignments_((options_ & e_ct_assignments) == e_ct_assignments) - {} - - template class Sequence> - inline std::size_t symbols(Sequence& symbols_list) - { - if (!collect_variables_ && !collect_functions_) - return 0; - else if (symbol_name_list_.empty()) - return 0; - - for (std::size_t i = 0; i < symbol_name_list_.size(); ++i) + + inline void set_c(const T new_c) { - std::string& s = symbol_name_list_[i].first; - std::transform(s.begin(),s.end(),s.begin(),static_cast(std::tolower)); + (*const_cast(&c_)) = new_c; } - - std::sort(symbol_name_list_.begin(),symbol_name_list_.end()); - std::unique_copy(symbol_name_list_.begin(), - symbol_name_list_.end(), - std::back_inserter(symbols_list)); - - return symbols_list.size(); - } - - template class Sequence> - inline std::size_t assignment_symbols(Sequence& assignment_list) - { - if (!collect_assignments_) - return 0; - else if (assignment_name_list_.empty()) - return 0; - - for (std::size_t i = 0; i < assignment_name_list_.size(); ++i) + + inline expression_node* branch(const std::size_t&) const { - std::string& s = assignment_name_list_[i].first; - std::transform(s.begin(),s.end(),s.begin(),static_cast(std::tolower)); + return branch_[0].first; } - - std::sort(assignment_name_list_.begin(),assignment_name_list_.end()); - std::unique_copy(assignment_name_list_.begin(), - assignment_name_list_.end(), - std::back_inserter(assignment_list)); - - return assignment_list.size(); - } - - void clear() - { - symbol_name_list_ .clear(); - assignment_name_list_.clear(); - } - - bool& collect_variables() - { - return collect_variables_; - } - - bool& collect_functions() - { - return collect_functions_; - } - - bool& collect_assignments() - { - return collect_assignments_; - } - - private: - - inline void add_symbol(const std::string& symbol, const symbol_type st) - { - switch (st) - { - case e_st_variable : - case e_st_vector : - case e_st_string : - case e_st_local_variable : - case e_st_local_vector : - case e_st_local_string : - case e_st_function : - if (collect_variables_ || collect_functions_) - symbol_name_list_.push_back(std::make_pair(symbol,st)); - break; - - default : return; + + inline expression_node* move_branch(const std::size_t&) + { + branch_[0].second = false; + return branch_[0].first; } - } - - inline void add_assignment(const std::string& symbol, const symbol_type st) - { - switch (st) - { - case e_st_variable : - case e_st_vector : - case e_st_string : - if (collect_assignments_) - assignment_name_list_.push_back(std::make_pair(symbol,st)); - break; - - default : return; + + private: + + cob_node(const cob_node&); + cob_node& operator=(const cob_node&); + + const T c_; + branch_t branch_[1]; + }; + + template + class boc_node : public boc_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef std::pair branch_t; + typedef Operation operation_t; + + // variable op constant node + explicit boc_node(const expression_ptr brnch, const T const_var) + : c_(const_var) + { + init_branches<1>(branch_,brnch); } - } - - std::size_t options_; - bool collect_variables_; - bool collect_functions_; - bool collect_assignments_; - symbol_list_t symbol_name_list_; - symbol_list_t assignment_name_list_; - - friend class parser; - }; - - static const std::size_t compile_all_opts = e_replacer + - e_joiner + - e_numeric_check + - e_bracket_check + - e_sequence_check + - e_commutative_check + - e_strength_reduction; - - parser(const std::size_t compile_options = compile_all_opts) - : compile_options_(compile_options), - resolve_unknown_symbol_(false), - vardef_disabled_((compile_options & e_disable_vardef) == e_disable_vardef), - scope_depth_(0), - unknown_symbol_resolver_(reinterpret_cast(0)), - #ifdef _MSC_VER - #pragma warning(push) - #pragma warning (disable:4355) - #endif - sem_(*this), - #ifdef _MSC_VER - #pragma warning(pop) - #endif - operator_joiner_2_(2), - operator_joiner_3_(3) - { - init_precompilation(); - - load_operations_map(base_ops_map_); - load_unary_operations_map(unary_op_map_); - load_binary_operations_map(binary_op_map_); - load_inv_binary_operations_map(inv_binary_op_map_); - load_sf3_map(sf3_map_); - load_sf4_map(sf4_map_); - - expression_generator_.init_synthesize_map(); - expression_generator_.set_parser(*this); - expression_generator_.set_uom(unary_op_map_); - expression_generator_.set_bom(binary_op_map_); - expression_generator_.set_ibom(inv_binary_op_map_); - expression_generator_.set_sf3m(sf3_map_); - expression_generator_.set_sf4m(sf4_map_); - expression_generator_.set_strength_reduction_state(strength_reduction_enabled()); - } - - ~parser() - {} - - inline void init_precompilation() - { - if (collect_variables_enabled()) - dec_.collect_variables() = true; - - if (collect_functions_enabled()) - dec_.collect_functions() = true; - - if (collect_assignments_enabled()) - dec_.collect_assignments() = true; - - if (replacer_enabled()) - { - symbol_replacer_.clear(); - symbol_replacer_.add_replace("true" ,"1",lexer::token::e_number); - symbol_replacer_.add_replace("false","0",lexer::token::e_number); - helper_assembly_.token_modifier_list.clear(); - helper_assembly_.register_modifier(&symbol_replacer_); - } - - if (commutative_check_enabled()) - { - for (std::size_t i = 0; i < details::reserved_words_size; ++i) + + ~boc_node() { - commutative_inserter_.ignore_symbol(details::reserved_words[i]); + cleanup_branches::execute(branch_); } - - helper_assembly_.token_inserter_list.clear(); - helper_assembly_.register_inserter(&commutative_inserter_); - } - - if (joiner_enabled()) - { - helper_assembly_.token_joiner_list.clear(); - helper_assembly_.register_joiner(&operator_joiner_2_); - helper_assembly_.register_joiner(&operator_joiner_3_); - } - - if ( - numeric_check_enabled () || - bracket_check_enabled () || - sequence_check_enabled() - ) - { - helper_assembly_.token_scanner_list.clear(); - - if (numeric_check_enabled()) + + inline T value() const { - helper_assembly_.register_scanner(&numeric_checker_); + return Operation::process(branch_[0].first->value(),c_); } - - if (bracket_check_enabled()) + + inline operator_type operation() const { - helper_assembly_.register_scanner(&bracket_checker_); + return Operation::operation(); } - - if (sequence_check_enabled()) + + inline const T c() const { - helper_assembly_.register_scanner(&sequence_validator_); + return c_; } - } - } - - inline bool compile(const std::string& expression_string, expression& expr) - { - error_list_ .clear(); - brkcnt_list_ .clear(); - synthesis_error_.clear(); - sem_ .cleanup(); - - expression_generator_.set_allocator(node_allocator_); - - scope_depth_ = 0; - - if (expression_string.empty()) - { - set_error( - make_error(parser_error::e_syntax, - "ERR00 - Empty expression!")); - - return false; - } - - if (!lexer_.process(expression_string)) - { - process_lexer_errors(); - return false; - } - - if (lexer_.empty()) - { - set_error( - make_error(parser_error::e_syntax, - "ERR01 - Empty expression!")); - - return false; - } - - if (!run_assemblies()) - { - return false; - } - - symbol_table_ = expr.get_symbol_table(); - dec_.clear(); - - lexer_.begin(); - next_token(); - - expression_node_ptr e = parse_corpus(); - - if ((0 != e) && (token_t::e_eof == current_token_.type)) - { - expr.set_expression(e); - register_local_vars(expr); - - return !(!expr); - } - else - { - if (error_list_.empty()) + + inline void set_c(const T new_c) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR02 - Invalid expression encountered")); + (*const_cast(&c_)) = new_c; } - - dec_.clear (); - sem_.cleanup(); - - if (0 != e) + + inline expression_node* branch(const std::size_t&) const { - delete e; + return branch_[0].first; } - - return false; - } - } - - void process_lexer_errors() - { - for (std::size_t i = 0; i < lexer_.size(); ++i) - { - if (lexer_[i].is_error()) + + inline expression_node* move_branch(const std::size_t&) { - std::string diagnostic = "ERR03 - "; - - switch (lexer_[i].type) - { - case lexer::token::e_error : diagnostic += "General token error"; - break; - - case lexer::token::e_err_symbol : diagnostic += "Symbol error"; - break; - - case lexer::token::e_err_number : diagnostic += "Invalid numeric token"; - break; - - case lexer::token::e_err_string : diagnostic += "Invalid string token"; - break; - - case lexer::token::e_err_sfunc : diagnostic += "Invalid special function token"; - break; - - default : diagnostic += "Unknown compiler error"; - } - - set_error( - make_error(parser_error::e_lexer, - lexer_[i], - diagnostic + ": " + lexer_[i].value)); + branch_[0].second = false; + return branch_[0].first; } - } - } - - inline bool replacer_enabled() const - { - return ((compile_options_ & e_replacer) == e_replacer); - } - - inline bool commutative_check_enabled() const - { - return ((compile_options_ & e_commutative_check) == e_commutative_check); - } - - inline bool joiner_enabled() const - { - return ((compile_options_ & e_joiner) == e_joiner); - } - - inline bool numeric_check_enabled() const - { - return ((compile_options_ & e_numeric_check) == e_numeric_check); - } - - inline bool bracket_check_enabled() const - { - return ((compile_options_ & e_bracket_check) == e_bracket_check); - } - - inline bool sequence_check_enabled() const - { - return ((compile_options_ & e_sequence_check) == e_sequence_check); - } - - inline bool strength_reduction_enabled() const - { - return ((compile_options_ & e_strength_reduction) == e_strength_reduction); - } - - inline bool collect_variables_enabled() const - { - return ((compile_options_ & e_collect_vars) == e_collect_vars); - } - - inline bool collect_functions_enabled() const - { - return ((compile_options_ & e_collect_funcs) == e_collect_funcs); - } - - inline bool collect_assignments_enabled() const - { - return ((compile_options_ & e_collect_assings) == e_collect_assings); - } - - inline bool run_assemblies() - { - if (commutative_check_enabled()) - { - helper_assembly_.run_inserters(lexer_); - } - - if (joiner_enabled()) - { - helper_assembly_.run_joiners(lexer_); - } - - if (replacer_enabled()) - { - helper_assembly_.run_modifiers(lexer_); - } - - if ( - numeric_check_enabled () || - bracket_check_enabled () || - sequence_check_enabled() - ) - { - if (!helper_assembly_.run_scanners(lexer_)) - { - if (helper_assembly_.error_token_scanner) - { - lexer::helper::bracket_checker* bracket_checker_ptr = 0; - lexer::helper::numeric_checker* numeric_checker_ptr = 0; - lexer::helper::sequence_validator* sequence_validator_ptr = 0; - - if (0 != (bracket_checker_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) - { - set_error( - make_error(parser_error::e_token, - bracket_checker_ptr->error_token(), - "ERR04 - Mismatched brackets: '" + bracket_checker_ptr->error_token().value + "'")); - } - else if (0 != (numeric_checker_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) - { - for (std::size_t i = 0; i < numeric_checker_ptr->error_count(); ++i) - { - lexer::token error_token = lexer_[numeric_checker_ptr->error_index(i)]; - - set_error( - make_error(parser_error::e_token, - error_token, - "ERR05 - Invalid numeric token: '" + error_token.value + "'")); - } - - if (numeric_checker_ptr->error_count()) - { - numeric_checker_ptr->clear_errors(); - } - } - else if (0 != (sequence_validator_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) - { - for (std::size_t i = 0; i < sequence_validator_ptr->error_count(); ++i) - { - std::pair error_token = sequence_validator_ptr->error(i); - - set_error( - make_error(parser_error::e_token, - error_token.first, - "ERR06 - Invalid token sequence: '" + - error_token.first.value + "' and '" + - error_token.second.value + "'")); - } - - if (sequence_validator_ptr->error_count()) - { - sequence_validator_ptr->clear_errors(); - } - } - } - - return false; + + private: + + boc_node(const boc_node&); + boc_node& operator=(const boc_node&); + + const T c_; + branch_t branch_[1]; + }; + +#ifndef exprtk_disable_string_capabilities + template + class sos_node : public sos_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef Operation operation_t; + + // string op string node + explicit sos_node(SType0 p0, SType1 p1) + : s0_(p0), + s1_(p1) + {} + + inline T value() const + { + return Operation::process(s0_,s1_); } - } - - return true; - } - - inline parser_error::type get_error(const std::size_t& index) - { - if (index < error_list_.size()) - return error_list_[index]; - else - throw std::invalid_argument("parser::get_error() - Invalid error index specificed"); - } - - inline std::string error() const - { - if (!error_list_.empty()) - { - return error_list_[0].diagnostic; - } - else - return std::string("No Error"); - } - - inline std::size_t error_count() const - { - return error_list_.size(); - } - - inline dependent_entity_collector& dec() - { - return dec_; - } - - inline bool replace_symbol(const std::string& old_symbol, const std::string& new_symbol) - { - if (!replacer_enabled()) - return false; - else if (details::is_reserved_word(old_symbol)) - return false; - else - return symbol_replacer_.add_replace(old_symbol,new_symbol,lexer::token::e_symbol); - } - - inline bool remove_replace_symbol(const std::string& symbol) - { - if (!replacer_enabled()) - return false; - else if (details::is_reserved_word(symbol)) - return false; - else - return symbol_replacer_.remove(symbol); - } - - inline void enable_unknown_symbol_resolver(unknown_symbol_resolver* usr = reinterpret_cast(0)) - { - resolve_unknown_symbol_ = true; - - if (usr) - unknown_symbol_resolver_ = usr; - else - unknown_symbol_resolver_ = &default_usr_; - } - - inline void disable_unknown_symbol_resolver() - { - resolve_unknown_symbol_ = false; - unknown_symbol_resolver_ = &default_usr_; - } - - private: - - inline bool valid_base_operation(const std::string& symbol) - { - const std::size_t length = symbol.size(); - if ( - (length < 3) || // Shortest base op symbol length - (length > 9) // Longest base op symbol length - ) - return false; - else - return (base_ops_map_.end() != base_ops_map_.find(symbol)); - } - - inline bool valid_vararg_operation(const std::string& symbol) - { - static const std::string s_sum = "sum" ; - static const std::string s_mul = "mul" ; - static const std::string s_avg = "avg" ; - static const std::string s_min = "min" ; - static const std::string s_max = "max" ; - static const std::string s_mand = "mand"; - static const std::string s_mor = "mor" ; - static const std::string s_multi = "~" ; - static const std::string s_mswitch = "[*]" ; - return - ( - details::imatch(symbol,s_sum ) || - details::imatch(symbol,s_mul ) || - details::imatch(symbol,s_avg ) || - details::imatch(symbol,s_min ) || - details::imatch(symbol,s_max ) || - details::imatch(symbol,s_mand ) || - details::imatch(symbol,s_mor ) || - details::imatch(symbol,s_multi ) || - details::imatch(symbol,s_mswitch) - ); - } - - inline void store_token() - { - lexer_.store(); - store_current_token_ = current_token_; - } - - inline void restore_token() - { - lexer_.restore(); - current_token_ = store_current_token_; - } - - #ifndef exprtk_enable_debugging - inline void next_token() - { - current_token_ = lexer_.next_token(); - } - #else - inline void next_token() - { - std::string ct_str = current_token_.value; - current_token_ = lexer_.next_token(); - std::string depth(2 * scope_depth_,' '); - exprtk_debug(("%s" - "prev[%s] --> curr[%s]\n", - depth.c_str(), - ct_str.c_str(), - current_token_.value.c_str())); - } - #endif - - inline const lexer::token& current_token() const - { - return current_token_; - } - - inline expression_node_ptr parse_corpus() - { - std::vector arg_list; - expression_node_ptr result = error_node(); - - scoped_vec_delete sdd(*this,arg_list); - - for (;;) - { - expression_node_ptr arg = parse_expression(); - - if (0 == arg) - { - if (error_list_.empty()) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR07 - Invalid expression encountered")); - } - - return error_node(); + + inline typename expression_node::node_type type() const + { + return Operation::type(); } - else - arg_list.push_back(arg); - - if (lexer_.finished()) - break; - else if (token_is(token_t::e_eof,false)) + + inline operator_type operation() const { - if (lexer_.finished()) - break; - else - next_token(); + return Operation::operation(); } - } - - result = simplify(arg_list); - - sdd.delete_ptr = (0 == result); - return result; - } - - static const precedence_level default_precedence = e_level00; - - struct state_t - { - inline void set(const precedence_level& l, - const precedence_level& r, - const details::operator_type& o) - { - left = l; - right = r; - operation = o; - } - - inline void reset() - { - left = e_level00; - right = e_level00; - } - - precedence_level left; - precedence_level right; - details::operator_type operation; - }; - - inline expression_node_ptr parse_expression(precedence_level precedence = e_level00) - { - expression_node_ptr expression = parse_branch(precedence); - - if (0 == expression) - { - return error_node(); - } - - bool break_loop = false; - - state_t current_state; - - for ( ; ; ) - { - current_state.reset(); - - switch (current_token_.type) - { - case token_t::e_assign : current_state.set(e_level00,e_level00,details::e_assign); break; - case token_t::e_addass : current_state.set(e_level00,e_level00,details::e_addass); break; - case token_t::e_subass : current_state.set(e_level00,e_level00,details::e_subass); break; - case token_t::e_mulass : current_state.set(e_level00,e_level00,details::e_mulass); break; - case token_t::e_divass : current_state.set(e_level00,e_level00,details::e_divass); break; - case token_t::e_modass : current_state.set(e_level00,e_level00,details::e_modass); break; - case token_t::e_swap : current_state.set(e_level00,e_level00,details::e_swap ); break; - case token_t::e_lt : current_state.set(e_level05,e_level06,details:: e_lt); break; - case token_t::e_lte : current_state.set(e_level05,e_level06,details:: e_lte); break; - case token_t::e_eq : current_state.set(e_level05,e_level06,details:: e_eq); break; - case token_t::e_ne : current_state.set(e_level05,e_level06,details:: e_ne); break; - case token_t::e_gte : current_state.set(e_level05,e_level06,details:: e_gte); break; - case token_t::e_gt : current_state.set(e_level05,e_level06,details:: e_gt); break; - case token_t::e_add : current_state.set(e_level07,e_level08,details:: e_add); break; - case token_t::e_sub : current_state.set(e_level07,e_level08,details:: e_sub); break; - case token_t::e_div : current_state.set(e_level10,e_level11,details:: e_div); break; - case token_t::e_mul : current_state.set(e_level10,e_level11,details:: e_mul); break; - case token_t::e_mod : current_state.set(e_level10,e_level11,details:: e_mod); break; - case token_t::e_pow : current_state.set(e_level12,e_level12,details:: e_pow); break; - default : if (token_t::e_symbol == current_token_.type) - { - static const std::string s_and = "and"; - static const std::string s_nand = "nand"; - static const std::string s_or = "or"; - static const std::string s_nor = "nor"; - static const std::string s_xor = "xor"; - static const std::string s_xnor = "xnor"; - static const std::string s_in = "in"; - static const std::string s_like = "like"; - static const std::string s_ilike = "ilike"; - static const std::string s_and1 = "&"; - static const std::string s_or1 = "|"; - - if (details::imatch(current_token_.value,s_and)) - { - current_state.set(e_level01,e_level02,details::e_and); - break; - } - else if (details::imatch(current_token_.value,s_and1)) - { - #ifndef exprtk_disable_sc_andor - current_state.set(e_level01,e_level02,details::e_scand); - #else - current_state.set(e_level01,e_level02,details::e_and); - #endif - break; - } - else if (details::imatch(current_token_.value,s_nand)) - { - current_state.set(e_level01,e_level02,details::e_nand); - break; - } - else if (details::imatch(current_token_.value,s_or)) - { - current_state.set(e_level03,e_level04,details::e_or); - break; - } - else if (details::imatch(current_token_.value,s_or1)) - { - #ifndef exprtk_disable_sc_andor - current_state.set(e_level03,e_level04,details::e_scor); - #else - current_state.set(e_level03,e_level04,details::e_or); - #endif - break; - } - else if (details::imatch(current_token_.value,s_nor)) - { - current_state.set(e_level03,e_level04,details::e_nor); - break; - } - else if (details::imatch(current_token_.value,s_xor)) - { - current_state.set(e_level03,e_level04,details::e_xor); - break; - } - else if (details::imatch(current_token_.value,s_xnor)) - { - current_state.set(e_level03,e_level04,details::e_xnor); - break; - } - else if (details::imatch(current_token_.value,s_in)) - { - current_state.set(e_level03,e_level04,details::e_in); - break; - } - else if (details::imatch(current_token_.value,s_like)) - { - current_state.set(e_level03,e_level04,details::e_like); - break; - } - else if (details::imatch(current_token_.value,s_ilike)) - { - current_state.set(e_level03,e_level04,details::e_ilike); - break; - } - } - - break_loop = true; + + inline std::string& s0() + { + return s0_; } - - if (break_loop) + + inline std::string& s1() { - parse_pending_string_rangesize(expression); - break; + return s1_; } - else if (current_state.left < precedence) - break; - - lexer::token prev_token = current_token_; - - next_token(); - - expression_node_ptr right_branch = error_node(); - expression_node_ptr new_expression = error_node(); - - if ((right_branch = parse_expression(current_state.right))) + + protected: + + SType0 s0_; + SType1 s1_; + + private: + + sos_node(sos_node&); + sos_node& operator=(sos_node&); + }; + + template + class str_xrox_node : public sos_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef Operation operation_t; + + // string-range op string node + explicit str_xrox_node(SType0 p0, SType1 p1, RangePack rp0) + : s0_(p0), + s1_(p1), + rp0_(rp0) + {} + + ~str_xrox_node() { - new_expression = expression_generator_ - ( - current_state.operation, - expression, - right_branch - ); + rp0_.free(); } - - if (0 == new_expression) - { - if (error_list_.empty()) - { - set_error( - make_error(parser_error::e_syntax, - prev_token, - !synthesis_error_.empty() ? - synthesis_error_ : - "ERR08 - General parsing error at token: '" + prev_token.value + "'")); - } - - free_node(node_allocator_,expression); - - return error_node(); + + inline T value() const + { + std::size_t r0 = 0; + std::size_t r1 = 0; + + if (rp0_(r0,r1,s0_.size())) + return Operation::process(s0_.substr(r0,(r1 - r0) + 1),s1_); + else + return T(0); } - else + + inline typename expression_node::node_type type() const { - expression = new_expression; - - if (token_is(token_t::e_ternary,false) && (precedence == e_level00)) - { - expression = parse_ternary_conditional_statement(expression); - } - - parse_pending_string_rangesize(expression); + return Operation::type(); } - } - - return expression; - } - - bool simplify_unary_negation_branch(expression_node_ptr& node) - { - { - typedef details::unary_branch_node > ubn_t; - ubn_t* n = dynamic_cast(node); - - if (n) + + inline operator_type operation() const { - expression_node_ptr un_r = n->branch(0); - n->release(); - free_node(node_allocator_,node); - node = un_r; - - return true; + return Operation::operation(); } - } - - { - typedef details::unary_variable_node > ubn_t; - - ubn_t* n = dynamic_cast(node); - - if (n) + + inline std::string& s0() { - const T& v = n->v(); - expression_node_ptr return_node = error_node(); - - if ( - (return_node = symbol_table_.get_variable(v)) || - (return_node = sem_ .get_variable(v)) - ) - { - free_node(node_allocator_,node); - node = return_node; - - return true; - } - else - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR09 - Failed to find variable node in symbol table")); - free_node(node_allocator_,node); - - return false; - } + return s0_; } - } - - return false; - } - - static inline expression_node_ptr error_node() - { - return reinterpret_cast(0); - } - - template - struct scoped_delete - { - typedef Type* ptr_t; - - scoped_delete(parser& pr, ptr_t& p) - : delete_ptr(true), - parser_(pr), - p_(&p) - {} - - scoped_delete(parser& pr, ptr_t (&p)[N]) - : delete_ptr(true), - parser_(pr), - p_(&p[0]) - {} - - ~scoped_delete() - { - if (delete_ptr) + + inline std::string& s1() { - for (std::size_t i = 0; i < N; ++i) - { - free_node(parser_.node_allocator_,p_[i]); - } + return s1_; } - } - - bool delete_ptr; - parser& parser_; - ptr_t* p_; - - private: - - scoped_delete& operator=(const scoped_delete&); - }; - - template - struct scoped_deq_delete - { - typedef Type* ptr_t; - - scoped_deq_delete(parser& pr, std::deque& deq) - : delete_ptr(true), - parser_(pr), - deq_(deq) - {} - - ~scoped_deq_delete() - { - if (delete_ptr && !deq_.empty()) - { - for (std::size_t i = 0; i < deq_.size(); ++i) - { - free_node(parser_.node_allocator_,deq_[i]); - } - - deq_.clear(); + + protected: + + SType0 s0_; + SType1 s1_; + RangePack rp0_; + + private: + + str_xrox_node(str_xrox_node&); + str_xrox_node& operator=(str_xrox_node&); + }; + + template + class str_xoxr_node : public sos_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef Operation operation_t; + + // string op string range node + explicit str_xoxr_node(SType0 p0, SType1 p1, RangePack rp1) + : s0_ (p0 ), + s1_ (p1 ), + rp1_(rp1) + {} + + ~str_xoxr_node() + { + rp1_.free(); } - } - - bool delete_ptr; - parser& parser_; - std::deque& deq_; - - private: - - scoped_deq_delete& operator=(const scoped_deq_delete&); - }; - - template - struct scoped_vec_delete - { - typedef Type* ptr_t; - - scoped_vec_delete(parser& pr, std::vector& vec) - : delete_ptr(true), - parser_(pr), - vec_(vec) - {} - - ~scoped_vec_delete() - { - if (delete_ptr && !vec_.empty()) - { - for (std::size_t i = 0; i < vec_.size(); ++i) - { - free_node(parser_.node_allocator_,vec_[i]); - } - - vec_.clear(); + + inline T value() const + { + std::size_t r0 = 0; + std::size_t r1 = 0; + + if (rp1_(r0,r1,s1_.size())) + return Operation::process(s0_,s1_.substr(r0,(r1 - r0) + 1)); + else + return T(0); } - } - - bool delete_ptr; - parser& parser_; - std::vector& vec_; - - private: - - scoped_vec_delete& operator=(const scoped_vec_delete&); - }; - - inline expression_node_ptr parse_function_invocation(ifunction* function, const std::string& function_name) - { - expression_node_ptr func_node = reinterpret_cast(0); - - switch (function->param_count) - { - case 0 : func_node = parse_function_call_0 (function,function_name); break; - case 1 : func_node = parse_function_call< 1>(function,function_name); break; - case 2 : func_node = parse_function_call< 2>(function,function_name); break; - case 3 : func_node = parse_function_call< 3>(function,function_name); break; - case 4 : func_node = parse_function_call< 4>(function,function_name); break; - case 5 : func_node = parse_function_call< 5>(function,function_name); break; - case 6 : func_node = parse_function_call< 6>(function,function_name); break; - case 7 : func_node = parse_function_call< 7>(function,function_name); break; - case 8 : func_node = parse_function_call< 8>(function,function_name); break; - case 9 : func_node = parse_function_call< 9>(function,function_name); break; - case 10 : func_node = parse_function_call<10>(function,function_name); break; - case 11 : func_node = parse_function_call<11>(function,function_name); break; - case 12 : func_node = parse_function_call<12>(function,function_name); break; - case 13 : func_node = parse_function_call<13>(function,function_name); break; - case 14 : func_node = parse_function_call<14>(function,function_name); break; - case 15 : func_node = parse_function_call<15>(function,function_name); break; - case 16 : func_node = parse_function_call<16>(function,function_name); break; - case 17 : func_node = parse_function_call<17>(function,function_name); break; - case 18 : func_node = parse_function_call<18>(function,function_name); break; - case 19 : func_node = parse_function_call<19>(function,function_name); break; - case 20 : func_node = parse_function_call<20>(function,function_name); break; - default : { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR10 - Invalid number of parameters for function: '" + function_name + "'")); - - return error_node(); - } - } - - if (func_node) - return func_node; - else - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR11 - Failed to generate call to function: '" + function_name + "'")); - - return error_node(); - } - } - - template - inline expression_node_ptr parse_function_call(ifunction* function, const std::string& function_name) - { - if (0 == NumberofParameters) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR12 - Expecting ifunction '" + function_name + "' to have non-zero parameter count")); - - return error_node(); - } - - expression_node_ptr branch[NumberofParameters]; - expression_node_ptr result = error_node(); - - std::fill_n(branch,NumberofParameters,reinterpret_cast(0)); - scoped_delete sd(*this,branch); - - next_token(); - - if (!token_is(token_t::e_lbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR13 - Expecting argument list for function: '" + function_name + "'")); - - return error_node(); - } - - for (int i = 0; i < static_cast(NumberofParameters); ++i) - { - branch[i] = parse_expression(); - - if (0 == branch[i]) + + inline typename expression_node::node_type type() const { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR14 - Failed to parse argument " + details::to_str(i) + " for function: '" + function_name + "'")); - - return error_node(); + return Operation::type(); } - else if (i < static_cast(NumberofParameters - 1)) + + inline operator_type operation() const { - if (!token_is(token_t::e_comma)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR15 - Invalid number of arguments for function: '" + function_name + "'")); - - return error_node(); - } + return Operation::operation(); } - } - - if (!token_is(token_t::e_rbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR16 - Invalid number of arguments for function: '" + function_name + "'")); - - return error_node(); - } - else - result = expression_generator_.function(function,branch); - - sd.delete_ptr = false; - - return result; - } - - inline expression_node_ptr parse_function_call_0(ifunction* function, const std::string& function_name) - { - expression_node_ptr result = expression_generator_.function(function); - next_token(); - if ( - token_is(token_t::e_lbracket) && - !token_is(token_t::e_rbracket) - ) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR17 - Expecting '()' to proceed call to function: '" + function_name + "'")); - - free_node(node_allocator_,result); - - return error_node(); - } - else - return result; - } - - template - inline int parse_base_function_call(expression_node_ptr (¶m_list)[MaxNumberofParameters]) - { - std::fill_n(param_list,MaxNumberofParameters,reinterpret_cast(0)); - - scoped_delete sd(*this,param_list); - - next_token(); - - if (!token_is(token_t::e_lbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR18 - Expected a '(' at start of function call, instead got: '" + current_token_.value + "'")); - - return 0; - } - - int param_index = 0; - - for (; param_index < static_cast(MaxNumberofParameters); ++param_index) - { - param_list[param_index] = parse_expression(); - - if (0 == param_list[param_index]) + + inline std::string& s0() { - return 0; + return s0_; } - else if (token_is(token_t::e_rbracket)) - break; - else if (token_is(token_t::e_comma)) - continue; - else + + inline std::string& s1() { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR19 - Expected a ',' between function input parameters, instead got: '" + current_token_.value + "'")); - - return 0; + return s1_; } - } - - sd.delete_ptr = false; - - return (param_index + 1); - } - - inline expression_node_ptr parse_base_operation() - { - typedef std::pair map_range_t; - - const std::string operation_name = current_token_.value; - map_range_t itr_range = base_ops_map_.equal_range(operation_name); - - if (0 == std::distance(itr_range.first,itr_range.second)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR20 - No entry found for base operation: " + operation_name)); - - return error_node(); - } - - const std::size_t MaxNumberofParameters = 6; - expression_node_ptr param_list[MaxNumberofParameters] = {0}; - - std::size_t parameter_count = parse_base_function_call(param_list); - - if (0 == parameter_count) - { - return error_node(); - } - else if (parameter_count <= 6) - { - for (base_ops_map_t::iterator itr = itr_range.first; itr != itr_range.second; ++itr) + + protected: + + SType0 s0_; + SType1 s1_; + RangePack rp1_; + + private: + + str_xoxr_node(str_xoxr_node&); + str_xoxr_node& operator=(str_xoxr_node&); + }; + + template + class str_xroxr_node : public sos_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef Operation operation_t; + + // string-range op string-range node + explicit str_xroxr_node(SType0 p0, SType1 p1, RangePack rp0, RangePack rp1) + : s0_ (p0 ), + s1_ (p1 ), + rp0_(rp0), + rp1_(rp1) + {} + + ~str_xroxr_node() + { + rp0_.free(); + rp1_.free(); + } + + inline T value() const + { + std::size_t r0_0 = 0; + std::size_t r0_1 = 0; + std::size_t r1_0 = 0; + std::size_t r1_1 = 0; + if ( + rp0_(r0_0,r1_0,s0_.size()) && + rp1_(r0_1,r1_1,s1_.size()) + ) + { + return Operation::process( + s0_.substr(r0_0,(r1_0 - r0_0) + 1), + s1_.substr(r0_1,(r1_1 - r0_1) + 1) + ); + } + else + return T(0); + } + + inline typename expression_node::node_type type() const + { + return Operation::type(); + } + + inline operator_type operation() const + { + return Operation::operation(); + } + + inline std::string& s0() + { + return s0_; + } + + inline std::string& s1() + { + return s1_; + } + + protected: + + SType0 s0_; + SType1 s1_; + RangePack rp0_; + RangePack rp1_; + + private: + + str_xroxr_node(str_xroxr_node&); + str_xroxr_node& operator=(str_xroxr_node&); + }; + + template + class str_sogens_node : public binary_node + { + public: + + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; + typedef range_pack range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + + str_sogens_node(const operator_type& opr, + expression_ptr branch0, + expression_ptr branch1) + : binary_node(opr,branch0,branch1), + str0_base_ptr_ (0), + str1_base_ptr_ (0), + str0_range_ptr_(0), + str1_range_ptr_(0) + { + if (is_generally_string_node(binary_node::branch_[0].first)) + { + str0_base_ptr_ = dynamic_cast(binary_node::branch_[0].first); + + if (0 == str0_base_ptr_) + return; + + irange_ptr range_ptr = dynamic_cast(binary_node::branch_[0].first); + + if (0 == range_ptr) + return; + + str0_range_ptr_ = &(range_ptr->range_ref()); + } + + if (is_generally_string_node(binary_node::branch_[1].first)) + { + str1_base_ptr_ = dynamic_cast(binary_node::branch_[1].first); + + if (0 == str1_base_ptr_) + return; + + irange_ptr range_ptr = dynamic_cast(binary_node::branch_[1].first); + + if (0 == range_ptr) + return; + + str1_range_ptr_ = &(range_ptr->range_ref()); + } + } + + inline T value() const + { + if ( + str0_base_ptr_ && + str1_base_ptr_ && + str0_range_ptr_ && + str1_range_ptr_ + ) + { + binary_node::branch_[0].first->value(); + binary_node::branch_[1].first->value(); + + std::size_t str0_r0 = 0; + std::size_t str0_r1 = 0; + + std::size_t str1_r0 = 0; + std::size_t str1_r1 = 0; + + range_t& range0 = (*str0_range_ptr_); + range_t& range1 = (*str1_range_ptr_); + + if ( + range0(str0_r0,str0_r1,str0_base_ptr_->size()) && + range1(str1_r0,str1_r1,str1_base_ptr_->size()) + ) + { + return Operation::process( + str0_base_ptr_->str().substr(str0_r0,(str0_r1 - str0_r0) + 1), + str1_base_ptr_->str().substr(str1_r0,(str1_r1 - str1_r0) + 1) + ); + } + } + + return std::numeric_limits::quiet_NaN(); + } + + inline typename expression_node::node_type type() const + { + return Operation::type(); + } + + inline operator_type operation() const + { + return Operation::operation(); + } + + private: + + str_sogens_node(str_sogens_node&); + str_sogens_node& operator=(str_sogens_node&); + + str_base_ptr str0_base_ptr_; + str_base_ptr str1_base_ptr_; + range_ptr str0_range_ptr_; + range_ptr str1_range_ptr_; + }; + + template + class sosos_node : public sosos_base_node + { + public: + + typedef expression_node* expression_ptr; + typedef Operation operation_t; + + // variable op variable node + explicit sosos_node(SType0 p0, SType1 p1, SType2 p2) + : s0_(p0), + s1_(p1), + s2_(p2) + {} + + inline T value() const { - details::base_operation_t& operation = itr->second; - - if (operation.num_params == parameter_count) - { - switch (parameter_count) - { - #define base_opr_case(N) \ - case N : { \ - expression_node_ptr pl##N[N] = {0}; \ - std::copy(param_list,param_list + N,pl##N); \ - lodge_symbol(operation_name,e_st_function); \ - return expression_generator_(operation.type,pl##N);\ - } \ - - base_opr_case(1) - base_opr_case(2) - base_opr_case(3) - base_opr_case(4) - base_opr_case(5) - base_opr_case(6) - #undef base_opr_case - } - } - } - } - - for (std::size_t i = 0; i < MaxNumberofParameters; ++i) - { - free_node(node_allocator_,param_list[i]); - } - - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR21 - Invalid number of parameters for call to function: '" + operation_name + "'")); - - return error_node(); - } - - inline expression_node_ptr parse_conditional_statement_01(expression_node_ptr condition) - { - // Parse: [if][(][condition][,][consequent][,][alternative][)] - - expression_node_ptr consequent = error_node(); - expression_node_ptr alternative = error_node(); - - bool result = true; - - if (!token_is(token_t::e_comma)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR22 - Expected ',' between if-statement condition and consequent")); - result = false; - } - else if (0 == (consequent = parse_expression())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR23 - Failed to parse consequent for if-statement")); - result = false; - } - else if (!token_is(token_t::e_comma)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR24 - Expected ',' between if-statement consequent and alternative")); - result = false; - } - else if (0 == (alternative = parse_expression())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR25 - Failed to parse alternative for if-statement")); - result = false; - } - else if (!token_is(token_t::e_rbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR26 - Expected ')' at the end of if-statement")); - result = false; - } - - if (!result) - { - free_node(node_allocator_, condition); - free_node(node_allocator_, consequent); - free_node(node_allocator_,alternative); - - return error_node(); - } - else - return expression_generator_.conditional(condition,consequent,alternative); - } - - inline expression_node_ptr parse_conditional_statement_02(expression_node_ptr condition) - { - expression_node_ptr consequent = error_node(); - expression_node_ptr alternative = error_node(); - - bool result = true; - - if (token_is(token_t::e_lcrlbracket,false)) - { - if (0 == (consequent = parse_multi_sequence("if-statement-01"))) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR27 - Failed to parse body of consequent for if-statement")); - result = false; - } - } - else - { - if ( - commutative_check_enabled() && - token_is(token_t::e_mul,false) - ) + return Operation::process(s0_,s1_,s2_); + } + + inline typename expression_node::node_type type() const { - next_token(); + return Operation::type(); } - - if (0 != (consequent = parse_expression())) + + inline operator_type operation() const { - if (!token_is(token_t::e_eof)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR28 - Expected ';' at the end of the consequent for if-statement")); - result = false; - } + return Operation::operation(); } - else + + inline std::string& s0() { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR29 - Failed to parse body of consequent for if-statement")); - result = false; + return s0_; } - } - - if (result) - { - if (details::imatch(current_token_.value,"else")) + + inline std::string& s1() { - next_token(); - - if (token_is(token_t::e_lcrlbracket,false)) - { - if (0 == (alternative = parse_multi_sequence("else-statement-01"))) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR30 - Failed to parse body of the 'else' for if-statement")); - result = false; - } - } - else if (details::imatch(current_token_.value,"if")) - { - if (0 == (alternative = parse_conditional_statement())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR31 - Failed to parse body of if-else statement")); - result = false; - } - } - else if (0 != (alternative = parse_expression())) - { - if (!token_is(token_t::e_eof)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR32 - Expected ';' at the end of the 'else-if' for the if-statement")); - result = false; - } - } - else - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR33 - Failed to parse body of the 'else' for if-statement")); - result = false; - } - } - } - - if (!result) - { - free_node(node_allocator_, condition); - free_node(node_allocator_, consequent); - free_node(node_allocator_,alternative); - - return error_node(); - } - else - return expression_generator_.conditional(condition,consequent,alternative); - } - - inline expression_node_ptr parse_conditional_statement() - { - expression_node_ptr condition = error_node(); - - next_token(); - - if (!token_is(token_t::e_lbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR34 - Expected '(' at start of if-statement, instead got: '" + current_token_.value + "'")); - - return error_node(); - } - else if (0 == (condition = parse_expression())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR35 - Failed to parse condition for if-statement")); - - return error_node(); - } - else if (token_is(token_t::e_comma,false)) - { - // if (x,y,z) - return parse_conditional_statement_01(condition); - } - else if (token_is(token_t::e_rbracket)) - { - // 00. if (x) y; - // 01. if (x) y; else z; - // 02. if (x) y; else {z0; ... zn;} - // 03. if (x) y; else if (z) w; - // 04. if (x) y; else if (z) w; else u; - // 05. if (x) y; else if (z) w; else {u0; ... un;} - // 06. if (x) y; else if (z) {w0; ... wn;} - // 07. if (x) {y0; ... yn;} - // 08. if (x) {y0; ... yn;} else z; - // 09. if (x) {y0; ... yn;} else {z0; ... zn;}; - // 10. if (x) {y0; ... yn;} else if (z) w; - // 11. if (x) {y0; ... yn;} else if (z) w; else u; - // 12. if (x) {y0; ... nex;} else if (z) w; else {u0 ... un;} - // 13. if (x) {y0; ... yn;} else if (z) {w0; ... wn;} - return parse_conditional_statement_02(condition); - } - - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR36 - Invalid if-statement")); - - free_node(node_allocator_,condition); - - return error_node(); - } - - inline expression_node_ptr parse_ternary_conditional_statement(expression_node_ptr condition) - { - // Parse: [condition][?][consequent][:][alternative] - expression_node_ptr consequent = error_node(); - expression_node_ptr alternative = error_node(); - - bool result = true; - - if (0 == condition) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR37 - Encountered invalid condition branch for ternary if-statement")); - - return error_node(); - } - else if (!token_is(token_t::e_ternary)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR38 - Expected '?' after condition of ternary if-statement")); - - result = false; - } - else if (0 == (consequent = parse_expression())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR39 - Failed to parse consequent for if-statement")); - - result = false; - } - else if (!token_is(token_t::e_colon)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR40 - Expected ':' between ternary if-statement consequent and alternative")); - - result = false; - } - else if (0 == (alternative = parse_expression())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR41 - Failed to parse alternative for if-statement")); - - result = false; - } - - if (!result) - { - free_node(node_allocator_, condition); - free_node(node_allocator_, consequent); - free_node(node_allocator_,alternative); - - return error_node(); - } - else - return expression_generator_.conditional(condition,consequent,alternative); - } - - inline expression_node_ptr parse_while_loop() - { - // Parse: [while][(][test expr][)][{][expression][}] - expression_node_ptr condition = error_node(); - expression_node_ptr branch = error_node(); - expression_node_ptr result_node = error_node(); - - bool result = true; - - next_token(); - - if (!token_is(token_t::e_lbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR42 - Expected '(' at start of while-loop condition statement")); - - return error_node(); - } - else if (0 == (condition = parse_expression())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR43 - Failed to parse condition for while-loop")); - - return error_node(); - } - else if (!token_is(token_t::e_rbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR44 - Expected ')' at end of while-loop condition statement")); - result = false; - } - - brkcnt_list_.push_front(false); - - if (result) - { - if (0 == (branch = parse_multi_sequence("while-loop"))) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR45 - Failed to parse body of while-loop")); - result = false; - } - else if (0 == (result_node = expression_generator_.while_loop(condition, - branch, - brkcnt_list_.front()))) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR46 - Failed to synthesize while-loop")); - result = false; - } - } - - if (!result) - { - free_node(node_allocator_, branch); - free_node(node_allocator_, condition); - free_node(node_allocator_,result_node); - - brkcnt_list_.pop_front(); - - return error_node(); - } - else - return result_node; - } - - inline expression_node_ptr parse_repeat_until_loop() - { - // Parse: [repeat][{][expression][}][until][(][test expr][)] - expression_node_ptr condition = error_node(); - expression_node_ptr branch = error_node(); - next_token(); - - std::vector arg_list; - scoped_vec_delete sdd(*this,arg_list); - - brkcnt_list_.push_front(false); - - if (details::imatch(current_token_.value,"until")) - { - next_token(); - branch = node_allocator_.allocate >(); - } - else - { - token_t::token_type seperator = token_t::e_eof; - - scope_handler sh(*this); - - for (;;) + return s1_; + } + + inline std::string& s2() { - expression_node_ptr arg = parse_expression(); - - if (0 == arg) - return error_node(); - else - arg_list.push_back(arg); - - if (details::imatch(current_token_.value,"until")) - { - next_token(); - break; - } - - bool is_next_until = peek_token_is(token_t::e_symbol) && - peek_token_is("until"); - - if (!token_is(seperator) && is_next_until) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR47 - Expected '" + token_t::to_str(seperator) + "' for body of repeat until loop")); - - return error_node(); - } - - if (details::imatch(current_token_.value,"until")) - { - next_token(); - break; - } + return s2_; } - - branch = simplify(arg_list); - - if ((sdd.delete_ptr = (0 == branch))) + + protected: + + SType0 s0_; + SType1 s1_; + SType2 s2_; + + private: + + sosos_node(sosos_node&); + sosos_node& operator=(sosos_node&); + }; +#endif + + template + class ipow_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef PowOp operation_t; + + explicit ipow_node(const T& v) + : v_(v) + {} + + inline T value() const { - brkcnt_list_.pop_front(); - - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR48 - Failed to parse body of repeat until loop")); - - return error_node(); + return PowOp::result(v_); } - } - - if (!token_is(token_t::e_lbracket)) - { - brkcnt_list_.pop_front(); - - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR49 - Expected '(' before condition statement of repeat until loop")); - - free_node(node_allocator_,branch); - - return error_node(); - } - else if (0 == (condition = parse_expression())) - { - brkcnt_list_.pop_front(); - - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR50 - Failed to parse condition for repeat until loop")); - - free_node(node_allocator_,branch); - - return error_node(); - } - else if (!token_is(token_t::e_rbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR51 - Expected ')' after condition of repeat until loop")); - - free_node(node_allocator_, branch); - free_node(node_allocator_, condition); - - brkcnt_list_.pop_front(); - - return error_node(); - } - - expression_node_ptr result; - - result = expression_generator_ - .repeat_until_loop(condition,branch,brkcnt_list_.front()); - - if (0 == result) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR52 - Failed to synthesize repeat until loop")); - - free_node(node_allocator_, condition); - brkcnt_list_.pop_front(); - - return error_node(); - } - else - { - brkcnt_list_.pop_front(); - return result; - } - } - - inline expression_node_ptr parse_for_loop() - { - expression_node_ptr initialiser = error_node(); - expression_node_ptr condition = error_node(); - expression_node_ptr incrementor = error_node(); - expression_node_ptr loop_body = error_node(); - - scope_element* se = 0; - bool result = true; - std::string loop_counter_symbol; - - next_token(); - - scope_handler sh(*this); - - if (!token_is(token_t::e_lbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR53 - Expected '(' at start of for-loop")); - - return error_node(); - } - - if (!token_is(token_t::e_eof)) - { - if ( - !token_is(token_t::e_symbol,false) && - details::imatch(current_token_.value,"var") - ) + + inline typename expression_node::node_type type() const { - next_token(); - - if (!token_is(token_t::e_symbol,false)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR54 - Expected a variable at the start of initialiser section of for-loop")); - - return error_node(); - } - else if (!peek_token_is(token_t::e_assign)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR55 - Expected variable assignment of initialiser section of for-loop")); - - return error_node(); - } - - loop_counter_symbol = current_token_.value; - - se = &sem_.get_element(loop_counter_symbol); - - if ((se->name == loop_counter_symbol) && se->active) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR56 - For-loop variable '" + loop_counter_symbol+ "' is being shadowed by a previous declaration")); - - return error_node(); - } - else if (!symbol_table_.is_variable(loop_counter_symbol)) - { - if ( - !se->active && - (se->name == loop_counter_symbol) && - (se->type == scope_element::e_variable) - ) - { - se->active = true; - se->ref_count++; - } - else - { - scope_element nse; - nse.name = loop_counter_symbol; - nse.type = scope_element::e_variable; - nse.depth = scope_depth_; - nse.data = new T(T(0)); - nse.var_node = new variable_node_t(*(T*)(nse.data)); - - if (!sem_.add_element(nse)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR57 - Failed to add new local variable '" + loop_counter_symbol + "' to SEM")); - - result = false; - - } - else - exprtk_debug(("parse_for_loop() - INFO - Added new local variable: %s\n",nse.name.c_str())); - } - } + return expression_node::e_ipow; } - - if (0 == (initialiser = parse_expression())) + + private: + + ipow_node(const ipow_node&); + ipow_node& operator=(const ipow_node&); + + const T& v_; + }; + + template + class bipow_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef std::pair branch_t; + typedef PowOp operation_t; + + explicit bipow_node(expression_ptr brnch) + { + init_branches<1>(branch_, brnch); + } + + ~bipow_node() + { + cleanup_branches::execute(branch_); + } + + inline T value() const + { + return PowOp::result(branch_[0].first->value()); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_ipow; + } + + private: + + bipow_node(const bipow_node&); + bipow_node& operator=(const bipow_node&); + + branch_t branch_[1]; + }; + + template + class ipowinv_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef PowOp operation_t; + + explicit ipowinv_node(const T& v) + : v_(v) + {} + + inline T value() const { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR58 - Failed to parse initialiser of for-loop")); - result = false; + return (T(1) / PowOp::result(v_)); } - - if (!token_is(token_t::e_eof)) + + inline typename expression_node::node_type type() const { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR59 - Expected ';' after initialiser of for-loop")); - result = false; + return expression_node::e_ipowinv; } - } - - if (!token_is(token_t::e_eof)) - { - if (0 == (condition = parse_expression())) + + private: + + ipowinv_node(const ipowinv_node&); + ipowinv_node& operator=(const ipowinv_node&); + + const T& v_; + }; + + template + class bipowninv_node : public expression_node + { + public: + + typedef expression_node* expression_ptr; + typedef std::pair branch_t; + typedef PowOp operation_t; + + explicit bipowninv_node(expression_ptr brnch) + { + init_branches<1>(branch_, brnch); + } + + ~bipowninv_node() + { + cleanup_branches::execute(branch_); + } + + inline T value() const + { + return (T(1) / PowOp::result(branch_[0].first->value())); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_ipowinv; + } + + private: + + bipowninv_node(const bipowninv_node&); + bipowninv_node& operator=(const bipowninv_node&); + + branch_t branch_[1]; + }; + + template + inline bool is_vov_node(const expression_node* node) + { + return (0 != dynamic_cast*>(node)); + } + + template + inline bool is_cov_node(const expression_node* node) + { + return (0 != dynamic_cast*>(node)); + } + + template + inline bool is_voc_node(const expression_node* node) + { + return (0 != dynamic_cast*>(node)); + } + + template + inline bool is_cob_node(const expression_node* node) + { + return (0 != dynamic_cast*>(node)); + } + + template + inline bool is_boc_node(const expression_node* node) + { + return (0 != dynamic_cast*>(node)); + } + + template + inline bool is_t0ot1ot2_node(const expression_node* node) + { + return (0 != dynamic_cast*>(node)); + } + + template + inline bool is_t0ot1ot2ot3_node(const expression_node* node) + { + return (0 != dynamic_cast*>(node)); + } + + template + inline bool is_uv_node(const expression_node* node) + { + return (0 != dynamic_cast*>(node)); + } + + template + inline bool is_string_node(const expression_node* node) + { + return node && (expression_node::e_stringvar == node->type()); + } + + template + inline bool is_string_range_node(const expression_node* node) + { + return node && (expression_node::e_stringvarrng == node->type()); + } + + template + inline bool is_const_string_node(const expression_node* node) + { + return node && (expression_node::e_stringconst == node->type()); + } + + template + inline bool is_const_string_range_node(const expression_node* node) + { + return node && (expression_node::e_cstringvarrng == node->type()); + } + + template + inline bool is_string_assignment_node(const expression_node* node) + { + return node && (expression_node::e_strass == node->type()); + } + + template + inline bool is_string_concat_node(const expression_node* node) + { + return node && (expression_node::e_strconcat == node->type()); + } + + template + inline bool is_string_function_node(const expression_node* node) + { + return node && (expression_node::e_strfunction == node->type()); + } + + template + inline bool is_string_condition_node(const expression_node* node) + { + return node && (expression_node::e_strcondition == node->type()); + } + + template + inline bool is_string_ccondition_node(const expression_node* node) + { + return node && (expression_node::e_strccondition == node->type()); + } + + template + inline bool is_genricstring_range_node(const expression_node* node) + { + return node && (expression_node::e_strgenrange == node->type()); + } + + template + inline bool is_generally_string_node(const expression_node* node) + { + if (node) + { + switch (node->type()) + { + case expression_node::e_stringvar : + case expression_node::e_stringconst : + case expression_node::e_stringvarrng : + case expression_node::e_cstringvarrng : + case expression_node::e_strgenrange : + case expression_node::e_strass : + case expression_node::e_strconcat : + case expression_node::e_strfunction : + case expression_node::e_strcondition : + case expression_node::e_strccondition : return true; + default : return false; + } + } + + return false; + } + + class node_allocator + { + public: + + template + inline expression_node* allocate(OpType& operation, ExprNode (&branch)[1]) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR60 - Failed to parse condition of for-loop")); - result = false; + return allocate(operation,branch[0]); } - else if (!token_is(token_t::e_eof)) + + template + inline expression_node* allocate(OpType& operation, ExprNode (&branch)[2]) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR61 - Expected ';' after condition section of for-loop")); - result = false; + return allocate(operation,branch[0],branch[1]); } - } - - if (!token_is(token_t::e_rbracket)) - { - if (0 == (incrementor = parse_expression())) + + template + inline expression_node* allocate(OpType& operation, ExprNode (&branch)[3]) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR62 - Failed to parse incrementor of for-loop")); - result = false; + return allocate(operation,branch[0],branch[1],branch[2]); } - else if (!token_is(token_t::e_rbracket)) + + template + inline expression_node* allocate(OpType& operation, ExprNode (&branch)[4]) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR63 - Expected ')' after incrementor section of for-loop")); - result = false; + return allocate(operation,branch[0],branch[1],branch[2],branch[3]); } - } - - if (result) - { - brkcnt_list_.push_front(false); - if (0 == (loop_body = parse_multi_sequence("for-loop"))) + + template + inline expression_node* allocate(OpType& operation, ExprNode (&branch)[5]) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR64 - Failed to parse body of for-loop")); - result = false; + return allocate(operation,branch[0],branch[1],branch[2],branch[3],branch[4]); } - } - - if (!result) - { - if (se) + + template + inline expression_node* allocate(OpType& operation, ExprNode (&branch)[6]) { - se->ref_count--; + return allocate(operation,branch[0],branch[1],branch[2],branch[3],branch[4],branch[5]); } - - sem_.cleanup(); - - free_node(node_allocator_,initialiser); - free_node(node_allocator_, condition); - free_node(node_allocator_,incrementor); - free_node(node_allocator_, loop_body); - - if (!brkcnt_list_.empty()) + + template + inline expression_node* allocate() const { - brkcnt_list_.pop_front(); + return new node_type(); } - - return error_node(); - } - else - { - expression_node_ptr result_node = - expression_generator_.for_loop(initialiser, - condition, - incrementor, - loop_body, - brkcnt_list_.front()); - brkcnt_list_.pop_front(); - - return result_node; - } - } - - inline expression_node_ptr parse_switch_statement() - { - std::vector arg_list; - expression_node_ptr result = error_node(); - - if (!details::imatch(current_token_.value,"switch")) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR65 - Expected keyword 'switch'")); - - return error_node(); - } - - scoped_vec_delete svd(*this,arg_list); - - next_token(); - - if (!token_is(token_t::e_lcrlbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR66 - Expected '{' for call to switch statement")); - - return error_node(); - } - - for ( ; ; ) - { - if (!details::imatch("case",current_token_.value)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR67 - Expected either a 'case' or 'default' statement")); - - return error_node(); + + template class Sequence> + inline expression_node* allocate(const Sequence& seq) const + { + return new node_type(seq); } - - next_token(); - - expression_node_ptr condition = parse_expression(); - - if (0 == condition) - return error_node(); - else if (!token_is(token_t::e_colon)) + + template + inline expression_node* allocate(T1& t1) const { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR68 - Expected ':' for case of switch statement")); - - return error_node(); + return new node_type(t1); } - - expression_node_ptr consequent = parse_expression(); - - if (0 == consequent) - return error_node(); - else if (!token_is(token_t::e_eof)) + + template + inline expression_node* allocate_c(const T1& t1) const { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR69 - Expected ';' at end of case for switch statement")); - - return error_node(); + return new node_type(t1); } - - // Can we optimize away the case statement? - if (is_constant_node(condition) && is_false(condition)) + + template + inline expression_node* allocate(const T1& t1, const T2& t2) const { - free_node(node_allocator_, condition); - free_node(node_allocator_,consequent); - - condition = 0; - consequent = 0; - } - else - { - arg_list.push_back(condition); - arg_list.push_back(consequent); - } - - if (details::imatch("default",current_token_.value)) - { - next_token(); - if (!token_is(token_t::e_colon)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR70 - Expected ':' for default of switch statement")); - - return error_node(); - } - - expression_node_ptr default_statement = parse_expression(); - - if (0 == default_statement) - return error_node(); - else if (!token_is(token_t::e_eof)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR71 - Expected ';' at end of default for switch statement")); - - return error_node(); - } - - arg_list.push_back(default_statement); - break; - } - } - - if (!token_is(token_t::e_rcrlbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR72 - Expected '}' at end of switch statement")); - - return error_node(); - } - - result = expression_generator_.switch_statement(arg_list); - - svd.delete_ptr = (0 == result); - - return result; - } - - inline expression_node_ptr parse_multi_switch_statement() - { - std::vector arg_list; - expression_node_ptr result = error_node(); - - if (!details::imatch(current_token_.value,"[*]")) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR73 - Expected token '[*]'")); - - return error_node(); - } - - scoped_vec_delete svd(*this,arg_list); - - next_token(); - - if (!token_is(token_t::e_lcrlbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR74 - Expected '{' for call to [*] statement")); - - return error_node(); - } - - for ( ; ; ) - { - if (!details::imatch("case",current_token_.value)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR75 - Expected a 'case' statement for multi-switch")); - - return error_node(); + return new node_type(t1,t2); } - - next_token(); - - expression_node_ptr condition = parse_expression(); - - if (0 == condition) - return error_node(); - - if (!token_is(token_t::e_colon)) + + template + inline expression_node* allocate_cr(const T1& t1, T2& t2) const { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR76 - Expected ':' for case of [*] statement")); - - return error_node(); + return new node_type(t1,t2); } - - expression_node_ptr consequent = parse_expression(); - - if (0 == consequent) - return error_node(); - - if (!token_is(token_t::e_eof)) + + template + inline expression_node* allocate_rc(T1& t1, const T2& t2) const { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR77 - Expected ';' at end of case for [*] statement")); - - return error_node(); + return new node_type(t1,t2); } - - // Can we optimize away the case statement? - if (is_constant_node(condition) && is_false(condition)) + + template + inline expression_node* allocate_rr(T1& t1, T2& t2) const { - free_node(node_allocator_, condition); - free_node(node_allocator_,consequent); - - condition = 0; - consequent = 0; + return new node_type(t1,t2); } - else + + template + inline expression_node* allocate_tt(T1 t1, T2 t2) const { - arg_list.push_back(condition); - arg_list.push_back(consequent); + return new node_type(t1,t2); } - - if (token_is(token_t::e_rcrlbracket,false)) + + template + inline expression_node* allocate_ttt(T1 t1, T2 t2, T3 t3) const { - break; + return new node_type(t1,t2,t3); } - } - - if (!token_is(token_t::e_rcrlbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR78 - Expected '}' at end of [*] statement")); - - return error_node(); - } - - result = expression_generator_.multi_switch_statement(arg_list); - - svd.delete_ptr = (0 == result); - - return result; - } - - inline expression_node_ptr parse_vararg_function() - { - std::vector arg_list; - expression_node_ptr result = error_node(); - - details::operator_type opt_type = details::e_default; - const std::string symbol = current_token_.value; - - if (details::imatch(symbol,"~")) - { - next_token(); - return parse_multi_sequence(); - } - else if (details::imatch(symbol,"[*]")) - { - return parse_multi_switch_statement(); - } - else if (details::imatch(symbol,"avg" )) opt_type = details::e_avg; - else if (details::imatch(symbol,"mand")) opt_type = details::e_mand; - else if (details::imatch(symbol,"max" )) opt_type = details::e_max; - else if (details::imatch(symbol,"min" )) opt_type = details::e_min; - else if (details::imatch(symbol,"mor" )) opt_type = details::e_mor; - else if (details::imatch(symbol,"mul" )) opt_type = details::e_prod; - else if (details::imatch(symbol,"sum" )) opt_type = details::e_sum; - else - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR79 - Unsupported vararg function: " + symbol)); - - return error_node(); - } - - scoped_vec_delete sdd(*this,arg_list); - - next_token(); - if (!token_is(token_t::e_lbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR80 - Expected '(' for call to vararg function: " + symbol)); - - return error_node(); - } - - for ( ; ; ) - { - expression_node_ptr arg = parse_expression(); - - if (0 == arg) - return error_node(); - else - arg_list.push_back(arg); - - if (token_is(token_t::e_rbracket)) - break; - else if (!token_is(token_t::e_comma)) + + template + inline expression_node* allocate_tttt(T1 t1, T2 t2, T3 t3, T4 t4) const { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR81 - Expected ',' for call to vararg function: " + symbol)); - - return error_node(); + return new node_type(t1,t2,t3,t4); } - } - - result = expression_generator_.vararg_function(opt_type,arg_list); - - sdd.delete_ptr = (0 == result); - return result; - } - - inline expression_node_ptr parse_string_range_statement(expression_node_ptr& expression) - { - if (!token_is(token_t::e_lsqrbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR82 - Expected '[' as start of string range definition")); - - free_node(node_allocator_,expression); - - return error_node(); - } - else if (token_is(token_t::e_rsqrbracket)) - { - return node_allocator_.allocate >(expression); - } - - range_t rp; - - if (!parse_range(rp,true)) - { - free_node(node_allocator_,expression); - - return error_node(); - } - - expression_node_ptr result = expression_generator_(expression,rp); - - if (0 == result) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR83 - Failed to generate string range node")); - - free_node(node_allocator_,expression); - } - - rp.clear(); - - return result; - } - - inline void parse_pending_string_rangesize(expression_node_ptr& expression) - { - const std::size_t max_rangesize_parses = 100; - std::size_t i = 0; - - while - ( - (0 != expression) && - (i++ < max_rangesize_parses) && - error_list_.empty() && - token_is(token_t::e_lsqrbracket,false) && - is_generally_string_node(expression) - ) - { - expression = parse_string_range_statement(expression); - } - } - - template class Sequence> - inline expression_node_ptr simplify(Sequence& expression_list) - { - if (expression_list.empty()) - return error_node(); - else if (1 == expression_list.size()) - return expression_list[0]; - - Sequence tmp_expression_list; - - for (std::size_t i = 0; i < (expression_list.size() - 1); ++i) - { - if (is_variable_node(expression_list[i])) - continue; - else if ( - is_constant_node(expression_list[i]) || - is_null_node (expression_list[i]) - ) + + template + inline expression_node* allocate_rrr(T1& t1, T2& t2, T3& t3) const + { + return new node_type(t1,t2,t3); + } + + template + inline expression_node* allocate_rrrr(T1& t1, T2& t2, T3& t3, T4& t4) const + { + return new node_type(t1,t2,t3,t4); + } + + template + inline expression_node* allocate_rrrrr(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5) const + { + return new node_type(t1,t2,t3,t4,t5); + } + + template + inline expression_node* allocate(const T1& t1, const T2& t2, + const T3& t3) const + { + return new node_type(t1,t2,t3); + } + + template + inline expression_node* allocate(const T1& t1, const T2& t2, + const T3& t3, const T4& t4) const + { + return new node_type(t1,t2,t3,t4); + } + + template + inline expression_node* allocate(const T1& t1, const T2& t2, + const T3& t3, const T4& t4, + const T5& t5) const + { + return new node_type(t1,t2,t3,t4,t5); + } + + template + inline expression_node* allocate(const T1& t1, const T2& t2, + const T3& t3, const T4& t4, + const T5& t5, const T6& t6) const + { + return new node_type(t1,t2,t3,t4,t5,t6); + } + + template + inline expression_node* allocate(const T1& t1, const T2& t2, + const T3& t3, const T4& t4, + const T5& t5, const T6& t6, + const T7& t7) const + { + return new node_type(t1,t2,t3,t4,t5,t6,t7); + } + + template + inline expression_node* allocate(const T1& t1, const T2& t2, + const T3& t3, const T4& t4, + const T5& t5, const T6& t6, + const T7& t7, const T8& t8) const + { + return new node_type(t1,t2,t3,t4,t5,t6,t7,t8); + } + + template + inline expression_node* allocate(const T1& t1, const T2& t2, + const T3& t3, const T4& t4, + const T5& t5, const T6& t6, + const T7& t7, const T8& t8, + const T9& t9) const + { + return new node_type(t1,t2,t3,t4,t5,t6,t7,t8,t9); + } + + template + inline expression_node* allocate(const T1& t1, const T2& t2, + const T3& t3, const T4& t4, + const T5& t5, const T6& t6, + const T7& t7, const T8& t8, + const T9& t9, const T10& t10) const + { + return new node_type(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10); + } + + template + inline expression_node* allocate_type(T1 t1, T2 t2, T3 t3) const + { + return new node_type(t1,t2,t3); + } + + template + inline expression_node* allocate_type(T1 t1, T2 t2, + T3 t3, T4 t4) const + { + return new node_type(t1,t2,t3,t4); + } + + template + inline expression_node* allocate_type(T1 t1, T2 t2, + T3 t3, T4 t4, + T5 t5) const + { + return new node_type(t1,t2,t3,t4,t5); + } + + template + inline expression_node* allocate_type(T1 t1, T2 t2, + T3 t3, T4 t4, + T5 t5, T6 t6, + T7 t7) const + { + return new node_type(t1,t2,t3,t4,t5,t6,t7); + } + + template + void inline free(expression_node*& e) const { - free_node(node_allocator_,expression_list[i]); - continue; + delete e; + e = 0; } - else - tmp_expression_list.push_back(expression_list[i]); - } - - tmp_expression_list.push_back(expression_list.back()); - expression_list.swap(tmp_expression_list); - - if (1 == expression_list.size()) - return expression_list[0]; - else - return expression_generator_.vararg_function(details::e_multi,expression_list); - } - - inline expression_node_ptr parse_multi_sequence(const std::string& source = "") - { - token_t::token_type close_bracket = token_t::e_rcrlbracket; - token_t::token_type seperator = token_t::e_eof; - - if (!token_is(token_t::e_lcrlbracket)) - { - if (token_is(token_t::e_lbracket)) + }; + + inline void load_operations_map(std::multimap& m) + { +#define register_op(Symbol,Type,Args) \ +m.insert(std::make_pair(std::string(Symbol),details::base_operation_t(Type,Args))); \ + + register_op( "abs",e_abs , 1) + register_op( "acos",e_acos , 1) + register_op( "acosh",e_acosh , 1) + register_op( "asin",e_asin , 1) + register_op( "asinh",e_asinh , 1) + register_op( "atan",e_atan , 1) + register_op( "atanh",e_atanh , 1) + register_op( "ceil",e_ceil , 1) + register_op( "cos",e_cos , 1) + register_op( "cosh",e_cosh , 1) + register_op( "exp",e_exp , 1) + register_op( "expm1",e_expm1 , 1) + register_op( "floor",e_floor , 1) + register_op( "log",e_log , 1) + register_op( "log10",e_log10 , 1) + register_op( "log2",e_log2 , 1) + register_op( "log1p",e_log1p , 1) + register_op( "round",e_round , 1) + register_op( "sin",e_sin , 1) + register_op( "sinc",e_sinc , 1) + register_op( "sinh",e_sinh , 1) + register_op( "sec",e_sec , 1) + register_op( "csc",e_csc , 1) + register_op( "sqrt",e_sqrt , 1) + register_op( "tan",e_tan , 1) + register_op( "tanh",e_tanh , 1) + register_op( "cot",e_cot , 1) + register_op( "rad2deg",e_r2d , 1) + register_op( "deg2rad",e_d2r , 1) + register_op( "deg2grad",e_d2g , 1) + register_op( "grad2deg",e_g2d , 1) + register_op( "sgn",e_sgn , 1) + register_op( "not",e_notl , 1) + register_op( "erf",e_erf , 1) + register_op( "erfc",e_erfc , 1) + register_op( "ncdf",e_ncdf , 1) + register_op( "frac",e_frac , 1) + register_op( "trunc",e_trunc , 1) + register_op( "atan2",e_atan2 , 2) + register_op( "mod",e_mod , 2) + register_op( "logn",e_logn , 2) + register_op( "pow",e_pow , 2) + register_op( "root",e_root , 2) + register_op( "roundn",e_roundn , 2) + register_op( "equal",e_equal , 2) + register_op("not_equal",e_nequal , 2) + register_op( "hypot",e_hypot , 2) + register_op( "shr",e_shr , 2) + register_op( "shl",e_shl , 2) + register_op( "clamp",e_clamp , 3) + register_op( "iclamp",e_iclamp , 3) + register_op( "inrange",e_inrange , 3) +#undef register_op + } + + } // namespace details + + class function_traits + { + public: + + function_traits() + : allow_zero_parameters_(false), + has_side_effects_(true), + min_num_args_(0), + max_num_args_(std::numeric_limits::max()) + {} + + inline bool& allow_zero_parameters() + { + return allow_zero_parameters_; + } + + inline bool& has_side_effects() + { + return has_side_effects_; + } + + std::size_t& min_num_args() + { + return min_num_args_; + } + + std::size_t& max_num_args() + { + return max_num_args_; + } + + private: + + bool allow_zero_parameters_; + bool has_side_effects_; + std::size_t min_num_args_; + std::size_t max_num_args_; + }; + + template + void enable_zero_parameters(FunctionType& func) + { + func.allow_zero_parameters() = true; + + if (0 != func.min_num_args()) + { + func.min_num_args() = 0; + } + } + + template + void disable_zero_parameters(FunctionType& func) + { + func.allow_zero_parameters() = false; + } + + template + void enable_has_side_effects(FunctionType& func) + { + func.has_side_effects() = true; + } + + template + void disable_has_side_effects(FunctionType& func) + { + func.has_side_effects() = false; + } + + template + void set_min_num_args(FunctionType& func, const std::size_t& num_args) + { + func.min_num_args() = num_args; + + if ((0 != func.min_num_args()) && func.allow_zero_parameters()) + func.allow_zero_parameters() = false; + } + + template + void set_max_num_args(FunctionType& func, const std::size_t& num_args) + { + func.max_num_args() = num_args; + } + + template + class ifunction : public function_traits + { + public: + + explicit ifunction(const std::size_t& pc) + : param_count(pc) + {} + + virtual ~ifunction() + {} + +#define empty_method_body \ +{ \ +return std::numeric_limits::quiet_NaN(); \ +} \ + + inline virtual T operator()() + empty_method_body + + inline virtual T operator()(const T&) + empty_method_body + + inline virtual T operator()(const T&,const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + empty_method_body + + inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + empty_method_body + +#undef empty_method_body + + std::size_t param_count; + }; + + template + class ivararg_function : public function_traits + { + public: + + virtual ~ivararg_function() + {} + + inline virtual T operator()(const std::vector&) + { + exprtk_debug(("ivararg_function::operator() - Operator has not been overridden.\n")); + return std::numeric_limits::quiet_NaN(); + } + }; + + template + class igeneric_function : public function_traits + { + public: + + enum return_type + { + e_rtrn_scalar = 0, + e_rtrn_string = 1 + }; + + typedef T type; + typedef type_store generic_type; + typedef typename generic_type::parameter_list parameter_list_t; + + igeneric_function(const std::string& param_seq = "", const return_type rtr_type = e_rtrn_scalar) + : parameter_sequence(param_seq), + rtrn_type(rtr_type) + {} + + virtual ~igeneric_function() + {} + +#define igeneric_function_empty_body(N) \ +{ \ +exprtk_debug(("igeneric_function::operator() - Operator has not been overridden. ["#N"]\n")); \ +return std::numeric_limits::quiet_NaN(); \ +} \ + + // f(i_0,i_1,....,i_N) --> Scalar + inline virtual T operator()(parameter_list_t) + igeneric_function_empty_body(1) + + // f(i_0,i_1,....,i_N) --> String + inline virtual T operator()(std::string&, parameter_list_t) + igeneric_function_empty_body(2) + + // f(psi,i_0,i_1,....,i_N) --> Scalar + inline virtual T operator()(const std::size_t&, parameter_list_t) + igeneric_function_empty_body(3) + + // f(psi,i_0,i_1,....,i_N) --> String + inline virtual T operator()(const std::size_t&, std::string&, parameter_list_t) + igeneric_function_empty_body(4) + + std::string parameter_sequence; + return_type rtrn_type; + }; + + template class parser; + template class expression_helper; + + template + class symbol_table + { + public: + + typedef T (*ff1_functor)(T); + typedef T (*ff2_functor)(T,T); + typedef T (*ff3_functor)(T,T,T); + typedef T (*ff4_functor)(T,T,T,T); + typedef T (*ff5_functor)(T,T,T,T,T); + typedef T (*ff6_functor)(T,T,T,T,T,T); + + protected: + + struct freefunc1 : public exprtk::ifunction + { + using exprtk::ifunction::operator(); + + freefunc1(ff1_functor ff) : exprtk::ifunction(1), f(ff) {} + inline T operator()(const T& v0) + { return f(v0); } + ff1_functor f; + }; + + struct freefunc2 : public exprtk::ifunction + { + using exprtk::ifunction::operator(); + + freefunc2(ff2_functor ff) : exprtk::ifunction(2), f(ff) {} + inline T operator()(const T& v0, const T& v1) + { return f(v0,v1); } + ff2_functor f; + }; + + struct freefunc3 : public exprtk::ifunction + { + using exprtk::ifunction::operator(); + + freefunc3(ff3_functor ff) : exprtk::ifunction(3), f(ff) {} + inline T operator()(const T& v0, const T& v1, const T& v2) + { return f(v0,v1,v2); } + ff3_functor f; + }; + + struct freefunc4 : public exprtk::ifunction + { + using exprtk::ifunction::operator(); + + freefunc4(ff4_functor ff) : exprtk::ifunction(4), f(ff) {} + inline T operator()(const T& v0, const T& v1, const T& v2, const T& v3) + { return f(v0,v1,v2,v3); } + ff4_functor f; + }; + + struct freefunc5 : public exprtk::ifunction + { + using exprtk::ifunction::operator(); + + freefunc5(ff5_functor ff) : exprtk::ifunction(5), f(ff) {} + inline T operator()(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4) + { return f(v0,v1,v2,v3,v4); } + ff5_functor f; + }; + + struct freefunc6 : public exprtk::ifunction + { + using exprtk::ifunction::operator(); + + freefunc6(ff6_functor ff) : exprtk::ifunction(6), f(ff) {} + inline T operator()(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) + { return f(v0,v1,v2,v3,v4,v5); } + ff6_functor f; + }; + + template + struct type_store + { + typedef details::expression_node* expression_ptr; + typedef typename details::variable_node variable_node_t; + typedef ifunction ifunction_t; + typedef ivararg_function ivararg_function_t; + typedef igeneric_function igeneric_function_t; + typedef details::vector_holder vector_t; +#ifndef exprtk_disable_string_capabilities + typedef typename details::stringvar_node stringvar_node_t; +#endif + + typedef Type type_t; + typedef type_t* type_ptr; + typedef std::pair type_pair_t; + typedef std::map type_map_t; + typedef typename type_map_t::iterator tm_itr_t; + typedef typename type_map_t::const_iterator tm_const_itr_t; + + enum { lut_size = 256 }; + + type_map_t map; + std::size_t size; + + type_store() + : size(0) + {} + + inline bool symbol_exists(const std::string& symbol_name) const + { + if (symbol_name.empty()) + return false; + else if (map.end() != map.find(symbol_name)) + return true; + else + return false; + } + + template + inline std::string entity_name(const PtrType& ptr) const + { + if (map.empty()) + return std::string(); + + tm_const_itr_t itr = map.begin(); + + while (map.end() != itr) + { + if (itr->second.second == ptr) + { + return itr->first; + } + else + ++itr; + } + + return std::string(); + } + + inline bool is_constant(const std::string& symbol_name) const + { + if (symbol_name.empty()) + return false; + else + { + tm_const_itr_t itr = map.find(symbol_name); + + if (map.end() == itr) + return false; + else + return (*itr).second.first; + } + } + + template + inline bool add_impl(const std::string& symbol_name, RType t, const bool is_const) + { + if (symbol_name.size() > 1) + { + for (std::size_t i = 0; i < details::reserved_symbols_size; ++i) + { + if (details::imatch(symbol_name,details::reserved_symbols[i])) + { + return false; + } + } + } + + tm_itr_t itr = map.find(symbol_name); + + if (map.end() == itr) + { + map[symbol_name] = Tie::make(t,is_const); + ++size; + } + + return true; + } + + struct tie_array + { + static inline std::pair make(std::pair v, const bool is_const = false) + { + return std::make_pair(is_const,new vector_t(v.first,v.second)); + } + }; + + struct tie_stdvec + { + template + static inline std::pair make(std::vector& v, const bool is_const = false) + { + return std::make_pair(is_const,new vector_t(v)); + } + }; + + struct tie_vecview { - close_bracket = token_t::e_rbracket; - seperator = token_t::e_comma; - } - else + static inline std::pair make(exprtk::vector_view& v, const bool is_const = false) + { + return std::make_pair(is_const,new vector_t(v)); + } + }; + + struct tie_stddeq + { + template + static inline std::pair make(std::deque& v, const bool is_const = false) + { + return std::make_pair(is_const,new vector_t(v)); + } + }; + + template + inline bool add(const std::string& symbol_name, T (&v)[v_size], const bool is_const = false) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR84 - Expected '" + token_t::to_str(close_bracket) + "' for call to multi-sequence" + - ((!source.empty()) ? std::string(" section of " + source): ""))); - - return error_node(); + return add_impl >(symbol_name,std::make_pair(v,v_size),is_const); } - } - else if (token_is(token_t::e_rcrlbracket)) - { - return node_allocator_.allocate >(); - } - - std::vector arg_list; - expression_node_ptr result = error_node(); - - scoped_vec_delete sdd(*this,arg_list); - - scope_handler sh(*this); - - for (;;) - { - expression_node_ptr arg = parse_expression(); - - if (0 == arg) - return error_node(); - else - arg_list.push_back(arg); - - if (token_is(close_bracket)) - break; - - bool is_next_close = peek_token_is(close_bracket); - - if (!token_is(seperator) && is_next_close) + + inline bool add(const std::string& symbol_name, T* v, const std::size_t v_size, const bool is_const = false) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR85 - Expected '" + details::to_str(seperator) + "' for call to multi-sequence section of " + source)); - - return error_node(); + return add_impl >(symbol_name,std::make_pair(v,v_size),is_const); } - - if (token_is(close_bracket)) - break; - } - - result = simplify(arg_list); - - sdd.delete_ptr = (0 == result); - return result; - } - - inline bool parse_range(range_t& rp, const bool skip_lsqr = false) - { - // Examples of valid ranges: - // 1. [1:5] -> 1..5 - // 2. [ :5] -> 0..5 - // 3. [1: ] -> 1..end - // 4. [x:y] -> x..y where x <= y - // 5. [x+1:y/2] -> x+1..y/2 where x+1 <= y/2 - // 6. [ :y] -> 0..y where 0 <= y - // 7. [x: ] -> x..end where x <= end - - rp.clear(); - - if (!skip_lsqr && !token_is(token_t::e_lsqrbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR86 - Expected '[' for start of range")); - - return false; - } - - if (token_is(token_t::e_colon)) - { - rp.n0_c.first = true; - rp.n0_c.second = 0; - rp.cache.first = 0; - } - else - { - expression_node_ptr r0 = parse_expression(); - - if (0 == r0) + + template + inline bool add(const std::string& symbol_name, std::vector& v, const bool is_const = false) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR87 - Failed parse begin section of range")); - - return false; - + return add_impl&>(symbol_name,v,is_const); } - else if (is_constant_node(r0)) + + inline bool add(const std::string& symbol_name, exprtk::vector_view& v, const bool is_const = false) { - T r0_value = r0->value(); - - if (r0_value >= T(0)) - { - rp.n0_c.first = true; - rp.n0_c.second = static_cast(details::numeric::to_int64(r0_value)); - rp.cache.first = rp.n0_c.second; - } - - free_node(node_allocator_,r0); - - if (r0_value < T(0)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR88 - Range lower bound less than zero! Constraint: r0 >= 0")); - - return false; - } + return add_impl&>(symbol_name,v,is_const); } - else - { - rp.n0_e.first = true; - rp.n0_e.second = r0; + + template + inline bool add(const std::string& symbol_name, std::deque& v, const bool is_const = false) + { + return add_impl&>(symbol_name,v,is_const); + } + + inline bool add(const std::string& symbol_name, RawType& t, const bool is_const = false) + { + struct tie + { + static inline std::pair make(T& t,const bool is_const = false) + { + return std::make_pair(is_const,new variable_node_t(t)); + } + +#ifndef exprtk_disable_string_capabilities + static inline std::pair make(std::string& t,const bool is_const = false) + { + return std::make_pair(is_const,new stringvar_node_t(t)); + } +#endif + + static inline std::pair make(function_t& t, const bool is_constant = false) + { + return std::make_pair(is_constant,&t); + } + + static inline std::pair make(vararg_function_t& t, const bool is_const = false) + { + return std::make_pair(is_const,&t); + } + + static inline std::pair make(generic_function_t& t, const bool is_constant = false) + { + return std::make_pair(is_constant,&t); + } + }; + + tm_itr_t itr = map.find(symbol_name); + + if (map.end() == itr) + { + map[symbol_name] = tie::make(t,is_const); + ++size; + } + + return true; + } + + inline type_ptr get(const std::string& symbol_name) const + { + tm_const_itr_t itr = map.find(symbol_name); + + if (map.end() == itr) + return reinterpret_cast(0); + else + return itr->second.second; + } + + template + struct ptr_match + { + static inline bool test(const PtrType, const void*) + { + return false; + } + }; + + template + struct ptr_match + { + static inline bool test(const variable_node_t* p, const void* ptr) + { + exprtk_debug(("ptr_match::test() - %p <--> %p\n",(void*)(&(p->ref())),ptr)); + return (&(p->ref()) == ptr); + } + }; + + inline type_ptr get_from_varptr(const void* ptr) const + { + tm_const_itr_t itr = map.begin(); + + while (map.end() != itr) + { + type_ptr ret_ptr = itr->second.second; + + if (ptr_match::test(ret_ptr,ptr)) + { + return ret_ptr; + } + + ++itr; + } + + return type_ptr(0); + } + + inline bool remove(const std::string& symbol_name, const bool delete_node = true) + { + tm_itr_t itr = map.find(symbol_name); + + if (map.end() != itr) + { + struct deleter + { + static inline void process(std::pair& n) { delete n.second; } + static inline void process(std::pair& n) { delete n.second; } +#ifndef exprtk_disable_string_capabilities + static inline void process(std::pair& n) { delete n.second; } +#endif + static inline void process(std::pair&) { } + }; + + if (delete_node) + { + deleter::process((*itr).second); + } + + map.erase(itr); + --size; + + return true; + } + else + return false; + } + + inline RawType& type_ref(const std::string& symbol_name) + { + struct init_type + { + static inline double set(double) { return (0.0); } + static inline double set(long double) { return (0.0); } + static inline float set(float) { return (0.0f); } + static inline std::string set(std::string) { return std::string(""); } + }; + + static RawType null_type = init_type::set(RawType()); + + tm_const_itr_t itr = map.find(symbol_name); + + if (map.end() == itr) + return null_type; + else + return itr->second.second->ref(); + } + + inline void clear(const bool delete_node = true) + { + struct deleter + { + static inline void process(std::pair& n) { delete n.second; } + static inline void process(std::pair& n) { delete n.second; } + static inline void process(std::pair&) { } +#ifndef exprtk_disable_string_capabilities + static inline void process(std::pair& n) { delete n.second; } +#endif + }; + + if (!map.empty()) + { + if (delete_node) + { + tm_itr_t itr = map.begin(); + tm_itr_t end = map.end(); + + while (end != itr) + { + deleter::process((*itr).second); + ++itr; + } + } + + map.clear(); + } + + size = 0; + } + + template class Sequence> + inline std::size_t get_list(Sequence,Allocator>& list) const + { + std::size_t count = 0; + + if (!map.empty()) + { + tm_const_itr_t itr = map.begin(); + tm_const_itr_t end = map.end(); + + while (end != itr) + { + list.push_back(std::make_pair((*itr).first,itr->second.second->ref())); + ++itr; + ++count; + } + } + + return count; + } + + template class Sequence> + inline std::size_t get_list(Sequence& vlist) const + { + std::size_t count = 0; + + if (!map.empty()) + { + tm_const_itr_t itr = map.begin(); + tm_const_itr_t end = map.end(); + + while (end != itr) + { + vlist.push_back((*itr).first); + ++itr; + ++count; + } + } + + return count; } - - if (!token_is(token_t::e_colon)) + }; + + typedef details::expression_node* expression_ptr; + typedef typename details::variable_node variable_t; + typedef typename details::vector_holder vector_holder_t; + typedef variable_t* variable_ptr; +#ifndef exprtk_disable_string_capabilities + typedef typename details::stringvar_node stringvar_t; + typedef stringvar_t* stringvar_ptr; +#endif + typedef ifunction function_t; + typedef ivararg_function vararg_function_t; + typedef igeneric_function generic_function_t; + typedef function_t* function_ptr; + typedef vararg_function_t* vararg_function_ptr; + typedef generic_function_t* generic_function_ptr; + + static const std::size_t lut_size = 256; + + // Symbol Table Holder + struct control_block + { + struct st_data + { + type_store,T> variable_store; +#ifndef exprtk_disable_string_capabilities + type_store,std::string> stringvar_store; +#endif + type_store,ifunction > function_store; + type_store,ivararg_function > vararg_function_store; + type_store,igeneric_function > generic_function_store; + type_store,igeneric_function > string_function_store; + type_store vector_store; + + st_data() + { + for (std::size_t i = 0; i < details::reserved_words_size; ++i) + { + reserved_symbol_table_.insert(details::reserved_words[i]); + } + + for (std::size_t i = 0; i < details::reserved_symbols_size; ++i) + { + reserved_symbol_table_.insert(details::reserved_symbols[i]); + } + } + + ~st_data() + { + for (std::size_t i = 0; i < free_function_list_.size(); ++i) + { + delete free_function_list_[i]; + } + } + + inline bool is_reserved_symbol(const std::string& symbol) const + { + return (reserved_symbol_table_.end() != reserved_symbol_table_.find(symbol)); + } + + std::list local_symbol_list_; + std::list local_stringvar_list_; + std::set reserved_symbol_table_; + std::vector*> free_function_list_; + }; + + control_block() + : ref_count(1), + data_(new st_data) + {} + + control_block(st_data* data) + : ref_count(1), + data_(data) + {} + + ~control_block() { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR89 - Expected ':' for break in range")); - - rp.free(); - return false; + if (data_ && (0 == ref_count)) + { + delete data_; + data_ = 0; + } } - } - - if (token_is(token_t::e_rsqrbracket)) - { - rp.n1_c.first = true; - rp.n1_c.second = std::numeric_limits::max(); - } - else - { - expression_node_ptr r1 = parse_expression(); - - if (0 == r1) + + static inline control_block* create() { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR90 - Failed parse end section of range")); - - rp.free(); - return false; - + return new control_block; } - else if (is_constant_node(r1)) + + template + static inline void destroy(control_block*& cntrl_blck, SymTab* sym_tab) { - T r1_value = r1->value(); - - if (r1_value >= T(0)) - { - rp.n1_c.first = true; - rp.n1_c.second = static_cast(details::numeric::to_int64(r1_value)); - rp.cache.second = rp.n1_c.second; - } - - free_node(node_allocator_,r1); - - if (r1_value < T(0)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR91 - Range upper bound less than zero! Constraint: r1 >= 0")); - - return false; - } - } + if (cntrl_blck) + { + if ( + (0 != cntrl_blck->ref_count) && + (0 == --cntrl_blck->ref_count) + ) + { + if (sym_tab) + sym_tab->clear(); + + delete cntrl_blck; + } + + cntrl_blck = 0; + } + } + + std::size_t ref_count; + st_data* data_; + }; + + public: + + symbol_table() + : control_block_(control_block::create()) + { + clear(); + } + + ~symbol_table() + { + control_block::destroy(control_block_,this); + } + + symbol_table(const symbol_table& st) + { + control_block_ = st.control_block_; + control_block_->ref_count++; + } + + inline symbol_table& operator=(const symbol_table& st) + { + if (this != &st) + { + control_block::destroy(control_block_,reinterpret_cast*>(0)); + + control_block_ = st.control_block_; + control_block_->ref_count++; + } + + return *this; + } + + inline bool operator==(const symbol_table& st) + { + return (this == &st) || (control_block_ == st.control_block_); + } + + inline void clear_variables(const bool delete_node = true) + { + local_data().variable_store.clear(delete_node); + } + + inline void clear_functions() + { + local_data().function_store.clear(); + } + + inline void clear_strings() + { +#ifndef exprtk_disable_string_capabilities + local_data().stringvar_store.clear(); +#endif + } + + inline void clear_vectors() + { + local_data().vector_store.clear(); + } + + inline void clear() + { + if (!valid()) return; + clear_variables(); + clear_functions(); + clear_strings (); + clear_vectors (); + } + + inline std::size_t variable_count() const + { + if (valid()) + return local_data().variable_store.size; else - { - rp.n1_e.first = true; - rp.n1_e.second = r1; - } - - if (!token_is(token_t::e_rsqrbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR92 - Expected ']' for start of range")); - - rp.free(); - return false; - } - } - - if (rp.const_range()) - { - std::size_t r0 = 0; - std::size_t r1 = 0; - - bool rp_result = rp(r0,r1); - - if (!rp_result || (r0 > r1)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR93 - Invalid range, Constraint: r0 <= r1")); - - return false; - } - } - - return true; - } - - inline void lodge_symbol(const std::string& symbol, - const symbol_type st) - { - dec_.add_symbol(symbol,st); - } - - inline expression_node_ptr parse_string() - { - const std::string symbol = current_token_.value; - - if (!symbol_table_.is_conststr_stringvar(symbol)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR94 - Unknown string symbol")); - - return error_node(); - } - - expression_node_ptr result = symbol_table_.get_stringvar(symbol); - - typedef details::stringvar_node* strvar_node_t; - strvar_node_t const_str_node = static_cast(0); - - const bool is_const_string = symbol_table_.is_constant_string(symbol); - - if (is_const_string) - { - const_str_node = static_cast(result); - result = expression_generator_(const_str_node->str()); - } - - lodge_symbol(symbol,e_st_string); - - if (peek_token_is(token_t::e_lsqrbracket)) - { - next_token(); - - if (peek_token_is(token_t::e_rsqrbracket)) - { - next_token(); - next_token(); - - if (const_str_node) - { - free_node(node_allocator_,result); - - return expression_generator_(T(const_str_node->size())); - } - else - return node_allocator_.allocate > - (static_cast*>(result)->ref()); - } - - range_t rp; - - if (!parse_range(rp)) - { - free_node(node_allocator_,result); - - return error_node(); - } - else if (const_str_node) - { - free_node(node_allocator_,result); - result = expression_generator_(const_str_node->ref(),rp); - } + return 0; + } + +#ifndef exprtk_disable_string_capabilities + inline std::size_t stringvar_count() const + { + if (valid()) + return local_data().stringvar_store.size; else - result = expression_generator_(static_cast*>(result)->ref(),rp); - - if (result) - rp.clear(); - } - else - next_token(); - - return result; - } - - inline expression_node_ptr parse_const_string() - { - const std::string const_str = current_token_.value; - expression_node_ptr result = expression_generator_(const_str); - - if (peek_token_is(token_t::e_lsqrbracket)) - { - next_token(); - - if (peek_token_is(token_t::e_rsqrbracket)) - { - next_token(); - next_token(); - - free_node(node_allocator_,result); - - return expression_generator_(T(const_str.size())); - } - - range_t rp; - - if (!parse_range(rp)) - { - free_node(node_allocator_,result); - - return error_node(); - } - - free_node(node_allocator_,result); - - if (rp.n1_c.first && (rp.n1_c.second == std::numeric_limits::max())) - { - rp.n1_c.second = const_str.size() - 1; - rp.cache.second = rp.n1_c.second; - } - - if ( - (rp.n0_c.first && (rp.n0_c.second >= const_str.size())) || - (rp.n1_c.first && (rp.n1_c.second >= const_str.size())) - ) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR95 - Overflow in range for string: '" + const_str + "'[" + - (rp.n0_c.first ? details::to_str(rp.n0_c.second) : "?") + ":" + - (rp.n1_c.first ? details::to_str(rp.n1_c.second) : "?") + "]")); - - return error_node(); - } - - result = expression_generator_(const_str,rp); - - if (result) - rp.clear(); - } - else - next_token(); - - return result; - } - - inline expression_node_ptr parse_vector() - { - const std::string symbol = current_token_.value; - - vector_holder_ptr vec = vector_holder_ptr(0); - - const scope_element& se = sem_.get_element(symbol); - - if ( - (se.name != symbol) || - (se.depth > scope_depth_) || - (scope_element::e_vector != se.type) - ) - { - if (0 == (vec = symbol_table_.get_vector(symbol))) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR96 - Symbol '" + symbol+ " not a vector")); - - return error_node(); + return 0; + } +#endif + + inline std::size_t function_count() const + { + if (valid()) + return local_data().function_store.size; + else + return 0; + } + + inline std::size_t vector_count() const + { + if (valid()) + return local_data().vector_store.size; + else + return 0; + } + + inline variable_ptr get_variable(const std::string& variable_name) const + { + if (!valid()) + return reinterpret_cast(0); + else if (!valid_symbol(variable_name)) + return reinterpret_cast(0); + else + return local_data().variable_store.get(variable_name); + } + + inline variable_ptr get_variable(const T& var_ref) const + { + if (!valid()) + return reinterpret_cast(0); + else + return local_data().variable_store.get_from_varptr( + reinterpret_cast(&var_ref)); + } + +#ifndef exprtk_disable_string_capabilities + inline stringvar_ptr get_stringvar(const std::string& string_name) const + { + if (!valid()) + return reinterpret_cast(0); + else if (!valid_symbol(string_name)) + return reinterpret_cast(0); + else + return local_data().stringvar_store.get(string_name); + } +#endif + + inline function_ptr get_function(const std::string& function_name) const + { + if (!valid()) + return reinterpret_cast(0); + else if (!valid_symbol(function_name)) + return reinterpret_cast(0); + else + return local_data().function_store.get(function_name); + } + + inline vararg_function_ptr get_vararg_function(const std::string& vararg_function_name) const + { + if (!valid()) + return reinterpret_cast(0); + else if (!valid_symbol(vararg_function_name)) + return reinterpret_cast(0); + else + return local_data().vararg_function_store.get(vararg_function_name); + } + + inline generic_function_ptr get_generic_function(const std::string& function_name) const + { + if (!valid()) + return reinterpret_cast(0); + else if (!valid_symbol(function_name)) + return reinterpret_cast(0); + else + return local_data().generic_function_store.get(function_name); + } + + inline generic_function_ptr get_string_function(const std::string& function_name) const + { + if (!valid()) + return reinterpret_cast(0); + else if (!valid_symbol(function_name)) + return reinterpret_cast(0); + else + return local_data().string_function_store.get(function_name); + } + + typedef vector_holder_t* vector_holder_ptr; + + inline vector_holder_ptr get_vector(const std::string& vector_name) const + { + if (!valid()) + return reinterpret_cast(0); + else if (!valid_symbol(vector_name)) + return reinterpret_cast(0); + else + return local_data().vector_store.get(vector_name); + } + + inline T& variable_ref(const std::string& symbol_name) + { + static T null_var = T(0); + if (!valid()) + return null_var; + else if (!valid_symbol(symbol_name)) + return null_var; + else + return local_data().variable_store.type_ref(symbol_name); + } + +#ifndef exprtk_disable_string_capabilities + inline std::string& stringvar_ref(const std::string& symbol_name) + { + static std::string null_stringvar; + if (!valid()) + return null_stringvar; + else if (!valid_symbol(symbol_name)) + return null_stringvar; + else + return local_data().stringvar_store.type_ref(symbol_name); + } +#endif + + inline bool is_constant_node(const std::string& symbol_name) const + { + if (!valid()) + return false; + else if (!valid_symbol(symbol_name)) + return false; + else + return local_data().variable_store.is_constant(symbol_name); + } + +#ifndef exprtk_disable_string_capabilities + inline bool is_constant_string(const std::string& symbol_name) const + { + if (!valid()) + return false; + else if (!valid_symbol(symbol_name)) + return false; + else if (!local_data().stringvar_store.symbol_exists(symbol_name)) + return false; + else + return local_data().stringvar_store.is_constant(symbol_name); + } +#endif + + inline bool create_variable(const std::string& variable_name, const T& value = T(0)) + { + if (!valid()) + return false; + else if (!valid_symbol(variable_name)) + return false; + else if (symbol_exists(variable_name)) + return false; + + local_data().local_symbol_list_.push_back(value); + T& t = local_data().local_symbol_list_.back(); + + return add_variable(variable_name,t); + } + +#ifndef exprtk_disable_string_capabilities + inline bool create_stringvar(const std::string& stringvar_name, const std::string& value = std::string("")) + { + if (!valid()) + return false; + else if (!valid_symbol(stringvar_name)) + return false; + else if (symbol_exists(stringvar_name)) + return false; + + local_data().local_stringvar_list_.push_back(value); + std::string& s = local_data().local_stringvar_list_.back(); + + return add_stringvar(stringvar_name,s); + } +#endif + + inline bool add_variable(const std::string& variable_name, T& t, const bool is_constant = false) + { + if (!valid()) + return false; + else if (!valid_symbol(variable_name)) + return false; + else if (symbol_exists(variable_name)) + return false; + else + return local_data().variable_store.add(variable_name,t,is_constant); + } + + inline bool add_constant(const std::string& constant_name, const T& value) + { + if (!valid()) + return false; + else if (!valid_symbol(constant_name)) + return false; + else if (symbol_exists(constant_name)) + return false; + + local_data().local_symbol_list_.push_back(value); + T& t = local_data().local_symbol_list_.back(); + + return add_variable(constant_name,t,true); + } + +#ifndef exprtk_disable_string_capabilities + inline bool add_stringvar(const std::string& stringvar_name, std::string& s, const bool is_constant = false) + { + if (!valid()) + return false; + else if (!valid_symbol(stringvar_name)) + return false; + else if (symbol_exists(stringvar_name)) + return false; + else + return local_data().stringvar_store.add(stringvar_name,s,is_constant); + } +#endif + + inline bool add_function(const std::string& function_name, function_t& function) + { + if (!valid()) + return false; + else if (!valid_symbol(function_name)) + return false; + else if (symbol_exists(function_name)) + return false; + else + return local_data().function_store.add(function_name,function); + } + + inline bool add_function(const std::string& vararg_function_name, vararg_function_t& vararg_function) + { + if (!valid()) + return false; + else if (!valid_symbol(vararg_function_name)) + return false; + else if (symbol_exists(vararg_function_name)) + return false; + else + return local_data().vararg_function_store.add(vararg_function_name,vararg_function); + } + + inline bool add_function(const std::string& function_name, generic_function_t& function) + { + if (!valid()) + return false; + else if (!valid_symbol(function_name)) + return false; + else if (symbol_exists(function_name)) + return false; + else if (std::string::npos != function.parameter_sequence.find_first_not_of("STVZ*?|")) + return false; + else if (generic_function_t::e_rtrn_scalar == function.rtrn_type) + return local_data().generic_function_store.add(function_name,function); + else if (generic_function_t::e_rtrn_string == function.rtrn_type) + return local_data().string_function_store.add(function_name, function); + else + return false; + } + + inline bool add_function(const std::string& function_name, ff1_functor function) + { + if (!valid()) + return false; + else if (!valid_symbol(function_name)) + return false; + else if (symbol_exists(function_name)) + return false; + + exprtk::ifunction* ifunc = new freefunc1(function); + + local_data().free_function_list_.push_back(ifunc); + + return add_function(function_name,(*local_data().free_function_list_.back())); + } + + inline bool add_function(const std::string& function_name, ff2_functor function) + { + if (!valid()) + return false; + else if (!valid_symbol(function_name)) + return false; + else if (symbol_exists(function_name)) + return false; + + exprtk::ifunction* ifunc = new freefunc2(function); + + local_data().free_function_list_.push_back(ifunc); + + return add_function(function_name,(*local_data().free_function_list_.back())); + } + + inline bool add_function(const std::string& function_name, ff3_functor function) + { + if (!valid()) + return false; + else if (!valid_symbol(function_name)) + return false; + else if (symbol_exists(function_name)) + return false; + + exprtk::ifunction* ifunc = new freefunc3(function); + + local_data().free_function_list_.push_back(ifunc); + + return add_function(function_name,(*local_data().free_function_list_.back())); + } + + inline bool add_function(const std::string& function_name, ff4_functor function) + { + if (!valid()) + return false; + else if (!valid_symbol(function_name)) + return false; + else if (symbol_exists(function_name)) + return false; + + exprtk::ifunction* ifunc = new freefunc4(function); + + local_data().free_function_list_.push_back(ifunc); + + return add_function(function_name,(*local_data().free_function_list_.back())); + } + + inline bool add_function(const std::string& function_name, ff5_functor function) + { + if (!valid()) + return false; + else if (!valid_symbol(function_name)) + return false; + else if (symbol_exists(function_name)) + return false; + + exprtk::ifunction* ifunc = new freefunc5(function); + + local_data().free_function_list_.push_back(ifunc); + + return add_function(function_name,(*local_data().free_function_list_.back())); + } + + inline bool add_function(const std::string& function_name, ff6_functor function) + { + if (!valid()) + return false; + else if (!valid_symbol(function_name)) + return false; + else if (symbol_exists(function_name)) + return false; + + exprtk::ifunction* ifunc = new freefunc6(function); + + local_data().free_function_list_.push_back(ifunc); + + return add_function(function_name,(*local_data().free_function_list_.back())); + } + + inline bool add_reserved_function(const std::string& function_name, function_t& function) + { + if (!valid()) + return false; + else if (!valid_symbol(function_name,false)) + return false; + else if (symbol_exists(function_name,false)) + return false; + else + return local_data().function_store.add(function_name,function); + } + + inline bool add_reserved_function(const std::string& vararg_function_name, vararg_function_t& vararg_function) + { + if (!valid()) + return false; + else if (!valid_symbol(vararg_function_name,false)) + return false; + else if (symbol_exists(vararg_function_name,false)) + return false; + else + return local_data().vararg_function_store.add(vararg_function_name,vararg_function); + } + + inline bool add_reserved_function(const std::string& function_name, generic_function_t& function) + { + if (!valid()) + return false; + else if (!valid_symbol(function_name,false)) + return false; + else if (symbol_exists(function_name,false)) + return false; + else if (std::string::npos != function.parameter_sequence.find_first_not_of("STV*?|")) + return false; + else if (generic_function_t::e_rtrn_scalar == function.rtrn_type) + return local_data().generic_function_store.add(function_name,function); + else if (generic_function_t::e_rtrn_string == function.rtrn_type) + return local_data().string_function_store.add(function_name, function); + else + return false; + } + + template + inline bool add_vector(const std::string& vector_name, T (&v)[N]) + { + if (!valid()) + return false; + else if (!valid_symbol(vector_name)) + return false; + else if (symbol_exists(vector_name)) + return false; + else + return local_data().vector_store.add(vector_name,v); + } + + inline bool add_vector(const std::string& vector_name, T* v, const std::size_t& v_size) + { + if (!valid()) + return false; + else if (!valid_symbol(vector_name)) + return false; + else if (symbol_exists(vector_name)) + return false; + else + return local_data().vector_store.add(vector_name,v,v_size); + } + + template + inline bool add_vector(const std::string& vector_name, std::vector& v) + { + if (!valid()) + return false; + else if (!valid_symbol(vector_name)) + return false; + else if (symbol_exists(vector_name)) + return false; + else + return local_data().vector_store.add(vector_name,v); + } + + inline bool add_vector(const std::string& vector_name, exprtk::vector_view& v) + { + if (!valid()) + return false; + else if (!valid_symbol(vector_name)) + return false; + else if (symbol_exists(vector_name)) + return false; + else + return local_data().vector_store.add(vector_name,v); + } + + inline bool remove_variable(const std::string& variable_name, const bool delete_node = true) + { + if (!valid()) + return false; + else + return local_data().variable_store.remove(variable_name, delete_node); + } + +#ifndef exprtk_disable_string_capabilities + inline bool remove_stringvar(const std::string& string_name) + { + if (!valid()) + return false; + else + return local_data().stringvar_store.remove(string_name); + } +#endif + + inline bool remove_function(const std::string& function_name) + { + if (!valid()) + return false; + else + return local_data().function_store.remove(function_name); + } + + inline bool remove_vararg_function(const std::string& vararg_function_name) + { + if (!valid()) + return false; + else + return local_data().vararg_function_store.remove(vararg_function_name); + } + + inline bool remove_vector(const std::string& vector_name) + { + if (!valid()) + return false; + else + return local_data().vector_store.remove(vector_name); + } + + inline bool add_constants() + { + return add_pi () && + add_epsilon () && + add_infinity(); + } + + inline bool add_pi() + { + static const T local_pi = T(details::numeric::constant::pi); + return add_constant("pi",local_pi); + } + + inline bool add_epsilon() + { + static const T local_epsilon = details::numeric::details::epsilon_type::value(); + return add_constant("epsilon",local_epsilon); + } + + inline bool add_infinity() + { + static const T local_infinity = std::numeric_limits::infinity(); + return add_constant("inf",local_infinity); + } + + template + inline bool add_package(Package& package) + { + return package.register_package(*this); + } + + template class Sequence> + inline std::size_t get_variable_list(Sequence,Allocator>& vlist) const + { + if (!valid()) + return 0; + else + return local_data().variable_store.get_list(vlist); + } + + template class Sequence> + inline std::size_t get_variable_list(Sequence& vlist) const + { + if (!valid()) + return 0; + else + return local_data().variable_store.get_list(vlist); + } + +#ifndef exprtk_disable_string_capabilities + template class Sequence> + inline std::size_t get_stringvar_list(Sequence,Allocator>& svlist) const + { + if (!valid()) + return 0; + else + return local_data().stringvar_store.get_list(svlist); + } + + template class Sequence> + inline std::size_t get_stringvar_list(Sequence& svlist) const + { + if (!valid()) + return 0; + else + return local_data().stringvar_store.get_list(svlist); + } +#endif + + template class Sequence> + inline std::size_t get_vector_list(Sequence& vlist) const + { + if (!valid()) + return 0; + else + return local_data().vector_store.get_list(vlist); + } + + inline bool symbol_exists(const std::string& symbol_name, const bool check_reserved_symb = true) const + { + /* + Function will return true if symbol_name exists as either a + reserved symbol, variable, stringvar or function name in any + of the type stores. + */ + if (!valid()) + return false; + else if (local_data().variable_store.symbol_exists(symbol_name)) + return true; +#ifndef exprtk_disable_string_capabilities + else if (local_data().stringvar_store.symbol_exists(symbol_name)) + return true; +#endif + else if (local_data().function_store.symbol_exists(symbol_name)) + return true; + else if (check_reserved_symb && local_data().is_reserved_symbol(symbol_name)) + return true; + else + return false; + } + + inline bool is_variable(const std::string& variable_name) const + { + if (!valid()) + return false; + else + return local_data().variable_store.symbol_exists(variable_name); + } + +#ifndef exprtk_disable_string_capabilities + inline bool is_stringvar(const std::string& stringvar_name) const + { + if (!valid()) + return false; + else + return local_data().stringvar_store.symbol_exists(stringvar_name); + } + + inline bool is_conststr_stringvar(const std::string& symbol_name) const + { + if (!valid()) + return false; + else if (!valid_symbol(symbol_name)) + return false; + else if (!local_data().stringvar_store.symbol_exists(symbol_name)) + return false; + + return ( + local_data().stringvar_store.symbol_exists(symbol_name) || + local_data().stringvar_store.is_constant (symbol_name) + ); + } +#endif + + inline bool is_function(const std::string& function_name) const + { + if (!valid()) + return false; + else + return local_data().function_store.symbol_exists(function_name); + } + + inline bool is_vararg_function(const std::string& vararg_function_name) const + { + if (!valid()) + return false; + else + return local_data().vararg_function_store.symbol_exists(vararg_function_name); + } + + inline bool is_vector(const std::string& vector_name) const + { + if (!valid()) + return false; + else + return local_data().vector_store.symbol_exists(vector_name); + } + + inline std::string get_variable_name(const expression_ptr& ptr) const + { + return local_data().variable_store.entity_name(ptr); + } + + inline std::string get_vector_name(const vector_holder_ptr& ptr) const + { + return local_data().vector_store.entity_name(ptr); + } + +#ifndef exprtk_disable_string_capabilities + inline std::string get_stringvar_name(const expression_ptr& ptr) const + { + return local_data().stringvar_store.entity_name(ptr); + } + + inline std::string get_conststr_stringvar_name(const expression_ptr& ptr) const + { + return local_data().stringvar_store.entity_name(ptr); + } +#endif + + inline bool valid() const + { + // Symbol table sanity check. + return control_block_ && control_block_->data_; + } + + inline void load_from(const symbol_table& st) + { + { + std::vector name_list; + + st.local_data().function_store.get_list(name_list); + + if (!name_list.empty()) + { + for (std::size_t i = 0; i < name_list.size(); ++i) + { + exprtk::ifunction& ifunc = *st.get_function(name_list[i]); + add_function(name_list[i],ifunc); + } + } + } + + { + std::vector name_list; + + st.local_data().vararg_function_store.get_list(name_list); + + if (!name_list.empty()) + { + for (std::size_t i = 0; i < name_list.size(); ++i) + { + exprtk::ivararg_function& ivafunc = *st.get_vararg_function(name_list[i]); + add_function(name_list[i],ivafunc); + } + } + } + + { + std::vector name_list; + + st.local_data().generic_function_store.get_list(name_list); + + if (!name_list.empty()) + { + for (std::size_t i = 0; i < name_list.size(); ++i) + { + exprtk::igeneric_function& ifunc = *st.get_generic_function(name_list[i]); + add_function(name_list[i],ifunc); + } + } + } + + { + std::vector name_list; + + st.local_data().string_function_store.get_list(name_list); + + if (!name_list.empty()) + { + for (std::size_t i = 0; i < name_list.size(); ++i) + { + exprtk::igeneric_function& ifunc = *st.get_string_function(name_list[i]); + add_function(name_list[i],ifunc); + } + } + } + } + + private: + + inline bool valid_symbol(const std::string& symbol, const bool check_reserved_symb = true) const + { + if (symbol.empty()) + return false; + else if (!details::is_letter(symbol[0])) + return false; + else if (symbol.size() > 1) + { + for (std::size_t i = 1; i < symbol.size(); ++i) + { + if ( + !details::is_letter_or_digit(symbol[i]) && + ('_' != symbol[i]) + ) + { + if (('.' == symbol[i]) && (i < (symbol.size() - 1))) + continue; + else + return false; + } + } + } + + return (check_reserved_symb) ? (!local_data().is_reserved_symbol(symbol)) : true; + } + + inline bool valid_function(const std::string& symbol) const + { + if (symbol.empty()) + return false; + else if (!details::is_letter(symbol[0])) + return false; + else if (symbol.size() > 1) + { + for (std::size_t i = 1; i < symbol.size(); ++i) + { + if ( + !details::is_letter_or_digit(symbol[i]) && + ('_' != symbol[i]) + ) + { + if (('.' == symbol[i]) && (i < (symbol.size() - 1))) + continue; + else + return false; + } + } } - } - else - vec = se.vec_node; - - expression_node_ptr index_expr = error_node(); - - next_token(); - - if (!token_is(token_t::e_lsqrbracket)) - { - return node_allocator_.allocate(vec); - } - else if (token_is(token_t::e_rsqrbracket)) - { - return expression_generator_(T(vec->size())); - } - else if (0 == (index_expr = parse_expression())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR97 - Failed to parse index for vector: '" + symbol + "'")); - - return error_node(); - } - else if (!token_is(token_t::e_rsqrbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR98 - Expected ']' for index of vector: '" + symbol + "'")); - - free_node(node_allocator_,index_expr); - - return error_node(); - } - - return expression_generator_.vector_element(symbol,vec,index_expr); - } - - inline expression_node_ptr parse_vararg_function_call(ivararg_function* vararg_function, const std::string& vararg_function_name) - { - std::vector arg_list; - expression_node_ptr result = error_node(); - - scoped_vec_delete sdd(*this,arg_list); - - next_token(); - - if (token_is(token_t::e_lbracket)) - { - if (!token_is(token_t::e_rbracket)) + + return true; + } + + typedef typename control_block::st_data local_data_t; + + inline local_data_t& local_data() + { + return *(control_block_->data_); + } + + inline const local_data_t& local_data() const + { + return *(control_block_->data_); + } + + control_block* control_block_; + + friend class parser; + }; + + template + class function_compositor; + + template + class expression + { + private: + + typedef details::expression_node* expression_ptr; + typedef details::vector_holder* vector_holder_ptr; + typedef std::vector > symtab_list_t; + + struct control_block + { + enum data_type + { + e_unknown , + e_expr , + e_vecholder, + e_data , + e_vecdata , + e_string + }; + + struct data_pack + { + data_pack() + : pointer(0), + type(e_unknown), + size(0) + {} + + data_pack(void* ptr, data_type dt, std::size_t sz = 0) + : pointer(ptr), + type(dt), + size(sz) + {} + + void* pointer; + data_type type; + std::size_t size; + }; + + typedef std::vector local_data_list_t; + typedef results_context results_context_t; + + control_block() + : ref_count(0), + expr (0), + results (0), + retinv_null(false), + return_invoked(&retinv_null) + {} + + control_block(expression_ptr e) + : ref_count(1), + expr (e), + results (0), + retinv_null(false), + return_invoked(&retinv_null) + {} + + ~control_block() + { + if (expr && details::branch_deletable(expr)) + { + delete expr; + expr = reinterpret_cast(0); + } + + if (!local_data_list.empty()) + { + for (std::size_t i = 0; i < local_data_list.size(); ++i) + { + switch (local_data_list[i].type) + { + case e_expr : delete reinterpret_cast(local_data_list[i].pointer); + break; + + case e_vecholder : delete reinterpret_cast(local_data_list[i].pointer); + break; + + case e_data : delete (T*)(local_data_list[i].pointer); + break; + + case e_vecdata : delete [] (T*)(local_data_list[i].pointer); + break; + + case e_string : delete (std::string*)(local_data_list[i].pointer); + break; + + default : break; + } + } + } + + if (results) + { + delete results; + } + } + + static inline control_block* create(expression_ptr e) + { + return new control_block(e); + } + + static inline void destroy(control_block*& cntrl_blck) + { + if (cntrl_blck) + { + if ( + (0 != cntrl_blck->ref_count) && + (0 == --cntrl_blck->ref_count) + ) + { + delete cntrl_blck; + } + + cntrl_blck = 0; + } + } + + std::size_t ref_count; + expression_ptr expr; + local_data_list_t local_data_list; + results_context_t* results; + bool retinv_null; + bool* return_invoked; + + friend class function_compositor; + }; + + public: + + expression() + : control_block_(0) + { + set_expression(new details::null_node()); + } + + expression(const expression& e) + : control_block_(e.control_block_), + symbol_table_list_(e.symbol_table_list_) + { + control_block_->ref_count++; + } + + inline expression& operator=(const expression& e) + { + if (this != &e) + { + if (control_block_) + { + if ( + (0 != control_block_->ref_count) && + (0 == --control_block_->ref_count) + ) + { + delete control_block_; + } + + control_block_ = 0; + } + + control_block_ = e.control_block_; + control_block_->ref_count++; + symbol_table_list_ = e.symbol_table_list_; + } + + return *this; + } + + inline bool operator==(const expression& e) + { + return (this == &e); + } + + inline bool operator!() const + { + return ( + (0 == control_block_ ) || + (0 == control_block_->expr) + ); + } + + inline expression& release() + { + control_block::destroy(control_block_); + + return *this; + } + + ~expression() + { + control_block::destroy(control_block_); + } + + inline T value() const + { + return control_block_->expr->value(); + } + + inline T operator()() const + { + return value(); + } + + inline operator T() const + { + return value(); + } + + inline operator bool() const + { + return details::is_true(value()); + } + + inline void register_symbol_table(symbol_table& st) + { + symbol_table_list_.push_back(st); + } + + inline const symbol_table& get_symbol_table(const std::size_t& index = 0) const + { + return symbol_table_list_[index]; + } + + inline symbol_table& get_symbol_table(const std::size_t& index = 0) + { + return symbol_table_list_[index]; + } + + typedef results_context results_context_t; + + inline const results_context_t& results() const + { + if (control_block_->results) + return (*control_block_->results); + else { - for ( ; ; ) - { - expression_node_ptr arg = parse_expression(); - - if (0 == arg) - return error_node(); - else - arg_list.push_back(arg); - - if (token_is(token_t::e_rbracket)) - break; - else if (!token_is(token_t::e_comma)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR99 - Expected ',' for call to vararg function: " + vararg_function_name)); - - return error_node(); - } - } + static const results_context_t null_results; + return null_results; + } + } + + inline bool return_invoked() const + { + return (*control_block_->return_invoked); + } + + private: + + inline symtab_list_t get_symbol_table_list() const + { + return symbol_table_list_; + } + + inline void set_expression(const expression_ptr expr) + { + if (expr) + { + if (control_block_) + { + if (0 == --control_block_->ref_count) + { + delete control_block_; + } + } + + control_block_ = control_block::create(expr); + } + } + + inline void register_local_var(expression_ptr expr) + { + if (expr) + { + if (control_block_) + { + control_block_-> + local_data_list.push_back( + typename expression::control_block:: + data_pack(reinterpret_cast(expr), + control_block::e_expr)); + } + } + } + + inline void register_local_var(vector_holder_ptr vec_holder) + { + if (vec_holder) + { + if (control_block_) + { + control_block_-> + local_data_list.push_back( + typename expression::control_block:: + data_pack(reinterpret_cast(vec_holder), + control_block::e_vecholder)); + } + } + } + + inline void register_local_data(void* data, const std::size_t& size = 0, const std::size_t data_mode = 0) + { + if (data) + { + if (control_block_) + { + typename control_block::data_type dt = control_block::e_data; + + switch (data_mode) + { + case 0 : dt = control_block::e_data; break; + case 1 : dt = control_block::e_vecdata; break; + case 2 : dt = control_block::e_string; break; + } + + control_block_-> + local_data_list.push_back( + typename expression::control_block:: + data_pack(reinterpret_cast(data),dt,size)); + } + } + } + + inline const typename control_block::local_data_list_t& local_data_list() + { + if (control_block_) + { + return control_block_->local_data_list; } - } - - result = expression_generator_.vararg_function_call(vararg_function,arg_list); - - sdd.delete_ptr = (0 == result); - - return result; - } - - class type_checker - { - public: - - typedef parser parser_t; - typedef std::vector param_seq_list_t; - - type_checker(parser_t& p, - const std::string& func_name, - const std::string& param_seq) - : invalid_state_(true), - parser_(p), - function_name_(func_name) - { - split(param_seq); - } - - bool verify(const std::string& param_seq, std::size_t& pseq_index) - { - if (param_seq_list_.empty()) - return true; - - std::vector > error_list; - - for (std::size_t i = 0; i < param_seq_list_.size(); ++i) + else { - std::size_t diff_index = 0; - char diff_value = 0; - - bool result = details::sequence_match(param_seq_list_[i], - param_seq, - diff_index,diff_value); - - if (result) - { - pseq_index = i; - return true; - } - else - error_list.push_back(std::make_pair(diff_index,diff_value)); + static typename control_block::local_data_list_t null_local_data_list; + return null_local_data_list; + } + } + + inline void register_return_results(results_context_t* rc) + { + if (control_block_ && rc) + { + control_block_->results = rc; + } + } + + inline void set_retinvk(bool* retinvk_ptr) + { + if (control_block_) + { + control_block_->return_invoked = retinvk_ptr; + } + } + + control_block* control_block_; + symtab_list_t symbol_table_list_; + + friend class parser; + friend class expression_helper; + friend class function_compositor; + }; + + template + class expression_helper + { + public: + + static inline bool is_constant(const expression& expr) + { + return details::is_constant_node(expr.control_block_->expr); + } + + static inline bool is_variable(const expression& expr) + { + return details::is_variable_node(expr.control_block_->expr); + } + + static inline bool is_unary(const expression& expr) + { + return details::is_unary_node(expr.control_block_->expr); + } + + static inline bool is_binary(const expression& expr) + { + return details::is_binary_node(expr.control_block_->expr); + } + + static inline bool is_function(const expression& expr) + { + return details::is_function(expr.control_block_->expr); + } + + static inline bool is_null(const expression& expr) + { + return details::is_null_node(expr.control_block_->expr); + } + }; + + template + inline bool is_valid(const expression& expr) + { + return !expression_helper::is_null(expr); + } + + namespace parser_error + { + enum error_mode + { + e_unknown = 0, + e_syntax = 1, + e_token = 2, + e_numeric = 4, + e_symtab = 5, + e_lexer = 6, + e_helper = 7 + }; + + struct type + { + type() + : mode(parser_error::e_unknown), + line_no (0), + column_no(0) + {} + + lexer::token token; + error_mode mode; + std::string diagnostic; + std::string error_line; + std::size_t line_no; + std::size_t column_no; + }; + + inline type make_error(error_mode mode, const std::string& diagnostic = "") + { + type t; + t.mode = mode; + t.token.type = lexer::token::e_error; + t.diagnostic = diagnostic; + exprtk_debug(("%s\n",diagnostic .c_str())); + return t; + } + + inline type make_error(error_mode mode, const lexer::token& tk, const std::string& diagnostic = "") + { + type t; + t.mode = mode; + t.token = tk; + t.diagnostic = diagnostic; + exprtk_debug(("%s\n",diagnostic .c_str())); + return t; + } + + inline std::string to_str(error_mode mode) + { + switch (mode) + { + case e_unknown : return std::string("Unknown Error"); + case e_syntax : return std::string("Syntax Error" ); + case e_token : return std::string("Token Error" ); + case e_numeric : return std::string("Numeric Error"); + case e_symtab : return std::string("Symbol Error" ); + case e_lexer : return std::string("Lexer Error" ); + case e_helper : return std::string("Helper Error" ); + default : return std::string("Unknown Error"); + } + } + + inline bool update_error(type& error, const std::string& expression) + { + if ( + expression.empty() || + (error.token.position > expression.size()) || + (std::numeric_limits::max() == error.token.position) + ) + { + return false; + } + + std::size_t error_line_start = 0; + + for (std::size_t i = error.token.position; i > 0; --i) + { + const details::char_t c = expression[i]; + + if (('\n' == c) || ('\r' == c)) + { + error_line_start = i + 1; + break; + } + } + + std::size_t next_nl_position = std::min(expression.size(), + expression.find_first_of('\n',error.token.position + 1)); + + error.column_no = error.token.position - error_line_start; + error.error_line = expression.substr(error_line_start, + next_nl_position - error_line_start); + + error.line_no = 0; + + for (std::size_t i = 0; i < next_nl_position; ++i) + { + if ('\n' == expression[i]) + ++error.line_no; + } + + return true; + } + + inline void dump_error(const type& error) + { + printf("Position: %02d Type: [%s] Msg: %s\n", + static_cast(error.token.position), + exprtk::parser_error::to_str(error.mode).c_str(), + error.diagnostic.c_str()); + } + } + + template + class parser : public lexer::parser_helper + { + private: + + enum precedence_level + { + e_level00, + e_level01, + e_level02, + e_level03, + e_level04, + e_level05, + e_level06, + e_level07, + e_level08, + e_level09, + e_level10, + e_level11, + e_level12, + e_level13, + e_level14 + }; + + typedef const T& cref_t; + typedef const T const_t; + typedef ifunction F; + typedef ivararg_function VAF; + typedef igeneric_function GF; + typedef ifunction ifunction_t; + typedef ivararg_function ivararg_function_t; + typedef igeneric_function igeneric_function_t; + typedef details::expression_node expression_node_t; + typedef details::literal_node literal_node_t; + typedef details::unary_node unary_node_t; + typedef details::binary_node binary_node_t; + typedef details::trinary_node trinary_node_t; + typedef details::quaternary_node quaternary_node_t; + typedef details::conditional_node conditional_node_t; + typedef details::cons_conditional_node cons_conditional_node_t; + typedef details::while_loop_node while_loop_node_t; + typedef details::repeat_until_loop_node repeat_until_loop_node_t; + typedef details::for_loop_node for_loop_node_t; +#ifndef exprtk_disable_break_continue + typedef details::while_loop_bc_node while_loop_bc_node_t; + typedef details::repeat_until_loop_bc_node repeat_until_loop_bc_node_t; + typedef details::for_loop_bc_node for_loop_bc_node_t; +#endif + typedef details::switch_node switch_node_t; + typedef details::variable_node variable_node_t; + typedef details::vector_elem_node vector_elem_node_t; + typedef details::rebasevector_elem_node rebasevector_elem_node_t; + typedef details::rebasevector_celem_node rebasevector_celem_node_t; + typedef details::vector_node vector_node_t; + typedef details::range_pack range_t; +#ifndef exprtk_disable_string_capabilities + typedef details::stringvar_node stringvar_node_t; + typedef details::string_literal_node string_literal_node_t; + typedef details::string_range_node string_range_node_t; + typedef details::const_string_range_node const_string_range_node_t; + typedef details::generic_string_range_node generic_string_range_node_t; + typedef details::string_concat_node string_concat_node_t; + typedef details::assignment_string_node assignment_string_node_t; + typedef details::assignment_string_range_node assignment_string_range_node_t; + typedef details::conditional_string_node conditional_string_node_t; + typedef details::cons_conditional_str_node cons_conditional_str_node_t; +#endif + typedef details::assignment_node assignment_node_t; + typedef details::assignment_vec_elem_node assignment_vec_elem_node_t; + typedef details::assignment_rebasevec_elem_node assignment_rebasevec_elem_node_t; + typedef details::assignment_rebasevec_celem_node assignment_rebasevec_celem_node_t; + typedef details::assignment_vec_node assignment_vec_node_t; + typedef details::assignment_vecvec_node assignment_vecvec_node_t; + typedef details::scand_node scand_node_t; + typedef details::scor_node scor_node_t; + typedef lexer::token token_t; + typedef expression_node_t* expression_node_ptr; + typedef symbol_table symbol_table_t; + typedef typename expression::symtab_list_t symbol_table_list_t; + typedef details::vector_holder* vector_holder_ptr; + + typedef typename details::functor_t functor_t; + typedef typename functor_t::qfunc_t quaternary_functor_t; + typedef typename functor_t::tfunc_t trinary_functor_t; + typedef typename functor_t::bfunc_t binary_functor_t; + typedef typename functor_t::ufunc_t unary_functor_t; + + typedef details::operator_type operator_t; + + typedef std::map unary_op_map_t; + typedef std::map binary_op_map_t; + typedef std::map trinary_op_map_t; + + typedef std::map > sf3_map_t; + typedef std::map > sf4_map_t; + + typedef std::map inv_binary_op_map_t; + typedef std::multimap base_ops_map_t; + typedef std::set disabled_func_set_t; + + typedef details::T0oT1_define vov_t; + typedef details::T0oT1_define cov_t; + typedef details::T0oT1_define voc_t; + + typedef details::T0oT1oT2_define vovov_t; + typedef details::T0oT1oT2_define vovoc_t; + typedef details::T0oT1oT2_define vocov_t; + typedef details::T0oT1oT2_define covov_t; + typedef details::T0oT1oT2_define covoc_t; + typedef details::T0oT1oT2_define cocov_t; + typedef details::T0oT1oT2_define vococ_t; + + typedef details::T0oT1oT2oT3_define vovovov_t; + typedef details::T0oT1oT2oT3_define vovovoc_t; + typedef details::T0oT1oT2oT3_define vovocov_t; + typedef details::T0oT1oT2oT3_define vocovov_t; + typedef details::T0oT1oT2oT3_define covovov_t; + + typedef details::T0oT1oT2oT3_define covocov_t; + typedef details::T0oT1oT2oT3_define vocovoc_t; + typedef details::T0oT1oT2oT3_define covovoc_t; + typedef details::T0oT1oT2oT3_define vococov_t; + + typedef results_context results_context_t; + + typedef parser_helper prsrhlpr_t; + + struct scope_element + { + enum element_type + { + e_none , + e_variable, + e_vector , + e_vecelem , + e_string + }; + + typedef details::vector_holder vector_holder_t; + typedef variable_node_t* variable_node_ptr; + typedef vector_holder_t* vector_holder_ptr; + typedef expression_node_t* expression_node_ptr; +#ifndef exprtk_disable_string_capabilities + typedef stringvar_node_t* stringvar_node_ptr; +#endif + + scope_element() + : name("???"), + size (std::numeric_limits::max()), + index(std::numeric_limits::max()), + depth(std::numeric_limits::max()), + ref_count(0), + ip_index (0), + type (e_none), + active(false), + data (0), + var_node(0), + vec_node(0) +#ifndef exprtk_disable_string_capabilities + ,str_node(0) +#endif + {} + + bool operator < (const scope_element& se) const + { + if (ip_index < se.ip_index) + return true; + else if (ip_index > se.ip_index) + return false; + else if (depth < se.depth) + return true; + else if (depth > se.depth) + return false; + else if (index < se.index) + return true; + else if (index > se.index) + return false; + else + return (name < se.name); + } + + void clear() + { + name = "???"; + size = std::numeric_limits::max(); + index = std::numeric_limits::max(); + depth = std::numeric_limits::max(); + type = e_none; + active = false; + ref_count = 0; + ip_index = 0; + data = 0; + var_node = 0; + vec_node = 0; +#ifndef exprtk_disable_string_capabilities + str_node = 0; +#endif } - - if (1 == error_list.size()) + + std::string name; + std::size_t size; + std::size_t index; + std::size_t depth; + std::size_t ref_count; + std::size_t ip_index; + element_type type; + bool active; + void* data; + expression_node_ptr var_node; + vector_holder_ptr vec_node; +#ifndef exprtk_disable_string_capabilities + stringvar_node_ptr str_node; +#endif + }; + + class scope_element_manager + { + public: + + typedef expression_node_t* expression_node_ptr; + typedef variable_node_t* variable_node_ptr; + typedef parser parser_t; + + scope_element_manager(parser& p) + : parser_(p), + input_param_cnt_(0) + {} + + inline std::size_t size() const { - parser_. - set_error( - make_error(parser_error::e_syntax, - parser_.current_token(), - "ERR100 - Failed parameter type check for function '" + function_name_ + "', " - "Expected '" + param_seq_list_[0] + "' call set: '" + param_seq +"'")); + return element_.size(); + } + + inline bool empty() const + { + return element_.empty(); + } + + inline scope_element& get_element(const std::size_t& index) + { + if (index < element_.size()) + return element_[index]; + else + return null_element_; + } + + inline scope_element& get_element(const std::string& var_name, + const std::size_t index = std::numeric_limits::max()) + { + const std::size_t current_depth = parser_.state_.scope_depth; + + for (std::size_t i = 0; i < element_.size(); ++i) + { + scope_element& se = element_[i]; + + if (se.depth > current_depth) + continue; + else if ( + (se.name == var_name) && + (se.index == index) + ) + return se; + } + + return null_element_; + } + + inline scope_element& get_active_element(const std::string& var_name, + const std::size_t index = std::numeric_limits::max()) + { + const std::size_t current_depth = parser_.state_.scope_depth; + + for (std::size_t i = 0; i < element_.size(); ++i) + { + scope_element& se = element_[i]; + + if (se.depth > current_depth) + continue; + else if ( + (se.name == var_name) && + (se.index == index) && + (se.active) + ) + return se; + } + + return null_element_; + } + + inline bool add_element(const scope_element& se) + { + for (std::size_t i = 0; i < element_.size(); ++i) + { + scope_element& cse = element_[i]; + + if ( + (cse.name == se.name ) && + (cse.depth <= se.depth) && + (cse.index == se.index) && + (cse.size == se.size ) && + (cse.type == se.type ) && + (cse.active) + ) + return false; + } + + element_.push_back(se); + std::sort(element_.begin(),element_.end()); + + return true; + } + + inline void deactivate(const std::size_t& scope_depth) + { + exprtk_debug(("deactivate() - Scope depth: %d\n", + static_cast(parser_.state_.scope_depth))); + + for (std::size_t i = 0; i < element_.size(); ++i) + { + scope_element& se = element_[i]; + + if (se.active && (se.depth >= scope_depth)) + { + exprtk_debug(("deactivate() - element[%02d] '%s'\n", + static_cast(i), + se.name.c_str())); + + se.active = false; + } + } + } + + inline void free_element(scope_element& se) + { + switch (se.type) + { + case scope_element::e_variable : if (se.data ) delete (T*) se.data; + if (se.var_node) delete se.var_node; + break; + + case scope_element::e_vector : if (se.data ) delete[] (T*) se.data; + if (se.vec_node) delete se.vec_node; + break; + + case scope_element::e_vecelem : if (se.var_node) delete se.var_node; + break; + +#ifndef exprtk_disable_string_capabilities + case scope_element::e_string : if (se.data ) delete (std::string*) se.data; + if (se.str_node) delete se.str_node; + break; +#endif + + default : return; + } + + se.clear(); + } + + inline void cleanup() + { + for (std::size_t i = 0; i < element_.size(); ++i) + { + free_element(element_[i]); + } + + element_.clear(); + + input_param_cnt_ = 0; + } + + inline std::size_t next_ip_index() + { + return ++input_param_cnt_; + } + + inline expression_node_ptr get_variable(const T& v) + { + for (std::size_t i = 0; i < element_.size(); ++i) + { + scope_element& se = element_[i]; + + if ( + se.active && + se.var_node && + details::is_variable_node(se.var_node) + ) + { + variable_node_ptr vn = reinterpret_cast(se.var_node); + + if (&(vn->ref()) == (&v)) + { + return se.var_node; + } + } + } + + return expression_node_ptr(0); + } + + private: + + scope_element_manager& operator=(const scope_element_manager&); + + parser_t& parser_; + std::vector element_; + scope_element null_element_; + std::size_t input_param_cnt_; + }; + + class scope_handler + { + public: + + typedef parser parser_t; + + scope_handler(parser& p) + : parser_(p) + { + parser_.state_.scope_depth++; +#ifdef exprtk_enable_debugging + std::string depth(2 * parser_.state_.scope_depth,'-'); + exprtk_debug(("%s> Scope Depth: %02d\n", + depth.c_str(), + static_cast(parser_.state_.scope_depth))); +#endif } - else + + ~scope_handler() { - // find first with largest diff_index; - std::size_t max_diff_index = 0; - - for (std::size_t i = 1; i < error_list.size(); ++i) - { - if (error_list[i].first > error_list[max_diff_index].first) - { - max_diff_index = i; - } - } - - parser_. - set_error( - make_error(parser_error::e_syntax, - parser_.current_token(), - "ERR101 - Failed parameter type check for function '" + function_name_ + "', " - "Best match: '" + param_seq_list_[max_diff_index] + "' call set: '" + param_seq +"'")); + parser_.sem_.deactivate(parser_.state_.scope_depth); + parser_.state_.scope_depth--; +#ifdef exprtk_enable_debugging + std::string depth(2 * parser_.state_.scope_depth,'-'); + exprtk_debug(("<%s Scope Depth: %02d\n", + depth.c_str(), + static_cast(parser_.state_.scope_depth))); +#endif } - - return false; - } - - std::size_t paramseq_count() const - { - return param_seq_list_.size(); - } - - std::string paramseq(const std::size_t& index) const - { - return param_seq_list_[index]; - } - - bool invalid() const - { - return !invalid_state_; - } - - private: - - void split(const std::string& s) - { - if (s.empty()) - return; - - std::size_t start = 0; - std::size_t end = 0; - - param_seq_list_t param_seq_list; - - struct token_validator - { - static inline bool process(const std::string& str, - std::size_t s, std::size_t e, - param_seq_list_t& psl) - { - if ( - (e - s) && - (std::string::npos == str.find("?*")) && - (std::string::npos == str.find("**")) - ) - { - const std::string curr_str = str.substr(s,e - s); - - if (std::string::npos == curr_str.find_first_not_of("STV*?|")) - { - psl.push_back(curr_str); + + private: + + scope_handler& operator=(const scope_handler&); + + parser_t& parser_; + }; + + struct symtab_store + { + symbol_table_list_t symtab_list_; + + typedef typename symbol_table_t::local_data_t local_data_t; + typedef typename symbol_table_t::variable_ptr variable_ptr; + typedef typename symbol_table_t::function_ptr function_ptr; +#ifndef exprtk_disable_string_capabilities + typedef typename symbol_table_t::stringvar_ptr stringvar_ptr; +#endif + typedef typename symbol_table_t::vector_holder_ptr vector_holder_ptr; + typedef typename symbol_table_t::vararg_function_ptr vararg_function_ptr; + typedef typename symbol_table_t::generic_function_ptr generic_function_ptr; + + inline bool empty() const + { + return symtab_list_.empty(); + } + + inline void clear() + { + symtab_list_.clear(); + } + + inline bool valid() const + { + if (!empty()) + { + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (symtab_list_[i].valid()) + return true; + } + } + + return false; + } + + inline bool valid_symbol(const std::string& symbol) const + { + if (!symtab_list_.empty()) + return symtab_list_[0].valid_symbol(symbol); + else + return false; + } + + inline bool valid_function_name(const std::string& symbol) const + { + if (!symtab_list_.empty()) + return symtab_list_[0].valid_function(symbol); + else + return false; + } + + inline variable_ptr get_variable(const std::string& variable_name) const + { + if (!valid_symbol(variable_name)) + return reinterpret_cast(0); + + variable_ptr result = reinterpret_cast(0); + + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else + result = local_data(i) + .variable_store.get(variable_name); + + if (result) break; + } + + return result; + } + + inline variable_ptr get_variable(const T& var_ref) const + { + variable_ptr result = reinterpret_cast(0); + + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else + result = local_data(i).variable_store + .get_from_varptr(reinterpret_cast(&var_ref)); + + if (result) break; + } + + return result; + } + +#ifndef exprtk_disable_string_capabilities + inline stringvar_ptr get_stringvar(const std::string& string_name) const + { + if (!valid_symbol(string_name)) + return reinterpret_cast(0); + + stringvar_ptr result = reinterpret_cast(0); + + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else + result = local_data(i) + .stringvar_store.get(string_name); + + if (result) break; + } + + return result; + } +#endif + + inline function_ptr get_function(const std::string& function_name) const + { + if (!valid_function_name(function_name)) + return reinterpret_cast(0); + + function_ptr result = reinterpret_cast(0); + + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else + result = local_data(i) + .function_store.get(function_name); + + if (result) break; + } + + return result; + } + + inline vararg_function_ptr get_vararg_function(const std::string& vararg_function_name) const + { + if (!valid_function_name(vararg_function_name)) + return reinterpret_cast(0); + + vararg_function_ptr result = reinterpret_cast(0); + + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else + result = local_data(i) + .vararg_function_store.get(vararg_function_name); + + if (result) break; + } + + return result; + } + + inline generic_function_ptr get_generic_function(const std::string& function_name) const + { + if (!valid_function_name(function_name)) + return reinterpret_cast(0); + + generic_function_ptr result = reinterpret_cast(0); + + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else + result = local_data(i) + .generic_function_store.get(function_name); + + if (result) break; + } + + return result; + } + + inline generic_function_ptr get_string_function(const std::string& function_name) const + { + if (!valid_function_name(function_name)) + return reinterpret_cast(0); + + generic_function_ptr result = reinterpret_cast(0); + + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else + result = + local_data(i).string_function_store.get(function_name); + + if (result) break; + } + + return result; + } + + inline vector_holder_ptr get_vector(const std::string& vector_name) const + { + if (!valid_symbol(vector_name)) + return reinterpret_cast(0); + + vector_holder_ptr result = reinterpret_cast(0); + + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else + result = + local_data(i).vector_store.get(vector_name); + + if (result) break; + } + + return result; + } + + inline bool is_constant_node(const std::string& symbol_name) const + { + if (!valid_symbol(symbol_name)) + return false; + + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else if (local_data(i).variable_store.is_constant(symbol_name)) return true; - } - } - - return false; - } - }; - - while (std::string::npos != (end = s.find('|',start))) + } + + return false; + } + +#ifndef exprtk_disable_string_capabilities + inline bool is_constant_string(const std::string& symbol_name) const + { + if (!valid_symbol(symbol_name)) + return false; + + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else if (!local_data(i).stringvar_store.symbol_exists(symbol_name)) + continue; + else if ( local_data(i).stringvar_store.is_constant(symbol_name)) + return true; + } + + return false; + } +#endif + + inline bool symbol_exists(const std::string& symbol) const + { + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else if (symtab_list_[i].symbol_exists(symbol)) + return true; + } + + return false; + } + + inline bool is_variable(const std::string& variable_name) const + { + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else if ( + symtab_list_[i].local_data().variable_store + .symbol_exists(variable_name) + ) + return true; + } + + return false; + } + +#ifndef exprtk_disable_string_capabilities + inline bool is_stringvar(const std::string& stringvar_name) const + { + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else if ( + symtab_list_[i].local_data().stringvar_store + .symbol_exists(stringvar_name) + ) + return true; + } + + return false; + } + + inline bool is_conststr_stringvar(const std::string& symbol_name) const + { + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else if ( + symtab_list_[i].local_data().stringvar_store + .symbol_exists(symbol_name) + ) + { + return ( + local_data(i).stringvar_store.symbol_exists(symbol_name) || + local_data(i).stringvar_store.is_constant (symbol_name) + ); + + } + } + + return false; + } +#endif + + inline bool is_function(const std::string& function_name) const + { + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else if ( + local_data(i).vararg_function_store + .symbol_exists(function_name) + ) + return true; + } + + return false; + } + + inline bool is_vararg_function(const std::string& vararg_function_name) const + { + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else if ( + local_data(i).vararg_function_store + .symbol_exists(vararg_function_name) + ) + return true; + } + + return false; + } + + inline bool is_vector(const std::string& vector_name) const + { + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else if ( + local_data(i).vector_store + .symbol_exists(vector_name) + ) + return true; + } + + return false; + } + + inline std::string get_variable_name(const expression_node_ptr& ptr) const { - if (!token_validator::process(s,start,end,param_seq_list)) - { - invalid_state_ = false; - - const std::string err_param_seq = s.substr(start,end - start); - - parser_. - set_error( - make_error(parser_error::e_syntax, - parser_.current_token(), - "ERR102 - Invalid parameter sequence of '" + err_param_seq + - "' for function: " + function_name_)); - - return; - } - else - start = end + 1; + return local_data().variable_store.entity_name(ptr); } - - if (start < s.size()) + + inline std::string get_vector_name(const vector_holder_ptr& ptr) const { - if (token_validator::process(s,start,s.size(),param_seq_list)) - param_seq_list_ = param_seq_list; - else - { - const std::string err_param_seq = s.substr(start,s.size() - start); - - parser_. - set_error( - make_error(parser_error::e_syntax, - parser_.current_token(), - "ERR103 - Invalid parameter sequence of '" + err_param_seq + - "' for function: " + function_name_)); - return; - } - } - } - - type_checker(const type_checker&); - type_checker& operator=(const type_checker&); - - bool invalid_state_; - parser_t& parser_; - std::string function_name_; - param_seq_list_t param_seq_list_; - }; - - inline expression_node_ptr parse_generic_function_call(igeneric_function* function, const std::string& function_name) - { - std::vector arg_list; - - scoped_vec_delete sdd(*this,arg_list); - - next_token(); - - std::string param_type_list; - - type_checker tc(*this,function_name,function->parameter_sequence); - - if (tc.invalid()) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR104 - Type checker instantiation failure for generic function: " + function_name)); - - return error_node(); - } - - if (token_is(token_t::e_lbracket)) - { - if (!token_is(token_t::e_rbracket)) + return local_data().vector_store.entity_name(ptr); + } + +#ifndef exprtk_disable_string_capabilities + inline std::string get_stringvar_name(const expression_node_ptr& ptr) const { - for ( ; ; ) - { - expression_node_ptr arg = parse_expression(); - - if (0 == arg) - return error_node(); - - if (is_ivector_node(arg)) - param_type_list += 'V'; - else if (is_generally_string_node(arg)) - param_type_list += 'S'; - else // Everything else is assumed to be scalar returning expression - param_type_list += 'T'; - - arg_list.push_back(arg); - - if (token_is(token_t::e_rbracket)) - break; - else if (!token_is(token_t::e_comma)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR105 - Expected ',' for call to generic function: " + function_name)); - - return error_node(); - } - } + return local_data().stringvar_store.entity_name(ptr); } - } - - std::size_t param_seq_index = 0; - - if (!tc.verify(param_type_list, param_seq_index)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR106 - Expected ',' for call to generic function: " + function_name)); - - return error_node(); - } - - expression_node_ptr result = error_node(); - - if (tc.paramseq_count() <= 1) - result = expression_generator_ - .generic_function_call(function,arg_list); - else - result = expression_generator_ - .generic_function_call(function,arg_list,param_seq_index); - - sdd.delete_ptr = (0 == result); - - return result; - } - - inline expression_node_ptr parse_string_function_call(igeneric_function* function, const std::string& function_name) - { - std::vector arg_list; - - scoped_vec_delete sdd(*this,arg_list); - - next_token(); - - std::string param_type_list; - - type_checker tc(*this,function_name,function->parameter_sequence); - - if ( - (!function->parameter_sequence.empty()) && - (0 == tc.paramseq_count()) - ) - { - return error_node(); - } - - if (token_is(token_t::e_lbracket)) - { - if (!token_is(token_t::e_rbracket)) + + inline std::string get_conststr_stringvar_name(const expression_node_ptr& ptr) const { - for ( ; ; ) - { - expression_node_ptr arg = parse_expression(); - - if (0 == arg) - return error_node(); - - if (is_ivector_node(arg)) - param_type_list += 'V'; - else if (is_generally_string_node(arg)) - param_type_list += 'S'; - else // Everything else is a scalar returning expression - param_type_list += 'T'; - - arg_list.push_back(arg); - - if (token_is(token_t::e_rbracket)) - break; - else if (!token_is(token_t::e_comma)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR107 - Expected ',' for call to string function: " + function_name)); - - return error_node(); - } - } + return local_data().stringvar_store.entity_name(ptr); } - } - - std::size_t param_seq_index = 0; - - if (!tc.verify(param_type_list, param_seq_index)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR108 - Expected ',' for call to string function: " + function_name)); - - return error_node(); - } - - expression_node_ptr result = error_node(); - - if (tc.paramseq_count() <= 1) - result = expression_generator_ - .string_function_call(function,arg_list); - else - result = expression_generator_ - .string_function_call(function,arg_list,param_seq_index); - - sdd.delete_ptr = (0 == result); - - return result; - } - - template - struct parse_special_function_impl - { - static inline expression_node_ptr process(parser& p,const details::operator_type opt_type) - { - expression_node_ptr branch[NumberOfParameters]; - expression_node_ptr result = error_node(); - std::fill_n(branch,NumberOfParameters,reinterpret_cast(0)); - scoped_delete sd(p,branch); - - p.next_token(); - - if (!p.token_is(token_t::e_lbracket)) +#endif + + inline local_data_t& local_data(const std::size_t& index = 0) { - p.set_error( - make_error(parser_error::e_syntax, - p.current_token(), - "ERR109 - Expected '(' for special function")); - - return error_node(); + return symtab_list_[index].local_data(); } - - for (std::size_t i = 0; i < NumberOfParameters; ++i) + + inline const local_data_t& local_data(const std::size_t& index = 0) const { - branch[i] = p.parse_expression(); - - if (0 == branch[i]) - { - return p.error_node(); - } - else if (i < (NumberOfParameters - 1)) - { - if (!p.token_is(token_t::e_comma)) - { - p.set_error( - make_error(parser_error::e_syntax, - p.current_token(), - "ERR110 - Expected ',' before next parameter of special function")); - - return p.error_node(); - } - } + return symtab_list_[index].local_data(); } - - if (!p.token_is(token_t::e_rbracket)) - return p.error_node(); - else - result = p.expression_generator_.special_function(opt_type,branch); - - sd.delete_ptr = (0 == result); - - return result; - } - }; - - inline expression_node_ptr parse_special_function() - { - // Expect: $fDD(expr0,expr1,expr2) or $fDD(expr0,expr1,expr2,expr3) - if ( - !details::is_digit(current_token_.value[2]) || - !details::is_digit(current_token_.value[3]) - ) - { - set_error( - make_error(parser_error::e_token, - current_token_, - "ERR111 - Invalid special function[1]: " + current_token_.value)); - - return error_node(); - } - - const unsigned int id = (current_token_.value[2] - '0') * 10 + (current_token_.value[3] - '0'); - - if (id >= details::e_sffinal) - { - set_error( - make_error(parser_error::e_token, - current_token_, - "ERR112 - Invalid special function[2]: " + current_token_.value)); - - return error_node(); - } - - const std::size_t sf_3_to_4 = details::e_sf48; - const details::operator_type opt_type = details::operator_type(id + 1000); - const std::size_t NumberOfParameters = (id < (sf_3_to_4 - 1000)) ? 3 : 4; - - switch (NumberOfParameters) - { - case 3 : return parse_special_function_impl::process(*this,opt_type); - case 4 : return parse_special_function_impl::process(*this,opt_type); - default : return error_node(); - } - } - - inline expression_node_ptr parse_null_statement() - { - next_token(); - return node_allocator_.allocate >(); - } - - #ifndef exprtk_disable_break_continue - inline expression_node_ptr parse_break_statement() - { - if (!brkcnt_list_.empty()) - { - next_token(); - - brkcnt_list_.front() = true; - - expression_node_ptr return_expr = error_node(); - - if (token_is(token_t::e_lsqrbracket)) - { - if (0 == (return_expr = parse_expression())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR113 - Failed to parse return expression for 'break' statement")); - - return error_node(); - } - else if (!token_is(token_t::e_rsqrbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR114 - Expected ']' at the completion of break's return expression")); - - free_node(node_allocator_,return_expr); - - return error_node(); - } - } - - return node_allocator_.allocate >(return_expr); - } - else - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR115 - Invalid use of 'break', allowed only in the scope of a loop")); - } - - return error_node(); - } - - inline expression_node_ptr parse_continue_statement() - { - if (!brkcnt_list_.empty()) - { - next_token(); - brkcnt_list_.front() = true; - return node_allocator_.allocate >(); - } - else - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR116 - Invalid use of 'continue', allowed only in the scope of a loop")); - - return error_node(); - } - } - #endif - - inline expression_node_ptr parse_define_vector_statement(const std::string& vec_name) - { - expression_node_ptr size_expr = error_node(); - - if (!token_is(token_t::e_lsqrbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR117 - Expected '[' as part of vector size definition")); - - return error_node(); - } - else if (0 == (size_expr = parse_expression())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR118 - Failed to determine size of vector '" + vec_name + "'")); - - return error_node(); - } - else if (!is_constant_node(size_expr)) - { - free_node(node_allocator_,size_expr); - - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR119 - Expected a literal number as size of vector '" + vec_name + "'")); - - return error_node(); - } - - T vector_size = size_expr->value(); - - free_node(node_allocator_,size_expr); - - if ( - (vector_size <= T(0)) || - std::not_equal_to() - (T(0),vector_size - details::numeric::trunc(vector_size)) - ) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR120 - Invalid vector size. Must be an integer greater than zero, size: " + - details::to_str(details::numeric::to_int32(vector_size)))); - - return error_node(); - } - - std::vector vec_initilizer_list; - - scoped_vec_delete svd(*this,vec_initilizer_list); - - bool single_value_initialiser = false; - - if (!token_is(token_t::e_rsqrbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR121 - Expected ']' as part of vector size definition")); - - return error_node(); - } - else if (!token_is(token_t::e_eof)) - { - if (!token_is(token_t::e_assign)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR122 - Expected ':=' as part of vector definition")); - - return error_node(); - } - else if (token_is(token_t::e_lsqrbracket)) - { - expression_node_ptr initialiser = parse_expression(); - - if (0 == initialiser) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR123 - Failed to parse single vector initialiser")); - - return error_node(); - } - - vec_initilizer_list.push_back(initialiser); - - if (!token_is(token_t::e_rsqrbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR124 - Expected ']' to close single value vector initialiser")); - - return error_node(); - } - - single_value_initialiser = true; - } - else if (!token_is(token_t::e_lcrlbracket)) + + inline symbol_table_t& get_symbol_table(const std::size_t& index = 0) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR125 - Expected '{' as part of vector initialiser list")); - - return error_node(); + return symtab_list_[index]; } - else if (!token_is(token_t::e_rcrlbracket)) + }; + + struct parser_state + { + parser_state() { - for (;;) - { - expression_node_ptr initialiser = parse_expression(); - - if (0 == initialiser) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR126 - Expected '{' as part of vector initialiser list")); - - return error_node(); - } - else - vec_initilizer_list.push_back(initialiser); - - if (token_is(token_t::e_rcrlbracket)) - break; - - bool is_next_close = peek_token_is(token_t::e_rcrlbracket); - - if (!token_is(token_t::e_comma) && is_next_close) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR127 - Expected ',' between vector initialisers")); - - return error_node(); - } - - if (token_is(token_t::e_rcrlbracket)) - break; - } - } - - if ( - !token_is(token_t::e_rbracket ,false) && - !token_is(token_t::e_rcrlbracket,false) && - !token_is(token_t::e_rsqrbracket,false) - ) - { - if (!token_is(token_t::e_eof)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR128 - Expected ';' at end of vector definition")); - - return error_node(); - } + reset(); } - - if (vec_initilizer_list.size() > vector_size) + + void reset() { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR129 - Initialiser list larger than the number of elements in the vector: '" + vec_name + "'")); - - return error_node(); - } - } - - typename symbol_table_t::vector_holder_ptr vec_holder = typename symbol_table_t::vector_holder_ptr(0); - - std::size_t vec_size = static_cast(details::numeric::to_int32(vector_size)); - - scope_element& se = sem_.get_element(vec_name); - - if (se.name == vec_name) - { - if (se.active) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR130 - Illegal redefinition of local vector: '" + vec_name + "'")); - - return error_node(); + parsing_return_stmt = false; + parsing_break_stmt = false; + return_stmt_present = false; + side_effect_present = false; + scope_depth = 0; } - else if ( - (se.size == vec_size) && - (scope_element::e_vector == se.type) - ) + +#ifndef exprtk_enable_debugging + void activate_side_effect(const std::string&) +#else + void activate_side_effect(const std::string& source) +#endif { - vec_holder = se.vec_node; - se.active = true; - se.ref_count++; + if (!side_effect_present) + { + side_effect_present = true; + + exprtk_debug(("activate_side_effect() - caller: %s\n",source.c_str())); + } + } + + bool parsing_return_stmt; + bool parsing_break_stmt; + bool return_stmt_present; + bool side_effect_present; + std::size_t scope_depth; + }; + + public: + + struct unknown_symbol_resolver + { + + enum usr_symbol_type + { + e_usr_variable_type = 0, + e_usr_constant_type = 1 + }; + + virtual ~unknown_symbol_resolver() + {} + + virtual bool process(const std::string& /*unknown_symbol*/, + usr_symbol_type& st, + T& default_value, + std::string& error_message) + { + st = e_usr_variable_type; + default_value = T(0); + error_message.clear(); + + return true; } - } - - if (0 == vec_holder) - { - scope_element nse; - nse.name = vec_name; - nse.type = scope_element::e_vector; - nse.depth = scope_depth_; - nse.size = vec_size; - nse.data = new T[vec_size]; - nse.vec_node = new typename scope_element::vector_holder_t((T*)(nse.data),nse.size); - - if (!sem_.add_element(nse)) + }; + + enum collect_type + { + e_ct_none = 0, + e_ct_variables = 1, + e_ct_functions = 2, + e_ct_assignments = 4 + }; + + enum symbol_type + { + e_st_unknown = 0, + e_st_variable = 1, + e_st_vector = 2, + e_st_vecelem = 3, + e_st_string = 4, + e_st_function = 5, + e_st_local_variable = 6, + e_st_local_vector = 7, + e_st_local_string = 8 + }; + + class dependent_entity_collector + { + public: + + typedef std::pair symbol_t; + typedef std::vector symbol_list_t; + + dependent_entity_collector(const std::size_t options = e_ct_none) + : options_(options), + collect_variables_ ((options_ & e_ct_variables ) == e_ct_variables ), + collect_functions_ ((options_ & e_ct_functions ) == e_ct_functions ), + collect_assignments_((options_ & e_ct_assignments) == e_ct_assignments), + return_present_ (false), + final_stmt_return_(false) + {} + + template class Sequence> + inline std::size_t symbols(Sequence& symbols_list) + { + if (!collect_variables_ && !collect_functions_) + return 0; + else if (symbol_name_list_.empty()) + return 0; + + for (std::size_t i = 0; i < symbol_name_list_.size(); ++i) + { + std::string& s = symbol_name_list_[i].first; +#ifndef MODIFICATION + std::transform(s.begin(),s.end(),s.begin(),static_cast(std::tolower)); +#endif + } + + std::sort(symbol_name_list_.begin(),symbol_name_list_.end()); + + std::unique_copy(symbol_name_list_.begin(), + symbol_name_list_.end(), + std::back_inserter(symbols_list)); + + return symbols_list.size(); + } + + template class Sequence> + inline std::size_t assignment_symbols(Sequence& assignment_list) + { + if (!collect_assignments_) + return 0; + else if (assignment_name_list_.empty()) + return 0; + + for (std::size_t i = 0; i < assignment_name_list_.size(); ++i) + { + std::string& s = assignment_name_list_[i].first; +#ifndef MODIFICATION + std::transform(s.begin(),s.end(),s.begin(),static_cast(std::tolower)); +#endif + } + + std::sort(assignment_name_list_.begin(),assignment_name_list_.end()); + + std::unique_copy(assignment_name_list_.begin(), + assignment_name_list_.end(), + std::back_inserter(assignment_list)); + + return assignment_list.size(); + } + + void clear() { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR131 - Failed to add new local vector '" + vec_name + "' to SEM")); - - return error_node(); - } - - vec_holder = nse.vec_node; - - exprtk_debug(("parse_define_vector_statement() - INFO - Added new local vector: %s[%d]\n", - nse.name.c_str(), - static_cast(nse.size))); - } - - lodge_symbol(vec_name,e_st_local_vector); - - expression_node_ptr result = - node_allocator_ - .allocate >( - (*vec_holder)[0], - vec_size, - vec_initilizer_list, - single_value_initialiser); - - svd.delete_ptr = (0 == result); - - return result; - } - - inline bool local_variable_is_shadowed(const std::string& symbol) - { - const scope_element& se = sem_.get_element(symbol); - return (se.name == symbol) && se.active; - } - - inline expression_node_ptr parse_define_var_statement() - { - if (vardef_disabled_) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR132 - Illegal variable definition")); - - return error_node(); - } - else if (!details::imatch(current_token_.value,"var")) - { - return error_node(); - } - else - next_token(); - - const std::string var_name = current_token_.value; - - expression_node_ptr initialisation_expression = error_node(); - - if (!token_is(token_t::e_symbol)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR133 - Expected a symbol for variable definition")); - - return error_node(); - } - else if (details::is_reserved_symbol(var_name)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR134 - Illegal redefinition of reserved keyword: '" + var_name + "'")); - - return error_node(); - } - else if (symbol_table_.symbol_exists(var_name)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR135 - Illegal redefinition of variable '" + var_name + "'")); - - return error_node(); - } - else if (local_variable_is_shadowed(var_name)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR136 - Illegal redefinition of local variable: '" + var_name + "'")); - - return error_node(); - } - else if (token_is(token_t::e_lsqrbracket,false)) - { - return parse_define_vector_statement(var_name); - } - else if (token_is(token_t::e_lcrlbracket,false)) - { - return parse_uninitialised_var_statement(var_name); - } - else if (token_is(token_t::e_assign)) - { - if (0 == (initialisation_expression = parse_expression())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR137 - Failed to parse initialisation expression")); - - return error_node(); - } - } - - if ( - !token_is(token_t::e_rbracket ,false) && - !token_is(token_t::e_rcrlbracket,false) && - !token_is(token_t::e_rsqrbracket,false) - ) - { - if (!token_is(token_t::e_eof,false)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR138 - Expected ';' after variable definition")); - - free_node(node_allocator_,initialisation_expression); - - return error_node(); - } - } - - variable_node_t* var_node = reinterpret_cast(0); - - scope_element& se = sem_.get_element(var_name); - - if (se.name == var_name) - { - if (se.active) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR139 - Illegal redefinition of local variable: '" + var_name + "'")); - - free_node(node_allocator_,initialisation_expression); - - return error_node(); - } - else if (scope_element::e_variable == se.type) + symbol_name_list_ .clear(); + assignment_name_list_.clear(); + retparam_list_ .clear(); + return_present_ = false; + final_stmt_return_ = false; + } + + bool& collect_variables() + { + return collect_variables_; + } + + bool& collect_functions() + { + return collect_functions_; + } + + bool& collect_assignments() + { + return collect_assignments_; + } + + bool return_present() const + { + return return_present_; + } + + bool final_stmt_return() const + { + return final_stmt_return_; + } + + typedef std::vector retparam_list_t; + + retparam_list_t return_param_type_list() const + { + return retparam_list_; + } + + private: + + inline void add_symbol(const std::string& symbol, const symbol_type st) + { + switch (st) + { + case e_st_variable : + case e_st_vector : + case e_st_string : + case e_st_local_variable : + case e_st_local_vector : + case e_st_local_string : + case e_st_function : + if (collect_variables_ || collect_functions_) + symbol_name_list_.push_back(std::make_pair(symbol,st)); + break; + + default : return; + } + } + + inline void add_assignment(const std::string& symbol, const symbol_type st) + { + switch (st) + { + case e_st_variable : + case e_st_vector : + case e_st_string : + if (collect_assignments_) + assignment_name_list_.push_back(std::make_pair(symbol,st)); + break; + + default : return; + } + } + + std::size_t options_; + bool collect_variables_; + bool collect_functions_; + bool collect_assignments_; + bool return_present_; + bool final_stmt_return_; + symbol_list_t symbol_name_list_; + symbol_list_t assignment_name_list_; + retparam_list_t retparam_list_; + + friend class parser; + }; + + class settings_store + { + private: + + typedef std::set disabled_entity_set_t; + typedef disabled_entity_set_t::iterator des_itr_t; + + public: + + enum settings_compilation_options + { + e_unknown = 0, + e_replacer = 1, + e_joiner = 2, + e_numeric_check = 4, + e_bracket_check = 8, + e_sequence_check = 16, + e_commutative_check = 32, + e_strength_reduction = 64, + e_disable_vardef = 128, + e_collect_vars = 256, + e_collect_funcs = 512, + e_collect_assings = 1024, + e_disable_usr_on_rsrvd = 2048, + e_disable_zero_return = 4096 + }; + + enum settings_base_funcs + { + e_bf_unknown = 0, + e_bf_abs , e_bf_acos , e_bf_acosh , e_bf_asin , + e_bf_asinh , e_bf_atan , e_bf_atan2 , e_bf_atanh , + e_bf_avg , e_bf_ceil , e_bf_clamp , e_bf_cos , + e_bf_cosh , e_bf_cot , e_bf_csc , e_bf_equal , + e_bf_erf , e_bf_erfc , e_bf_exp , e_bf_expm1 , + e_bf_floor , e_bf_frac , e_bf_hypot , e_bf_iclamp , + e_bf_like , e_bf_log , e_bf_log10 , e_bf_log1p , + e_bf_log2 , e_bf_logn , e_bf_mand , e_bf_max , + e_bf_min , e_bf_mod , e_bf_mor , e_bf_mul , + e_bf_ncdf , e_bf_pow , e_bf_root , e_bf_round , + e_bf_roundn , e_bf_sec , e_bf_sgn , e_bf_sin , + e_bf_sinc , e_bf_sinh , e_bf_sqrt , e_bf_sum , + e_bf_swap , e_bf_tan , e_bf_tanh , e_bf_trunc , + e_bf_not_equal , e_bf_inrange , e_bf_deg2grad , e_bf_deg2rad, + e_bf_rad2deg , e_bf_grad2deg + }; + + enum settings_control_structs + { + e_ctrl_unknown = 0, + e_ctrl_ifelse, + e_ctrl_switch, + e_ctrl_for_loop, + e_ctrl_while_loop, + e_ctrl_repeat_loop + }; + + enum settings_logic_opr { - var_node = se.var_node; - se.active = true; - se.ref_count++; - } - } - - if (0 == var_node) - { - scope_element nse; - nse.name = var_name; - nse.active = true; - nse.ref_count = 1; - nse.type = scope_element::e_variable; - nse.depth = scope_depth_; - nse.data = new T(T(0)); - nse.var_node = new variable_node_t(*(T*)(nse.data)); - - if (!sem_.add_element(nse)) + e_logic_unknown = 0, + e_logic_and, e_logic_nand, e_logic_nor, + e_logic_not, e_logic_or, e_logic_xnor, + e_logic_xor, e_logic_scand, e_logic_scor + }; + + enum settings_arithmetic_opr { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR140 - Failed to add new local variable '" + var_name + "' to SEM")); - - free_node(node_allocator_,initialisation_expression); - - return error_node(); - } - - var_node = nse.var_node; - - exprtk_debug(("parse_define_var_statement() - INFO - Added new local variable: %s\n",nse.name.c_str())); - } - - lodge_symbol(var_name,e_st_local_variable); - - expression_node_ptr branch[2] = {0}; - - branch[0] = var_node; - branch[1] = initialisation_expression ? initialisation_expression : expression_generator_(T(0)); - - return expression_generator_(details::e_assign,branch); - } - - inline expression_node_ptr parse_uninitialised_var_statement(const std::string& var_name) - { - if ( - !token_is(token_t::e_lcrlbracket) || - !token_is(token_t::e_rcrlbracket) - ) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR141 - Expected a '{}' for uninitialised var definition")); - - return error_node(); - } - else if (!token_is(token_t::e_eof,false)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR142 - Expected ';' after uninitialised variable definition")); - - return error_node(); - } - - variable_node_t* var_node = reinterpret_cast(0); - - scope_element& se = sem_.get_element(var_name); - - if (se.name == var_name) - { - if (se.active) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR143 - Illegal redefinition of local variable: '" + var_name + "'")); - - return error_node(); - } - else if (scope_element::e_variable == se.type) + e_arith_unknown = 0, + e_arith_add, e_arith_sub, e_arith_mul, + e_arith_div, e_arith_mod, e_arith_pow + }; + + enum settings_assignment_opr { - var_node = se.var_node; - se.active = true; - se.ref_count++; - } - } - - if (0 == var_node) - { - scope_element nse; - nse.name = var_name; - nse.active = true; - nse.ref_count = 1; - nse.type = scope_element::e_variable; - nse.depth = scope_depth_; - nse.ip_index = sem_.next_ip_index(); - nse.data = new T(T(0)); - nse.var_node = new variable_node_t(*(T*)(nse.data)); - - if (!sem_.add_element(nse)) + e_assign_unknown = 0, + e_assign_assign, e_assign_addass, e_assign_subass, + e_assign_mulass, e_assign_divass, e_assign_modass + }; + + enum settings_inequality_opr { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR144 - Failed to add new local variable '" + var_name + "' to SEM")); - - return error_node(); - } - - exprtk_debug(("parse_uninitialised_var_statement() - INFO - Added new local variable: %s\n",nse.name.c_str())); - } - - lodge_symbol(var_name,e_st_local_variable); - - return expression_generator_(T(0)); - } - - inline expression_node_ptr parse_swap_statement() - { - if (!details::imatch(current_token_.value,"swap")) - { - return error_node(); - } - else - next_token(); - - if (!token_is(token_t::e_lbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR145 - Expected '(' at start of swap statement")); - - return error_node(); - } - - expression_node_ptr variable0 = error_node(); - expression_node_ptr variable1 = error_node(); - - bool variable0_generated = false; - bool variable1_generated = false; - - const std::string var0_name = current_token_.value; - - if (!token_is(token_t::e_symbol,false)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR146 - Expected a symbol for variable or vector element definition")); - - return error_node(); - } - else if (peek_token_is(token_t::e_lsqrbracket)) - { - if (0 == (variable0 = parse_vector())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR147 - First parameter to swap is an invalid vector element: '" + var0_name + "'")); - - return error_node(); - } - - variable0_generated = true; - } - else - { - if (symbol_table_.is_variable(var0_name)) + e_ineq_unknown = 0, + e_ineq_lt, e_ineq_lte, e_ineq_eq, + e_ineq_equal, e_ineq_ne, e_ineq_nequal, + e_ineq_gte, e_ineq_gt + }; + + static const std::size_t compile_all_opts = e_replacer + + e_joiner + + e_numeric_check + + e_bracket_check + + e_sequence_check + + e_commutative_check + + e_strength_reduction; + + settings_store(const std::size_t compile_options = compile_all_opts) { - variable0 = symbol_table_.get_variable(var0_name); + load_compile_options(compile_options); } - - scope_element& se = sem_.get_element(var0_name); - - if ( - (se.active) && - (se.name == var0_name) && - (scope_element::e_variable == se.type) - ) + + settings_store& enable_all_base_functions() { - variable0 = se.var_node; + disabled_func_set_.clear(); + return *this; } - - lodge_symbol(var0_name,e_st_variable); - - if (0 == variable0) + + settings_store& enable_all_control_structures() { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR148 - First parameter to swap is an invalid variable: '" + var0_name + "'")); - - return error_node(); + disabled_ctrl_set_.clear(); + return *this; + } + + settings_store& enable_all_logic_ops() + { + disabled_logic_set_.clear(); + return *this; + } + + settings_store& enable_all_arithmetic_ops() + { + disabled_arithmetic_set_.clear(); + return *this; + } + + settings_store& enable_all_assignment_ops() + { + disabled_assignment_set_.clear(); + return *this; + } + + settings_store& enable_all_inequality_ops() + { + disabled_inequality_set_.clear(); + return *this; + } + + settings_store& enable_local_vardef() + { + disable_vardef_ = false; + return *this; + } + + settings_store& disable_all_base_functions() + { + std::copy(details::base_function_list, + details::base_function_list + details::base_function_list_size, + std::insert_iterator + (disabled_func_set_,disabled_func_set_.begin())); + return *this; + } + + settings_store& disable_all_control_structures() + { + std::copy(details::cntrl_struct_list, + details::cntrl_struct_list + details::cntrl_struct_list_size, + std::insert_iterator + (disabled_ctrl_set_,disabled_ctrl_set_.begin())); + return *this; + } + + settings_store& disable_all_logic_ops() + { + std::copy(details::logic_ops_list, + details::logic_ops_list + details::logic_ops_list_size, + std::insert_iterator + (disabled_logic_set_,disabled_logic_set_.begin())); + return *this; + } + + settings_store& disable_all_arithmetic_ops() + { + std::copy(details::arithmetic_ops_list, + details::arithmetic_ops_list + details::arithmetic_ops_list_size, + std::insert_iterator + (disabled_arithmetic_set_,disabled_arithmetic_set_.begin())); + return *this; + } + + settings_store& disable_all_assignment_ops() + { + std::copy(details::assignment_ops_list, + details::assignment_ops_list + details::assignment_ops_list_size, + std::insert_iterator + (disabled_assignment_set_,disabled_assignment_set_.begin())); + return *this; + } + + settings_store& disable_all_inequality_ops() + { + std::copy(details::inequality_ops_list, + details::inequality_ops_list + details::inequality_ops_list_size, + std::insert_iterator + (disabled_inequality_set_,disabled_inequality_set_.begin())); + return *this; } - else - next_token(); - } - - if (!token_is(token_t::e_comma)) - { - set_error( - make_error(parser_error::e_syntax, - current_token(), - "ERR149 - Expected ',' between parameters to swap")); - - if (variable0_generated) + + settings_store& disable_local_vardef() { - free_node(node_allocator_,variable0); + disable_vardef_ = true; + return *this; + } + + bool replacer_enabled () const { return enable_replacer_; } + bool commutative_check_enabled () const { return enable_commutative_check_; } + bool joiner_enabled () const { return enable_joiner_; } + bool numeric_check_enabled () const { return enable_numeric_check_; } + bool bracket_check_enabled () const { return enable_bracket_check_; } + bool sequence_check_enabled () const { return enable_sequence_check_; } + bool strength_reduction_enabled () const { return enable_strength_reduction_; } + bool collect_variables_enabled () const { return enable_collect_vars_; } + bool collect_functions_enabled () const { return enable_collect_funcs_; } + bool collect_assignments_enabled() const { return enable_collect_assings_; } + bool vardef_disabled () const { return disable_vardef_; } + bool rsrvd_sym_usr_disabled () const { return disable_rsrvd_sym_usr_; } + bool zero_return_disabled () const { return disable_zero_return_; } + + bool function_enabled(const std::string& function_name) + { + if (disabled_func_set_.empty()) + return true; + else + return (disabled_func_set_.end() == disabled_func_set_.find(function_name)); + } + + bool control_struct_enabled(const std::string& control_struct) + { + if (disabled_ctrl_set_.empty()) + return true; + else + return (disabled_ctrl_set_.end() == disabled_ctrl_set_.find(control_struct)); + } + + bool logic_enabled(const std::string& logic_operation) + { + if (disabled_logic_set_.empty()) + return true; + else + return (disabled_logic_set_.end() == disabled_logic_set_.find(logic_operation)); + } + + bool arithmetic_enabled(const details::operator_type& arithmetic_operation) + { + if (disabled_logic_set_.empty()) + return true; + else + return (disabled_arithmetic_set_.end() == disabled_arithmetic_set_.find(arith_opr_to_string(arithmetic_operation))); + } + + bool assignment_enabled(const details::operator_type& assignment) + { + if (disabled_assignment_set_.empty()) + return true; + else + return (disabled_assignment_set_.end() == disabled_assignment_set_.find(assign_opr_to_string(assignment))); + } + + bool inequality_enabled(const details::operator_type& inequality) + { + if (disabled_inequality_set_.empty()) + return true; + else + return (disabled_inequality_set_.end() == disabled_inequality_set_.find(inequality_opr_to_string(inequality))); + } + + bool function_disabled(const std::string& function_name) + { + if (disabled_func_set_.empty()) + return false; + else + return (disabled_func_set_.end() != disabled_func_set_.find(function_name)); + } + + bool control_struct_disabled(const std::string& control_struct) + { + if (disabled_ctrl_set_.empty()) + return false; + else + return (disabled_ctrl_set_.end() != disabled_ctrl_set_.find(control_struct)); + } + + bool logic_disabled(const std::string& logic_operation) + { + if (disabled_logic_set_.empty()) + return false; + else + return (disabled_logic_set_.end() != disabled_logic_set_.find(logic_operation)); + } + + bool assignment_disabled(const details::operator_type assignment_operation) + { + if (disabled_assignment_set_.empty()) + return false; + else + return (disabled_assignment_set_.end() != disabled_assignment_set_.find(assign_opr_to_string(assignment_operation))); + } + + bool arithmetic_disabled(const details::operator_type arithmetic_operation) + { + if (disabled_arithmetic_set_.empty()) + return false; + else + return (disabled_arithmetic_set_.end() != disabled_arithmetic_set_.find(arith_opr_to_string(arithmetic_operation))); + } + + bool inequality_disabled(const details::operator_type& inequality) + { + if (disabled_inequality_set_.empty()) + return false; + else + return (disabled_inequality_set_.end() != disabled_inequality_set_.find(inequality_opr_to_string(inequality))); + } + + settings_store& disable_base_function(settings_base_funcs bf) + { + if ( + (e_bf_unknown != bf) && + (static_cast(bf) < (details::base_function_list_size + 1)) + ) + { + disabled_func_set_.insert(details::base_function_list[bf - 1]); + } + + return *this; + } + + settings_store& disable_control_structure(settings_control_structs ctrl_struct) + { + if ( + (e_ctrl_unknown != ctrl_struct) && + (static_cast(ctrl_struct) < (details::cntrl_struct_list_size + 1)) + ) + { + disabled_ctrl_set_.insert(details::cntrl_struct_list[ctrl_struct - 1]); + } + + return *this; + } + + settings_store& disable_logic_operation(settings_logic_opr logic) + { + if ( + (e_logic_unknown != logic) && + (static_cast(logic) < (details::logic_ops_list_size + 1)) + ) + { + disabled_logic_set_.insert(details::logic_ops_list[logic - 1]); + } + + return *this; + } + + settings_store& disable_arithmetic_operation(settings_arithmetic_opr arithmetic) + { + if ( + (e_arith_unknown != arithmetic) && + (static_cast(arithmetic) < (details::arithmetic_ops_list_size + 1)) + ) + { + disabled_arithmetic_set_.insert(details::arithmetic_ops_list[arithmetic - 1]); + } + + return *this; + } + + settings_store& disable_assignment_operation(settings_assignment_opr assignment) + { + if ( + (e_assign_unknown != assignment) && + (static_cast(assignment) < (details::assignment_ops_list_size + 1)) + ) + { + disabled_assignment_set_.insert(details::assignment_ops_list[assignment - 1]); + } + + return *this; + } + + settings_store& disable_inequality_operation(settings_inequality_opr inequality) + { + if ( + (e_ineq_unknown != inequality) && + (static_cast(inequality) < (details::inequality_ops_list_size + 1)) + ) + { + disabled_inequality_set_.insert(details::inequality_ops_list[inequality - 1]); + } + + return *this; + } + + settings_store& enable_base_function(settings_base_funcs bf) + { + if ( + (e_bf_unknown != bf) && + (static_cast(bf) < (details::base_function_list_size + 1)) + ) + { + des_itr_t itr = disabled_func_set_.find(details::base_function_list[bf - 1]); + + if (disabled_func_set_.end() != itr) + { + disabled_func_set_.erase(itr); + } + } + + return *this; + } + + settings_store& enable_control_structure(settings_control_structs ctrl_struct) + { + if ( + (e_ctrl_unknown != ctrl_struct) && + (static_cast(ctrl_struct) < (details::cntrl_struct_list_size + 1)) + ) + { + des_itr_t itr = disabled_ctrl_set_.find(details::cntrl_struct_list[ctrl_struct - 1]); + + if (disabled_ctrl_set_.end() != itr) + { + disabled_ctrl_set_.erase(itr); + } + } + + return *this; + } + + settings_store& enable_logic_operation(settings_logic_opr logic) + { + if ( + (e_logic_unknown != logic) && + (static_cast(logic) < (details::logic_ops_list_size + 1)) + ) + { + des_itr_t itr = disabled_logic_set_.find(details::logic_ops_list[logic - 1]); + + if (disabled_logic_set_.end() != itr) + { + disabled_logic_set_.erase(itr); + } + } + + return *this; + } + + settings_store& enable_arithmetic_operation(settings_arithmetic_opr arithmetic) + { + if ( + (e_arith_unknown != arithmetic) && + (static_cast(arithmetic) < (details::arithmetic_ops_list_size + 1)) + ) + { + des_itr_t itr = disabled_arithmetic_set_.find(details::arithmetic_ops_list[arithmetic - 1]); + + if (disabled_arithmetic_set_.end() != itr) + { + disabled_arithmetic_set_.erase(itr); + } + } + + return *this; + } + + settings_store& enable_assignment_operation(settings_assignment_opr assignment) + { + if ( + (e_assign_unknown != assignment) && + (static_cast(assignment) < (details::assignment_ops_list_size + 1)) + ) + { + des_itr_t itr = disabled_assignment_set_.find(details::assignment_ops_list[assignment - 1]); + + if (disabled_assignment_set_.end() != itr) + { + disabled_assignment_set_.erase(itr); + } + } + + return *this; + } + + settings_store& enable_inequality_operation(settings_inequality_opr inequality) + { + if ( + (e_ineq_unknown != inequality) && + (static_cast(inequality) < (details::inequality_ops_list_size + 1)) + ) + { + des_itr_t itr = disabled_inequality_set_.find(details::inequality_ops_list[inequality - 1]); + + if (disabled_inequality_set_.end() != itr) + { + disabled_inequality_set_.erase(itr); + } + } + + return *this; + } + + private: + + void load_compile_options(const std::size_t compile_options) + { + enable_replacer_ = (compile_options & e_replacer ) == e_replacer; + enable_joiner_ = (compile_options & e_joiner ) == e_joiner; + enable_numeric_check_ = (compile_options & e_numeric_check ) == e_numeric_check; + enable_bracket_check_ = (compile_options & e_bracket_check ) == e_bracket_check; + enable_sequence_check_ = (compile_options & e_sequence_check ) == e_sequence_check; + enable_commutative_check_ = (compile_options & e_commutative_check ) == e_commutative_check; + enable_strength_reduction_ = (compile_options & e_strength_reduction ) == e_strength_reduction; + enable_collect_vars_ = (compile_options & e_collect_vars ) == e_collect_vars; + enable_collect_funcs_ = (compile_options & e_collect_funcs ) == e_collect_funcs; + enable_collect_assings_ = (compile_options & e_collect_assings ) == e_collect_assings; + disable_vardef_ = (compile_options & e_disable_vardef ) == e_disable_vardef; + disable_rsrvd_sym_usr_ = (compile_options & e_disable_usr_on_rsrvd) == e_disable_usr_on_rsrvd; + disable_zero_return_ = (compile_options & e_disable_zero_return ) == e_disable_zero_return; + } + + std::string assign_opr_to_string(details::operator_type opr) + { + switch (opr) + { + case details::e_assign : return ":="; + case details::e_addass : return "+="; + case details::e_subass : return "-="; + case details::e_mulass : return "*="; + case details::e_divass : return "/="; + case details::e_modass : return "%="; + default : return ""; + } + } + + std::string arith_opr_to_string(details::operator_type opr) + { + switch (opr) + { + case details::e_add : return "+"; + case details::e_sub : return "-"; + case details::e_mul : return "*"; + case details::e_div : return "/"; + case details::e_mod : return "%"; + default : return ""; + } + } + + std::string inequality_opr_to_string(details::operator_type opr) + { + switch (opr) + { + case details::e_lt : return "<"; + case details::e_lte : return "<="; + case details::e_eq : return "=="; + case details::e_equal : return "="; + case details::e_ne : return "!="; + case details::e_nequal: return "<>"; + case details::e_gte : return ">="; + case details::e_gt : return ">"; + default : return ""; + } + } + + bool enable_replacer_; + bool enable_joiner_; + bool enable_numeric_check_; + bool enable_bracket_check_; + bool enable_sequence_check_; + bool enable_commutative_check_; + bool enable_strength_reduction_; + bool enable_collect_vars_; + bool enable_collect_funcs_; + bool enable_collect_assings_; + bool disable_vardef_; + bool disable_rsrvd_sym_usr_; + bool disable_zero_return_; + + disabled_entity_set_t disabled_func_set_ ; + disabled_entity_set_t disabled_ctrl_set_ ; + disabled_entity_set_t disabled_logic_set_; + disabled_entity_set_t disabled_arithmetic_set_; + disabled_entity_set_t disabled_assignment_set_; + disabled_entity_set_t disabled_inequality_set_; + + friend class parser; + }; + + typedef settings_store settings_t; + + parser(const settings_t& settings = settings_t()) + : settings_(settings), + resolve_unknown_symbol_(false), + results_context_(0), + unknown_symbol_resolver_(reinterpret_cast(0)), +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning (disable:4355) +#endif + sem_(*this), +#ifdef _MSC_VER +#pragma warning(pop) +#endif + operator_joiner_2_(2), + operator_joiner_3_(3) + { + init_precompilation(); + + load_operations_map (base_ops_map_ ); + load_unary_operations_map (unary_op_map_ ); + load_binary_operations_map (binary_op_map_ ); + load_inv_binary_operations_map(inv_binary_op_map_); + load_sf3_map (sf3_map_ ); + load_sf4_map (sf4_map_ ); + + expression_generator_.init_synthesize_map(); + expression_generator_.set_parser(*this); + expression_generator_.set_uom(unary_op_map_); + expression_generator_.set_bom(binary_op_map_); + expression_generator_.set_ibom(inv_binary_op_map_); + expression_generator_.set_sf3m(sf3_map_); + expression_generator_.set_sf4m(sf4_map_); + expression_generator_.set_strength_reduction_state(settings_.strength_reduction_enabled()); + } + + ~parser() + {} + + inline void init_precompilation() + { + if (settings_.collect_variables_enabled()) + dec_.collect_variables() = true; + + if (settings_.collect_functions_enabled()) + dec_.collect_functions() = true; + + if (settings_.collect_assignments_enabled()) + dec_.collect_assignments() = true; + + if (settings_.replacer_enabled()) + { + symbol_replacer_.clear(); + symbol_replacer_.add_replace("true" ,"1",lexer::token::e_number); + symbol_replacer_.add_replace("false","0",lexer::token::e_number); + helper_assembly_.token_modifier_list.clear(); + helper_assembly_.register_modifier(&symbol_replacer_); + } + + if (settings_.commutative_check_enabled()) + { + for (std::size_t i = 0; i < details::reserved_words_size; ++i) + { + commutative_inserter_.ignore_symbol(details::reserved_words[i]); + } + + helper_assembly_.token_inserter_list.clear(); + helper_assembly_.register_inserter(&commutative_inserter_); + } + + if (settings_.joiner_enabled()) + { + helper_assembly_.token_joiner_list.clear(); + helper_assembly_.register_joiner(&operator_joiner_2_); + helper_assembly_.register_joiner(&operator_joiner_3_); + } + + if ( + settings_.numeric_check_enabled () || + settings_.bracket_check_enabled () || + settings_.sequence_check_enabled() + ) + { + helper_assembly_.token_scanner_list.clear(); + + if (settings_.numeric_check_enabled()) + { + helper_assembly_.register_scanner(&numeric_checker_); + } + + if (settings_.bracket_check_enabled()) + { + helper_assembly_.register_scanner(&bracket_checker_); + } + + if (settings_.sequence_check_enabled()) + { + helper_assembly_.register_scanner(&sequence_validator_); + } + } + } + + inline bool compile(const std::string& expression_string, expression& expr) + { + state_ .reset(); + error_list_ .clear(); + brkcnt_list_ .clear(); + synthesis_error_.clear(); + sem_ .cleanup(); + + return_cleanup(); + + expression_generator_.set_allocator(node_allocator_); + + if (expression_string.empty()) + { + set_error( + make_error(parser_error::e_syntax, + "ERR000 - Empty expression!")); + + return false; } - - return error_node(); - } - - const std::string var1_name = current_token_.value; - - if (!token_is(token_t::e_symbol,false)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR150 - Expected a symbol for variable or vector element definition")); - - if (variable0_generated) + + if (!init(expression_string)) { - free_node(node_allocator_,variable0); + process_lexer_errors(); + return false; } - - return error_node(); - } - else if (peek_token_is(token_t::e_lsqrbracket)) - { - if (0 == (variable1 = parse_vector())) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR151 - Second parameter to swap is an invalid vector element: '" + var1_name + "'")); - - if (variable0_generated) - { - free_node(node_allocator_,variable0); - } - - return error_node(); - } - - variable1_generated = true; - } - else - { - if (symbol_table_.is_variable(var1_name)) + + if (lexer().empty()) { - variable1 = symbol_table_.get_variable(var1_name); + set_error( + make_error(parser_error::e_syntax, + "ERR001 - Empty expression!")); + + return false; } - - scope_element& se = sem_.get_element(var1_name); - - if ( - (se.active) && - (se.name == var1_name) && - (scope_element::e_variable == se.type) - ) + + if (!run_assemblies()) { - variable1 = se.var_node; + return false; } - - lodge_symbol(var1_name,e_st_variable); - - if (0 == variable1) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR152 - Second parameter to swap is an invalid variable: '" + var1_name + "'")); - - if (variable0_generated) - { - free_node(node_allocator_,variable0); - } - - return error_node(); + + symtab_store_.symtab_list_ = expr.get_symbol_table_list(); + dec_.clear(); + + lexer().begin(); + + next_token(); + + expression_node_ptr e = parse_corpus(); + + if ((0 != e) && (token_t::e_eof == current_token().type)) + { + bool* retinvk_ptr = 0; + + if (state_.return_stmt_present) + { + dec_.return_present_ = true; + + e = expression_generator_ + .return_envelope(e,results_context_,retinvk_ptr); + } + + expr.set_expression(e); + expr.set_retinvk(retinvk_ptr); + + register_local_vars(expr); + register_return_results(expr); + + return !(!expr); } else - next_token(); - } - - if (!token_is(token_t::e_rbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR153 - Expected ')' at end of swap statement")); - - if (variable0_generated) { - free_node(node_allocator_,variable0); + if (error_list_.empty()) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR002 - Invalid expression encountered")); + } + + dec_.clear (); + sem_.cleanup (); + return_cleanup(); + + if ((0 != e) && branch_deletable(e)) + { + delete e; + } + + return false; + } + } + + void process_lexer_errors() + { + for (std::size_t i = 0; i < lexer().size(); ++i) + { + if (lexer()[i].is_error()) + { + std::string diagnostic = "ERR003 - "; + + switch (lexer()[i].type) + { + case lexer::token::e_error : diagnostic += "General token error"; + break; + + case lexer::token::e_err_symbol : diagnostic += "Symbol error"; + break; + + case lexer::token::e_err_number : diagnostic += "Invalid numeric token"; + break; + + case lexer::token::e_err_string : diagnostic += "Invalid string token"; + break; + + case lexer::token::e_err_sfunc : diagnostic += "Invalid special function token"; + break; + + default : diagnostic += "Unknown compiler error"; + } + + set_error( + make_error(parser_error::e_lexer, + lexer()[i], + diagnostic + ": " + lexer()[i].value)); + } + } + } + + inline bool run_assemblies() + { + if (settings_.commutative_check_enabled()) + { + helper_assembly_.run_inserters(lexer()); + } + + if (settings_.joiner_enabled()) + { + helper_assembly_.run_joiners(lexer()); + } + + if (settings_.replacer_enabled()) + { + helper_assembly_.run_modifiers(lexer()); + } + + if ( + settings_.numeric_check_enabled () || + settings_.bracket_check_enabled () || + settings_.sequence_check_enabled() + ) + { + if (!helper_assembly_.run_scanners(lexer())) + { + if (helper_assembly_.error_token_scanner) + { + lexer::helper::bracket_checker* bracket_checker_ptr = 0; + lexer::helper::numeric_checker* numeric_checker_ptr = 0; + lexer::helper::sequence_validator* sequence_validator_ptr = 0; + + if (0 != (bracket_checker_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) + { + set_error( + make_error(parser_error::e_token, + bracket_checker_ptr->error_token(), + "ERR004 - Mismatched brackets: '" + bracket_checker_ptr->error_token().value + "'")); + } + else if (0 != (numeric_checker_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) + { + for (std::size_t i = 0; i < numeric_checker_ptr->error_count(); ++i) + { + lexer::token error_token = lexer()[numeric_checker_ptr->error_index(i)]; + + set_error( + make_error(parser_error::e_token, + error_token, + "ERR005 - Invalid numeric token: '" + error_token.value + "'")); + } + + if (numeric_checker_ptr->error_count()) + { + numeric_checker_ptr->clear_errors(); + } + } + else if (0 != (sequence_validator_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) + { + for (std::size_t i = 0; i < sequence_validator_ptr->error_count(); ++i) + { + std::pair error_token = sequence_validator_ptr->error(i); + + set_error( + make_error(parser_error::e_token, + error_token.first, + "ERR006 - Invalid token sequence: '" + + error_token.first.value + "' and '" + + error_token.second.value + "'")); + } + + if (sequence_validator_ptr->error_count()) + { + sequence_validator_ptr->clear_errors(); + } + } + } + + return false; + } } - - if (variable1_generated) + + return true; + } + + inline settings_store& settings() + { + return settings_; + } + + inline parser_error::type get_error(const std::size_t& index) + { + if (index < error_list_.size()) + return error_list_[index]; + else + throw std::invalid_argument("parser::get_error() - Invalid error index specificed"); + } + + inline std::string error() const + { + if (!error_list_.empty()) { - free_node(node_allocator_,variable1); + return error_list_[0].diagnostic; } - - return error_node(); - } - - typedef details::variable_node* variable_node_ptr; - variable_node_ptr v0 = variable_node_ptr(0); - variable_node_ptr v1 = variable_node_ptr(0); - - if ( - (0 != (v0 = dynamic_cast(variable0))) && - (0 != (v1 = dynamic_cast(variable1))) - ) - { - expression_node_ptr result = node_allocator_.allocate >(v0,v1); - - if (variable0_generated) + else + return std::string("No Error"); + } + + inline std::size_t error_count() const + { + return error_list_.size(); + } + + inline dependent_entity_collector& dec() + { + return dec_; + } + + inline bool replace_symbol(const std::string& old_symbol, const std::string& new_symbol) + { + if (!settings_.replacer_enabled()) + return false; + else if (details::is_reserved_word(old_symbol)) + return false; + else + return symbol_replacer_.add_replace(old_symbol,new_symbol,lexer::token::e_symbol); + } + + inline bool remove_replace_symbol(const std::string& symbol) + { + if (!settings_.replacer_enabled()) + return false; + else if (details::is_reserved_word(symbol)) + return false; + else + return symbol_replacer_.remove(symbol); + } + + inline void enable_unknown_symbol_resolver(unknown_symbol_resolver* usr = reinterpret_cast(0)) + { + resolve_unknown_symbol_ = true; + + if (usr) + unknown_symbol_resolver_ = usr; + else + unknown_symbol_resolver_ = &default_usr_; + } + + inline void disable_unknown_symbol_resolver() + { + resolve_unknown_symbol_ = false; + unknown_symbol_resolver_ = &default_usr_; + } + + private: + + inline bool valid_base_operation(const std::string& symbol) + { + const std::size_t length = symbol.size(); + + if ( + (length < 3) || // Shortest base op symbol length + (length > 9) // Longest base op symbol length + ) + return false; + else + return settings_.function_enabled(symbol) && + (base_ops_map_.end() != base_ops_map_.find(symbol)); + } + + inline bool valid_vararg_operation(const std::string& symbol) + { + static const std::string s_sum = "sum" ; + static const std::string s_mul = "mul" ; + static const std::string s_avg = "avg" ; + static const std::string s_min = "min" ; + static const std::string s_max = "max" ; + static const std::string s_mand = "mand"; + static const std::string s_mor = "mor" ; + static const std::string s_multi = "~" ; + static const std::string s_mswitch = "[*]" ; + + return + ( + details::imatch(symbol,s_sum ) || + details::imatch(symbol,s_mul ) || + details::imatch(symbol,s_avg ) || + details::imatch(symbol,s_min ) || + details::imatch(symbol,s_max ) || + details::imatch(symbol,s_mand ) || + details::imatch(symbol,s_mor ) || + details::imatch(symbol,s_multi ) || + details::imatch(symbol,s_mswitch) + ) && + settings_.function_enabled(symbol); + } + + bool is_invalid_arithmetic_operation(const details::operator_type operation) + { + return settings_.arithmetic_disabled(operation); + } + + bool is_invalid_assignment_operation(const details::operator_type operation) + { + return settings_.assignment_disabled(operation); + } + + bool is_invalid_inequality_operation(const details::operator_type operation) + { + return settings_.inequality_disabled(operation); + } + +#ifdef exprtk_enable_debugging + inline void next_token() + { + std::string ct_str = current_token().value; + parser_helper::next_token(); + std::string depth(2 * state_.scope_depth,' '); + exprtk_debug(("%s" + "prev[%s] --> curr[%s]\n", + depth.c_str(), + ct_str.c_str(), + current_token().value.c_str())); + } +#endif + + inline expression_node_ptr parse_corpus() + { + std::vector arg_list; + std::vector side_effect_list; + + expression_node_ptr result = error_node(); + + scoped_vec_delete sdd(*this,arg_list); + + lexer::token begin_token; + lexer::token end_token; + + for ( ; ; ) + { + state_.side_effect_present = false; + + begin_token = current_token(); + + expression_node_ptr arg = parse_expression(); + + if (0 == arg) + { + if (error_list_.empty()) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR007 - Invalid expression encountered")); + } + + return error_node(); + } + else + { + arg_list.push_back(arg); + + side_effect_list.push_back(state_.side_effect_present); + + end_token = current_token(); + + std::string sub_expr = construct_subexpr(begin_token,end_token); + + exprtk_debug(("parse_corpus(%02d) Subexpr: %s\n", + static_cast(arg_list.size() - 1), + sub_expr.c_str())); + + exprtk_debug(("parse_corpus(%02d) - Side effect present: %s\n", + static_cast(arg_list.size() - 1), + state_.side_effect_present ? "true" : "false")); + + exprtk_debug(("-------------------------------------------------\n")); + } + + if (lexer().finished()) + break; + else if (token_is(token_t::e_eof,prsrhlpr_t::e_hold)) + { + if (lexer().finished()) + break; + else + next_token(); + } + } + + if ( + !arg_list.empty() && + is_return_node(arg_list.back()) + ) { - free_node(node_allocator_,variable0); + dec_.final_stmt_return_ = true; } - - if (variable1_generated) + + result = simplify(arg_list,side_effect_list); + + sdd.delete_ptr = (0 == result); + + return result; + } + + std::string construct_subexpr(lexer::token& begin_token, lexer::token& end_token) + { + std::string result = lexer().substr(begin_token.position,end_token.position); + + for (std::size_t i = 0; i < result.size(); ++i) { - free_node(node_allocator_,variable1); + if (details::is_whitespace(result[i])) result[i] = ' '; } - + return result; - } - else - return node_allocator_.allocate >(variable0,variable1); - } - - inline bool post_variable_process(const std::string& symbol) - { - if ( - peek_token_is(token_t::e_lbracket ) || - peek_token_is(token_t::e_lcrlbracket) || - peek_token_is(token_t::e_lsqrbracket) - ) - { - if (!commutative_check_enabled()) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR154 - Invalid sequence of variable '"+ symbol + "' and bracket")); - - return false; - } - - lexer_.insert_front(token_t::e_mul); - } - - return true; - } - - inline bool post_bracket_process(const typename token_t::token_type& token, expression_node_ptr& branch) - { - bool implied_mul = false; - - if (is_generally_string_node(branch)) - return true; - - switch (token) - { - case token_t::e_lcrlbracket : implied_mul = token_is(token_t::e_lbracket ,false) || - token_is(token_t::e_lcrlbracket,false) || - token_is(token_t::e_lsqrbracket,false) ; - break; - - case token_t::e_lbracket : implied_mul = token_is(token_t::e_lbracket ,false) || - token_is(token_t::e_lcrlbracket,false) || - token_is(token_t::e_lsqrbracket,false) ; - break; - - case token_t::e_lsqrbracket : implied_mul = token_is(token_t::e_lbracket ,false) || - token_is(token_t::e_lcrlbracket,false) || - token_is(token_t::e_lsqrbracket,false) ; - break; - - default : return true; - } - - if (implied_mul) - { - if (!commutative_check_enabled()) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR155 - Invalid sequence of brackets")); - - return false; + } + + static const precedence_level default_precedence = e_level00; + + struct state_t + { + inline void set(const precedence_level& l, + const precedence_level& r, + const details::operator_type& o) + { + left = l; + right = r; + operation = o; + } + + inline void reset() + { + left = e_level00; + right = e_level00; + operation = details::e_default; + } + + precedence_level left; + precedence_level right; + details::operator_type operation; + }; + + inline expression_node_ptr parse_expression(precedence_level precedence = e_level00) + { + expression_node_ptr expression = parse_branch(precedence); + + if (0 == expression) + { + return error_node(); + } + + bool break_loop = false; + + state_t current_state; + + for ( ; ; ) + { + current_state.reset(); + + switch (current_token().type) + { + case token_t::e_assign : current_state.set(e_level00,e_level00,details::e_assign); break; + case token_t::e_addass : current_state.set(e_level00,e_level00,details::e_addass); break; + case token_t::e_subass : current_state.set(e_level00,e_level00,details::e_subass); break; + case token_t::e_mulass : current_state.set(e_level00,e_level00,details::e_mulass); break; + case token_t::e_divass : current_state.set(e_level00,e_level00,details::e_divass); break; + case token_t::e_modass : current_state.set(e_level00,e_level00,details::e_modass); break; + case token_t::e_swap : current_state.set(e_level00,e_level00,details::e_swap ); break; + case token_t::e_lt : current_state.set(e_level05,e_level06,details:: e_lt); break; + case token_t::e_lte : current_state.set(e_level05,e_level06,details:: e_lte); break; + case token_t::e_eq : current_state.set(e_level05,e_level06,details:: e_eq); break; + case token_t::e_ne : current_state.set(e_level05,e_level06,details:: e_ne); break; + case token_t::e_gte : current_state.set(e_level05,e_level06,details:: e_gte); break; + case token_t::e_gt : current_state.set(e_level05,e_level06,details:: e_gt); break; + case token_t::e_add : current_state.set(e_level07,e_level08,details:: e_add); break; + case token_t::e_sub : current_state.set(e_level07,e_level08,details:: e_sub); break; + case token_t::e_div : current_state.set(e_level10,e_level11,details:: e_div); break; + case token_t::e_mul : current_state.set(e_level10,e_level11,details:: e_mul); break; + case token_t::e_mod : current_state.set(e_level10,e_level11,details:: e_mod); break; + case token_t::e_pow : current_state.set(e_level12,e_level12,details:: e_pow); break; + default : if (token_t::e_symbol == current_token().type) + { + static const std::string s_and = "and"; + static const std::string s_nand = "nand"; + static const std::string s_or = "or"; + static const std::string s_nor = "nor"; + static const std::string s_xor = "xor"; + static const std::string s_xnor = "xnor"; + static const std::string s_in = "in"; + static const std::string s_like = "like"; + static const std::string s_ilike = "ilike"; + static const std::string s_and1 = "&"; + static const std::string s_or1 = "|"; + + if (details::imatch(current_token().value,s_and)) + { + current_state.set(e_level03,e_level04,details::e_and); + break; + } + else if (details::imatch(current_token().value,s_and1)) + { +#ifndef exprtk_disable_sc_andor + current_state.set(e_level03,e_level04,details::e_scand); +#else + current_state.set(e_level03,e_level04,details::e_and); +#endif + break; + } + else if (details::imatch(current_token().value,s_nand)) + { + current_state.set(e_level03,e_level04,details::e_nand); + break; + } + else if (details::imatch(current_token().value,s_or)) + { + current_state.set(e_level01,e_level02,details::e_or); + break; + } + else if (details::imatch(current_token().value,s_or1)) + { +#ifndef exprtk_disable_sc_andor + current_state.set(e_level01,e_level02,details::e_scor); +#else + current_state.set(e_level01,e_level02,details::e_or); +#endif + break; + } + else if (details::imatch(current_token().value,s_nor)) + { + current_state.set(e_level01,e_level02,details::e_nor); + break; + } + else if (details::imatch(current_token().value,s_xor)) + { + current_state.set(e_level01,e_level02,details::e_xor); + break; + } + else if (details::imatch(current_token().value,s_xnor)) + { + current_state.set(e_level01,e_level02,details::e_xnor); + break; + } + else if (details::imatch(current_token().value,s_in)) + { + current_state.set(e_level04,e_level04,details::e_in); + break; + } + else if (details::imatch(current_token().value,s_like)) + { + current_state.set(e_level04,e_level04,details::e_like); + break; + } + else if (details::imatch(current_token().value,s_ilike)) + { + current_state.set(e_level04,e_level04,details::e_ilike); + break; + } + } + + break_loop = true; + } + + if (break_loop) + { + parse_pending_string_rangesize(expression); + break; + } + else if (current_state.left < precedence) + break; + + lexer::token prev_token = current_token(); + + next_token(); + + expression_node_ptr right_branch = error_node(); + expression_node_ptr new_expression = error_node(); + + if (is_invalid_arithmetic_operation(current_state.operation)) + { + free_node(node_allocator_,expression); + + set_error( + make_error(parser_error::e_syntax, + prev_token, + "ERR008 - Invalid arithmetic operation '" + details::to_str(current_state.operation) + "'")); + + return error_node(); + } + else if (is_invalid_inequality_operation(current_state.operation)) + { + free_node(node_allocator_,expression); + + set_error( + make_error(parser_error::e_syntax, + prev_token, + "ERR009 - Invalid inequality operation '" + details::to_str(current_state.operation) + "'")); + + return error_node(); + } + else if (is_invalid_assignment_operation(current_state.operation)) + { + free_node(node_allocator_,expression); + + set_error( + make_error(parser_error::e_syntax, + prev_token, + "ERR010 - Invalid assignment operation '" + details::to_str(current_state.operation) + "'")); + + return error_node(); + } + + if (0 != (right_branch = parse_expression(current_state.right))) + { + if ( + details::is_return_node( expression) || + details::is_return_node(right_branch) + ) + { + free_node(node_allocator_, expression); + free_node(node_allocator_,right_branch); + + set_error( + make_error(parser_error::e_syntax, + prev_token, + "ERR011 - Return statements cannot be part of sub-expressions")); + + return error_node(); + } + + new_expression = expression_generator_ + ( + current_state.operation, + expression, + right_branch + ); + } + + if (0 == new_expression) + { + if (error_list_.empty()) + { + set_error( + make_error(parser_error::e_syntax, + prev_token, + !synthesis_error_.empty() ? + synthesis_error_ : + "ERR012 - General parsing error at token: '" + prev_token.value + "'")); + } + + free_node(node_allocator_,expression); + + return error_node(); + } + else + { + if ( + token_is(token_t::e_ternary,prsrhlpr_t::e_hold) && + (precedence == e_level00) + ) + { + expression = parse_ternary_conditional_statement(new_expression); + } + else + expression = new_expression; + + parse_pending_string_rangesize(expression); + } + } + + return expression; + } + + bool simplify_unary_negation_branch(expression_node_ptr& node) + { + { + typedef details::unary_branch_node > ubn_t; + ubn_t* n = dynamic_cast(node); + + if (n) + { + expression_node_ptr un_r = n->branch(0); + n->release(); + free_node(node_allocator_,node); + node = un_r; + + return true; + } + } + + { + typedef details::unary_variable_node > uvn_t; + + uvn_t* n = dynamic_cast(node); + + if (n) + { + const T& v = n->v(); + expression_node_ptr return_node = error_node(); + + if ( + (0 != (return_node = symtab_store_.get_variable(v))) || + (0 != (return_node = sem_ .get_variable(v))) + ) + { + free_node(node_allocator_,node); + node = return_node; + + return true; + } + else + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR013 - Failed to find variable node in symbol table")); + + free_node(node_allocator_,node); + + return false; + } + } } - else if (token_t::e_eof != current_token_.type) + + return false; + } + + static inline expression_node_ptr error_node() + { + return reinterpret_cast(0); + } + + template + struct scoped_delete + { + typedef Type* ptr_t; + + scoped_delete(parser& pr, ptr_t& p) + : delete_ptr(true), + parser_(pr), + p_(&p) + {} + + scoped_delete(parser& pr, ptr_t (&p)[N]) + : delete_ptr(true), + parser_(pr), + p_(&p[0]) + {} + + ~scoped_delete() + { + if (delete_ptr) + { + for (std::size_t i = 0; i < N; ++i) + { + free_node(parser_.node_allocator_,p_[i]); + } + } + } + + bool delete_ptr; + parser& parser_; + ptr_t* p_; + + private: + + scoped_delete& operator=(const scoped_delete&); + }; + + template + struct scoped_deq_delete + { + typedef Type* ptr_t; + + scoped_deq_delete(parser& pr, std::deque& deq) + : delete_ptr(true), + parser_(pr), + deq_(deq) + {} + + ~scoped_deq_delete() + { + if (delete_ptr && !deq_.empty()) + { + for (std::size_t i = 0; i < deq_.size(); ++i) + { + free_node(parser_.node_allocator_,deq_[i]); + } + + deq_.clear(); + } + } + + bool delete_ptr; + parser& parser_; + std::deque& deq_; + + private: + + scoped_deq_delete& operator=(const scoped_deq_delete&); + }; + + template + struct scoped_vec_delete + { + typedef Type* ptr_t; + + scoped_vec_delete(parser& pr, std::vector& vec) + : delete_ptr(true), + parser_(pr), + vec_(vec) + {} + + ~scoped_vec_delete() + { + if (delete_ptr && !vec_.empty()) + { + for (std::size_t i = 0; i < vec_.size(); ++i) + { + free_node(parser_.node_allocator_,vec_[i]); + } + + vec_.clear(); + } + } + + bool delete_ptr; + parser& parser_; + std::vector& vec_; + + private: + + scoped_vec_delete& operator=(const scoped_vec_delete&); + }; + + struct scoped_bool_negator + { + scoped_bool_negator(bool& bb) + : b(bb) + { b = !b; } + + ~scoped_bool_negator() + { b = !b; } + + bool& b; + }; + + struct scoped_bool_or_restorer + { + scoped_bool_or_restorer(bool& bb) + : b(bb), + original_value_(bb) + {} + + ~scoped_bool_or_restorer() { - lexer_.insert_front(current_token_.type); - lexer_.insert_front(token_t::e_mul); - next_token(); + b = b || original_value_; } - } - - return true; - } - - inline expression_node_ptr parse_symtab_symbol() - { - const std::string symbol = current_token_.value; - - // Are we dealing with a variable or a special constant? - expression_node_ptr variable = symbol_table_.get_variable(symbol); - - if (variable) - { - if (symbol_table_.is_constant_node(symbol)) + + bool& b; + bool original_value_; + }; + + inline expression_node_ptr parse_function_invocation(ifunction* function, const std::string& function_name) + { + expression_node_ptr func_node = reinterpret_cast(0); + + switch (function->param_count) + { + case 0 : func_node = parse_function_call_0 (function,function_name); break; + case 1 : func_node = parse_function_call< 1>(function,function_name); break; + case 2 : func_node = parse_function_call< 2>(function,function_name); break; + case 3 : func_node = parse_function_call< 3>(function,function_name); break; + case 4 : func_node = parse_function_call< 4>(function,function_name); break; + case 5 : func_node = parse_function_call< 5>(function,function_name); break; + case 6 : func_node = parse_function_call< 6>(function,function_name); break; + case 7 : func_node = parse_function_call< 7>(function,function_name); break; + case 8 : func_node = parse_function_call< 8>(function,function_name); break; + case 9 : func_node = parse_function_call< 9>(function,function_name); break; + case 10 : func_node = parse_function_call<10>(function,function_name); break; + case 11 : func_node = parse_function_call<11>(function,function_name); break; + case 12 : func_node = parse_function_call<12>(function,function_name); break; + case 13 : func_node = parse_function_call<13>(function,function_name); break; + case 14 : func_node = parse_function_call<14>(function,function_name); break; + case 15 : func_node = parse_function_call<15>(function,function_name); break; + case 16 : func_node = parse_function_call<16>(function,function_name); break; + case 17 : func_node = parse_function_call<17>(function,function_name); break; + case 18 : func_node = parse_function_call<18>(function,function_name); break; + case 19 : func_node = parse_function_call<19>(function,function_name); break; + case 20 : func_node = parse_function_call<20>(function,function_name); break; + default : { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR014 - Invalid number of parameters for function: '" + function_name + "'")); + + return error_node(); + } + } + + if (func_node) + return func_node; + else + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR015 - Failed to generate call to function: '" + function_name + "'")); + + return error_node(); + } + } + + template + inline expression_node_ptr parse_function_call(ifunction* function, const std::string& function_name) + { +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4127) +#endif + if (0 == NumberofParameters) { - variable = expression_generator_(variable->value()); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR016 - Expecting ifunction '" + function_name + "' to have non-zero parameter count")); + + return error_node(); } - - if (!post_variable_process(symbol)) - return error_node(); - - lodge_symbol(symbol,e_st_variable); +#ifdef _MSC_VER +#pragma warning(pop) +#endif + + expression_node_ptr branch[NumberofParameters]; + expression_node_ptr result = error_node(); + + std::fill_n(branch,NumberofParameters,reinterpret_cast(0)); + scoped_delete sd(*this,branch); + next_token(); - - return variable; - } - - // Are we dealing with a locally defined variable or vector? - if (!sem_.empty()) - { - scope_element& se = sem_.get_element(symbol); - - if (se.name == symbol) - { - if (scope_element::e_variable == se.type) - { - se.active = true; - lodge_symbol(symbol,e_st_local_variable); - - if (!post_variable_process(symbol)) - return error_node(); - - next_token(); - - return se.var_node; - } - else if (scope_element::e_vector == se.type) - { - return parse_vector(); - } - } - } - - #ifndef exprtk_disable_string_capabilities - // Are we dealing with a string variable? - if (symbol_table_.is_stringvar(symbol)) - { - return parse_string(); - } - #endif - - { - // Are we dealing with a function? - ifunction* function = symbol_table_.get_function(symbol); - - if (function) + + if (!token_is(token_t::e_lbracket)) { - lodge_symbol(symbol,e_st_function); - - expression_node_ptr func_node = - parse_function_invocation(function,symbol); - - if (func_node) - return func_node; - else - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR156 - Failed to generate node for function: '" + symbol + "'")); - - return error_node(); - } + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR017 - Expecting argument list for function: '" + function_name + "'")); + + return error_node(); + } + + for (int i = 0; i < static_cast(NumberofParameters); ++i) + { + branch[i] = parse_expression(); + + if (0 == branch[i]) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR018 - Failed to parse argument " + details::to_str(i) + " for function: '" + function_name + "'")); + + return error_node(); + } + else if (i < static_cast(NumberofParameters - 1)) + { + if (!token_is(token_t::e_comma)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR019 - Invalid number of arguments for function: '" + function_name + "'")); + + return error_node(); + } + } } - } - - { - // Are we dealing with a vararg function? - ivararg_function* vararg_function = symbol_table_.get_vararg_function(symbol); - - if (vararg_function) + + if (!token_is(token_t::e_rbracket)) { - lodge_symbol(symbol,e_st_function); - - expression_node_ptr vararg_func_node = - parse_vararg_function_call(vararg_function,symbol); - - if (vararg_func_node) - return vararg_func_node; - else - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR157 - Failed to generate node for vararg function: '" + symbol + "'")); - - return error_node(); - } + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR020 - Invalid number of arguments for function: '" + function_name + "'")); + + return error_node(); } - } - - { - // Are we dealing with a vararg generic function? - igeneric_function* generic_function = symbol_table_.get_generic_function(symbol); - - if (generic_function) + else + result = expression_generator_.function(function,branch); + + sd.delete_ptr = false; + + return result; + } + + inline expression_node_ptr parse_function_call_0(ifunction* function, const std::string& function_name) + { + expression_node_ptr result = expression_generator_.function(function); + + state_.side_effect_present = function->has_side_effects(); + + next_token(); + + if ( + token_is(token_t::e_lbracket) && + !token_is(token_t::e_rbracket) + ) { - lodge_symbol(symbol,e_st_function); - - expression_node_ptr genericfunc_node = - parse_generic_function_call(generic_function,symbol); - - if (genericfunc_node) - return genericfunc_node; - else - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR158 - Failed to generate node for generic function: '" + symbol + "'")); - - return error_node(); - } + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR021 - Expecting '()' to proceed call to function: '" + function_name + "'")); + + free_node(node_allocator_,result); + + return error_node(); } - } - - { - // Are we dealing with a vararg string returing function? - igeneric_function* string_function = symbol_table_.get_string_function(symbol); - - if (string_function) + else + return result; + } + + template + inline int parse_base_function_call(expression_node_ptr (¶m_list)[MaxNumberofParameters]) + { + std::fill_n(param_list,MaxNumberofParameters,reinterpret_cast(0)); + + scoped_delete sd(*this,param_list); + + next_token(); + + if (!token_is(token_t::e_lbracket)) { - lodge_symbol(symbol,e_st_function); - - expression_node_ptr stringfunc_node = - parse_string_function_call(string_function,symbol); - - if (stringfunc_node) - return stringfunc_node; - else - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR159 - Failed to generate node for string function: '" + symbol + "'")); - - return error_node(); - } + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR022 - Expected a '(' at start of function call, instead got: '" + current_token().value + "'")); + + return 0; + } + + int param_index = 0; + + for (; param_index < static_cast(MaxNumberofParameters); ++param_index) + { + param_list[param_index] = parse_expression(); + + if (0 == param_list[param_index]) + return 0; + else if (token_is(token_t::e_rbracket)) + break; + else if (token_is(token_t::e_comma)) + continue; + else + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR023 - Expected a ',' between function input parameters, instead got: '" + current_token().value + "'")); + + return 0; + } + } + + sd.delete_ptr = false; + + return (param_index + 1); + } + + inline expression_node_ptr parse_base_operation() + { + typedef std::pair map_range_t; + + const std::string operation_name = current_token().value; + map_range_t itr_range = base_ops_map_.equal_range(operation_name); + + if (0 == std::distance(itr_range.first,itr_range.second)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR024 - No entry found for base operation: " + operation_name)); + + return error_node(); + } + + static const std::size_t MaxNumberofParameters = 4; + expression_node_ptr param_list[MaxNumberofParameters] = {0}; + + std::size_t parameter_count = parse_base_function_call(param_list); + + if (0 == parameter_count) + { + return error_node(); + } + else if (parameter_count <= MaxNumberofParameters) + { + for (base_ops_map_t::iterator itr = itr_range.first; itr != itr_range.second; ++itr) + { + details::base_operation_t& operation = itr->second; + + if (operation.num_params == parameter_count) + { + switch (parameter_count) + { +#define base_opr_case(N) \ +case N : { \ +expression_node_ptr pl##N[N] = {0}; \ +std::copy(param_list,param_list + N,pl##N); \ +lodge_symbol(operation_name,e_st_function); \ +return expression_generator_(operation.type,pl##N); \ +} \ + + base_opr_case(1) + base_opr_case(2) + base_opr_case(3) + base_opr_case(4) +#undef base_opr_case + } + } + } } - } - - // Are we dealing with a vector element? - if (symbol_table_.is_vector(symbol)) - { - lodge_symbol(symbol,e_st_vector); - return parse_vector(); - } - - if (details::is_reserved_symbol(symbol)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR160 - Invalid use of reserved symbol '" + symbol + "'")); - - return error_node(); - } - - // Should we handle unknown symbols? - if (resolve_unknown_symbol_ && unknown_symbol_resolver_) - { - T default_value = T(0); - std::string error_message; - typename unknown_symbol_resolver::usr_symbol_type usr_symbol_type; - - if (unknown_symbol_resolver_->process(symbol,usr_symbol_type,default_value,error_message)) + + for (std::size_t i = 0; i < MaxNumberofParameters; ++i) { - bool create_result = false; - - switch (usr_symbol_type) - { - case unknown_symbol_resolver::e_usr_variable_type : create_result = symbol_table_.create_variable(symbol,default_value); - break; - - case unknown_symbol_resolver::e_usr_constant_type : create_result = symbol_table_.add_constant(symbol,default_value); - break; - - default : create_result = false; - } - - if (create_result) - { - expression_node_ptr var = symbol_table_.get_variable(symbol); - - if (var) - { - if (symbol_table_.is_constant_node(symbol)) - { - var = expression_generator_(var->value()); - } - - lodge_symbol(symbol,e_st_variable); - - if (!post_variable_process(symbol)) - return error_node(); - - next_token(); - - return var; - } - } - - set_error( - make_error(parser_error::e_symtab, - current_token_, - "ERR161 - Failed to create variable: '" + symbol + "'")); - - return error_node(); + free_node(node_allocator_,param_list[i]); } - } - - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR162 - Undefined symbol: '" + symbol + "'")); - - return error_node(); - } - - inline expression_node_ptr parse_symbol() - { - static const std::string symbol_if = "if" ; - static const std::string symbol_while = "while" ; - static const std::string symbol_repeat = "repeat" ; - static const std::string symbol_for = "for" ; - static const std::string symbol_switch = "switch" ; - static const std::string symbol_null = "null" ; - static const std::string symbol_break = "break" ; - static const std::string symbol_continue = "continue"; - static const std::string symbol_var = "var" ; - static const std::string symbol_swap = "swap" ; - - if (valid_vararg_operation(current_token_.value)) - { - return parse_vararg_function(); - } - else if (valid_base_operation(current_token_.value)) - { - return parse_base_operation(); - } - else if (details::imatch(current_token_.value,symbol_if)) - { - return parse_conditional_statement(); - } - else if (details::imatch(current_token_.value,symbol_while)) - { - return parse_while_loop(); - } - else if (details::imatch(current_token_.value,symbol_repeat)) - { - return parse_repeat_until_loop(); - } - else if (details::imatch(current_token_.value,symbol_for)) - { - return parse_for_loop(); - } - else if (details::imatch(current_token_.value,symbol_switch)) - { - return parse_switch_statement(); - } - else if (details::is_valid_sf_symbol(current_token_.value)) - { - return parse_special_function(); - } - else if (details::imatch(current_token_.value,symbol_null)) - { - return parse_null_statement(); - } - #ifndef exprtk_disable_break_continue - else if (details::imatch(current_token_.value,symbol_break)) - { - return parse_break_statement(); - } - else if (details::imatch(current_token_.value,symbol_continue)) - { - return parse_continue_statement(); - } - #endif - else if (details::imatch(current_token_.value,symbol_var)) - { - return parse_define_var_statement(); - } - else if (details::imatch(current_token_.value,symbol_swap)) - { - return parse_swap_statement(); - } - else if (symbol_table_.valid() || !sem_.empty()) - { - return parse_symtab_symbol(); - } - else - { + set_error( - make_error(parser_error::e_symtab, - current_token_, - "ERR163 - Variable or function detected, yet symbol-table is invalid, Symbol: " + current_token_.value)); - + make_error(parser_error::e_syntax, + current_token(), + "ERR025 - Invalid number of parameters for call to function: '" + operation_name + "'")); + return error_node(); - } - } - - inline expression_node_ptr parse_branch(precedence_level precedence = e_level00) - { - expression_node_ptr branch = error_node(); - - if (token_t::e_number == current_token_.type) - { - T numeric_value = T(0); - - if (details::string_to_real(current_token_.value,numeric_value)) + } + + inline expression_node_ptr parse_conditional_statement_01(expression_node_ptr condition) + { + // Parse: [if][(][condition][,][consequent][,][alternative][)] + + expression_node_ptr consequent = error_node(); + expression_node_ptr alternative = error_node(); + + bool result = true; + + if (!token_is(token_t::e_comma)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR026 - Expected ',' between if-statement condition and consequent")); + result = false; + } + else if (0 == (consequent = parse_expression())) { - expression_node_ptr literal_exp = expression_generator_(numeric_value); - next_token(); - branch = literal_exp; + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR027 - Failed to parse consequent for if-statement")); + result = false; } - else + else if (!token_is(token_t::e_comma)) { - set_error( - make_error(parser_error::e_numeric, - current_token_, - "ERR164 - Failed to convert '" + current_token_.value + "' to a number")); - - return error_node(); - } - } - else if (token_t::e_symbol == current_token_.type) - { - branch = parse_symbol(); - } - #ifndef exprtk_disable_string_capabilities - else if (token_t::e_string == current_token_.type) - { - branch = parse_const_string(); - } - #endif - else if (token_t::e_lbracket == current_token_.type) - { - next_token(); - - if (0 == (branch = parse_expression())) - return error_node(); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR028 - Expected ',' between if-statement consequent and alternative")); + result = false; + } + else if (0 == (alternative = parse_expression())) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR029 - Failed to parse alternative for if-statement")); + result = false; + } else if (!token_is(token_t::e_rbracket)) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR165 - Expected ')' instead of: '" + current_token_.value + "'")); - - free_node(node_allocator_,branch); - - return error_node(); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR030 - Expected ')' at the end of if-statement")); + result = false; } - else if (!post_bracket_process(token_t::e_lbracket,branch)) + +#ifndef exprtk_disable_string_capabilities + if (result) { - free_node(node_allocator_,branch); - - return error_node(); + const bool consq_is_str = is_generally_string_node( consequent); + const bool alter_is_str = is_generally_string_node(alternative); + + if (consq_is_str || alter_is_str) + { + if (consq_is_str && alter_is_str) + { + return expression_generator_ + .conditional_string(condition,consequent,alternative); + } + + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR031 - Return types of ternary if-statement differ")); + + result = false; + } } - } - else if (token_t::e_lsqrbracket == current_token_.type) - { - next_token(); - - if (0 == (branch = parse_expression())) - return error_node(); - else if (!token_is(token_t::e_rsqrbracket)) +#endif + + if (!result) { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR166 - Expected ']' instead of: '" + current_token_.value + "'")); - - free_node(node_allocator_,branch); - - return error_node(); + free_node(node_allocator_, condition); + free_node(node_allocator_, consequent); + free_node(node_allocator_,alternative); + + return error_node(); } - else if (!post_bracket_process(token_t::e_lsqrbracket,branch)) + else + return expression_generator_ + .conditional(condition,consequent,alternative); + } + + inline expression_node_ptr parse_conditional_statement_02(expression_node_ptr condition) + { + expression_node_ptr consequent = error_node(); + expression_node_ptr alternative = error_node(); + + bool result = true; + + if (token_is(token_t::e_lcrlbracket,prsrhlpr_t::e_hold)) + { + if (0 == (consequent = parse_multi_sequence("if-statement-01"))) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR032 - Failed to parse body of consequent for if-statement")); + result = false; + } + } + else { - free_node(node_allocator_,branch); - - return error_node(); + if ( + settings_.commutative_check_enabled() && + token_is(token_t::e_mul,prsrhlpr_t::e_hold) + ) + { + next_token(); + } + + if (0 != (consequent = parse_expression())) + { + if (!token_is(token_t::e_eof)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR033 - Expected ';' at the end of the consequent for if-statement")); + result = false; + } + } + else + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR034 - Failed to parse body of consequent for if-statement")); + result = false; + } + } + + if (result) + { + if (details::imatch(current_token().value,"else")) + { + next_token(); + + if (token_is(token_t::e_lcrlbracket,prsrhlpr_t::e_hold)) + { + if (0 == (alternative = parse_multi_sequence("else-statement-01"))) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR035 - Failed to parse body of the 'else' for if-statement")); + result = false; + } + } + else if (details::imatch(current_token().value,"if")) + { + if (0 == (alternative = parse_conditional_statement())) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR036 - Failed to parse body of if-else statement")); + result = false; + } + } + else if (0 != (alternative = parse_expression())) + { + if (!token_is(token_t::e_eof)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR037 - Expected ';' at the end of the 'else-if' for the if-statement")); + result = false; + } + } + else + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR038 - Failed to parse body of the 'else' for if-statement")); + result = false; + } + } } - } - else if (token_t::e_lcrlbracket == current_token_.type) - { - next_token(); - - if (0 == (branch = parse_expression())) - return error_node(); - else if (!token_is(token_t::e_rcrlbracket)) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR167 - Expected '}' instead of: '" + current_token_.value + "'")); - - free_node(node_allocator_,branch); - - return error_node(); + +#ifndef exprtk_disable_string_capabilities + if (result) + { + const bool consq_is_str = is_generally_string_node( consequent); + const bool alter_is_str = is_generally_string_node(alternative); + + if (consq_is_str || alter_is_str) + { + if (consq_is_str && alter_is_str) + { + return expression_generator_ + .conditional_string(condition,consequent,alternative); + } + + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR039 - Return types of ternary if-statement differ")); + + result = false; + } } - else if (!post_bracket_process(token_t::e_lcrlbracket,branch)) +#endif + + if (!result) { - free_node(node_allocator_,branch); - - return error_node(); + free_node(node_allocator_, condition); + free_node(node_allocator_, consequent); + free_node(node_allocator_,alternative); + + return error_node(); } - } - else if (token_t::e_sub == current_token_.type) - { - next_token(); - branch = parse_expression(e_level11); - - if ( - branch && - !( - details::is_neg_unary_node (branch) && - simplify_unary_negation_branch(branch) - ) - ) - { - branch = expression_generator_(details::e_neg,branch); - } - } - else if (token_t::e_add == current_token_.type) - { + else + return expression_generator_ + .conditional(condition,consequent,alternative); + } + + inline expression_node_ptr parse_conditional_statement() + { + expression_node_ptr condition = error_node(); + next_token(); - branch = parse_expression(e_level13); - } - else if (token_t::e_eof == current_token_.type) - { - set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR168 - Premature end of expression[1]")); - - return error_node(); - } - else - { + + if (!token_is(token_t::e_lbracket)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR040 - Expected '(' at start of if-statement, instead got: '" + current_token().value + "'")); + + return error_node(); + } + else if (0 == (condition = parse_expression())) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR041 - Failed to parse condition for if-statement")); + + return error_node(); + } + else if (token_is(token_t::e_comma,prsrhlpr_t::e_hold)) + { + // if (x,y,z) + return parse_conditional_statement_01(condition); + } + else if (token_is(token_t::e_rbracket)) + { + // 00. if (x) y; + // 01. if (x) y; else z; + // 02. if (x) y; else {z0; ... zn;} + // 03. if (x) y; else if (z) w; + // 04. if (x) y; else if (z) w; else u; + // 05. if (x) y; else if (z) w; else {u0; ... un;} + // 06. if (x) y; else if (z) {w0; ... wn;} + // 07. if (x) {y0; ... yn;} + // 08. if (x) {y0; ... yn;} else z; + // 09. if (x) {y0; ... yn;} else {z0; ... zn;}; + // 10. if (x) {y0; ... yn;} else if (z) w; + // 11. if (x) {y0; ... yn;} else if (z) w; else u; + // 12. if (x) {y0; ... nex;} else if (z) w; else {u0 ... un;} + // 13. if (x) {y0; ... yn;} else if (z) {w0; ... wn;} + return parse_conditional_statement_02(condition); + } + set_error( - make_error(parser_error::e_syntax, - current_token_, - "ERR169 - Premature end of expression[2]")); - + make_error(parser_error::e_syntax, + current_token(), + "ERR042 - Invalid if-statement")); + + free_node(node_allocator_,condition); + return error_node(); - } - - if ( - branch && - (e_level00 == precedence) && - token_is(token_t::e_ternary,false) - ) - { - branch = parse_ternary_conditional_statement(branch); - } - - parse_pending_string_rangesize(branch); - - return branch; - } - - inline bool token_is(const typename token_t::token_type& ttype, const bool advance_token = true) - { - if (current_token_.type != ttype) - { - return false; - } - - if (advance_token) - { - next_token(); - } - - return true; - } - - inline bool peek_token_is(const typename token_t::token_type& ttype) - { - return (lexer_.peek_next_token().type == ttype); - } - - inline bool peek_token_is(const std::string& s) - { - return (details::imatch(lexer_.peek_next_token().value,s)); - } - - template - class expression_generator - { - public: - - typedef details::expression_node* expression_node_ptr; - typedef expression_node_ptr (*synthesize_functor_t)(expression_generator&, const details::operator_type& operation, expression_node_ptr (&branch)[2]); - typedef std::map synthesize_map_t; - typedef typename exprtk::parser parser_t; - typedef const Type& vtype; - typedef const Type ctype; - - inline void init_synthesize_map() - { - #ifndef exprtk_disable_enhanced_features - synthesize_map_["(v)o(v)"] = synthesize_vov_expression::process; - synthesize_map_["(c)o(v)"] = synthesize_cov_expression::process; - synthesize_map_["(v)o(c)"] = synthesize_voc_expression::process; - - #define register_synthezier(S) \ - synthesize_map_[S ::node_type::id()] = S ::process; \ - - register_synthezier(synthesize_vovov_expression0) - register_synthezier(synthesize_vovov_expression1) - register_synthezier(synthesize_vovoc_expression0) - register_synthezier(synthesize_vovoc_expression1) - register_synthezier(synthesize_vocov_expression0) - register_synthezier(synthesize_vocov_expression1) - register_synthezier(synthesize_covov_expression0) - register_synthezier(synthesize_covov_expression1) - register_synthezier(synthesize_covoc_expression0) - register_synthezier(synthesize_covoc_expression1) - register_synthezier(synthesize_cocov_expression1) - register_synthezier(synthesize_vococ_expression0) - - register_synthezier(synthesize_vovovov_expression0) - register_synthezier(synthesize_vovovoc_expression0) - register_synthezier(synthesize_vovocov_expression0) - register_synthezier(synthesize_vocovov_expression0) - register_synthezier(synthesize_covovov_expression0) - register_synthezier(synthesize_covocov_expression0) - register_synthezier(synthesize_vocovoc_expression0) - register_synthezier(synthesize_covovoc_expression0) - register_synthezier(synthesize_vococov_expression0) - - register_synthezier(synthesize_vovovov_expression1) - register_synthezier(synthesize_vovovoc_expression1) - register_synthezier(synthesize_vovocov_expression1) - register_synthezier(synthesize_vocovov_expression1) - register_synthezier(synthesize_covovov_expression1) - register_synthezier(synthesize_covocov_expression1) - register_synthezier(synthesize_vocovoc_expression1) - register_synthezier(synthesize_covovoc_expression1) - register_synthezier(synthesize_vococov_expression1) - - register_synthezier(synthesize_vovovov_expression2) - register_synthezier(synthesize_vovovoc_expression2) - register_synthezier(synthesize_vovocov_expression2) - register_synthezier(synthesize_vocovov_expression2) - register_synthezier(synthesize_covovov_expression2) - register_synthezier(synthesize_covocov_expression2) - register_synthezier(synthesize_vocovoc_expression2) - register_synthezier(synthesize_covovoc_expression2) - - register_synthezier(synthesize_vovovov_expression3) - register_synthezier(synthesize_vovovoc_expression3) - register_synthezier(synthesize_vovocov_expression3) - register_synthezier(synthesize_vocovov_expression3) - register_synthezier(synthesize_covovov_expression3) - register_synthezier(synthesize_covocov_expression3) - register_synthezier(synthesize_vocovoc_expression3) - register_synthezier(synthesize_covovoc_expression3) - register_synthezier(synthesize_vococov_expression3) - - register_synthezier(synthesize_vovovov_expression4) - register_synthezier(synthesize_vovovoc_expression4) - register_synthezier(synthesize_vovocov_expression4) - register_synthezier(synthesize_vocovov_expression4) - register_synthezier(synthesize_covovov_expression4) - register_synthezier(synthesize_covocov_expression4) - register_synthezier(synthesize_vocovoc_expression4) - register_synthezier(synthesize_covovoc_expression4) - #endif - } - - inline void set_parser(parser_t& p) - { - parser_ = &p; - } - - inline void set_uom(unary_op_map_t& unary_op_map) - { - unary_op_map_ = &unary_op_map; - } - - inline void set_bom(binary_op_map_t& binary_op_map) - { - binary_op_map_ = &binary_op_map; - } - - inline void set_ibom(inv_binary_op_map_t& inv_binary_op_map) - { - inv_binary_op_map_ = &inv_binary_op_map; - } - - inline void set_sf3m(sf3_map_t& sf3_map) - { - sf3_map_ = &sf3_map; - } - - inline void set_sf4m(sf4_map_t& sf4_map) - { - sf4_map_ = &sf4_map; - } - - inline void set_allocator(details::node_allocator& na) - { - node_allocator_ = &na; - } - - inline void set_strength_reduction_state(const bool enabled) - { - strength_reduction_enabled_ = enabled; - } - - inline bool strength_reduction_enabled() const - { - return strength_reduction_enabled_; - } - - inline bool valid_operator(const details::operator_type& operation, binary_functor_t& bop) - { - typename binary_op_map_t::iterator bop_itr = binary_op_map_->find(operation); - - if ((*binary_op_map_).end() == bop_itr) - return false; - - bop = bop_itr->second; - - return true; - } - - inline bool valid_operator(const details::operator_type& operation, unary_functor_t& uop) - { - typename unary_op_map_t::iterator uop_itr = unary_op_map_->find(operation); - - if ((*unary_op_map_).end() == uop_itr) - return false; - - uop = uop_itr->second; - - return true; - } - - inline details::operator_type get_operator(const binary_functor_t& bop) - { - return (*inv_binary_op_map_).find(bop)->second; - } - - inline expression_node_ptr operator()(const Type& v) const - { - return node_allocator_->allocate(v); - } - - inline expression_node_ptr operator()(const std::string& s) const - { - return node_allocator_->allocate(s); - } - - inline expression_node_ptr operator()(std::string& s, range_t& rp) const - { - return node_allocator_->allocate_rr(s,rp); - } - - inline expression_node_ptr operator()(const std::string& s, range_t& rp) const - { - return node_allocator_->allocate_tt(s,rp); - } - - inline expression_node_ptr operator()(expression_node_ptr branch, range_t& rp) const - { - if (is_generally_string_node(branch)) - return node_allocator_->allocate_tt(branch,rp); - else - return error_node(); - } - - inline bool unary_optimizable(const details::operator_type& operation) const - { - return (details::e_abs == operation) || (details::e_acos == operation) || - (details::e_acosh == operation) || (details::e_asin == operation) || - (details::e_asinh == operation) || (details::e_atan == operation) || - (details::e_atanh == operation) || (details::e_ceil == operation) || - (details::e_cos == operation) || (details::e_cosh == operation) || - (details::e_exp == operation) || (details::e_expm1 == operation) || - (details::e_floor == operation) || (details::e_log == operation) || - (details::e_log10 == operation) || (details::e_log2 == operation) || - (details::e_log1p == operation) || (details::e_neg == operation) || - (details::e_pos == operation) || (details::e_round == operation) || - (details::e_sin == operation) || (details::e_sinc == operation) || - (details::e_sinh == operation) || (details::e_sqrt == operation) || - (details::e_tan == operation) || (details::e_tanh == operation) || - (details::e_cot == operation) || (details::e_sec == operation) || - (details::e_csc == operation) || (details::e_r2d == operation) || - (details::e_d2r == operation) || (details::e_d2g == operation) || - (details::e_g2d == operation) || (details::e_notl == operation) || - (details::e_sgn == operation) || (details::e_erf == operation) || - (details::e_erfc == operation) || (details::e_ncdf == operation) || - (details::e_frac == operation) || (details::e_trunc == operation); - } - - inline bool sf3_optimizable(const std::string& sf3id, trinary_functor_t& tfunc) - { - typename sf3_map_t::iterator itr = sf3_map_->find(sf3id); - - if (sf3_map_->end() == itr) - return false; - else - tfunc = itr->second.first; - - return true; - } - - inline bool sf4_optimizable(const std::string& sf4id, quaternary_functor_t& qfunc) - { - typename sf4_map_t::iterator itr = sf4_map_->find(sf4id); - - if (sf4_map_->end() == itr) - return false; - else - qfunc = itr->second.first; - - return true; - } - - inline bool sf3_optimizable(const std::string& sf3id, details::operator_type& operation) - { - typename sf3_map_t::iterator itr = sf3_map_->find(sf3id); - - if (sf3_map_->end() == itr) - return false; - else - operation = itr->second.second; - - return true; - } - - inline bool sf4_optimizable(const std::string& sf4id, details::operator_type& operation) - { - typename sf4_map_t::iterator itr = sf4_map_->find(sf4id); - - if (sf4_map_->end() == itr) - return false; - else - operation = itr->second.second; - - return true; - } - - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr (&branch)[1]) - { - if (0 == branch[0]) - return error_node(); - else if (details::is_null_node(branch[0])) - return branch[0]; - else if (details::is_break_node(branch[0])) - return error_node(); - else if (details::is_continue_node(branch[0])) - return error_node(); - else if (details::is_constant_node(branch[0])) - return synthesize_expression(operation,branch); - else if (unary_optimizable(operation) && details::is_variable_node(branch[0])) - return synthesize_uv_expression(operation,branch); - else if (unary_optimizable(operation) && details::is_ivector_node(branch[0])) - return synthesize_uvec_expression(operation,branch); - else - return synthesize_unary_expression(operation,branch); - } - - inline bool is_assignment_operation(const details::operator_type& operation) const - { - return (details::e_addass == operation) || - (details::e_subass == operation) || - (details::e_mulass == operation) || - (details::e_divass == operation) || - (details::e_modass == operation) ; - } - - #ifndef exprtk_disable_string_capabilities - inline bool valid_string_operation(const details::operator_type& operation) const - { - return (details::e_add == operation) || - (details::e_lt == operation) || - (details::e_lte == operation) || - (details::e_gt == operation) || - (details::e_gte == operation) || - (details::e_eq == operation) || - (details::e_ne == operation) || - (details::e_in == operation) || - (details::e_like == operation) || - (details::e_ilike == operation) || - (details::e_assign == operation) || - (details::e_addass == operation) || - (details::e_swap == operation) ; - } - #else - inline bool valid_string_operation(const details::operator_type&) const - { - return false; - } - #endif - - inline std::string to_str(const details::operator_type& operation) const - { - switch (operation) - { - case details::e_add : return "+"; - case details::e_sub : return "-"; - case details::e_mul : return "*"; - case details::e_div : return "/"; - case details::e_mod : return "%"; - case details::e_pow : return "^"; - case details::e_lt : return "<"; - case details::e_lte : return "<="; - case details::e_gt : return ">"; - case details::e_gte : return ">="; - case details::e_eq : return "=="; - case details::e_ne : return "!="; - case details::e_and : return "and"; - case details::e_nand : return "nand"; - case details::e_or : return "or"; - case details::e_nor : return "nor"; - case details::e_xor : return "xor"; - case details::e_xnor : return "xnor"; - default : return "UNKNOWN"; - } - } - - inline bool operation_optimizable(const details::operator_type& operation) const - { - return (details::e_add == operation) || - (details::e_sub == operation) || - (details::e_mul == operation) || - (details::e_div == operation) || - (details::e_mod == operation) || - (details::e_pow == operation) || - (details::e_lt == operation) || - (details::e_lte == operation) || - (details::e_gt == operation) || - (details::e_gte == operation) || - (details::e_eq == operation) || - (details::e_ne == operation) || - (details::e_and == operation) || - (details::e_nand == operation) || - (details::e_or == operation) || - (details::e_nor == operation) || - (details::e_xor == operation) || - (details::e_xnor == operation) ; - } - - inline std::string branch_to_id(expression_node_ptr branch) - { - static const std::string null_str ("(null)" ); - static const std::string const_str ("(c)" ); - static const std::string var_str ("(v)" ); - static const std::string vov_str ("(vov)" ); - static const std::string cov_str ("(cov)" ); - static const std::string voc_str ("(voc)" ); - static const std::string str_str ("(s)" ); - static const std::string strrng_str ("(rngs)" ); - static const std::string cs_str ("(cs)" ); - static const std::string cstrrng_str("(crngs)"); - - if (details::is_null_node(branch)) - return null_str; - else if (details::is_constant_node(branch)) - return const_str; - else if (details::is_variable_node(branch)) - return var_str; - else if (details::is_vov_node(branch)) - return vov_str; - else if (details::is_cov_node(branch)) - return cov_str; - else if (details::is_voc_node(branch)) - return voc_str; - else if (details::is_string_node(branch)) - return str_str; - else if (details::is_const_string_node(branch)) - return cs_str; - else if (details::is_string_range_node(branch)) - return strrng_str; - else if (details::is_const_string_range_node(branch)) - return cstrrng_str; - else if (details::is_t0ot1ot2_node(branch)) - return "(" + dynamic_cast*>(branch)->type_id() + ")"; - else if (details::is_t0ot1ot2ot3_node(branch)) - return "(" + dynamic_cast*>(branch)->type_id() + ")"; - else - return "ERROR"; - } - - inline std::string branch_to_id(expression_node_ptr (&branch)[2]) - { - return branch_to_id(branch[0]) + std::string("o") + branch_to_id(branch[1]); - } - - inline bool cov_optimizable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const - { - if (!operation_optimizable(operation)) - return false; - else - return (details::is_constant_node(branch[0]) && details::is_variable_node(branch[1])); - } - - inline bool voc_optimizable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const - { - if (!operation_optimizable(operation)) - return false; - else - return (details::is_variable_node(branch[0]) && details::is_constant_node(branch[1])); - } - - inline bool vov_optimizable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const - { - if (!operation_optimizable(operation)) - return false; - else - return (details::is_variable_node(branch[0]) && details::is_variable_node(branch[1])); - } - - inline bool cob_optimizable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const - { - if (!operation_optimizable(operation)) - return false; - else - return (details::is_constant_node(branch[0]) && !details::is_constant_node(branch[1])); - } - - inline bool boc_optimizable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const - { - if (!operation_optimizable(operation)) - return false; - else - return (!details::is_constant_node(branch[0]) && details::is_constant_node(branch[1])); - } - - inline bool cocob_optimizable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const - { - if ( - (details::e_add == operation) || - (details::e_sub == operation) || - (details::e_mul == operation) || - (details::e_div == operation) - ) + } + + inline expression_node_ptr parse_ternary_conditional_statement(expression_node_ptr condition) + { + // Parse: [condition][?][consequent][:][alternative] + expression_node_ptr consequent = error_node(); + expression_node_ptr alternative = error_node(); + + bool result = true; + + if (0 == condition) { - return (details::is_constant_node(branch[0]) && details::is_cob_node(branch[1])) || - (details::is_constant_node(branch[1]) && details::is_cob_node(branch[0])); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR043 - Encountered invalid condition branch for ternary if-statement")); + + return error_node(); } - else - return false; - } - - inline bool coboc_optimizable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const - { - if ( - (details::e_add == operation) || - (details::e_sub == operation) || - (details::e_mul == operation) || - (details::e_div == operation) - ) + else if (!token_is(token_t::e_ternary)) { - return (details::is_constant_node(branch[0]) && details::is_boc_node(branch[1])) || - (details::is_constant_node(branch[1]) && details::is_boc_node(branch[0])); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR044 - Expected '?' after condition of ternary if-statement")); + + result = false; } - else - return false; - } - - inline bool uvouv_optimizable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const - { - if (!operation_optimizable(operation)) - return false; - else - return (details::is_uv_node(branch[0]) && details::is_uv_node(branch[1])); - } - - inline bool vob_optimizable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const - { - if (!operation_optimizable(operation)) - return false; - else - return (details::is_variable_node(branch[0]) && !details::is_variable_node(branch[1])); - } - - inline bool bov_optimizable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const - { - if (!operation_optimizable(operation)) - return false; - else - return (!details::is_variable_node(branch[0]) && details::is_variable_node(branch[1])); - } - - inline bool binext_optimizable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const - { - if (!operation_optimizable(operation)) - return false; - else - return (!details::is_constant_node(branch[0]) || !details::is_constant_node(branch[1])); - } - - inline bool is_invalid_assignment_op(const details::operator_type& operation, expression_node_ptr (&branch)[2]) - { - if (is_assignment_operation(operation)) + else if (0 == (consequent = parse_expression())) { - const bool b1_is_genstring = details::is_generally_string_node(branch[1]); - - if (details::is_string_node(branch[0])) - return !b1_is_genstring; - else - return ( - !details::is_variable_node (branch[0]) && - !details::is_vector_elem_node(branch[0]) && - !details::is_vector_node (branch[0]) - ) - || b1_is_genstring; + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR045 - Failed to parse consequent for ternary if-statement")); + + result = false; } - else - return false; - } - - inline bool is_invalid_break_continue_op(expression_node_ptr (&branch)[2]) - { - return ( - details::is_break_node (branch[0]) || - details::is_break_node (branch[1]) || - details::is_continue_node(branch[0]) || - details::is_continue_node(branch[1]) - ); - } - - inline bool is_invalid_string_op(const details::operator_type& operation, expression_node_ptr (&branch)[2]) - { - const bool b0_string = is_generally_string_node(branch[0]); - const bool b1_string = is_generally_string_node(branch[1]); - - bool result = false; - - if (b0_string ^ b1_string) - result = true; - else if (!valid_string_operation(operation) && b0_string && b1_string) - result = true; - - if (result) + else if (!token_is(token_t::e_colon)) { - parser_->set_synthesis_error("Invalid string operation"); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR046 - Expected ':' between ternary if-statement consequent and alternative")); + + result = false; } - - return result; - } - - inline bool is_invalid_string_op(const details::operator_type& operation, expression_node_ptr (&branch)[3]) - { - const bool b0_string = is_generally_string_node(branch[0]); - const bool b1_string = is_generally_string_node(branch[1]); - const bool b2_string = is_generally_string_node(branch[2]); - - bool result = false; - - if ((b0_string ^ b1_string) || (b1_string ^ b2_string)) - result = true; - else if ((details::e_inrange != operation) && b0_string && b1_string && b2_string) - result = true; - - if (result) + else if (0 == (alternative = parse_expression())) { - parser_->set_synthesis_error("Invalid string operation"); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR047 - Failed to parse alternative for ternary if-statement")); + + result = false; } - - return result; - } - - inline bool is_string_operation(const details::operator_type& operation, expression_node_ptr (&branch)[2]) - { - const bool b0_string = is_generally_string_node(branch[0]); - const bool b1_string = is_generally_string_node(branch[1]); - - return (b0_string && b1_string && valid_string_operation(operation)); - } - - inline bool is_string_operation(const details::operator_type& operation, expression_node_ptr (&branch)[3]) - { - const bool b0_string = is_generally_string_node(branch[0]); - const bool b1_string = is_generally_string_node(branch[1]); - const bool b2_string = is_generally_string_node(branch[2]); - - return (b0_string && b1_string && b2_string && (details::e_inrange == operation)); - } - - #ifndef exprtk_disable_sc_andor - inline bool is_shortcircuit_expression(const details::operator_type& operation) - { - return ( - (details::e_scand == operation) || - (details::e_scor == operation) - ); - } - #else - inline bool is_shortcircuit_expression(const details::operator_type&) - { - return false; - } - #endif - - inline bool is_null_present(expression_node_ptr (&branch)[2]) - { - return ( - details::is_null_node(branch[0]) || - details::is_null_node(branch[1]) - ); - } - - inline bool is_vector_eqineq_operation(const details::operator_type& operation, expression_node_ptr (&branch)[2]) - { - if (!is_ivector_node(branch[0]) && !is_ivector_node(branch[1])) - return false; - else - return ( - (details::e_lt == operation) || - (details::e_lte == operation) || - (details::e_gt == operation) || - (details::e_gte == operation) || - (details::e_eq == operation) || - (details::e_ne == operation) - ); - } - - inline bool is_vector_arithmetic_operation(const details::operator_type& operation, expression_node_ptr (&branch)[2]) - { - if (!is_ivector_node(branch[0]) && !is_ivector_node(branch[1])) - return false; - else - return ( - (details::e_add == operation) || - (details::e_sub == operation) || - (details::e_mul == operation) || - (details::e_div == operation) || - (details::e_pow == operation) - ); - } - - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr (&branch)[2]) - { - if ((0 == branch[0]) || (0 == branch[1])) - return error_node(); - else if (is_invalid_string_op(operation,branch)) - return error_node(); - else if (is_invalid_assignment_op(operation,branch)) - return error_node(); - else if (is_invalid_break_continue_op(branch)) - return error_node(); - else if (details::e_assign == operation) - return synthesize_assignment_expression(operation,branch); - else if (details::e_swap == operation) - return synthesize_swap_expression(branch); - else if (is_assignment_operation(operation)) - return synthesize_assignment_operation_expression(operation,branch); - else if (is_vector_eqineq_operation(operation,branch)) - return synthesize_veceqineq_operation_expression(operation,branch); - else if (is_vector_arithmetic_operation(operation,branch)) - return synthesize_vecarithmetic_operation_expression(operation,branch); - else if (is_shortcircuit_expression(operation)) - return synthesize_shortcircuit_expression(operation,branch); - else if (is_string_operation(operation,branch)) - return synthesize_string_expression(operation,branch); - else if (is_null_present(branch)) - return synthesize_null_expression(operation,branch); - - expression_node_ptr result = error_node(); - - #ifndef exprtk_disable_enhanced_features - if (synthesize_expression(operation,branch,result)) - return result; - else - #endif - + +#ifndef exprtk_disable_string_capabilities + if (result) { - /* - Possible reductions: - 1. c o cob -> cob - 2. cob o c -> cob - 3. c o boc -> boc - 4. boc o c -> boc - */ - result = error_node(); - - if (cocob_optimizable(operation,branch)) - result = synthesize_cocob_expression::process(*this,operation,branch); - else if (coboc_optimizable(operation,branch) && (0 == result)) - result = synthesize_coboc_expression::process(*this,operation,branch); - - if (result) - return result; + const bool consq_is_str = is_generally_string_node( consequent); + const bool alter_is_str = is_generally_string_node(alternative); + + if (consq_is_str || alter_is_str) + { + if (consq_is_str && alter_is_str) + { + return expression_generator_ + .conditional_string(condition,consequent,alternative); + } + + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR048 - Return types of ternary if-statement differ")); + + result = false; + } } - - if (uvouv_optimizable(operation,branch)) - return synthesize_uvouv_expression(operation,branch); - else if (vob_optimizable(operation,branch)) - return synthesize_vob_expression::process(*this,operation,branch); - else if (bov_optimizable(operation,branch)) - return synthesize_bov_expression::process(*this,operation,branch); - else if (cob_optimizable(operation,branch)) - return synthesize_cob_expression::process(*this,operation,branch); - else if (boc_optimizable(operation,branch)) - return synthesize_boc_expression::process(*this,operation,branch); - #ifndef exprtk_disable_enhanced_features - else if (cov_optimizable(operation,branch)) - return synthesize_cov_expression::process(*this,operation,branch); - #endif - else if (binext_optimizable(operation,branch)) - return synthesize_binary_ext_expression::process(*this,operation,branch); - else - return synthesize_expression(operation,branch); - } - - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr (&branch)[3]) - { - if ( - (0 == branch[0]) || - (0 == branch[1]) || - (0 == branch[2]) - ) +#endif + + if (!result) { - details::free_all_nodes(*node_allocator_,branch); - - return error_node(); + free_node(node_allocator_, condition); + free_node(node_allocator_, consequent); + free_node(node_allocator_,alternative); + + return error_node(); } - else if (is_invalid_string_op(operation,branch)) - return error_node(); - else if (is_string_operation(operation,branch)) - return synthesize_string_expression(operation,branch); - else - return synthesize_expression(operation,branch); - } - - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr (&branch)[4]) - { - return synthesize_expression(operation,branch); - } - - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr (&branch)[5]) - { - return synthesize_expression(operation,branch); - } - - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr (&branch)[6]) - { - return synthesize_expression(operation,branch); - } - - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr b0) - { - expression_node_ptr branch[1] = { b0 }; - return (*this)(operation,branch); - } - - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr b0, expression_node_ptr b1) - { - if ((0 == b0) || (0 == b1)) - return error_node(); else + return expression_generator_ + .conditional(condition,consequent,alternative); + } + + inline expression_node_ptr parse_while_loop() + { + // Parse: [while][(][test expr][)][{][expression][}] + expression_node_ptr condition = error_node(); + expression_node_ptr branch = error_node(); + expression_node_ptr result_node = error_node(); + + bool result = true; + + next_token(); + + if (!token_is(token_t::e_lbracket)) { - expression_node_ptr branch[2] = { b0, b1 }; - return expression_generator::operator()(operation,branch); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR049 - Expected '(' at start of while-loop condition statement")); + + return error_node(); } - } - - inline expression_node_ptr conditional(expression_node_ptr condition, - expression_node_ptr consequent, - expression_node_ptr alternative) const - { - if ((0 == condition) || (0 == consequent)) - { - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,consequent ); - free_node(*node_allocator_,alternative); - - return error_node(); + else if (0 == (condition = parse_expression())) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR050 - Failed to parse condition for while-loop")); + + return error_node(); } - // Can the condition be immediately evaluated? if so optimize. - else if (details::is_constant_node(condition)) + else if (!token_is(token_t::e_rbracket)) { - // True branch - if (details::is_true(condition)) - { - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,alternative); - - return consequent; - } - // False branch - else - { - free_node(*node_allocator_,condition); - free_node(*node_allocator_,consequent); - - if (alternative) - return alternative; - else - return node_allocator_->allocate >(); - } + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR051 - Expected ')' at end of while-loop condition statement")); + result = false; } - else if ((0 != consequent) && (0 != alternative)) + + brkcnt_list_.push_front(false); + + if (result) { - return node_allocator_->allocate(condition,consequent,alternative); + if (0 == (branch = parse_multi_sequence("while-loop"))) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR052 - Failed to parse body of while-loop")); + result = false; + } + else if (0 == (result_node = expression_generator_.while_loop(condition, + branch, + brkcnt_list_.front()))) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR053 - Failed to synthesize while-loop")); + result = false; + } + } + + if (!result) + { + free_node(node_allocator_, branch); + free_node(node_allocator_, condition); + free_node(node_allocator_,result_node); + + brkcnt_list_.pop_front(); + + return error_node(); } else - return node_allocator_->allocate(condition,consequent); - } - - inline expression_node_ptr while_loop(expression_node_ptr& condition, - expression_node_ptr& branch, - const bool brkcont = false) const - { - if (!brkcont && details::is_constant_node(condition)) - { - expression_node_ptr result = error_node(); - if (details::is_true(condition)) - // Infinite loops are not allowed. - result = error_node(); - else - result = node_allocator_->allocate >(); - - free_node(*node_allocator_, condition); - free_node(*node_allocator_, branch ); - - return result; - } - else if (details::is_null_node(condition)) + return result_node; + } + + inline expression_node_ptr parse_repeat_until_loop() + { + // Parse: [repeat][{][expression][}][until][(][test expr][)] + expression_node_ptr condition = error_node(); + expression_node_ptr branch = error_node(); + next_token(); + + std::vector arg_list; + std::vector side_effect_list; + + scoped_vec_delete sdd(*this,arg_list); + + brkcnt_list_.push_front(false); + + if (details::imatch(current_token().value,"until")) { - free_node(*node_allocator_,condition); - - return branch; + next_token(); + branch = node_allocator_.allocate >(); } - else if (!brkcont) - return node_allocator_->allocate(condition,branch); - #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate(condition,branch); - #else - return error_node(); - #endif - } - - inline expression_node_ptr repeat_until_loop(expression_node_ptr& condition, - expression_node_ptr& branch, - const bool brkcont = false) const - { - if (!brkcont && details::is_constant_node(condition)) - { - if (details::is_true(condition) && details::is_constant_node(branch)) - { - free_node(*node_allocator_,condition); - - return branch; - } - - free_node(*node_allocator_, condition); - free_node(*node_allocator_, branch ); - - return error_node(); + { + token_t::token_type seperator = token_t::e_eof; + + scope_handler sh(*this); + + scoped_bool_or_restorer sbr(state_.side_effect_present); + + for ( ; ; ) + { + state_.side_effect_present = false; + + expression_node_ptr arg = parse_expression(); + + if (0 == arg) + return error_node(); + else + { + arg_list.push_back(arg); + side_effect_list.push_back(state_.side_effect_present); + } + + if (details::imatch(current_token().value,"until")) + { + next_token(); + break; + } + + bool is_next_until = peek_token_is(token_t::e_symbol) && + peek_token_is("until"); + + if (!token_is(seperator) && is_next_until) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR054 - Expected '" + token_t::to_str(seperator) + "' in body of repeat until loop")); + + return error_node(); + } + + if (details::imatch(current_token().value,"until")) + { + next_token(); + break; + } + } + + branch = simplify(arg_list,side_effect_list); + + sdd.delete_ptr = (0 == branch); + + if (sdd.delete_ptr) + { + brkcnt_list_.pop_front(); + + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR055 - Failed to parse body of repeat until loop")); + + return error_node(); + } + } + + if (!token_is(token_t::e_lbracket)) + { + brkcnt_list_.pop_front(); + + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR056 - Expected '(' before condition statement of repeat until loop")); + + free_node(node_allocator_,branch); + + return error_node(); + } + else if (0 == (condition = parse_expression())) + { + brkcnt_list_.pop_front(); + + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR057 - Failed to parse condition for repeat until loop")); + + free_node(node_allocator_,branch); + + return error_node(); } - else if (details::is_null_node(condition)) + else if (!token_is(token_t::e_rbracket)) { - free_node(*node_allocator_,condition); - - return branch; + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR058 - Expected ')' after condition of repeat until loop")); + + free_node(node_allocator_, branch); + free_node(node_allocator_, condition); + + brkcnt_list_.pop_front(); + + return error_node(); + } + + expression_node_ptr result; + + result = expression_generator_ + .repeat_until_loop(condition,branch,brkcnt_list_.front()); + + if (0 == result) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR059 - Failed to synthesize repeat until loop")); + + free_node(node_allocator_, condition); + brkcnt_list_.pop_front(); + + return error_node(); } - else if (!brkcont) - return node_allocator_->allocate(condition,branch); - #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate(condition,branch); - #else - return error_node(); - #endif - } - - inline expression_node_ptr for_loop(expression_node_ptr& initialiser, - expression_node_ptr& condition, - expression_node_ptr& incrementor, - expression_node_ptr& loop_body, - bool brkcont = false) const - { - if (!brkcont && details::is_constant_node(condition)) - { - expression_node_ptr result = error_node(); - - if (details::is_true(condition)) - // Infinite loops are not allowed. - result = error_node(); - else - result = node_allocator_->allocate >(); - - free_node(*node_allocator_,initialiser); - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,incrementor); - free_node(*node_allocator_,loop_body ); - - return result; + { + brkcnt_list_.pop_front(); + return result; + } + } + + inline expression_node_ptr parse_for_loop() + { + expression_node_ptr initialiser = error_node(); + expression_node_ptr condition = error_node(); + expression_node_ptr incrementor = error_node(); + expression_node_ptr loop_body = error_node(); + + scope_element* se = 0; + bool result = true; + std::string loop_counter_symbol; + + next_token(); + + scope_handler sh(*this); + + if (!token_is(token_t::e_lbracket)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR060 - Expected '(' at start of for-loop")); + + return error_node(); } - else if (details::is_null_node(condition)) + + if (!token_is(token_t::e_eof)) { - free_node(*node_allocator_,initialiser); - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,incrementor); - - return loop_body; - } - else if (!brkcont) - return node_allocator_->allocate(initialiser, - condition, - incrementor, - loop_body); - #ifndef exprtk_disable_break_continue + if ( + !token_is(token_t::e_symbol,prsrhlpr_t::e_hold) && + details::imatch(current_token().value,"var") + ) + { + next_token(); + + if (!token_is(token_t::e_symbol,prsrhlpr_t::e_hold)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR061 - Expected a variable at the start of initialiser section of for-loop")); + + return error_node(); + } + else if (!peek_token_is(token_t::e_assign)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR062 - Expected variable assignment of initialiser section of for-loop")); + + return error_node(); + } + + loop_counter_symbol = current_token().value; + + se = &sem_.get_element(loop_counter_symbol); + + if ((se->name == loop_counter_symbol) && se->active) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR063 - For-loop variable '" + loop_counter_symbol+ "' is being shadowed by a previous declaration")); + + return error_node(); + } + else if (!symtab_store_.is_variable(loop_counter_symbol)) + { + if ( + !se->active && + (se->name == loop_counter_symbol) && + (se->type == scope_element::e_variable) + ) + { + se->active = true; + se->ref_count++; + } + else + { + scope_element nse; + nse.name = loop_counter_symbol; + nse.active = true; + nse.ref_count = 1; + nse.type = scope_element::e_variable; + nse.depth = state_.scope_depth; + nse.data = new T(T(0)); + nse.var_node = node_allocator_.allocate(*(T*)(nse.data)); + + if (!sem_.add_element(nse)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR064 - Failed to add new local variable '" + loop_counter_symbol + "' to SEM")); + + sem_.free_element(nse); + + result = false; + } + else + { + exprtk_debug(("parse_for_loop() - INFO - Added new local variable: %s\n",nse.name.c_str())); + + state_.activate_side_effect("parse_for_loop()"); + } + } + } + } + + if (0 == (initialiser = parse_expression())) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR065 - Failed to parse initialiser of for-loop")); + result = false; + } + else if (!token_is(token_t::e_eof)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR066 - Expected ';' after initialiser of for-loop")); + result = false; + } + } + + if (!token_is(token_t::e_eof)) + { + if (0 == (condition = parse_expression())) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR067 - Failed to parse condition of for-loop")); + result = false; + } + else if (!token_is(token_t::e_eof)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR068 - Expected ';' after condition section of for-loop")); + result = false; + } + } + + if (!token_is(token_t::e_rbracket)) + { + if (0 == (incrementor = parse_expression())) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR069 - Failed to parse incrementor of for-loop")); + result = false; + } + else if (!token_is(token_t::e_rbracket)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR070 - Expected ')' after incrementor section of for-loop")); + result = false; + } + } + + if (result) + { + brkcnt_list_.push_front(false); + + if (0 == (loop_body = parse_multi_sequence("for-loop"))) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR071 - Failed to parse body of for-loop")); + result = false; + } + } + + if (!result) + { + if (se) + { + se->ref_count--; + } + + sem_.cleanup(); + + free_node(node_allocator_,initialiser); + free_node(node_allocator_, condition); + free_node(node_allocator_,incrementor); + free_node(node_allocator_, loop_body); + + if (!brkcnt_list_.empty()) + { + brkcnt_list_.pop_front(); + } + + return error_node(); + } else - return node_allocator_->allocate(initialiser, - condition, - incrementor, - loop_body); - #else - return error_node(); - #endif - } - - template class Sequence> - inline expression_node_ptr const_optimize_switch(Sequence& arg_list) - { + { + expression_node_ptr result_node = + expression_generator_.for_loop(initialiser, + condition, + incrementor, + loop_body, + brkcnt_list_.front()); + brkcnt_list_.pop_front(); + + return result_node; + } + } + + inline expression_node_ptr parse_switch_statement() + { + std::vector arg_list; expression_node_ptr result = error_node(); - - for (std::size_t i = 0; i < (arg_list.size() / 2); ++i) + + if (!details::imatch(current_token().value,"switch")) { - expression_node_ptr condition = arg_list[(2 * i) ]; - expression_node_ptr consequent = arg_list[(2 * i) + 1]; - - if ((0 == result) && details::is_true(condition)) - { - result = consequent; - break; - } - } - - if (0 == result) + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR072 - Expected keyword 'switch'")); + + return error_node(); + } + + scoped_vec_delete svd(*this,arg_list); + + next_token(); + + if (!token_is(token_t::e_lcrlbracket)) { - result = arg_list.back(); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR073 - Expected '{' for call to switch statement")); + + return error_node(); + } + + for ( ; ; ) + { + if (!details::imatch("case",current_token().value)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR074 - Expected either a 'case' or 'default' statement")); + + return error_node(); + } + + next_token(); + + expression_node_ptr condition = parse_expression(); + + if (0 == condition) + return error_node(); + else if (!token_is(token_t::e_colon)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR075 - Expected ':' for case of switch statement")); + + return error_node(); + } + + expression_node_ptr consequent = parse_expression(); + + if (0 == consequent) + return error_node(); + else if (!token_is(token_t::e_eof)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR076 - Expected ';' at end of case for switch statement")); + + return error_node(); + } + + // Can we optimise away the case statement? + if (is_constant_node(condition) && is_false(condition)) + { + free_node(node_allocator_, condition); + free_node(node_allocator_,consequent); + + condition = 0; + consequent = 0; + } + else + { + arg_list.push_back( condition); + arg_list.push_back(consequent); + } + + if (details::imatch("default",current_token().value)) + { + next_token(); + if (!token_is(token_t::e_colon)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR077 - Expected ':' for default of switch statement")); + + return error_node(); + } + + expression_node_ptr default_statement = error_node(); + + if (token_is(token_t::e_lcrlbracket,prsrhlpr_t::e_hold)) + default_statement = parse_multi_sequence("switch-default"); + else + default_statement = parse_expression(); + + if (0 == default_statement) + return error_node(); + else if (!token_is(token_t::e_eof)) + { + free_node(node_allocator_,default_statement); + + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR078 - Expected ';' at end of default for switch statement")); + + return error_node(); + } + + arg_list.push_back(default_statement); + break; + } } - - for (std::size_t i = 0; i < arg_list.size(); ++i) + + if (!token_is(token_t::e_rcrlbracket)) { - expression_node_ptr current_expr = arg_list[i]; - - if (current_expr && (current_expr != result)) - { - free_node(*node_allocator_,current_expr); - } - } - + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR079 - Expected '}' at end of switch statement")); + + return error_node(); + } + + result = expression_generator_.switch_statement(arg_list); + + svd.delete_ptr = (0 == result); + return result; - } - - template class Sequence> - inline expression_node_ptr const_optimize_mswitch(Sequence& arg_list) - { + } + + inline expression_node_ptr parse_multi_switch_statement() + { + std::vector arg_list; expression_node_ptr result = error_node(); - - for (std::size_t i = 0; i < (arg_list.size() / 2); ++i) - { - expression_node_ptr condition = arg_list[(2 * i) ]; - expression_node_ptr consequent = arg_list[(2 * i) + 1]; - - if (details::is_true(condition)) - { - result = consequent; - } - } - - if (0 == result) + + if (!details::imatch(current_token().value,"[*]")) { - T zero = T(0); - result = node_allocator_->allocate(zero); - } - - for (std::size_t i = 0; i < arg_list.size(); ++i) + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR080 - Expected token '[*]'")); + + return error_node(); + } + + scoped_vec_delete svd(*this,arg_list); + + next_token(); + + if (!token_is(token_t::e_lcrlbracket)) { - expression_node_ptr& current_expr = arg_list[i]; - - if (current_expr && (current_expr != result)) - { - free_node(*node_allocator_,current_expr); - } - } - + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR081 - Expected '{' for call to [*] statement")); + + return error_node(); + } + + for ( ; ; ) + { + if (!details::imatch("case",current_token().value)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR082 - Expected a 'case' statement for multi-switch")); + + return error_node(); + } + + next_token(); + + expression_node_ptr condition = parse_expression(); + + if (0 == condition) + return error_node(); + + if (!token_is(token_t::e_colon)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR083 - Expected ':' for case of [*] statement")); + + return error_node(); + } + + expression_node_ptr consequent = parse_expression(); + + if (0 == consequent) + return error_node(); + + if (!token_is(token_t::e_eof)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR084 - Expected ';' at end of case for [*] statement")); + + return error_node(); + } + + // Can we optimise away the case statement? + if (is_constant_node(condition) && is_false(condition)) + { + free_node(node_allocator_, condition); + free_node(node_allocator_,consequent); + + condition = 0; + consequent = 0; + } + else + { + arg_list.push_back(condition); + arg_list.push_back(consequent); + } + + if (token_is(token_t::e_rcrlbracket,prsrhlpr_t::e_hold)) + { + break; + } + } + + if (!token_is(token_t::e_rcrlbracket)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR085 - Expected '}' at end of [*] statement")); + + return error_node(); + } + + result = expression_generator_.multi_switch_statement(arg_list); + + svd.delete_ptr = (0 == result); + return result; - } - - template class Sequence> - inline expression_node_ptr switch_statement(Sequence& arg_list) - { - if (!all_nodes_valid(arg_list)) - { - details::free_all_nodes(*node_allocator_,arg_list); - - return error_node(); - } - else if (is_constant_foldable(arg_list)) - return const_optimize_switch(arg_list); + } + + inline expression_node_ptr parse_vararg_function() + { + std::vector arg_list; + expression_node_ptr result = error_node(); + + details::operator_type opt_type = details::e_default; + const std::string symbol = current_token().value; + + if (details::imatch(symbol,"~")) + { + next_token(); + return parse_multi_sequence(); + } + else if (details::imatch(symbol,"[*]")) + { + return parse_multi_switch_statement(); + } + else if (details::imatch(symbol,"avg" )) opt_type = details::e_avg; + else if (details::imatch(symbol,"mand")) opt_type = details::e_mand; + else if (details::imatch(symbol,"max" )) opt_type = details::e_max; + else if (details::imatch(symbol,"min" )) opt_type = details::e_min; + else if (details::imatch(symbol,"mor" )) opt_type = details::e_mor; + else if (details::imatch(symbol,"mul" )) opt_type = details::e_prod; + else if (details::imatch(symbol,"sum" )) opt_type = details::e_sum; else - return node_allocator_->allocate >(arg_list); - } - - template class Sequence> - inline expression_node_ptr multi_switch_statement(Sequence& arg_list) - { - if (!all_nodes_valid(arg_list)) { - details::free_all_nodes(*node_allocator_,arg_list); - - return error_node(); - } - else if (is_constant_foldable(arg_list)) - return const_optimize_mswitch(arg_list); - else - return node_allocator_->allocate >(arg_list); - } - - #define unary_opr_switch_statements \ - case_stmt(details:: e_abs,details:: abs_op) \ - case_stmt(details:: e_acos,details:: acos_op) \ - case_stmt(details::e_acosh,details::acosh_op) \ - case_stmt(details:: e_asin,details:: asin_op) \ - case_stmt(details::e_asinh,details::asinh_op) \ - case_stmt(details:: e_atan,details:: atan_op) \ - case_stmt(details::e_atanh,details::atanh_op) \ - case_stmt(details:: e_ceil,details:: ceil_op) \ - case_stmt(details:: e_cos,details:: cos_op) \ - case_stmt(details:: e_cosh,details:: cosh_op) \ - case_stmt(details:: e_exp,details:: exp_op) \ - case_stmt(details::e_expm1,details::expm1_op) \ - case_stmt(details::e_floor,details::floor_op) \ - case_stmt(details:: e_log,details:: log_op) \ - case_stmt(details::e_log10,details::log10_op) \ - case_stmt(details:: e_log2,details:: log2_op) \ - case_stmt(details::e_log1p,details::log1p_op) \ - case_stmt(details:: e_neg,details:: neg_op) \ - case_stmt(details:: e_pos,details:: pos_op) \ - case_stmt(details::e_round,details::round_op) \ - case_stmt(details:: e_sin,details:: sin_op) \ - case_stmt(details:: e_sinc,details:: sinc_op) \ - case_stmt(details:: e_sinh,details:: sinh_op) \ - case_stmt(details:: e_sqrt,details:: sqrt_op) \ - case_stmt(details:: e_tan,details:: tan_op) \ - case_stmt(details:: e_tanh,details:: tanh_op) \ - case_stmt(details:: e_cot,details:: cot_op) \ - case_stmt(details:: e_sec,details:: sec_op) \ - case_stmt(details:: e_csc,details:: csc_op) \ - case_stmt(details:: e_r2d,details:: r2d_op) \ - case_stmt(details:: e_d2r,details:: d2r_op) \ - case_stmt(details:: e_d2g,details:: d2g_op) \ - case_stmt(details:: e_g2d,details:: g2d_op) \ - case_stmt(details:: e_notl,details:: notl_op) \ - case_stmt(details:: e_sgn,details:: sgn_op) \ - case_stmt(details:: e_erf,details:: erf_op) \ - case_stmt(details:: e_erfc,details:: erfc_op) \ - case_stmt(details:: e_ncdf,details:: ncdf_op) \ - case_stmt(details:: e_frac,details:: frac_op) \ - case_stmt(details::e_trunc,details::trunc_op) \ - - inline expression_node_ptr synthesize_uv_expression(const details::operator_type& operation, - expression_node_ptr (&branch)[1]) - { - T& v = static_cast*>(branch[0])->ref(); - - switch (operation) + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR086 - Unsupported vararg function: " + symbol)); + + return error_node(); + } + + scoped_vec_delete sdd(*this,arg_list); + + lodge_symbol(symbol,e_st_function); + + next_token(); + + if (!token_is(token_t::e_lbracket)) { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate > >(v); \ - - unary_opr_switch_statements - #undef case_stmt - default : return error_node(); - } - } - - inline expression_node_ptr synthesize_uvec_expression(const details::operator_type& operation, - expression_node_ptr (&branch)[1]) - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate > > \ - (operation,branch[0]); \ - - unary_opr_switch_statements - #undef case_stmt - default : return error_node(); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR087 - Expected '(' for call to vararg function: " + symbol)); + + return error_node(); + } + + for ( ; ; ) + { + expression_node_ptr arg = parse_expression(); + + if (0 == arg) + return error_node(); + else + arg_list.push_back(arg); + + if (token_is(token_t::e_rbracket)) + break; + else if (!token_is(token_t::e_comma)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR088 - Expected ',' for call to vararg function: " + symbol)); + + return error_node(); + } + } + + result = expression_generator_.vararg_function(opt_type,arg_list); + + sdd.delete_ptr = (0 == result); + return result; + } + +#ifndef exprtk_disable_string_capabilities + inline expression_node_ptr parse_string_range_statement(expression_node_ptr& expression) + { + if (!token_is(token_t::e_lsqrbracket)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR089 - Expected '[' as start of string range definition")); + + free_node(node_allocator_,expression); + + return error_node(); } - } - - inline expression_node_ptr synthesize_unary_expression(const details::operator_type& operation, - expression_node_ptr (&branch)[1]) - { - switch (operation) + else if (token_is(token_t::e_rsqrbracket)) { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate > >(branch[0]); \ - - unary_opr_switch_statements - #undef case_stmt - default : return error_node(); + return node_allocator_.allocate >(expression); } - } - - inline expression_node_ptr const_optimize_sf3(const details::operator_type& operation, - expression_node_ptr (&branch)[3]) - { - expression_node_ptr temp_node = error_node(); - - switch (operation) + + range_t rp; + + if (!parse_range(rp,true)) { - #define case_stmt(op0,op1) \ - case op0 : temp_node = node_allocator_-> \ - allocate > > \ - (operation,branch); \ - break; \ - - case_stmt(details::e_sf00,details::sf00_op) case_stmt(details::e_sf01,details::sf01_op) - case_stmt(details::e_sf02,details::sf02_op) case_stmt(details::e_sf03,details::sf03_op) - case_stmt(details::e_sf04,details::sf04_op) case_stmt(details::e_sf05,details::sf05_op) - case_stmt(details::e_sf06,details::sf06_op) case_stmt(details::e_sf07,details::sf07_op) - case_stmt(details::e_sf08,details::sf08_op) case_stmt(details::e_sf09,details::sf09_op) - case_stmt(details::e_sf10,details::sf10_op) case_stmt(details::e_sf11,details::sf11_op) - case_stmt(details::e_sf12,details::sf12_op) case_stmt(details::e_sf13,details::sf13_op) - case_stmt(details::e_sf14,details::sf14_op) case_stmt(details::e_sf15,details::sf15_op) - case_stmt(details::e_sf16,details::sf16_op) case_stmt(details::e_sf17,details::sf17_op) - case_stmt(details::e_sf18,details::sf18_op) case_stmt(details::e_sf19,details::sf19_op) - case_stmt(details::e_sf20,details::sf20_op) case_stmt(details::e_sf21,details::sf21_op) - case_stmt(details::e_sf22,details::sf22_op) case_stmt(details::e_sf23,details::sf23_op) - case_stmt(details::e_sf24,details::sf24_op) case_stmt(details::e_sf25,details::sf25_op) - case_stmt(details::e_sf26,details::sf26_op) case_stmt(details::e_sf27,details::sf27_op) - case_stmt(details::e_sf28,details::sf28_op) case_stmt(details::e_sf29,details::sf29_op) - case_stmt(details::e_sf30,details::sf30_op) case_stmt(details::e_sf31,details::sf31_op) - case_stmt(details::e_sf32,details::sf32_op) case_stmt(details::e_sf33,details::sf33_op) - case_stmt(details::e_sf34,details::sf34_op) case_stmt(details::e_sf35,details::sf35_op) - case_stmt(details::e_sf36,details::sf36_op) case_stmt(details::e_sf37,details::sf37_op) - case_stmt(details::e_sf38,details::sf38_op) case_stmt(details::e_sf39,details::sf39_op) - case_stmt(details::e_sf40,details::sf40_op) case_stmt(details::e_sf41,details::sf41_op) - case_stmt(details::e_sf42,details::sf42_op) case_stmt(details::e_sf43,details::sf43_op) - case_stmt(details::e_sf44,details::sf44_op) case_stmt(details::e_sf45,details::sf45_op) - case_stmt(details::e_sf46,details::sf46_op) case_stmt(details::e_sf47,details::sf47_op) - #undef case_stmt - default : return error_node(); + free_node(node_allocator_,expression); + + return error_node(); } - - T v = temp_node->value(); - node_allocator_->free(temp_node); - details::free_node(*node_allocator_,temp_node); - - return node_allocator_->allocate(v); - } - - inline expression_node_ptr varnode_optimize_sf3(const details::operator_type& operation, expression_node_ptr (&branch)[3]) - { - typedef details::variable_node* variable_ptr; - - const Type& v0 = static_cast(branch[0])->ref(); - const Type& v1 = static_cast(branch[1])->ref(); - const Type& v2 = static_cast(branch[2])->ref(); - - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate_rrr > > \ - (v0,v1,v2); \ - - case_stmt(details::e_sf00,details::sf00_op) case_stmt(details::e_sf01,details::sf01_op) - case_stmt(details::e_sf02,details::sf02_op) case_stmt(details::e_sf03,details::sf03_op) - case_stmt(details::e_sf04,details::sf04_op) case_stmt(details::e_sf05,details::sf05_op) - case_stmt(details::e_sf06,details::sf06_op) case_stmt(details::e_sf07,details::sf07_op) - case_stmt(details::e_sf08,details::sf08_op) case_stmt(details::e_sf09,details::sf09_op) - case_stmt(details::e_sf10,details::sf10_op) case_stmt(details::e_sf11,details::sf11_op) - case_stmt(details::e_sf12,details::sf12_op) case_stmt(details::e_sf13,details::sf13_op) - case_stmt(details::e_sf14,details::sf14_op) case_stmt(details::e_sf15,details::sf15_op) - case_stmt(details::e_sf16,details::sf16_op) case_stmt(details::e_sf17,details::sf17_op) - case_stmt(details::e_sf18,details::sf18_op) case_stmt(details::e_sf19,details::sf19_op) - case_stmt(details::e_sf20,details::sf20_op) case_stmt(details::e_sf21,details::sf21_op) - case_stmt(details::e_sf22,details::sf22_op) case_stmt(details::e_sf23,details::sf23_op) - case_stmt(details::e_sf24,details::sf24_op) case_stmt(details::e_sf25,details::sf25_op) - case_stmt(details::e_sf26,details::sf26_op) case_stmt(details::e_sf27,details::sf27_op) - case_stmt(details::e_sf28,details::sf28_op) case_stmt(details::e_sf29,details::sf29_op) - case_stmt(details::e_sf30,details::sf30_op) case_stmt(details::e_sf31,details::sf31_op) - case_stmt(details::e_sf32,details::sf32_op) case_stmt(details::e_sf33,details::sf33_op) - case_stmt(details::e_sf34,details::sf34_op) case_stmt(details::e_sf35,details::sf35_op) - case_stmt(details::e_sf36,details::sf36_op) case_stmt(details::e_sf37,details::sf37_op) - case_stmt(details::e_sf38,details::sf38_op) case_stmt(details::e_sf39,details::sf39_op) - case_stmt(details::e_sf40,details::sf40_op) case_stmt(details::e_sf41,details::sf41_op) - case_stmt(details::e_sf42,details::sf42_op) case_stmt(details::e_sf43,details::sf43_op) - case_stmt(details::e_sf44,details::sf44_op) case_stmt(details::e_sf45,details::sf45_op) - case_stmt(details::e_sf46,details::sf46_op) case_stmt(details::e_sf47,details::sf47_op) - #undef case_stmt - default : return error_node(); - } - } - - inline expression_node_ptr special_function(const details::operator_type& operation, expression_node_ptr (&branch)[3]) - { - if (!all_nodes_valid(branch)) - return error_node(); - else if (is_constant_foldable(branch)) - return const_optimize_sf3(operation,branch); - else if (all_nodes_variables(branch)) - return varnode_optimize_sf3(operation,branch); - else + + expression_node_ptr result = expression_generator_(expression,rp); + + if (0 == result) { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate > >(operation,branch); \ - - case_stmt(details::e_sf00,details::sf00_op) case_stmt(details::e_sf01,details::sf01_op) - case_stmt(details::e_sf02,details::sf02_op) case_stmt(details::e_sf03,details::sf03_op) - case_stmt(details::e_sf04,details::sf04_op) case_stmt(details::e_sf05,details::sf05_op) - case_stmt(details::e_sf06,details::sf06_op) case_stmt(details::e_sf07,details::sf07_op) - case_stmt(details::e_sf08,details::sf08_op) case_stmt(details::e_sf09,details::sf09_op) - case_stmt(details::e_sf10,details::sf10_op) case_stmt(details::e_sf11,details::sf11_op) - case_stmt(details::e_sf12,details::sf12_op) case_stmt(details::e_sf13,details::sf13_op) - case_stmt(details::e_sf14,details::sf14_op) case_stmt(details::e_sf15,details::sf15_op) - case_stmt(details::e_sf16,details::sf16_op) case_stmt(details::e_sf17,details::sf17_op) - case_stmt(details::e_sf18,details::sf18_op) case_stmt(details::e_sf19,details::sf19_op) - case_stmt(details::e_sf20,details::sf20_op) case_stmt(details::e_sf21,details::sf21_op) - case_stmt(details::e_sf22,details::sf22_op) case_stmt(details::e_sf23,details::sf23_op) - case_stmt(details::e_sf24,details::sf24_op) case_stmt(details::e_sf25,details::sf25_op) - case_stmt(details::e_sf26,details::sf26_op) case_stmt(details::e_sf27,details::sf27_op) - case_stmt(details::e_sf28,details::sf28_op) case_stmt(details::e_sf29,details::sf29_op) - case_stmt(details::e_sf30,details::sf30_op) case_stmt(details::e_sf31,details::sf31_op) - case_stmt(details::e_sf32,details::sf32_op) case_stmt(details::e_sf33,details::sf33_op) - case_stmt(details::e_sf34,details::sf34_op) case_stmt(details::e_sf35,details::sf35_op) - case_stmt(details::e_sf36,details::sf36_op) case_stmt(details::e_sf37,details::sf37_op) - case_stmt(details::e_sf38,details::sf38_op) case_stmt(details::e_sf39,details::sf39_op) - case_stmt(details::e_sf40,details::sf40_op) case_stmt(details::e_sf41,details::sf41_op) - case_stmt(details::e_sf42,details::sf42_op) case_stmt(details::e_sf43,details::sf43_op) - case_stmt(details::e_sf44,details::sf44_op) case_stmt(details::e_sf45,details::sf45_op) - case_stmt(details::e_sf46,details::sf46_op) case_stmt(details::e_sf47,details::sf47_op) - #undef case_stmt - default : return error_node(); - } - } - } - - inline expression_node_ptr const_optimize_sf4(const details::operator_type& operation, expression_node_ptr (&branch)[4]) - { - expression_node_ptr temp_node = error_node(); - - switch (operation) + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR090 - Failed to generate string range node")); + + free_node(node_allocator_,expression); + } + + rp.clear(); + + return result; + } +#else + inline expression_node_ptr parse_string_range_statement(expression_node_ptr&) + { + return error_node(); + } +#endif + + inline void parse_pending_string_rangesize(expression_node_ptr& expression) + { + // Allow no more than 100 range calls, eg: s[][][]...[][] + const std::size_t max_rangesize_parses = 100; + + std::size_t i = 0; + + while + ( + (0 != expression) && + (i++ < max_rangesize_parses) && + error_list_.empty() && + is_generally_string_node(expression) && + token_is(token_t::e_lsqrbracket,prsrhlpr_t::e_hold) + ) { - #define case_stmt(op0,op1) \ - case op0 : temp_node = node_allocator_-> \ - allocate > >(operation,branch); \ - break; \ - - case_stmt(details::e_sf48,details::sf48_op) case_stmt(details::e_sf49,details::sf49_op) - case_stmt(details::e_sf50,details::sf50_op) case_stmt(details::e_sf51,details::sf51_op) - case_stmt(details::e_sf52,details::sf52_op) case_stmt(details::e_sf53,details::sf53_op) - case_stmt(details::e_sf54,details::sf54_op) case_stmt(details::e_sf55,details::sf55_op) - case_stmt(details::e_sf56,details::sf56_op) case_stmt(details::e_sf57,details::sf57_op) - case_stmt(details::e_sf58,details::sf58_op) case_stmt(details::e_sf59,details::sf59_op) - case_stmt(details::e_sf60,details::sf60_op) case_stmt(details::e_sf61,details::sf61_op) - case_stmt(details::e_sf62,details::sf62_op) case_stmt(details::e_sf63,details::sf63_op) - case_stmt(details::e_sf64,details::sf64_op) case_stmt(details::e_sf65,details::sf65_op) - case_stmt(details::e_sf66,details::sf66_op) case_stmt(details::e_sf67,details::sf67_op) - case_stmt(details::e_sf68,details::sf68_op) case_stmt(details::e_sf69,details::sf69_op) - case_stmt(details::e_sf70,details::sf70_op) case_stmt(details::e_sf71,details::sf71_op) - case_stmt(details::e_sf72,details::sf72_op) case_stmt(details::e_sf73,details::sf73_op) - case_stmt(details::e_sf74,details::sf74_op) case_stmt(details::e_sf75,details::sf75_op) - case_stmt(details::e_sf76,details::sf76_op) case_stmt(details::e_sf77,details::sf77_op) - case_stmt(details::e_sf78,details::sf78_op) case_stmt(details::e_sf79,details::sf79_op) - case_stmt(details::e_sf80,details::sf80_op) case_stmt(details::e_sf81,details::sf81_op) - case_stmt(details::e_sf82,details::sf82_op) case_stmt(details::e_sf83,details::sf83_op) - case_stmt(details::e_sf84,details::sf84_op) case_stmt(details::e_sf85,details::sf85_op) - case_stmt(details::e_sf86,details::sf86_op) case_stmt(details::e_sf87,details::sf87_op) - case_stmt(details::e_sf88,details::sf88_op) case_stmt(details::e_sf89,details::sf89_op) - case_stmt(details::e_sf90,details::sf90_op) case_stmt(details::e_sf91,details::sf91_op) - case_stmt(details::e_sf92,details::sf92_op) case_stmt(details::e_sf93,details::sf93_op) - case_stmt(details::e_sf94,details::sf94_op) case_stmt(details::e_sf95,details::sf95_op) - case_stmt(details::e_sf96,details::sf96_op) case_stmt(details::e_sf97,details::sf97_op) - case_stmt(details::e_sf98,details::sf98_op) case_stmt(details::e_sf99,details::sf99_op) - #undef case_stmt - default : return error_node(); + expression = parse_string_range_statement(expression); + } + } + + template class Sequence> + inline expression_node_ptr simplify(Sequence& expression_list, + Sequence& side_effect_list) + { + if (expression_list.empty()) + return error_node(); + else if (1 == expression_list.size()) + return expression_list[0]; + + Sequence tmp_expression_list; + + bool return_node_present = false; + + for (std::size_t i = 0; i < (expression_list.size() - 1); ++i) + { + if (is_variable_node(expression_list[i])) + continue; + else if ( + is_return_node (expression_list[i]) || + is_break_node (expression_list[i]) || + is_continue_node(expression_list[i]) + ) + { + tmp_expression_list.push_back(expression_list[i]); + + // Remove all subexpressions after first short-circuit + // node has been encountered. + + for (std::size_t j = i + 1; j < expression_list.size(); ++j) + { + free_node(node_allocator_,expression_list[j]); + } + + return_node_present = true; + + break; + } + else if ( + is_constant_node(expression_list[i]) || + is_null_node (expression_list[i]) || + !side_effect_list[i] + ) + { + free_node(node_allocator_,expression_list[i]); + continue; + } + else + tmp_expression_list.push_back(expression_list[i]); } - - T v = temp_node->value(); - details::free_node(*node_allocator_,temp_node); - - return node_allocator_->allocate(v); - } - - inline expression_node_ptr varnode_optimize_sf4(const details::operator_type& operation, expression_node_ptr (&branch)[4]) - { - typedef details::variable_node* variable_ptr; - - const Type& v0 = static_cast(branch[0])->ref(); - const Type& v1 = static_cast(branch[1])->ref(); - const Type& v2 = static_cast(branch[2])->ref(); - const Type& v3 = static_cast(branch[3])->ref(); - - switch (operation) + + if (!return_node_present) { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate_rrrr > >(v0,v1,v2,v3); \ - - case_stmt(details::e_sf48,details::sf48_op) case_stmt(details::e_sf49,details::sf49_op) - case_stmt(details::e_sf50,details::sf50_op) case_stmt(details::e_sf51,details::sf51_op) - case_stmt(details::e_sf52,details::sf52_op) case_stmt(details::e_sf53,details::sf53_op) - case_stmt(details::e_sf54,details::sf54_op) case_stmt(details::e_sf55,details::sf55_op) - case_stmt(details::e_sf56,details::sf56_op) case_stmt(details::e_sf57,details::sf57_op) - case_stmt(details::e_sf58,details::sf58_op) case_stmt(details::e_sf59,details::sf59_op) - case_stmt(details::e_sf60,details::sf60_op) case_stmt(details::e_sf61,details::sf61_op) - case_stmt(details::e_sf62,details::sf62_op) case_stmt(details::e_sf63,details::sf63_op) - case_stmt(details::e_sf64,details::sf64_op) case_stmt(details::e_sf65,details::sf65_op) - case_stmt(details::e_sf66,details::sf66_op) case_stmt(details::e_sf67,details::sf67_op) - case_stmt(details::e_sf68,details::sf68_op) case_stmt(details::e_sf69,details::sf69_op) - case_stmt(details::e_sf70,details::sf70_op) case_stmt(details::e_sf71,details::sf71_op) - case_stmt(details::e_sf72,details::sf72_op) case_stmt(details::e_sf73,details::sf73_op) - case_stmt(details::e_sf74,details::sf74_op) case_stmt(details::e_sf75,details::sf75_op) - case_stmt(details::e_sf76,details::sf76_op) case_stmt(details::e_sf77,details::sf77_op) - case_stmt(details::e_sf78,details::sf78_op) case_stmt(details::e_sf79,details::sf79_op) - case_stmt(details::e_sf80,details::sf80_op) case_stmt(details::e_sf81,details::sf81_op) - case_stmt(details::e_sf82,details::sf82_op) case_stmt(details::e_sf83,details::sf83_op) - case_stmt(details::e_sf84,details::sf84_op) case_stmt(details::e_sf85,details::sf85_op) - case_stmt(details::e_sf86,details::sf86_op) case_stmt(details::e_sf87,details::sf87_op) - case_stmt(details::e_sf88,details::sf88_op) case_stmt(details::e_sf89,details::sf89_op) - case_stmt(details::e_sf90,details::sf90_op) case_stmt(details::e_sf91,details::sf91_op) - case_stmt(details::e_sf92,details::sf92_op) case_stmt(details::e_sf93,details::sf93_op) - case_stmt(details::e_sf94,details::sf94_op) case_stmt(details::e_sf95,details::sf95_op) - case_stmt(details::e_sf96,details::sf96_op) case_stmt(details::e_sf97,details::sf97_op) - case_stmt(details::e_sf98,details::sf98_op) case_stmt(details::e_sf99,details::sf99_op) - #undef case_stmt - default : return error_node(); - } - } - - inline expression_node_ptr special_function(const details::operator_type& operation, expression_node_ptr (&branch)[4]) - { - if (!all_nodes_valid(branch)) - return error_node(); - else if (is_constant_foldable(branch)) - return const_optimize_sf4(operation,branch); - else if (all_nodes_variables(branch)) - return varnode_optimize_sf4(operation,branch); - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate > >(operation,branch); \ - - case_stmt(details::e_sf48,details::sf48_op) case_stmt(details::e_sf49,details::sf49_op) - case_stmt(details::e_sf50,details::sf50_op) case_stmt(details::e_sf51,details::sf51_op) - case_stmt(details::e_sf52,details::sf52_op) case_stmt(details::e_sf53,details::sf53_op) - case_stmt(details::e_sf54,details::sf54_op) case_stmt(details::e_sf55,details::sf55_op) - case_stmt(details::e_sf56,details::sf56_op) case_stmt(details::e_sf57,details::sf57_op) - case_stmt(details::e_sf58,details::sf58_op) case_stmt(details::e_sf59,details::sf59_op) - case_stmt(details::e_sf60,details::sf60_op) case_stmt(details::e_sf61,details::sf61_op) - case_stmt(details::e_sf62,details::sf62_op) case_stmt(details::e_sf63,details::sf63_op) - case_stmt(details::e_sf64,details::sf64_op) case_stmt(details::e_sf65,details::sf65_op) - case_stmt(details::e_sf66,details::sf66_op) case_stmt(details::e_sf67,details::sf67_op) - case_stmt(details::e_sf68,details::sf68_op) case_stmt(details::e_sf69,details::sf69_op) - case_stmt(details::e_sf70,details::sf70_op) case_stmt(details::e_sf71,details::sf71_op) - case_stmt(details::e_sf72,details::sf72_op) case_stmt(details::e_sf73,details::sf73_op) - case_stmt(details::e_sf74,details::sf74_op) case_stmt(details::e_sf75,details::sf75_op) - case_stmt(details::e_sf76,details::sf76_op) case_stmt(details::e_sf77,details::sf77_op) - case_stmt(details::e_sf78,details::sf78_op) case_stmt(details::e_sf79,details::sf79_op) - case_stmt(details::e_sf80,details::sf80_op) case_stmt(details::e_sf81,details::sf81_op) - case_stmt(details::e_sf82,details::sf82_op) case_stmt(details::e_sf83,details::sf83_op) - case_stmt(details::e_sf84,details::sf84_op) case_stmt(details::e_sf85,details::sf85_op) - case_stmt(details::e_sf86,details::sf86_op) case_stmt(details::e_sf87,details::sf87_op) - case_stmt(details::e_sf88,details::sf88_op) case_stmt(details::e_sf89,details::sf89_op) - case_stmt(details::e_sf90,details::sf90_op) case_stmt(details::e_sf91,details::sf91_op) - case_stmt(details::e_sf92,details::sf92_op) case_stmt(details::e_sf93,details::sf93_op) - case_stmt(details::e_sf94,details::sf94_op) case_stmt(details::e_sf95,details::sf95_op) - case_stmt(details::e_sf96,details::sf96_op) case_stmt(details::e_sf97,details::sf97_op) - case_stmt(details::e_sf98,details::sf98_op) case_stmt(details::e_sf99,details::sf99_op) - #undef case_stmt - default : return error_node(); - } - } - - template class Sequence> - inline expression_node_ptr const_optimize_varargfunc(const details::operator_type& operation, Sequence& arg_list) - { - expression_node_ptr temp_node = error_node(); - - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : temp_node = node_allocator_-> \ - allocate > > \ - (arg_list); \ - break; \ - - case_stmt(details::e_sum, details::vararg_add_op ) - case_stmt(details::e_prod, details::vararg_mul_op ) - case_stmt(details::e_avg, details::vararg_avg_op ) - case_stmt(details::e_min, details::vararg_min_op ) - case_stmt(details::e_max, details::vararg_max_op ) - case_stmt(details::e_mand, details::vararg_mand_op ) - case_stmt(details::e_mor, details::vararg_mor_op ) - case_stmt(details::e_multi,details::vararg_multi_op) - #undef case_stmt - default : return error_node(); + tmp_expression_list.push_back(expression_list.back()); } - - T v = temp_node->value(); - details::free_node(*node_allocator_,temp_node); - - return node_allocator_->allocate(v); - } - - inline bool special_one_parameter_vararg(const details::operator_type& operation) - { - return ( - (details::e_sum == operation) || - (details::e_prod == operation) || - (details::e_avg == operation) || - (details::e_min == operation) || - (details::e_max == operation) - ); - } - - template class Sequence> - inline expression_node_ptr varnode_optimize_varargfunc(const details::operator_type& operation, Sequence& arg_list) - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate > >(arg_list); \ - - case_stmt(details::e_sum, details::vararg_add_op ) - case_stmt(details::e_prod, details::vararg_mul_op ) - case_stmt(details::e_avg, details::vararg_avg_op ) - case_stmt(details::e_min, details::vararg_min_op ) - case_stmt(details::e_max, details::vararg_max_op ) - case_stmt(details::e_mand, details::vararg_mand_op ) - case_stmt(details::e_mor, details::vararg_mor_op ) - case_stmt(details::e_multi,details::vararg_multi_op) - #undef case_stmt - default : return error_node(); - } - } - - template class Sequence> - inline expression_node_ptr vectorize_func(const details::operator_type& operation, Sequence& arg_list) - { - if (1 == arg_list.size()) - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate > >(arg_list[0]); \ - - case_stmt(details::e_sum, details::vec_add_op) - case_stmt(details::e_prod, details::vec_mul_op) - case_stmt(details::e_avg, details::vec_avg_op) - case_stmt(details::e_min, details::vec_min_op) - case_stmt(details::e_max, details::vec_max_op) - #undef case_stmt - default : return error_node(); - } + + expression_list.swap(tmp_expression_list); + + if (tmp_expression_list.size() > expression_list.size()) + { + exprtk_debug(("simplify() - Reduced subexpressions from %d to %d\n", + static_cast(tmp_expression_list.size()), + static_cast(expression_list .size()))); } + + if ( + return_node_present || + side_effect_list.back() || + (expression_list.size() > 1) + ) + state_.activate_side_effect("simplify()"); + + if (1 == expression_list.size()) + return expression_list[0]; else - return error_node(); - } - - template class Sequence> - inline expression_node_ptr vararg_function(const details::operator_type& operation, Sequence& arg_list) - { - if (!all_nodes_valid(arg_list)) - { - details::free_all_nodes(*node_allocator_,arg_list); - - return error_node(); - } - else if (is_constant_foldable(arg_list)) - return const_optimize_varargfunc(operation,arg_list); - else if ((arg_list.size() == 1) && details::is_ivector_node(arg_list[0])) - return vectorize_func(operation,arg_list); - else if ((arg_list.size() == 1) && special_one_parameter_vararg(operation)) - return arg_list[0]; - else if (all_nodes_variables(arg_list)) - return varnode_optimize_varargfunc(operation,arg_list); - - switch (operation) + return expression_generator_.vararg_function(details::e_multi,expression_list); + } + + inline expression_node_ptr parse_multi_sequence(const std::string& source = "") + { + token_t::token_type close_bracket = token_t::e_rcrlbracket; + token_t::token_type seperator = token_t::e_eof; + + if (!token_is(token_t::e_lcrlbracket)) + { + if (token_is(token_t::e_lbracket)) + { + close_bracket = token_t::e_rbracket; + seperator = token_t::e_comma; + } + else + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR091 - Expected '" + token_t::to_str(close_bracket) + "' for call to multi-sequence" + + ((!source.empty()) ? std::string(" section of " + source): ""))); + + return error_node(); + } + } + else if (token_is(token_t::e_rcrlbracket)) + { + return node_allocator_.allocate >(); + } + + std::vector arg_list; + std::vector side_effect_list; + + expression_node_ptr result = error_node(); + + scoped_vec_delete sdd(*this,arg_list); + + scope_handler sh(*this); + + scoped_bool_or_restorer sbr(state_.side_effect_present); + + for ( ; ; ) + { + state_.side_effect_present = false; + + expression_node_ptr arg = parse_expression(); + + if (0 == arg) + return error_node(); + else + { + arg_list.push_back(arg); + side_effect_list.push_back(state_.side_effect_present); + } + + if (token_is(close_bracket)) + break; + + bool is_next_close = peek_token_is(close_bracket); + + if (!token_is(seperator) && is_next_close) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR092 - Expected '" + details::to_str(seperator) + "' for call to multi-sequence section of " + source)); + + return error_node(); + } + + if (token_is(close_bracket)) + break; + } + + result = simplify(arg_list,side_effect_list); + + sdd.delete_ptr = (0 == result); + return result; + } + + inline bool parse_range(range_t& rp, const bool skip_lsqr = false) + { + // Examples of valid ranges: + // 1. [1:5] -> 1..5 + // 2. [ :5] -> 0..5 + // 3. [1: ] -> 1..end + // 4. [x:y] -> x..y where x <= y + // 5. [x+1:y/2] -> x+1..y/2 where x+1 <= y/2 + // 6. [ :y] -> 0..y where 0 <= y + // 7. [x: ] -> x..end where x <= end + + rp.clear(); + + if (!skip_lsqr && !token_is(token_t::e_lsqrbracket)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR093 - Expected '[' for start of range")); + + return false; + } + + if (token_is(token_t::e_colon)) { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate > >(arg_list); \ - - case_stmt(details::e_sum, details::vararg_add_op ) - case_stmt(details::e_prod, details::vararg_mul_op ) - case_stmt(details::e_avg, details::vararg_avg_op ) - case_stmt(details::e_min, details::vararg_min_op ) - case_stmt(details::e_max, details::vararg_max_op ) - case_stmt(details::e_mand, details::vararg_mand_op ) - case_stmt(details::e_mor, details::vararg_mor_op ) - case_stmt(details::e_multi,details::vararg_multi_op) - #undef case_stmt - default : return error_node(); - } - } - - template - inline expression_node_ptr function(ifunction_t* f, expression_node_ptr (&b)[N]) - { - typedef typename details::function_N_node function_N_node_t; - expression_node_ptr result = synthesize_expression(f,b); - - if (0 == result) - return error_node(); + rp.n0_c.first = true; + rp.n0_c.second = 0; + rp.cache.first = 0; + } else { - // Can the function call be completely optimized? - if (details::is_constant_node(result)) - return result; - else if (!all_nodes_valid(b)) - return error_node(); - else if (N != f->param_count) - { - details::free_all_nodes(*node_allocator_,b); - - return error_node(); - } - - function_N_node_t* func_node_ptr = static_cast(result); - - if (func_node_ptr->init_branches(b)) - return result; - else - { - details::free_all_nodes(*node_allocator_,b); - - return error_node(); - } + expression_node_ptr r0 = parse_expression(); + + if (0 == r0) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR094 - Failed parse begin section of range")); + + return false; + + } + else if (is_constant_node(r0)) + { + T r0_value = r0->value(); + + if (r0_value >= T(0)) + { + rp.n0_c.first = true; + rp.n0_c.second = static_cast(details::numeric::to_int64(r0_value)); + rp.cache.first = rp.n0_c.second; + } + + free_node(node_allocator_,r0); + + if (r0_value < T(0)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR095 - Range lower bound less than zero! Constraint: r0 >= 0")); + + return false; + } + } + else + { + rp.n0_e.first = true; + rp.n0_e.second = r0; + } + + if (!token_is(token_t::e_colon)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR096 - Expected ':' for break in range")); + + rp.free(); + return false; + } + } + + if (token_is(token_t::e_rsqrbracket)) + { + rp.n1_c.first = true; + rp.n1_c.second = std::numeric_limits::max(); } - } - - inline expression_node_ptr function(ifunction_t* f) - { - typedef typename details::function_N_node function_N_node_t; - return node_allocator_->allocate(f); - } - - inline expression_node_ptr vararg_function_call(ivararg_function_t* vaf, - std::vector& arg_list) - { - if (!all_nodes_valid(arg_list)) + else { - details::free_all_nodes(*node_allocator_,arg_list); - - return error_node(); + expression_node_ptr r1 = parse_expression(); + + if (0 == r1) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR097 - Failed parse end section of range")); + + rp.free(); + return false; + + } + else if (is_constant_node(r1)) + { + T r1_value = r1->value(); + + if (r1_value >= T(0)) + { + rp.n1_c.first = true; + rp.n1_c.second = static_cast(details::numeric::to_int64(r1_value)); + rp.cache.second = rp.n1_c.second; + } + + free_node(node_allocator_,r1); + + if (r1_value < T(0)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR098 - Range upper bound less than zero! Constraint: r1 >= 0")); + + return false; + } + } + else + { + rp.n1_e.first = true; + rp.n1_e.second = r1; + } + + if (!token_is(token_t::e_rsqrbracket)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR099 - Expected ']' for start of range")); + + rp.free(); + return false; + } + } + + if (rp.const_range()) + { + std::size_t r0 = 0; + std::size_t r1 = 0; + + bool rp_result = rp(r0,r1); + + if (!rp_result || (r0 > r1)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR100 - Invalid range, Constraint: r0 <= r1")); + + return false; + } + } + + return true; + } + + inline void lodge_symbol(const std::string& symbol, + const symbol_type st) + { + dec_.add_symbol(symbol,st); + } + +#ifndef exprtk_disable_string_capabilities + inline expression_node_ptr parse_string() + { + const std::string symbol = current_token().value; + + typedef details::stringvar_node* strvar_node_t; + + expression_node_ptr result = error_node(); + strvar_node_t const_str_node = static_cast(0); + bool is_const_string = false; + + scope_element& se = sem_.get_active_element(symbol); + + if (scope_element::e_string == se.type) + { + se.active = true; + result = se.str_node; + lodge_symbol(symbol,e_st_local_string); } - - typedef details::vararg_function_node alloc_type; - - expression_node_ptr result = node_allocator_->allocate(vaf,arg_list); - - if ( - !arg_list.empty() && - !vaf->has_side_effects && - is_constant_foldable(arg_list) - ) + else { - Type v = result->value(); - details::free_node(*node_allocator_,result); - result = node_allocator_->allocate(v); + if (!symtab_store_.is_conststr_stringvar(symbol)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR101 - Unknown string symbol")); + + return error_node(); + } + + result = symtab_store_.get_stringvar(symbol); + + is_const_string = symtab_store_.is_constant_string(symbol); + + if (is_const_string) + { + const_str_node = static_cast(result); + result = expression_generator_(const_str_node->str()); + } + + lodge_symbol(symbol,e_st_string); + } + + if (peek_token_is(token_t::e_lsqrbracket)) + { + next_token(); + + if (peek_token_is(token_t::e_rsqrbracket)) + { + next_token(); + next_token(); + + if (const_str_node) + { + free_node(node_allocator_,result); + + return expression_generator_(T(const_str_node->size())); + } + else + return node_allocator_.allocate > + (static_cast*>(result)->ref()); + } + + range_t rp; + + if (!parse_range(rp)) + { + free_node(node_allocator_,result); + + return error_node(); + } + else if (const_str_node) + { + free_node(node_allocator_,result); + result = expression_generator_(const_str_node->ref(),rp); + } + else + result = expression_generator_(static_cast*>(result)->ref(),rp); + + if (result) + rp.clear(); } - + else + next_token(); + return result; - } - - inline expression_node_ptr generic_function_call(igeneric_function_t* gf, - std::vector& arg_list, - const std::size_t& param_seq_index = std::numeric_limits::max()) - { - if (!all_nodes_valid(arg_list)) - { - details::free_all_nodes(*node_allocator_,arg_list); - return error_node(); + } +#else + inline expression_node_ptr parse_string() + { + return error_node(); + } +#endif + +#ifndef exprtk_disable_string_capabilities + inline expression_node_ptr parse_const_string() + { + const std::string const_str = current_token().value; + expression_node_ptr result = expression_generator_(const_str); + + if (peek_token_is(token_t::e_lsqrbracket)) + { + next_token(); + + if (peek_token_is(token_t::e_rsqrbracket)) + { + next_token(); + next_token(); + + free_node(node_allocator_,result); + + return expression_generator_(T(const_str.size())); + } + + range_t rp; + + if (!parse_range(rp)) + { + free_node(node_allocator_,result); + + return error_node(); + } + + free_node(node_allocator_,result); + + if (rp.n1_c.first && (rp.n1_c.second == std::numeric_limits::max())) + { + rp.n1_c.second = const_str.size() - 1; + rp.cache.second = rp.n1_c.second; + } + + if ( + (rp.n0_c.first && (rp.n0_c.second >= const_str.size())) || + (rp.n1_c.first && (rp.n1_c.second >= const_str.size())) + ) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR102 - Overflow in range for string: '" + const_str + "'[" + + (rp.n0_c.first ? details::to_str(static_cast(rp.n0_c.second)) : "?") + ":" + + (rp.n1_c.first ? details::to_str(static_cast(rp.n1_c.second)) : "?") + "]")); + + return error_node(); + } + + result = expression_generator_(const_str,rp); + + if (result) + rp.clear(); } - - typedef details::generic_function_node alloc_type1; - typedef details::multimode_genfunction_node alloc_type2; - - const std::size_t no_psi = std::numeric_limits::max(); - - expression_node_ptr result = error_node(); - - if (no_psi == param_seq_index) - result = node_allocator_->allocate(gf,arg_list); else - result = node_allocator_->allocate(gf,param_seq_index,arg_list); - - alloc_type1* genfunc_node_ptr = static_cast(result); - + next_token(); + + return result; + } +#else + inline expression_node_ptr parse_const_string() + { + return error_node(); + } +#endif + + inline expression_node_ptr parse_vector() + { + const std::string symbol = current_token().value; + + vector_holder_ptr vec = vector_holder_ptr(0); + + const scope_element& se = sem_.get_active_element(symbol); + if ( - !arg_list.empty() && - !gf->has_side_effects && - is_constant_foldable(arg_list) - ) - { - genfunc_node_ptr->init_branches(); - Type v = result->value(); - details::free_node(*node_allocator_,result); - return node_allocator_->allocate(v); - } - else if (genfunc_node_ptr->init_branches()) - return result; + (se.name != symbol) || + (se.depth > state_.scope_depth) || + (scope_element::e_vector != se.type) + ) + { + if (0 == (vec = symtab_store_.get_vector(symbol))) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR103 - Symbol '" + symbol+ " not a vector")); + + return error_node(); + } + } else + vec = se.vec_node; + + expression_node_ptr index_expr = error_node(); + + next_token(); + + if (!token_is(token_t::e_lsqrbracket)) { - details::free_node(*node_allocator_,result); - details::free_all_nodes(*node_allocator_,arg_list); - return error_node(); + return node_allocator_.allocate(vec); } - } - - inline expression_node_ptr string_function_call(igeneric_function_t* gf, - std::vector& arg_list, - const std::size_t& param_seq_index = std::numeric_limits::max()) - { - if (!all_nodes_valid(arg_list)) + else if (token_is(token_t::e_rsqrbracket)) { - details::free_all_nodes(*node_allocator_,arg_list); - return error_node(); + return expression_generator_(T(vec->size())); } - - typedef details::string_function_node alloc_type1; - typedef details::multimode_strfunction_node alloc_type2; - - const std::size_t no_psi = std::numeric_limits::max(); - - expression_node_ptr result = error_node(); - - if (no_psi == param_seq_index) - result = node_allocator_->allocate(gf,arg_list); - else - result = node_allocator_->allocate(gf,param_seq_index,arg_list); - - alloc_type1* strfunc_node_ptr = static_cast(result); - - if ( - !arg_list.empty() && - !gf->has_side_effects && - is_constant_foldable(arg_list) - ) - { - strfunc_node_ptr->init_branches(); - Type v = result->value(); - details::free_node(*node_allocator_,result); - return node_allocator_->allocate(v); - } - else if (strfunc_node_ptr->init_branches()) - return result; - else + else if (0 == (index_expr = parse_expression())) { - details::free_node(*node_allocator_,result); - details::free_all_nodes(*node_allocator_,arg_list); - return error_node(); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR104 - Failed to parse index for vector: '" + symbol + "'")); + + return error_node(); } - } - - inline expression_node_ptr vector_element(const std::string& symbol, - vector_holder_ptr vector_base, - expression_node_ptr index) - { - expression_node_ptr result = error_node(); - - if (details::is_constant_node(index)) + else if (!token_is(token_t::e_rsqrbracket)) { - std::size_t i = static_cast(details::numeric::to_int64(index->value())); - details::free_node(*node_allocator_,index); - Type* v = (*vector_base)[i]; - - scope_element& se = parser_->sem_.get_element(symbol,i); - - if (se.index == i) - { - result = se.var_node; - } - else - { - scope_element nse; - nse.name = symbol; - nse.type = scope_element::e_vecelem; - nse.index = i; - nse.depth = parser_->scope_depth_; - nse.data = 0; - nse.var_node = new variable_node_t((*v)); - - if (!parser_->sem_.add_element(nse)) - { - parser_->set_synthesis_error("Failed to add new local vector element to SEM [1]"); - result = error_node(); - } - else - exprtk_debug(("vector_element() - INFO - Added new local vector element: %s\n",nse.name.c_str())); - - result = nse.var_node; - } - } - else - result = node_allocator_->allocate >(index,(*vector_base)[0]); - - return result; - } - - private: - - template - inline bool is_constant_foldable(NodePtr (&b)[N]) const - { - for (std::size_t i = 0; i < N; ++i) + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR105 - Expected ']' for index of vector: '" + symbol + "'")); + + free_node(node_allocator_,index_expr); + + return error_node(); + } + + return expression_generator_.vector_element(symbol,vec,index_expr); + } + + inline expression_node_ptr parse_vararg_function_call(ivararg_function* vararg_function, const std::string& vararg_function_name) + { + std::vector arg_list; + expression_node_ptr result = error_node(); + + scoped_vec_delete sdd(*this,arg_list); + + next_token(); + + if (token_is(token_t::e_lbracket)) { - if (0 == b[i]) - return false; - else if (!details::is_constant_node(b[i])) - return false; + if (token_is(token_t::e_rbracket)) + { + if (!vararg_function->allow_zero_parameters()) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR106 - Zero parameter call to vararg function: " + + vararg_function_name + " not allowed")); + + return error_node(); + } + } + else + { + for ( ; ; ) + { + expression_node_ptr arg = parse_expression(); + + if (0 == arg) + return error_node(); + else + arg_list.push_back(arg); + + if (token_is(token_t::e_rbracket)) + break; + else if (!token_is(token_t::e_comma)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR107 - Expected ',' for call to vararg function: " + + vararg_function_name)); + + return error_node(); + } + } + } } - - return true; - } - - template class Sequence> - inline bool is_constant_foldable(const Sequence& b) const - { - for (std::size_t i = 0; i < b.size(); ++i) + else if (!vararg_function->allow_zero_parameters()) { - if (0 == b[i]) - return false; - else if (!details::is_constant_node(b[i])) - return false; + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR108 - Zero parameter call to vararg function: " + + vararg_function_name + " not allowed")); + + return error_node(); } - - return true; - } - - void lodge_assignment(symbol_type cst, expression_node_ptr node) - { - if (!parser_->dec_.collect_assignments()) - return; - - std::string symbol_name; - - switch (cst) + + if (arg_list.size() < vararg_function->min_num_args()) { - case e_st_variable : symbol_name = parser_->symbol_table_ - .get_variable_name(node); - break; - - case e_st_string : symbol_name = parser_->symbol_table_ - .get_stringvar_name(node); - break; - - case e_st_vector : { - typedef details::vector_holder vector_holder_t; - - vector_holder_t& vh = static_cast(node)->ref(); - - symbol_name = parser_->symbol_table_.get_vector_name(&vh); - } - break; - - default : return; + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR109 - Invalid number of parameters to call to vararg function: " + + vararg_function_name + ", require at least " + + details::to_str(static_cast(vararg_function->min_num_args())) + " parameters")); + + return error_node(); } - - parser_->dec_.add_assignment(symbol_name,cst); - } - - inline expression_node_ptr synthesize_assignment_expression(const details::operator_type& operation, expression_node_ptr (&branch)[2]) - { - if (details::is_variable_node(branch[0])) + else if (arg_list.size() > vararg_function->max_num_args()) { - lodge_assignment(e_st_variable,branch[0]); - - return synthesize_expression(operation,branch); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR110 - Invalid number of parameters to call to vararg function: " + + vararg_function_name + ", require no more than " + + details::to_str(static_cast(vararg_function->max_num_args())) + " parameters")); + + return error_node(); + } + + result = expression_generator_.vararg_function_call(vararg_function,arg_list); + + sdd.delete_ptr = (0 == result); + + return result; + } + + class type_checker + { + public: + + typedef parser parser_t; + typedef std::vector param_seq_list_t; + + type_checker(parser_t& p, + const std::string& func_name, + const std::string& param_seq) + : invalid_state_(true), + parser_(p), + function_name_(func_name) + { + split(param_seq); + } + + bool verify(const std::string& param_seq, std::size_t& pseq_index) + { + if (param_seq_list_.empty()) + return true; + + std::vector > error_list; + + for (std::size_t i = 0; i < param_seq_list_.size(); ++i) + { + details::char_t diff_value = 0; + std::size_t diff_index = 0; + + bool result = details::sequence_match(param_seq_list_[i], + param_seq, + diff_index,diff_value); + + if (result) + { + pseq_index = i; + return true; + } + else + error_list.push_back(std::make_pair(diff_index,diff_value)); + } + + if (1 == error_list.size()) + { + parser_. + set_error( + make_error(parser_error::e_syntax, + parser_.current_token(), + "ERR111 - Failed parameter type check for function '" + function_name_ + "', " + "Expected '" + param_seq_list_[0] + "' call set: '" + param_seq +"'")); + } + else + { + // find first with largest diff_index; + std::size_t max_diff_index = 0; + + for (std::size_t i = 1; i < error_list.size(); ++i) + { + if (error_list[i].first > error_list[max_diff_index].first) + { + max_diff_index = i; + } + } + + parser_. + set_error( + make_error(parser_error::e_syntax, + parser_.current_token(), + "ERR112 - Failed parameter type check for function '" + function_name_ + "', " + "Best match: '" + param_seq_list_[max_diff_index] + "' call set: '" + param_seq +"'")); + } + + return false; + } + + std::size_t paramseq_count() const + { + return param_seq_list_.size(); + } + + std::string paramseq(const std::size_t& index) const + { + return param_seq_list_[index]; + } + + bool invalid() const + { + return !invalid_state_; + } + + bool allow_zero_parameters() const + { + return + param_seq_list_.end() != std::find(param_seq_list_.begin(), + param_seq_list_.end(), + "Z"); + } + + private: + + void split(const std::string& s) + { + if (s.empty()) + return; + + std::size_t start = 0; + std::size_t end = 0; + + param_seq_list_t param_seq_list; + + struct token_validator + { + static inline bool process(const std::string& str, + std::size_t s, std::size_t e, + param_seq_list_t& psl) + { + if ( + (e - s) && + (std::string::npos == str.find("?*")) && + (std::string::npos == str.find("**")) + ) + { + const std::string curr_str = str.substr(s,e - s); + + if ("Z" == curr_str) + { + psl.push_back(curr_str); + return true; + } + else if (std::string::npos == curr_str.find_first_not_of("STV*?|")) + { + psl.push_back(curr_str); + return true; + } + } + + return false; + } + }; + + while (std::string::npos != (end = s.find('|',start))) + { + if (!token_validator::process(s,start,end,param_seq_list)) + { + invalid_state_ = false; + + const std::string err_param_seq = s.substr(start,end - start); + + parser_. + set_error( + make_error(parser_error::e_syntax, + parser_.current_token(), + "ERR113 - Invalid parameter sequence of '" + err_param_seq + + "' for function: " + function_name_)); + + return; + } + else + start = end + 1; + } + + if (start < s.size()) + { + if (token_validator::process(s,start,s.size(),param_seq_list)) + param_seq_list_ = param_seq_list; + else + { + const std::string err_param_seq = s.substr(start,s.size() - start); + + parser_. + set_error( + make_error(parser_error::e_syntax, + parser_.current_token(), + "ERR114 - Invalid parameter sequence of '" + err_param_seq + + "' for function: " + function_name_)); + return; + } + } + } + + type_checker(const type_checker&); + type_checker& operator=(const type_checker&); + + bool invalid_state_; + parser_t& parser_; + std::string function_name_; + param_seq_list_t param_seq_list_; + }; + + inline expression_node_ptr parse_generic_function_call(igeneric_function* function, const std::string& function_name) + { + std::vector arg_list; + + scoped_vec_delete sdd(*this,arg_list); + + next_token(); + + std::string param_type_list; + + type_checker tc(*this,function_name,function->parameter_sequence); + + if (tc.invalid()) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR115 - Type checker instantiation failure for generic function: " + function_name)); + + return error_node(); } - else if (details::is_vector_elem_node(branch[0])) - return synthesize_expression(operation,branch); - else if (details::is_string_node(branch[0])) + + if ( + !function->parameter_sequence.empty() && + function->allow_zero_parameters () && + !tc .allow_zero_parameters () + ) { - lodge_assignment(e_st_string,branch[0]); - - return synthesize_expression(operation,branch); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR116 - Mismatch in zero parameter condition for generic function: " + + function_name)); + + return error_node(); } - else if (details::is_string_range_node(branch[0])) + + if (token_is(token_t::e_lbracket)) { - lodge_assignment(e_st_string,branch[0]); - - return synthesize_expression(operation,branch); + if (token_is(token_t::e_rbracket)) + { + if ( + !function->allow_zero_parameters() && + !tc .allow_zero_parameters() + ) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR117 - Zero parameter call to generic function: " + + function_name + " not allowed")); + + return error_node(); + } + } + else + { + for ( ; ; ) + { + expression_node_ptr arg = parse_expression(); + + if (0 == arg) + return error_node(); + + if (is_ivector_node(arg)) + param_type_list += 'V'; + else if (is_generally_string_node(arg)) + param_type_list += 'S'; + else // Everything else is assumed to be a scalar returning expression + param_type_list += 'T'; + + arg_list.push_back(arg); + + if (token_is(token_t::e_rbracket)) + break; + else if (!token_is(token_t::e_comma)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR118 - Expected ',' for call to generic function: " + function_name)); + + return error_node(); + } + } + } } - else if (details::is_vector_node(branch[0])) + else if ( + !function->parameter_sequence.empty() && + function->allow_zero_parameters () && + !tc .allow_zero_parameters () + ) { - lodge_assignment(e_st_vector,branch[0]); - - if (details::is_ivector_node(branch[1])) - return synthesize_expression(operation,branch); - else - return synthesize_expression(operation,branch); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR119 - Zero parameter call to generic function: " + + function_name + " not allowed")); + + return error_node(); + } + + std::size_t param_seq_index = 0; + + if (!tc.verify(param_type_list, param_seq_index)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR120 - Expected ',' for call to generic function: " + function_name)); + + return error_node(); } + + expression_node_ptr result = error_node(); + + if (tc.paramseq_count() <= 1) + result = expression_generator_ + .generic_function_call(function,arg_list); else + result = expression_generator_ + .generic_function_call(function,arg_list,param_seq_index); + + sdd.delete_ptr = (0 == result); + + return result; + } + + inline expression_node_ptr parse_string_function_call(igeneric_function* function, const std::string& function_name) + { + std::vector arg_list; + + scoped_vec_delete sdd(*this,arg_list); + + next_token(); + + std::string param_type_list; + + type_checker tc(*this,function_name,function->parameter_sequence); + + if ( + (!function->parameter_sequence.empty()) && + (0 == tc.paramseq_count()) + ) { - parser_->set_synthesis_error("Invalid assignment operation.[1]"); - - return error_node(); + return error_node(); } - } - - inline expression_node_ptr synthesize_assignment_operation_expression(const details::operator_type& operation, - expression_node_ptr (&branch)[2]) - { - if (details::is_variable_node(branch[0])) + + if (token_is(token_t::e_lbracket)) { - lodge_assignment(e_st_variable,branch[0]); - - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ - - case_stmt(details::e_addass,details::add_op) - case_stmt(details::e_subass,details::sub_op) - case_stmt(details::e_mulass,details::mul_op) - case_stmt(details::e_divass,details::div_op) - case_stmt(details::e_modass,details::mod_op) - #undef case_stmt - default : return error_node(); - } - } - else if (details::is_vector_elem_node(branch[0])) - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ - - case_stmt(details::e_addass,details::add_op) - case_stmt(details::e_subass,details::sub_op) - case_stmt(details::e_mulass,details::mul_op) - case_stmt(details::e_divass,details::div_op) - case_stmt(details::e_modass,details::mod_op) - #undef case_stmt - default : return error_node(); - } - } - else if (details::is_vector_node(branch[0])) - { - lodge_assignment(e_st_vector,branch[0]); - - if (details::is_ivector_node(branch[1])) - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ - - case_stmt(details::e_addass,details::add_op) - case_stmt(details::e_subass,details::sub_op) - case_stmt(details::e_mulass,details::mul_op) - case_stmt(details::e_divass,details::div_op) - case_stmt(details::e_modass,details::mod_op) - #undef case_stmt - default : return error_node(); - } - } - else - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ - - case_stmt(details::e_addass,details::add_op) - case_stmt(details::e_subass,details::sub_op) - case_stmt(details::e_mulass,details::mul_op) - case_stmt(details::e_divass,details::div_op) - case_stmt(details::e_modass,details::mod_op) - #undef case_stmt - default : return error_node(); - } - } + if (!token_is(token_t::e_rbracket)) + { + for ( ; ; ) + { + expression_node_ptr arg = parse_expression(); + + if (0 == arg) + return error_node(); + + if (is_ivector_node(arg)) + param_type_list += 'V'; + else if (is_generally_string_node(arg)) + param_type_list += 'S'; + else // Everything else is a scalar returning expression + param_type_list += 'T'; + + arg_list.push_back(arg); + + if (token_is(token_t::e_rbracket)) + break; + else if (!token_is(token_t::e_comma)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR121 - Expected ',' for call to string function: " + function_name)); + + return error_node(); + } + } + } } - else if ( - (details::e_addass == operation) && - details::is_string_node(branch[0]) - ) + + std::size_t param_seq_index = 0; + + if (!tc.verify(param_type_list, param_seq_index)) { - typedef details::assignment_string_node addass_t; - - lodge_assignment(e_st_string,branch[0]); - - return synthesize_expression(operation,branch); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR122 - Expected ',' for call to string function: " + function_name)); + + return error_node(); } + + expression_node_ptr result = error_node(); + + if (tc.paramseq_count() <= 1) + result = expression_generator_ + .string_function_call(function,arg_list); else - { - parser_->set_synthesis_error("Invalid assignment operation[2]"); - - return error_node(); - } - } - - inline expression_node_ptr synthesize_veceqineq_operation_expression(const details::operator_type& operation, - expression_node_ptr (&branch)[2]) - { - const bool is_b0_ivec = details::is_ivector_node(branch[0]); - const bool is_b1_ivec = details::is_ivector_node(branch[1]); - - if (is_b0_ivec && is_b1_ivec) - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ - - case_stmt(details:: e_lt,details:: lt_op) - case_stmt(details:: e_lte,details:: lte_op) - case_stmt(details:: e_gt,details:: gt_op) - case_stmt(details:: e_gte,details:: gte_op) - case_stmt(details:: e_eq,details:: eq_op) - case_stmt(details:: e_ne,details:: ne_op) - #undef case_stmt - default : return error_node(); - } - } - else if (is_b0_ivec && !is_b1_ivec) - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ - - case_stmt(details:: e_lt,details:: lt_op) - case_stmt(details:: e_lte,details:: lte_op) - case_stmt(details:: e_gt,details:: gt_op) - case_stmt(details:: e_gte,details:: gte_op) - case_stmt(details:: e_eq,details:: eq_op) - case_stmt(details:: e_ne,details:: ne_op) - #undef case_stmt - default : return error_node(); - } - } - else if (!is_b0_ivec && is_b1_ivec) - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ - - case_stmt(details:: e_lt,details:: lt_op) - case_stmt(details:: e_lte,details:: lte_op) - case_stmt(details:: e_gt,details:: gt_op) - case_stmt(details:: e_gte,details:: gte_op) - case_stmt(details:: e_eq,details:: eq_op) - case_stmt(details:: e_ne,details:: ne_op) - #undef case_stmt - default : return error_node(); - } - } - else - return error_node(); - } - - inline expression_node_ptr synthesize_vecarithmetic_operation_expression(const details::operator_type& operation, - expression_node_ptr (&branch)[2]) - { - const bool is_b0_ivec = details::is_ivector_node(branch[0]); - const bool is_b1_ivec = details::is_ivector_node(branch[1]); - - #define vector_ops \ - case_stmt(details::e_add,details::add_op) \ - case_stmt(details::e_sub,details::sub_op) \ - case_stmt(details::e_mul,details::mul_op) \ - case_stmt(details::e_div,details::div_op) \ - case_stmt(details::e_mod,details::mod_op) \ - - if (is_b0_ivec && is_b1_ivec) - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ - - vector_ops - case_stmt(details::e_pow,details:: pow_op) - #undef case_stmt - default : return error_node(); - } - } - else if (is_b0_ivec && !is_b1_ivec) - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ - - vector_ops - case_stmt(details::e_pow,details:: pow_op) - #undef case_stmt - default : return error_node(); - } - } - else if (!is_b0_ivec && is_b1_ivec) - { - switch (operation) - { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ - - vector_ops - #undef case_stmt - default : return error_node(); - } + result = expression_generator_ + .string_function_call(function,arg_list,param_seq_index); + + sdd.delete_ptr = (0 == result); + + return result; + } + + template + struct parse_special_function_impl + { + static inline expression_node_ptr process(parser& p,const details::operator_type opt_type) + { + expression_node_ptr branch[NumberOfParameters]; + expression_node_ptr result = error_node(); + std::fill_n(branch,NumberOfParameters,reinterpret_cast(0)); + scoped_delete sd(p,branch); + + p.next_token(); + + if (!p.token_is(token_t::e_lbracket)) + { + p.set_error( + make_error(parser_error::e_syntax, + p.current_token(), + "ERR123 - Expected '(' for special function")); + + return error_node(); + } + + for (std::size_t i = 0; i < NumberOfParameters; ++i) + { + branch[i] = p.parse_expression(); + + if (0 == branch[i]) + { + return p.error_node(); + } + else if (i < (NumberOfParameters - 1)) + { + if (!p.token_is(token_t::e_comma)) + { + p.set_error( + make_error(parser_error::e_syntax, + p.current_token(), + "ERR124 - Expected ',' before next parameter of special function")); + + return p.error_node(); + } + } + } + + if (!p.token_is(token_t::e_rbracket)) + return p.error_node(); + else + result = p.expression_generator_.special_function(opt_type,branch); + + sd.delete_ptr = (0 == result); + + return result; } - else - return error_node(); - - #undef vector_ops - } - - inline expression_node_ptr synthesize_swap_expression(expression_node_ptr (&branch)[2]) - { - const bool v0_is_ivar = details::is_ivariable_node(branch[0]); - const bool v1_is_ivar = details::is_ivariable_node(branch[1]); - - const bool v0_is_ivec = details::is_ivector_node(branch[0]); - const bool v1_is_ivec = details::is_ivector_node(branch[1]); - - const bool v0_is_str = details::is_generally_string_node(branch[0]); - const bool v1_is_str = details::is_generally_string_node(branch[1]); - - if (v0_is_ivar && v1_is_ivar) + }; + + inline expression_node_ptr parse_special_function() + { + // Expect: $fDD(expr0,expr1,expr2) or $fDD(expr0,expr1,expr2,expr3) + if ( + !details::is_digit(current_token().value[2]) || + !details::is_digit(current_token().value[3]) + ) + { + set_error( + make_error(parser_error::e_token, + current_token(), + "ERR125 - Invalid special function[1]: " + current_token().value)); + + return error_node(); + } + + const unsigned int id = (current_token().value[2] - '0') * 10 + (current_token().value[3] - '0'); + + if (id >= details::e_sffinal) + { + set_error( + make_error(parser_error::e_token, + current_token(), + "ERR126 - Invalid special function[2]: " + current_token().value)); + + return error_node(); + } + + const std::size_t sf_3_to_4 = details::e_sf48; + const details::operator_type opt_type = details::operator_type(id + 1000); + const std::size_t NumberOfParameters = (id < (sf_3_to_4 - 1000)) ? 3 : 4; + + switch (NumberOfParameters) + { + case 3 : return parse_special_function_impl::process(*this,opt_type); + case 4 : return parse_special_function_impl::process(*this,opt_type); + default : return error_node(); + } + } + + inline expression_node_ptr parse_null_statement() + { + next_token(); + return node_allocator_.allocate >(); + } + +#ifndef exprtk_disable_break_continue + inline expression_node_ptr parse_break_statement() + { + if (state_.parsing_break_stmt) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR127 - Break call within a break call is not allowed")); + + return error_node(); + } + + scoped_bool_negator sbn(state_.parsing_break_stmt); + + if (!brkcnt_list_.empty()) { - typedef details::variable_node* variable_node_ptr; - - variable_node_ptr v0 = variable_node_ptr(0); - variable_node_ptr v1 = variable_node_ptr(0); - - if ( - (0 != (v0 = dynamic_cast(branch[0]))) && - (0 != (v1 = dynamic_cast(branch[1]))) - ) - { - return node_allocator_->allocate >(v0,v1); - } - else - return node_allocator_->allocate >(branch[0],branch[1]); + next_token(); + + brkcnt_list_.front() = true; + + expression_node_ptr return_expr = error_node(); + + if (token_is(token_t::e_lsqrbracket)) + { + if (0 == (return_expr = parse_expression())) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR128 - Failed to parse return expression for 'break' statement")); + + return error_node(); + } + else if (!token_is(token_t::e_rsqrbracket)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR129 - Expected ']' at the completion of break's return expression")); + + free_node(node_allocator_,return_expr); + + return error_node(); + } + } + + state_.activate_side_effect("parse_break_statement()"); + + return node_allocator_.allocate >(return_expr); } - else if (v0_is_ivec && v1_is_ivec) + else { - return node_allocator_->allocate >(branch[0],branch[1]); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR130 - Invalid use of 'break', allowed only in the scope of a loop")); } - else if (v0_is_str && v1_is_str) + + return error_node(); + } + + inline expression_node_ptr parse_continue_statement() + { + if (!brkcnt_list_.empty()) { - return node_allocator_->allocate >(branch[0],branch[1]); + next_token(); + + brkcnt_list_.front() = true; + state_.activate_side_effect("parse_continue_statement()"); + + return node_allocator_.allocate >(); } else { - parser_->set_synthesis_error("Only variables, strings, vectors or vector elements can be swapped"); - - return error_node(); - } - } - - #ifndef exprtk_disable_sc_andor - inline expression_node_ptr synthesize_shortcircuit_expression(const details::operator_type& operation, expression_node_ptr (&branch)[2]) - { - expression_node_ptr result = error_node(); - - if (details::is_constant_node(branch[0])) - { - if ( - (details::e_scand == operation) && - std::equal_to()(T(0),branch[0]->value()) - ) - result = node_allocator_->allocate_c(T(0)); - else if ( - (details::e_scor == operation) && - std::not_equal_to()(T(0),branch[0]->value()) - ) - result = node_allocator_->allocate_c(T(1)); + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR131 - Invalid use of 'continue', allowed only in the scope of a loop")); + + return error_node(); } - - if (details::is_constant_node(branch[1]) && (0 == result)) - { - if ( - (details::e_scand == operation) && - std::equal_to()(T(0),branch[1]->value()) - ) - result = node_allocator_->allocate_c(T(0)); - else if ( - (details::e_scor == operation) && - std::not_equal_to()(T(0),branch[1]->value()) - ) - result = node_allocator_->allocate_c(T(1)); + } +#endif + + inline expression_node_ptr parse_define_vector_statement(const std::string& vec_name) + { + expression_node_ptr size_expr = error_node(); + + if (!token_is(token_t::e_lsqrbracket)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR132 - Expected '[' as part of vector size definition")); + + return error_node(); } - - if (result) + else if (0 == (size_expr = parse_expression())) { - free_node(*node_allocator_,branch[0]); - free_node(*node_allocator_,branch[1]); - - return result; + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR133 - Failed to determine size of vector '" + vec_name + "'")); + + return error_node(); } - else if (details::e_scand == operation) - return synthesize_expression(operation,branch); - else if (details::e_scor == operation) - return synthesize_expression(operation,branch); - else - return error_node(); - } - #else - inline expression_node_ptr synthesize_shortcircuit_expression(const details::operator_type&, expression_node_ptr (&)[2]) - { - return error_node(); - } - #endif - - #define basic_opr_switch_statements \ - case_stmt(details::e_add,details::add_op) \ - case_stmt(details::e_sub,details::sub_op) \ - case_stmt(details::e_mul,details::mul_op) \ - case_stmt(details::e_div,details::div_op) \ - case_stmt(details::e_mod,details::mod_op) \ - case_stmt(details::e_pow,details::pow_op) \ - - #define extended_opr_switch_statements \ - case_stmt(details:: e_lt,details:: lt_op) \ - case_stmt(details:: e_lte,details:: lte_op) \ - case_stmt(details:: e_gt,details:: gt_op) \ - case_stmt(details:: e_gte,details:: gte_op) \ - case_stmt(details:: e_eq,details:: eq_op) \ - case_stmt(details:: e_ne,details:: ne_op) \ - case_stmt(details:: e_and,details:: and_op) \ - case_stmt(details::e_nand,details::nand_op) \ - case_stmt(details:: e_or,details:: or_op) \ - case_stmt(details:: e_nor,details:: nor_op) \ - case_stmt(details:: e_xor,details:: xor_op) \ - case_stmt(details::e_xnor,details::xnor_op) \ - - #ifndef exprtk_disable_cardinal_pow_optimisation - template