diff --git a/.github/workflows/make-tests.yml b/.github/workflows/make-tests.yml index 7392253ae4..bbc817b7fe 100644 --- a/.github/workflows/make-tests.yml +++ b/.github/workflows/make-tests.yml @@ -13,6 +13,8 @@ jobs: matrix: java: [11, 21] os: [ubuntu-latest, macos-latest] + #java: [11, 17, 21] + #os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-14, macos-15, macos-26, ubuntu-22.04-arm, ubuntu-24.04-arm, macos-15-intel] runs-on: ${{ matrix.os }} steps: @@ -34,7 +36,15 @@ jobs: strategy: matrix: java: [11, 21] - runs-on: windows-latest + os: [windows-latest] + #java: [11, 17, 21] + #os: [windows-2019, windows-2022, windows-2025] #, windows-11-arm] + #exclude: + #- os: windows-11-arm + #java: 11 + #- os: windows-11-arm + #java: 17 + runs-on: ${{ matrix.os }} steps: - run: git config --global core.autocrlf input diff --git a/prism/Makefile b/prism/Makefile index 8ad48c954f..eb352c5e5b 100644 --- a/prism/Makefile +++ b/prism/Makefile @@ -14,17 +14,32 @@ # If this is a problem, the best solution is to create symlinks. export PRISM_SRC_DIR = src -export PRISM_CLASSES_DIR = classes export PRISM_OBJ_DIR = obj export PRISM_LIB_DIR = lib +export PRISM_BIN_DIR = bin export PRISM_INCLUDE_DIR = include export PRISM_IMAGES_DIR = images export PRISM_DTDS_DIR = dtds -export PRISM_TESTS_DIR = unit-tests + +# Java locations, files + +JAVA_SRC_DIR := src +JAVA_CLASSES_DIR := classes +JAVA_TESTS_SRC_DIR := unit-tests +JAVA_TESTS_CLASSES_DIR := $(JAVA_CLASSES_DIR) + +JAVA_SRC_FILES := $(shell find $(JAVA_SRC_DIR) -name "*.java") +JAVA_SRC_FILES_LIST := $(JAVA_CLASSES_DIR)/java_sources.txt +JAVA_COMPILED_STAMP := $(JAVA_CLASSES_DIR)/java_compiled.stamp +JAVA_PARSER_JJ := $(JAVA_SRC_DIR)/parser/PrismParser.jj +JAVA_PARSER_JAVA := $(JAVA_SRC_DIR)/parser/PrismParser.java +JAVA_TESTS_SRC_FILES := $(shell find $(JAVA_TESTS_SRC_DIR) -name "*.java") +JAVA_TESTS_SRC_FILES_LIST := $(JAVA_TESTS_CLASSES_DIR)/java_tests_sources.txt +JAVA_TESTS_COMPILED_STAMP := $(JAVA_TESTS_CLASSES_DIR)/java_tests_compiled.stamp # Location of CUDD (used to be variable; now mainly fixed with the git repo layout) -CUDD_DIR = ../cudd +CUDD_DIR := ../cudd #################### # Operating system # @@ -41,37 +56,46 @@ CUDD_DIR = ../cudd #OSTYPE = cygwin #OSTYPE = darwin -ifdef OSTYPE +ifneq ($(OSTYPE),) # Look for common variants, e.g. gnu-linux -> linux ifneq (,$(findstring linux, $(OSTYPE))) - OSTYPE = linux + OSTYPE := linux endif ifneq (,$(findstring solaris, $(OSTYPE))) - OSTYPE = solaris + OSTYPE := solaris endif ifneq (,$(findstring cygwin, $(OSTYPE))) - OSTYPE = cygwin + OSTYPE := cygwin endif # For Cygwin , OSTYPE is sometimes set to "posix" ifneq (,$(findstring posix, $(OSTYPE))) - OSTYPE = cygwin + OSTYPE := cygwin endif ifneq (,$(findstring darwin, $(OSTYPE))) - OSTYPE = darwin + OSTYPE := darwin endif else - # If OSTYPE is not defined/available, try uname - ifneq (,$(findstring Linux, $(shell uname -s))) - OSTYPE = linux - endif - ifneq (,$(findstring SunOS, $(shell uname -s))) - OSTYPE = solaris - endif - ifneq (,$(findstring CYGWIN, $(shell uname -s))) - OSTYPE = cygwin - endif - ifneq (,$(findstring Darwin, $(shell uname -s))) - OSTYPE = darwin + # If OSTYPE is not defined/available, + # First try OS (on Windows), otherwise try uname + ifeq ($(OS),Windows_NT) + OSTYPE := cygwin + else + UNAME_STR := $(shell uname -s 2>/dev/null || echo unknown) + ifneq (,$(findstring Linux, $(UNAME_STR))) + OSTYPE := linux + endif + ifneq (,$(findstring SunOS, $(UNAME_STR))) + OSTYPE := solaris + endif + ifneq (,$(findstring CYGWIN, $(UNAME_STR))) + OSTYPE := cygwin + endif + ifneq (,$(findstring MINGW, $(UNAME_STR))) + OSTYPE := cygwin + endif + ifneq (,$(findstring Darwin, $(UNAME_STR))) + OSTYPE := darwin + endif endif endif @@ -82,37 +106,37 @@ endif # For Linux/Mac, we use uname to check the architecture ifeq ($(OSTYPE),linux) ifneq (,$(findstring 86_64, $(shell uname -m))) - ARCH = amd64 + ARCH := amd64 endif ifneq (,$(findstring ia64, $(shell uname -m))) - ARCH = ia64 + ARCH := ia64 endif ifneq (,$(findstring aarch64, $(shell uname -m))) - ARCH = aarch64 + ARCH := aarch64 endif endif ifeq ($(OSTYPE),darwin) ifneq (,$(findstring x86_64, $(shell uname -m))) - ARCH = x86_64 + ARCH := x86_64 endif ifneq (,$(findstring arm64, $(shell uname -m))) - ARCH = arm64 + ARCH := arm64 endif endif # For Windows, we decide whether to build in 64-bit mode based on # whether java is 32/64-bit (since these need to match) ifeq ($(OSTYPE),cygwin) # Default to 64-bit, which is most likely these days - ARCH = x86_64 + ARCH := x86_64 ifeq ($(shell which java 2>/dev/null),) $(error "Could not find java executable. Please install Java or add it to your PATH.") endif JAVA_VERSION_STRING := $(shell java -version 2>&1) ifneq (,$(findstring 32-bit, $(JAVA_VERSION_STRING))) - ARCH = + ARCH := endif ifneq (,$(findstring Client VM, $(JAVA_VERSION_STRING))) - ARCH = + ARCH := endif endif @@ -141,13 +165,13 @@ DETECT_JAVAC = $(shell $(PRISM_SRC_DIR)/scripts/findjavac.sh 2> /dev/null) # Find directory containing javac ifeq ("$(DETECT_JAVAC)","") - JAVA_DIR = + JAVA_DIR := else - JAVA_DIR = $(shell dirname "$(DETECT_JAVAC)" | sed -e 's/\/bin//' -e 's/\/Commands//') + JAVA_DIR := $(shell dirname "$(DETECT_JAVAC)" | sed -e 's/\/bin//' -e 's/\/Commands//') endif # As a backup way of detecting JAVA_DIR, run java_home -JAVA_DIR_BACKUP = $(shell \ +JAVA_DIR_BACKUP := $(shell \ if [ -f /usr/libexec/java_home ]; then /usr/libexec/java_home; \ else echo ""; fi ) @@ -159,14 +183,14 @@ JAVA_DIR_BACKUP = $(shell \ # Now we locate the JNI header files jni.h and jni_md.h # (in fact this is the only reason we need JAVA_DIR) -JAVA_JNI_H_DIR = $(shell \ +JAVA_JNI_H_DIR := $(shell \ if [ -f "$(JAVA_DIR)"/include/jni.h ]; then echo "$(JAVA_DIR)"/include; \ elif [ -f "$(JAVA_DIR)"/Headers/jni.h ]; then echo "$(JAVA_DIR)"/Headers; \ elif [ -f "$(JAVA_DIR_BACKUP)"/include/jni.h ]; then echo "$(JAVA_DIR_BACKUP)"/include; \ elif [ -f "$(JAVA_DIR_BACKUP)"/Headers/jni.h ]; then echo "$(JAVA_DIR_BACKUP)"/Headers; \ else echo ""; fi ) -JAVA_JNI_MD_H_DIR = $(shell (ls "$(JAVA_JNI_H_DIR)"/jni_md.h "$(JAVA_JNI_H_DIR)"/*/jni_md.h | head -n 1 | sed 's/\/jni_md.h//') 2>/dev/null) -JAVA_INCLUDES = -I $(JAVA_JNI_H_DIR) -I $(JAVA_JNI_MD_H_DIR) +JAVA_JNI_MD_H_DIR := $(shell (ls "$(JAVA_JNI_H_DIR)"/jni_md.h "$(JAVA_JNI_H_DIR)"/*/jni_md.h | head -n 1 | sed 's/\/jni_md.h//') 2>/dev/null) +JAVA_INCLUDES := -I $(JAVA_JNI_H_DIR) -I $(JAVA_JNI_MD_H_DIR) ################## # Compilers etc. # @@ -174,21 +198,21 @@ JAVA_INCLUDES = -I $(JAVA_JNI_H_DIR) -I $(JAVA_JNI_MD_H_DIR) ifeq ($(OSTYPE),cygwin) ifeq ($(ARCH),x86_64) - CC = /usr/bin/x86_64-w64-mingw32-gcc - CXX = /usr/bin/x86_64-w64-mingw32-g++ + CC := /usr/bin/x86_64-w64-mingw32-gcc + CXX := /usr/bin/x86_64-w64-mingw32-g++ else - CC = /usr/bin/i686-w64-mingw32-gcc - CXX = /usr/bin/i686-w64-mingw32-g++ + CC := /usr/bin/i686-w64-mingw32-gcc + CXX := /usr/bin/i686-w64-mingw32-g++ endif - JAVACC = javacc.bat + JAVACC := javacc.bat else - CC = gcc - CXX = g++ - JAVACC = javacc + CC := gcc + CXX := g++ + JAVACC := javacc endif -LD = $(CXX) -JAVAC = javac -JAVA = java +LD := $(CXX) +JAVAC := javac +JAVA := java export CC CXX LD JAVAC JAVACC @@ -198,17 +222,17 @@ export CC CXX LD JAVAC JAVACC # Tell compiler to generate debug information? # (WARNING: must not contain a % symbol!) -DEBUG = -#DEBUG = -g +DEBUG := +#DEBUG := -g # Compiler optimisation level: # (WARNING: must not contain a % symbol!) -OPTIMISE = -O3 -#OPTIMISE = +OPTIMISE := -O3 +#OPTIMISE := # Compiler warnings to enable: # (WARNING: must not contain a % symbol!) -WARNINGS = #-Wformat +WARNINGS := #-Wformat # Flags for compilation/linking # Flags to generate shared libraries @@ -220,62 +244,62 @@ WARNINGS = #-Wformat ifeq ($(OSTYPE),linux) ifeq ($(ARCH),amd64) # Position Independent Code required on AMD64/Itanium - CFLAGS = -m64 -fPIC -DPIC $(DEBUG) $(OPTIMISE) $(WARNINGS) - CXXFLAGS = --std=c++11 $(CFLAGS) - LDFLAGS = - BINDISTSUFFIX = linux64 - BINDISTARCH = x86 + CFLAGS := -m64 -fPIC -DPIC $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS := --std=c++11 $(CFLAGS) + LDFLAGS := + BINDISTSUFFIX := linux64 + BINDISTARCH := x86 else ifeq ($(ARCH),ia64) # Position Independent Code required on AMD64/Itanium # Note: We omit the -m64 flag from here since it seems to be unsupported by gcc on IA64 - CFLAGS = -fPIC -DPIC $(DEBUG) $(OPTIMISE) $(WARNINGS) - CXXFLAGS = --std=c++11 $(CFLAGS) - LDFLAGS = - BINDISTSUFFIX = linux64 - BINDISTARCH = ia64 + CFLAGS := -fPIC -DPIC $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS := --std=c++11 $(CFLAGS) + LDFLAGS := + BINDISTSUFFIX := linux64 + BINDISTARCH := ia64 else ifeq ($(ARCH),aarch64) # Position Independent Code required on Aarch64 - CFLAGS = -fPIC -DPIC $(DEBUG) $(OPTIMISE) $(WARNINGS) - CXXFLAGS = --std=c++11 $(CFLAGS) - LDFLAGS = - BINDISTSUFFIX = linux64 - BINDISTARCH = arm + CFLAGS := -fPIC -DPIC $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS := --std=c++11 $(CFLAGS) + LDFLAGS := + BINDISTSUFFIX := linux64 + BINDISTARCH := arm else - CFLAGS = -m32 $(DEBUG) $(OPTIMISE) $(WARNINGS) - CXXFLAGS = --std=c++11 $(CFLAGS) - LDFLAGS = - BINDISTSUFFIX = linux32 - BINDISTARCH = x86 + CFLAGS := -m32 $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS := --std=c++11 $(CFLAGS) + LDFLAGS := + BINDISTSUFFIX := linux32 + BINDISTARCH := x86 endif endif endif - BIN_TARGETS=prism.linux xprism.linux + BIN_TARGETS := prism.linux xprism.linux JFLAGS := -encoding UTF8 - SHARED = -shared - #SHARED = -G - EXE = - LIBPREFIX = lib - LIBSUFFIX = .so - LIBMATH = -lm - CLASSPATHSEP = : + SHARED := -shared + #SHARED := -G + EXE := + LIBPREFIX := lib + LIBSUFFIX := .so + LIBMATH := -lm + CLASSPATHSEP := : endif # Solaris ifeq ($(OSTYPE),solaris) - CFLAGS = -mcpu=ultrasparc $(DEBUG) $(OPTIMISE) $(WARNINGS) - CXXFLAGS = --std=c++11 $(CFLAGS) - LDFLAGS = - BINDISTSUFFIX = solaris - BINDISTARCH = solaris - BIN_TARGETS=prism.linux xprism.linux + CFLAGS := -mcpu=ultrasparc $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS := --std=c++11 $(CFLAGS) + LDFLAGS := + BINDISTSUFFIX := solaris + BINDISTARCH := solaris + BIN_TARGETS := prism.linux xprism.linux JFLAGS := -encoding UTF8 - SHARED = -shared -mimpure-text - EXE = - LIBPREFIX = lib - LIBSUFFIX = .so - LIBMATH = -lm - CLASSPATHSEP = : + SHARED := -shared -mimpure-text + EXE := + LIBPREFIX := lib + LIBSUFFIX := .so + LIBMATH := -lm + CLASSPATHSEP := : endif # Cygwin ifeq ($(OSTYPE),cygwin) @@ -284,61 +308,61 @@ ifeq ($(OSTYPE),cygwin) # -Wl,--add-stdcall-alias needed so shared libraries can be read from JNI # -Wl ... -lpthread ... --no-whole-archive needed to statically include pthread in case missing ifeq ($(ARCH),x86_64) - CFLAGS = $(DEBUG) $(OPTIMISE) $(WARNINGS) - CXXFLAGS = --std=c++11 -DWIN32 $(CFLAGS) - LDFLAGS = -static-libgcc -static-libstdc++ -Wl,--add-stdcall-alias -Wl,-Bstatic,--whole-archive -lpthread -Wl,-Bdynamic,--no-whole-archive - BINDISTSUFFIX = win64 - BINDISTARCH = x86 + CFLAGS := $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS := --std=c++11 -DWIN32 $(CFLAGS) + LDFLAGS := -static-libgcc -static-libstdc++ -Wl,--add-stdcall-alias -Wl,-Bstatic,--whole-archive -lpthread -Wl,-Bdynamic,--no-whole-archive + BINDISTSUFFIX := win64 + BINDISTARCH := x86 else - CFLAGS = -march=i686 $(DEBUG) $(OPTIMISE) $(WARNINGS) - CXXFLAGS = --std=c++11 -DWIN32 $(CFLAGS) - LDFLAGS = -static-libgcc -static-libstdc++ -Wl,--add-stdcall-alias -Wl,-Bstatic,--whole-archive -lpthread -Wl,-Bdynamic,--no-whole-archive - BINDISTSUFFIX = win32 - BINDISTARCH = x86 + CFLAGS := -march=i686 $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS := --std=c++11 -DWIN32 $(CFLAGS) + LDFLAGS := -static-libgcc -static-libstdc++ -Wl,--add-stdcall-alias -Wl,-Bstatic,--whole-archive -lpthread -Wl,-Bdynamic,--no-whole-archive + BINDISTSUFFIX := win32 + BINDISTARCH := x86 endif - BIN_TARGETS=prism.cygwin xprism.linux prism.bat.win xprism.bat.win + BIN_TARGETS := prism.cygwin xprism.linux prism.bat.win xprism.bat.win JFLAGS := -encoding UTF8 - SHARED = -shared - #SHARED = -G - EXE = .exe - LIBPREFIX = - LIBSUFFIX = .dll - LIBMATH = - CLASSPATHSEP = ; + SHARED := -shared + #SHARED := -G + EXE := .exe + LIBPREFIX := + LIBSUFFIX := .dll + LIBMATH := + CLASSPATHSEP := ; endif # Darwin ifeq ($(OSTYPE),darwin) ifeq ($(ARCH),x86_64) - CFLAGS = -arch x86_64 -fPIC -DPIC $(DEBUG) $(OPTIMISE) $(WARNINGS) - CXXFLAGS = --std=c++11 $(CFLAGS) - LDFLAGS = -arch x86_64 -Wl,-search_paths_first - BINDISTSUFFIX = mac64 - BINDISTARCH = x86 - BIN_TARGETS=prism.darwin xprism.linux + CFLAGS := -arch x86_64 -fPIC -DPIC $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS := --std=c++11 $(CFLAGS) + LDFLAGS := -arch x86_64 -Wl,-search_paths_first + BINDISTSUFFIX := mac64 + BINDISTARCH := x86 + BIN_TARGETS := prism.darwin xprism.linux else ifeq ($(ARCH),arm64) - CFLAGS = -arch arm64 -fPIC -DPIC $(DEBUG) $(OPTIMISE) $(WARNINGS) - CXXFLAGS = --std=c++11 $(CFLAGS) - LDFLAGS = -arch arm64 -Wl,-search_paths_first - BINDISTSUFFIX = mac64 - BINDISTARCH = arm - BIN_TARGETS=prism.darwin xprism.linux + CFLAGS := -arch arm64 -fPIC -DPIC $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS := --std=c++11 $(CFLAGS) + LDFLAGS := -arch arm64 -Wl,-search_paths_first + BINDISTSUFFIX := mac64 + BINDISTARCH := arm + BIN_TARGETS := prism.darwin xprism.linux else - CFLAGS = -arch i386 $(DEBUG) $(OPTIMISE) $(WARNINGS) - CXXFLAGS = --std=c++11 $(CFLAGS) - LDFLAGS = -arch i386 -Wl,-search_paths_first - BINDISTSUFFIX = mac32 - BINDISTARCH = x86 - BIN_TARGETS=prism.darwin xprism.linux + CFLAGS := -arch i386 $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS := --std=c++11 $(CFLAGS) + LDFLAGS := -arch i386 -Wl,-search_paths_first + BINDISTSUFFIX := mac32 + BINDISTARCH := x86 + BIN_TARGETS := prism.darwin xprism.linux endif endif JFLAGS := -encoding UTF8 - SHARED = -dynamiclib - EXE = - LIBPREFIX = lib - LIBSUFFIX = .dylib - LIBMATH = -lm - CLASSPATHSEP = : + SHARED := -dynamiclib + EXE := + LIBPREFIX := lib + LIBSUFFIX := .dylib + LIBMATH := -lm + CLASSPATHSEP := : endif # Java flags @@ -350,9 +374,7 @@ export CFLAGS CXXFLAGS LDFLAGS JFLAGS LIBPREFIX LIBSUFFIX # Main part of Makefile: Compiling PRISM # ########################################## -MAKE_DIRS = dd jdd odd dv prism mtbdd sparse hybrid parser settings userinterface pepa/compiler simulator jltl2ba jltl2dstar explicit pta param strat automata common cex - -EXT_PACKAGES = lpsolve55 lp_solve_5.5_java +EXT_PACKAGES := lpsolve55 lp_solve_5.5_java .PHONY: clean javadoc tests release @@ -371,14 +393,6 @@ cuddpackage: checks @echo Making cudd ...; cd $(CUDD_DIR) && \ LD= LDFLAGS= ./install.sh -# Use this to force a rebuild (with javacc) of the main parser -parser: - @echo Making parser ...; \ - cd $(PRISM_SRC_DIR)/parser && \ - $(MAKE) touch && \ - $(MAKE) \ - CLASSPATHSEP="$(CLASSPATHSEP)" - # Build various external libraries needed by PRISM extpackages: checks @for ext in $(EXT_PACKAGES); do \ @@ -399,25 +413,30 @@ extpackages: checks # Compile main PRISM code # (we also do some preparatory checks, and build launch scripts afterwards) -prism: checks make_dirs bin_scripts - -# Compile each (top-level) source directory separately -make_dirs: - @mkdir -p bin $(PRISM_CLASSES_DIR) $(PRISM_OBJ_DIR)/dd $(PRISM_OBJ_DIR)/jdd $(PRISM_OBJ_DIR)/odd $(PRISM_OBJ_DIR)/dv $(PRISM_OBJ_DIR)/prism $(PRISM_OBJ_DIR)/mtbdd $(PRISM_OBJ_DIR)/sparse $(PRISM_OBJ_DIR)/hybrid $(PRISM_OBJ_DIR)/simulator - @for dir in $(MAKE_DIRS); do \ - echo Making $(PRISM_SRC_DIR)/$$dir ...; \ - (cd $(PRISM_SRC_DIR)/$$dir && \ - $(MAKE) \ - CUDD_DIR="$(CUDD_DIR)" \ - JAVA_INCLUDES="$(JAVA_INCLUDES)" \ - JAVA_JNI_H_DIR="$(JAVA_JNI_H_DIR)" \ - JAVA_JNI_MD_H_DIR="$(JAVA_JNI_MD_H_DIR)" \ - SHARED="$(SHARED)" \ - EXE="$(EXE)" \ - LIBMATH="$(LIBMATH)" \ - CLASSPATHSEP="$(CLASSPATHSEP)") \ - || exit 1; \ - done +prism: checks prism_java prism_lib prism_ng bin_scripts + +# Compile all Java code, build JNI headers +prism_java: $(JAVA_COMPILED_STAMP) + +$(JAVA_COMPILED_STAMP): $(JAVA_SRC_FILES) + @mkdir -p $(JAVA_CLASSES_DIR) $(PRISM_INCLUDE_DIR)/jni + @find $(JAVA_SRC_DIR) -name "*.java" > $(JAVA_SRC_FILES_LIST) + @echo "Compiling Java files..." + $(JAVAC) $(JFLAGS) -classpath "$(PRISM_LIB_DIR)/*" -d $(JAVA_CLASSES_DIR) -h $(PRISM_INCLUDE_DIR)/jni @$(JAVA_SRC_FILES_LIST) + @touch $@ + +# Rebuild PRISM (JavaCC) compiler if needed +# Just emit warning if javacc not available and fall back to pre-compiled .java +$(JAVA_PARSER_JAVA): $(JAVA_PARSER_JJ) + @$(JAVACC) $< || echo "Warning: Did not recompile $@" + +# Use this to force a rebuild (with javacc) of the main parser +parser: parser_force prism_java + +parser_force: + @ echo "Forcing parser rebuild" + @$(JAVACC) $(JAVA_PARSER_JJ) + # On Windows, convert the generated JNI headers using dos2unix # and any scripts to be run from Cywgin, in case extracted with CRLF endings. @if [ "$(OSTYPE)" = "cygwin" ]; then \ @@ -426,23 +445,79 @@ make_dirs: dos2unix "$(PRISM_SRC_DIR)"/bin/prism.cygwin; \ fi -# Compile unit tests -make_tests: - @echo Making $(PRISM_TESTS_DIR) ...; \ - (cd $(PRISM_TESTS_DIR) && \ - $(MAKE) \ - CLASSPATHSEP="$(CLASSPATHSEP)") \ - || exit 1; +PRISM_LIB_DIRS := dd jdd odd dv prism mtbdd sparse hybrid + +PRISM_LIB_EXCLUDE_FILES := $(PRISM_SRC_DIR)/dd/dd_test.cc +PRISM_LIB_ALL_SRC_FILES := $(shell find $(foreach d,$(PRISM_LIB_DIRS),$(PRISM_SRC_DIR)/$(d)) -name "*.cc") +PRISM_LIB_SRC_FILES := $(filter-out $(PRISM_LIB_EXCLUDE_FILES), $(PRISM_LIB_ALL_SRC_FILES)) +PRISM_LIB_OBJ_FILES := $(patsubst $(PRISM_SRC_DIR)/%.cc, $(PRISM_OBJ_DIR)/%.o, $(PRISM_LIB_SRC_FILES)) + +OLD_SHARED_LIBS := dd jdd odd dv prismmtbdd prismsparse prismhybrid +OLD_SHARED_LIB_FILES := $(patsubst %, $(PRISM_LIB_DIR)/$(LIBPREFIX)%$(LIBSUFFIX), $(OLD_SHARED_LIBS)) + +INCLUDES := \ +-I$(CUDD_DIR)/include \ +-I"$(JAVA_JNI_H_DIR)" \ +-I"$(JAVA_JNI_MD_H_DIR)" \ +-I$(PRISM_INCLUDE_DIR) \ +-Iext/lpsolve55/include + +LIBRARIES := \ +-L$(PRISM_LIB_DIR) \ +-L$(CUDD_DIR)/lib \ +-lcudd \ +$(LIBMATH) \ +-llpsolve55 + +# Setup RPATH. Use = here (not :=) so $@ is evaluated inside the recipe scope +RPATH_LINUX = -Wl,-soname,$(notdir $@) -Wl,-rpath,'$$ORIGIN' +RPATH_DARWIN = -Wl,-install_name,@rpath/$(notdir $@) -Wl,-rpath,@loader_path/. +# Then pick the right one based on OSTYPE +$(PRISM_LIB_DIR)/$(LIBPREFIX)prism$(LIBSUFFIX): RPATH_SETTING = \ + $(if $(filter linux,$(OSTYPE)),$(RPATH_LINUX), \ + $(if $(filter darwin,$(OSTYPE)),$(RPATH_DARWIN),)) + +# Compile the main native shared library +prism_lib: prism_java $(PRISM_LIB_DIR)/$(LIBPREFIX)prism$(LIBSUFFIX) + +$(PRISM_LIB_DIR)/$(LIBPREFIX)prism$(LIBSUFFIX): $(PRISM_LIB_OBJ_FILES) + @echo "Linking shared library $@..." + $(LD) $(SHARED) $(LDFLAGS) $(RPATH_SETTING) -o $@ $^ $(LIBRARIES) + +$(PRISM_OBJ_DIR)/%.o: $(PRISM_SRC_DIR)/%.cc + @mkdir -p $(dir $@) + $(CXX) $(CXXFLAGS) -c $< -o $@ -I$(PRISM_INCLUDE_DIR)/jni $(INCLUDES) + +# Compile ngprism +# (on Windows, link winsocket library, ws2_32) +prism_ng: $(PRISM_OBJ_DIR)/prism/ngprism$(EXE) + +$(PRISM_OBJ_DIR)/prism/ngprism$(EXE): $(PRISM_SRC_DIR)/prism/ngprism.c + @echo "Bilding $@..." + @if [ "$(EXE)" = "" ]; then \ + $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<; \ + else \ + $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< -lws2_32; \ + fi; + +# Compile (Java) unit tests +$(JAVA_TESTS_COMPILED_STAMP): $(JAVA_TESTS_SRC_FILES) + @mkdir -p $(JAVA_TESTS_CLASSES_DIR) + @find $(JAVA_TESTS_SRC_DIR) -name "*.java" > $(JAVA_TESTS_SRC_FILES_LIST) + @echo "Compiling Java unit tests..." + $(JAVAC) $(JFLAGS) -sourcepath $(JAVA_SRC_DIR) -classpath $(PRISM_CLASSPATH) -d $(JAVA_TESTS_CLASSES_DIR) -h $(PRISM_INCLUDE_DIR)/jni @$(JAVA_TESTS_SRC_FILES_LIST) + @touch $@ # Copy/modify the launch scripts and put in the bin directory bin_scripts: + @mkdir -p $(PRISM_BIN_DIR) @for target in $(BIN_TARGETS); do \ target_trunc=`echo $$target | sed 's/\.[^.]*$$//'` && \ - echo Copying "$(PRISM_SRC_DIR)/bin/$$target -> bin/$$target_trunc" && \ - cp $(PRISM_SRC_DIR)/bin/$$target bin/$$target_trunc; \ + echo Copying "$(PRISM_SRC_DIR)/bin/$$target -> $(PRISM_BIN_DIR)/$$target_trunc" && \ + cp $(PRISM_SRC_DIR)/bin/$$target "$(PRISM_BIN_DIR)/$$target_trunc"; \ done; - @echo Copying "$(PRISM_OBJ_DIR)/prism/ngprism$(EXE) -> bin/ngprism$(EXE)" && \ - cp $(PRISM_OBJ_DIR)/prism/ngprism$(EXE) bin/ngprism$(EXE) + @echo Copying "$(PRISM_OBJ_DIR)/prism/ngprism$(EXE) -> $(PRISM_BIN_DIR)/ngprism$(EXE)" && \ + cp $(PRISM_OBJ_DIR)/prism/ngprism$(EXE) $(PRISM_BIN_DIR)/ngprism$(EXE) @./install.sh silent # Some checks to make sure that the main settings are valid @@ -505,7 +580,7 @@ checks: # Misc: count the number of lines of code count_loc: - find $(PRISM_SRC_DIR) -name '*.java' -o -name '*.cc' | xargs wc -l + find $(PRISM_SRC_DIR) $(JAVA_SRC_DIR) -name '*.java' -o -name '*.cc' | xargs wc -l ########### # Testing # @@ -513,23 +588,23 @@ count_loc: # Run all unit tests JUNIT_JAR = $(wildcard $(PRISM_LIB_DIR)/junit-platform-console-standalone*.jar) -unittests: make_tests +unittests: $(JAVA_TESTS_COMPILED_STAMP) # Provide Regex to match our test classes. If none is given, only certain test classes are excluded by default. $(JAVA) -jar $(JUNIT_JAR) -cp classes --include-classname '^(Test.*|.+[.$$]Test.*|.+Tests?[.$$].+|.*Tests?)$$' -scan-classpath --details=summary # Run a single test case from the test suite (useful quick check that the build was ok) test: - bin/prism etc/tests/dtmc_pctl.prism etc/tests/dtmc_pctl.prism.props -h -test + $(PRISM_BIN_DIR)/prism etc/tests/dtmc_pctl.prism etc/tests/dtmc_pctl.prism.props -h -test # Run a single test case from the test suite that relies on lpsolve being properly installed testlpsolve: - bin/prism etc/tests/test_lpsolve_mdpmo.prism etc/tests/test_lpsolve_mdpmo.prism.props -lp -test + $(PRISM_BIN_DIR)/prism etc/tests/test_lpsolve_mdpmo.prism etc/tests/test_lpsolve_mdpmo.prism.props -lp -test # Run all tests from the test suite (in ../prism-tests and ./tests) # Optionally, extra arguments for prism-auto are picked up via variable TESTS_ARGS tests: testslocal @if [ -d ../prism-tests ]; then \ - etc/scripts/prism-auto -t -m ../prism-tests -p bin/prism --print-failures --nailgun --ngprism bin/ngprism $(TESTS_ARGS); \ + etc/scripts/prism-auto -t -m ../prism-tests -p $(PRISM_BIN_DIR)/prism --print-failures --nailgun --ngprism $(PRISM_BIN_DIR)/ngprism $(TESTS_ARGS); \ else \ echo "Skipping tests"; \ fi @@ -537,13 +612,13 @@ tests: testslocal # Just display the command to run the test suite on this version of PRISM # Optionally, extra arguments for prism-auto are picked up via variable TESTS_ARGS testsecho: - @echo etc/scripts/prism-auto -t -m ../prism-tests -p bin/prism --print-failures --nailgun --ngprism bin/ngprism $(TESTS_ARGS) + @echo etc/scripts/prism-auto -t -m ../prism-tests -p $(PRISM_BIN_DIR)/prism --print-failures --nailgun --ngprism $(PRISM_BIN_DIR)/ngprism $(TESTS_ARGS) # Run local tests (in ./tests) # Optionally, extra arguments for prism-auto are picked up via variable TESTS_ARGS testslocal: @if [ -d tests ]; then \ - etc/scripts/prism-auto -t -m tests -p bin/prism --print-failures --nailgun --ngprism bin/ngprism $(TESTS_ARGS); \ + etc/scripts/prism-auto -t -m tests -p $(PRISM_BIN_DIR)/prism --print-failures --nailgun --ngprism $(PRISM_BIN_DIR)/ngprism $(TESTS_ARGS); \ else \ echo "Skipping local tests"; \ fi @@ -556,7 +631,7 @@ testslocal: testsfull: etc/scripts/prism-auto -t -m ../prism-tests \ --skip-export-runs --skip-duplicate-runs --test-all -a ../prism-tests/all-engines.args --timeout 1m \ - -p bin/prism --print-failures --nailgun $(TESTS_ARGS); + -p $(PRISM_BIN_DIR)/prism --print-failures --nailgun $(TESTS_ARGS); ########################## # Building distributions # @@ -565,18 +640,18 @@ testsfull: # Build prism.jar binary: @echo "Generating JAR file ($(PRISM_LIB_DIR)/prism.jar)..." - @jar cmf $(PRISM_SRC_DIR)/manifest.txt $(PRISM_LIB_DIR)/prism.jar -C $(PRISM_CLASSES_DIR) . -C . $(PRISM_IMAGES_DIR) $(PRISM_DTDS_DIR) + @jar cmf $(JAVA_SRC_DIR)/manifest.txt $(PRISM_LIB_DIR)/prism.jar -C $(JAVA_CLASSES_DIR) . -C . $(PRISM_IMAGES_DIR) $(PRISM_DTDS_DIR) # Build prism-sources.jar source-jar: @echo "Generating sources JAR file ($(PRISM_LIB_DIR)/prism-sources.jar)..." - @find $(PRISM_SRC_DIR) -type f -name '*.java' -o -name '*.form' -o -name '*.jj' | sed -e "s/^$(PRISM_SRC_DIR)./-C $(PRISM_SRC_DIR) /" > prism-sources.txt + @find $(JAVA_SRC_DIR) -type f -name '*.java' -o -name '*.form' -o -name '*.jj' | sed -e "s/^$(JAVA_SRC_DIR)./-C $(JAVA_SRC_DIR) /" > prism-sources.txt @jar cf $(PRISM_LIB_DIR)/prism-sources.jar @prism-sources.txt @rm -f prism-sources.txt # Download a local html copy of the manual -#PRISM_MANUAL_WEBSITE = http://prismmodelchecker.localhost/manual/ -PRISM_MANUAL_WEBSITE = http://www.prismmodelchecker.org/manual/ +#PRISM_MANUAL_WEBSITE := http://prismmodelchecker.localhost/manual/ +PRISM_MANUAL_WEBSITE := http://www.prismmodelchecker.org/manual/ doc: clean_doc (cd .. && wget -r -np -k -E -nH --no-cookies --header "Cookie: setskin=offline" --restrict-file-names=windows --reject '*action=sourceblock*' $(PRISM_MANUAL_WEBSITE) $(PRISM_MANUAL_WEBSITE)/pub/skins/offline/images/) clean_doc: @@ -636,10 +711,18 @@ build_release_source: # Build Javadoc (and put in javadoc directory) -PRISM_CLASSPATH = "$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(PRISM_LIB_DIR)/*" +PRISM_CLASSPATH := "$(JAVA_CLASSES_DIR)$(CLASSPATHSEP)$(PRISM_LIB_DIR)/*" + +PRISM_JAVADOC_DIR := javadoc -javadoc: - @JAVADOC_DIRS=`echo $(MAKE_DIRS) | sed 's/\//./g' | sed 's/ /:/g'` && \mkdir -p javadoc; javadoc $(JFLAGS) -d javadoc -overview $(PRISM_SRC_DIR)/overview.html -sourcepath $(PRISM_SRC_DIR) -classpath $(PRISM_SRC_DIR)$(CLASSPATHSEP)$(PRISM_CLASSPATH) -subpackages $$JAVADOC_DIRS -exclude parser +javadoc: prism_java + @mkdir -p $(PRISM_JAVADOC_DIR) + @echo "Generating Javadoc..." + javadoc -d $(PRISM_JAVADOC_DIR) \ + -classpath $(PRISM_CLASSPATH) \ + -quiet \ + -Xdoclint:none \ + @$(JAVA_SRC_FILES_LIST) ############### # Cleaning up # @@ -647,22 +730,22 @@ javadoc: # Clean main PRISM build (not CUDD or external libs) clean: checks - @(for dir in $(MAKE_DIRS); do \ - echo Cleaning $(PRISM_SRC_DIR)/$$dir ...; \ - (cd $(PRISM_SRC_DIR)/$$dir && \ - $(MAKE) -s EXE="$(EXE)" clean) \ - || exit 1; \ - done; \ - find $(PRISM_CLASSES_DIR) -name '*.class' -exec rm {} \; ; \ - rm -f $(PRISM_LIB_DIR)/*jnilib; \ - rm -f $(PRISM_LIB_DIR)/prism.jar; \ - rm -f $(PRISM_LIB_DIR)/prism-sources.jar; \ - rm -f $(BIN_PRISM) $(BIN_XPRISM) $(BIN_PRISM_BAT) $(BIN_XPRISM_BAT) ) + rm -rf $(JAVA_CLASSES_DIR) + rm -f $(JAVA_SRC_FILES_LIST) $(JAVA_COMPILED_STAMP) + rm -f $(JAVA_TESTS_SRC_FILES_LIST) $(JAVA_TESTS_COMPILED_STAMP) + rm -rf $(PRISM_OBJ_DIR) + rm -f $(PRISM_LIB_DIR)/$(LIBPREFIX)prism$(LIBSUFFIX) + rm -f $(OLD_SHARED_LIB_FILES) + rm -f $(PRISM_INCLUDE_DIR)/jni/*.h + rm -f $(PRISM_LIB_DIR)/*jnilib + rm -f $(PRISM_LIB_DIR)/prism.jar + rm -f $(PRISM_LIB_DIR)/prism-sources.jar + rm -f $(addprefix $(PRISM_BIN_DIR)/, $(notdir $(basename $(BIN_TARGETS)))) $(PRISM_BIN_DIR)/ngprism$(EXE) celan: clean # Clean PRISM + CUDD and external libs -clean_all: checks clean_cudd clean_ext clean clean_tests +clean_all: checks clean_cudd clean_ext clean clean_cudd: @(cd $(CUDD_DIR) && ./clean.sh) @@ -675,50 +758,11 @@ clean_ext: || exit 1; \ done ) -clean_tests: - @(cd $(PRISM_TESTS_DIR) && $(MAKE) clean) - # Remove just the prism.jar binary clean_binary: @echo "Removing JAR file ($(PRISM_LIB_DIR)/prism.jar)..." @rm -f $(PRISM_LIB_DIR)/prism.jar -# Clear individual directories (sometimes useful) -clean_dd: checks - @(cd $(PRISM_SRC_DIR)/dd && $(MAKE) -s EXE="$(EXE)" clean) -clean_jdd: checks - @(cd $(PRISM_SRC_DIR)/jdd && $(MAKE) -s EXE="$(EXE)" clean) -clean_odd: checks - @(cd $(PRISM_SRC_DIR)/odd && $(MAKE) -s EXE="$(EXE)" clean) -clean_dv: checks - @(cd $(PRISM_SRC_DIR)/dv && $(MAKE) -s EXE="$(EXE)" clean) -clean_prism: checks - @(cd $(PRISM_SRC_DIR)/prism && $(MAKE) -s EXE="$(EXE)" clean) -clean_mtbdd: checks - @(cd $(PRISM_SRC_DIR)/mtbdd && $(MAKE) -s EXE="$(EXE)" clean) -clean_sparse: checks - @(cd $(PRISM_SRC_DIR)/sparse && $(MAKE) -s EXE="$(EXE)" clean) -clean_hybrid: checks - @(cd $(PRISM_SRC_DIR)/hybrid && $(MAKE) -s EXE="$(EXE)" clean) -clean_parser: checks - @(cd $(PRISM_SRC_DIR)/parser && $(MAKE) -s EXE="$(EXE)" clean) -clean_userinterface: checks - @(cd $(PRISM_SRC_DIR)/userinterface && $(MAKE) -s EXE="$(EXE)" clean) -clean_simulator: checks - @(cd $(PRISM_SRC_DIR)/simulator && $(MAKE) -s EXE="$(EXE)" clean) -clean_jltl2ba: checks - @(cd $(PRISM_SRC_DIR)/jltl2ba && $(MAKE) -s EXE="$(EXE)" clean) -clean_jltl2dstar: checks - @(cd $(PRISM_SRC_DIR)/jltl2dstar && $(MAKE) -s EXE="$(EXE)" clean) -clean_explicit: checks - @(cd $(PRISM_SRC_DIR)/explicit && $(MAKE) -s EXE="$(EXE)" clean) -clean_pta: checks - @(cd $(PRISM_SRC_DIR)/pta && $(MAKE) -s EXE="$(EXE)" clean) -clean_param: checks - @(cd $(PRISM_SRC_DIR)/param && $(MAKE) -s EXE="$(EXE)" clean) -clean_strat: checks - @(cd $(PRISM_SRC_DIR)/strat && $(MAKE) -s EXE="$(EXE)" clean) - ############### # IDE support # ############### diff --git a/prism/ext/lp_solve_5.5_java/lib/build b/prism/ext/lp_solve_5.5_java/lib/build index 0915f3920e..6d090d3887 100755 --- a/prism/ext/lp_solve_5.5_java/lib/build +++ b/prism/ext/lp_solve_5.5_java/lib/build @@ -50,4 +50,4 @@ SRC_DIR=../src/c INCL="-I$JAVA_JNI_H_DIR -I$JAVA_JNI_MD_H_DIR -I $LPSOLVE_DIR -I $SRC_DIR" $c $CFLAGS $INCL -c $SRC_DIR/lpsolve5j.cpp -$c $CFLAGS -shared -Wl,-soname,liblpsolve55j.so -o $PLATFORM/liblpsolve55j.so lpsolve5j.o -L$LPSOLVE_LIB_DIR -lc -llpsolve55 +$c $CFLAGS -shared -Wl,-soname,liblpsolve55j.so -Wl,-soname,liblpsolve55j.so -Wl,-rpath,'$ORIGIN' -o $PLATFORM/liblpsolve55j.so lpsolve5j.o -L$LPSOLVE_LIB_DIR -lc -llpsolve55 diff --git a/prism/ext/lp_solve_5.5_java/lib/mac/build-osx b/prism/ext/lp_solve_5.5_java/lib/mac/build-osx index 3cad3e43fb..b3ebff729b 100755 --- a/prism/ext/lp_solve_5.5_java/lib/mac/build-osx +++ b/prism/ext/lp_solve_5.5_java/lib/mac/build-osx @@ -32,4 +32,4 @@ if [ "$ARCH" = "arm64" ]; then fi g++ $CFLAGS $INCL -c $SRC_DIR/lpsolve5j.cpp -g++ $CFLAGS -dynamiclib lpsolve5j.o -compatibility_version 5.5.0 -current_version 5.5.0 -o liblpsolve55j.dylib -lc -llpsolve55 -L$LPSOLVE_LIB_DIR +g++ $CFLAGS -dynamiclib lpsolve5j.o -compatibility_version 5.5.0 -current_version 5.5.0 -Wl,-install_name,@rpath/liblpsolve55j.dylib -Wl,-rpath,@loader_path/. -o liblpsolve55j.dylib -lc -llpsolve55 -L$LPSOLVE_LIB_DIR diff --git a/prism/ext/lpsolve55/src/lp_solve_5.5/lpsolve55/ccc.osx b/prism/ext/lpsolve55/src/lp_solve_5.5/lpsolve55/ccc.osx index 28f4f7f509..9db193feff 100644 --- a/prism/ext/lpsolve55/src/lp_solve_5.5/lpsolve55/ccc.osx +++ b/prism/ext/lpsolve55/src/lp_solve_5.5/lpsolve55/ccc.osx @@ -38,7 +38,7 @@ libtool -static -o bin/$PLATFORM/liblpsolve55.a `echo $src|sed s/[.]c/.o/g|sed ' if [ "$so" != "" ] then $c -arch i386 -fPIC -fno-common -s -c -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL -I../colamd -I. $opts $NOISNAN -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine $src - $c -arch i386 -dynamiclib bin/$PLATFORM/liblpsolve55.a -compatibility_version 5.5.0 -current_version 5.5.0 -o bin/$PLATFORM/liblpsolve55.dylib `echo $src|sed s/[.]c/.o/g|sed 's/[^ ]*\///g'` -lc + $c -arch i386 -dynamiclib bin/$PLATFORM/liblpsolve55.a -compatibility_version 5.5.0 -current_version 5.5.0 -Wl,-install_name,@rpath/liblpsolve55.dylib -o bin/$PLATFORM/liblpsolve55.dylib `echo $src|sed s/[.]c/.o/g|sed 's/[^ ]*\///g'` -lc mv bin/$PLATFORM/liblpsolve55.dylib ../../../lib fi diff --git a/prism/ext/lpsolve55/src/lp_solve_5.5/lpsolve55/ccc.osx64 b/prism/ext/lpsolve55/src/lp_solve_5.5/lpsolve55/ccc.osx64 index 9456c2d7b6..2b0e30943b 100644 --- a/prism/ext/lpsolve55/src/lp_solve_5.5/lpsolve55/ccc.osx64 +++ b/prism/ext/lpsolve55/src/lp_solve_5.5/lpsolve55/ccc.osx64 @@ -45,7 +45,7 @@ libtool -static -o bin/$PLATFORM/liblpsolve55.a `echo $src|sed s/[.]c/.o/g|sed ' if [ "$so" != "" ] then $c $CFLAGS -fPIC -fno-common -s -c -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL -I../colamd -I. $opts $NOISNAN -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine $src - $c $CFLAGS -dynamiclib bin/$PLATFORM/liblpsolve55.a -compatibility_version 5.5.0 -current_version 5.5.0 -o bin/$PLATFORM/liblpsolve55.dylib `echo $src|sed s/[.]c/.o/g|sed 's/[^ ]*\///g'` -lc + $c $CFLAGS -dynamiclib bin/$PLATFORM/liblpsolve55.a -compatibility_version 5.5.0 -current_version 5.5.0 -Wl,-install_name,@rpath/liblpsolve55.dylib -o bin/$PLATFORM/liblpsolve55.dylib `echo $src|sed s/[.]c/.o/g|sed 's/[^ ]*\///g'` -lc mv bin/$PLATFORM/liblpsolve55.dylib ../../../lib fi diff --git a/prism/include/DoubleVectorGlob.h b/prism/include/DoubleVectorGlob.h deleted file mode 100644 index 66f5584d27..0000000000 --- a/prism/include/DoubleVectorGlob.h +++ /dev/null @@ -1,36 +0,0 @@ -//============================================================================== -// -// Copyright (c) 2002- -// Authors: -// * Dave Parker (University of Oxford, formerly University of Birmingham) -// -//------------------------------------------------------------------------------ -// -// This file is part of PRISM. -// -// PRISM is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// PRISM is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with PRISM; if not, write to the Free Software Foundation, -// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -//============================================================================== - -#include "PrismNativeGlob.h" - -//------------------------------------------------------------------------------ - -// externs to global variables - -// cudd manager -extern DdManager *ddman; - -//------------------------------------------------------------------------------ diff --git a/prism/include/PrismHybridGlob.h b/prism/include/PrismHybridGlob.h deleted file mode 100644 index 8d072425b3..0000000000 --- a/prism/include/PrismHybridGlob.h +++ /dev/null @@ -1,56 +0,0 @@ -//============================================================================== -// -// Copyright (c) 2002- -// Authors: -// * Dave Parker (University of Oxford, formerly University of Birmingham) -// -//------------------------------------------------------------------------------ -// -// This file is part of PRISM. -// -// PRISM is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// PRISM is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with PRISM; if not, write to the Free Software Foundation, -// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -//============================================================================== - -#include -#include -#include -#include -#include "PrismNativeGlob.h" - -//------------------------------------------------------------------------------ - -// externs to global variables - -// cudd manager -extern DdManager *ddman; - -// details from numerical computation which may be queried -extern double last_unif; - -//------------------------------------------------------------------------------ - -// macros, function prototypes - -#define logtwo(X) log((double)X)/log(2.0) -void PH_PrintToMainLog(JNIEnv *env, const char *str, ...) IS_LIKE_PRINTF(2,3); -void PH_PrintWarningToMainLog(JNIEnv *env, const char *str, ...) IS_LIKE_PRINTF(2,3); -void PH_PrintToTechLog(JNIEnv *env, const char *str, ...) IS_LIKE_PRINTF(2,3); -void PH_PrintMemoryToMainLog(JNIEnv *env, const char *before, double mem, const char *after); -void PH_SetErrorMessage(const char *str, ...) IS_LIKE_PRINTF(1,2); -char *PH_GetErrorMessage(); -bool PH_GetFlagExportIterations(); - -//------------------------------------------------------------------------------ diff --git a/prism/include/PrismMTBDDGlob.h b/prism/include/PrismMTBDDGlob.h deleted file mode 100644 index 6cba3e17f9..0000000000 --- a/prism/include/PrismMTBDDGlob.h +++ /dev/null @@ -1,58 +0,0 @@ -//============================================================================== -// -// Copyright (c) 2002- -// Authors: -// * Dave Parker (University of Oxford, formerly University of Birmingham) -// -//------------------------------------------------------------------------------ -// -// This file is part of PRISM. -// -// PRISM is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// PRISM is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with PRISM; if not, write to the Free Software Foundation, -// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -//============================================================================== - -#include -#include -#include "PrismNativeGlob.h" - -//------------------------------------------------------------------------------ - -// externs to global variables - -// cudd manager -extern DdManager *ddman; - -// export stuff -extern int export_type; -extern FILE *export_file; -extern JNIEnv *export_env; - -//------------------------------------------------------------------------------ - -// function prototypes - -void PM_PrintToMainLog(JNIEnv *env, const char *str, ...) IS_LIKE_PRINTF(2,3); -void PM_PrintWarningToMainLog(JNIEnv *env, const char *str, ...) IS_LIKE_PRINTF(2,3); -void PM_PrintToTechLog(JNIEnv *env, const char *str, ...) IS_LIKE_PRINTF(2,3); -void PM_SetErrorMessage(const char *str, ...) IS_LIKE_PRINTF(1,2); -char *PM_GetErrorMessage(); -int store_export_info(int type, jstring fn, JNIEnv *env); - - -void export_string(const char *str, ...) IS_LIKE_PRINTF(1,2); -bool PM_GetFlagExportIterations(); - -//------------------------------------------------------------------------------ diff --git a/prism/include/PrismNativeGlob.h b/prism/include/PrismNativeGlob.h index 2c79635f95..8b06c22d68 100644 --- a/prism/include/PrismNativeGlob.h +++ b/prism/include/PrismNativeGlob.h @@ -28,8 +28,11 @@ #define PRISMNATIVEGLOB_H //------------------------------------------------------------------------------ + +#include #include #include +#include // Flags for building Windows DLLs #ifdef __MINGW32__ @@ -69,6 +72,9 @@ //------------------------------------------------------------------------------ +#define MAX_LOG_STRING_LEN 1024 +#define MAX_ERR_STRING_LEN 1024 + // Constants - these need to match the definitions in prism/Prism.java const int EXPORT_PLAIN = 1; @@ -102,13 +108,32 @@ const int REACH_FRONTIER = 2; //------------------------------------------------------------------------------ +#define logtwo(X) log((double)X)/log(2.0) + // External refs to global variables // Prism object EXPORT extern jclass prism_cls; EXPORT extern jobject prism_obj; +// CUDD manager: stored so that it doesn't have to be passed to every CUDD/dd call. +// Set via (JNI) PN_SetCUDDManager, cached here and accessible across all native code. +EXPORT extern DdManager *ddman; + +// Export stuff: + +EXPORT extern int export_type; +EXPORT extern FILE *export_file; +EXPORT extern JNIEnv *export_env; +// adversary export mode +EXPORT extern int export_adv; +// adversary export filename +EXPORT extern const char *export_adv_filename; +// export iterations filename +EXPORT extern const char *export_iterations_filename; + // Options: + // numerical method stuff EXPORT extern int lin_eq_method; EXPORT extern double lin_eq_method_param; @@ -126,18 +151,27 @@ EXPORT extern int sor_max_mem; EXPORT extern int num_sor_levels; // use steady-state detection for transient computation? EXPORT extern bool do_ss_detect; -// adversary EXPORT extern mode -EXPORT extern int export_adv; -// adversary export filename -EXPORT extern const char *export_adv_filename; -// export iterations filename -EXPORT extern const char *export_iterations_filename; // details from numerical computation which may be queried EXPORT extern double last_error_bound; //------------------------------------------------------------------------------ +// function prototypes + +EXPORT void PN_SetErrorMessage(const char *str, ...) IS_LIKE_PRINTF(1,2); +EXPORT char *PH_GetErrorMessage(); + +int store_export_info(int type, jstring fn, JNIEnv *env); +void export_string(const char *str, ...) IS_LIKE_PRINTF(1,2); +bool PN_GetFlagExportIterations(); + +void PN_PrintToMainLog(JNIEnv *env, const char *str, ...) IS_LIKE_PRINTF(2,3); +void PN_PrintWarningToMainLog(JNIEnv *env, const char *str, ...) IS_LIKE_PRINTF(2,3); +void PN_PrintMemoryToMainLog(JNIEnv *env, const char *before, double mem, const char *after); + +//------------------------------------------------------------------------------ + #endif //------------------------------------------------------------------------------ diff --git a/prism/include/PrismSparseGlob.h b/prism/include/PrismSparseGlob.h deleted file mode 100644 index a6e8dc1667..0000000000 --- a/prism/include/PrismSparseGlob.h +++ /dev/null @@ -1,58 +0,0 @@ -//============================================================================== -// -// Copyright (c) 2002- -// Authors: -// * Dave Parker (University of Oxford, formerly University of Birmingham) -// -//------------------------------------------------------------------------------ -// -// This file is part of PRISM. -// -// PRISM is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// PRISM is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with PRISM; if not, write to the Free Software Foundation, -// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -//============================================================================== - -#include -#include -#include "PrismNativeGlob.h" - -//------------------------------------------------------------------------------ - -// externs to global variables - -// cudd manager -extern DdManager *ddman; - -// export stuff -extern int export_type; -extern FILE *export_file; -extern JNIEnv *export_env; - -//------------------------------------------------------------------------------ - -// macros, function prototypes - -#define logtwo(X) log((double)X)/log(2.0) -void PS_PrintToMainLog(JNIEnv *env, const char *str, ...) IS_LIKE_PRINTF(2,3); -void PS_PrintWarningToMainLog(JNIEnv *env, const char *str, ...) IS_LIKE_PRINTF(2,3); -void PS_PrintToTechLog(JNIEnv *env, const char *str, ...) IS_LIKE_PRINTF(2,3); -void PS_PrintMemoryToMainLog(JNIEnv *env, const char *before, double mem, const char *after); -void PS_SetErrorMessage(const char *str, ...) IS_LIKE_PRINTF(1,2); -char *PS_GetErrorMessage(); -int store_export_info(int type, jstring fn, JNIEnv *env); -void export_string(const char *str, ...) IS_LIKE_PRINTF(1,2); -bool PS_GetFlagExportIterations(); - -//------------------------------------------------------------------------------ diff --git a/prism/include/jni/dv_DoubleVector.h b/prism/include/jni/dv_DoubleVector.h index 7c62f70109..40ac78cfee 100644 --- a/prism/include/jni/dv_DoubleVector.h +++ b/prism/include/jni/dv_DoubleVector.h @@ -7,14 +7,6 @@ #ifdef __cplusplus extern "C" { #endif -/* - * Class: dv_DoubleVector - * Method: DV_SetCUDDManager - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_dv_DoubleVector_DV_1SetCUDDManager - (JNIEnv *, jclass, jlong); - /* * Class: dv_DoubleVector * Method: DV_CreateZeroVector diff --git a/prism/include/jni/hybrid_PrismHybrid.h b/prism/include/jni/hybrid_PrismHybrid.h index 5d75262944..04f2f09293 100644 --- a/prism/include/jni/hybrid_PrismHybrid.h +++ b/prism/include/jni/hybrid_PrismHybrid.h @@ -7,62 +7,6 @@ #ifdef __cplusplus extern "C" { #endif -/* - * Class: hybrid_PrismHybrid - * Method: PH_FreeGlobalRefs - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_hybrid_PrismHybrid_PH_1FreeGlobalRefs - (JNIEnv *, jclass); - -/* - * Class: hybrid_PrismHybrid - * Method: PH_SetCUDDManager - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_hybrid_PrismHybrid_PH_1SetCUDDManager - (JNIEnv *, jclass, jlong); - -/* - * Class: hybrid_PrismHybrid - * Method: PH_SetMainLog - * Signature: (Lprism/PrismLog;)V - */ -JNIEXPORT void JNICALL Java_hybrid_PrismHybrid_PH_1SetMainLog - (JNIEnv *, jclass, jobject); - -/* - * Class: hybrid_PrismHybrid - * Method: PH_SetTechLog - * Signature: (Lprism/PrismLog;)V - */ -JNIEXPORT void JNICALL Java_hybrid_PrismHybrid_PH_1SetTechLog - (JNIEnv *, jclass, jobject); - -/* - * Class: hybrid_PrismHybrid - * Method: PH_SetExportIterations - * Signature: (Z)V - */ -JNIEXPORT void JNICALL Java_hybrid_PrismHybrid_PH_1SetExportIterations - (JNIEnv *, jclass, jboolean); - -/* - * Class: hybrid_PrismHybrid - * Method: PH_GetErrorMessage - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_hybrid_PrismHybrid_PH_1GetErrorMessage - (JNIEnv *, jclass); - -/* - * Class: hybrid_PrismHybrid - * Method: PH_GetLastUnif - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL Java_hybrid_PrismHybrid_PH_1GetLastUnif - (JNIEnv *, jclass); - /* * Class: hybrid_PrismHybrid * Method: PH_ProbBoundedUntil diff --git a/prism/include/jni/mtbdd_PrismMTBDD.h b/prism/include/jni/mtbdd_PrismMTBDD.h index 10f90046a0..c2a6251ff5 100644 --- a/prism/include/jni/mtbdd_PrismMTBDD.h +++ b/prism/include/jni/mtbdd_PrismMTBDD.h @@ -7,54 +7,6 @@ #ifdef __cplusplus extern "C" { #endif -/* - * Class: mtbdd_PrismMTBDD - * Method: PM_FreeGlobalRefs - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_mtbdd_PrismMTBDD_PM_1FreeGlobalRefs - (JNIEnv *, jclass); - -/* - * Class: mtbdd_PrismMTBDD - * Method: PM_SetCUDDManager - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_mtbdd_PrismMTBDD_PM_1SetCUDDManager - (JNIEnv *, jclass, jlong); - -/* - * Class: mtbdd_PrismMTBDD - * Method: PM_SetMainLog - * Signature: (Lprism/PrismLog;)V - */ -JNIEXPORT void JNICALL Java_mtbdd_PrismMTBDD_PM_1SetMainLog - (JNIEnv *, jclass, jobject); - -/* - * Class: mtbdd_PrismMTBDD - * Method: PM_SetTechLog - * Signature: (Lprism/PrismLog;)V - */ -JNIEXPORT void JNICALL Java_mtbdd_PrismMTBDD_PM_1SetTechLog - (JNIEnv *, jclass, jobject); - -/* - * Class: mtbdd_PrismMTBDD - * Method: PM_SetExportIterations - * Signature: (Z)V - */ -JNIEXPORT void JNICALL Java_mtbdd_PrismMTBDD_PM_1SetExportIterations - (JNIEnv *, jclass, jboolean); - -/* - * Class: mtbdd_PrismMTBDD - * Method: PM_GetErrorMessage - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_mtbdd_PrismMTBDD_PM_1GetErrorMessage - (JNIEnv *, jclass); - /* * Class: mtbdd_PrismMTBDD * Method: PM_Reachability diff --git a/prism/include/jni/odd_ODDUtils.h b/prism/include/jni/odd_ODDUtils.h index a83395fa32..23528b8eb6 100644 --- a/prism/include/jni/odd_ODDUtils.h +++ b/prism/include/jni/odd_ODDUtils.h @@ -7,14 +7,6 @@ #ifdef __cplusplus extern "C" { #endif -/* - * Class: odd_ODDUtils - * Method: ODD_SetCUDDManager - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_odd_ODDUtils_ODD_1SetCUDDManager - (JNIEnv *, jclass, jlong); - /* * Class: odd_ODDUtils * Method: ODD_BuildODD diff --git a/prism/include/jni/prism_PrismNative.h b/prism/include/jni/prism_PrismNative.h index 33be832a47..9db7131ac3 100644 --- a/prism/include/jni/prism_PrismNative.h +++ b/prism/include/jni/prism_PrismNative.h @@ -23,6 +23,38 @@ JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1FreeGlobalRefs JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1SetPrism (JNIEnv *, jclass, jobject); +/* + * Class: prism_PrismNative + * Method: PN_SetCUDDManager + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1SetCUDDManager + (JNIEnv *, jclass, jlong); + +/* + * Class: prism_PrismNative + * Method: PN_SetMainLog + * Signature: (Lprism/PrismLog;)V + */ +JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1SetMainLog + (JNIEnv *, jclass, jobject); + +/* + * Class: prism_PrismNative + * Method: PN_GetErrorMessage + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_prism_PrismNative_PN_1GetErrorMessage + (JNIEnv *, jclass); + +/* + * Class: prism_PrismNative + * Method: PN_SetExportIterations + * Signature: (Z)V + */ +JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1SetExportIterations + (JNIEnv *, jclass, jboolean); + /* * Class: prism_PrismNative * Method: PN_SetCompact diff --git a/prism/include/jni/sparse_PrismSparse.h b/prism/include/jni/sparse_PrismSparse.h index 30e6607b08..2019c3db3d 100644 --- a/prism/include/jni/sparse_PrismSparse.h +++ b/prism/include/jni/sparse_PrismSparse.h @@ -7,54 +7,6 @@ #ifdef __cplusplus extern "C" { #endif -/* - * Class: sparse_PrismSparse - * Method: PS_FreeGlobalRefs - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1FreeGlobalRefs - (JNIEnv *, jclass); - -/* - * Class: sparse_PrismSparse - * Method: PS_SetCUDDManager - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1SetCUDDManager - (JNIEnv *, jclass, jlong); - -/* - * Class: sparse_PrismSparse - * Method: PS_SetMainLog - * Signature: (Lprism/PrismLog;)V - */ -JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1SetMainLog - (JNIEnv *, jclass, jobject); - -/* - * Class: sparse_PrismSparse - * Method: PS_SetTechLog - * Signature: (Lprism/PrismLog;)V - */ -JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1SetTechLog - (JNIEnv *, jclass, jobject); - -/* - * Class: sparse_PrismSparse - * Method: PS_SetExportIterations - * Signature: (Z)V - */ -JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1SetExportIterations - (JNIEnv *, jclass, jboolean); - -/* - * Class: sparse_PrismSparse - * Method: PS_GetErrorMessage - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_sparse_PrismSparse_PS_1GetErrorMessage - (JNIEnv *, jclass); - /* * Class: sparse_PrismSparse * Method: PS_ProbBoundedUntil diff --git a/prism/src/automata/Makefile b/prism/src/automata/Makefile deleted file mode 100644 index a06e69710d..0000000000 --- a/prism/src/automata/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = automata -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/src/bin/prism.darwin b/prism/src/bin/prism.darwin index 1f4233c2f4..6d8f3a167c 100755 --- a/prism/src/bin/prism.darwin +++ b/prism/src/bin/prism.darwin @@ -102,11 +102,12 @@ PRISM_CLASSPATH="$PRISM_DIR"/lib/prism.jar:"$PRISM_DIR"/classes:"$PRISM_DIR":"$P PRISM_LIB_PATH="$PRISM_DIR"/lib # Copy library path to relevant vars -DYLD_LIBRARY_PATH="${PRISM_LIB_PATH}${DYLD_LIBRARY_PATH:+:}${DYLD_LIBRARY_PATH}" +#DYLD_LIBRARY_PATH="${PRISM_LIB_PATH}${DYLD_LIBRARY_PATH:+:}${DYLD_LIBRARY_PATH}" JAVA_LIBRARY_PATH="$PRISM_LIB_PATH" # Export environment variables -export PRISM_DIR DYLD_LIBRARY_PATH +export PRISM_DIR +# export LD_LIBRARY_PATH # Main Java class to launch PRISM_MAINCLASS=${PRISM_MAINCLASS:-prism.PrismCL} diff --git a/prism/src/bin/prism.linux b/prism/src/bin/prism.linux index 938dd52cfd..e9fdc8ff21 100755 --- a/prism/src/bin/prism.linux +++ b/prism/src/bin/prism.linux @@ -93,11 +93,12 @@ PRISM_CLASSPATH="$PRISM_DIR"/lib/prism.jar:"$PRISM_DIR"/classes:"$PRISM_DIR":"$P PRISM_LIB_PATH="$PRISM_DIR"/lib # Copy library path to relevant vars -LD_LIBRARY_PATH="${PRISM_LIB_PATH}${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}" +#LD_LIBRARY_PATH="${PRISM_LIB_PATH}${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}" JAVA_LIBRARY_PATH="$PRISM_LIB_PATH" # Export environment variables -export PRISM_DIR LD_LIBRARY_PATH +export PRISM_DIR +# export LD_LIBRARY_PATH # Main Java class to launch PRISM_MAINCLASS=${PRISM_MAINCLASS:-prism.PrismCL} diff --git a/prism/src/cex/Makefile b/prism/src/cex/Makefile deleted file mode 100644 index 63859a332e..0000000000 --- a/prism/src/cex/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = cex -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/src/common/Makefile b/prism/src/common/Makefile deleted file mode 100644 index b22ca64d73..0000000000 --- a/prism/src/common/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = common -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java iterable/*.java functions/*.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/src/dd/Makefile b/prism/src/dd/Makefile deleted file mode 100644 index d93174d772..0000000000 --- a/prism/src/dd/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = dd -PRISM_DIR_REL = ../.. - -INCLUDES = \ --I$(PRISM_DIR_REL)/$(CUDD_DIR)/include \ --I$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR) - -LIBRARIES = \ --L$(PRISM_DIR_REL)/$(CUDD_DIR)/lib \ --lcudd - -CC_FILES = $(wildcard *.cc) -O_FILES = $(CC_FILES:%.cc=$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o) - -default: all - -all: checks $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)dd$(LIBSUFFIX) $(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/dd_test$(EXE) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)dd$(LIBSUFFIX): $(O_FILES) - $(LD) $(SHARED) $(LDFLAGS) -o $@ $(O_FILES) $(LIBRARIES) - -$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/dd_test$(EXE): $(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/dd_test.o $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)dd$(LIBSUFFIX) - $(LD) $(LDFLAGS) -o $@ $(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/dd_test.o -L$(PRISM_DIR_REL)/$(PRISM_LIB_DIR) -ldd - -$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o: %.cc - $(CXX) $(CXXFLAGS) -c $< -o $@ $(INCLUDES) - -clean: checks - @rm -f $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)dd$(LIBSUFFIX) $(O_FILES) $(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/dd_test$(EXE) - -celan: clean - -################################################# diff --git a/prism/src/dv/DoubleVector.cc b/prism/src/dv/DoubleVector.cc index df220d902c..56625b7133 100644 --- a/prism/src/dv/DoubleVector.cc +++ b/prism/src/dv/DoubleVector.cc @@ -27,31 +27,12 @@ #include "dv.h" #include "DoubleVector.h" -#include "DoubleVectorGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include #include -//------------------------------------------------------------------------------ - -// cudd manager -DdManager *ddman; - -//------------------------------------------------------------------------------ -// cudd manager -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_dv_DoubleVector_DV_1SetCUDDManager -( -JNIEnv *env, -jclass cls, -jlong __jlongpointer ddm -) -{ - ddman = jlong_to_DdManager(ddm); -} - //------------------------------------------------------------------------------ // DoubleVector methods //------------------------------------------------------------------------------ diff --git a/prism/src/dv/DoubleVector.java b/prism/src/dv/DoubleVector.java index 0c683ecdce..4530e6f8db 100644 --- a/prism/src/dv/DoubleVector.java +++ b/prism/src/dv/DoubleVector.java @@ -43,7 +43,7 @@ public class DoubleVector static { try { - System.loadLibrary("dv"); + System.loadLibrary("prism"); } catch (UnsatisfiedLinkError e) { System.out.println(e); @@ -51,20 +51,6 @@ public class DoubleVector } } - //------------------------------------------------------------------------------ - // CUDD manager - //------------------------------------------------------------------------------ - - // CUDD manager - - // JNI method to set CUDD manager for native code - public static void setCUDDManager() - { - DV_SetCUDDManager(JDD.GetCUDDManager()); - } - - private static native void DV_SetCUDDManager(long ddm); - //------------------------------------------------------------------------------ // Instance variables/methods //------------------------------------------------------------------------------ diff --git a/prism/src/dv/IntegerVector.cc b/prism/src/dv/IntegerVector.cc index 9cf3d82413..50ef8ae175 100644 --- a/prism/src/dv/IntegerVector.cc +++ b/prism/src/dv/IntegerVector.cc @@ -26,8 +26,8 @@ //============================================================================== #include "iv.h" -#include "DoubleVectorGlob.h" #include "IntegerVector.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include diff --git a/prism/src/dv/IntegerVector.java b/prism/src/dv/IntegerVector.java index be1627b320..e228b45cf3 100644 --- a/prism/src/dv/IntegerVector.java +++ b/prism/src/dv/IntegerVector.java @@ -42,7 +42,7 @@ public class IntegerVector static { try { - System.loadLibrary("dv"); + System.loadLibrary("prism"); } catch (UnsatisfiedLinkError e) { System.out.println(e); diff --git a/prism/src/dv/Makefile b/prism/src/dv/Makefile deleted file mode 100644 index c5f82a60a0..0000000000 --- a/prism/src/dv/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = dv -PRISM_DIR_REL = ../.. - -INCLUDES = \ --I$(PRISM_DIR_REL)/$(CUDD_DIR)/include \ --I"$(JAVA_JNI_H_DIR)" \ --I"$(JAVA_JNI_MD_H_DIR)" \ --I$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR) - -LIBRARIES = \ --L$(PRISM_DIR_REL)/$(PRISM_LIB_DIR) \ --lodd \ --ldd \ -$(LIBMATH) - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -CC_FILES = $(wildcard *.cc) -O_FILES = $(CC_FILES:%.cc=$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o) - -default: all - -all: checks $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)dv$(LIBSUFFIX) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)dv$(LIBSUFFIX): $(O_FILES) - $(LD) $(SHARED) $(LDFLAGS) -o $@ $(O_FILES) $(LIBRARIES) - -$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o: %.cc - $(CXX) $(CXXFLAGS) -c $< -o $@ $(INCLUDES) - -clean: checks - @rm -f $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)dv$(LIBSUFFIX) $(O_FILES) - -celan: clean - -################################################# diff --git a/prism/src/explicit/Makefile b/prism/src/explicit/Makefile deleted file mode 100644 index 60183a3070..0000000000 --- a/prism/src/explicit/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = explicit -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java rewards/*.java modelviews/*.java graphviz/*.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/src/hybrid/Makefile b/prism/src/hybrid/Makefile deleted file mode 100644 index 766714cb0e..0000000000 --- a/prism/src/hybrid/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = hybrid -PRISM_DIR_REL = ../.. - -INCLUDES = \ --I$(PRISM_DIR_REL)/$(CUDD_DIR)/include \ --I"$(JAVA_JNI_H_DIR)" \ --I"$(JAVA_JNI_MD_H_DIR)" \ --I$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR) - -LIBRARIES = \ --L$(PRISM_DIR_REL)/$(PRISM_LIB_DIR) \ --lprismsparse \ --lodd \ --ldd \ --ldv \ --lprism \ -$(LIBMATH) - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -CC_FILES = $(wildcard *.cc) -O_FILES = $(CC_FILES:%.cc=$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o) - -default: all - -all: checks $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prismhybrid$(LIBSUFFIX) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prismhybrid$(LIBSUFFIX): $(O_FILES) - $(LD) $(SHARED) $(LDFLAGS) -o $@ $(O_FILES) $(LIBRARIES) - -$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o: %.cc - $(CXX) $(CXXFLAGS) -c $< -o $@ $(INCLUDES) - -clean: checks - @rm -f $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prismhybrid$(LIBSUFFIX) $(O_FILES) - -celan: clean - -################################################# diff --git a/prism/src/hybrid/PH_JOR.cc b/prism/src/hybrid/PH_JOR.cc index 80cf3dbcb0..ba485cd4c8 100644 --- a/prism/src/hybrid/PH_JOR.cc +++ b/prism/src/hybrid/PH_JOR.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -133,18 +133,18 @@ jdouble omega // omega (over-relaxation parameter) a = DD_ITE(ddman, id, DD_Constant(ddman, 0), a); // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(a, rvars, cvars, num_rvars, odd, true, transpose); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false, transpose); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -154,12 +154,12 @@ jdouble omega // omega (over-relaxation parameter) } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diags, either by extracting from mtbdd or // by doing (negative, non-diagonal) row sums of original A matrix (and then setting to 1 if sum is 0) - PH_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); if (!row_sums) { diags = DD_MaxAbstract(ddman, diags, cvars, num_cvars); diags_vec = mtbdd_to_double_vector(ddman, diags, rvars, num_rvars, odd); @@ -180,8 +180,8 @@ jdouble omega // omega (over-relaxation parameter) } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PH_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // invert diagonal if (!compact_d) { @@ -192,7 +192,7 @@ jdouble omega // omega (over-relaxation parameter) // build b vector (if present) if (b != NULL) { - PH_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -204,30 +204,30 @@ jdouble omega // omega (over-relaxation parameter) } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PH_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = mtbdd_to_double_vector(ddman, init, rvars, num_rvars, odd); soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PH_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PH_JOR ("); title += (omega == 1.0)?"Jacobi": ("JOR omega=" + std::to_string(omega)); title += ")"; iterationExport.reset(new ExportIterations(title.c_str())); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln, n, 0); } @@ -240,7 +240,7 @@ jdouble omega // omega (over-relaxation parameter) // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -286,8 +286,8 @@ jdouble omega // omega (over-relaxation parameter) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -303,10 +303,10 @@ jdouble omega // omega (over-relaxation parameter) time_taken = (double)(stop - start1)/1000; // print iters/timing info - PH_PrintToMainLog(env, "\n%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error - if (!done) { delete[] soln; soln = NULL; PH_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } + if (!done) { delete[] soln; soln = NULL; PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } // the difference between vector values is not a reliable error bound // but we store it anyway in case it is useful for estimating a bound @@ -314,7 +314,7 @@ jdouble omega // omega (over-relaxation parameter) // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_JORInterval.cc b/prism/src/hybrid/PH_JORInterval.cc index 304149027d..c31e9a19bd 100644 --- a/prism/src/hybrid/PH_JORInterval.cc +++ b/prism/src/hybrid/PH_JORInterval.cc @@ -35,7 +35,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -114,7 +114,7 @@ jint flags MeasureSupNormInterval measure(term_crit == TERM_CRIT_RELATIVE); if (omega <= 0.0 || omega > 1.0) { - PH_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); + PN_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); return ptr_to_jlong(NULL); } @@ -146,18 +146,18 @@ jint flags a = DD_ITE(ddman, id, DD_Constant(ddman, 0), a); // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(a, rvars, cvars, num_rvars, odd, true, transpose); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false, transpose); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -167,12 +167,12 @@ jint flags } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diags, either by extracting from mtbdd or // by doing (negative, non-diagonal) row sums of original A matrix (and then setting to 1 if sum is 0) - PH_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); if (!row_sums) { diags = DD_MaxAbstract(ddman, diags, cvars, num_cvars); diags_vec = mtbdd_to_double_vector(ddman, diags, rvars, num_rvars, odd); @@ -193,8 +193,8 @@ jint flags } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PH_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // invert diagonal if (!compact_d) { @@ -205,7 +205,7 @@ jint flags // build b vector (if present) if (b != NULL) { - PH_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -217,31 +217,31 @@ jint flags } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PH_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln_below = mtbdd_to_double_vector(ddman, lower, rvars, num_rvars, odd); soln_above = mtbdd_to_double_vector(ddman, upper, rvars, num_rvars, odd); soln_below2 = new double[n]; soln_above2 = new double[n]; kb = n*8.0/1024.0; kbt += 4*kb; - PH_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PH_JOR_Interval ("); title += (omega == 1.0)?"Jacobi": ("JOR omega=" + std::to_string(omega)); title += ")"; iterationExport.reset(new ExportIterations(title.c_str())); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln_below, n, 0); iterationExport->exportVector(soln_above, n, 1); } @@ -255,7 +255,7 @@ jint flags // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -320,14 +320,14 @@ jint flags measure.reset(); measure.measure(soln_below2, soln_above2, n); if (measure.value() < term_crit_param) { - PH_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); done = true; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -346,14 +346,14 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iters/timing info - PH_PrintToMainLog(env, "\n%s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!done) { delete[] soln_below; soln_below = NULL; - PH_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); - PH_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); } if (helper.flag_select_midpoint() && soln_below) { // we did converge, select midpoint @@ -369,7 +369,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln_below) delete[] soln_below; soln_below = 0; } diff --git a/prism/src/hybrid/PH_NondetBoundedUntil.cc b/prism/src/hybrid/PH_NondetBoundedUntil.cc index f08856cc2c..6cbed73841 100644 --- a/prism/src/hybrid/PH_NondetBoundedUntil.cc +++ b/prism/src/hybrid/PH_NondetBoundedUntil.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include @@ -117,24 +117,24 @@ jboolean min // min or max probabilities (true = min, false = max) n = odd->eoff + odd->toff; // build hdds for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrices... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrices... "); hddms = build_hdd_matrices_mdp(a, NULL, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); nm = hddms->nm; kb = hddms->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms->nm, hddms->num_levels, hddms->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms->nm, hddms->num_levels, hddms->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse bits - PH_PrintToMainLog(env, "Adding sparse bits... "); + PN_PrintToMainLog(env, "Adding sparse bits... "); add_sparse_matrices_mdp(hddms, compact); kb = hddms->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms->l_sm_min, hddms->l_sm_max, hddms->num_sm, hddms->compact_sm, hddms->nm); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms->l_sm_min, hddms->l_sm_max, hddms->num_sm, hddms->compact_sm, hddms->nm); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of yes - PH_PrintToMainLog(env, "Creating vector for yes... "); + PN_PrintToMainLog(env, "Creating vector for yes... "); yes_vec = mtbdd_to_double_vector(ddman, yes, rvars, num_rvars, odd); compact_y = false; // try and convert to compact form if required @@ -146,21 +146,21 @@ jboolean min // min or max probabilities (true = min, false = max) } kb = (!compact_y) ? n*8.0/1024.0 : (yes_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_y) PH_PrintToMainLog(env, "[dist=%d, compact] ", yes_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_y) PN_PrintToMainLog(env, "[dist=%d, compact] ", yes_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); //for(i = 0; i < n; i++) printf("%f ", (!compact_y)?(yes_vec[i]):(yes_dist->dist[yes_dist->ptrs[i]])); printf("\n"); // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = new double[n]; soln2 = new double[n]; soln3 = new double[n]; kb = n*8.0/1024.0; kbt += 3*kb; - PH_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution is yes if (!compact_y) { @@ -176,7 +176,7 @@ jboolean min // min or max probabilities (true = min, false = max) start3 = stop; // start iterations - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -235,8 +235,8 @@ jboolean min // min or max probabilities (true = min, false = max) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PH_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -252,11 +252,11 @@ jboolean min // min or max probabilities (true = min, false = max) time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PH_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_NondetReachReward.cc b/prism/src/hybrid/PH_NondetReachReward.cc index 8511f3d189..0d6368af87 100644 --- a/prism/src/hybrid/PH_NondetReachReward.cc +++ b/prism/src/hybrid/PH_NondetReachReward.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -131,21 +131,21 @@ jboolean min // min or max probabilities (true = min, false = max) a = DD_Apply(ddman, APPLY_TIMES, trans, maybe); // build hdds for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrices... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrices... "); hddms = build_hdd_matrices_mdp(a, NULL, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); nm = hddms->nm; kb = hddms->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms->nm, hddms->num_levels, hddms->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms->nm, hddms->num_levels, hddms->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse bits - PH_PrintToMainLog(env, "Adding sparse bits... "); + PN_PrintToMainLog(env, "Adding sparse bits... "); add_sparse_matrices_mdp(hddms, compact); kb = hddms->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms->l_sm_min, hddms->l_sm_max, hddms->num_sm, hddms->compact_sm, hddms->nm); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms->l_sm_min, hddms->l_sm_max, hddms->num_sm, hddms->compact_sm, hddms->nm); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // multiply transition rewards by transition probs and sum rows // (note also filters out unwanted states at the same time) @@ -156,20 +156,20 @@ jboolean min // min or max probabilities (true = min, false = max) trans_rewards = DD_Apply(ddman, APPLY_TIMES, trans_rewards, DD_SetVectorElement(ddman, DD_Constant(ddman, 0), cvars, num_cvars, 0, 1)); // build hdds for transition rewards matrix - PH_PrintToMainLog(env, "Building hybrid MTBDD matrices for rewards... "); + PN_PrintToMainLog(env, "Building hybrid MTBDD matrices for rewards... "); hddms2 = build_hdd_matrices_mdp(trans_rewards, hddms, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); kb = hddms2->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms2->nm, hddms2->num_levels, hddms2->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms2->nm, hddms2->num_levels, hddms2->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse bits - PH_PrintToMainLog(env, "Adding sparse bits... "); + PN_PrintToMainLog(env, "Adding sparse bits... "); add_sparse_matrices_mdp(hddms2, compact); kb = hddms2->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms2->l_sm_min, hddms2->l_sm_max, hddms2->num_sm, hddms2->compact_sm, hddms2->nm); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms2->l_sm_min, hddms2->l_sm_max, hddms2->num_sm, hddms2->compact_sm, hddms2->nm); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // remove goal and infinity states from state rewards vector Cudd_Ref(state_rewards); @@ -177,7 +177,7 @@ jboolean min // min or max probabilities (true = min, false = max) state_rewards = DD_Apply(ddman, APPLY_TIMES, state_rewards, maybe); // put state rewards in a vector - PH_PrintToMainLog(env, "Creating rewards vector... "); + PN_PrintToMainLog(env, "Creating rewards vector... "); rew_vec = mtbdd_to_double_vector(ddman, state_rewards, rvars, num_rvars, odd); // try and convert to compact form if required compact_r = false; @@ -189,20 +189,20 @@ jboolean min // min or max probabilities (true = min, false = max) } kb = (!compact_r) ? n*8.0/1024.0 : (rew_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_r) PH_PrintToMainLog(env, "[dist=%d, compact] ", rew_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_r) PN_PrintToMainLog(env, "[dist=%d, compact] ", rew_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = new double[n]; soln2 = new double[n]; soln3 = new double[n]; kb = n*8.0/1024.0; kbt += 3*kb; - PH_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution is zero for (i = 0; i < n; i++) { @@ -210,9 +210,9 @@ jboolean min // min or max probabilities (true = min, false = max) } std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PH_NondetReachReward")); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln, n, 0); } @@ -225,7 +225,7 @@ jboolean min // min or max probabilities (true = min, false = max) // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -309,8 +309,8 @@ jboolean min // min or max probabilities (true = min, false = max) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -326,10 +326,10 @@ jboolean min // min or max probabilities (true = min, false = max) time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PH_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error - if (!done) { delete[] soln; soln = NULL; PH_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } + if (!done) { delete[] soln; soln = NULL; PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } // the difference between vector values is not a reliable error bound // but we store it anyway in case it is useful for estimating a bound @@ -337,7 +337,7 @@ jboolean min // min or max probabilities (true = min, false = max) // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_NondetReachRewardInterval.cc b/prism/src/hybrid/PH_NondetReachRewardInterval.cc index 0894396ea2..a1de0e052f 100644 --- a/prism/src/hybrid/PH_NondetReachRewardInterval.cc +++ b/prism/src/hybrid/PH_NondetReachRewardInterval.cc @@ -35,7 +35,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "ExportIterations.h" @@ -126,10 +126,10 @@ jint flags IntervalIteration helper(flags); if (!helper.flag_ensure_monotonic_from_above()) { - PH_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); } if (!helper.flag_ensure_monotonic_from_below()) { - PH_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); } // exception handling around whole function @@ -150,21 +150,21 @@ jint flags a = DD_Apply(ddman, APPLY_TIMES, trans, maybe); // build hdds for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrices... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrices... "); hddms = build_hdd_matrices_mdp(a, NULL, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); nm = hddms->nm; kb = hddms->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms->nm, hddms->num_levels, hddms->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms->nm, hddms->num_levels, hddms->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse bits - PH_PrintToMainLog(env, "Adding sparse bits... "); + PN_PrintToMainLog(env, "Adding sparse bits... "); add_sparse_matrices_mdp(hddms, compact); kb = hddms->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms->l_sm_min, hddms->l_sm_max, hddms->num_sm, hddms->compact_sm, hddms->nm); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms->l_sm_min, hddms->l_sm_max, hddms->num_sm, hddms->compact_sm, hddms->nm); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // multiply transition rewards by transition probs and sum rows // (note also filters out unwanted states at the same time) @@ -175,20 +175,20 @@ jint flags trans_rewards = DD_Apply(ddman, APPLY_TIMES, trans_rewards, DD_SetVectorElement(ddman, DD_Constant(ddman, 0), cvars, num_cvars, 0, 1)); // build hdds for transition rewards matrix - PH_PrintToMainLog(env, "Building hybrid MTBDD matrices for rewards... "); + PN_PrintToMainLog(env, "Building hybrid MTBDD matrices for rewards... "); hddms2 = build_hdd_matrices_mdp(trans_rewards, hddms, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); kb = hddms2->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms2->nm, hddms2->num_levels, hddms2->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms2->nm, hddms2->num_levels, hddms2->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse bits - PH_PrintToMainLog(env, "Adding sparse bits... "); + PN_PrintToMainLog(env, "Adding sparse bits... "); add_sparse_matrices_mdp(hddms2, compact); kb = hddms2->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms2->l_sm_min, hddms2->l_sm_max, hddms2->num_sm, hddms2->compact_sm, hddms2->nm); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms2->l_sm_min, hddms2->l_sm_max, hddms2->num_sm, hddms2->compact_sm, hddms2->nm); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // remove goal and infinity states from state rewards vector Cudd_Ref(state_rewards); @@ -196,7 +196,7 @@ jint flags state_rewards = DD_Apply(ddman, APPLY_TIMES, state_rewards, maybe); // put state rewards in a vector - PH_PrintToMainLog(env, "Creating rewards vector... "); + PN_PrintToMainLog(env, "Creating rewards vector... "); rew_vec = mtbdd_to_double_vector(ddman, state_rewards, rvars, num_rvars, odd); // try and convert to compact form if required compact_r = false; @@ -208,11 +208,11 @@ jint flags } kb = (!compact_r) ? n*8.0/1024.0 : (rew_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_r) PH_PrintToMainLog(env, "[dist=%d, compact] ", rew_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_r) PN_PrintToMainLog(env, "[dist=%d, compact] ", rew_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); // initial solution from below is lower soln_below = mtbdd_to_double_vector(ddman, lower, rvars, num_rvars, odd); soln_below2 = new double[n]; @@ -224,15 +224,15 @@ jint flags kb = n*8.0/1024.0; kbt += 6*kb; - PH_PrintMemoryToMainLog(env, "[6 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[6 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PH_NondetReachReward (interval)")); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln_below, n, 0); iterationExport->exportVector(soln_above, n, 1); } @@ -246,7 +246,7 @@ jint flags // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations (interval iteration)...\n"); + PN_PrintToMainLog(env, "\nStarting iterations (interval iteration)...\n"); while (!done && iters < max_iters) { @@ -352,14 +352,14 @@ jint flags measure.reset(); measure.measure(soln_below2, soln_above2, n); if (measure.value() < term_crit_param) { - PH_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); done = true; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -378,14 +378,14 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PH_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!done) { delete[] soln_below; soln_below = NULL; - PH_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); - PH_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); } if (helper.flag_select_midpoint() && soln_below) { // we did converge, select midpoint @@ -401,7 +401,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln_below) delete[] soln_below; soln_below = 0; } diff --git a/prism/src/hybrid/PH_NondetUntil.cc b/prism/src/hybrid/PH_NondetUntil.cc index 5e69eb76f4..424cad152c 100644 --- a/prism/src/hybrid/PH_NondetUntil.cc +++ b/prism/src/hybrid/PH_NondetUntil.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -122,24 +122,24 @@ jboolean min // min or max probabilities (true = min, false = max) n = odd->eoff + odd->toff; // build hdds for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrices... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrices... "); hddms = build_hdd_matrices_mdp(a, NULL, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); nm = hddms->nm; kb = hddms->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms->nm, hddms->num_levels, hddms->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms->nm, hddms->num_levels, hddms->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse bits - PH_PrintToMainLog(env, "Adding sparse bits... "); + PN_PrintToMainLog(env, "Adding sparse bits... "); add_sparse_matrices_mdp(hddms, compact); kb = hddms->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms->l_sm_min, hddms->l_sm_max, hddms->num_sm, hddms->compact_sm, hddms->nm); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms->l_sm_min, hddms->l_sm_max, hddms->num_sm, hddms->compact_sm, hddms->nm); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of yes - PH_PrintToMainLog(env, "Creating vector for yes... "); + PN_PrintToMainLog(env, "Creating vector for yes... "); yes_vec = mtbdd_to_double_vector(ddman, yes, rvars, num_rvars, odd); compact_y = false; // try and convert to compact form if required @@ -151,21 +151,21 @@ jboolean min // min or max probabilities (true = min, false = max) } kb = (!compact_y) ? n*8.0/1024.0 : (yes_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_y) PH_PrintToMainLog(env, "[dist=%d, compact] ", yes_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_y) PN_PrintToMainLog(env, "[dist=%d, compact] ", yes_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); //for(i = 0; i < n; i++) printf("%f ", (!compact_y)?(yes_vec[i]):(yes_dist->dist[yes_dist->ptrs[i]])); printf("\n"); // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = new double[n]; soln2 = new double[n]; soln3 = new double[n]; kb = n*8.0/1024.0; kbt += 3*kb; - PH_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution is yes if (!compact_y) { @@ -175,9 +175,9 @@ jboolean min // min or max probabilities (true = min, false = max) } std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PH_NondetUntil")); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln, n, 0); } @@ -190,7 +190,7 @@ jboolean min // min or max probabilities (true = min, false = max) // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -260,8 +260,8 @@ jboolean min // min or max probabilities (true = min, false = max) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -277,10 +277,10 @@ jboolean min // min or max probabilities (true = min, false = max) time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PH_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error - if (!done) { delete[] soln; soln = NULL; PH_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } + if (!done) { delete[] soln; soln = NULL; PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } // the difference between vector values is not a reliable error bound // but we store it anyway in case it is useful for estimating a bound @@ -288,7 +288,7 @@ jboolean min // min or max probabilities (true = min, false = max) // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_NondetUntilInterval.cc b/prism/src/hybrid/PH_NondetUntilInterval.cc index 5ce3d73d8e..38b31a0568 100644 --- a/prism/src/hybrid/PH_NondetUntilInterval.cc +++ b/prism/src/hybrid/PH_NondetUntilInterval.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -114,10 +114,10 @@ jint flags IntervalIteration helper(flags); if (!helper.flag_ensure_monotonic_from_above()) { - PH_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); } if (!helper.flag_ensure_monotonic_from_below()) { - PH_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); } // exception handling around whole function @@ -135,24 +135,24 @@ jint flags n = odd->eoff + odd->toff; // build hdds for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrices... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrices... "); hddms = build_hdd_matrices_mdp(a, NULL, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); nm = hddms->nm; kb = hddms->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms->nm, hddms->num_levels, hddms->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[nm=%d, levels=%d, nodes=%d] ", hddms->nm, hddms->num_levels, hddms->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse bits - PH_PrintToMainLog(env, "Adding sparse bits... "); + PN_PrintToMainLog(env, "Adding sparse bits... "); add_sparse_matrices_mdp(hddms, compact); kb = hddms->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms->l_sm_min, hddms->l_sm_max, hddms->num_sm, hddms->compact_sm, hddms->nm); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d-%d, num=%d, compact=%d/%d] ", hddms->l_sm_min, hddms->l_sm_max, hddms->num_sm, hddms->compact_sm, hddms->nm); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of yes - PH_PrintToMainLog(env, "Creating vector for yes... "); + PN_PrintToMainLog(env, "Creating vector for yes... "); yes_vec = mtbdd_to_double_vector(ddman, yes, rvars, num_rvars, odd); compact_y = false; // try and convert to compact form if required @@ -164,12 +164,12 @@ jint flags } kb = (!compact_y) ? n*8.0/1024.0 : (yes_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_y) PH_PrintToMainLog(env, "[dist=%d, compact] ", yes_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_y) PN_PrintToMainLog(env, "[dist=%d, compact] ", yes_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); //for(i = 0; i < n; i++) printf("%f ", (!compact_y)?(yes_vec[i]):(yes_dist->dist[yes_dist->ptrs[i]])); printf("\n"); // get vector of maybe - PH_PrintToMainLog(env, "Creating vector for maybe... "); + PN_PrintToMainLog(env, "Creating vector for maybe... "); maybe_vec = mtbdd_to_double_vector(ddman, maybe, rvars, num_rvars, odd); compact_maybe = false; // try and convert to compact form if required @@ -181,12 +181,12 @@ jint flags } kb = (!compact_maybe) ? n*8.0/1024.0 : (maybe_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_maybe) PH_PrintToMainLog(env, "[dist=%d, compact] ", maybe_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_maybe) PN_PrintToMainLog(env, "[dist=%d, compact] ", maybe_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); //for(i = 0; i < n; i++) printf("%f ", (!compact_maybe)?(maybe_vec[i]):(maybe_dist->dist[maybe_dist->ptrs[i]])); printf("\n"); // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln_below = new double[n]; soln_below2 = new double[n]; soln_below3 = new double[n]; @@ -196,10 +196,10 @@ jint flags kb = n*8.0/1024.0; kbt += 6*kb; - PH_PrintMemoryToMainLog(env, "[6 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[6 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution from below is yes, from above 1 for yes or maybe states double yes_val, maybe_val; @@ -220,9 +220,9 @@ jint flags } std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PH_NondetUntil_Interval")); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln_below, n, 0); iterationExport->exportVector(soln_above, n, 1); } @@ -236,7 +236,7 @@ jint flags // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations (interval iteration)...\n"); + PN_PrintToMainLog(env, "\nStarting iterations (interval iteration)...\n"); while (!done && iters < max_iters) { @@ -326,14 +326,14 @@ jint flags measure.reset(); measure.measure(soln_below2, soln_above2, n); if (measure.value() < term_crit_param) { - PH_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); done = true; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -352,14 +352,14 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PH_PrintToMainLog(env, "\nIterative method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!done) { delete[] soln_below; soln_below = NULL; - PH_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); - PH_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); } if (helper.flag_select_midpoint() && soln_below) { // we did converge, select midpoint @@ -375,7 +375,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln_below) delete[] soln_below; soln_below = 0; } diff --git a/prism/src/hybrid/PH_PSOR.cc b/prism/src/hybrid/PH_PSOR.cc index cda98f6de8..1a15f8ff55 100644 --- a/prism/src/hybrid/PH_PSOR.cc +++ b/prism/src/hybrid/PH_PSOR.cc @@ -35,7 +35,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "Measures.h" #include "ExportIterations.h" @@ -134,28 +134,28 @@ jboolean forwards // forwards or backwards? a = DD_ITE(ddman, id, DD_Constant(ddman, 0), a); // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(a, rvars, cvars, num_rvars, odd, true, transpose); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // split hdd matrix into blocks // nb: in terms of memory, this gets precedence over sparse matrices - PH_PrintToMainLog(env, "Splitting into blocks... "); + PN_PrintToMainLog(env, "Splitting into blocks... "); split_hdd_matrix(hddm, compact, false, transpose); compact_b = hddm->compact_b; kb = hddm->mem_b; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, n=%d, nnz=%d%s] ", hddm->l_b, hddm->blocks->n, hddm->blocks->nnz, compact_b?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, n=%d, nnz=%d%s] ", hddm->l_b, hddm->blocks->n, hddm->blocks->nnz, compact_b?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false, transpose); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -165,13 +165,13 @@ jboolean forwards // forwards or backwards? } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diags, either by extracting from mtbdd or // by doing (negative, non-diagonal) row sums of original A matrix (and then setting to 1 if sum is 0) // (the latter is a fix for steady-state solution of a subsystem e.g. a BSCC) - PH_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); if (!row_sums) { diags = DD_MaxAbstract(ddman, diags, cvars, num_cvars); diags_vec = mtbdd_to_double_vector(ddman, diags, rvars, num_rvars, odd); @@ -192,8 +192,8 @@ jboolean forwards // forwards or backwards? } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PH_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // invert diagonal if (!compact_d) { @@ -204,7 +204,7 @@ jboolean forwards // forwards or backwards? // build b vector (if present) if (b != NULL) { - PH_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -216,32 +216,32 @@ jboolean forwards // forwards or backwards? } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PH_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = mtbdd_to_double_vector(ddman, init, rvars, num_rvars, odd); soln2 = new double[hddm->blocks->max]; for (i = 0; i < hddm->blocks->max; i++) soln2[i] = 0; kb = (n*8.0/1024.0)+(hddm->blocks->max*8.0/1024.0); kbt += kb; - PH_PrintMemoryToMainLog(env, "[", (n*8.0/1024.0), ""); - PH_PrintMemoryToMainLog(env, " + ", (hddm->blocks->max*8.0/1024.0), ""); - PH_PrintMemoryToMainLog(env, " = ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", (n*8.0/1024.0), ""); + PN_PrintMemoryToMainLog(env, " + ", (hddm->blocks->max*8.0/1024.0), ""); + PN_PrintMemoryToMainLog(env, " = ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PH_PSOR ("); title += (omega == 1.0)?"Pseudo Gauss-Seidel": ("Pseudo SOR omega=" + std::to_string(omega)); title += ")"; iterationExport.reset(new ExportIterations(title.c_str())); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln, n, 0); } @@ -253,13 +253,13 @@ jboolean forwards // forwards or backwards? // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { iters++; -// PH_PrintToMainLog(env, "Iteration %d: ", iters); +// PN_PrintToMainLog(env, "Iteration %d: ", iters); // start3 = util_cpu_time(); measure.reset(); @@ -347,7 +347,7 @@ jboolean forwards // forwards or backwards? done = true; } -// PH_PrintToMainLog(env, "%.2f %.2f sec\n", ((double)(util_cpu_time() - start3)/1000), ((double)(util_cpu_time() - start2)/1000)/iters); +// PN_PrintToMainLog(env, "%.2f %.2f sec\n", ((double)(util_cpu_time() - start3)/1000), ((double)(util_cpu_time() - start2)/1000)/iters); } // stop clocks @@ -356,10 +356,10 @@ jboolean forwards // forwards or backwards? time_taken = (double)(stop - start1)/1000; // print iters/timing info - PH_PrintToMainLog(env, "\n%sPseudo %s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%sPseudo %s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error - if (!done) { delete[] soln; soln = NULL; PH_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } + if (!done) { delete[] soln; soln = NULL; PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } // the difference between vector values is not a reliable error bound // but we store it anyway in case it is useful for estimating a bound @@ -367,7 +367,7 @@ jboolean forwards // forwards or backwards? // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_PSORInterval.cc b/prism/src/hybrid/PH_PSORInterval.cc index 174ee82f49..5fb1a6c4ba 100644 --- a/prism/src/hybrid/PH_PSORInterval.cc +++ b/prism/src/hybrid/PH_PSORInterval.cc @@ -36,7 +36,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "Measures.h" #include "ExportIterations.h" @@ -115,7 +115,7 @@ jint flags MeasureSupNormInterval measure(term_crit == TERM_CRIT_RELATIVE); if (omega <= 0.0 || omega > 1.0) { - PH_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); + PN_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); return ptr_to_jlong(NULL); } @@ -147,28 +147,28 @@ jint flags a = DD_ITE(ddman, id, DD_Constant(ddman, 0), a); // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(a, rvars, cvars, num_rvars, odd, true, transpose); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // split hdd matrix into blocks // nb: in terms of memory, this gets precedence over sparse matrices - PH_PrintToMainLog(env, "Splitting into blocks... "); + PN_PrintToMainLog(env, "Splitting into blocks... "); split_hdd_matrix(hddm, compact, false, transpose); compact_b = hddm->compact_b; kb = hddm->mem_b; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, n=%d, nnz=%d%s] ", hddm->l_b, hddm->blocks->n, hddm->blocks->nnz, compact_b?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, n=%d, nnz=%d%s] ", hddm->l_b, hddm->blocks->n, hddm->blocks->nnz, compact_b?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false, transpose); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -178,13 +178,13 @@ jint flags } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diags, either by extracting from mtbdd or // by doing (negative, non-diagonal) row sums of original A matrix (and then setting to 1 if sum is 0) // (the latter is a fix for steady-state solution of a subsystem e.g. a BSCC) - PH_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); if (!row_sums) { diags = DD_MaxAbstract(ddman, diags, cvars, num_cvars); diags_vec = mtbdd_to_double_vector(ddman, diags, rvars, num_rvars, odd); @@ -205,8 +205,8 @@ jint flags } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PH_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // invert diagonal if (!compact_d) { @@ -217,7 +217,7 @@ jint flags // build b vector (if present) if (b != NULL) { - PH_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -229,33 +229,33 @@ jint flags } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PH_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln_below = mtbdd_to_double_vector(ddman, lower, rvars, num_rvars, odd); soln_above = mtbdd_to_double_vector(ddman, upper, rvars, num_rvars, odd); soln2 = new double[hddm->blocks->max]; for (i = 0; i < hddm->blocks->max; i++) soln2[i] = 0; kb = 2*(n*8.0/1024.0)+(hddm->blocks->max*8.0/1024.0); kbt += kb; - PH_PrintMemoryToMainLog(env, "[2 x ", (n*8.0/1024.0), ""); - PH_PrintMemoryToMainLog(env, " + ", (hddm->blocks->max*8.0/1024.0), ""); - PH_PrintMemoryToMainLog(env, " = ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", (n*8.0/1024.0), ""); + PN_PrintMemoryToMainLog(env, " + ", (hddm->blocks->max*8.0/1024.0), ""); + PN_PrintMemoryToMainLog(env, " = ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PH_PSOR_Interval (Pseudo "); title += (omega == 1.0)?"Gauss-Seidel": ("SOR omega=" + std::to_string(omega)); title += ")"; iterationExport.reset(new ExportIterations(title.c_str())); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln_below, n, 0); iterationExport->exportVector(soln_above, n, 1); } @@ -268,13 +268,13 @@ jint flags // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { iters++; -// PH_PrintToMainLog(env, "Iteration %d: ", iters); +// PN_PrintToMainLog(env, "Iteration %d: ", iters); // start3 = util_cpu_time(); // stuff for block storage @@ -374,11 +374,11 @@ jint flags measure.reset(); measure.measure(soln_below, soln_above, n); if (measure.value() < term_crit_param) { - PH_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); done = true; } -// PH_PrintToMainLog(env, "%.2f %.2f sec\n", ((double)(util_cpu_time() - start3)/1000), ((double)(util_cpu_time() - start2)/1000)/iters); +// PN_PrintToMainLog(env, "%.2f %.2f sec\n", ((double)(util_cpu_time() - start3)/1000), ((double)(util_cpu_time() - start2)/1000)/iters); } // stop clocks @@ -387,14 +387,14 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iters/timing info - PH_PrintToMainLog(env, "\n%sPseudo %s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%sPseudo %s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!done) { delete[] soln_below; soln_below = NULL; - PH_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); - PH_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); } if (helper.flag_select_midpoint() && soln_below) { // we did converge, select midpoint @@ -410,7 +410,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln_below) delete[] soln_below; soln_below = 0; } diff --git a/prism/src/hybrid/PH_Power.cc b/prism/src/hybrid/PH_Power.cc index 2719ecb105..69a15c22af 100644 --- a/prism/src/hybrid/PH_Power.cc +++ b/prism/src/hybrid/PH_Power.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -117,18 +117,18 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) Cudd_Ref(a); // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(a, rvars, cvars, num_rvars, odd, true, transpose); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false, transpose); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -138,12 +138,12 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // build b vector (if present) if (b != NULL) { - PH_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -155,25 +155,25 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PH_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = mtbdd_to_double_vector(ddman, init, rvars, num_rvars, odd); soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PH_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PH_Power")); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln, n, 0); } @@ -186,7 +186,7 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -218,8 +218,8 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -235,10 +235,10 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) time_taken = (double)(stop - start1)/1000; // print iters/timing info - PH_PrintToMainLog(env, "\nPower method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nPower method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error - if (!done) { delete[] soln; soln = NULL; PH_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } + if (!done) { delete[] soln; soln = NULL; PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } // the difference between vector values is not a reliable error bound // but we store it anyway in case it is useful for estimating a bound @@ -246,7 +246,7 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_PowerInterval.cc b/prism/src/hybrid/PH_PowerInterval.cc index 0d18e30263..175b9e37fd 100644 --- a/prism/src/hybrid/PH_PowerInterval.cc +++ b/prism/src/hybrid/PH_PowerInterval.cc @@ -35,7 +35,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -125,18 +125,18 @@ jint flags Cudd_Ref(a); // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(a, rvars, cvars, num_rvars, odd, true, transpose); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false, transpose); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -146,12 +146,12 @@ jint flags } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // build b vector (if present) if (b != NULL) { - PH_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -163,27 +163,27 @@ jint flags } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PH_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln_below = mtbdd_to_double_vector(ddman, lower, rvars, num_rvars, odd); soln_above = mtbdd_to_double_vector(ddman, upper, rvars, num_rvars, odd); soln_below2 = new double[n]; soln_above2 = new double[n]; kb = n*8.0/1024.0; kbt += 4*kb; - PH_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PH_Power_Interval")); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln_below, n, 0); iterationExport->exportVector(soln_above, n, 1); } @@ -197,7 +197,7 @@ jint flags // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -245,14 +245,14 @@ jint flags measure.reset(); measure.measure(soln_below2, soln_above2, n); if (measure.value() < term_crit_param) { - PH_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); done = true; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -271,14 +271,14 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iters/timing info - PH_PrintToMainLog(env, "\nPower method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nPower method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!done) { delete[] soln_below; soln_below = NULL; - PH_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); - PH_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); } if (helper.flag_select_midpoint() && soln_below) { // we did converge, select midpoint @@ -294,7 +294,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln_below) delete[] soln_below; soln = 0; } diff --git a/prism/src/hybrid/PH_ProbBoundedUntil.cc b/prism/src/hybrid/PH_ProbBoundedUntil.cc index 02fc14a7c5..0e6fbafe6f 100644 --- a/prism/src/hybrid/PH_ProbBoundedUntil.cc +++ b/prism/src/hybrid/PH_ProbBoundedUntil.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include @@ -112,18 +112,18 @@ jint bound // time bound a = DD_Apply(ddman, APPLY_TIMES, trans, maybe); // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(a, rvars, cvars, num_rvars, odd, true); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -133,11 +133,11 @@ jint bound // time bound } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of yes - PH_PrintToMainLog(env, "Creating vector for yes... "); + PN_PrintToMainLog(env, "Creating vector for yes... "); yes_vec = mtbdd_to_double_vector(ddman, yes, rvars, num_rvars, odd); compact_y = false; // try and convert to compact form if required @@ -149,20 +149,20 @@ jint bound // time bound } kb = (!compact_y) ? n*8.0/1024.0 : (yes_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_y) PH_PrintToMainLog(env, "[dist=%d, compact] ", yes_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_y) PN_PrintToMainLog(env, "[dist=%d, compact] ", yes_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); //for(i = 0; i < n; i++) printf("%f ", (!compact_y)?(yes_vec[i]):(yes_dist->dist[yes_dist->ptrs[i]])); printf("\n"); // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = new double[n]; soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PH_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution is yes if (!compact_y) { @@ -178,7 +178,7 @@ jint bound // time bound start3 = stop; // start iterations - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -199,8 +199,8 @@ jint bound // time bound // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PH_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -216,11 +216,11 @@ jint bound // time bound time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PH_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_ProbCumulReward.cc b/prism/src/hybrid/PH_ProbCumulReward.cc index d2be2f17ab..9ee7f89f46 100644 --- a/prism/src/hybrid/PH_ProbCumulReward.cc +++ b/prism/src/hybrid/PH_ProbCumulReward.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include @@ -107,18 +107,18 @@ jint bound // time bound n = odd->eoff + odd->toff; // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(trans, rvars, cvars, num_rvars, odd, true); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -128,8 +128,8 @@ jint bound // time bound } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // multiply transition rewards by transition probs and sum rows // then combine state and transition rewards and put in a vector @@ -141,7 +141,7 @@ jint bound // time bound all_rewards = DD_Apply(ddman, APPLY_PLUS, state_rewards, all_rewards); // get vector of rewards - PH_PrintToMainLog(env, "Creating vector for rewards... "); + PN_PrintToMainLog(env, "Creating vector for rewards... "); rew_vec = mtbdd_to_double_vector(ddman, all_rewards, rvars, num_rvars, odd); // try and convert to compact form if required compact_r = false; @@ -153,19 +153,19 @@ jint bound // time bound } kb = (!compact_r) ? n*8.0/1024.0 : (rew_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_r) PH_PrintToMainLog(env, "[dist=%d, compact] ", rew_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_r) PN_PrintToMainLog(env, "[dist=%d, compact] ", rew_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = new double[n]; soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PH_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution is zero for (i = 0; i < n; i++) { @@ -179,7 +179,7 @@ jint bound // time bound start3 = stop; // start iterations - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -194,8 +194,8 @@ jint bound // time bound // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PH_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -211,11 +211,11 @@ jint bound // time bound time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PH_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_ProbInstReward.cc b/prism/src/hybrid/PH_ProbInstReward.cc index c05de54dbf..da772619df 100644 --- a/prism/src/hybrid/PH_ProbInstReward.cc +++ b/prism/src/hybrid/PH_ProbInstReward.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include @@ -100,18 +100,18 @@ jint bound // time bound n = odd->eoff + odd->toff; // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(trans, rvars, cvars, num_rvars, odd, true); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -121,20 +121,20 @@ jint bound // time bound } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors // (solution is initialised to the state rewards) - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = mtbdd_to_double_vector(ddman, state_rewards, rvars, num_rvars, odd); soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PH_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // get setup time stop = util_cpu_time(); @@ -143,7 +143,7 @@ jint bound // time bound start3 = stop; // start iterations - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -158,8 +158,8 @@ jint bound // time bound // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PH_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -175,11 +175,11 @@ jint bound // time bound time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PH_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_ProbReachReward.cc b/prism/src/hybrid/PH_ProbReachReward.cc index fe0b63bc4a..5d554f2cdd 100644 --- a/prism/src/hybrid/PH_ProbReachReward.cc +++ b/prism/src/hybrid/PH_ProbReachReward.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include @@ -155,7 +155,7 @@ jlong __jlongpointer m // 'maybe' states // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_ProbReachRewardInterval.cc b/prism/src/hybrid/PH_ProbReachRewardInterval.cc index 809044b4c5..8a1577574d 100644 --- a/prism/src/hybrid/PH_ProbReachRewardInterval.cc +++ b/prism/src/hybrid/PH_ProbReachRewardInterval.cc @@ -35,7 +35,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "IntervalIteration.h" #include "jnipointer.h" #include @@ -126,10 +126,10 @@ jint flags IntervalIteration helper(flags); if (!helper.flag_ensure_monotonic_from_above()) { - PH_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); } if (!helper.flag_ensure_monotonic_from_below()) { - PH_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); } // call iterative method @@ -170,7 +170,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_ProbTransient.cc b/prism/src/hybrid/PH_ProbTransient.cc index 50bd5d5bb8..f381018e2d 100644 --- a/prism/src/hybrid/PH_ProbTransient.cc +++ b/prism/src/hybrid/PH_ProbTransient.cc @@ -35,7 +35,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "Measures.h" #include @@ -104,18 +104,18 @@ jint time // time n = odd->eoff + odd->toff; // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(trans, rvars, cvars, num_rvars, odd, false); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -125,11 +125,11 @@ jint time // time } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); // for soln, we just use init (since we are free to modify/delete this vector) // we also report the memory usage of this vector here, even though it has already been created soln = init; @@ -137,10 +137,10 @@ jint time // time sum = new double[n]; kb = n*8.0/1024.0; kbt += 3*kb; - PH_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // get setup time stop = util_cpu_time(); @@ -151,7 +151,7 @@ jint time // time // start transient analysis iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < time && !done; iters++) { @@ -173,9 +173,9 @@ jint time // time // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)time); - if (do_ss_detect) PH_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)time); + if (do_ss_detect) PN_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -191,12 +191,12 @@ jint time // time time_taken = (double)(stop - start1)/1000; // print iters/timing info - if (done) PH_PrintToMainLog(env, "\nSteady state detected at iteration %d\n", iters); - PH_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + if (done) PN_PrintToMainLog(env, "\nSteady state detected at iteration %d\n", iters); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_ProbUntil.cc b/prism/src/hybrid/PH_ProbUntil.cc index 0788dc14ba..8274dd84c9 100644 --- a/prism/src/hybrid/PH_ProbUntil.cc +++ b/prism/src/hybrid/PH_ProbUntil.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include @@ -119,7 +119,7 @@ jlong __jlongpointer m // 'maybe' states // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_ProbUntilInterval.cc b/prism/src/hybrid/PH_ProbUntilInterval.cc index 51ca8ec9d8..665c2f3554 100644 --- a/prism/src/hybrid/PH_ProbUntilInterval.cc +++ b/prism/src/hybrid/PH_ProbUntilInterval.cc @@ -35,7 +35,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "IntervalIteration.h" #include "jnipointer.h" #include @@ -103,10 +103,10 @@ jint flags IntervalIteration helper(flags); if (!helper.flag_ensure_monotonic_from_above()) { - PH_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); } if (!helper.flag_ensure_monotonic_from_below()) { - PH_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); } // call iterative method @@ -138,7 +138,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_SOR.cc b/prism/src/hybrid/PH_SOR.cc index 9d9fa9b660..22edf8390c 100644 --- a/prism/src/hybrid/PH_SOR.cc +++ b/prism/src/hybrid/PH_SOR.cc @@ -35,7 +35,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -144,29 +144,29 @@ jboolean fwds // forwards or backwards? a = DD_ITE(ddman, id, DD_Constant(ddman, 0), a); // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(a, rvars, cvars, num_rvars, odd, true, transpose); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // split hdd matrix into blocks // nb: in terms of memory, this gets precedence over sparse matrices - PH_PrintToMainLog(env, "Splitting into blocks... "); + PN_PrintToMainLog(env, "Splitting into blocks... "); split_hdd_matrix(hddm, compact, false, transpose); compact_b = hddm->compact_b; rearrange_hdd_blocks(hddm, false); kb = hddm->mem_b; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, n=%d, nnz=%d%s] ", hddm->l_b, hddm->blocks->n, hddm->blocks->nnz, compact_b?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, n=%d, nnz=%d%s] ", hddm->l_b, hddm->blocks->n, hddm->blocks->nnz, compact_b?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, true, transpose); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -177,12 +177,12 @@ jboolean fwds // forwards or backwards? l_b_max = (hddm->l_b == hddm->num_levels); kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diags, either by extracting from mtbdd or // by doing (negative, non-diagonal) row sums of original A matrix (and then setting to 1 if sum is 0) - PH_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); if (!row_sums) { diags = DD_MaxAbstract(ddman, diags, cvars, num_cvars); diags_vec = mtbdd_to_double_vector(ddman, diags, rvars, num_rvars, odd); @@ -203,8 +203,8 @@ jboolean fwds // forwards or backwards? } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PH_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // invert diagonal if (!compact_d) { @@ -215,7 +215,7 @@ jboolean fwds // forwards or backwards? // build b vector (if present) if (b != NULL) { - PH_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -227,32 +227,32 @@ jboolean fwds // forwards or backwards? } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PH_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = mtbdd_to_double_vector(ddman, init, rvars, num_rvars, odd); soln2 = new double[hddm->blocks->max]; for (i = 0; i < hddm->blocks->max; i++) soln2[i] = 0; kb = (n*8.0/1024.0)+(hddm->blocks->max*8.0/1024.0); kbt += kb; - PH_PrintMemoryToMainLog(env, "[", (n*8.0/1024.0), ""); - PH_PrintMemoryToMainLog(env, " + ", (hddm->blocks->max*8.0/1024.0), ""); - PH_PrintMemoryToMainLog(env, " = ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", (n*8.0/1024.0), ""); + PN_PrintMemoryToMainLog(env, " + ", (hddm->blocks->max*8.0/1024.0), ""); + PN_PrintMemoryToMainLog(env, " = ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PH_SOR ("); title += (omega == 1.0)?"Gauss-Seidel": ("SOR omega=" + std::to_string(omega)); title += ")"; iterationExport.reset(new ExportIterations(title.c_str())); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln, n, 0); } @@ -265,7 +265,7 @@ jboolean fwds // forwards or backwards? // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -387,8 +387,8 @@ jboolean fwds // forwards or backwards? // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure->isRelative()?"relative ":"", measure->value()); - PH_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure->isRelative()?"relative ":"", measure->value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } } @@ -399,10 +399,10 @@ jboolean fwds // forwards or backwards? time_taken = (double)(stop - start1)/1000; // print iters/timing info - PH_PrintToMainLog(env, "\n%s%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%s%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error - if (!done) { delete[] soln; soln = NULL; PH_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } + if (!done) { delete[] soln; soln = NULL; PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } // the difference between vector values is not a reliable error bound // but we store it anyway in case it is useful for estimating a bound @@ -410,7 +410,7 @@ jboolean fwds // forwards or backwards? // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_SORInterval.cc b/prism/src/hybrid/PH_SORInterval.cc index e0a3146a4e..82f43a40b5 100644 --- a/prism/src/hybrid/PH_SORInterval.cc +++ b/prism/src/hybrid/PH_SORInterval.cc @@ -36,7 +36,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -125,7 +125,7 @@ jint flags MeasureSupNormInterval measure(term_crit == TERM_CRIT_RELATIVE); if (omega <= 0.0 || omega > 1.0) { - PH_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); + PN_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); return ptr_to_jlong(NULL); } @@ -158,29 +158,29 @@ jint flags a = DD_ITE(ddman, id, DD_Constant(ddman, 0), a); // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(a, rvars, cvars, num_rvars, odd, true, transpose); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // split hdd matrix into blocks // nb: in terms of memory, this gets precedence over sparse matrices - PH_PrintToMainLog(env, "Splitting into blocks... "); + PN_PrintToMainLog(env, "Splitting into blocks... "); split_hdd_matrix(hddm, compact, false, transpose); compact_b = hddm->compact_b; rearrange_hdd_blocks(hddm, false); kb = hddm->mem_b; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, n=%d, nnz=%d%s] ", hddm->l_b, hddm->blocks->n, hddm->blocks->nnz, compact_b?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, n=%d, nnz=%d%s] ", hddm->l_b, hddm->blocks->n, hddm->blocks->nnz, compact_b?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, true, transpose); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -191,12 +191,12 @@ jint flags l_b_max = (hddm->l_b == hddm->num_levels); kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diags, either by extracting from mtbdd or // by doing (negative, non-diagonal) row sums of original A matrix (and then setting to 1 if sum is 0) - PH_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); if (!row_sums) { diags = DD_MaxAbstract(ddman, diags, cvars, num_cvars); diags_vec = mtbdd_to_double_vector(ddman, diags, rvars, num_rvars, odd); @@ -217,8 +217,8 @@ jint flags } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PH_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // invert diagonal if (!compact_d) { @@ -229,7 +229,7 @@ jint flags // build b vector (if present) if (b != NULL) { - PH_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -241,33 +241,33 @@ jint flags } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PH_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln_below = mtbdd_to_double_vector(ddman, lower, rvars, num_rvars, odd); soln_above = mtbdd_to_double_vector(ddman, upper, rvars, num_rvars, odd); soln2 = new double[hddm->blocks->max]; for (i = 0; i < hddm->blocks->max; i++) soln2[i] = 0; kb = 2*(n*8.0/1024.0)+(hddm->blocks->max*8.0/1024.0); kbt += kb; - PH_PrintMemoryToMainLog(env, "[2 x ", (n*8.0/1024.0), ""); - PH_PrintMemoryToMainLog(env, " + ", (hddm->blocks->max*8.0/1024.0), ""); - PH_PrintMemoryToMainLog(env, " = ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", (n*8.0/1024.0), ""); + PN_PrintMemoryToMainLog(env, " + ", (hddm->blocks->max*8.0/1024.0), ""); + PN_PrintMemoryToMainLog(env, " = ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PH_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PH_SORInterval ("); title += (omega == 1.0)?"Gauss-Seidel": ("SOR omega=" + std::to_string(omega)); title += ")"; iterationExport.reset(new ExportIterations(title.c_str())); - PH_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln_below, n, 0); iterationExport->exportVector(soln_above, n, 1); } @@ -281,7 +281,7 @@ jint flags // start iterations iters = 0; done = false; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -411,14 +411,14 @@ jint flags measure.reset(); measure.measure(soln_below, soln_above, n); if (measure.value() < term_crit_param) { - PH_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); done = true; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } } @@ -429,14 +429,14 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iters/timing info - PH_PrintToMainLog(env, "\n%s%s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%s%s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!done) { delete[] soln_below; soln_below = NULL; - PH_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); - PH_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); } if (helper.flag_select_midpoint() && soln_below) { // we did converge, select midpoint @@ -452,7 +452,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln_below) delete[] soln_below; soln_below = 0; } diff --git a/prism/src/hybrid/PH_StochBoundedUntil.cc b/prism/src/hybrid/PH_StochBoundedUntil.cc index c45393fb81..b74a218b73 100644 --- a/prism/src/hybrid/PH_StochBoundedUntil.cc +++ b/prism/src/hybrid/PH_StochBoundedUntil.cc @@ -35,7 +35,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "Measures.h" #include @@ -116,7 +116,7 @@ jlong __jlongpointer mu // probs for multiplying // count number of states to be made absorbing x = DD_GetNumMinterms(ddman, maybe, num_rvars); - PH_PrintToMainLog(env, "\nNumber of non-absorbing states: %.0f of %d (%.1f%%)\n", x, n, 100.0*(x/n)); + PN_PrintToMainLog(env, "\nNumber of non-absorbing states: %.0f of %d (%.1f%%)\n", x, n, 100.0*(x/n)); // filter out rows from rate matrix Cudd_Ref(trans); @@ -124,18 +124,18 @@ jlong __jlongpointer mu // probs for multiplying r = DD_Apply(ddman, APPLY_TIMES, trans, maybe); // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(r, rvars, cvars, num_rvars, odd, false); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -145,11 +145,11 @@ jlong __jlongpointer mu // probs for multiplying } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diagonals - PH_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); diags = hdd_negative_row_sums(hddm, n); compact_d = false; // try and convert to compact form if required @@ -161,8 +161,8 @@ jlong __jlongpointer mu // probs for multiplying } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PH_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); //for(i = 0; i < n; i++) printf("%f ", (!compact_d)?(diags[i]):(diags_dist->dist[diags_dist->ptrs[i]])); printf("\n"); // find max diagonal element @@ -177,8 +177,7 @@ jlong __jlongpointer mu // probs for multiplying // constant for uniformization unif = 1.02*max_diag; - last_unif = unif; - + // modify diagonals if (!compact_d) { for (i = 0; i < n; i++) diags[i] = diags[i] / unif + 1; @@ -187,13 +186,13 @@ jlong __jlongpointer mu // probs for multiplying } // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = mtbdd_to_double_vector(ddman, yes, rvars, num_rvars, odd); soln2 = new double[n]; sum = new double[n]; kb = n*8.0/1024.0; kbt += 3*kb; - PH_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); // multiply initial solution by 'mult' probs if (mult != NULL) { @@ -203,19 +202,19 @@ jlong __jlongpointer mu // probs for multiplying } // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // compute new termination criterion parameter (epsilon/8) term_crit_param_unif = term_crit_param / 8.0; // compute poisson probabilities (fox/glynn) - PH_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); + PN_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); fgw = fox_glynn(unif * time, 1.0e-300, 1.0e+300, term_crit_param_unif); if (fgw.right < 0) throw "Overflow in Fox-Glynn computation (time bound too big?)"; for (i = fgw.left; i <= fgw.right; i++) { fgw.weights[i-fgw.left] /= fgw.total_weight; } - PH_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); + PN_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); // set up vectors for (i = 0; i < n; i++) { @@ -231,7 +230,7 @@ jlong __jlongpointer mu // probs for multiplying // start transient analysis done = false; num_iters = -1; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // if necessary, do 0th element of summation (doesn't require any matrix powers) if (fgw.left == 0) for (i = 0; i < n; i++) { @@ -273,16 +272,16 @@ jlong __jlongpointer mu // probs for multiplying } // add to sum for (i = 0; i < n; i++) sum[i] += weight * soln2[i]; - PH_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); + PN_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); num_iters = iters; break; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); - if (do_ss_detect) PH_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); + if (do_ss_detect) PN_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -304,15 +303,15 @@ jlong __jlongpointer mu // probs for multiplying // print iters/timing info if (num_iters == -1) num_iters = fgw.right; - PH_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (sum) delete[] sum; sum = 0; } catch (const char *err) { - PH_SetErrorMessage("%s", err); + PN_SetErrorMessage("%s", err); if (sum) delete[] sum; sum = 0; } diff --git a/prism/src/hybrid/PH_StochCumulReward.cc b/prism/src/hybrid/PH_StochCumulReward.cc index 765d7ee061..d786022cda 100644 --- a/prism/src/hybrid/PH_StochCumulReward.cc +++ b/prism/src/hybrid/PH_StochCumulReward.cc @@ -35,7 +35,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "Measures.h" #include @@ -114,18 +114,18 @@ jdouble time // time bound n = odd->eoff + odd->toff; // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(trans, rvars, cvars, num_rvars, odd, false); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -135,11 +135,11 @@ jdouble time // time bound } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diagonals - PH_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); diags = hdd_negative_row_sums(hddm, n); compact_d = false; // try and convert to compact form if required @@ -151,8 +151,8 @@ jdouble time // time bound } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PH_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // find max diagonal element if (!compact_d) { @@ -166,8 +166,7 @@ jdouble time // time bound // constant for uniformization unif = 1.02*max_diag; - last_unif = unif; - + // modify diagonals if (!compact_d) { for (i = 0; i < n; i++) diags[i] = diags[i] / unif + 1; @@ -191,29 +190,29 @@ jdouble time // time bound Cudd_RecursiveDeref(ddman, tmp); // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); // soln has already been created and initialised to rewards vector as required // need to create soln2 and sum soln2 = new double[n]; sum = new double[n]; kb = n*8.0/1024.0; kbt += 3*kb; - PH_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // compute new termination criterion parameter (epsilon/8) term_crit_param_unif = term_crit_param / 8.0; // compute poisson probabilities (fox/glynn) - PH_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); + PN_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); fgw = fox_glynn(unif * time, 1.0e-300, 1.0e+300, term_crit_param_unif); if (fgw.right < 0) throw "Overflow in Fox-Glynn computation (time bound too big?)"; for (i = fgw.left; i <= fgw.right; i++) { fgw.weights[i-fgw.left] /= fgw.total_weight; } - PH_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); + PN_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); // modify the poisson probabilities to what we need for this computation // first make the kth value equal to the sum of the values for 0...k @@ -239,7 +238,7 @@ jdouble time // time bound // start transient analysis done = false; num_iters = -1; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // do 0th element of summation (doesn't require any matrix powers) if (fgw.left == 0) { @@ -284,16 +283,16 @@ jdouble time // time bound // add to sum for (i = 0; i < n; i++) sum[i] += weight * soln2[i]; - PH_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); + PN_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); num_iters = iters; break; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); - if (do_ss_detect) PH_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); + if (do_ss_detect) PN_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -317,15 +316,15 @@ jdouble time // time bound // print iters/timing info if (num_iters == -1) num_iters = fgw.right; - PH_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (sum) delete[] sum; sum = 0; } catch (const char *err) { - PH_SetErrorMessage("%s", err); + PN_SetErrorMessage("%s", err); if (sum) delete[] sum; sum = 0; } diff --git a/prism/src/hybrid/PH_StochSteadyState.cc b/prism/src/hybrid/PH_StochSteadyState.cc index ae34e39eca..fc23df695b 100644 --- a/prism/src/hybrid/PH_StochSteadyState.cc +++ b/prism/src/hybrid/PH_StochSteadyState.cc @@ -34,7 +34,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include @@ -101,7 +101,7 @@ jint num_cvars q = DD_Apply(ddman, APPLY_PLUS, trans, DD_Apply(ddman, APPLY_TIMES, DD_Identity(ddman, rvars, cvars, num_rvars), diags)); // build iteration matrix - PH_PrintToMainLog(env, "\nBuilding power method iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "\nBuilding power method iteration matrix MTBDD... "); // (includes a "fix" for when we are solving a subsystem e.g. BSCC) // (although i don't think we actually need this for the power method) Cudd_Ref(diags); @@ -109,7 +109,7 @@ jint num_cvars Cudd_Ref(q); a = DD_Apply(ddman, APPLY_PLUS, DD_Apply(ddman, APPLY_TIMES, DD_Constant(ddman, deltat), q), DD_Apply(ddman, APPLY_TIMES, DD_Identity(ddman, rvars, cvars, num_rvars), tmp)); i = DD_GetNumNodes(ddman, a); - PH_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]", i, i*20.0/1024.0); // deref unneeded mtbdds Cudd_RecursiveDeref(ddman, diags); @@ -163,7 +163,7 @@ jint num_cvars // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/hybrid/PH_StochTransient.cc b/prism/src/hybrid/PH_StochTransient.cc index b85670a032..2750edcb23 100644 --- a/prism/src/hybrid/PH_StochTransient.cc +++ b/prism/src/hybrid/PH_StochTransient.cc @@ -35,7 +35,7 @@ #include #include "sparse.h" #include "hybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "Measures.h" #include @@ -110,18 +110,18 @@ jdouble time // time bound n = odd->eoff + odd->toff; // build hdd for matrix - PH_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); + PN_PrintToMainLog(env, "\nBuilding hybrid MTBDD matrix... "); hddm = build_hdd_matrix(trans, rvars, cvars, num_rvars, odd, false); hdd = hddm->top; zero = hddm->zero; num_levels = hddm->num_levels; kb = hddm->mem_nodes; kbt = kb; - PH_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, nodes=%d] ", hddm->num_levels, hddm->num_nodes); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // add sparse matrices - PH_PrintToMainLog(env, "Adding explicit sparse matrices... "); + PN_PrintToMainLog(env, "Adding explicit sparse matrices... "); add_sparse_matrices(hddm, compact, false); compact_sm = hddm->compact_sm; if (compact_sm) { @@ -131,11 +131,11 @@ jdouble time // time bound } kb = hddm->mem_sm; kbt += kb; - PH_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[levels=%d, num=%d%s] ", hddm->l_sm, hddm->num_sm, compact_sm?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diagonals - PH_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); diags = hdd_negative_row_sums(hddm, n); compact_d = false; // try and convert to compact form if required @@ -147,8 +147,8 @@ jdouble time // time bound } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PH_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PH_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); //for(i = 0; i < n; i++) printf("%f ", (!compact_d)?(diags[i]):(diags_dist->dist[diags_dist->ptrs[i]])); printf("\n"); // find max diagonal element @@ -163,8 +163,7 @@ jdouble time // time bound // constant for uniformization unif = 1.02*max_diag; - last_unif = unif; - + // modify diagonals if (!compact_d) { for (i = 0; i < n; i++) diags[i] = diags[i] / unif + 1; @@ -173,7 +172,7 @@ jdouble time // time bound } // create solution/iteration vectors - PH_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); // for soln, we just use init (since we are free to modify/delete this vector) // we also report the memory usage of this vector here, even though it has already been created soln = init; @@ -181,22 +180,22 @@ jdouble time // time bound sum = new double[n]; kb = n*8.0/1024.0; kbt += 3*kb; - PH_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); // print total memory usage - PH_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // compute new termination criterion parameter (epsilon/8) term_crit_param_unif = term_crit_param / 8.0; // compute poisson probabilities (fox/glynn) - PH_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); + PN_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); fgw = fox_glynn(unif * time, 1.0e-300, 1.0e+300, term_crit_param_unif); if (fgw.right < 0) throw "Overflow in Fox-Glynn computation (time bound too big?)"; for (i = fgw.left; i <= fgw.right; i++) { fgw.weights[i-fgw.left] /= fgw.total_weight; } - PH_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); + PN_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); // set up vectors for (i = 0; i < n; i++) { @@ -212,7 +211,7 @@ jdouble time // time bound // start transient analysis done = false; num_iters = -1; - PH_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // if necessary, do 0th element of summation (doesn't require any matrix powers) if (fgw.left == 0) for (i = 0; i < n; i++) { @@ -254,16 +253,16 @@ jdouble time // time bound } // add to sum for (i = 0; i < n; i++) sum[i] += weight * soln2[i]; - PH_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); + PN_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); num_iters = iters; break; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PH_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); - if (do_ss_detect) PH_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); - PH_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); + if (do_ss_detect) PN_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -285,15 +284,15 @@ jdouble time // time bound // print iters/timing info if (num_iters == -1) num_iters = fgw.right; - PH_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PH_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (sum) delete[] sum; sum = 0; } catch (const char *err) { - PH_SetErrorMessage("%s", err); + PN_SetErrorMessage("%s", err); if (sum) delete[] sum; sum = 0; } diff --git a/prism/src/hybrid/PrismHybrid.cc b/prism/src/hybrid/PrismHybrid.cc deleted file mode 100644 index 0b2b087181..0000000000 --- a/prism/src/hybrid/PrismHybrid.cc +++ /dev/null @@ -1,258 +0,0 @@ -//============================================================================== -// -// Copyright (c) 2002- -// Authors: -// * Dave Parker (University of Oxford, formerly University of Birmingham) -// -//------------------------------------------------------------------------------ -// -// This file is part of PRISM. -// -// PRISM is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// PRISM is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with PRISM; if not, write to the Free Software Foundation, -// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -//============================================================================== - -#include "PrismHybrid.h" -#include -#include -#include -#include -#include -#include -#include "hybrid.h" -#include "PrismHybridGlob.h" -#include "jnipointer.h" - -#define MAX_LOG_STRING_LEN 1024 -#define MAX_ERR_STRING_LEN 1024 - -//------------------------------------------------------------------------------ -// hybrid engine global variables -//------------------------------------------------------------------------------ - -// cudd manager -DdManager *ddman; - -// logs -// global refs to log classes -static jclass main_log_cls = NULL; -static jclass tech_log_cls = NULL; -// global refs to log objects -static jobject main_log_obj = NULL; -static jobject tech_log_obj = NULL; -// method ids for print method in logs -static jmethodID main_log_mid = NULL; -static jmethodID main_log_warn = NULL; -static jmethodID tech_log_mid = NULL; - -// export stuff -static bool exportIterations = false; - -// error message -static char error_message[MAX_ERR_STRING_LEN]; - -// details from numerical computation which may be queried -double last_unif; - -//------------------------------------------------------------------------------ -// cudd manager -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_hybrid_PrismHybrid_PH_1SetCUDDManager(JNIEnv *env, jclass cls, jlong __jlongpointer ddm) -{ - ddman = jlong_to_DdManager(ddm); -} - -//------------------------------------------------------------------------------ -// logs -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_hybrid_PrismHybrid_PH_1SetMainLog(JNIEnv *env, jclass cls, jobject log) -{ - // if main log has been set previously, we need to delete existing global refs first - if (main_log_obj != NULL) { - env->DeleteGlobalRef(main_log_cls); - main_log_cls = NULL; - env->DeleteGlobalRef(main_log_obj); - main_log_obj = NULL; - } - - // make a global reference to the log object - main_log_obj = env->NewGlobalRef(log); - // get the log class and make a global reference to it - main_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(main_log_obj)); - // get the method id for the print method - main_log_mid = env->GetMethodID(main_log_cls, "print", "(Ljava/lang/String;)V"); - main_log_warn = env->GetMethodID(main_log_cls, "printWarning", "(Ljava/lang/String;)V"); -} - -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_hybrid_PrismHybrid_PH_1SetTechLog(JNIEnv *env, jclass cls, jobject log) -{ - // if tech log has been set previously, we need to delete existing global refs first - if (tech_log_obj != NULL) { - env->DeleteGlobalRef(tech_log_cls); - tech_log_cls = NULL; - env->DeleteGlobalRef(tech_log_obj); - tech_log_obj = NULL; - } - - // make a global reference to the log object - tech_log_obj = env->NewGlobalRef(log); - // get the log class and make a global reference to it - tech_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(tech_log_obj)); - // get the method id for the print method - tech_log_mid = env->GetMethodID(tech_log_cls, "print", "(Ljava/lang/String;)V"); -} - -//------------------------------------------------------------------------------ - -void PH_PrintToMainLog(JNIEnv *env, const char *str, ...) -{ - va_list argptr; - char full_string[MAX_LOG_STRING_LEN]; - - va_start(argptr, str); - vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); - va_end(argptr); - - if (env) - env->CallVoidMethod(main_log_obj, main_log_mid, env->NewStringUTF(full_string)); - else - printf("%s", full_string); -} - -//------------------------------------------------------------------------------ - -void PH_PrintWarningToMainLog(JNIEnv *env, const char *str, ...) -{ - va_list argptr; - char full_string[MAX_LOG_STRING_LEN]; - - va_start(argptr, str); - vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); - va_end(argptr); - - if (env) - env->CallVoidMethod(main_log_obj, main_log_warn, env->NewStringUTF(full_string)); - else - printf("\nWarning: %s\n", full_string); -} - -//------------------------------------------------------------------------------ - -void PH_PrintToTechLog(JNIEnv *env, const char *str, ...) -{ - va_list argptr; - char full_string[MAX_LOG_STRING_LEN]; - - va_start(argptr, str); - vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); - va_end(argptr); - - if (env) - env->CallVoidMethod(tech_log_obj, tech_log_mid, env->NewStringUTF(full_string)); - else - printf("%s", full_string); -} - -//------------------------------------------------------------------------------ - -// Print formatted memory info to main log - -void PH_PrintMemoryToMainLog(JNIEnv *env, const char *before, double mem, const char *after) -{ - char full_string[MAX_LOG_STRING_LEN]; - - if (mem > 1048576) - snprintf(full_string, MAX_LOG_STRING_LEN, "%s%.1f GB%s", before, mem/1048576.0, after); - else if (mem > 1024) - snprintf(full_string, MAX_LOG_STRING_LEN, "%s%.1f MB%s", before, mem/1024.0, after); - else - snprintf(full_string, MAX_LOG_STRING_LEN, "%s%.1f KB%s", before, mem, after); - - if (env) { - env->CallVoidMethod(main_log_obj, main_log_mid, env->NewStringUTF(full_string)); - } - else { - printf("%s", full_string); - } -} - -//------------------------------------------------------------------------------ -// error message handling -//------------------------------------------------------------------------------ - -void PH_SetErrorMessage(const char *str, ...) -{ - va_list argptr; - - va_start(argptr, str); - vsnprintf(error_message, MAX_ERR_STRING_LEN, str, argptr); - va_end(argptr); -} - -char *PH_GetErrorMessage() -{ - return error_message; -} - -JNIEXPORT jstring JNICALL Java_hybrid_PrismHybrid_PH_1GetErrorMessage(JNIEnv *env, jclass cls) -{ - return env->NewStringUTF(error_message); -} - -//------------------------------------------------------------------------------ -// export flags -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_hybrid_PrismHybrid_PH_1SetExportIterations(JNIEnv *env, jclass cls, jboolean value) -{ - exportIterations = value; -} - -bool PH_GetFlagExportIterations() -{ - return exportIterations; -} - -//------------------------------------------------------------------------------ -// numerical computation detail queries -//------------------------------------------------------------------------------ - -JNIEXPORT jdouble JNICALL Java_hybrid_PrismHybrid_PH_1GetLastUnif(JNIEnv *env, jclass cls) -{ - return last_unif; -} - -//------------------------------------------------------------------------------ -// tidy up -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_hybrid_PrismHybrid_PH_1FreeGlobalRefs(JNIEnv *env, jclass cls) -{ - // delete all global references - env->DeleteGlobalRef(main_log_cls); - main_log_cls = NULL; - env->DeleteGlobalRef(tech_log_cls); - tech_log_cls = NULL; - env->DeleteGlobalRef(main_log_obj); - main_log_obj = NULL; - env->DeleteGlobalRef(tech_log_obj); - tech_log_obj = NULL; -} - -//------------------------------------------------------------------------------ diff --git a/prism/src/hybrid/PrismHybrid.java b/prism/src/hybrid/PrismHybrid.java index 09675b2067..9938df8d9b 100644 --- a/prism/src/hybrid/PrismHybrid.java +++ b/prism/src/hybrid/PrismHybrid.java @@ -42,7 +42,7 @@ public class PrismHybrid static { try { - System.loadLibrary("prismhybrid"); + System.loadLibrary("prism"); } catch (UnsatisfiedLinkError e) { System.out.println(e); @@ -51,25 +51,9 @@ public class PrismHybrid } //------------------------------------------------------------------------------ - // initialise/close down methods + // Local utility methods //------------------------------------------------------------------------------ - public static void initialise(PrismLog mainLog, PrismLog techLog) - { - setCUDDManager(); - setMainLog(mainLog); - setTechLog(techLog); - } - - public static void closeDown() - { - // tidy up any JNI stuff - PH_FreeGlobalRefs(); - } - - // tidy up in jni (free global references) - private static native void PH_FreeGlobalRefs(); - /** * Check that number of reachable states is in a range that can be handled by * the hybrid engine methods. @@ -82,63 +66,13 @@ private static void checkNumStates(ODDNode odd) throws PrismNotSupportedExceptio ODDUtils.checkInt(odd, "Currently, the hybrid engine cannot handle models"); } - //------------------------------------------------------------------------------ - // cudd manager - //------------------------------------------------------------------------------ - - // cudd manager - - // jni method to set cudd manager for native code - private static native void PH_SetCUDDManager(long ddm); - public static void setCUDDManager() - { - PH_SetCUDDManager(JDD.GetCUDDManager()); - } - - //------------------------------------------------------------------------------ - // logs - //------------------------------------------------------------------------------ - - // main log - - // place to store main log for java code - private static PrismLog mainLog; - // jni method to set main log for native code - private static native void PH_SetMainLog(PrismLog log); - // method to set main log both in java and c++ - public static void setMainLog(PrismLog log) - { - mainLog = log; - PH_SetMainLog(log); - } - - // tech log - - // place to store tech log for java code - private static PrismLog techLog; - // jni method to set tech log for native code - private static native void PH_SetTechLog(PrismLog log); - // method to set tech log both in java and c++ - public static void setTechLog(PrismLog log) - { - techLog = log; - PH_SetTechLog(log); - } - - private static native void PH_SetExportIterations(boolean value); - public static void SetExportIterations(boolean value) - { - PH_SetExportIterations(value); - } - //------------------------------------------------------------------------------ // error message //------------------------------------------------------------------------------ - private static native String PH_GetErrorMessage(); public static String getErrorMessage() { - return PH_GetErrorMessage(); + return PrismNative.PN_GetErrorMessage(); } /** @@ -157,16 +91,6 @@ private static PrismException generateExceptionForError() } } - //------------------------------------------------------------------------------ - // numerical computation detail queries - //------------------------------------------------------------------------------ - - private static native double PH_GetLastUnif(); - public static double getLastUnif() - { - return PH_GetLastUnif(); - } - //------------------------------------------------------------------------------ // JNI wrappers for blocks of hybrid code //------------------------------------------------------------------------------ diff --git a/prism/src/hybrid/hybrid.cc b/prism/src/hybrid/hybrid.cc index e081001966..4876fa04c4 100644 --- a/prism/src/hybrid/hybrid.cc +++ b/prism/src/hybrid/hybrid.cc @@ -29,7 +29,7 @@ #include "sparse.h" #include "hybrid.h" #include "PrismHybrid.h" -#include "PrismHybridGlob.h" +#include "PrismNativeGlob.h" #include #include diff --git a/prism/src/jdd/JDD.cc b/prism/src/jdd/JDD.cc index 080d9fdbaf..e831aab820 100644 --- a/prism/src/jdd/JDD.cc +++ b/prism/src/jdd/JDD.cc @@ -38,6 +38,8 @@ //------------------------------------------------------------------------------ +// CUDD manager: cached here locally, so that it doesn't have to be passed to every +// CUDD/dd call. Extracted from underlying CUDD lib on call to InitialiseCUDD static DdManager *ddman; //------------------------------------------------------------------------------ diff --git a/prism/src/jdd/JDD.java b/prism/src/jdd/JDD.java index 8ea23fc7c4..71eb58aed7 100644 --- a/prism/src/jdd/JDD.java +++ b/prism/src/jdd/JDD.java @@ -149,7 +149,7 @@ public static class CuddOutOfMemoryException extends RuntimeException { static { try { - System.loadLibrary("jdd"); + System.loadLibrary("prism"); } catch (UnsatisfiedLinkError e) { System.out.println(e); diff --git a/prism/src/jdd/JDDNode.java b/prism/src/jdd/JDDNode.java index 13ae3025e3..a2f8313d4e 100644 --- a/prism/src/jdd/JDDNode.java +++ b/prism/src/jdd/JDDNode.java @@ -42,7 +42,7 @@ public class JDDNode static { try { - System.loadLibrary("jdd"); + System.loadLibrary("prism"); } catch (UnsatisfiedLinkError e) { System.out.println(e); diff --git a/prism/src/jdd/JDDVars.java b/prism/src/jdd/JDDVars.java index 36b961dab8..ad239598da 100644 --- a/prism/src/jdd/JDDVars.java +++ b/prism/src/jdd/JDDVars.java @@ -53,7 +53,7 @@ public class JDDVars implements Iterable static { try { - System.loadLibrary("jdd"); + System.loadLibrary("prism"); } catch (UnsatisfiedLinkError e) { System.out.println(e); diff --git a/prism/src/jdd/Makefile b/prism/src/jdd/Makefile deleted file mode 100644 index 3bfdd39fd9..0000000000 --- a/prism/src/jdd/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = jdd -PRISM_DIR_REL = ../.. - -INCLUDES = \ --I$(PRISM_DIR_REL)/$(CUDD_DIR)/include \ --I"$(JAVA_JNI_H_DIR)" \ --I"$(JAVA_JNI_MD_H_DIR)" \ --I$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR) - -LIBRARIES = \ --L$(PRISM_DIR_REL)/$(PRISM_LIB_DIR) \ --ldd - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -CC_FILES = $(wildcard *.cc) -O_FILES = $(CC_FILES:%.cc=$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o) - -default: all - -all: checks $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)jdd$(LIBSUFFIX) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)jdd$(LIBSUFFIX): $(O_FILES) - $(LD) $(SHARED) $(LDFLAGS) -o $@ $(O_FILES) $(LIBRARIES) - -$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o: %.cc - $(CXX) $(CXXFLAGS) -c $< -o $@ $(INCLUDES) - -clean: checks - @rm -f $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)jdd$(LIBSUFFIX) $(O_FILES) - -celan: clean - -################################################# diff --git a/prism/src/jltl2ba/Makefile b/prism/src/jltl2ba/Makefile deleted file mode 100644 index 1566dee69b..0000000000 --- a/prism/src/jltl2ba/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = jltl2ba -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/src/jltl2dstar/Makefile b/prism/src/jltl2dstar/Makefile deleted file mode 100644 index f5666cf374..0000000000 --- a/prism/src/jltl2dstar/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = jltl2dstar -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/src/mtbdd/Makefile b/prism/src/mtbdd/Makefile deleted file mode 100644 index dd2f328749..0000000000 --- a/prism/src/mtbdd/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = mtbdd -PRISM_DIR_REL = ../.. - -INCLUDES = \ --I$(PRISM_DIR_REL)/$(CUDD_DIR)/include \ --I"$(JAVA_JNI_H_DIR)" \ --I"$(JAVA_JNI_MD_H_DIR)" \ --I$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR) - -LIBRARIES = \ --L$(PRISM_DIR_REL)/$(PRISM_LIB_DIR) \ --lodd \ --ldd \ --ldv \ --lprism \ -$(LIBMATH) - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -CC_FILES = $(wildcard *.cc) -O_FILES = $(CC_FILES:%.cc=$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o) - -default: all - -all: checks $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prismmtbdd$(LIBSUFFIX) - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prismmtbdd$(LIBSUFFIX): $(O_FILES) - $(LD) $(SHARED) $(LDFLAGS) -o $@ $(O_FILES) $(LIBRARIES) - -$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o: %.cc - $(CXX) $(CXXFLAGS) -c $< -o $@ $(INCLUDES) - -clean: checks - @rm -f $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prismmtbdd$(LIBSUFFIX) $(O_FILES) - -celan: clean - -################################################# diff --git a/prism/src/mtbdd/PM_ExportLabels.cc b/prism/src/mtbdd/PM_ExportLabels.cc index 0ccba09b9b..afecfe27b9 100644 --- a/prism/src/mtbdd/PM_ExportLabels.cc +++ b/prism/src/mtbdd/PM_ExportLabels.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ diff --git a/prism/src/mtbdd/PM_ExportMatrix.cc b/prism/src/mtbdd/PM_ExportMatrix.cc index ce192cbebc..8d2d8adc7c 100644 --- a/prism/src/mtbdd/PM_ExportMatrix.cc +++ b/prism/src/mtbdd/PM_ExportMatrix.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ diff --git a/prism/src/mtbdd/PM_ExportVector.cc b/prism/src/mtbdd/PM_ExportVector.cc index f2b0f6a9c2..2c09a39a16 100644 --- a/prism/src/mtbdd/PM_ExportVector.cc +++ b/prism/src/mtbdd/PM_ExportVector.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ diff --git a/prism/src/mtbdd/PM_JOR.cc b/prism/src/mtbdd/PM_JOR.cc index 177df48b93..8ee813aac7 100644 --- a/prism/src/mtbdd/PM_JOR.cc +++ b/prism/src/mtbdd/PM_JOR.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "ExportIterations.h" @@ -113,9 +113,9 @@ jdouble omega // omega (jor parameter) // print out some memory usage i = DD_GetNumNodes(ddman, a); - PM_PrintToMainLog(env, "\nIteration matrix MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "\nIteration matrix MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); i = DD_GetNumNodes(ddman, diags); - PM_PrintToMainLog(env, "Diagonals MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "Diagonals MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); // store initial solution, transposing if necessary Cudd_Ref(init); @@ -125,13 +125,13 @@ jdouble omega // omega (jor parameter) } std::unique_ptr iterationExport; - if (PM_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PM_JOR ("); title += (omega == 1.0)?"Jacobi": ("JOR omega=" + std::to_string(omega)); title += ")"; iterationExport.reset(new ExportIterations(title.c_str())); - PM_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(sol, (transpose?cvars:rvars), num_rvars, odd, 0); } @@ -144,7 +144,7 @@ jdouble omega // omega (jor parameter) // start iterations iters = 0; done = false; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -182,8 +182,8 @@ jdouble omega // omega (jor parameter) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d: ", iters); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: ", iters); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -222,7 +222,7 @@ jdouble omega // omega (jor parameter) time_taken = (double)(stop - start1)/1000; // print iters/timing info - PM_PrintToMainLog(env, "\n%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); // free memory Cudd_RecursiveDeref(ddman, id); @@ -231,7 +231,7 @@ jdouble omega // omega (jor parameter) Cudd_RecursiveDeref(ddman, b); // if the iterative method didn't terminate, this is an error - if (!done) { Cudd_RecursiveDeref(ddman, sol); PM_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); return 0; } + if (!done) { Cudd_RecursiveDeref(ddman, sol); PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); return 0; } return ptr_to_jlong(sol); } diff --git a/prism/src/mtbdd/PM_JORInterval.cc b/prism/src/mtbdd/PM_JORInterval.cc index 0ec8a9369c..edaf59ce37 100644 --- a/prism/src/mtbdd/PM_JORInterval.cc +++ b/prism/src/mtbdd/PM_JORInterval.cc @@ -32,7 +32,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "ExportIterations.h" @@ -80,7 +80,7 @@ jint flags bool done; if (omega <= 0.0 || omega > 1.0) { - PM_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); + PN_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); return ptr_to_jlong(NULL); } @@ -125,9 +125,9 @@ jint flags // print out some memory usage i = DD_GetNumNodes(ddman, a); - PM_PrintToMainLog(env, "\nIteration matrix MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "\nIteration matrix MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); i = DD_GetNumNodes(ddman, diags); - PM_PrintToMainLog(env, "Diagonals MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "Diagonals MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); // store initial solutions, transposing if necessary Cudd_Ref(lower); @@ -140,13 +140,13 @@ jint flags } std::unique_ptr iterationExport; - if (PM_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PM_JOR ("); title += (omega == 1.0)?"Jacobi": ("JOR omega=" + std::to_string(omega)); title += "), interval"; iterationExport.reset(new ExportIterations(title.c_str())); - PM_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(sol_below, (transpose?cvars:rvars), num_rvars, odd, 0); iterationExport->exportVector(sol_above, (transpose?cvars:rvars), num_rvars, odd, 1); } @@ -160,7 +160,7 @@ jint flags // start iterations iters = 0; done = false; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); bool below_unchanged = false, above_unchanged = false; @@ -236,8 +236,8 @@ jint flags // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d: ", iters); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: ", iters); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -254,7 +254,7 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iters/timing info - PM_PrintToMainLog(env, "\n%s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); DdNode *result; if (helper.flag_select_midpoint() && done) { // we did converge, select midpoint @@ -300,9 +300,9 @@ jint flags if (!done) { Cudd_RecursiveDeref(ddman, result); if (below_unchanged && above_unchanged) { - PM_SetErrorMessage("In interval iteration, after %d iterations, both lower and upper iteration did not change anymore but don't have the required precision yet.\nThis could be caused by the MTBDD's engine collapsing of similar constants, consider setting a smaller value for -cuddepsilon or -cuddepsilon 0 to disable collapsing", iters); + PN_SetErrorMessage("In interval iteration, after %d iterations, both lower and upper iteration did not change anymore but don't have the required precision yet.\nThis could be caused by the MTBDD's engine collapsing of similar constants, consider setting a smaller value for -cuddepsilon or -cuddepsilon 0 to disable collapsing", iters); } else { - PM_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } return 0; } diff --git a/prism/src/mtbdd/PM_NondetBoundedUntil.cc b/prism/src/mtbdd/PM_NondetBoundedUntil.cc index e03cdcc783..238aa4a6ca 100644 --- a/prism/src/mtbdd/PM_NondetBoundedUntil.cc +++ b/prism/src/mtbdd/PM_NondetBoundedUntil.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" @@ -78,12 +78,12 @@ jboolean min // min or max probabilities (true = min, false = max) start1 = start2 = util_cpu_time(); // get a - filter out rows - PM_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); Cudd_Ref(trans); Cudd_Ref(maybe); a = DD_Apply(ddman, APPLY_TIMES, trans, maybe); i = DD_GetNumNodes(ddman, a); - PM_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); // initial solution // (prob in 0 steps given by yes) @@ -97,7 +97,7 @@ jboolean min // min or max probabilities (true = min, false = max) start3 = stop; // start iterations - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -131,10 +131,10 @@ jboolean min // min or max probabilities (true = min, false = max) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PM_PrintToMainLog(env, "sol=%d nodes", DD_GetNumNodes(ddman, sol)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "sol=%d nodes", DD_GetNumNodes(ddman, sol)); // NB: but tmp was probably bigger than sol (pre min/max-abstract) - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -149,7 +149,7 @@ jboolean min // min or max probabilities (true = min, false = max) time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PM_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // free memory Cudd_RecursiveDeref(ddman, a); diff --git a/prism/src/mtbdd/PM_NondetInstReward.cc b/prism/src/mtbdd/PM_NondetInstReward.cc index ff9472943c..e00506678c 100644 --- a/prism/src/mtbdd/PM_NondetInstReward.cc +++ b/prism/src/mtbdd/PM_NondetInstReward.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" @@ -93,7 +93,7 @@ jlong __jlongpointer in // start iterations iters = 0; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how many iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -119,8 +119,8 @@ jlong __jlongpointer in // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -132,7 +132,7 @@ jlong __jlongpointer in // Cudd_Ref(init); // tmp = DD_Apply(ddman, APPLY_TIMES, sol, init); // tmp = DD_SumAbstract(ddman, tmp, rvars, num_rvars); -// PM_PrintToMainLog(env, "%i: %f (%0.f, %0d)\n", iters, Cudd_V(tmp), DD_GetNumMinterms(ddman, sol, num_rvars), DD_GetNumNodes(ddman, sol)); +// PN_PrintToMainLog(env, "%i: %f (%0.f, %0d)\n", iters, Cudd_V(tmp), DD_GetNumMinterms(ddman, sol, num_rvars), DD_GetNumNodes(ddman, sol)); // Cudd_RecursiveDeref(ddman, tmp); } @@ -142,7 +142,7 @@ jlong __jlongpointer in time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PM_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // free memory Cudd_RecursiveDeref(ddman, new_mask); diff --git a/prism/src/mtbdd/PM_NondetReachReward.cc b/prism/src/mtbdd/PM_NondetReachReward.cc index dd5db61bab..1070e397f8 100644 --- a/prism/src/mtbdd/PM_NondetReachReward.cc +++ b/prism/src/mtbdd/PM_NondetReachReward.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "ExportIterations.h" @@ -88,7 +88,7 @@ jboolean min // min or max probabilities (true = min, false = max) // get reachable states reach = odd->dd; - PM_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); // filter out rows (goal states and infinity states) from matrix Cudd_Ref(trans); @@ -122,10 +122,10 @@ jboolean min // min or max probabilities (true = min, false = max) // print memory usage i = DD_GetNumNodes(ddman, a); - PM_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); std::unique_ptr iterationExport; - if (PM_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PM_NondetReachReward")); iterationExport->exportVector(sol, rvars, num_rvars, odd, 0); } @@ -139,7 +139,7 @@ jboolean min // min or max probabilities (true = min, false = max) // start iterations iters = 0; done = false; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -191,8 +191,8 @@ jboolean min // min or max probabilities (true = min, false = max) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d: ", iters); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: ", iters); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -226,7 +226,7 @@ jboolean min // min or max probabilities (true = min, false = max) time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PM_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // free memory Cudd_RecursiveDeref(ddman, a); @@ -234,7 +234,7 @@ jboolean min // min or max probabilities (true = min, false = max) Cudd_RecursiveDeref(ddman, new_mask); // if the iterative method didn't terminate, this is an error - if (!done) { Cudd_RecursiveDeref(ddman, sol); PM_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); return 0; } + if (!done) { Cudd_RecursiveDeref(ddman, sol); PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); return 0; } return ptr_to_jlong(sol); } diff --git a/prism/src/mtbdd/PM_NondetReachRewardInterval.cc b/prism/src/mtbdd/PM_NondetReachRewardInterval.cc index d157ad4a75..8b0ac33c6f 100644 --- a/prism/src/mtbdd/PM_NondetReachRewardInterval.cc +++ b/prism/src/mtbdd/PM_NondetReachRewardInterval.cc @@ -32,7 +32,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "ExportIterations.h" @@ -91,10 +91,10 @@ jint flags IntervalIteration helper(flags); if (!helper.flag_ensure_monotonic_from_above()) { - PM_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); } if (!helper.flag_ensure_monotonic_from_below()) { - PM_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); } // start clocks @@ -103,7 +103,7 @@ jint flags // get reachable states reach = odd->dd; - PM_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); // filter out rows (goal states and infinity states) from matrix Cudd_Ref(trans); @@ -145,10 +145,10 @@ jint flags // print memory usage i = DD_GetNumNodes(ddman, a); - PM_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); std::unique_ptr iterationExport; - if (PM_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PM_NondetReachReward (interval)")); iterationExport->exportVector(sol_below, rvars, num_rvars, odd, 0); iterationExport->exportVector(sol_above, rvars, num_rvars, odd, 1); @@ -163,7 +163,7 @@ jint flags // start iterations iters = 0; done = false; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); bool below_unchanged = false, above_unchanged = false; @@ -258,10 +258,10 @@ jint flags // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d: ", iters); - PM_PrintToMainLog(env, "sol_below=%d nodes sol_above=%d nodes", DD_GetNumNodes(ddman, sol_below), DD_GetNumNodes(ddman, sol_above)); + PN_PrintToMainLog(env, "Iteration %d: ", iters); + PN_PrintToMainLog(env, "sol_below=%d nodes sol_above=%d nodes", DD_GetNumNodes(ddman, sol_below), DD_GetNumNodes(ddman, sol_above)); // NB: but tmp was probably bigger than sol (pre min/max-abstract) - PM_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -278,7 +278,7 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PM_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); DdNode *result; if (helper.flag_select_midpoint() && done) { // we did converge, select midpoint @@ -323,9 +323,9 @@ jint flags if (!done) { Cudd_RecursiveDeref(ddman, result); if (below_unchanged && above_unchanged) { - PM_SetErrorMessage("In interval iteration, after %d iterations, both lower and upper iteration did not change anymore but don't have the required precision yet.\nThis could be caused by the MTBDD's engine collapsing of similar constants, consider setting a smaller value for -cuddepsilon or -cuddepsilon 0 to disable collapsing", iters); + PN_SetErrorMessage("In interval iteration, after %d iterations, both lower and upper iteration did not change anymore but don't have the required precision yet.\nThis could be caused by the MTBDD's engine collapsing of similar constants, consider setting a smaller value for -cuddepsilon or -cuddepsilon 0 to disable collapsing", iters); } else { - PM_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } return 0; } diff --git a/prism/src/mtbdd/PM_NondetUntil.cc b/prism/src/mtbdd/PM_NondetUntil.cc index b90fb81f3d..dc4e15757d 100644 --- a/prism/src/mtbdd/PM_NondetUntil.cc +++ b/prism/src/mtbdd/PM_NondetUntil.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "ExportIterations.h" @@ -80,12 +80,12 @@ jboolean min // min or max probabilities (true = min, false = max) start1 = start2 = util_cpu_time(); // get a - filter out rows - PM_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); Cudd_Ref(trans); Cudd_Ref(maybe); a = DD_Apply(ddman, APPLY_TIMES, trans, maybe); i = DD_GetNumNodes(ddman, a); - PM_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); // initial solution // (prob in 0 steps given by yes) @@ -93,7 +93,7 @@ jboolean min // min or max probabilities (true = min, false = max) sol = yes; std::unique_ptr iterationExport; - if (PM_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PM_NondetUntil")); iterationExport->exportVector(sol, rvars, num_rvars, odd, 0); } @@ -107,12 +107,12 @@ jboolean min // min or max probabilities (true = min, false = max) // start iterations iters = 0; done = false; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { // if (iters%20==0) { -// PM_PrintToMainLog(env, "Iteration %d:\n", iters); +// PN_PrintToMainLog(env, "Iteration %d:\n", iters); // DD_PrintTerminalsAndNumbers(ddman, sol, num_rvars); // } @@ -164,10 +164,10 @@ jboolean min // min or max probabilities (true = min, false = max) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d: ", iters); - PM_PrintToMainLog(env, "sol=%d nodes", DD_GetNumNodes(ddman, sol)); + PN_PrintToMainLog(env, "Iteration %d: ", iters); + PN_PrintToMainLog(env, "sol=%d nodes", DD_GetNumNodes(ddman, sol)); // NB: but tmp was probably bigger than sol (pre min/max-abstract) - PM_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -201,13 +201,13 @@ jboolean min // min or max probabilities (true = min, false = max) time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PM_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // free memory Cudd_RecursiveDeref(ddman, a); // if the iterative method didn't terminate, this is an error - if (!done) { Cudd_RecursiveDeref(ddman, sol); PM_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); return 0; } + if (!done) { Cudd_RecursiveDeref(ddman, sol); PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); return 0; } return ptr_to_jlong(sol); } diff --git a/prism/src/mtbdd/PM_NondetUntilInterval.cc b/prism/src/mtbdd/PM_NondetUntilInterval.cc index 908269e52e..bfefaaee33 100644 --- a/prism/src/mtbdd/PM_NondetUntilInterval.cc +++ b/prism/src/mtbdd/PM_NondetUntilInterval.cc @@ -32,7 +32,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "ExportIterations.h" @@ -85,12 +85,12 @@ jint flags start1 = start2 = util_cpu_time(); // get a - filter out rows - PM_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); Cudd_Ref(trans); Cudd_Ref(maybe); a = DD_Apply(ddman, APPLY_TIMES, trans, maybe); i = DD_GetNumNodes(ddman, a); - PM_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); // initial solution // (prob in 0 steps given by yes) @@ -103,7 +103,7 @@ jint flags sol_above = DD_Or(ddman, yes, maybe); std::unique_ptr iterationExport; - if (PM_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PM_NondetUntilInterval")); iterationExport->exportVector(sol_below, rvars, num_rvars, odd, 0); iterationExport->exportVector(sol_above, rvars, num_rvars, odd, 1); @@ -118,7 +118,7 @@ jint flags // start iterations iters = 0; done = false; - PM_PrintToMainLog(env, "\nStarting iterations (interval iteration)...\n"); + PN_PrintToMainLog(env, "\nStarting iterations (interval iteration)...\n"); bool below_unchanged = false, above_unchanged = false; @@ -126,7 +126,7 @@ jint flags below_unchanged = above_unchanged = false; // if (iters%20==0) { -// PM_PrintToMainLog(env, "Iteration %d:\n", iters); +// PN_PrintToMainLog(env, "Iteration %d:\n", iters); // DD_PrintTerminalsAndNumbers(ddman, sol, num_rvars); // } @@ -214,10 +214,10 @@ jint flags // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d: ", iters); - PM_PrintToMainLog(env, "sol_below=%d nodes sol_above=%d nodes", DD_GetNumNodes(ddman, sol_below), DD_GetNumNodes(ddman, sol_above)); + PN_PrintToMainLog(env, "Iteration %d: ", iters); + PN_PrintToMainLog(env, "sol_below=%d nodes sol_above=%d nodes", DD_GetNumNodes(ddman, sol_below), DD_GetNumNodes(ddman, sol_above)); // NB: but tmp was probably bigger than sol (pre min/max-abstract) - PM_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -234,7 +234,7 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PM_PrintToMainLog(env, "\nIterative method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); DdNode *result; if (helper.flag_select_midpoint() && done) { // we did converge, select midpoint @@ -277,9 +277,9 @@ jint flags if (!done) { Cudd_RecursiveDeref(ddman, result); if (below_unchanged && above_unchanged) { - PM_SetErrorMessage("In interval iteration, after %d iterations, both lower and upper iteration did not change anymore but don't have the required precision yet.\nThis could be caused by the MTBDD's engine collapsing of similar constants, consider setting a smaller value for -cuddepsilon or -cuddepsilon 0 to disable collapsing", iters); + PN_SetErrorMessage("In interval iteration, after %d iterations, both lower and upper iteration did not change anymore but don't have the required precision yet.\nThis could be caused by the MTBDD's engine collapsing of similar constants, consider setting a smaller value for -cuddepsilon or -cuddepsilon 0 to disable collapsing", iters); } else { - PM_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } return 0; } diff --git a/prism/src/mtbdd/PM_Power.cc b/prism/src/mtbdd/PM_Power.cc index 4d7f7ce59b..bb315ca76a 100644 --- a/prism/src/mtbdd/PM_Power.cc +++ b/prism/src/mtbdd/PM_Power.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "ExportIterations.h" @@ -83,7 +83,7 @@ jboolean transpose // transpose A? (i.e. solve xA=b not Ax=b?) // print out some memory usage i = DD_GetNumNodes(ddman, a); - PM_PrintToMainLog(env, "\nIteration matrix MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "\nIteration matrix MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); // transpose b if necessary if (transpose) { @@ -98,9 +98,9 @@ jboolean transpose // transpose A? (i.e. solve xA=b not Ax=b?) } std::unique_ptr iterationExport; - if (PM_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PM_Power")); - PM_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(sol, (transpose?cvars:rvars), num_rvars, odd, 0); } @@ -113,7 +113,7 @@ jboolean transpose // transpose A? (i.e. solve xA=b not Ax=b?) // start iterations iters = 0; done = false; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -146,8 +146,8 @@ jboolean transpose // transpose A? (i.e. solve xA=b not Ax=b?) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d: ", iters); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: ", iters); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -186,13 +186,13 @@ jboolean transpose // transpose A? (i.e. solve xA=b not Ax=b?) time_taken = (double)(stop - start1)/1000; // print iters/timing info - PM_PrintToMainLog(env, "\nPower method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nPower method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // free memory Cudd_RecursiveDeref(ddman, b); // if the iterative method didn't terminate, this is an error - if (!done) { Cudd_RecursiveDeref(ddman, sol); PM_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); return 0; } + if (!done) { Cudd_RecursiveDeref(ddman, sol); PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); return 0; } return ptr_to_jlong(sol); } diff --git a/prism/src/mtbdd/PM_PowerInterval.cc b/prism/src/mtbdd/PM_PowerInterval.cc index ac5533fe2c..94b5bd80f7 100644 --- a/prism/src/mtbdd/PM_PowerInterval.cc +++ b/prism/src/mtbdd/PM_PowerInterval.cc @@ -32,7 +32,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "ExportIterations.h" @@ -90,7 +90,7 @@ jint flags // print out some memory usage i = DD_GetNumNodes(ddman, a); - PM_PrintToMainLog(env, "\nIteration matrix MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "\nIteration matrix MTBDD... [nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); // transpose b if necessary if (transpose) { @@ -108,9 +108,9 @@ jint flags } std::unique_ptr iterationExport; - if (PM_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PM_Power (interval)")); - PM_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(sol_below, (transpose?cvars:rvars), num_rvars, odd, 0); iterationExport->exportVector(sol_above, (transpose?cvars:rvars), num_rvars, odd, 1); } @@ -124,7 +124,7 @@ jint flags // start iterations iters = 0; done = false; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); bool below_unchanged = false, above_unchanged = false; @@ -191,8 +191,8 @@ jint flags // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d: ", iters); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: ", iters); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } } @@ -208,7 +208,7 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iters/timing info - PM_PrintToMainLog(env, "\nPower method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nPower method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); DdNode *result; if (helper.flag_select_midpoint() && done) { // we did converge, select midpoint @@ -251,9 +251,9 @@ jint flags if (!done) { Cudd_RecursiveDeref(ddman, result); if (below_unchanged && above_unchanged) { - PM_SetErrorMessage("In interval iteration, after %d iterations, both lower and upper iteration did not change anymore but don't have the required precision yet.\nThis could be caused by the MTBDD's engine collapsing of similar constants, consider setting a smaller value for -cuddepsilon or -cuddepsilon 0 to disable collapsing", iters); + PN_SetErrorMessage("In interval iteration, after %d iterations, both lower and upper iteration did not change anymore but don't have the required precision yet.\nThis could be caused by the MTBDD's engine collapsing of similar constants, consider setting a smaller value for -cuddepsilon or -cuddepsilon 0 to disable collapsing", iters); } else { - PM_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } return 0; } diff --git a/prism/src/mtbdd/PM_Prob0.cc b/prism/src/mtbdd/PM_Prob0.cc index c9d891b63d..4a39577ef3 100644 --- a/prism/src/mtbdd/PM_Prob0.cc +++ b/prism/src/mtbdd/PM_Prob0.cc @@ -30,7 +30,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -114,7 +114,7 @@ jlong __jlongpointer psi // psi(b2) time_for_iters = time_taken; // print iterations/timing info - PM_PrintToMainLog(env, "\nProb0: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nProb0: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); return ptr_to_jlong(sol); } diff --git a/prism/src/mtbdd/PM_Prob0A.cc b/prism/src/mtbdd/PM_Prob0A.cc index 8611857863..f7f5b32c92 100644 --- a/prism/src/mtbdd/PM_Prob0A.cc +++ b/prism/src/mtbdd/PM_Prob0A.cc @@ -30,7 +30,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -123,7 +123,7 @@ jlong __jlongpointer psi // psi(b2) time_for_iters = time_taken; // print iterations/timing info - PM_PrintToMainLog(env, "\nProb0A: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nProb0A: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); return ptr_to_jlong(sol); } diff --git a/prism/src/mtbdd/PM_Prob0E.cc b/prism/src/mtbdd/PM_Prob0E.cc index c763cae60f..0d1ce0f8b0 100644 --- a/prism/src/mtbdd/PM_Prob0E.cc +++ b/prism/src/mtbdd/PM_Prob0E.cc @@ -30,7 +30,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -128,7 +128,7 @@ jlong __jlongpointer psi // psi(b2) time_for_iters = time_taken; // print iterations/timing info - PM_PrintToMainLog(env, "\nProb0E: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nProb0E: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); return ptr_to_jlong(sol); } diff --git a/prism/src/mtbdd/PM_Prob1.cc b/prism/src/mtbdd/PM_Prob1.cc index 07a71b4cf9..0719739836 100644 --- a/prism/src/mtbdd/PM_Prob1.cc +++ b/prism/src/mtbdd/PM_Prob1.cc @@ -30,7 +30,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -119,7 +119,7 @@ jlong __jlongpointer _no // no time_for_iters = time_taken; // print iterations/timing info - PM_PrintToMainLog(env, "\nProb1: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nProb1: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); return ptr_to_jlong(sol); } diff --git a/prism/src/mtbdd/PM_Prob1A.cc b/prism/src/mtbdd/PM_Prob1A.cc index ac116d2de2..98cdd6576a 100644 --- a/prism/src/mtbdd/PM_Prob1A.cc +++ b/prism/src/mtbdd/PM_Prob1A.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -129,7 +129,7 @@ jlong __jlongpointer psi // psi(b2) time_for_iters = time_taken; // print iterations/timing info - PM_PrintToMainLog(env, "\nProb1A: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nProb1A: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); Cudd_RecursiveDeref(ddman, notno); diff --git a/prism/src/mtbdd/PM_Prob1E.cc b/prism/src/mtbdd/PM_Prob1E.cc index 91d2fc428b..b9e0691f6d 100644 --- a/prism/src/mtbdd/PM_Prob1E.cc +++ b/prism/src/mtbdd/PM_Prob1E.cc @@ -30,7 +30,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -142,7 +142,7 @@ jlong __jlongpointer _no // no time_for_iters = time_taken; // print iterations/timing info - PM_PrintToMainLog(env, "\nProb1E: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nProb1E: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); return ptr_to_jlong(u); } diff --git a/prism/src/mtbdd/PM_ProbBoundedUntil.cc b/prism/src/mtbdd/PM_ProbBoundedUntil.cc index fbd4dfd9bb..6e964e1747 100644 --- a/prism/src/mtbdd/PM_ProbBoundedUntil.cc +++ b/prism/src/mtbdd/PM_ProbBoundedUntil.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" @@ -72,12 +72,12 @@ jint bound // time bound start1 = start2 = util_cpu_time(); // get a - filter out rows - PM_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "\nBuilding iteration matrix MTBDD... "); Cudd_Ref(trans); Cudd_Ref(maybe); a = DD_Apply(ddman, APPLY_TIMES, trans, maybe); i = DD_GetNumNodes(ddman, a); - PM_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]\n", i, i*20.0/1024.0); // initial solution // (prob in 0 steps given by yes) @@ -91,7 +91,7 @@ jint bound // time bound start3 = stop; // start iterations - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -107,8 +107,8 @@ jint bound // time bound // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -123,7 +123,7 @@ jint bound // time bound time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PM_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // free memory Cudd_RecursiveDeref(ddman, a); diff --git a/prism/src/mtbdd/PM_ProbCumulReward.cc b/prism/src/mtbdd/PM_ProbCumulReward.cc index 5436b7b3d8..84f7f705ff 100644 --- a/prism/src/mtbdd/PM_ProbCumulReward.cc +++ b/prism/src/mtbdd/PM_ProbCumulReward.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" @@ -90,7 +90,7 @@ jint bound // time bound start3 = stop; // start iterations - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -106,8 +106,8 @@ jint bound // time bound // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -122,7 +122,7 @@ jint bound // time bound time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PM_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // free memory Cudd_RecursiveDeref(ddman, all_rewards); diff --git a/prism/src/mtbdd/PM_ProbInstReward.cc b/prism/src/mtbdd/PM_ProbInstReward.cc index 3b835fb18b..431daa9e50 100644 --- a/prism/src/mtbdd/PM_ProbInstReward.cc +++ b/prism/src/mtbdd/PM_ProbInstReward.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" @@ -81,7 +81,7 @@ jint bound // time bound // start iterations iters = 0; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -94,8 +94,8 @@ jint bound // time bound // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -110,7 +110,7 @@ jint bound // time bound time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PM_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); return ptr_to_jlong(sol); } diff --git a/prism/src/mtbdd/PM_ProbReachReward.cc b/prism/src/mtbdd/PM_ProbReachReward.cc index fd1085c906..794edfdb2e 100644 --- a/prism/src/mtbdd/PM_ProbReachReward.cc +++ b/prism/src/mtbdd/PM_ProbReachReward.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -115,7 +115,7 @@ jlong __jlongpointer m // 'maybe' states break; default: // set error message and return NULL pointer after cleanup, below - PM_SetErrorMessage("Gauss-Seidel and its variants are currently not supported by the MTBDD engine"); + PN_SetErrorMessage("Gauss-Seidel and its variants are currently not supported by the MTBDD engine"); break; } diff --git a/prism/src/mtbdd/PM_ProbReachRewardInterval.cc b/prism/src/mtbdd/PM_ProbReachRewardInterval.cc index 4eee082ef7..677b2b6a81 100644 --- a/prism/src/mtbdd/PM_ProbReachRewardInterval.cc +++ b/prism/src/mtbdd/PM_ProbReachRewardInterval.cc @@ -32,7 +32,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "IntervalIteration.h" #include "jnipointer.h" @@ -110,10 +110,10 @@ jint flags IntervalIteration helper(flags); if (!helper.flag_ensure_monotonic_from_above()) { - PM_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); } if (!helper.flag_ensure_monotonic_from_below()) { - PM_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); } // call iterative method @@ -130,7 +130,7 @@ jint flags break; default: // set error message and return NULL pointer after cleanup, below - PM_SetErrorMessage("Gauss-Seidel and its variants are currently not supported by the MTBDD engine"); + PN_SetErrorMessage("Gauss-Seidel and its variants are currently not supported by the MTBDD engine"); break; } diff --git a/prism/src/mtbdd/PM_ProbTransient.cc b/prism/src/mtbdd/PM_ProbTransient.cc index 301d5a12b4..ab0c612e7d 100644 --- a/prism/src/mtbdd/PM_ProbTransient.cc +++ b/prism/src/mtbdd/PM_ProbTransient.cc @@ -32,7 +32,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -84,7 +84,7 @@ jint time // time // start iterations iters = 0; done = false; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < time && !done; iters++) { @@ -111,8 +111,8 @@ jint time // time // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)time); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)time); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -130,8 +130,8 @@ jint time // time time_taken = (double)(stop - start1)/1000; // print iterations/timing info - if (done) PM_PrintToMainLog(env, "\nSteady state detected at iteration %d\n", iters); - PM_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + if (done) PN_PrintToMainLog(env, "\nSteady state detected at iteration %d\n", iters); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // derefs // nb: we deref init, even though it is passed in as a param diff --git a/prism/src/mtbdd/PM_ProbUntil.cc b/prism/src/mtbdd/PM_ProbUntil.cc index 5bd86540a8..d1549b569e 100644 --- a/prism/src/mtbdd/PM_ProbUntil.cc +++ b/prism/src/mtbdd/PM_ProbUntil.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -95,7 +95,7 @@ jlong __jlongpointer m // 'maybe' states break; default: // set error message and return NULL pointer after cleanup, below - PM_SetErrorMessage("Gauss-Seidel and its variants are currently not supported by the MTBDD engine"); + PN_SetErrorMessage("Gauss-Seidel and its variants are currently not supported by the MTBDD engine"); break; } diff --git a/prism/src/mtbdd/PM_ProbUntilInterval.cc b/prism/src/mtbdd/PM_ProbUntilInterval.cc index c1ace0dac5..f8c3cd417f 100644 --- a/prism/src/mtbdd/PM_ProbUntilInterval.cc +++ b/prism/src/mtbdd/PM_ProbUntilInterval.cc @@ -32,7 +32,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "IntervalIteration.h" #include "jnipointer.h" @@ -94,10 +94,10 @@ jint flags IntervalIteration helper(flags); if (!helper.flag_ensure_monotonic_from_above()) { - PM_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); } if (!helper.flag_ensure_monotonic_from_below()) { - PM_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); } // call iterative method @@ -114,7 +114,7 @@ jint flags break; default: // set error message and return NULL pointer after cleanup, below - PM_SetErrorMessage("Gauss-Seidel and its variants are currently not supported by the MTBDD engine"); + PN_SetErrorMessage("Gauss-Seidel and its variants are currently not supported by the MTBDD engine"); break; } diff --git a/prism/src/mtbdd/PM_Reachability.cc b/prism/src/mtbdd/PM_Reachability.cc index 9ad7bb68c0..8555580c65 100644 --- a/prism/src/mtbdd/PM_Reachability.cc +++ b/prism/src/mtbdd/PM_Reachability.cc @@ -30,7 +30,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -82,9 +82,9 @@ jlong __jlongpointer s // start state iters++; // output info on progress if (info > 0) { - PM_PrintToMainLog(env, "Iteration %d:", iters); - PM_PrintToMainLog(env, " %0.f states", DD_GetNumMinterms(ddman, reach, num_rvars)); - PM_PrintToMainLog(env, " (%d nodes)", DD_GetNumNodes(ddman, reach)); + PN_PrintToMainLog(env, "Iteration %d:", iters); + PN_PrintToMainLog(env, " %0.f states", DD_GetNumMinterms(ddman, reach, num_rvars)); + PN_PrintToMainLog(env, " (%d nodes)", DD_GetNumNodes(ddman, reach)); start2 = util_cpu_time(); } // perform iteration @@ -108,7 +108,7 @@ jlong __jlongpointer s // start state // output info on progress if (info > 0) { stop = util_cpu_time(); - PM_PrintToMainLog(env, " (%.2f seconds)\n", (double)(stop - start2)/1000); + PN_PrintToMainLog(env, " (%.2f seconds)\n", (double)(stop - start2)/1000); } } reach = DD_PermuteVariables(ddman, reach, cvars, rvars, num_cvars); @@ -127,9 +127,9 @@ jlong __jlongpointer s // start state iters++; // output info on progress if (info > 0) { - PM_PrintToMainLog(env, "Iteration %d:", iters); - PM_PrintToMainLog(env, " %0.f states", DD_GetNumMinterms(ddman, reach, num_rvars)); - PM_PrintToMainLog(env, " (%d nodes)", DD_GetNumNodes(ddman, reach)); + PN_PrintToMainLog(env, "Iteration %d:", iters); + PN_PrintToMainLog(env, " %0.f states", DD_GetNumMinterms(ddman, reach, num_rvars)); + PN_PrintToMainLog(env, " (%d nodes)", DD_GetNumNodes(ddman, reach)); start2 = util_cpu_time(); } // perform iteration @@ -158,7 +158,7 @@ jlong __jlongpointer s // start state // output info on progress if (info > 0) { stop = util_cpu_time(); - PM_PrintToMainLog(env, " (%.2f seconds)\n", (double)(stop - start2)/1000); + PN_PrintToMainLog(env, " (%.2f seconds)\n", (double)(stop - start2)/1000); } } reach = DD_PermuteVariables(ddman, reach, cvars, rvars, num_cvars); @@ -173,7 +173,7 @@ jlong __jlongpointer s // start state time_for_iters = time_taken; // print iterations/timing info - PM_PrintToMainLog(env, "\nReachability (%s): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", reach_method==REACH_BFS?"BFS":"frontier", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nReachability (%s): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", reach_method==REACH_BFS?"BFS":"frontier", iters, time_taken, time_for_iters/iters, time_for_setup); return ptr_to_jlong(reach); } diff --git a/prism/src/mtbdd/PM_StochBoundedUntil.cc b/prism/src/mtbdd/PM_StochBoundedUntil.cc index 3ea647ff28..412a499fc8 100644 --- a/prism/src/mtbdd/PM_StochBoundedUntil.cc +++ b/prism/src/mtbdd/PM_StochBoundedUntil.cc @@ -32,7 +32,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -91,19 +91,19 @@ jlong __jlongpointer mu // probs for multiplying // count number of states to be made absorbing x = DD_GetNumMinterms(ddman, maybe, num_cvars); - PM_PrintToMainLog(env, "\nNumber of non-absorbing states: %.0f of %d (%.1f%%)\n", x, n, 100.0*x/n); + PN_PrintToMainLog(env, "\nNumber of non-absorbing states: %.0f of %d (%.1f%%)\n", x, n, 100.0*x/n); // compute diagonals - PM_PrintToMainLog(env, "\nComputing diagonals MTBDD... "); + PN_PrintToMainLog(env, "\nComputing diagonals MTBDD... "); Cudd_Ref(trans); diags = DD_SumAbstract(ddman, trans, cvars, num_rvars); diags = DD_Apply(ddman, APPLY_TIMES, diags, DD_Constant(ddman, -1)); i = DD_GetNumNodes(ddman, diags); - PM_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); if (combine) { - PM_PrintToMainLog(env, "Building iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "Building iteration matrix MTBDD... "); // METHOD 1 (combine rate matrix and diagonals) @@ -114,7 +114,7 @@ jlong __jlongpointer mu // probs for multiplying Cudd_Ref(trans); Cudd_Ref(diags); q = DD_Apply(ddman, APPLY_PLUS, trans, DD_Apply(ddman, APPLY_TIMES, DD_Identity(ddman, rvars, cvars, num_rvars), diags)); -// PM_PrintToMainLog(env, "Q = %d %d %.0f\n", DD_GetNumNodes(ddman, q), DD_GetNumTerminals(ddman, q), DD_GetNumMinterms(ddman, q, num_rvars+num_cvars)); +// PN_PrintToMainLog(env, "Q = %d %d %.0f\n", DD_GetNumNodes(ddman, q), DD_GetNumTerminals(ddman, q), DD_GetNumMinterms(ddman, q, num_rvars+num_cvars)); // filter out rows Cudd_Ref(maybe); @@ -134,24 +134,24 @@ jlong __jlongpointer mu // probs for multiplying q = DD_Apply(ddman, APPLY_DIVIDE, q, DD_Constant(ddman, unif)); Cudd_Ref(reach); q = DD_Apply(ddman, APPLY_PLUS, q, DD_Apply(ddman, APPLY_TIMES, DD_Identity(ddman, rvars, cvars, num_rvars), reach)); -// PM_PrintToMainLog(env, "Q (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, q), DD_GetNumTerminals(ddman, q), DD_GetNumMinterms(ddman, q, num_rvars+num_cvars)); +// PN_PrintToMainLog(env, "Q (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, q), DD_GetNumTerminals(ddman, q), DD_GetNumMinterms(ddman, q, num_rvars+num_cvars)); i = DD_GetNumNodes(ddman, q); - PM_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); } else { // METHOD 2 (keep rate matrix and diagonals separate) - PM_PrintToMainLog(env, "Building iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "Building iteration matrix MTBDD... "); // copy trans/diags Cudd_Ref(trans); r = trans; Cudd_Ref(diags); d = diags; -// PM_PrintToMainLog(env, "r = %d %d %.0f\n", DD_GetNumNodes(ddman, r), DD_GetNumTerminals(ddman, r), DD_GetNumMinterms(ddman, r, num_rvars+num_cvars)); -// PM_PrintToMainLog(env, "diags = %d %d %.0f\n", DD_GetNumNodes(ddman, d), DD_GetNumTerminals(ddman, d), DD_GetNumMinterms(ddman, d, num_rvars)); +// PN_PrintToMainLog(env, "r = %d %d %.0f\n", DD_GetNumNodes(ddman, r), DD_GetNumTerminals(ddman, r), DD_GetNumMinterms(ddman, r, num_rvars+num_cvars)); +// PN_PrintToMainLog(env, "diags = %d %d %.0f\n", DD_GetNumNodes(ddman, d), DD_GetNumTerminals(ddman, d), DD_GetNumMinterms(ddman, d, num_rvars)); // filter out rows Cudd_Ref(maybe); @@ -170,21 +170,21 @@ jlong __jlongpointer mu // probs for multiplying d = DD_Apply(ddman, APPLY_DIVIDE, d, DD_Constant(ddman, unif)); Cudd_Ref(reach); d = DD_Apply(ddman, APPLY_PLUS, d, reach); -// PM_PrintToMainLog(env, "r (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, r), DD_GetNumTerminals(ddman, r), DD_GetNumMinterms(ddman, r, num_rvars+num_cvars)); -// PM_PrintToMainLog(env, "diags (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, d), DD_GetNumTerminals(ddman, d), DD_GetNumMinterms(ddman, d, num_rvars)); +// PN_PrintToMainLog(env, "r (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, r), DD_GetNumTerminals(ddman, r), DD_GetNumMinterms(ddman, r, num_rvars+num_cvars)); +// PN_PrintToMainLog(env, "diags (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, d), DD_GetNumTerminals(ddman, d), DD_GetNumMinterms(ddman, d, num_rvars)); i = DD_GetNumNodes(ddman, r); - PM_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); } // compute new termination criterion parameter (epsilon/8) term_crit_param_unif = term_crit_param / 8.0; // compute poisson probabilities (fox/glynn) - PM_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); + PN_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); fgw = fox_glynn(unif * time, 1.0e-300, 1.0e+300, term_crit_param_unif); if (fgw.right < 0) { - PM_SetErrorMessage("Overflow in Fox-Glynn computation (time bound too big?)"); + PN_SetErrorMessage("Overflow in Fox-Glynn computation (time bound too big?)"); if (combine) { // METHOD 1 @@ -201,12 +201,12 @@ jlong __jlongpointer mu // probs for multiplying for (i = fgw.left; i <= fgw.right; i++) { fgw.weights[i-fgw.left] /= fgw.total_weight; } - PM_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); + PN_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); -// PM_PrintToMainLog(env, "right-left = %d\n", fgw.right-fgw.left); -// PM_PrintToMainLog(env, "total_weight = %f\n", fgw.total_weight); +// PN_PrintToMainLog(env, "right-left = %d\n", fgw.right-fgw.left); +// PN_PrintToMainLog(env, "total_weight = %f\n", fgw.total_weight); // for (int i = 0; i < (fgw.right-fgw.left+1); i++) { -// PM_PrintToMainLog(env, "%.20f\n", fgw.weights[i]/fgw.total_weight); +// PN_PrintToMainLog(env, "%.20f\n", fgw.weights[i]/fgw.total_weight); // } // set up vectors @@ -229,9 +229,9 @@ jlong __jlongpointer mu // probs for multiplying // start iterations done = false; num_iters = -1; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); -// PM_PrintToMainLog(env, "Iteration 0: (%d %d %.0f)", DD_GetNumNodes(ddman, sol), DD_GetNumTerminals(ddman, sol), DD_GetNumMinterms(ddman, sol, num_rvars)); -// PM_PrintToMainLog(env, " (%d %d %.0f)\n", DD_GetNumNodes(ddman, sum), DD_GetNumTerminals(ddman, sum), DD_GetNumMinterms(ddman, sum, num_rvars)); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); +// PN_PrintToMainLog(env, "Iteration 0: (%d %d %.0f)", DD_GetNumNodes(ddman, sol), DD_GetNumTerminals(ddman, sol), DD_GetNumMinterms(ddman, sol, num_rvars)); +// PN_PrintToMainLog(env, " (%d %d %.0f)\n", DD_GetNumNodes(ddman, sum), DD_GetNumTerminals(ddman, sum), DD_GetNumMinterms(ddman, sum, num_rvars)); // if necessary, do 0th element of summation (doesn't require any matrix powers) if (fgw.left == 0) { @@ -269,8 +269,8 @@ jlong __jlongpointer mu // probs for multiplying } -// PM_PrintToMainLog(env, "(%d %d %.0f) ", DD_GetNumNodes(ddman, sol), DD_GetNumTerminals(ddman, sol), DD_GetNumMinterms(ddman, sol, num_rvars)); -// PM_PrintToMainLog(env, "(%d %d %.0f)\n", DD_GetNumNodes(ddman, sum), DD_GetNumTerminals(ddman, sum), DD_GetNumMinterms(ddman, sum, num_rvars)); +// PN_PrintToMainLog(env, "(%d %d %.0f) ", DD_GetNumNodes(ddman, sol), DD_GetNumTerminals(ddman, sol), DD_GetNumMinterms(ddman, sol, num_rvars)); +// PN_PrintToMainLog(env, "(%d %d %.0f)\n", DD_GetNumNodes(ddman, sum), DD_GetNumTerminals(ddman, sum), DD_GetNumMinterms(ddman, sum, num_rvars)); // check for steady state convergence if (do_ss_detect) switch (term_crit) { @@ -300,7 +300,7 @@ jlong __jlongpointer mu // probs for multiplying // add to sum Cudd_Ref(tmp); sum = DD_Apply(ddman, APPLY_PLUS, sum, DD_Apply(ddman, APPLY_TIMES, tmp, DD_Constant(ddman, weight))); - PM_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); + PN_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); num_iters = iters; Cudd_RecursiveDeref(ddman, tmp); break; @@ -308,8 +308,8 @@ jlong __jlongpointer mu // probs for multiplying // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -331,7 +331,7 @@ jlong __jlongpointer mu // probs for multiplying // print iterations/timing info if (num_iters == -1) num_iters = fgw.right; - PM_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); // free memory if (combine) { diff --git a/prism/src/mtbdd/PM_StochCumulReward.cc b/prism/src/mtbdd/PM_StochCumulReward.cc index 2498bf0c17..be90c56e83 100644 --- a/prism/src/mtbdd/PM_StochCumulReward.cc +++ b/prism/src/mtbdd/PM_StochCumulReward.cc @@ -32,7 +32,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -84,14 +84,14 @@ jdouble time // time bound reach = odd->dd; // compute diagonals - PM_PrintToMainLog(env, "\nComputing diagonals MTBDD... "); + PN_PrintToMainLog(env, "\nComputing diagonals MTBDD... "); Cudd_Ref(trans); diags = DD_SumAbstract(ddman, trans, cvars, num_rvars); diags = DD_Apply(ddman, APPLY_TIMES, diags, DD_Constant(ddman, -1)); i = DD_GetNumNodes(ddman, diags); - PM_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); - PM_PrintToMainLog(env, "Building iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "Building iteration matrix MTBDD... "); // build generator matrix q from trans and diags // note that any self loops are effectively removed because we include their rates @@ -112,7 +112,7 @@ jdouble time // time bound Cudd_Ref(reach); q = DD_Apply(ddman, APPLY_PLUS, q, DD_Apply(ddman, APPLY_TIMES, DD_Identity(ddman, rvars, cvars, num_rvars), reach)); i = DD_GetNumNodes(ddman, q); - PM_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); // combine state/transition rewards into a single vector - this is the initial solution vector Cudd_Ref(trans); @@ -129,10 +129,10 @@ jdouble time // time bound term_crit_param_unif = term_crit_param / 8.0; // compute poisson probabilities (fox/glynn) - PM_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); + PN_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); fgw = fox_glynn(unif * time, 1.0e-300, 1.0e+300, term_crit_param_unif); if (fgw.right < 0) { - PM_SetErrorMessage("Overflow in Fox-Glynn computation (time bound too big?)"); + PN_SetErrorMessage("Overflow in Fox-Glynn computation (time bound too big?)"); Cudd_RecursiveDeref(ddman, q); Cudd_RecursiveDeref(ddman, diags); Cudd_RecursiveDeref(ddman, sol); @@ -142,7 +142,7 @@ jdouble time // time bound for (i = fgw.left; i <= fgw.right; i++) { fgw.weights[i-fgw.left] /= fgw.total_weight; } - PM_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); + PN_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); // modify the poisson probabilities to what we need for this computation // first make the kth value equal to the sum of the values for 0...k @@ -163,7 +163,7 @@ jdouble time // time bound // start transient analysis done = false; num_iters = -1; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // do 0th element of summation (doesn't require any matrix powers) if (fgw.left == 0) { @@ -211,7 +211,7 @@ jdouble time // time bound // add to sum Cudd_Ref(tmp); sum = DD_Apply(ddman, APPLY_PLUS, sum, DD_Apply(ddman, APPLY_TIMES, tmp, DD_Constant(ddman, weight))); - PM_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); + PN_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); num_iters = iters; Cudd_RecursiveDeref(ddman, tmp); break; @@ -219,8 +219,8 @@ jdouble time // time bound // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -245,7 +245,7 @@ jdouble time // time bound // print iters/timing info if (num_iters == -1) num_iters = fgw.right; - PM_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); // free memory Cudd_RecursiveDeref(ddman, q); diff --git a/prism/src/mtbdd/PM_StochSteadyState.cc b/prism/src/mtbdd/PM_StochSteadyState.cc index 9c25d3987a..eea932dc01 100644 --- a/prism/src/mtbdd/PM_StochSteadyState.cc +++ b/prism/src/mtbdd/PM_StochSteadyState.cc @@ -31,7 +31,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -111,7 +111,7 @@ jint num_cvars break; default: // set error message and return NULL pointer after cleanup, below - PM_SetErrorMessage("Gauss-Seidel and its variants are currently not supported by the MTBDD engine"); + PN_SetErrorMessage("Gauss-Seidel and its variants are currently not supported by the MTBDD engine"); break; } diff --git a/prism/src/mtbdd/PM_StochTransient.cc b/prism/src/mtbdd/PM_StochTransient.cc index bf84a83320..169c2a5107 100644 --- a/prism/src/mtbdd/PM_StochTransient.cc +++ b/prism/src/mtbdd/PM_StochTransient.cc @@ -32,7 +32,7 @@ #include #include #include -#include "PrismMTBDDGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" //------------------------------------------------------------------------------ @@ -86,16 +86,16 @@ jdouble time // time reach = odd->dd; // compute diagonals - PM_PrintToMainLog(env, "\nComputing diagonals MTBDD... "); + PN_PrintToMainLog(env, "\nComputing diagonals MTBDD... "); Cudd_Ref(trans); diags = DD_SumAbstract(ddman, trans, cvars, num_rvars); diags = DD_Apply(ddman, APPLY_TIMES, diags, DD_Constant(ddman, -1)); i = DD_GetNumNodes(ddman, diags); - PM_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); if (combine) { - PM_PrintToMainLog(env, "Building iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "Building iteration matrix MTBDD... "); // METHOD 1 (combine rate matrix and diagonals) @@ -106,7 +106,7 @@ jdouble time // time Cudd_Ref(trans); Cudd_Ref(diags); q = DD_Apply(ddman, APPLY_PLUS, trans, DD_Apply(ddman, APPLY_TIMES, DD_Identity(ddman, rvars, cvars, num_rvars), diags)); -// PM_PrintToMainLog(env, "Q = %d %d %.0f\n", DD_GetNumNodes(ddman, q), DD_GetNumTerminals(ddman, q), DD_GetNumMinterms(ddman, q, num_rvars+num_cvars)); +// PN_PrintToMainLog(env, "Q = %d %d %.0f\n", DD_GetNumNodes(ddman, q), DD_GetNumTerminals(ddman, q), DD_GetNumMinterms(ddman, q, num_rvars+num_cvars)); // find max diagonal element max_diag = -DD_FindMin(ddman, diags); @@ -118,24 +118,24 @@ jdouble time // time q = DD_Apply(ddman, APPLY_DIVIDE, q, DD_Constant(ddman, unif)); Cudd_Ref(reach); q = DD_Apply(ddman, APPLY_PLUS, q, DD_Apply(ddman, APPLY_TIMES, DD_Identity(ddman, rvars, cvars, num_rvars), reach)); -// PM_PrintToMainLog(env, "Q (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, q), DD_GetNumTerminals(ddman, q), DD_GetNumMinterms(ddman, q, num_rvars+num_cvars)); +// PN_PrintToMainLog(env, "Q (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, q), DD_GetNumTerminals(ddman, q), DD_GetNumMinterms(ddman, q, num_rvars+num_cvars)); i = DD_GetNumNodes(ddman, q); - PM_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); } else { // METHOD 2 (keep rate matrix and diagonals separate) - PM_PrintToMainLog(env, "Building iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "Building iteration matrix MTBDD... "); // copy trans/diags Cudd_Ref(trans); r = trans; Cudd_Ref(diags); d = diags; -// PM_PrintToMainLog(env, "r = %d %d %.0f\n", DD_GetNumNodes(ddman, r), DD_GetNumTerminals(ddman, r), DD_GetNumMinterms(ddman, r, num_rvars+num_cvars)); -// PM_PrintToMainLog(env, "diags = %d %d %.0f\n", DD_GetNumNodes(ddman, d), DD_GetNumTerminals(ddman, d), DD_GetNumMinterms(ddman, d, num_rvars)); +// PN_PrintToMainLog(env, "r = %d %d %.0f\n", DD_GetNumNodes(ddman, r), DD_GetNumTerminals(ddman, r), DD_GetNumMinterms(ddman, r, num_rvars+num_cvars)); +// PN_PrintToMainLog(env, "diags = %d %d %.0f\n", DD_GetNumNodes(ddman, d), DD_GetNumTerminals(ddman, d), DD_GetNumMinterms(ddman, d, num_rvars)); // find max diagonal element max_diag = -DD_FindMin(ddman, d); @@ -148,24 +148,24 @@ jdouble time // time d = DD_Apply(ddman, APPLY_DIVIDE, d, DD_Constant(ddman, unif)); Cudd_Ref(reach); d = DD_Apply(ddman, APPLY_PLUS, d, reach); -// PM_PrintToMainLog(env, "r (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, r), DD_GetNumTerminals(ddman, r), DD_GetNumMinterms(ddman, r, num_rvars+num_cvars)); -// PM_PrintToMainLog(env, "diags (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, d), DD_GetNumTerminals(ddman, d), DD_GetNumMinterms(ddman, d, num_rvars)); +// PN_PrintToMainLog(env, "r (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, r), DD_GetNumTerminals(ddman, r), DD_GetNumMinterms(ddman, r, num_rvars+num_cvars)); +// PN_PrintToMainLog(env, "diags (final) = %d %d %.0f\n", DD_GetNumNodes(ddman, d), DD_GetNumTerminals(ddman, d), DD_GetNumMinterms(ddman, d, num_rvars)); // transpose diagonals diags = DD_PermuteVariables(ddman, diags, rvars, cvars, num_rvars); i = DD_GetNumNodes(ddman, r); - PM_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%ld] [%.1f Kb]\n", i, i*20.0/1024.0); } // compute new termination criterion parameter (epsilon/8) term_crit_param_unif = term_crit_param / 8.0; // compute poisson probabilities (fox/glynn) - PM_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); + PN_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); fgw = fox_glynn(unif * time, 1.0e-300, 1.0e+300, term_crit_param_unif); if (fgw.right < 0) { - PM_SetErrorMessage("Overflow in Fox-Glynn computation (time bound too big?)"); + PN_SetErrorMessage("Overflow in Fox-Glynn computation (time bound too big?)"); if (combine) { // METHOD 1 @@ -185,12 +185,12 @@ jdouble time // time for (i = fgw.left; i <= fgw.right; i++) { fgw.weights[i-fgw.left] /= fgw.total_weight; } - PM_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); + PN_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); -// PM_PrintToMainLog(env, "right-left = %d\n", fgw.right-fgw.left); -// PM_PrintToMainLog(env, "total_weight = %f\n", fgw.total_weight); +// PN_PrintToMainLog(env, "right-left = %d\n", fgw.right-fgw.left); +// PN_PrintToMainLog(env, "total_weight = %f\n", fgw.total_weight); // for (int i = 0; i < (fgw.right-fgw.left+1); i++) { -// PM_PrintToMainLog(env, "%.20f\n", fgw.weights[i]/fgw.total_weight); +// PN_PrintToMainLog(env, "%.20f\n", fgw.weights[i]/fgw.total_weight); // } // set up vectors @@ -208,9 +208,9 @@ jdouble time // time // start iterations done = false; num_iters = -1; - PM_PrintToMainLog(env, "\nStarting iterations...\n"); -// PM_PrintToMainLog(env, "Iteration 0: (%d %d %.0f)", DD_GetNumNodes(ddman, sol), DD_GetNumTerminals(ddman, sol), DD_GetNumMinterms(ddman, sol, num_rvars)); -// PM_PrintToMainLog(env, " (%d %d %.0f)\n", DD_GetNumNodes(ddman, sum), DD_GetNumTerminals(ddman, sum), DD_GetNumMinterms(ddman, sum, num_rvars)); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); +// PN_PrintToMainLog(env, "Iteration 0: (%d %d %.0f)", DD_GetNumNodes(ddman, sol), DD_GetNumTerminals(ddman, sol), DD_GetNumMinterms(ddman, sol, num_rvars)); +// PN_PrintToMainLog(env, " (%d %d %.0f)\n", DD_GetNumNodes(ddman, sum), DD_GetNumTerminals(ddman, sum), DD_GetNumMinterms(ddman, sum, num_rvars)); // if necessary, do 0th element of summation (doesn't require any matrix powers) if (fgw.left == 0) { @@ -248,8 +248,8 @@ jdouble time // time } -// PM_PrintToMainLog(env, "(%d %d %.0f) ", DD_GetNumNodes(ddman, sol), DD_GetNumTerminals(ddman, sol), DD_GetNumMinterms(ddman, sol, num_rvars)); -// PM_PrintToMainLog(env, "(%d %d %.0f)\n", DD_GetNumNodes(ddman, sum), DD_GetNumTerminals(ddman, sum), DD_GetNumMinterms(ddman, sum, num_rvars)); +// PN_PrintToMainLog(env, "(%d %d %.0f) ", DD_GetNumNodes(ddman, sol), DD_GetNumTerminals(ddman, sol), DD_GetNumMinterms(ddman, sol, num_rvars)); +// PN_PrintToMainLog(env, "(%d %d %.0f)\n", DD_GetNumNodes(ddman, sum), DD_GetNumTerminals(ddman, sum), DD_GetNumMinterms(ddman, sum, num_rvars)); // check for steady state convergence if (do_ss_detect) switch (term_crit) { @@ -279,7 +279,7 @@ jdouble time // time // add to sum Cudd_Ref(tmp); sum = DD_Apply(ddman, APPLY_PLUS, sum, DD_Apply(ddman, APPLY_TIMES, tmp, DD_Constant(ddman, weight))); - PM_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); + PN_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); num_iters = iters; Cudd_RecursiveDeref(ddman, tmp); break; @@ -287,8 +287,8 @@ jdouble time // time // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PM_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); - PM_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -313,7 +313,7 @@ jdouble time // time // print iterations/timing info if (num_iters == -1) num_iters = fgw.right; - PM_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); // free memory if (combine) { diff --git a/prism/src/mtbdd/PrismMTBDD.cc b/prism/src/mtbdd/PrismMTBDD.cc deleted file mode 100644 index 6ae7aec11f..0000000000 --- a/prism/src/mtbdd/PrismMTBDD.cc +++ /dev/null @@ -1,271 +0,0 @@ -//============================================================================== -// -// Copyright (c) 2002- -// Authors: -// * Dave Parker (University of Oxford, formerly University of Birmingham) -// -//------------------------------------------------------------------------------ -// -// This file is part of PRISM. -// -// PRISM is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// PRISM is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with PRISM; if not, write to the Free Software Foundation, -// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -//============================================================================== - -#include "PrismMTBDD.h" -#include -#include -#include -#include -#include -#include -#include -#include "PrismMTBDDGlob.h" -#include "jnipointer.h" - -#define MAX_LOG_STRING_LEN 1024 -#define MAX_ERR_STRING_LEN 1024 - -//------------------------------------------------------------------------------ -// mtbdd engine global variables -//------------------------------------------------------------------------------ - -// cudd manager -DdManager *ddman; - -// logs -// global refs to log classes -static jclass main_log_cls = NULL; -static jclass tech_log_cls = NULL; -// global refs to log objects -static jobject main_log_obj = NULL; -static jobject tech_log_obj = NULL; -// method ids for print method in logs -static jmethodID main_log_mid = NULL; -static jmethodID main_log_warn = NULL; -static jmethodID tech_log_mid = NULL; - -// export stuff -int export_type; -FILE *export_file; -JNIEnv *export_env; -static bool exportIterations = false; - -// error message -static char error_message[MAX_ERR_STRING_LEN]; - -//------------------------------------------------------------------------------ -// cudd manager -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_mtbdd_PrismMTBDD_PM_1SetCUDDManager(JNIEnv *env, jclass cls, jlong __jlongpointer ddm) -{ - ddman = jlong_to_DdManager(ddm); -} - -//------------------------------------------------------------------------------ -// logs -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_mtbdd_PrismMTBDD_PM_1SetMainLog(JNIEnv *env, jclass cls, jobject log) -{ - // if main log has been set previously, we need to delete existing global refs first - if (main_log_obj != NULL) { - env->DeleteGlobalRef(main_log_cls); - main_log_cls = NULL; - env->DeleteGlobalRef(main_log_obj); - main_log_obj = NULL; - } - - // make a global reference to the log object - main_log_obj = env->NewGlobalRef(log); - // get the log class and make a global reference to it - main_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(main_log_obj)); - // get the method id for the print method - main_log_mid = env->GetMethodID(main_log_cls, "print", "(Ljava/lang/String;)V"); - main_log_warn = env->GetMethodID(main_log_cls, "printWarning", "(Ljava/lang/String;)V"); -} - -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_mtbdd_PrismMTBDD_PM_1SetTechLog(JNIEnv *env, jclass cls, jobject log) -{ - // if tech log has been set previously, we need to delete existing global refs first - if (tech_log_obj != NULL) { - env->DeleteGlobalRef(tech_log_cls); - tech_log_cls = NULL; - env->DeleteGlobalRef(tech_log_obj); - tech_log_obj = NULL; - } - - // make a global reference to the log object - tech_log_obj = env->NewGlobalRef(log); - // get the log class and make a global reference to it - tech_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(tech_log_obj)); - // get the method id for the print method - tech_log_mid = env->GetMethodID(tech_log_cls, "print", "(Ljava/lang/String;)V"); -} - -//------------------------------------------------------------------------------ - -void PM_PrintToMainLog(JNIEnv *env, const char *str, ...) -{ - va_list argptr; - char full_string[MAX_LOG_STRING_LEN]; - - va_start(argptr, str); - vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); - va_end(argptr); - - if (env) - env->CallVoidMethod(main_log_obj, main_log_mid, env->NewStringUTF(full_string)); - else - printf("%s", full_string); -} - -//------------------------------------------------------------------------------ - -void PM_PrintWarningToMainLog(JNIEnv *env, const char *str, ...) -{ - va_list argptr; - char full_string[MAX_LOG_STRING_LEN]; - - va_start(argptr, str); - vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); - va_end(argptr); - - if (env) - env->CallVoidMethod(main_log_obj, main_log_warn, env->NewStringUTF(full_string)); - else - printf("\nWarning: %s\n", full_string); -} - -//------------------------------------------------------------------------------ - -void PM_PrintToTechLog(JNIEnv *env, const char *str, ...) -{ - va_list argptr; - char full_string[MAX_LOG_STRING_LEN]; - - va_start(argptr, str); - vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); - va_end(argptr); - - if (env) - env->CallVoidMethod(tech_log_obj, tech_log_mid, env->NewStringUTF(full_string)); - else - printf("%s", full_string); -} - -//------------------------------------------------------------------------------ -// export stuff -//------------------------------------------------------------------------------ - -// store export info globally -// returns 0 on failure, 1 otherwise - -int store_export_info(int type, jstring fn, JNIEnv *env) -{ - export_type = type; - if (fn) { - const char *filename = env->GetStringUTFChars(fn, 0); - export_file = fopen(filename, "w"); - if (!export_file) { - env->ReleaseStringUTFChars(fn, filename); - return 0; - } - env->ReleaseStringUTFChars(fn, filename); - } else { - export_file = NULL; - } - export_env = env; - return 1; -} - -//------------------------------------------------------------------------------ - -// export string (either to file or main log) - -void export_string(const char *str, ...) -{ - va_list argptr; - char full_string[MAX_LOG_STRING_LEN]; - - va_start(argptr, str); - vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); - va_end(argptr); - - if (export_file) { - fprintf(export_file, "%s", full_string); - } else { - PM_PrintToMainLog(export_env, "%s", full_string); - } -} - -//------------------------------------------------------------------------------ -// export flags -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_mtbdd_PrismMTBDD_PM_1SetExportIterations(JNIEnv *env, jclass cls, jboolean value) -{ - exportIterations = value; -} - -bool PM_GetFlagExportIterations() -{ - return exportIterations; -} - -//------------------------------------------------------------------------------ -// error message handling -//------------------------------------------------------------------------------ - -void PM_SetErrorMessage(const char *str, ...) -{ - va_list argptr; - - va_start(argptr, str); - vsnprintf(error_message, MAX_ERR_STRING_LEN, str, argptr); - va_end(argptr); -} - -char *PM_GetErrorMessage() -{ - return error_message; -} - -JNIEXPORT jstring JNICALL Java_mtbdd_PrismMTBDD_PM_1GetErrorMessage(JNIEnv *env, jclass cls) -{ - return env->NewStringUTF(error_message); -} - -//------------------------------------------------------------------------------ -// tidy up -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_mtbdd_PrismMTBDD_PM_1FreeGlobalRefs(JNIEnv *env, jclass cls) -{ - // delete all global references - env->DeleteGlobalRef(main_log_cls); - main_log_cls = NULL; - env->DeleteGlobalRef(tech_log_cls); - tech_log_cls = NULL; - env->DeleteGlobalRef(main_log_obj); - main_log_obj = NULL; - env->DeleteGlobalRef(tech_log_obj); - tech_log_obj = NULL; -} - -//------------------------------------------------------------------------------ diff --git a/prism/src/mtbdd/PrismMTBDD.java b/prism/src/mtbdd/PrismMTBDD.java index 712f740a76..ddd1964ce7 100644 --- a/prism/src/mtbdd/PrismMTBDD.java +++ b/prism/src/mtbdd/PrismMTBDD.java @@ -44,7 +44,7 @@ public class PrismMTBDD static { try { - System.loadLibrary("prismmtbdd"); + System.loadLibrary("prism"); } catch (UnsatisfiedLinkError e) { System.out.println(e); @@ -52,83 +52,13 @@ public class PrismMTBDD } } - //------------------------------------------------------------------------------ - // initialise/close down methods - //------------------------------------------------------------------------------ - - public static void initialise(PrismLog mainLog, PrismLog techLog) - { - setCUDDManager(); - setMainLog(mainLog); - setTechLog(techLog); - } - - public static void closeDown() - { - // tidy up any JNI stuff - PM_FreeGlobalRefs(); - } - - // tidy up in jni (free global references) - private static native void PM_FreeGlobalRefs(); - - //------------------------------------------------------------------------------ - // cudd manager - //------------------------------------------------------------------------------ - - // cudd manager - - // jni method to set cudd manager for native code - private static native void PM_SetCUDDManager(long ddm); - public static void setCUDDManager() - { - PM_SetCUDDManager(JDD.GetCUDDManager()); - } - - //------------------------------------------------------------------------------ - // logs - //------------------------------------------------------------------------------ - - // main log - - // place to store main log for java code - private static PrismLog mainLog; - // jni method to set main log for native code - private static native void PM_SetMainLog(PrismLog log); - // method to set main log both in java and c++ - public static void setMainLog(PrismLog log) - { - mainLog = log; - PM_SetMainLog(log); - } - - // tech log - - // place to store tech log for java code - private static PrismLog techLog; - // jni method to set tech log for native code - private static native void PM_SetTechLog(PrismLog log); - // method to set tech log both in java and c++ - public static void setTechLog(PrismLog log) - { - techLog = log; - PM_SetTechLog(log); - } - - private static native void PM_SetExportIterations(boolean value); - public static void SetExportIterations(boolean value) - { - PM_SetExportIterations(value); - } - //------------------------------------------------------------------------------ // error message //------------------------------------------------------------------------------ - private static native String PM_GetErrorMessage(); public static String getErrorMessage() { - return PM_GetErrorMessage(); + return PrismNative.PN_GetErrorMessage(); } /** diff --git a/prism/src/odd/Makefile b/prism/src/odd/Makefile deleted file mode 100644 index 54cfd0456b..0000000000 --- a/prism/src/odd/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = odd -PRISM_DIR_REL = ../.. - -INCLUDES = \ --I$(PRISM_DIR_REL)/$(CUDD_DIR)/include \ --I"$(JAVA_JNI_H_DIR)" \ --I"$(JAVA_JNI_MD_H_DIR)" \ --I$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR) - -LIBRARIES = \ --L$(PRISM_DIR_REL)/$(PRISM_LIB_DIR) \ --ldd - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -CC_FILES = $(wildcard *.cc) -O_FILES = $(CC_FILES:%.cc=$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)odd$(LIBSUFFIX) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)odd$(LIBSUFFIX): $(O_FILES) - $(LD) $(SHARED) $(LDFLAGS) -o $@ $(O_FILES) $(LIBRARIES) - -$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o: %.cc - $(CXX) $(CXXFLAGS) -c $< -o $@ $(INCLUDES) - -clean: checks - @rm -f $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)odd$(LIBSUFFIX) $(O_FILES) - -celan: clean - -################################################# diff --git a/prism/src/odd/ODDUtils.cc b/prism/src/odd/ODDUtils.cc index be7483a90b..1eda4dd381 100644 --- a/prism/src/odd/ODDUtils.cc +++ b/prism/src/odd/ODDUtils.cc @@ -26,22 +26,9 @@ #include "odd.h" #include "ODDUtils.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" -//------------------------------------------------------------------------------ - -// cudd manager -DdManager *ddman; - -//------------------------------------------------------------------------------ -// cudd manager -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_odd_ODDUtils_ODD_1SetCUDDManager(JNIEnv *env, jclass cls, jlong __jlongpointer ddm) -{ - ddman = jlong_to_DdManager(ddm); -} - //------------------------------------------------------------------------------ // build odd //------------------------------------------------------------------------------ diff --git a/prism/src/odd/ODDUtils.java b/prism/src/odd/ODDUtils.java index d149476a21..c12751a593 100644 --- a/prism/src/odd/ODDUtils.java +++ b/prism/src/odd/ODDUtils.java @@ -39,7 +39,7 @@ public class ODDUtils static { try { - System.loadLibrary("odd"); + System.loadLibrary("prism"); } catch (UnsatisfiedLinkError e) { System.out.println(e); @@ -47,19 +47,6 @@ public class ODDUtils } } - //------------------------------------------------------------------------------ - // cudd manager - //------------------------------------------------------------------------------ - - // cudd manager - - // jni method to set cudd manager for native code - private static native void ODD_SetCUDDManager(long ddm); - public static void setCUDDManager() - { - ODD_SetCUDDManager(JDD.GetCUDDManager()); - } - //------------------------------------------------------------------------------ // JNI wrappers //------------------------------------------------------------------------------ diff --git a/prism/src/param/Makefile b/prism/src/param/Makefile deleted file mode 100644 index a2dea28391..0000000000 --- a/prism/src/param/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = param -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -#PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/commons-math3-3.0.jar:$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/blas.jar:$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/lapack.jar:$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/xerbla.jar:$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/f2jutil.jar" -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/src/parser/Makefile b/prism/src/parser/Makefile deleted file mode 100644 index 3d5bd695bd..0000000000 --- a/prism/src/parser/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = parser -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java ast/*.java type/*.java visitor/*.java) -JAVA_FILES = $(patsubst %package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks PrismParser.java Prism3To4.java $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -PrismParser.java: PrismParser.jj - $(JAVACC) $< || echo "Warning: Did not recompile PrismParser.jj" - -Prism3To4.java: Prism3To4.jj - $(JAVACC) $< || echo "Warning: Did not recompile Prism3To4.jj" - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -touch: checks - @touch PrismParser.jj - -celan: clean - -################################################# diff --git a/prism/src/pepa/compiler/Makefile b/prism/src/pepa/compiler/Makefile deleted file mode 100644 index 6f742c3d4d..0000000000 --- a/prism/src/pepa/compiler/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = pepa/compiler -PRISM_DIR_REL = ../../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ../..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/src/prism/Makefile b/prism/src/prism/Makefile deleted file mode 100644 index ecc325baab..0000000000 --- a/prism/src/prism/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = prism -PRISM_DIR_REL = ../.. - -INCLUDES = \ --I"$(JAVA_JNI_H_DIR)" \ --I"$(JAVA_JNI_MD_H_DIR)" \ --I$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR) - -LIBRARIES = \ -$(LIBMATH) - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -CC_FILES = $(wildcard *.cc) -O_FILES = $(CC_FILES:%.cc=$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o) - -default: all - -all: checks $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prism$(LIBSUFFIX) $(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/ngprism$(EXE) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prism$(LIBSUFFIX): $(O_FILES) - $(LD) $(SHARED) $(LDFLAGS) -o $@ $(O_FILES) $(LIBRARIES) - -$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o: %.cc - $(CXX) $(CXXFLAGS) -c $< -o $@ $(INCLUDES) - -$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/ngprism$(EXE): ngprism.c -# For ngprism on Windows, link winsocket library (ws2_32) - @if [ "$(EXE)" = "" ]; then \ - $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<; \ - else \ - $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< -lws2_32; \ - fi; - -clean: checks - @rm -f $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prism$(LIBSUFFIX) $(O_FILES) $(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/ngprism$(EXE) - -celan: clean - -################################################# diff --git a/prism/src/prism/Prism.java b/prism/src/prism/Prism.java index fd805dcc2a..b7fa1022bf 100644 --- a/prism/src/prism/Prism.java +++ b/prism/src/prism/Prism.java @@ -442,9 +442,7 @@ public void setMainLog(PrismLog l) mainLog = l; // pass to other components JDD.SetOutputStream(mainLog.getFilePointer()); - PrismMTBDD.setMainLog(mainLog); - PrismSparse.setMainLog(mainLog); - PrismHybrid.setMainLog(mainLog); + PrismNative.setMainLog(mainLog); } // Set methods for main prism settings @@ -1102,9 +1100,7 @@ public void notifySettings(PrismSettings settings) } } jdd.SanityJDD.enabled = settings.getBoolean(PrismSettings.PRISM_JDD_SANITY_CHECKS); - PrismSparse.SetExportIterations(settings.getBoolean(PrismSettings.PRISM_EXPORT_ITERATIONS)); - PrismHybrid.SetExportIterations(settings.getBoolean(PrismSettings.PRISM_EXPORT_ITERATIONS)); - PrismMTBDD.SetExportIterations(settings.getBoolean(PrismSettings.PRISM_EXPORT_ITERATIONS)); + PrismNative.SetExportIterations(settings.getBoolean(PrismSettings.PRISM_EXPORT_ITERATIONS)); } //------------------------------------------------------------------------------ @@ -1255,14 +1251,7 @@ public void initialise() throws PrismException JDD.SetOutputStream(mainLog.getFilePointer()); // initialise libraries/engines - PrismNative.initialise(this); - PrismMTBDD.initialise(mainLog, mainLog); - PrismSparse.initialise(mainLog, mainLog); - PrismHybrid.initialise(mainLog, mainLog); - - // set cudd manager in other packages - DoubleVector.setCUDDManager(); - ODDUtils.setCUDDManager(); + PrismNative.initialise(this, mainLog); } /** @@ -4223,9 +4212,6 @@ public void closeDown(boolean check) clearBuiltModel(); // Close down libraries/engines PrismNative.closeDown(); - PrismMTBDD.closeDown(); - PrismSparse.closeDown(); - PrismHybrid.closeDown(); ParamModelChecker.closeDown(); // Close down CUDD/JDD if (cuddStarted) { diff --git a/prism/src/prism/PrismNative.cc b/prism/src/prism/PrismNative.cc index a1281cfc7f..dec0eb0f7a 100644 --- a/prism/src/prism/PrismNative.cc +++ b/prism/src/prism/PrismNative.cc @@ -37,6 +37,35 @@ EXPORT jclass prism_cls = NULL; EXPORT jobject prism_obj = NULL; +// CUDD manager: stored so that it doesn't have to be passed to every CUDD/dd call. +// Set via (JNI) PN_SetCUDDManager, cached here and accessible across all native code. +DdManager *ddman; + +// error messages +static char error_message[MAX_ERR_STRING_LEN]; + +// logs +// global refs to log classes +static jclass main_log_cls = NULL; +// global refs to log objects +static jobject main_log_obj = NULL; +// method ids for print method in logs +static jmethodID main_log_mid = NULL; +static jmethodID main_log_warn = NULL; + +// Export stuff: + +EXPORT int export_type; +EXPORT FILE *export_file; +EXPORT JNIEnv *export_env; +static bool exportIterations = false; +// adversary export mode +EXPORT int export_adv; +// adversary export filename +EXPORT const char *export_adv_filename; +// export iterations filename +EXPORT const char *export_iterations_filename = "iterations.html"; + // Options: // numerical method stuff EXPORT int lin_eq_method; @@ -55,12 +84,6 @@ EXPORT int sor_max_mem; EXPORT int num_sor_levels; // use steady-state detection for transient computation? EXPORT bool do_ss_detect; -// adversary export mode -EXPORT int export_adv; -// adversary export filename -EXPORT const char *export_adv_filename; -// export iterations filename -EXPORT const char *export_iterations_filename = "iterations.html"; // details from numerical computation which may be queried EXPORT double last_error_bound; @@ -89,6 +112,132 @@ JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1SetPrism(JNIEnv *env, jclass c setlocale(LC_NUMERIC, "C"); } +//------------------------------------------------------------------------------ +// cudd manager +//------------------------------------------------------------------------------ + +JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1SetCUDDManager(JNIEnv *env, jclass cls, jlong __jlongpointer ddm) +{ + ddman = jlong_to_DdManager(ddm); +} + +//------------------------------------------------------------------------------ +// logs +//------------------------------------------------------------------------------ + +JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1SetMainLog(JNIEnv *env, jclass cls, jobject log) +{ + // if main log has been set previously, we need to delete existing global refs first + if (main_log_obj != NULL) { + env->DeleteGlobalRef(main_log_cls); + main_log_cls = NULL; + env->DeleteGlobalRef(main_log_obj); + main_log_obj = NULL; + } + + // make a global reference to the log object + main_log_obj = env->NewGlobalRef(log); + // get the log class and make a global reference to it + main_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(main_log_obj)); + // get the method id for the print method + main_log_mid = env->GetMethodID(main_log_cls, "print", "(Ljava/lang/String;)V"); + main_log_warn = env->GetMethodID(main_log_cls, "printWarning", "(Ljava/lang/String;)V"); +} + +//------------------------------------------------------------------------------ + +void PN_PrintToMainLog(JNIEnv *env, const char *str, ...) +{ + va_list argptr; + char full_string[MAX_LOG_STRING_LEN]; + + va_start(argptr, str); + vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); + va_end(argptr); + + if (env) + env->CallVoidMethod(main_log_obj, main_log_mid, env->NewStringUTF(full_string)); + else + printf("%s", full_string); +} + +//------------------------------------------------------------------------------ + +void PN_PrintWarningToMainLog(JNIEnv *env, const char *str, ...) +{ + va_list argptr; + char full_string[MAX_LOG_STRING_LEN]; + + va_start(argptr, str); + vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); + va_end(argptr); + + if (env) + env->CallVoidMethod(main_log_obj, main_log_warn, env->NewStringUTF(full_string)); + else + printf("\nWarning: %s\n", full_string); +} + +//------------------------------------------------------------------------------ + +// Print formatted memory info to main log + +void PN_PrintMemoryToMainLog(JNIEnv *env, const char *before, double mem, const char *after) +{ + char full_string[MAX_LOG_STRING_LEN]; + + if (mem > 1048576) + snprintf(full_string, MAX_LOG_STRING_LEN, "%s%.1f GB%s", before, mem/1048576.0, after); + else if (mem > 1024) + snprintf(full_string, MAX_LOG_STRING_LEN, "%s%.1f MB%s", before, mem/1024.0, after); + else + snprintf(full_string, MAX_LOG_STRING_LEN, "%s%.1f KB%s", before, mem, after); + + if (env) { + env->CallVoidMethod(main_log_obj, main_log_mid, env->NewStringUTF(full_string)); + } + else { + printf("%s", full_string); + } +} + +//------------------------------------------------------------------------------ +// error message handling +//------------------------------------------------------------------------------ + +void PN_SetErrorMessage(const char *str, ...) +{ + va_list argptr; + + va_start(argptr, str); + vsnprintf(error_message, MAX_ERR_STRING_LEN, str, argptr); + va_end(argptr); +} + +char *PN_GetErrorMessage() +{ + return error_message; +} + +JNIEXPORT jstring JNICALL Java_prism_PrismNative_PN_1GetErrorMessage(JNIEnv *env, jclass cls) +{ + return env->NewStringUTF(error_message); +} + +//------------------------------------------------------------------------------ +// Export stuff +//------------------------------------------------------------------------------ + +JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1SetExportIterations(JNIEnv *env, jclass cls, jboolean value) +{ + exportIterations = value; +} + +bool PN_GetFlagExportIterations() +{ + return exportIterations; +} + //------------------------------------------------------------------------------ // Set methods for options in native code //------------------------------------------------------------------------------ @@ -216,6 +365,51 @@ JNIEXPORT jint JNICALL Java_prism_PrismNative_PN_1SetWorkingDirectory(JNIEnv *en return rv; } +//------------------------------------------------------------------------------ +// export stuff +//------------------------------------------------------------------------------ + +// store export info globally +// returns 0 on failure, 1 otherwise + +int store_export_info(int type, jstring fn, JNIEnv *env) +{ + export_type = type; + if (fn) { + const char *filename = env->GetStringUTFChars(fn, 0); + export_file = fopen(filename, "w"); + if (!export_file) { + env->ReleaseStringUTFChars(fn, filename); + return 0; + } + env->ReleaseStringUTFChars(fn, filename); + } else { + export_file = NULL; + } + export_env = env; + return 1; +} + +//------------------------------------------------------------------------------ + +// export string (either to file or main log) + +void export_string(const char *str, ...) +{ + va_list argptr; + char full_string[MAX_LOG_STRING_LEN]; + + va_start(argptr, str); + vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); + va_end(argptr); + + if (export_file) { + fprintf(export_file, "%s", full_string); + } else { + PN_PrintToMainLog(export_env, "%s", full_string); + } +} + //------------------------------------------------------------------------------ // Some miscellaneous native methods //------------------------------------------------------------------------------ @@ -276,16 +470,11 @@ JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1FlushFile(JNIEnv *env, jclass //------------------------------------------------------------------------------ - JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1CloseFile(JNIEnv *env, jclass cls, jlong __jlongpointer fp) { fclose(jlong_to_FILE(fp)); } - - - - JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1SetLastErrorBound(JNIEnv *env, jclass cls,jdouble d) { last_error_bound = d; @@ -296,11 +485,6 @@ JNIEXPORT jdouble JNICALL Java_prism_PrismNative_PN_1GetLastErrorBound(JNIEnv *e return last_error_bound; } - - - - - //------------------------------------------------------------------------------ // tidy up //------------------------------------------------------------------------------ @@ -312,6 +496,10 @@ JNIEXPORT void JNICALL Java_prism_PrismNative_PN_1FreeGlobalRefs(JNIEnv *env, jc prism_cls = NULL; env->DeleteGlobalRef(prism_obj); prism_obj = NULL; + env->DeleteGlobalRef(main_log_cls); + main_log_cls = NULL; + env->DeleteGlobalRef(main_log_obj); + main_log_obj = NULL; } //------------------------------------------------------------------------------ diff --git a/prism/src/prism/PrismNative.java b/prism/src/prism/PrismNative.java index eaf9723b72..92696daae0 100644 --- a/prism/src/prism/PrismNative.java +++ b/prism/src/prism/PrismNative.java @@ -26,6 +26,8 @@ package prism; +import jdd.JDD; + /** * Set methods to pass options to native code. * And a few utility methods, relying on native methods in the "prism" shared library. @@ -46,9 +48,11 @@ public class PrismNative // Initialise/close down methods - public static void initialise(Prism prism) + public static void initialise(Prism prism, PrismLog mainLog) { setPrism(prism); + setCUDDManager(); + setMainLog(mainLog); } public static void closeDown() @@ -72,7 +76,38 @@ public static void setPrism(Prism prism) PrismNative.prism = prism; PN_SetPrism(prism); } - + + // cudd manager + + // jni method to set cudd manager for native code + private static native void PN_SetCUDDManager(long ddm); + public static void setCUDDManager() + { + PN_SetCUDDManager(JDD.GetCUDDManager()); + } + + // main log + + // place to store main log for java code + private static PrismLog mainLog; + // jni method to set main log for native code + private static native void PN_SetMainLog(PrismLog log); + // method to set main log both in java and c++ + public static void setMainLog(PrismLog log) + { + mainLog = log; + PN_SetMainLog(log); + } + + // Error message handling + public static native String PN_GetErrorMessage(); + + private static native void PN_SetExportIterations(boolean value); + public static void SetExportIterations(boolean value) + { + PN_SetExportIterations(value); + } + // Options passing private static native void PN_SetCompact(boolean b); diff --git a/prism/src/pta/Makefile b/prism/src/pta/Makefile deleted file mode 100644 index 54b00c944b..0000000000 --- a/prism/src/pta/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = pta -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java parser/*.java) -JAVA_FILES = $(patsubst %package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks parser/PTAParser.java $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -parser/PTAParser.java: parser/PTAParser.jj - @(cd parser; $(JAVACC) PTAParser.jj || echo "Warning: Did not recompile $<") - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/src/settings/Makefile b/prism/src/settings/Makefile deleted file mode 100644 index 6866280526..0000000000 --- a/prism/src/settings/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = settings -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/src/simulator/Makefile b/prism/src/simulator/Makefile deleted file mode 100644 index 2b9f712886..0000000000 --- a/prism/src/simulator/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = simulator -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java sampler/*.java method/*.java) -JAVA_FILES = $(patsubst %package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)simengine$(LIBSUFFIX) $(O_FILES) - -celan: clean - -################################################# diff --git a/prism/src/sparse/Makefile b/prism/src/sparse/Makefile deleted file mode 100644 index b1113c435b..0000000000 --- a/prism/src/sparse/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = sparse -PRISM_DIR_REL = ../.. - -INCLUDES = \ --I$(PRISM_DIR_REL)/$(CUDD_DIR)/include \ --I"$(JAVA_JNI_H_DIR)" \ --I"$(JAVA_JNI_MD_H_DIR)" \ --I$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR) \ --I$(PRISM_DIR_REL)/ext/lpsolve55/include - -LIBRARIES = \ --L$(PRISM_DIR_REL)/$(PRISM_LIB_DIR) \ --lodd \ --ldd \ --ldv \ --lprism \ -$(LIBMATH) \ --llpsolve55 - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -CC_FILES = $(wildcard *.cc) -O_FILES = $(CC_FILES:%.cc=$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o) - -default: all - -all: checks $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prismsparse$(LIBSUFFIX) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prismsparse$(LIBSUFFIX): $(O_FILES) - $(LD) $(SHARED) $(LDFLAGS) -o $@ $(O_FILES) $(LIBRARIES) - -$(PRISM_DIR_REL)/$(PRISM_OBJ_DIR)/$(THIS_DIR)/%.o: %.cc - $(CXX) $(CXXFLAGS) -c $< -o $@ $(INCLUDES) - -clean: checks - @rm -f $(CLASS_FILES) $(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/$(LIBPREFIX)prismsparse$(LIBSUFFIX) $(O_FILES) - -celan: clean - -################################################# diff --git a/prism/src/sparse/NDSparseMatrix.java b/prism/src/sparse/NDSparseMatrix.java index 7924c639a6..f2b42ee08c 100644 --- a/prism/src/sparse/NDSparseMatrix.java +++ b/prism/src/sparse/NDSparseMatrix.java @@ -50,7 +50,7 @@ public class NDSparseMatrix static { try { - System.loadLibrary("prismsparse"); + System.loadLibrary("prism"); } catch (UnsatisfiedLinkError e) { System.out.println(e); System.exit(1); diff --git a/prism/src/sparse/PS_ExportMC.cc b/prism/src/sparse/PS_ExportMC.cc index 8dc1ebface..5bdbf82161 100644 --- a/prism/src/sparse/PS_ExportMC.cc +++ b/prism/src/sparse/PS_ExportMC.cc @@ -32,7 +32,7 @@ #include #include "sparse.h" #include "prism.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include diff --git a/prism/src/sparse/PS_ExportMDP.cc b/prism/src/sparse/PS_ExportMDP.cc index bba7bd651c..8f1c7f1d9e 100644 --- a/prism/src/sparse/PS_ExportMDP.cc +++ b/prism/src/sparse/PS_ExportMDP.cc @@ -32,7 +32,7 @@ #include #include "sparse.h" #include "prism.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include diff --git a/prism/src/sparse/PS_ExportMatrix.cc b/prism/src/sparse/PS_ExportMatrix.cc index 64ba419e96..68f9ea441d 100644 --- a/prism/src/sparse/PS_ExportMatrix.cc +++ b/prism/src/sparse/PS_ExportMatrix.cc @@ -31,7 +31,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include diff --git a/prism/src/sparse/PS_ExportSubMDP.cc b/prism/src/sparse/PS_ExportSubMDP.cc index 98c8c5339a..4bd1c4c70d 100644 --- a/prism/src/sparse/PS_ExportSubMDP.cc +++ b/prism/src/sparse/PS_ExportSubMDP.cc @@ -31,7 +31,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include diff --git a/prism/src/sparse/PS_JOR.cc b/prism/src/sparse/PS_JOR.cc index 8e6679395b..f0a5d9d8a0 100644 --- a/prism/src/sparse/PS_JOR.cc +++ b/prism/src/sparse/PS_JOR.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -119,7 +119,7 @@ jdouble omega // omega (over-relaxation parameter) a = DD_ITE(ddman, id, DD_Constant(ddman, 0), a); // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_a = true; cmsrsm = NULL; @@ -137,12 +137,12 @@ jdouble omega // omega (over-relaxation parameter) } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diags, either by extracting from mtbdd or // by doing (negative, non-diagonal) row sums of original A matrix - PS_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); if (!row_sums) { diags = DD_MaxAbstract(ddman, diags, cvars, num_cvars); diags_vec = mtbdd_to_double_vector(ddman, diags, rvars, num_rvars, odd); @@ -163,8 +163,8 @@ jdouble omega // omega (over-relaxation parameter) } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PS_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // invert diagonal if (!compact_d) { @@ -175,7 +175,7 @@ jdouble omega // omega (over-relaxation parameter) // build b vector (if present) if (b != NULL) { - PS_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -187,29 +187,29 @@ jdouble omega // omega (over-relaxation parameter) } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PS_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = mtbdd_to_double_vector(ddman, init, rvars, num_rvars, odd); soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PS_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PS_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PS_JOR ("); title += (omega == 1.0)?"Jacobi": ("JOR omega=" + std::to_string(omega)); title += ")"; iterationExport.reset(new ExportIterations(title.c_str())); - PS_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln, n, 0); } @@ -222,7 +222,7 @@ jdouble omega // omega (over-relaxation parameter) // start iterations iters = 0; done = false; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -293,8 +293,8 @@ jdouble omega // omega (over-relaxation parameter) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -310,10 +310,10 @@ jdouble omega // omega (over-relaxation parameter) time_taken = (double)(stop - start1)/1000; // print iters/timing info - PS_PrintToMainLog(env, "\n%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error - if (!done) { delete[] soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } + if (!done) { delete[] soln; soln = NULL; PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } // the difference between vector values is not a reliable error bound // but we store it anyway in case it is useful for estimating a bound @@ -321,7 +321,7 @@ jdouble omega // omega (over-relaxation parameter) // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_JORInterval.cc b/prism/src/sparse/PS_JORInterval.cc index 3b36774e20..535d44a3a1 100644 --- a/prism/src/sparse/PS_JORInterval.cc +++ b/prism/src/sparse/PS_JORInterval.cc @@ -34,7 +34,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -99,7 +99,7 @@ jint flags MeasureSupNorm measure(term_crit == TERM_CRIT_RELATIVE); if (omega <= 0.0 || omega > 1.0) { - PS_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); + PN_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); return ptr_to_jlong(NULL); } @@ -131,7 +131,7 @@ jint flags a = DD_ITE(ddman, id, DD_Constant(ddman, 0), a); // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_a = true; cmsrsm = NULL; @@ -149,12 +149,12 @@ jint flags } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diags, either by extracting from mtbdd or // by doing (negative, non-diagonal) row sums of original A matrix - PS_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); if (!row_sums) { diags = DD_MaxAbstract(ddman, diags, cvars, num_cvars); diags_vec = mtbdd_to_double_vector(ddman, diags, rvars, num_rvars, odd); @@ -175,8 +175,8 @@ jint flags } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PS_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // invert diagonal if (!compact_d) { @@ -187,7 +187,7 @@ jint flags // build b vector (if present) if (b != NULL) { - PS_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -199,31 +199,31 @@ jint flags } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PS_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln_below = mtbdd_to_double_vector(ddman, lower, rvars, num_rvars, odd); soln_above = mtbdd_to_double_vector(ddman, upper, rvars, num_rvars, odd); soln_below2 = new double[n]; soln_above2 = new double[n]; kb = n*8.0/1024.0; kbt += 4*kb; - PS_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PS_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PS_JOR ("); title += (omega == 1.0)?"Jacobi":("JOR omega=" + std::to_string(omega)); title += "), interval"; iterationExport.reset(new ExportIterations(title.c_str())); - PS_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln_below, n, 0); iterationExport->exportVector(soln_above, n, 1); } @@ -237,7 +237,7 @@ jint flags // start iterations iters = 0; done = false; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -311,14 +311,14 @@ jint flags measure.reset(); measure.measure(soln_below2, soln_above2, n); if (measure.value() < term_crit_param) { - PS_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); done = true; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -337,14 +337,14 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iters/timing info - PS_PrintToMainLog(env, "\n%s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", (omega == 1.0)?"Jacobi":"JOR", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!done) { delete[] soln_below; soln_below = NULL; - PS_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); - PS_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); } if (helper.flag_select_midpoint() && soln_below) { // we did converge, select midpoint @@ -360,7 +360,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln_below) delete[] soln_below; soln_below = 0; } diff --git a/prism/src/sparse/PS_NondetBoundedUntil.cc b/prism/src/sparse/PS_NondetBoundedUntil.cc index 32b9c292f4..09da6b6763 100644 --- a/prism/src/sparse/PS_NondetBoundedUntil.cc +++ b/prism/src/sparse/PS_NondetBoundedUntil.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include @@ -98,7 +98,7 @@ jboolean min // min or max probabilities (true = min, false = max) n = odd->eoff + odd->toff; // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); ndsm = build_nd_sparse_matrix(ddman, a, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // get number of transitions/choices nnz = ndsm->nnz; @@ -106,26 +106,26 @@ jboolean min // min or max probabilities (true = min, false = max) kb = ndsm->mem; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector for yes - PS_PrintToMainLog(env, "Creating vector for yes... "); + PN_PrintToMainLog(env, "Creating vector for yes... "); yes_vec = mtbdd_to_double_vector(ddman, yes, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = new double[n]; soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PS_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution is yes for (i = 0; i < n; i++) { @@ -139,7 +139,7 @@ jboolean min // min or max probabilities (true = min, false = max) start3 = stop; // start iterations - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -179,8 +179,8 @@ jboolean min // min or max probabilities (true = min, false = max) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PS_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -196,11 +196,11 @@ jboolean min // min or max probabilities (true = min, false = max) time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_NondetCumulReward.cc b/prism/src/sparse/PS_NondetCumulReward.cc index e471077e6f..775529f27e 100644 --- a/prism/src/sparse/PS_NondetCumulReward.cc +++ b/prism/src/sparse/PS_NondetCumulReward.cc @@ -35,7 +35,6 @@ #include "sparse.h" #include "prism.h" #include "PrismNativeGlob.h" -#include "PrismSparseGlob.h" #include "jnipointer.h" #include @@ -93,7 +92,7 @@ jboolean min // min or max probabilities (true = min, false = max) n = odd->eoff + odd->toff; // build sparse matrix (probs) - PS_PrintToMainLog(env, "\nBuilding sparse matrix (transitions)... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix (transitions)... "); ndsm = build_nd_sparse_matrix(ddman, trans, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // get number of transitions/choices nnz = ndsm->nnz; @@ -101,38 +100,38 @@ jboolean min // min or max probabilities (true = min, false = max) kb = (nnz*12.0+nc*4.0+n*4.0)/1024.0; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // build sparse matrix (rewards) - PS_PrintToMainLog(env, "Building sparse matrix (transition rewards)... "); + PN_PrintToMainLog(env, "Building sparse matrix (transition rewards)... "); ndsm_r = build_sub_nd_sparse_matrix(ddman, trans, trans_rewards, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // get number of transitions/choices nnz_r = ndsm_r->nnz; nc_r = ndsm_r->nc; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); kb = (nnz_r*12.0+nc_r*4.0+n*4.0)/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector for state rewards - PS_PrintToMainLog(env, "Creating vector for state rewards... "); + PN_PrintToMainLog(env, "Creating vector for state rewards... "); sr_vec = mtbdd_to_double_vector(ddman, state_rewards, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = new double[n]; soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PS_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution is zero for (i = 0; i < n; i++) { @@ -146,7 +145,7 @@ jboolean min // min or max probabilities (true = min, false = max) start3 = stop; // start iterations - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // store local copies of stuff // firstly for transition matrix @@ -210,8 +209,8 @@ jboolean min // min or max probabilities (true = min, false = max) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PS_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -227,11 +226,11 @@ jboolean min // min or max probabilities (true = min, false = max) time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_NondetInstReward.cc b/prism/src/sparse/PS_NondetInstReward.cc index 0022cf8065..b02bab46f4 100644 --- a/prism/src/sparse/PS_NondetInstReward.cc +++ b/prism/src/sparse/PS_NondetInstReward.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include @@ -92,7 +92,7 @@ jlong __jlongpointer in n = odd->eoff + odd->toff; // build sparse matrix (probs) - PS_PrintToMainLog(env, "\nBuilding sparse matrix (transitions)... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix (transitions)... "); ndsm = build_nd_sparse_matrix(ddman, trans, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // get number of transitions/choices nnz = ndsm->nnz; @@ -100,20 +100,20 @@ jlong __jlongpointer in kb = (nnz*12.0+nc*4.0+n*4.0)/1024.0; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors // (solution is initialised to the state rewards) - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = mtbdd_to_double_vector(ddman, state_rewards, rvars, num_rvars, odd); soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PS_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // get setup time stop = util_cpu_time(); @@ -122,7 +122,7 @@ jlong __jlongpointer in start3 = stop; // start iterations - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -173,8 +173,8 @@ jlong __jlongpointer in // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PS_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -183,7 +183,7 @@ jlong __jlongpointer in soln = soln2; soln2 = tmpsoln; -// PS_PrintToMainLog(env, "%i: %f\n", iters, get_first_from_bdd(ddman, soln, init, rvars, num_rvars, odd)); +// PN_PrintToMainLog(env, "%i: %f\n", iters, get_first_from_bdd(ddman, soln, init, rvars, num_rvars, odd)); } // stop clocks @@ -192,11 +192,11 @@ jlong __jlongpointer in time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_NondetMultiObj.cc b/prism/src/sparse/PS_NondetMultiObj.cc index 22c94f3d6f..bb3d328abe 100644 --- a/prism/src/sparse/PS_NondetMultiObj.cc +++ b/prism/src/sparse/PS_NondetMultiObj.cc @@ -36,7 +36,6 @@ #include "sparse.h" #include "prism.h" #include "PrismNativeGlob.h" -#include "PrismSparseGlob.h" #include "jnipointer.h" #include #include @@ -202,10 +201,10 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet for (int probi = 0; probi < lenProb; probi++) { yes_vec[probi] = (double *) jlong_to_ptr(ptr_yes_vec[probi]); #ifdef MORE_OUTPUT - PS_PrintToMainLog(env, "yes_vec %d: ", probi); + PN_PrintToMainLog(env, "yes_vec %d: ", probi); for (int o = 0; o < n; o++) - PS_PrintToMainLog(env, "%f, ", yes_vec[probi][o]); - PS_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, "%f, ", yes_vec[probi][o]); + PN_PrintToMainLog(env, "\n"); #endif } @@ -277,20 +276,20 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet } #ifdef MORE_OUTPUT - PS_PrintToMainLog(env, "Initial soln: "); + PN_PrintToMainLog(env, "Initial soln: "); for (int o = 0; o < n; o++) - PS_PrintToMainLog(env, "%f, ", soln[o]); - PS_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, "%f, ", soln[o]); + PN_PrintToMainLog(env, "\n"); for (int it = 0; it < lenRew + lenProb; it++) { if (it != ignoredWeight) { - PS_PrintToMainLog(env, "psoln: "); + PN_PrintToMainLog(env, "psoln: "); for (int o = 0; o < n; o++) - PS_PrintToMainLog(env, "%f, ", psoln[it][o]); - PS_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, "%f, ", psoln[it][o]); + PN_PrintToMainLog(env, "\n"); } else { - PS_PrintToMainLog(env, "psoln: (ignored)\n"); + PN_PrintToMainLog(env, "psoln: (ignored)\n"); } } #endif @@ -303,13 +302,13 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet iters = 0; done = false; weightedDone = false; - //PS_PrintToMainLog(env, "Starting iterations...\n"); + //PN_PrintToMainLog(env, "Starting iterations...\n"); // open file to store adversary (if required) if (export_adv_enabled != EXPORT_ADV_NONE) { fp_adv = fopen(export_adv_filename, "w"); if (!fp_adv) { - PS_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").", export_adv_filename); + PN_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").", export_adv_filename); export_adv_enabled = EXPORT_ADV_NONE; } } @@ -571,14 +570,14 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet soln2 = tmpsoln; #ifdef MORE_OUTPUT - PS_PrintToMainLog(env, "Soln: "); + PN_PrintToMainLog(env, "Soln: "); for (int o = 0; o < n; o++) - PS_PrintToMainLog(env, "%e, ", soln[o]); - PS_PrintToMainLog(env, "\n"); - PS_PrintToMainLog(env, "Soln2: "); + PN_PrintToMainLog(env, "%e, ", soln[o]); + PN_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, "Soln2: "); for (int o = 0; o < n; o++) - PS_PrintToMainLog(env, "%e, ", soln[o]); - PS_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, "%e, ", soln[o]); + PN_PrintToMainLog(env, "\n"); #endif for (int it = 0; it < lenRew + lenProb; it++) { @@ -588,16 +587,16 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet psoln2[it] = tmpsoln; } #ifdef MORE_OUTPUT - PS_PrintToMainLog(env, "psoln: "); + PN_PrintToMainLog(env, "psoln: "); if (ignoredWeight != it) for (int o = 0; o < n; o++) - PS_PrintToMainLog(env, "%e, ", psoln[it][o]); - PS_PrintToMainLog(env, "\n"); - PS_PrintToMainLog(env, "psoln2: "); + PN_PrintToMainLog(env, "%e, ", psoln[it][o]); + PN_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, "psoln2: "); if (ignoredWeight != it) for (int o = 0; o < n; o++) - PS_PrintToMainLog(env, "%e, ", psoln2[it][o]); - PS_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, "%e, ", psoln2[it][o]); + PN_PrintToMainLog(env, "\n"); #endif } } @@ -655,11 +654,11 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "Iterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "Iterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!doneBeforeBounded) { // || !weightedDone) { - PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); throw 1; } @@ -668,11 +667,11 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet jdouble *retNative = env->GetDoubleArrayElements(ret, 0); // Display result - PS_PrintToMainLog(env, "Optimal value for weights ["); + PN_PrintToMainLog(env, "Optimal value for weights ["); for (int it = 0; it < lenRew + lenProb; it++) { - PS_PrintToMainLog(env, "%s%f", (it>0?",":""), weights[it]); + PN_PrintToMainLog(env, "%s%f", (it>0?",":""), weights[it]); } - PS_PrintToMainLog(env, "] from initial state: %f\n", soln[start_index]); + PN_PrintToMainLog(env, "] from initial state: %f\n", soln[start_index]); //copy all computed elements for (int it = 0; it < lenRew + lenProb; it++) @@ -692,7 +691,7 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet // close file to store adversary (if required) if (export_adv_enabled != EXPORT_ADV_NONE) { fclose(fp_adv); - PS_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", export_adv_filename); + PN_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", export_adv_filename); } // export individual solution vectors @@ -704,7 +703,7 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet export_vect_filename += std::to_string(it); FILE *fp_vect = fopen(export_vect_filename.c_str(), "w"); if (fp_vect) { - PS_PrintWarningToMainLog(env, "Exporting solution vector %d to file %s.", it, export_vect_filename.c_str()); + PN_PrintWarningToMainLog(env, "Exporting solution vector %d to file %s.", it, export_vect_filename.c_str()); for (i = 0; i < n; i++) { fprintf(fp_vect, "%d %g\n", i, psoln[it][i]); } @@ -716,13 +715,13 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); ret = 0; } catch (int e) { if (e==1) //1 means error was set above and exception was thrown to end the computation ret = 0; else - PS_SetErrorMessage("Unknown error."); + PN_SetErrorMessage("Unknown error."); } // free memory diff --git a/prism/src/sparse/PS_NondetMultiObjGS.cc b/prism/src/sparse/PS_NondetMultiObjGS.cc index 4a5e58d589..2ee6c8dfbe 100644 --- a/prism/src/sparse/PS_NondetMultiObjGS.cc +++ b/prism/src/sparse/PS_NondetMultiObjGS.cc @@ -36,7 +36,6 @@ #include "sparse.h" #include "prism.h" #include "PrismNativeGlob.h" -#include "PrismSparseGlob.h" #include "jnipointer.h" #include @@ -212,20 +211,20 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet } #ifdef MORE_OUTPUT - PS_PrintToMainLog(env, "Initial soln: "); + PN_PrintToMainLog(env, "Initial soln: "); for (int o = 0; o < n; o++) - PS_PrintToMainLog(env, "%f, ", soln[o]); - PS_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, "%f, ", soln[o]); + PN_PrintToMainLog(env, "\n"); for (int it = 0; it < lenRew + lenProb; it++) { if (it != ignoredWeight) { - PS_PrintToMainLog(env, "psoln: "); + PN_PrintToMainLog(env, "psoln: "); for (int o = 0; o < n; o++) - PS_PrintToMainLog(env, "%f, ", psoln[it][o]); - PS_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, "%f, ", psoln[it][o]); + PN_PrintToMainLog(env, "\n"); } else { - PS_PrintToMainLog(env, "psoln: (ignored)\n"); + PN_PrintToMainLog(env, "psoln: (ignored)\n"); } } #endif @@ -238,7 +237,7 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet iters = 0; done = false; weightedDone = false; - //PS_PrintToMainLog(env, "Starting iterations...\n"); + //PN_PrintToMainLog(env, "Starting iterations...\n"); // store local copies of stuff double *non_zeros = ndsm->non_zeros; @@ -462,19 +461,19 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet } #ifdef MORE_OUTPUT - PS_PrintToMainLog(env, "soln: "); + PN_PrintToMainLog(env, "soln: "); for (int o = 0; o < n; o++) - PS_PrintToMainLog(env, "%e, ", soln[o]); - PS_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, "%e, ", soln[o]); + PN_PrintToMainLog(env, "\n"); for (int it = 0; it < lenRew + lenProb; it++) { if (it != ignoredWeight) { - PS_PrintToMainLog(env, "psoln: "); + PN_PrintToMainLog(env, "psoln: "); for (int o = 0; o < n; o++) - PS_PrintToMainLog(env, "%e, ", psoln[it][o]); - PS_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, "%e, ", psoln[it][o]); + PN_PrintToMainLog(env, "\n"); } else { - PS_PrintToMainLog(env, "psoln: (ignored)\n"); + PN_PrintToMainLog(env, "psoln: (ignored)\n"); } } #endif @@ -499,11 +498,11 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "Iterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "Iterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (iters == max_iters) { - PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); throw 1; } @@ -529,14 +528,14 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } catch (int e) { if (e==1) //1 means error was set above and exception was thrown to end the computation ret = 0; else - PS_SetErrorMessage("Unknown error."); + PN_SetErrorMessage("Unknown error."); } if (soln) delete[] soln; diff --git a/prism/src/sparse/PS_NondetMultiReach.cc b/prism/src/sparse/PS_NondetMultiReach.cc index 36aa2ec36b..09f1dee56f 100644 --- a/prism/src/sparse/PS_NondetMultiReach.cc +++ b/prism/src/sparse/PS_NondetMultiReach.cc @@ -36,7 +36,6 @@ #include "sparse.h" #include "sparse_adv.h" #include "prism.h" -#include "PrismSparseGlob.h" #include "PrismNativeGlob.h" #include "jnipointer.h" #include @@ -131,15 +130,15 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti for(i=0; i%g", bounds[i]); break; - case 2: PS_PrintToMainLog(env, "P>=%g", bounds[i]); break; + case 0: PN_PrintToMainLog(env, "Pmax=?"); break; + case 1: PN_PrintToMainLog(env, "P>%g", bounds[i]); break; + case 2: PN_PrintToMainLog(env, "P>=%g", bounds[i]); break; } - PS_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, targets[i], num_rvars)); + PN_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, targets[i], num_rvars)); } // Filter out rows, store in "a" @@ -165,7 +164,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti n = odd->eoff + odd->toff; // Build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); ndsm = build_nd_sparse_matrix(ddman, a, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // Get number of transitions/choices nnz = ndsm->nnz; @@ -173,13 +172,13 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti kb = ndsm->mem; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // If needed, and if info is available, build a vector of action indices for the MDP if (export_adv != EXPORT_ADV_NONE) { if (trans_actions != NULL) { - PS_PrintToMainLog(env, "Building action information... "); + PN_PrintToMainLog(env, "Building action information... "); // first need to filter out unwanted rows Cudd_Ref(trans_actions); Cudd_Ref(maybe_yes); @@ -191,35 +190,35 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti Cudd_RecursiveDeref(ddman, tmp); kb = n*4.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // also extract list of action names from 'synchs' get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions); } else { - PS_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); + PN_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); } } // Get vectors for yes/maybe - PS_PrintToMainLog(env, "Creating vectors for yes... "); + PN_PrintToMainLog(env, "Creating vectors for yes... "); for(i=0; inon_zeros; @@ -231,7 +230,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti unsigned int *cols = ndsm->cols; // Set up LP problem... - PS_PrintToMainLog(env, "\nBuilding LP problem...\n"); + PN_PrintToMainLog(env, "\nBuilding LP problem...\n"); int *yes_vec; int *map_var; @@ -296,7 +295,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti num_lp_vars = maybe_nc + yes_nc + yes_count; // Store first LP var for final state map_var[n] = num_lp_vars; // maybe need to be modified. - PS_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars); + PN_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars); for(i=0; i 0 && relops[0]<=2) { for(i=0; i 0) { // for qualitative queries, return 1/0 for existence of solution or not - PS_PrintToMainLog(env, "LP problem solution %sfound so result is %s\n", lp_solved ? "" : "not ", lp_solved ? "true" : "false"); + PN_PrintToMainLog(env, "LP problem solution %sfound so result is %s\n", lp_solved ? "" : "not ", lp_solved ? "true" : "false"); lp_result = lp_solved ? 1.0 : 0.0; } else { // return NaN for quantitative queries that can't be solved - PS_PrintToMainLog(env, "LP problem solution %sfound; result is %f\n", lp_solved ? "" : "not ", lp_result); + PN_PrintToMainLog(env, "LP problem solution %sfound; result is %f\n", lp_solved ? "" : "not ", lp_result); if (!lp_solved) lp_result = NAN; } // Print timing info time_taken = time_for_setup + time_for_lp; - PS_PrintToMainLog(env, "\nLP problem solved in %.2f seconds (setup %.2f, lpsolve %.2f)\n", time_taken, time_for_setup, time_for_lp); + PN_PrintToMainLog(env, "\nLP problem solved in %.2f seconds (setup %.2f, lpsolve %.2f)\n", time_taken, time_for_setup, time_for_lp); delete yes_vec; delete map_var; // Catch exceptions: register error } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); lp_result = NAN; } diff --git a/prism/src/sparse/PS_NondetMultiReach.cc.withrewards b/prism/src/sparse/PS_NondetMultiReach.cc.withrewards index ba1d651268..ec1c8ea6bd 100644 --- a/prism/src/sparse/PS_NondetMultiReach.cc.withrewards +++ b/prism/src/sparse/PS_NondetMultiReach.cc.withrewards @@ -34,7 +34,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include #include "eclipse.h" @@ -146,17 +146,17 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti bounds = env->GetDoubleArrayElements(_bounds, 0); // Display some target info (just a test) - PS_PrintToMainLog(env, "\n%d Targets:\n", num_targets); + PN_PrintToMainLog(env, "\n%d Targets:\n", num_targets); for (i = 0; i < num_targets; i++) { - PS_PrintToMainLog(env, "#%d: ", i); + PN_PrintToMainLog(env, "#%d: ", i); switch (relops[i]) { - case 0: PS_PrintToMainLog(env, "Pmax=?"); break; - case 1: PS_PrintToMainLog(env, ">%g", bounds[i]); break; - case 2: PS_PrintToMainLog(env, ">=%g", bounds[i]); break; - case 3: PS_PrintToMainLog(env, "Rmax=?"); break; - case 4: PS_PrintToMainLog(env, ">=%g", bounds[i]); break; + case 0: PN_PrintToMainLog(env, "Pmax=?"); break; + case 1: PN_PrintToMainLog(env, ">%g", bounds[i]); break; + case 2: PN_PrintToMainLog(env, ">=%g", bounds[i]); break; + case 3: PN_PrintToMainLog(env, "Rmax=?"); break; + case 4: PN_PrintToMainLog(env, ">=%g", bounds[i]); break; } - PS_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, targets[i], num_rvars)); + PN_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, targets[i], num_rvars)); } //DdNode *yes1 = targets[0]; @@ -190,7 +190,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti n = odd->eoff + odd->toff; // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); ndsm = build_nd_sparse_matrix(ddman, a, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // get number of transitions/choices nnz = ndsm->nnz; @@ -198,34 +198,34 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti kb = ndsm->mem; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%d, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%d, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vectors for yes/maybe - PS_PrintToMainLog(env, "Creating vectors for yes... "); + PN_PrintToMainLog(env, "Creating vectors for yes... "); for(i=0; inon_zeros; @@ -247,15 +247,15 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti trans_rewards = jlong_to_DdNode(trr); // transition rewards Cudd_Ref(trans_rewards); trans_rewards = DD_Apply(ddman, APPLY_TIMES, trans_rewards, maybe); - PS_PrintToMainLog(env, "Building sparse matrix (transition rewards)... "); + PN_PrintToMainLog(env, "Building sparse matrix (transition rewards)... "); ndsm_r = build_sub_nd_sparse_matrix(ddman, a, trans_rewards, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); nnz_r = ndsm_r->nnz; nc_r = ndsm_r->nc; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%d, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%d, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); kb = (nnz_r*12.0+nc_r*4.0+n*4.0)/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); non_zeros_r = ndsm_r->non_zeros; choice_counts_r = ndsm_r->choice_counts; choice_starts_r = (int *)ndsm_r->choice_counts; @@ -263,20 +263,20 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti cols_r = ndsm_r->cols; //for(i=0; i 0) n_maybe_r ++; kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); * / + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); * / //maybe_vec_r = maybe_vec; }*/ /***************** end of set up *******************/ // Set up LP problem - PS_PrintToMainLog(env, "\nBuilding LP problem...\n"); + PN_PrintToMainLog(env, "\nBuilding LP problem...\n"); // Compute number of vars/constraints int maybe_nc = 0; for (i = 0; i < n; i++) { @@ -392,7 +392,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti start2 = stop; // Solve LP problem - PS_PrintToMainLog(env, "Solving LP problem...\n"); + PN_PrintToMainLog(env, "Solving LP problem...\n"); res = solve(lp); //Get LP solving time @@ -414,7 +414,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti time_taken = (double)(stop - start3)/1000; // print timing info - PS_PrintToMainLog(env, "\nLP problem solved in %.2f seconds (setup %.2f, lpsolve %.2f)\n", time_taken, time_for_setup, time_for_lp);*/ + PN_PrintToMainLog(env, "\nLP problem solved in %.2f seconds (setup %.2f, lpsolve %.2f)\n", time_taken, time_for_setup, time_for_lp);*/ /* * Hongyang: Use Eclipse with COIN CBC solver @@ -452,7 +452,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti }*/ if(checkReach) { - PS_PrintToMainLog(env, "Check reachability...\n"); + PN_PrintToMainLog(env, "Check reachability...\n"); // Maps states to ECLiPSe variables. // Each yes state has a coresponding variable. // Each maybe state has one or more variables. @@ -472,7 +472,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti } //if (arr_reals) delete[] arr_reals; - PS_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars + n_maybe_r); + PN_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars + n_maybe_r); arr_reals = new REAL[num_lp_vars + n_maybe_r]; // create map vector @@ -687,7 +687,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti } } - PS_PrintToMainLog(env, "Adding extra constraints for probabilisitic bounds\n"); + PN_PrintToMainLog(env, "Adding extra constraints for probabilisitic bounds\n"); for(i=0; i=0; k--) @@ -704,7 +704,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti ec_double(bounds[i]))); } - PS_PrintToMainLog(env, "Computing optimisation...\n"); + PN_PrintToMainLog(env, "Computing optimisation...\n"); fflush(stdout); pword tail = ec_nil(); x = 0; @@ -727,7 +727,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti /*x = 1; arr_reals[0] = 1.0; tail = ec_list(ec_refs_get(Vars, map_var_r[start_index]+num_lp_vars), tail);*/ - PS_PrintToMainLog(env, "computing max function for rewards ...\n"); + PN_PrintToMainLog(env, "computing max function for rewards ...\n"); double *non_zeros_r; unsigned char *choice_counts_r; int *choice_starts_r; @@ -736,15 +736,15 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti trans_rewards = jlong_to_DdNode(trr); // transition rewards Cudd_Ref(trans_rewards); trans_rewards = DD_Apply(ddman, APPLY_TIMES, trans_rewards, maybe); - PS_PrintToMainLog(env, "Building sparse matrix (transition rewards)... "); + PN_PrintToMainLog(env, "Building sparse matrix (transition rewards)... "); ndsm_r = build_sub_nd_sparse_matrix(ddman, a, trans_rewards, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); nnz_r = ndsm_r->nnz; nc_r = ndsm_r->nc; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%d, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%d, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); kb = (nnz_r*12.0+nc_r*4.0+n*4.0)/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); non_zeros_r = ndsm_r->non_zeros; choice_counts_r = ndsm_r->choice_counts; choice_starts_r = (int *)ndsm_r->choice_counts; @@ -795,9 +795,9 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti h2_r += choice_counts_r[j]; } } - /*PS_PrintToMainLog(env, " arr_reals:"); + /*PN_PrintToMainLog(env, " arr_reals:"); for (k = 0; k < num_lp_vars; k++) - PS_PrintToMainLog(env, " %1.1f", arr_reals[k]); + PN_PrintToMainLog(env, " %1.1f", arr_reals[k]); fflush(stdout);*/ for(k=num_lp_vars-1; k>=0; k--) @@ -818,7 +818,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti ec_term(ec_did("*",2), varlist, ec_listofdouble(num_lp_vars, pc))), ec_ref_get(Cost)));*/ } else { // ------------------------------ LTL model checking ---------------------------- - PS_PrintToMainLog(env, "Check LTL formulas...\n"); + PN_PrintToMainLog(env, "Check LTL formulas...\n"); int num_map; int yes_count = 0; // the number of target states @@ -866,7 +866,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti } num_lp_vars = maybe_nc + yes_nc + yes_count; map_var[n] = num_lp_vars; // maybe need to be modified. - PS_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars); + PN_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars); for(i=0; i2) continue; - //PS_PrintToMainLog(env, "num_map = %1d, i = %1d, bound = %1.1f\n", num_map, i, bounds[i]); + //PN_PrintToMainLog(env, "num_map = %1d, i = %1d, bound = %1.1f\n", num_map, i, bounds[i]); for(k=0; knnz; nc_r = ndsm_r->nc; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%d, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%d, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); kb = (nnz_r*12.0+nc_r*4.0+n*4.0)/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); non_zeros_r = ndsm_r->non_zeros; choice_counts_r = ndsm_r->choice_counts; choice_starts_r = (int *)ndsm_r->choice_counts; @@ -1369,10 +1369,10 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti h2_r += choice_counts_r[j]; } } - /*PS_PrintToMainLog(env, " arr_reals:"); + /*PN_PrintToMainLog(env, " arr_reals:"); for (k = 0; k < num_lp_vars; k++) - PS_PrintToMainLog(env, " %1.1f", arr_reals[k]); - PS_PrintToMainLog(env, "\n"); + PN_PrintToMainLog(env, " %1.1f", arr_reals[k]); + PN_PrintToMainLog(env, "\n"); fflush(stdout);*/ for(k=num_lp_vars-1; k>=0; k--) @@ -1399,7 +1399,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti f = fopen("model.dot", "w"); /* create a file for writing */ f = NULL; if(f==NULL) { - PS_PrintToMainLog(env, "\nWarning: Output of graph cancelled (could not open file \"%s\").\n", "model.dot"); + PN_PrintToMainLog(env, "\nWarning: Output of graph cancelled (could not open file \"%s\").\n", "model.dot"); } else { fprintf(f, "digraph model {\n"); for(i=0; i 0.0) { // the number of branches in the current state h1 = map_var[head_node+1] - map_var[head_node]; - //PS_PrintToMainLog(env, "h1 = %1d\n", h1); + //PN_PrintToMainLog(env, "h1 = %1d\n", h1); double sum = 0; for(i=0; iReleaseLongArrayElements(_targets, target_ptrs, 0); if (relops) env->ReleaseIntArrayElements(_relops, relops, 0); if (bounds) env->ReleaseDoubleArrayElements(_bounds, bounds, 0); } catch (const char *err) { - PS_SetErrorMessage(err); + PN_SetErrorMessage(err); if (yes2_vec) delete yes2_vec; yes2_vec = 0; if (target_ptrs) env->ReleaseLongArrayElements(_targets, target_ptrs, 0); diff --git a/prism/src/sparse/PS_NondetMultiReach1.cc b/prism/src/sparse/PS_NondetMultiReach1.cc index c1c09da7d5..1fe314ce4f 100644 --- a/prism/src/sparse/PS_NondetMultiReach1.cc +++ b/prism/src/sparse/PS_NondetMultiReach1.cc @@ -36,7 +36,6 @@ #include "sparse.h" #include "sparse_adv.h" #include "prism.h" -#include "PrismSparseGlob.h" #include "PrismNativeGlob.h" #include "jnipointer.h" #include @@ -147,21 +146,21 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti yes[i] = targets[i]; // Display some info about the targets/combinations - PS_PrintToMainLog(env, "\n%d Targets:\n", num_targets); + PN_PrintToMainLog(env, "\n%d Targets:\n", num_targets); for (i = 0; i < num_targets; i++) { - PS_PrintToMainLog(env, "#%d: ", i); + PN_PrintToMainLog(env, "#%d: ", i); switch (relops[i]) { - case 0: PS_PrintToMainLog(env, "Pmax=?"); break; - case 1: PS_PrintToMainLog(env, "P>%g", bounds[i]); break; - case 2: PS_PrintToMainLog(env, "P>=%g", bounds[i]); break; + case 0: PN_PrintToMainLog(env, "Pmax=?"); break; + case 1: PN_PrintToMainLog(env, "P>%g", bounds[i]); break; + case 2: PN_PrintToMainLog(env, "P>=%g", bounds[i]); break; } - PS_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, targets[i], num_rvars)); + PN_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, targets[i], num_rvars)); } - PS_PrintToMainLog(env, "%d Target combinations:\n", num_combinations); + PN_PrintToMainLog(env, "%d Target combinations:\n", num_combinations); for (i = 0; i < num_combinations; i++) { - PS_PrintToMainLog(env, "#%d: ", i); - PS_PrintToMainLog(env, "%d ", (int)combinationIDs[i]); - PS_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, combinations[i], num_rvars)); + PN_PrintToMainLog(env, "#%d: ", i); + PN_PrintToMainLog(env, "%d ", (int)combinationIDs[i]); + PN_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, combinations[i], num_rvars)); } // Filter out rows, store in "a" @@ -191,7 +190,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti n = odd->eoff + odd->toff; // Build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); ndsm = build_nd_sparse_matrix(ddman, a, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // Get number of transitions/choices nnz = ndsm->nnz; @@ -199,13 +198,13 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti kb = ndsm->mem; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // If needed, and if info is available, build a vector of action indices for the MDP if (export_adv != EXPORT_ADV_NONE) { if (trans_actions != NULL) { - PS_PrintToMainLog(env, "Building action information... "); + PN_PrintToMainLog(env, "Building action information... "); // first need to filter out unwanted rows Cudd_Ref(trans_actions); Cudd_Ref(maybe_yes); @@ -217,39 +216,39 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti Cudd_RecursiveDeref(ddman, tmp); kb = n*4.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // also extract list of action names from 'synchs' get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions); } else { - PS_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); + PN_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); } } // Get vectors for yes/maybe - PS_PrintToMainLog(env, "Creating vectors for yes "); + PN_PrintToMainLog(env, "Creating vectors for yes "); for(i=0; inon_zeros; @@ -261,7 +260,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti unsigned int *cols = ndsm->cols; // Set up LP problem... - PS_PrintToMainLog(env, "\nBuilding LP problem...\n"); + PN_PrintToMainLog(env, "\nBuilding LP problem...\n"); int *yes_vec; @@ -333,7 +332,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti num_lp_vars = maybe_nc + yes_nc + yes_count; // Store first LP var for final state map_var[n] = num_lp_vars; // maybe need to be modified. - PS_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars); + PN_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars); for(i=0; i 0 && relops[0]<=2) { for(i=0; i 0) { // for qualitative queries, return 1/0 for existence of solution or not - PS_PrintToMainLog(env, "LP problem solution %sfound so result is %s\n", lp_solved ? "" : "not ", lp_solved ? "true" : "false"); + PN_PrintToMainLog(env, "LP problem solution %sfound so result is %s\n", lp_solved ? "" : "not ", lp_solved ? "true" : "false"); lp_result = lp_solved ? 1.0 : 0.0; } else { // return NaN for quantitative queries that can't be solved - PS_PrintToMainLog(env, "LP problem solution %sfound; result is %f\n", lp_solved ? "" : "not ", lp_result); + PN_PrintToMainLog(env, "LP problem solution %sfound; result is %f\n", lp_solved ? "" : "not ", lp_result); if (!lp_solved) lp_result = NAN; } // Print timing info time_taken = time_for_setup + time_for_lp; - PS_PrintToMainLog(env, "\nLP problem solved in %.2f seconds (setup %.2f, lpsolve %.2f)\n", time_taken, time_for_setup, time_for_lp); + PN_PrintToMainLog(env, "\nLP problem solved in %.2f seconds (setup %.2f, lpsolve %.2f)\n", time_taken, time_for_setup, time_for_lp); delete yes_vec; delete map_var; // Catch exceptions: register error } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); lp_result = NAN; } diff --git a/prism/src/sparse/PS_NondetMultiReachReward.cc b/prism/src/sparse/PS_NondetMultiReachReward.cc index b695de1d5f..85bae02a43 100644 --- a/prism/src/sparse/PS_NondetMultiReachReward.cc +++ b/prism/src/sparse/PS_NondetMultiReachReward.cc @@ -36,7 +36,6 @@ #include "sparse.h" #include "sparse_adv.h" #include "prism.h" -#include "PrismSparseGlob.h" #include "PrismNativeGlob.h" #include "jnipointer.h" #include @@ -157,27 +156,27 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti boundsReward = env->GetDoubleArrayElements(_boundsReward, 0); // Display some info about the targets - PS_PrintToMainLog(env, "\n%d Targets:\n", num_targets); + PN_PrintToMainLog(env, "\n%d Targets:\n", num_targets); for (i = 0; i < num_targets; i++) { - PS_PrintToMainLog(env, "#%d: ", i); + PN_PrintToMainLog(env, "#%d: ", i); switch (relops[i]) { - case 0: PS_PrintToMainLog(env, "Pmax=?"); break; - case 1: PS_PrintToMainLog(env, "P>%g", bounds[i]); break; - case 2: PS_PrintToMainLog(env, "P>=%g", bounds[i]); break; + case 0: PN_PrintToMainLog(env, "Pmax=?"); break; + case 1: PN_PrintToMainLog(env, "P>%g", bounds[i]); break; + case 2: PN_PrintToMainLog(env, "P>=%g", bounds[i]); break; } - PS_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, targets[i], num_rvars)); + PN_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, targets[i], num_rvars)); } // Display some info about the rewards - PS_PrintToMainLog(env, "\n%d Rewards:\n", num_rewards); + PN_PrintToMainLog(env, "\n%d Rewards:\n", num_rewards); bool disable_selfloop = true; for (i = 0; i < num_rewards; i++) { - PS_PrintToMainLog(env, "#%d: ", i); + PN_PrintToMainLog(env, "#%d: ", i); switch (relopsReward[i]) { - case 3: PS_PrintToMainLog(env, "Rmax=?\n"); disable_selfloop = false; break; - case 8: PS_PrintToMainLog(env, "Rmin=?\n"); break; - case 4: PS_PrintToMainLog(env, "R>=%g\n", boundsReward[i]); disable_selfloop = false; break; - case 9: PS_PrintToMainLog(env, "R<=%g\n", boundsReward[i]); break; + case 3: PN_PrintToMainLog(env, "Rmax=?\n"); disable_selfloop = false; break; + case 8: PN_PrintToMainLog(env, "Rmin=?\n"); break; + case 4: PN_PrintToMainLog(env, "R>=%g\n", boundsReward[i]); disable_selfloop = false; break; + case 9: PN_PrintToMainLog(env, "R<=%g\n", boundsReward[i]); break; } } @@ -206,7 +205,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti n = odd->eoff + odd->toff; // Build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); ndsm = build_nd_sparse_matrix(ddman, a, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // Get number of transitions/choices nnz = ndsm->nnz; @@ -214,13 +213,13 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti kb = ndsm->mem; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // If needed, and if info is available, build a vector of action indices for the MDP if (export_adv != EXPORT_ADV_NONE) { if (trans_actions != NULL) { - PS_PrintToMainLog(env, "Building action information... "); + PN_PrintToMainLog(env, "Building action information... "); // first need to filter out unwanted rows Cudd_Ref(trans_actions); Cudd_Ref(maybe_yes); @@ -234,40 +233,40 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti Cudd_RecursiveDeref(ddman, tmp); kb = n*4.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // also extract list of action names from 'synchs' get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions); } else { - PS_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); + PN_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); } } // Get vectors for yes/maybe - PS_PrintToMainLog(env, "Creating vectors for yes... "); + PN_PrintToMainLog(env, "Creating vectors for yes... "); for(i=0; inon_zeros; @@ -279,7 +278,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti unsigned int *cols = ndsm->cols; // Set up LP problem... - PS_PrintToMainLog(env, "\nBuilding LP problem...\n"); + PN_PrintToMainLog(env, "\nBuilding LP problem...\n"); int *yes_vec; int *map_var; @@ -348,7 +347,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti num_lp_vars = maybe_nc + yes_nc + yes_count + bottomec_nc; // Store first LP var for final state map_var[n] = num_lp_vars; // maybe need to be modified. - PS_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars); + PN_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars); for(i=0; i 0 && relops[0] == 0) { x = 0; @@ -631,7 +630,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti //export_model(ndsm, n, yes_vec, start_index); // Solve the LP, extract result - PS_PrintToMainLog(env, "Solving LP problem...\n"); + PN_PrintToMainLog(env, "Solving LP problem...\n"); res = solve(lp); //Get LP solving time @@ -639,7 +638,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti time_for_lp = (double)(stop2 - start2)/1000; if (res != 0) { - PS_PrintToMainLog(env, "No solution\n"); + PN_PrintToMainLog(env, "No solution\n"); lp_solved = false; } else { lp_solved = true; @@ -656,39 +655,39 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti /*for (i=0; i @@ -172,33 +171,33 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti boundsReward = env->GetDoubleArrayElements(_boundsReward, 0); // Display some info about the targets/combinations - PS_PrintToMainLog(env, "\n%d Targets:\n", num_targets); + PN_PrintToMainLog(env, "\n%d Targets:\n", num_targets); for (i = 0; i < num_targets; i++) { - PS_PrintToMainLog(env, "#%d: ", i); + PN_PrintToMainLog(env, "#%d: ", i); switch (relops[i]) { - case 0: PS_PrintToMainLog(env, "Pmax=?"); break; - case 1: PS_PrintToMainLog(env, "P>%g", bounds[i]); break; - case 2: PS_PrintToMainLog(env, "P>=%g", bounds[i]); break; + case 0: PN_PrintToMainLog(env, "Pmax=?"); break; + case 1: PN_PrintToMainLog(env, "P>%g", bounds[i]); break; + case 2: PN_PrintToMainLog(env, "P>=%g", bounds[i]); break; } - PS_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, targets[i], num_rvars)); + PN_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, targets[i], num_rvars)); } - PS_PrintToMainLog(env, "%d Target combinations:\n", num_combinations); + PN_PrintToMainLog(env, "%d Target combinations:\n", num_combinations); for (i = 0; i < num_combinations; i++) { - PS_PrintToMainLog(env, "#%d: ", i); - PS_PrintToMainLog(env, "%d ", (int)combinationIDs[i]); - PS_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, combinations[i], num_rvars)); + PN_PrintToMainLog(env, "#%d: ", i); + PN_PrintToMainLog(env, "%d ", (int)combinationIDs[i]); + PN_PrintToMainLog(env, " (%.0f states)\n", DD_GetNumMinterms(ddman, combinations[i], num_rvars)); } // Display some info about the rewards - PS_PrintToMainLog(env, "\n%d Rewards:\n", num_rewards); + PN_PrintToMainLog(env, "\n%d Rewards:\n", num_rewards); bool disable_selfloop = true; for (i = 0; i < num_rewards; i++) { - PS_PrintToMainLog(env, "#%d: ", i); + PN_PrintToMainLog(env, "#%d: ", i); switch (relopsReward[i]) { - case 3: PS_PrintToMainLog(env, "Rmax=?\n"); disable_selfloop = false; break; - case 8: PS_PrintToMainLog(env, "Rmin=?\n"); break; - case 4: PS_PrintToMainLog(env, "R>=%g\n", boundsReward[i]); disable_selfloop = false; break; - case 9: PS_PrintToMainLog(env, "R<=%g\n", boundsReward[i]); break; + case 3: PN_PrintToMainLog(env, "Rmax=?\n"); disable_selfloop = false; break; + case 8: PN_PrintToMainLog(env, "Rmin=?\n"); break; + case 4: PN_PrintToMainLog(env, "R>=%g\n", boundsReward[i]); disable_selfloop = false; break; + case 9: PN_PrintToMainLog(env, "R<=%g\n", boundsReward[i]); break; } } @@ -231,7 +230,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti n = odd->eoff + odd->toff; // Build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); ndsm = build_nd_sparse_matrix(ddman, a, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // Get number of transitions/choices nnz = ndsm->nnz; @@ -239,13 +238,13 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti kb = ndsm->mem; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // If needed, and if info is available, build a vector of action indices for the MDP if (export_adv != EXPORT_ADV_NONE) { if (trans_actions != NULL) { - PS_PrintToMainLog(env, "Building action information... "); + PN_PrintToMainLog(env, "Building action information... "); // first need to filter out unwanted rows Cudd_Ref(trans_actions); Cudd_Ref(maybe_yes); @@ -257,44 +256,44 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti Cudd_RecursiveDeref(ddman, tmp); kb = n*4.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // also extract list of action names from 'synchs' get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions); } else { - PS_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); + PN_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); } } // Get vectors for yes/maybe - PS_PrintToMainLog(env, "Creating vectors for yes "); + PN_PrintToMainLog(env, "Creating vectors for yes "); for(i=0; inon_zeros; @@ -306,7 +305,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti unsigned int *cols = ndsm->cols; // Set up LP problem... - PS_PrintToMainLog(env, "\nBuilding LP problem...\n"); + PN_PrintToMainLog(env, "\nBuilding LP problem...\n"); int *yes_vec; int *map_var; @@ -381,7 +380,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti num_lp_vars = maybe_nc + yes_nc + yes_count + bottomec_nc; // Store first LP var for final state map_var[n] = num_lp_vars; // maybe need to be modified. - PS_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars); + PN_PrintToMainLog(env, "Number of LP variables = %1d\n", num_lp_vars); for(i=0; i 0 && relops[0] == 0) { x = 0; @@ -706,7 +705,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti //export_model(ndsm, n, yes_vec, start_index); // Solve the LP, extract result - PS_PrintToMainLog(env, "Solving LP problem...\n"); + PN_PrintToMainLog(env, "Solving LP problem...\n"); res = solve(lp); //Get LP solving time @@ -714,7 +713,7 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti time_for_lp = (double)(stop2 - start2)/1000; if (res != 0) { - PS_PrintToMainLog(env, "No solution\n"); + PN_PrintToMainLog(env, "No solution\n"); lp_solved = false; } else { lp_solved = true; @@ -731,39 +730,39 @@ JNIEXPORT jdouble __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1NondetMulti /*for (i=0; i @@ -132,7 +131,7 @@ jboolean min // min or max probabilities (true = min, false = max) trans_rewards = DD_Apply(ddman, APPLY_TIMES, trans_rewards, maybe); // build sparse matrix (probs) - PS_PrintToMainLog(env, "\nBuilding sparse matrix (transitions)... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix (transitions)... "); ndsm = build_nd_sparse_matrix(ddman, a, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // get number of transitions/choices nnz = ndsm->nnz; @@ -140,13 +139,13 @@ jboolean min // min or max probabilities (true = min, false = max) kb = (nnz*12.0+nc*4.0+n*4.0)/1024.0; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // if needed, and if info is available, build a vector of action indices for the MDP if (export_adv_enabled != EXPORT_ADV_NONE) { if (trans_actions != NULL) { - PS_PrintToMainLog(env, "Building action information... "); + PN_PrintToMainLog(env, "Building action information... "); // first need to filter out unwanted rows Cudd_Ref(trans_actions); Cudd_Ref(maybe); @@ -156,55 +155,55 @@ jboolean min // min or max probabilities (true = min, false = max) Cudd_RecursiveDeref(ddman, tmp); kb = n*4.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // also extract list of action names from 'synchs' get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions); } else { - PS_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); + PN_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); } } // build sparse matrix (rewards) - PS_PrintToMainLog(env, "Building sparse matrix (transition rewards)... "); + PN_PrintToMainLog(env, "Building sparse matrix (transition rewards)... "); ndsm_r = build_sub_nd_sparse_matrix(ddman, a, trans_rewards, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // get number of transitions/choices nnz_r = ndsm_r->nnz; nc_r = ndsm_r->nc; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); kb = (nnz_r*12.0+nc_r*4.0+n*4.0)/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector for state rewards - PS_PrintToMainLog(env, "Creating vector for state rewards... "); + PN_PrintToMainLog(env, "Creating vector for state rewards... "); sr_vec = mtbdd_to_double_vector(ddman, state_rewards, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector for yes - PS_PrintToMainLog(env, "Creating vector for inf... "); + PN_PrintToMainLog(env, "Creating vector for inf... "); inf_vec = mtbdd_to_double_vector(ddman, inf, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = new double[n]; soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PS_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // if required, create storage for adversary and initialise if (export_adv_enabled != EXPORT_ADV_NONE) { - PS_PrintToMainLog(env, "Allocating adversary vector... "); + PN_PrintToMainLog(env, "Allocating adversary vector... "); adv = new int[n]; kb = n*sizeof(int)/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // Initialise all entries to -1 ("don't know") for (i = 0; i < n; i++) { adv[i] = -1; @@ -212,7 +211,7 @@ jboolean min // min or max probabilities (true = min, false = max) } // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution is infinity in 'inf' states, zero elsewhere for (i = 0; i < n; i++) { @@ -220,9 +219,9 @@ jboolean min // min or max probabilities (true = min, false = max) } std::unique_ptr iterationExport; - if (PS_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PS_NondetReachReward")); - PS_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln, n, 0); } @@ -235,13 +234,13 @@ jboolean min // min or max probabilities (true = min, false = max) // start iterations iters = 0; done = false; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // open file to store adversary (if required) if (export_adv_enabled != EXPORT_ADV_NONE) { fp_adv = fopen(export_adv_filename, "w"); if (!fp_adv) { - PS_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").", export_adv_filename); + PN_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").", export_adv_filename); export_adv_enabled = EXPORT_ADV_NONE; } } @@ -335,8 +334,8 @@ jboolean min // min or max probabilities (true = min, false = max) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -399,15 +398,15 @@ jboolean min // min or max probabilities (true = min, false = max) time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error - if (!done) { delete[] soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } + if (!done) { delete[] soln; soln = NULL; PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } // close file to store adversary (if required) if (export_adv_enabled != EXPORT_ADV_NONE) { fclose(fp_adv); - PS_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", export_adv_filename); + PN_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", export_adv_filename); } // the difference between vector values is not a reliable error bound @@ -416,7 +415,7 @@ jboolean min // min or max probabilities (true = min, false = max) // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_NondetReachRewardInterval.cc b/prism/src/sparse/PS_NondetReachRewardInterval.cc index 5392f20f7a..97e40e9a54 100644 --- a/prism/src/sparse/PS_NondetReachRewardInterval.cc +++ b/prism/src/sparse/PS_NondetReachRewardInterval.cc @@ -36,7 +36,6 @@ #include "sparse.h" #include "prism.h" #include "PrismNativeGlob.h" -#include "PrismSparseGlob.h" #include "jnipointer.h" #include "ExportIterations.h" #include "IntervalIteration.h" @@ -116,10 +115,10 @@ jint flags IntervalIteration helper(flags); if (!helper.flag_ensure_monotonic_from_above()) { - PS_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); } if (!helper.flag_ensure_monotonic_from_below()) { - PS_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); } // exception handling around whole function @@ -147,7 +146,7 @@ jint flags trans_rewards = DD_Apply(ddman, APPLY_TIMES, trans_rewards, maybe); // build sparse matrix (probs) - PS_PrintToMainLog(env, "\nBuilding sparse matrix (transitions)... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix (transitions)... "); ndsm = build_nd_sparse_matrix(ddman, a, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // get number of transitions/choices nnz = ndsm->nnz; @@ -155,13 +154,13 @@ jint flags kb = (nnz*12.0+nc*4.0+n*4.0)/1024.0; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // if needed, and if info is available, build a vector of action indices for the MDP if (export_adv_enabled != EXPORT_ADV_NONE) { if (trans_actions != NULL) { - PS_PrintToMainLog(env, "Building action information... "); + PN_PrintToMainLog(env, "Building action information... "); // first need to filter out unwanted rows Cudd_Ref(trans_actions); Cudd_Ref(maybe); @@ -171,71 +170,71 @@ jint flags Cudd_RecursiveDeref(ddman, tmp); kb = n*4.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // also extract list of action names from 'synchs' get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions); } else { - PS_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); + PN_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); } } // build sparse matrix (rewards) - PS_PrintToMainLog(env, "Building sparse matrix (transition rewards)... "); + PN_PrintToMainLog(env, "Building sparse matrix (transition rewards)... "); ndsm_r = build_sub_nd_sparse_matrix(ddman, a, trans_rewards, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // get number of transitions/choices nnz_r = ndsm_r->nnz; nc_r = ndsm_r->nc; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc_r, nnz_r, ndsm_r->k); kb = (nnz_r*12.0+nc_r*4.0+n*4.0)/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector for state rewards - PS_PrintToMainLog(env, "Creating vector for state rewards... "); + PN_PrintToMainLog(env, "Creating vector for state rewards... "); sr_vec = mtbdd_to_double_vector(ddman, state_rewards, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector for yes - PS_PrintToMainLog(env, "Creating vector for inf... "); + PN_PrintToMainLog(env, "Creating vector for inf... "); inf_vec = mtbdd_to_double_vector(ddman, inf, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector for lower bounds - PS_PrintToMainLog(env, "Creating vector for lower bounds... "); + PN_PrintToMainLog(env, "Creating vector for lower bounds... "); lower_vec = mtbdd_to_double_vector(ddman, lower, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector for lower bounds - PS_PrintToMainLog(env, "Creating vector for upper bounds... "); + PN_PrintToMainLog(env, "Creating vector for upper bounds... "); upper_vec = mtbdd_to_double_vector(ddman, upper, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln_below = new double[n]; soln_below2 = new double[n]; soln_above = new double[n]; soln_above2 = new double[n]; kb = n*8.0/1024.0; kbt += 4*kb; - PS_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); // if required, create storage for adversary and initialise if (export_adv_enabled != EXPORT_ADV_NONE) { - PS_PrintToMainLog(env, "Allocating adversary vector... "); + PN_PrintToMainLog(env, "Allocating adversary vector... "); adv = new int[n]; kb = n*sizeof(int)/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // Initialise all entries to -1 ("don't know") for (i = 0; i < n; i++) { adv[i] = -1; @@ -243,7 +242,7 @@ jint flags } // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution from below is infinity in 'inf' states, lower elsewhere // initial solution from above is infinity in 'inf' states, upper elsewhere @@ -253,9 +252,9 @@ jint flags } std::unique_ptr iterationExport; - if (PS_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PS_NondetReachReward (interval)")); - PS_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln_below, n, 0); iterationExport->exportVector(soln_above, n, 1); } @@ -269,13 +268,13 @@ jint flags // start iterations iters = 0; done = false; - PS_PrintToMainLog(env, "\nStarting iterations (interval iteration)...\n"); + PN_PrintToMainLog(env, "\nStarting iterations (interval iteration)...\n"); // open file to store adversary (if required) if (export_adv_enabled != EXPORT_ADV_NONE) { fp_adv = fopen(export_adv_filename, "w"); if (!fp_adv) { - PS_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").", export_adv_filename); + PN_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").", export_adv_filename); export_adv_enabled = EXPORT_ADV_NONE; } } @@ -407,14 +406,14 @@ jint flags measure.reset(); measure.measure(soln_below2, soln_above2, n); if (measure.value() < term_crit_param) { - PS_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); done = true; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -480,20 +479,20 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!done) { delete[] soln_below; soln_below = NULL; - PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); - PS_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); } // close file to store adversary (if required) if (export_adv_enabled != EXPORT_ADV_NONE) { fclose(fp_adv); - PS_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", export_adv_filename); + PN_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", export_adv_filename); } if (helper.flag_select_midpoint() && soln_below) { // we did converge, select midpoint @@ -509,7 +508,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln_below) delete[] soln_below; soln_below = 0; } diff --git a/prism/src/sparse/PS_NondetUntil.cc b/prism/src/sparse/PS_NondetUntil.cc index 54ca868d78..338a52693f 100644 --- a/prism/src/sparse/PS_NondetUntil.cc +++ b/prism/src/sparse/PS_NondetUntil.cc @@ -35,7 +35,6 @@ #include "sparse.h" #include "prism.h" #include "PrismNativeGlob.h" -#include "PrismSparseGlob.h" #include "jnipointer.h" #include "Measures.h" #include "ExportIterations.h" @@ -130,7 +129,7 @@ jlong _strat // strategy storage n = odd->eoff + odd->toff; // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); ndsm = build_nd_sparse_matrix(ddman, a, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // get number of transitions/choices nnz = ndsm->nnz; @@ -138,13 +137,13 @@ jlong _strat // strategy storage kb = ndsm->mem; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // if needed, and if info is available, build a vector of action indices for the MDP if (export_adv_enabled != EXPORT_ADV_NONE || strat != NULL) { if (trans_actions != NULL) { - PS_PrintToMainLog(env, "Building action information... "); + PN_PrintToMainLog(env, "Building action information... "); // first need to filter out unwanted rows Cudd_Ref(trans_actions); Cudd_Ref(maybe); @@ -154,32 +153,32 @@ jlong _strat // strategy storage Cudd_RecursiveDeref(ddman, tmp); kb = n*4.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // also extract list of action names from 'synchs' get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions); } else { - PS_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); + PN_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); } } // get vector for yes - PS_PrintToMainLog(env, "Creating vector for yes... "); + PN_PrintToMainLog(env, "Creating vector for yes... "); yes_vec = mtbdd_to_double_vector(ddman, yes, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = new double[n]; soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PS_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // if required, create storage for adversary and initialise if (export_adv_enabled != EXPORT_ADV_NONE || strat != NULL) { - PS_PrintToMainLog(env, "Allocating adversary vector... "); + PN_PrintToMainLog(env, "Allocating adversary vector... "); // Use passed in (pre-filled) array, if provided if (strat) { adv = strat; @@ -192,11 +191,11 @@ jlong _strat // strategy storage } kb = n*sizeof(int)/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution is yes for (i = 0; i < n; i++) { @@ -205,9 +204,9 @@ jlong _strat // strategy storage } std::unique_ptr iterationExport; - if (PS_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PS_NondetUntil")); - PS_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln, n, 0); } @@ -220,13 +219,13 @@ jlong _strat // strategy storage // start iterations iters = 0; done = false; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // open file to store adversary (if required) if (export_adv_enabled != EXPORT_ADV_NONE) { fp_adv = fopen(export_adv_filename, "w"); if (!fp_adv) { - PS_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").", export_adv_filename); + PN_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").", export_adv_filename); export_adv_enabled = EXPORT_ADV_NONE; } } @@ -295,8 +294,8 @@ jlong _strat // strategy storage // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -359,15 +358,15 @@ jlong _strat // strategy storage time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error - if (!done) { delete[] soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } + if (!done) { delete[] soln; soln = NULL; PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } // close file to store adversary (if required) if (export_adv_enabled != EXPORT_ADV_NONE) { fclose(fp_adv); - PS_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", export_adv_filename); + PN_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", export_adv_filename); } // convert strategy indices from choices to actions @@ -383,7 +382,7 @@ jlong _strat // strategy storage // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_NondetUntilInterval.cc b/prism/src/sparse/PS_NondetUntilInterval.cc index 4e82ac5288..aef9f9d9a8 100644 --- a/prism/src/sparse/PS_NondetUntilInterval.cc +++ b/prism/src/sparse/PS_NondetUntilInterval.cc @@ -35,7 +35,6 @@ #include "sparse.h" #include "prism.h" #include "PrismNativeGlob.h" -#include "PrismSparseGlob.h" #include "jnipointer.h" #include "Measures.h" #include "ExportIterations.h" @@ -110,10 +109,10 @@ jint flags IntervalIteration helper(flags); if (!helper.flag_ensure_monotonic_from_above()) { - PS_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); } if (helper.flag_ensure_monotonic_from_below()) { - PS_PrintToMainLog(env, "Note: Interval iteration is configured to enforce monotonicity from below.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to enforce monotonicity from below.\n"); } // exception handling around whole function @@ -143,7 +142,7 @@ jint flags n = odd->eoff + odd->toff; // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); ndsm = build_nd_sparse_matrix(ddman, a, rvars, cvars, num_rvars, ndvars, num_ndvars, odd); // get number of transitions/choices nnz = ndsm->nnz; @@ -151,13 +150,13 @@ jint flags kb = ndsm->mem; kbt = kb; // print out info - PS_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nc=%d, nnz=%ld, k=%d] ", n, nc, nnz, ndsm->k); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // if needed, and if info is available, build a vector of action indices for the MDP if (export_adv_enabled != EXPORT_ADV_NONE || strat != NULL) { if (trans_actions != NULL) { - PS_PrintToMainLog(env, "Building action information... "); + PN_PrintToMainLog(env, "Building action information... "); // first need to filter out unwanted rows Cudd_Ref(trans_actions); Cudd_Ref(maybe); @@ -167,41 +166,41 @@ jint flags Cudd_RecursiveDeref(ddman, tmp); kb = n*4.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // also extract list of action names from 'synchs' get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions); } else { - PS_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); + PN_PrintWarningToMainLog(env, "Action labels are not available for adversary generation."); } } // get vector for yes - PS_PrintToMainLog(env, "Creating vector for yes... "); + PN_PrintToMainLog(env, "Creating vector for yes... "); yes_vec = mtbdd_to_double_vector(ddman, yes, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector for yes - PS_PrintToMainLog(env, "Creating vector for maybe... "); + PN_PrintToMainLog(env, "Creating vector for maybe... "); maybe_vec = mtbdd_to_double_vector(ddman, maybe, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln_below = new double[n]; soln_below2 = new double[n]; soln_above = new double[n]; soln_above2 = new double[n]; kb = n*8.0/1024.0; kbt += 4*kb; - PS_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); // if required, create storage for adversary and initialise if (export_adv_enabled != EXPORT_ADV_NONE || strat != NULL) { - PS_PrintToMainLog(env, "Allocating adversary vector... "); + PN_PrintToMainLog(env, "Allocating adversary vector... "); // Use passed in (pre-filled) array, if provided if (strat) { adv = strat; @@ -214,11 +213,11 @@ jint flags } kb = n*sizeof(int)/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution for below is yes, from above is 1 (expect for no states) for (i = 0; i < n; i++) { @@ -233,9 +232,9 @@ jint flags } std::unique_ptr iterationExport; - if (PS_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PS_NondetUntil_Interval")); - PS_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln_below, n, 0); iterationExport->exportVector(soln_above, n, 1); } @@ -249,13 +248,13 @@ jint flags // start iterations iters = 0; done = false; - PS_PrintToMainLog(env, "\nStarting iterations (interval iteration)...\n"); + PN_PrintToMainLog(env, "\nStarting iterations (interval iteration)...\n"); // open file to store adversary (if required) if (export_adv_enabled != EXPORT_ADV_NONE) { fp_adv = fopen(export_adv_filename, "w"); if (!fp_adv) { - PS_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").", export_adv_filename); + PN_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").", export_adv_filename); export_adv_enabled = EXPORT_ADV_NONE; } } @@ -355,14 +354,14 @@ jint flags measure.reset(); measure.measure(soln_below2, soln_above2, n); if (measure.value() < term_crit_param) { - PS_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); done = true; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -428,14 +427,14 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "\nIterative method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!done) { delete[] soln_below; soln_below = NULL; - PS_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); - PS_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); } if (helper.flag_select_midpoint() && soln_below) { // we did converge, select midpoint @@ -452,7 +451,7 @@ jint flags // close file to store adversary (if required) if (export_adv_enabled != EXPORT_ADV_NONE) { fclose(fp_adv); - PS_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", export_adv_filename); + PN_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", export_adv_filename); } // convert strategy indices from choices to actions @@ -464,7 +463,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln_below) delete[] soln_below; soln_below = 0; } diff --git a/prism/src/sparse/PS_Power.cc b/prism/src/sparse/PS_Power.cc index ff67cfc5fe..1b08e41f21 100644 --- a/prism/src/sparse/PS_Power.cc +++ b/prism/src/sparse/PS_Power.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -104,7 +104,7 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) Cudd_Ref(a); // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_a = true; cmsrsm = NULL; @@ -122,12 +122,12 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // build b vector (if present) if (b != NULL) { - PS_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -139,25 +139,25 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PS_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = mtbdd_to_double_vector(ddman, init, rvars, num_rvars, odd); soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PS_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PS_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PS_Power")); - PS_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln, n, 0); } @@ -170,7 +170,7 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) // start iterations iters = 0; done = false; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -235,8 +235,8 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, (measure.isRelative()?"relative ":""), measure.value()); - PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, (measure.isRelative()?"relative ":""), measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -252,10 +252,10 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) time_taken = (double)(stop - start1)/1000; // print iters/timing info - PS_PrintToMainLog(env, "\nPower method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nPower method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error - if (!done) { delete[] soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } + if (!done) { delete[] soln; soln = NULL; PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } // the difference between vector values is not a reliable error bound // but we store it anyway in case it is useful for estimating a bound @@ -263,7 +263,7 @@ jboolean transpose // transpose A? (i.e. solve xA=x not Ax=x?) // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_PowerInterval.cc b/prism/src/sparse/PS_PowerInterval.cc index fe2d9d9aa0..3e6f4c8c94 100644 --- a/prism/src/sparse/PS_PowerInterval.cc +++ b/prism/src/sparse/PS_PowerInterval.cc @@ -34,7 +34,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -111,7 +111,7 @@ jint flags Cudd_Ref(a); // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_a = true; cmsrsm = NULL; @@ -129,12 +129,12 @@ jint flags } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // build b vector (if present) if (b != NULL) { - PS_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -146,27 +146,27 @@ jint flags } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PS_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln_below = mtbdd_to_double_vector(ddman, lower, rvars, num_rvars, odd); soln_above = mtbdd_to_double_vector(ddman, upper, rvars, num_rvars, odd); soln_below2 = new double[n]; soln_above2 = new double[n]; kb = n*8.0/1024.0; kbt += 4*kb; - PS_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[4 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PS_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { iterationExport.reset(new ExportIterations("PS_PowerInterval")); - PS_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln_below, n, 0); iterationExport->exportVector(soln_above, n, 1); } @@ -180,7 +180,7 @@ jint flags // start iterations iters = 0; done = false; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -246,14 +246,14 @@ jint flags measure.reset(); measure.measure(soln_below2, soln_above2, n); if (measure.value() < term_crit_param) { - PS_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); done = true; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -272,14 +272,14 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iters/timing info - PS_PrintToMainLog(env, "\nPower method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nPower method (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!done) { delete[] soln_below; soln_below = NULL; - PS_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); - PS_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); } if (helper.flag_select_midpoint() && soln_below) { // we did converge, select midpoint @@ -295,7 +295,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln_below) delete[] soln_below; soln_below = 0; } diff --git a/prism/src/sparse/PS_ProbBoundedUntil.cc b/prism/src/sparse/PS_ProbBoundedUntil.cc index 0567d136d2..e9c804b02a 100644 --- a/prism/src/sparse/PS_ProbBoundedUntil.cc +++ b/prism/src/sparse/PS_ProbBoundedUntil.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include @@ -98,7 +98,7 @@ jint bound // time bound a = DD_Apply(ddman, APPLY_TIMES, trans, maybe); // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_tr = true; cmsrsm = NULL; @@ -116,11 +116,11 @@ jint bound // time bound } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of yes - PS_PrintToMainLog(env, "Creating vector for yes... "); + PN_PrintToMainLog(env, "Creating vector for yes... "); yes_vec = mtbdd_to_double_vector(ddman, yes, rvars, num_rvars, odd); // try and convert to compact form if required compact_y = false; @@ -132,19 +132,19 @@ jint bound // time bound } kb = (!compact_y) ? n*8.0/1024.0 : (yes_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_y) PS_PrintToMainLog(env, "[dist=%d, compact] ", yes_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_y) PN_PrintToMainLog(env, "[dist=%d, compact] ", yes_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = new double[n]; soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PS_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution is q for (i = 0; i < n; i++) { @@ -158,7 +158,7 @@ jint bound // time bound start3 = stop; // start iterations - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -213,8 +213,8 @@ jint bound // time bound // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PS_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -230,11 +230,11 @@ jint bound // time bound time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_ProbCumulReward.cc b/prism/src/sparse/PS_ProbCumulReward.cc index 9f4abd3a12..35372c3c5e 100644 --- a/prism/src/sparse/PS_ProbCumulReward.cc +++ b/prism/src/sparse/PS_ProbCumulReward.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include @@ -93,7 +93,7 @@ jint bound // time bound n = odd->eoff + odd->toff; // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_tr = true; cmsrsm = NULL; @@ -111,8 +111,8 @@ jint bound // time bound } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // multiply transition rewards by transition probs and sum rows // then combine state and transition rewards and put in a vector @@ -124,7 +124,7 @@ jint bound // time bound all_rewards = DD_Apply(ddman, APPLY_PLUS, state_rewards, all_rewards); // get vector of rewards - PS_PrintToMainLog(env, "Creating vector for rewards... "); + PN_PrintToMainLog(env, "Creating vector for rewards... "); rew_vec = mtbdd_to_double_vector(ddman, all_rewards, rvars, num_rvars, odd); // try and convert to compact form if required compact_r = false; @@ -136,19 +136,19 @@ jint bound // time bound } kb = (!compact_r) ? n*8.0/1024.0 : (rew_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_r) PS_PrintToMainLog(env, "[dist=%d, compact] ", rew_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_r) PN_PrintToMainLog(env, "[dist=%d, compact] ", rew_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = new double[n]; soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PS_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // initial solution is zero for (i = 0; i < n; i++) { @@ -162,7 +162,7 @@ jint bound // time bound start3 = stop; // start iterations - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -215,8 +215,8 @@ jint bound // time bound // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PS_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -232,11 +232,11 @@ jint bound // time bound time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_ProbInstReward.cc b/prism/src/sparse/PS_ProbInstReward.cc index 785eede096..f68909cb57 100644 --- a/prism/src/sparse/PS_ProbInstReward.cc +++ b/prism/src/sparse/PS_ProbInstReward.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include @@ -88,7 +88,7 @@ jint bound // time bound n = odd->eoff + odd->toff; // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_tr = true; cmsrsm = NULL; @@ -106,20 +106,20 @@ jint bound // time bound } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors // (solution is initialised to the state rewards) - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = mtbdd_to_double_vector(ddman, state_rewards, rvars, num_rvars, odd); soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PS_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // get setup time stop = util_cpu_time(); @@ -128,7 +128,7 @@ jint bound // time bound start3 = stop; // start iterations - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < bound; iters++) { @@ -181,8 +181,8 @@ jint bound // time bound // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); - PS_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)bound); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -198,11 +198,11 @@ jint bound // time bound time_taken = (double)(stop - start1)/1000; // print iterations/timing info - PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_ProbReachReward.cc b/prism/src/sparse/PS_ProbReachReward.cc index ae77c08975..bc6091292d 100644 --- a/prism/src/sparse/PS_ProbReachReward.cc +++ b/prism/src/sparse/PS_ProbReachReward.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include @@ -134,7 +134,7 @@ jlong __jlongpointer m // 'maybe' states case LIN_EQ_METHOD_BSOR: soln = jlong_to_double(Java_sparse_PrismSparse_PS_1SOR(env, cls, ptr_to_jlong(odd), ptr_to_jlong(rvars), num_rvars, ptr_to_jlong(cvars), num_cvars, ptr_to_jlong(a), ptr_to_jlong(state_rewards), ptr_to_jlong(state_rewards), false, false, lin_eq_method_param, false)); break; default: - PS_SetErrorMessage("Pseudo Gauss-Seidel/SOR methods are currently not supported by the sparse engine"); return 0; + PN_SetErrorMessage("Pseudo Gauss-Seidel/SOR methods are currently not supported by the sparse engine"); return 0; } // set reward for infinity states to infinity @@ -148,7 +148,7 @@ jlong __jlongpointer m // 'maybe' states // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_ProbReachRewardInterval.cc b/prism/src/sparse/PS_ProbReachRewardInterval.cc index 678e6b76a1..3837fea104 100644 --- a/prism/src/sparse/PS_ProbReachRewardInterval.cc +++ b/prism/src/sparse/PS_ProbReachRewardInterval.cc @@ -34,7 +34,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "IntervalIteration.h" #include "jnipointer.h" #include @@ -125,10 +125,10 @@ jint flags IntervalIteration helper(flags); if (!helper.flag_ensure_monotonic_from_above()) { - PS_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); } if (!helper.flag_ensure_monotonic_from_below()) { - PS_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); } // call iterative method @@ -149,7 +149,7 @@ jint flags case LIN_EQ_METHOD_BSOR: soln = jlong_to_double(Java_sparse_PrismSparse_PS_1SORInterval(env, cls, ptr_to_jlong(odd), ptr_to_jlong(rvars), num_rvars, ptr_to_jlong(cvars), num_cvars, ptr_to_jlong(a), ptr_to_jlong(state_rewards), ptr_to_jlong(lower), ptr_to_jlong(upper), false, false, lin_eq_method_param, false, flags)); break; default: - PS_SetErrorMessage("Pseudo Gauss-Seidel/SOR methods are currently not supported by the sparse engine"); return 0; + PN_SetErrorMessage("Pseudo Gauss-Seidel/SOR methods are currently not supported by the sparse engine"); return 0; } // set reward for infinity states to infinity @@ -163,7 +163,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_ProbTransient.cc b/prism/src/sparse/PS_ProbTransient.cc index 4a6df9ef12..743aed8b80 100644 --- a/prism/src/sparse/PS_ProbTransient.cc +++ b/prism/src/sparse/PS_ProbTransient.cc @@ -34,7 +34,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "Measures.h" #include @@ -92,7 +92,7 @@ jint time // time n = odd->eoff + odd->toff; // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_tr = true; cmscsm = NULL; @@ -110,21 +110,21 @@ jint time // time } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); // for soln, we just use init (since we are free to modify/delete this vector) // we also report the memory usage of this vector here, even though it has already been created soln = init; soln2 = new double[n]; kb = n*8.0/1024.0; kbt += 2*kb; - PS_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[2 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // get setup time stop = util_cpu_time(); @@ -135,7 +135,7 @@ jint time // time // start iterations iters = 0; done = false; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // note that we ignore max_iters as we know how any iterations _should_ be performed for (iters = 0; iters < time && !done; iters++) { @@ -197,9 +197,9 @@ jint time // time // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)time); - if (do_ss_detect) PS_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d (of %d): ", iters, (int)time); + if (do_ss_detect) PN_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -215,12 +215,12 @@ jint time // time time_taken = (double)(stop - start1)/1000; // print iters/timing info - if (done) PS_PrintToMainLog(env, "\nSteady state detected at iteration %d\n", iters); - PS_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); + if (done) PN_PrintToMainLog(env, "\nSteady state detected at iteration %d\n", iters); + PN_PrintToMainLog(env, "\nIterative method: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", iters, time_taken, time_for_iters/iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_ProbUntil.cc b/prism/src/sparse/PS_ProbUntil.cc index d14d3ca3f7..ae2ae9d49e 100644 --- a/prism/src/sparse/PS_ProbUntil.cc +++ b/prism/src/sparse/PS_ProbUntil.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include @@ -107,12 +107,12 @@ jlong __jlongpointer m // 'maybe' states case LIN_EQ_METHOD_BSOR: soln = jlong_to_double(Java_sparse_PrismSparse_PS_1SOR(env, cls, ptr_to_jlong(odd), ptr_to_jlong(rvars), num_rvars, ptr_to_jlong(cvars), num_cvars, ptr_to_jlong(a), ptr_to_jlong(b), ptr_to_jlong(b), false, false, lin_eq_method_param, false)); break; default: - PS_SetErrorMessage("Pseudo Gauss-Seidel/SOR methods are currently not supported by the sparse engine"); return 0; + PN_SetErrorMessage("Pseudo Gauss-Seidel/SOR methods are currently not supported by the sparse engine"); return 0; } // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_ProbUntilInterval.cc b/prism/src/sparse/PS_ProbUntilInterval.cc index bbfc58be0a..6a0d0a5faf 100644 --- a/prism/src/sparse/PS_ProbUntilInterval.cc +++ b/prism/src/sparse/PS_ProbUntilInterval.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "IntervalIteration.h" #include "jnipointer.h" #include @@ -101,10 +101,10 @@ jint flags IntervalIteration helper(flags); if (!helper.flag_ensure_monotonic_from_above()) { - PS_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from above.\n"); } if (!helper.flag_ensure_monotonic_from_below()) { - PS_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); + PN_PrintToMainLog(env, "Note: Interval iteration is configured to not enforce monotonicity from below.\n"); } // call iterative method @@ -125,12 +125,12 @@ jint flags case LIN_EQ_METHOD_BSOR: soln = jlong_to_double(Java_sparse_PrismSparse_PS_1SORInterval(env, cls, ptr_to_jlong(odd), ptr_to_jlong(rvars), num_rvars, ptr_to_jlong(cvars), num_cvars, ptr_to_jlong(a), ptr_to_jlong(b), ptr_to_jlong(lower), ptr_to_jlong(upper), false, false, lin_eq_method_param, false, flags)); break; default: - PS_SetErrorMessage("Pseudo Gauss-Seidel/SOR methods are currently not supported by the sparse engine"); return 0; + PN_SetErrorMessage("Pseudo Gauss-Seidel/SOR methods are currently not supported by the sparse engine"); return 0; } // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_SOR.cc b/prism/src/sparse/PS_SOR.cc index 69b5b8943b..b3bd282928 100644 --- a/prism/src/sparse/PS_SOR.cc +++ b/prism/src/sparse/PS_SOR.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -120,7 +120,7 @@ jboolean forwards // forwards or backwards? a = DD_ITE(ddman, id, DD_Constant(ddman, 0), a); // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_a = true; cmsrsm = NULL; @@ -138,12 +138,12 @@ jboolean forwards // forwards or backwards? } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diags, either by extracting from mtbdd or // by doing (negative, non-diagonal) row sums of original A matrix - PS_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); if (!row_sums) { diags = DD_MaxAbstract(ddman, diags, cvars, num_cvars); diags_vec = mtbdd_to_double_vector(ddman, diags, rvars, num_rvars, odd); @@ -164,8 +164,8 @@ jboolean forwards // forwards or backwards? } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PS_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // invert diagonal if (!compact_d) { @@ -176,7 +176,7 @@ jboolean forwards // forwards or backwards? // build b vector (if present) if (b != NULL) { - PS_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -188,28 +188,28 @@ jboolean forwards // forwards or backwards? } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PS_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vector... "); + PN_PrintToMainLog(env, "Allocating iteration vector... "); soln = mtbdd_to_double_vector(ddman, init, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += kb; - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PS_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PS_SOR ("); title += forwards?"":"Backwards "; title += (omega == 1.0)?"Gauss-Seidel":("SOR omega=" + std::to_string(omega)); title += ")"; iterationExport.reset(new ExportIterations(title.c_str())); - PS_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln, n, 0); } @@ -222,7 +222,7 @@ jboolean forwards // forwards or backwards? // start iterations iters = 0; done = false; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -301,8 +301,8 @@ jboolean forwards // forwards or backwards? // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } } @@ -313,10 +313,10 @@ jboolean forwards // forwards or backwards? time_taken = (double)(stop - start1)/1000; // print iters/timing info - PS_PrintToMainLog(env, "\n%s%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%s%s: %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error - if (!done) { delete[] soln; soln = NULL; PS_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } + if (!done) { delete[] soln; soln = NULL; PN_SetErrorMessage("Iterative method did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); } // the difference between vector values is not a reliable error bound // but we store it anyway in case it is useful for estimating a bound @@ -324,7 +324,7 @@ jboolean forwards // forwards or backwards? // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_SORInterval.cc b/prism/src/sparse/PS_SORInterval.cc index 0a3056f05b..9c54e3be04 100644 --- a/prism/src/sparse/PS_SORInterval.cc +++ b/prism/src/sparse/PS_SORInterval.cc @@ -34,7 +34,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -100,7 +100,7 @@ jint flags MeasureSupNorm measure(term_crit == TERM_CRIT_RELATIVE); if (omega <= 0.0 || omega > 1.0) { - PS_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); + PN_SetErrorMessage("Interval iteration requires 0 < omega <= 1.0, have omega = %g", omega); return ptr_to_jlong(NULL); } @@ -132,7 +132,7 @@ jint flags a = DD_ITE(ddman, id, DD_Constant(ddman, 0), a); // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_a = true; cmsrsm = NULL; @@ -150,12 +150,12 @@ jint flags } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_a?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diags, either by extracting from mtbdd or // by doing (negative, non-diagonal) row sums of original A matrix - PS_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); if (!row_sums) { diags = DD_MaxAbstract(ddman, diags, cvars, num_cvars); diags_vec = mtbdd_to_double_vector(ddman, diags, rvars, num_rvars, odd); @@ -176,8 +176,8 @@ jint flags } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PS_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // invert diagonal if (!compact_d) { @@ -188,7 +188,7 @@ jint flags // build b vector (if present) if (b != NULL) { - PS_PrintToMainLog(env, "Creating vector for RHS... "); + PN_PrintToMainLog(env, "Creating vector for RHS... "); b_vec = mtbdd_to_double_vector(ddman, b, rvars, num_rvars, odd); // try and convert to compact form if required compact_b = false; @@ -200,29 +200,29 @@ jint flags } kb = (!compact_b) ? n*8.0/1024.0 : (b_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_b) PS_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_b) PN_PrintToMainLog(env, "[dist=%d, compact] ", b_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); } // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln_below = mtbdd_to_double_vector(ddman, lower, rvars, num_rvars, odd); soln_above = mtbdd_to_double_vector(ddman, upper, rvars, num_rvars, odd); kb = n*8.0/1024.0; kbt += 2 * kb; - PS_PrintMemoryToMainLog(env, "[ 2 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[ 2 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); std::unique_ptr iterationExport; - if (PS_GetFlagExportIterations()) { + if (PN_GetFlagExportIterations()) { std::string title("PS_SOR ("); title += forwards?"":"Backwards "; title += (omega == 1.0)?"Gauss-Seidel":("SOR omega=" + std::to_string(omega)); title += "), interval"; iterationExport.reset(new ExportIterations(title.c_str())); - PS_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); + PN_PrintToMainLog(env, "Exporting iterations to %s\n", iterationExport->getFileName().c_str()); iterationExport->exportVector(soln_below, n, 0); iterationExport->exportVector(soln_above, n, 1); } @@ -236,7 +236,7 @@ jint flags // start iterations iters = 0; done = false; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); while (!done && iters < max_iters) { @@ -315,14 +315,14 @@ jint flags measure.reset(); measure.measure(soln_below, soln_above, n); if (measure.value() < term_crit_param) { - PS_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "Max %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); done = true; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } } @@ -333,14 +333,14 @@ jint flags time_taken = (double)(stop - start1)/1000; // print iters/timing info - PS_PrintToMainLog(env, "\n%s%s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); + PN_PrintToMainLog(env, "\n%s%s (interval iteration): %d iterations in %.2f seconds (average %.6f, setup %.2f)\n", forwards?"":"Backwards ", (omega == 1.0)?"Gauss-Seidel":"SOR", iters, time_taken, time_for_iters/iters, time_for_setup); // if the iterative method didn't terminate, this is an error if (!done) { delete[] soln_below; soln_below = NULL; - PS_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); - PS_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); + PN_SetErrorMessage("Iterative method (interval iteration) did not converge within %d iterations.\nConsider using a different numerical method or increasing the maximum number of iterations", iters); + PN_PrintToMainLog(env, "Max remaining %sdiff between upper and lower bound on convergence: %G", measure.isRelative()?"relative ":"", measure.value()); } if (helper.flag_select_midpoint() && soln_below) { // we did converge, select midpoint @@ -356,7 +356,7 @@ jint flags // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln_below) delete[] soln_below; soln_below = 0; } diff --git a/prism/src/sparse/PS_StochBoundedUntil.cc b/prism/src/sparse/PS_StochBoundedUntil.cc index 4714059c9a..ba758c45c1 100644 --- a/prism/src/sparse/PS_StochBoundedUntil.cc +++ b/prism/src/sparse/PS_StochBoundedUntil.cc @@ -34,7 +34,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "prism.h" #include "Measures.h" @@ -104,7 +104,7 @@ jlong __jlongpointer mu // probs for multiplying // count number of states to be made absorbing x = DD_GetNumMinterms(ddman, maybe, num_rvars); - PS_PrintToMainLog(env, "\nNumber of non-absorbing states: %.0f of %d (%.1f%%)\n", x, n, 100.0*(x/n)); + PN_PrintToMainLog(env, "\nNumber of non-absorbing states: %.0f of %d (%.1f%%)\n", x, n, 100.0*(x/n)); // filter out rows from rate matrix Cudd_Ref(trans); @@ -112,7 +112,7 @@ jlong __jlongpointer mu // probs for multiplying r = DD_Apply(ddman, APPLY_TIMES, trans, maybe); // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_tr = true; cmsrsm = NULL; @@ -130,11 +130,11 @@ jlong __jlongpointer mu // probs for multiplying } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diagonals - PS_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); diags = compact_tr ? cmsr_negative_row_sums(cmsrsm) : rm_negative_row_sums(rmsm); // try and convert to compact form if required compact_d = false; @@ -146,8 +146,8 @@ jlong __jlongpointer mu // probs for multiplying } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PS_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // find max diagonal element if (!compact_d) { @@ -177,13 +177,13 @@ jlong __jlongpointer mu // probs for multiplying } // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); soln = mtbdd_to_double_vector(ddman, yes, rvars, num_rvars, odd); soln2 = new double[n]; sum = new double[n]; kb = n*8.0/1024.0; kbt += 3*kb; - PS_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); // multiply initial solution by 'mult' probs if (mult != NULL) { @@ -193,19 +193,19 @@ jlong __jlongpointer mu // probs for multiplying } // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // compute new termination criterion parameter (epsilon/8) term_crit_param_unif = term_crit_param / 8.0; // compute poisson probabilities (fox/glynn) - PS_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); + PN_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); fgw = fox_glynn(unif * time, 1.0e-300, 1.0e+300, term_crit_param_unif); if (fgw.right < 0) throw "Overflow in Fox-Glynn computation (time bound too big?)"; for (i = fgw.left; i <= fgw.right; i++) { fgw.weights[i-fgw.left] /= fgw.total_weight; } - PS_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); + PN_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); // set up vectors for (i = 0; i < n; i++) { @@ -221,7 +221,7 @@ jlong __jlongpointer mu // probs for multiplying // start transient analysis done = false; num_iters = -1; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // if necessary, do 0th element of summation (doesn't require any matrix powers) if (fgw.left == 0) for (i = 0; i < n; i++) { @@ -299,16 +299,16 @@ jlong __jlongpointer mu // probs for multiplying } // add to sum for (i = 0; i < n; i++) sum[i] += weight * soln2[i]; - PS_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); + PN_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); num_iters = iters; break; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); - if (do_ss_detect) PS_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); + if (do_ss_detect) PN_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -330,15 +330,15 @@ jlong __jlongpointer mu // probs for multiplying // print iters/timing info if (num_iters == -1) num_iters = fgw.right; - PS_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (sum) delete[] sum; sum = 0; } catch (const char *err) { - PS_SetErrorMessage("%s", err); + PN_SetErrorMessage("%s", err); if (sum) delete[] sum; sum = 0; } diff --git a/prism/src/sparse/PS_StochCumulReward.cc b/prism/src/sparse/PS_StochCumulReward.cc index 845074a595..b22a0b70ee 100644 --- a/prism/src/sparse/PS_StochCumulReward.cc +++ b/prism/src/sparse/PS_StochCumulReward.cc @@ -34,7 +34,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "Measures.h" #include @@ -100,7 +100,7 @@ jdouble time // time bound n = odd->eoff + odd->toff; // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_tr = true; cmsrsm = NULL; @@ -118,11 +118,11 @@ jdouble time // time bound } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diagonals - PS_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); diags = compact_tr ? cmsr_negative_row_sums(cmsrsm) : rm_negative_row_sums(rmsm); // try and convert to compact form if required compact_d = false; @@ -134,8 +134,8 @@ jdouble time // time bound } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PS_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // find max diagonal element if (!compact_d) { @@ -180,29 +180,29 @@ jdouble time // time bound Cudd_RecursiveDeref(ddman, tmp); // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); // soln has already been created and initialised to rewards vector as required // need to create soln2 and sum soln2 = new double[n]; sum = new double[n]; kb = n*8.0/1024.0; kbt += 3*kb; - PS_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // compute new termination criterion parameter (epsilon/8) term_crit_param_unif = term_crit_param / 8.0; // compute poisson probabilities (fox/glynn) - PS_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); + PN_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); fgw = fox_glynn(unif * time, 1.0e-300, 1.0e+300, term_crit_param_unif); if (fgw.right < 0) throw "Overflow in Fox-Glynn computation (time bound too big?)"; for (i = fgw.left; i <= fgw.right; i++) { fgw.weights[i-fgw.left] /= fgw.total_weight; } - PS_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); + PN_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); // modify the poisson probabilities to what we need for this computation // first make the kth value equal to the sum of the values for 0...k @@ -228,7 +228,7 @@ jdouble time // time bound // start transient analysis done = false; num_iters = -1; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // do 0th element of summation (doesn't require any matrix powers) if (fgw.left == 0) { @@ -309,16 +309,16 @@ jdouble time // time bound // add to sum for (i = 0; i < n; i++) sum[i] += weight * soln2[i]; - PS_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); + PN_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); num_iters = iters; break; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); - if (do_ss_detect) PS_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); + if (do_ss_detect) PN_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -342,15 +342,15 @@ jdouble time // time bound // print iters/timing info if (num_iters == -1) num_iters = fgw.right; - PS_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (sum) delete[] sum; sum = 0; } catch (const char *err) { - PS_SetErrorMessage("%s", err); + PN_SetErrorMessage("%s", err); if (sum) delete[] sum; sum = 0; } diff --git a/prism/src/sparse/PS_StochSteadyState.cc b/prism/src/sparse/PS_StochSteadyState.cc index d275212e68..b5895ad7dc 100644 --- a/prism/src/sparse/PS_StochSteadyState.cc +++ b/prism/src/sparse/PS_StochSteadyState.cc @@ -33,7 +33,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include @@ -100,7 +100,7 @@ jint num_cvars q = DD_Apply(ddman, APPLY_PLUS, trans, DD_Apply(ddman, APPLY_TIMES, DD_Identity(ddman, rvars, cvars, num_rvars), diags)); // build iteration matrix - PS_PrintToMainLog(env, "\nBuilding power method iteration matrix MTBDD... "); + PN_PrintToMainLog(env, "\nBuilding power method iteration matrix MTBDD... "); // (includes a "fix" for when we are solving a subsystem e.g. BSCC) // (although i don't think we actually need this for the power method) Cudd_Ref(diags); @@ -108,7 +108,7 @@ jint num_cvars Cudd_Ref(q); a = DD_Apply(ddman, APPLY_PLUS, DD_Apply(ddman, APPLY_TIMES, DD_Constant(ddman, deltat), q), DD_Apply(ddman, APPLY_TIMES, DD_Identity(ddman, rvars, cvars, num_rvars), tmp)); i = DD_GetNumNodes(ddman, a); - PS_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]", i, i*20.0/1024.0); + PN_PrintToMainLog(env, "[nodes=%d] [%.1f Kb]", i, i*20.0/1024.0); // deref unneeded mtbdds Cudd_RecursiveDeref(ddman, diags); @@ -140,7 +140,7 @@ jint num_cvars case LIN_EQ_METHOD_BSOR: soln = jlong_to_double(Java_sparse_PrismSparse_PS_1SOR(env, cls, ptr_to_jlong(odd), ptr_to_jlong(rvars), num_rvars, ptr_to_jlong(cvars), num_cvars, ptr_to_jlong(a), 0, ptr_to_jlong(init), true, true, lin_eq_method_param, false)); break; default: - PS_SetErrorMessage("Pseudo Gauss-Seidel/SOR methods are currently not supported by the sparse engine"); return 0; + PN_SetErrorMessage("Pseudo Gauss-Seidel/SOR methods are currently not supported by the sparse engine"); return 0; } // normalise @@ -156,7 +156,7 @@ jint num_cvars // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (soln) delete[] soln; soln = 0; } diff --git a/prism/src/sparse/PS_StochTransient.cc b/prism/src/sparse/PS_StochTransient.cc index 3a2f0e300e..7e28eae2b2 100644 --- a/prism/src/sparse/PS_StochTransient.cc +++ b/prism/src/sparse/PS_StochTransient.cc @@ -34,7 +34,7 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" #include "Measures.h" #include @@ -96,7 +96,7 @@ jdouble time // time bound n = odd->eoff + odd->toff; // build sparse matrix - PS_PrintToMainLog(env, "\nBuilding sparse matrix... "); + PN_PrintToMainLog(env, "\nBuilding sparse matrix... "); // if requested, try and build a "compact" version compact_tr = true; cmscsm = NULL; @@ -114,11 +114,11 @@ jdouble time // time bound } kbt = kb; // print some info - PS_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + PN_PrintToMainLog(env, "[n=%d, nnz=%ld%s] ", n, nnz, compact_tr?", compact":""); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // get vector of diagonals - PS_PrintToMainLog(env, "Creating vector for diagonals... "); + PN_PrintToMainLog(env, "Creating vector for diagonals... "); diags = compact_tr ? cmsc_negative_row_sums(cmscsm) : cm_negative_row_sums(cmsm); // try and convert to compact form if required compact_d = false; @@ -130,8 +130,8 @@ jdouble time // time bound } kb = (!compact_d) ? n*8.0/1024.0 : (diags_dist->num_dist*8.0+n*2.0)/1024.0; kbt += kb; - if (compact_d) PS_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); - PS_PrintMemoryToMainLog(env, "[", kb, "]\n"); + if (compact_d) PN_PrintToMainLog(env, "[dist=%d, compact] ", diags_dist->num_dist); + PN_PrintMemoryToMainLog(env, "[", kb, "]\n"); // find max diagonal element if (!compact_d) { @@ -161,7 +161,7 @@ jdouble time // time bound } // create solution/iteration vectors - PS_PrintToMainLog(env, "Allocating iteration vectors... "); + PN_PrintToMainLog(env, "Allocating iteration vectors... "); // for soln, we just use init (since we are free to modify/delete this vector) // we also report the memory usage of this vector here, even though it has already been created soln = init; @@ -169,22 +169,22 @@ jdouble time // time bound sum = new double[n]; kb = n*8.0/1024.0; kbt += 3*kb; - PS_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); + PN_PrintMemoryToMainLog(env, "[3 x ", kb, "]\n"); // print total memory usage - PS_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); + PN_PrintMemoryToMainLog(env, "TOTAL: [", kbt, "]\n"); // compute new termination criterion parameter (epsilon/8) term_crit_param_unif = term_crit_param / 8.0; // compute poisson probabilities (fox/glynn) - PS_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); + PN_PrintToMainLog(env, "\nUniformisation: q.t = %f x %f = %f\n", unif, time, unif * time); fgw = fox_glynn(unif * time, 1.0e-300, 1.0e+300, term_crit_param_unif); if (fgw.right < 0) throw "Overflow in Fox-Glynn computation (time bound too big?)"; for (i = fgw.left; i <= fgw.right; i++) { fgw.weights[i-fgw.left] /= fgw.total_weight; } - PS_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); + PN_PrintToMainLog(env, "Fox-Glynn: left = %ld, right = %ld\n", fgw.left, fgw.right); // set up vectors for (i = 0; i < n; i++) { @@ -200,7 +200,7 @@ jdouble time // time bound // start transient analysis done = false; num_iters = -1; - PS_PrintToMainLog(env, "\nStarting iterations...\n"); + PN_PrintToMainLog(env, "\nStarting iterations...\n"); // if necessary, do 0th element of summation (doesn't require any matrix powers) if (fgw.left == 0) for (i = 0; i < n; i++) { @@ -278,16 +278,16 @@ jdouble time // time bound } // add to sum for (i = 0; i < n; i++) sum[i] += weight * soln2[i]; - PS_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); + PN_PrintToMainLog(env, "\nSteady state detected at iteration %ld\n", iters); num_iters = iters; break; } // print occasional status update if ((util_cpu_time() - start3) > UPDATE_DELAY) { - PS_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); - if (do_ss_detect) PS_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); - PS_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); + PN_PrintToMainLog(env, "Iteration %ld (of %ld): ", iters, fgw.right); + if (do_ss_detect) PN_PrintToMainLog(env, "max %sdiff=%f, ", measure.isRelative()?"relative ":"", measure.value()); + PN_PrintToMainLog(env, "%.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); start3 = util_cpu_time(); } @@ -309,15 +309,15 @@ jdouble time // time bound // print iters/timing info if (num_iters == -1) num_iters = fgw.right; - PS_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); + PN_PrintToMainLog(env, "\nIterative method: %ld iterations in %.2f seconds (average %.6f, setup %.2f)\n", num_iters, time_taken, time_for_iters/num_iters, time_for_setup); // catch exceptions: register error, free memory } catch (std::bad_alloc e) { - PS_SetErrorMessage("Out of memory"); + PN_SetErrorMessage("Out of memory"); if (sum) delete[] sum; sum = 0; } catch (const char *err) { - PS_SetErrorMessage("%s", err); + PN_SetErrorMessage("%s", err); if (sum) delete[] sum; sum = 0; } diff --git a/prism/src/sparse/PrismSparse.cc b/prism/src/sparse/PrismSparse.cc index 219c1685bc..97d65d1197 100644 --- a/prism/src/sparse/PrismSparse.cc +++ b/prism/src/sparse/PrismSparse.cc @@ -33,271 +33,9 @@ #include #include #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include "jnipointer.h" -#define MAX_LOG_STRING_LEN 1024 -#define MAX_ERR_STRING_LEN 1024 - -//------------------------------------------------------------------------------ -// sparse engine global variables -//------------------------------------------------------------------------------ - -// cudd manager -DdManager *ddman; - -// logs -// global refs to log classes -static jclass main_log_cls = NULL; -static jclass tech_log_cls = NULL; -// global refs to log objects -static jobject main_log_obj = NULL; -static jobject tech_log_obj = NULL; -// method ids for print method in logs -static jmethodID main_log_mid = NULL; -static jmethodID main_log_warn = NULL; -static jmethodID tech_log_mid = NULL; - -// export stuff -int export_type; -FILE *export_file; -JNIEnv *export_env; -static bool exportIterations = false; - -// error message -static char error_message[MAX_ERR_STRING_LEN]; - -//------------------------------------------------------------------------------ -// cudd manager -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1SetCUDDManager(JNIEnv *env, jclass cls, jlong __jlongpointer ddm) -{ - ddman = jlong_to_DdManager(ddm); -} - -//------------------------------------------------------------------------------ -// logs -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1SetMainLog(JNIEnv *env, jclass cls, jobject log) -{ - // if main log has been set previously, we need to delete existing global refs first - if (main_log_obj != NULL) { - env->DeleteGlobalRef(main_log_cls); - main_log_cls = NULL; - env->DeleteGlobalRef(main_log_obj); - main_log_obj = NULL; - } - - // make a global reference to the log object - main_log_obj = env->NewGlobalRef(log); - // get the log class and make a global reference to it - main_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(main_log_obj)); - // get the method id for the print method - main_log_mid = env->GetMethodID(main_log_cls, "print", "(Ljava/lang/String;)V"); - main_log_warn = env->GetMethodID(main_log_cls, "printWarning", "(Ljava/lang/String;)V"); -} - -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1SetTechLog(JNIEnv *env, jclass cls, jobject log) -{ - // if tech log has been set previously, we need to delete existing global refs first - if (tech_log_obj != NULL) { - env->DeleteGlobalRef(tech_log_cls); - tech_log_cls = NULL; - env->DeleteGlobalRef(tech_log_obj); - tech_log_obj = NULL; - } - - // make a global reference to the log object - tech_log_obj = env->NewGlobalRef(log); - // get the log class and make a global reference to it - tech_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(tech_log_obj)); - // get the method id for the print method - tech_log_mid = env->GetMethodID(tech_log_cls, "print", "(Ljava/lang/String;)V"); -} - -//------------------------------------------------------------------------------ - -void PS_PrintToMainLog(JNIEnv *env, const char *str, ...) -{ - va_list argptr; - char full_string[MAX_LOG_STRING_LEN]; - - va_start(argptr, str); - vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); - va_end(argptr); - - if (env) - env->CallVoidMethod(main_log_obj, main_log_mid, env->NewStringUTF(full_string)); - else - printf("%s", full_string); -} - -//------------------------------------------------------------------------------ - -void PS_PrintWarningToMainLog(JNIEnv *env, const char *str, ...) -{ - va_list argptr; - char full_string[MAX_LOG_STRING_LEN]; - - va_start(argptr, str); - vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); - va_end(argptr); - - if (env) - env->CallVoidMethod(main_log_obj, main_log_warn, env->NewStringUTF(full_string)); - else - printf("\nWarning: %s\n", full_string); -} - -//------------------------------------------------------------------------------ - -void PS_PrintToTechLog(JNIEnv *env, const char *str, ...) -{ - va_list argptr; - char full_string[MAX_LOG_STRING_LEN]; - - va_start(argptr, str); - vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); - va_end(argptr); - - if (env) - env->CallVoidMethod(tech_log_obj, tech_log_mid, env->NewStringUTF(full_string)); - else - printf("%s", full_string); -} - -//------------------------------------------------------------------------------ - -// Print formatted memory info to main log - -void PS_PrintMemoryToMainLog(JNIEnv *env, const char *before, double mem, const char *after) -{ - char full_string[MAX_LOG_STRING_LEN]; - - if (mem > 1048576) - snprintf(full_string, MAX_LOG_STRING_LEN, "%s%.1f GB%s", before, mem/1048576.0, after); - else if (mem > 1024) - snprintf(full_string, MAX_LOG_STRING_LEN, "%s%.1f MB%s", before, mem/1024.0, after); - else - snprintf(full_string, MAX_LOG_STRING_LEN, "%s%.1f KB%s", before, mem, after); - - if (env) { - env->CallVoidMethod(main_log_obj, main_log_mid, env->NewStringUTF(full_string)); - } - else { - printf("%s", full_string); - } -} - -//------------------------------------------------------------------------------ -// export stuff -//------------------------------------------------------------------------------ - -// store export info globally -// returns 0 on failure, 1 otherwise - -int store_export_info(int type, jstring fn, JNIEnv *env) -{ - export_type = type; - if (fn) { - const char *filename = env->GetStringUTFChars(fn, 0); - export_file = fopen(filename, "w"); - if (!export_file) { - env->ReleaseStringUTFChars(fn, filename); - return 0; - } - env->ReleaseStringUTFChars(fn, filename); - } else { - export_file = NULL; - } - export_env = env; - return 1; -} - -//------------------------------------------------------------------------------ - -// export string (either to file or main log) - -void export_string(const char *str, ...) -{ - va_list argptr; - char full_string[MAX_LOG_STRING_LEN]; - - va_start(argptr, str); - vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr); - va_end(argptr); - - if (export_file) { - fprintf(export_file, "%s", full_string); - } else { - PS_PrintToMainLog(export_env, "%s", full_string); - } -} - -//------------------------------------------------------------------------------ -// use steady-state detection? -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1SetDoSSDetect(JNIEnv *env, jclass cls, jboolean b) -{ - do_ss_detect = b; -} - -//------------------------------------------------------------------------------ -// error message handling -//------------------------------------------------------------------------------ - -void PS_SetErrorMessage(const char *str, ...) -{ - va_list argptr; - - va_start(argptr, str); - vsnprintf(error_message, MAX_ERR_STRING_LEN, str, argptr); - va_end(argptr); -} - -char *PS_GetErrorMessage() -{ - return error_message; -} - -JNIEXPORT jstring JNICALL Java_sparse_PrismSparse_PS_1GetErrorMessage(JNIEnv *env, jclass cls) -{ - return env->NewStringUTF(error_message); -} - - -JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1SetExportIterations(JNIEnv *env, jclass cls, jboolean value) -{ - exportIterations = value; -} - -bool PS_GetFlagExportIterations() -{ - return exportIterations; -} - -//------------------------------------------------------------------------------ -// tidy up -//------------------------------------------------------------------------------ - -JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1FreeGlobalRefs(JNIEnv *env, jclass cls) -{ - // delete all global references - env->DeleteGlobalRef(main_log_cls); - main_log_cls = NULL; - env->DeleteGlobalRef(tech_log_cls); - tech_log_cls = NULL; - env->DeleteGlobalRef(main_log_obj); - main_log_obj = NULL; - env->DeleteGlobalRef(tech_log_obj); - tech_log_obj = NULL; -} - //------------------------------------------------------------------------------ // Sparse matrix //------------------------------------------------------------------------------ diff --git a/prism/src/sparse/PrismSparse.java b/prism/src/sparse/PrismSparse.java index 1bbd6158d0..587fb0c7d9 100644 --- a/prism/src/sparse/PrismSparse.java +++ b/prism/src/sparse/PrismSparse.java @@ -54,7 +54,7 @@ public class PrismSparse static { try { - System.loadLibrary("prismsparse"); + System.loadLibrary("prism"); } catch (UnsatisfiedLinkError e) { System.out.println(e); @@ -66,22 +66,6 @@ public class PrismSparse // initialise/close down methods //---------------------------------------------------------------------------------------------- - public static void initialise(PrismLog mainLog, PrismLog techLog) - { - setCUDDManager(); - setMainLog(mainLog); - setTechLog(techLog); - } - - public static void closeDown() - { - // tidy up any JNI stuff - PS_FreeGlobalRefs(); - } - - // tidy up in jni (free global references) - private static native void PS_FreeGlobalRefs(); - /** * Check that number of reachable states is in a range that can be handled by * the sparse engine methods. @@ -94,63 +78,13 @@ private static void checkNumStates(ODDNode odd) throws PrismNotSupportedExceptio ODDUtils.checkInt(odd, "Currently, the sparse engine cannot handle models"); } - //---------------------------------------------------------------------------------------------- - // cudd manager - //---------------------------------------------------------------------------------------------- - - // cudd manager - - // jni method to set cudd manager for native code - private static native void PS_SetCUDDManager(long ddm); - public static void setCUDDManager() - { - PS_SetCUDDManager(JDD.GetCUDDManager()); - } - - //---------------------------------------------------------------------------------------------- - // logs - //---------------------------------------------------------------------------------------------- - - // main log - - // place to store main log for java code - private static PrismLog mainLog; - // jni method to set main log for native code - private static native void PS_SetMainLog(PrismLog log); - // method to set main log both in java and c++ - public static void setMainLog(PrismLog log) - { - mainLog = log; - PS_SetMainLog(log); - } - - // tech log - - // place to store tech log for java code - private static PrismLog techLog; - // jni method to set tech log for native code - private static native void PS_SetTechLog(PrismLog log); - // method to set tech log both in java and c++ - public static void setTechLog(PrismLog log) - { - techLog = log; - PS_SetTechLog(log); - } - - private static native void PS_SetExportIterations(boolean value); - public static void SetExportIterations(boolean value) - { - PS_SetExportIterations(value); - } - //------------------------------------------------------------------------------ // error message //------------------------------------------------------------------------------ - private static native String PS_GetErrorMessage(); public static String getErrorMessage() { - return PS_GetErrorMessage(); + return PrismNative.PN_GetErrorMessage(); } /** diff --git a/prism/src/sparse/sparse.cc b/prism/src/sparse/sparse.cc index 568b5dc478..04e13daaed 100644 --- a/prism/src/sparse/sparse.cc +++ b/prism/src/sparse/sparse.cc @@ -28,7 +28,7 @@ #include #include "dv.h" #include "sparse.h" -#include "PrismSparseGlob.h" +#include "PrismNativeGlob.h" #include //------------------------------------------------------------------------------ diff --git a/prism/src/sparse/sparse_adv.cc b/prism/src/sparse/sparse_adv.cc index 345e824d92..a614ad6ff1 100644 --- a/prism/src/sparse/sparse_adv.cc +++ b/prism/src/sparse/sparse_adv.cc @@ -28,7 +28,7 @@ //#include //#include "dv.h" #include "sparse_adv.h" -//#include "PrismSparseGlob.h" +//#include "PrismNativeGlob.h" //#include //------------------------------------------------------------------------------ diff --git a/prism/src/strat/Makefile b/prism/src/strat/Makefile deleted file mode 100644 index c498ad722c..0000000000 --- a/prism/src/strat/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = strat -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java) -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/src/userinterface/Makefile b/prism/src/userinterface/Makefile deleted file mode 100644 index dbaad54ba9..0000000000 --- a/prism/src/userinterface/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -THIS_DIR = userinterface -PRISM_DIR_REL = ../.. - -JNI_GEN_HEADER_DIR=$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_INCLUDE_DIR)/jni - -JAVA_FILES_ALL = $(wildcard *.java graph/*.java model/*.java model/computation/*.java model/pepaModel/*.java model/graphicModel/*.java util/*.java simulator/*.java properties/*.java properties/computation/*.java log/*.java) -JAVA_FILES = $(patsubst %package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class) - -PRISM_CLASSPATH = "$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks $(CLASS_FILES) - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/$(THIS_DIR)/%.class: %.java - (cd ..; $(JAVAC) $(JFLAGS) -sourcepath $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_SRC_DIR) -classpath $(PRISM_CLASSPATH) -h $(JNI_GEN_HEADER_DIR) -d $(THIS_DIR)/$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR) $(THIS_DIR)/$<) - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -################################################# diff --git a/prism/unit-tests/Makefile b/prism/unit-tests/Makefile deleted file mode 100644 index 0a82ebcb97..0000000000 --- a/prism/unit-tests/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -################################################ -# NB: This Makefile is designed to be called # -# from the main PRISM Makefile. It won't # -# work on its own because it needs # -# various options to be passed in # -################################################ - -.SUFFIXES: .o .c .cc - -# Reminder: $@ = target, $* = target without extension, $< = dependency - -PRISM_DIR_REL = .. - -JAVA_FILES_ALL := $(shell find . -name '*.java') -JAVA_FILES = $(subst package-info.java,,$(JAVA_FILES_ALL)) -CLASS_FILES = $(JAVA_FILES:%.java=$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)/%.class) - -PRISM_CLASSPATH = "$(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)$(CLASSPATHSEP)$(PRISM_DIR_REL)/$(PRISM_LIB_DIR)/*" - -default: all - -all: checks class_files - -# inhibit building in parallel (-j option) -.NOTPARALLEL: - -# Try and prevent accidental makes (i.e. called manually, not from top-level Makefile) -checks: - @if [ "$(PRISM_SRC_DIR)" = "" ]; then \ - (echo "Error: This Makefile is designed to be called from the main PRISM Makefile"; exit 1) \ - fi; - -class_files: - @echo "$(JAVA_FILES)" > java_files.txt - $(JAVAC) $(JFLAGS) -sourcepath "$(PRISM_DIR_REL)/$(PRISM_SRC_DIR)$(CLASSPATHSEP)$(PRISM_DIR_REL)/unit-tests"\ - -classpath $(PRISM_CLASSPATH)\ - -d $(PRISM_DIR_REL)/$(PRISM_CLASSES_DIR)\ - @java_files.txt - @rm -f java_files.txt - -clean: checks - @rm -f $(CLASS_FILES) - -celan: clean - -#################################################