Skip to main content

Library for sampling shape expressions.

Project description

ShapEx

Introduction

ShapEx is a tool that generates random behaviors from shape expressions, a formal specification formalism for describing sophisticated temporal behaviors of CPS. The tool samples a random behavior in two steps:

(1) it first explores the space of qualitative parameterized shapes and then

(2) instantiates parameters by sampling a possibly non-linear constraint.

It uses several sampling algorithms for the different stages of sample generation and generates timed traces according to a textual shape expression file.

Installation

ShapEx is written in Python 3 and uses our standalone library anyHR. It is necessary to have a working installation of Python 3, pip and git for the following installation process.

To install the tool, type pip install ShapEx.

This also installs anyHR and all other dependencies. The below example should now work right away.

Use

The following block illustrates a minimum working example for the use of the ShapEx tool. For all parameters the default values are used and 100 samples are generated for the SE from the imported text file 'pulse.se'.

from shapex.shapex.ShapEx import *

# initialize ShapEx object
se = ShapEx()
# loads the specification
se.add_shape_expression('pulse.se')
# Generate 100 examples 
samples = shapex_object.samples(100)

The following table gives an overview of the parameters that can be set at ShapEx object initialization (line 4 of the code above):

Parameter Description Values
timestep Difference between two consecutive timestamps. positive float (default 1.0)
word_sampler Qualitative word sampler. WordSamplerMode.SEARCH (default), WordSamplerMode.BOLTZMANN
search_budget Maximum number of distinctive qualitative words. Applicable to WordSamplerMode.SEARCH only. positive integer (default 10)
mean_word_length Mean length of qualitative word. Applicable to WordSamplerMode.BOLTZMANN only. positive float (default 10.0)
dir_sampling Direction sampling hit-and-run algorithm. Random (RDHR) vs. coordinate direction (CDHR) DirectionSampling.RDHR (default), DirectionSampling.CDHR
shrinking Direction sampling hit-and-run algorithm. Shrinking.NO_SHINKING (default), Shrinking.SHRINKING
init_point Hit-and-run with or without shrinking InitPoint.PSO (default), InitPoint.SMT
noise_distribution Finding initial point for hit-and-run. Particle swarm optimization (PSO) vs. constraint solving (SMT). 'uniform' (default), 'gaussian'
noise Distribution use to add noise to the generated signals. positive float (default 0.0)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

ShapEx-1.0.0-py3-none-any.whl (52.0 kB view details)

Uploaded Python 3

File details

Details for the file ShapEx-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ShapEx-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 52.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for ShapEx-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e674e25286102f97d9cd1b3f63a7bf794dd7504df4cfff656049f98769894019
MD5 6a6ec2e94bee4d73cb11742b610a6519
BLAKE2b-256 76d9915d8869271df5cb235bae5ddaf2c52d697f420a110f7a6509e17a0bfe7d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page