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.2.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.2-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mdpfuzz-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 6a1acfadc0188ffba0a38a3b48e7718daae3d9e39fbbc3af01d9bdfcb415adb9
MD5 450a38dc17cc089d3173044d4157179b
BLAKE2b-256 6d0f291ee33b89f86d9c01a52a7e1b45ed190d30a4f6b1c21084fb52da178355

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mdpfuzz-0.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 07a97fa711bbd25417ba03a68fa1e33659eef867eefcfde29ae97f34b30e65c0
MD5 f0fb78c56fec59585bf58e83152b6105
BLAKE2b-256 660624ff505d64b7586579a9009e7bc07520f950852d6ebe6978b430e515ebfd

See more details on using hashes here.

Provenance

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