Browse Source

bindings for POMDP analysis prepared

refactoring
Sebastian Junges 5 years ago
parent
commit
20106e34bc
  1. 4
      CMakeLists.txt
  2. 13
      cmake/CMakeLists.txt
  3. 1
      cmake/config.py.in
  4. 20
      setup.py
  5. 1
      src/mod_pomdp.cpp

4
CMakeLists.txt

@ -42,3 +42,7 @@ endif()
if(HAVE_STORM_DFT)
stormpy_module(dft storm-dft "${storm-dft_INCLUDE_DIR}")
endif()
if(HAVE_STORM_POMDP)
stormpy_module(pomdp storm-pomdp "${storm-pomdp_INCLUDE_DIR}")
endif()

13
cmake/CMakeLists.txt

@ -24,6 +24,13 @@ else()
set(HAVE_STORM_DFT FALSE)
endif()
find_library(STORM_POMDP NAMES storm-pomdp HINTS "${storm_DIR}/lib/")
if(STORM_POMDP)
set(HAVE_STORM_POMDP TRUE)
else()
set(HAVE_STORM_POMDP FALSE)
endif()
if(HAVE_STORM_PARS)
set(HAVE_STORM_PARS_BOOL "True")
else()
@ -36,6 +43,12 @@ else()
set(HAVE_STORM_DFT_BOOL "False")
endif()
if(HAVE_STORM_POMDP)
set(HAVE_STORM_POMDP_BOOL "True")
else()
set(HAVE_STORM_POMDP_BOOL "False")
endif()
if(STORM_USE_CLN_EA)
set(STORM_CLN_EA_BOOL "True")
else()

1
cmake/config.py.in

@ -6,3 +6,4 @@ STORM_CLN_EA = @STORM_CLN_EA_BOOL@
STORM_CLN_RF = @STORM_CLN_RF_BOOL@
HAVE_STORM_PARS = @HAVE_STORM_PARS_BOOL@
HAVE_STORM_DFT = @HAVE_STORM_DFT_BOOL@
HAVE_STORM_POMDP = @HAVE_STORM_POMDP_BOOL@

20
setup.py

@ -33,6 +33,7 @@ class CMakeBuild(build_ext):
('storm-dir=', None, 'Path to storm root (binary) location'),
('disable-dft', None, 'Disable support for DFTs'),
('disable-pars', None, 'Disable support for parametric models'),
('disable-pomdp', None, 'Disable support for POMDP analysis'),
('debug', None, 'Build in Debug mode'),
('jobs=', 'j', 'Number of jobs to use for compiling')
]
@ -84,6 +85,7 @@ class CMakeBuild(build_ext):
# Check additional support
use_dft = cmake_conf.HAVE_STORM_DFT and not self.config.get_as_bool("disable_dft")
use_pars = cmake_conf.HAVE_STORM_PARS and not self.config.get_as_bool("disable_pars")
use_pomdp = cmake_conf.HAVE_STORM_POMDP #and not self.config.get_as_bool("disable_pomdp")
# Print build info
print("Stormpy - Using storm {} from {}".format(storm_version, storm_dir))
@ -95,6 +97,10 @@ class CMakeBuild(build_ext):
print("Stormpy - Support for parametric models found and included.")
else:
print("Stormpy - Warning: No support for parametric models!")
if use_pomdp:
print("Stormpy - Support for POMDP analysis found and included.")
else:
print("Stormpy - Warning: No support for POMDP analysis!")
# Set general cmake build options
build_type = 'Debug' if self.config.get_as_bool("debug") else 'Release'
@ -106,6 +112,8 @@ class CMakeBuild(build_ext):
cmake_args += ['-DHAVE_STORM_DFT=ON']
if use_pars:
cmake_args += ['-DHAVE_STORM_PARS=ON']
if use_pomdp:
cmake_args += ['-DHAVE_STORM_POMDP=ON']
build_args = ['--config', build_type]
build_args += ['--', '-j{}'.format(self.config.get_as_int("jobs"))]
@ -160,6 +168,13 @@ class CMakeBuild(build_ext):
if not use_pars:
print("Stormpy - Bindings for parametric models skipped")
continue
elif ext.name == "pomdp":
with open(os.path.join(self._extdir(ext.name), ext.subdir, "_config.py"), "w") as f:
f.write("# Generated from setup.py at {}\n".format(datetime.datetime.now()))
f.write("storm_with_pomdp = {}".format(use_pomdp))
if not use_pomdp:
print("Stormpy - Bindings for POMDP analysis skipped")
continue
self.build_extension(ext, cmake_args, build_args)
def initialize_options(self):
@ -168,6 +183,7 @@ class CMakeBuild(build_ext):
self.storm_dir = None
self.disable_dft = None
self.disable_pars = None
self.disable_pomdp = None
self.debug = None
self.jobs = None
@ -180,6 +196,7 @@ class CMakeBuild(build_ext):
self.config.update("storm_dir", self.storm_dir)
self.config.update("disable_dft", self.disable_dft)
self.config.update("disable_pars", self.disable_pars)
self.config.update("disable_pomdp", self.disable_pomdp)
self.config.update("debug", self.debug)
self.config.update("jobs", self.jobs)
@ -231,7 +248,8 @@ setup(
CMakeExtension('storage', subdir='storage'),
CMakeExtension('utility', subdir='utility'),
CMakeExtension('dft', subdir='dft'),
CMakeExtension('pars', subdir='pars')],
CMakeExtension('pars', subdir='pars'),
CMakeExtension('pomdp', subdir='pomdp')],
cmdclass={'build_ext': CMakeBuild},
zip_safe=False,

1
src/mod_pomdp.cpp

@ -0,0 +1 @@
Loading…
Cancel
Save