Skip to main content

MDPFuzz Replication

Project description

Replicate of MDPFuzz

Code style: black

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.1.tar.gz (22.8 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.1-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mdpfuzz-0.0.1.tar.gz
  • Upload date:
  • Size: 22.8 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.1.tar.gz
Algorithm Hash digest
SHA256 10960ccf9a7070cd59baa63055a7ec30fbcc9759d1089d7eeb73352237116ab0
MD5 ecc0a06bbaed57fe4f7b693645adc413
BLAKE2b-256 8bb0bb737e45bdfd4d7b0b60cbbb752a5a02d74f875ca0df225d3cd8a117c578

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdpfuzz-0.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: mdpfuzz-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 23.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fbcd7ae6800b1d536631723faa7e070af91db7e8f081f14551ce6a0207918df9
MD5 4618758ed8be8bd1f4b0e8a02627be71
BLAKE2b-256 617d88ef3398d8af98d68c93c3d6c2f43efe540ee0d6966d59ef9dafdbce95ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdpfuzz-0.0.1-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