This package allows creation of STL rule hierarchies and computing their rank-preserving rewards, as detailed in this paper: https://arxiv.org/pdf/2212.03323.pdf.
To setup this package:
- clone this repository and then
pip install -e .
The core code is in rule_hierarchy/rule_hierarchy.py. The AbstractRuleHierarchy class is responsible for evaluating the STL rule hierarchy while the RuleHierarchy class takes the user-specified hierarchy and transforms it into an STL rule hierarchy. The user-specified rule hierarchy is communicated to RuleHierarchy as a list of Rule objects, ordered in decreasing order of importance; some examples of rules are provided in the rules directory.
A demo of how to build a rule hierarchy is provided in demo/simple_demo.py.
The main steps to setting up your custom rule hierarchy are:
- Create a subclass of
Ruletailored to the specific rule being implemented in therulesdirectory.- The class should have a
as_stl_formula()and aprepare_signals()method which generates anSTLCGformula and a properly shaped signal for STLCG to evaluate, respectively. - Examples of how to formulate the rule class can be found in the
rulesdirectory. - Include an import to the class in
__init__.pyinrules/__init__.py.
- The class should have a
- Create an ordered list of rules, e.g.,
rules = [AlwaysGreater(1.0), AlwaysLesser(2.0)]and pass it to theRuleHierarchyclass to create a rule hierarchy; see demo/simple_demo.py for a simple example.
A simple demo of how to use the rule hierarchy is presented in demo/simple_demo.py and a more involved demo that demonstrates planning with a continuous optimizer is provided in demo/optimization_demo.py.
Please cite the relevant paper if you use this code:
@article{veer2022receding,
title={Receding Horizon Planning with Rule Hierarchies for Autonomous Vehicles},
author={Veer, Sushant and Leung, Karen and Cosner, Ryan and Chen, Yuxiao and Karkus, Peter and Pavone, Marco},
journal={arXiv preprint arXiv:2212.03323},
year={2022}
}
The source code is released under the NSCL licence.