Skip to main content

MDPFuzz Replication

Project description

Replicate of MDPFuzz

Code style: black DOI

This repository contains a re-implementation the policy testing framework MDPFuzz, whose original code can be found here. This tool has been used in the paper Replicability Study: Policy Testing with MDPFuzz.

Installation

You can install the package with pip:

pip install mdpfuzz

One can also want to install the package locally:

git clone https://github.com/QuentinMaz/MDPFuzz_Replication mdpfuzz
cd mdpfuzz
pip install -e .

In the latter case, don't forget to append the folder mdpfuzz/ to your path.

Usage

The Fuzzer class (mdpfuzz/mdpfuzz.py) provides functions for fuzzing with and without GMM guidance, as well as a simple random testing procedure. It inputs an Executor object, which is responsible for generating and mutating inputs (also called seeds), loading the policy under test and executing test cases (i.e., running the policy with a given input). As such, using the package involves 3 simple steps:

  1. Implementing a Executor class for your use case.
  2. Creating an executor, loading the model under test and instantiate a fuzzer.
  3. Running the fuzzer (fuzzing - with or without GMM guidance - or Random Testing) with the testing budget you want!

Example

In the file dqn_mountain_car.py, we test a DQN agent (learnt using the library Stable Baselines3) for the Mountain Car environment.

Setup

Setup a virtual environment with, for instance, conda:

conda create -n demo python=3.10.12
conda activate demo
pip install mdpfuzz
# install gymnasium and stable-baselines3 dependencies
pip install gymnasium==0.29.1
pip install stable-baselines3==2.2.1

Make sure to activate the virtual environment (conda activate demo) before executing the script!

Additionally, we provide the script as a Jupyter notebook in which with we detail each step of the demonstration. If you use the notebook, install the following dependency in the virtual environment: pip install ipykernel.

The demonstration consists of:

  1. Learning and saving the DQN agent (dqn_mountain_car.zip).
  2. Testing the agent with a budget of 2500 test cases, with both Random Testing and MDPFuzz. The results of Random Testing are recorded in the current directory prefixed by random_testing, while the results of MDPFuzz are prefixed by mdpfuzz.
  3. Plotting the evolution of the number of failures found over the test cases by the two methods in the file failure_results_comparison_demo.png.

Project details


Download files

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

Source Distribution

mdpfuzz-0.0.3.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mdpfuzz-0.0.3-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file mdpfuzz-0.0.3.tar.gz.

File metadata

  • Download URL: mdpfuzz-0.0.3.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mdpfuzz-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cc9258f2a3d1cc38e78c2c3270a32656235ce5874e4ffc0ba737467c0575b1eb
MD5 7d39452196c37655600e4bab8953b4e8
BLAKE2b-256 6216c68560b9470c488d040ee33dc2ae6489395690395d0c51e8e9b41d996b60

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdpfuzz-0.0.3.tar.gz:

Publisher: release.yml on QuentinMaz/MDPFuzz_Replication

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdpfuzz-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: mdpfuzz-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mdpfuzz-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4febd7470c47fdd95d905b413deb0613780c73b4b17900b6478a249552f91b73
MD5 b093cf70d0e17672d406d4584f1c19a6
BLAKE2b-256 5172cd6bfc1acb058d03a0479f122dd64f13e8c9bc280e00dd407aa4e37d5f9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdpfuzz-0.0.3-py3-none-any.whl:

Publisher: release.yml on QuentinMaz/MDPFuzz_Replication

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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