pyRDDLGym-gurobi
Author: Mike Gimelfarb
This repository supports compilation of RDDL description files into Gurobi's mixed-integer (non-linear) programs, and automated planning tools for optimizing these programs in MDPs.
[!NOTE]
The Gurobi planners currently determinize all stochastic variables, making it less suitable for highly stochastic problems or problems with (stochastic) dead ends. If you find it is not making sufficient progress on a stochastic problem, or doesn't scale well computationally to your problem, check out the PROST planner (for discrete spaces), the JAX planner (for continuous problems), or the deep reinforcement learning wrappers.
Contents
- Installation
- Running the Basic Example
- Running from the Python API
- Customizing Gurobi
- Citing pyRDDLGym-gurobi
Installation
The basic requirements are pyRDDLGym>=2.0 and gurobipy>=10.0.0.
To run the basic example, you will also require rddlrepository>=2.0. Everything except rddlrepository can be installed via pip:
pip install pyRDDLGym-gurobi
Running the Basic Example
The basic example provided in pyRDDLGym-gurobi will run the Gurobi planner on a domain and instance of your choosing. To run this, navigate to the install directory of pyRDDLGym-gurobi, and run:
python -m pyRDDLGym_gurobi.examples.run_plan <domain> <instance> <horizon>
where:
<domain>is the domain identifier as specified in rddlrepository (i.e. Wildfire_MDP_ippc2014), or a path pointing to a validdomain.rddlfile<instance>instance is the instance identifier (i.e. 1, 2, ... 10) in rddlrepository, or a path pointing to a validinstance.rddlfile<horizon>is the planning lookahead horizon.
Running from the Python API
If you are working with the Python API, you can instantiate the environment and planner however you wish:
import pyRDDLGym
from pyRDDLGym_gurobi.core.planner import GurobiStraightLinePlan, GurobiOnlineController
# Create the environment
env = pyRDDLGym.make("domain name", "instance name")
# Create the planner
plan = GurobiStraightLinePlan()
controller = GurobiOnlineController(rddl=env.model, plan=plan, rollout_horizon=5)
# Run the planner
controller.evaluate(env, episodes=1, verbose=True, render=True)
Note, that the GurobiOnlineController is an instance of pyRDDLGym's BaseAgent, so the evaluate() function can be used to streamline interaction with the environment.
Customizing Gurobi
The Gurobi compiler and planner run using the Gurobi engine and can be configured by configuring Gurobipy.
Configuration File
Create a gurobi.env file in the location of your running script, and in it specify the parameters that you would like to pass to Gurobi.
For example, to instruct Gurobi to limit each optimization to 60 seconds, and to print progress during optimization to console:
TimeLimit 60
OutputFlag 1
Passing Parameters Directly
Parameters can be passed as a dictionary to the model_params argument of the Gurobi controller:
controller = GurobiOnlineController(rddl=env.model, plan=plan, rollout_horizon=5,
model_params={'NonConvex': 2, 'OutputFlag': 1})
and then the controller can be used as described in the previous section.
Citing pyRDDLGym-gurobi
The following citation describes the main ideas of the framework. Please cite it if you found it useful:
@inproceedings{gimelfarb2024jaxplan,
title={JaxPlan and GurobiPlan: Optimization Baselines for Replanning in Discrete and Mixed Discrete and Continuous Probabilistic Domains},
author={Michael Gimelfarb and Ayal Taitler and Scott Sanner},
booktitle={34th International Conference on Automated Planning and Scheduling},
year={2024},
url={https://openreview.net/forum?id=7IKtmUpLEH}
}
Metadata
Release files for pyRDDLGym-gurobi 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyrddlgym_gurobi-0.2.tar.gz | 21.5 kB | Without provenance | Details for pyrddlgym_gurobi-0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyRDDLGym_gurobi-0.2-py3-none-any.whl | Python 3 | none | any | Details for pyRDDLGym_gurobi-0.2-py3-none-any.whl |
Total release size: 41.9 kB
Release files / pyrddlgym_gurobi-0.2.tar.gz
| Download URL | pyrddlgym_gurobi-0.2.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72c847f352739a313caaa4f7002a3ff06999dd86d3c34a7b8383de9876de8e9d
|
|
BLAKE2b-256 checksum How to use checksums |
09730fe54afbe52107bcbe1f312b6e20f82f3288f15c955a8318e349212eb5e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.0
|
Release files / pyRDDLGym_gurobi-0.2-py3-none-any.whl
| Download URL | pyRDDLGym_gurobi-0.2-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b81b164d35cb1e9309da3a9a5ed6feba8f949620b95e171787b790c809a1d4b5
|
|
BLAKE2b-256 checksum How to use checksums |
71d3a609f4b616ea3cbe0528cd2d82e3a40335be42b799be647286e39b03ef99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.0
|
Security for pyRDDLGym-gurobi 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.