Skip to main content

Reinforcement Learning-based VANET simulations

Project description


Veins-Gym exports Veins simulations as Open AI Gyms. This enables the application of Reinforcement Learning algorithms to solve problems in the VANET domain, in particular popular frameworks such as Tensorflow or PyTorch.

To install, simply run pip install veins-gym (Veins-Gym on PyPI).


This project is licensed under the terms of the GNU General Public License 2.0.

Hints and FAQ

Here are some frequent issues with Veins-Gym and its environments.

Please also checkout the guide on how to build new environments in doc/

Protobuf Files Out of Sync

Sometimes the C++ code files generated by protoc get out of sync with the installed version of libprotobuf. This leads to errors at link-time of the environment (not veins-gym itself, which does not contain C++-code) like:

undefined reference to google::protobuf::internal::ParseContext::ParseMessage

Solution: Re-generate the and .pb.h files in the environment.

  • check/update the installation of protobuf-compiler and libprotoc on your system (package names may differ based on the Linux distribution)
  • remove the generated src/protobuf/veinsgym.pb.h and src/protobuf/ files (or however they may be called in the environment)
  • re-generate the protobuf-files by running snakemake src/protobuf/ src/protobuf/veinsgym.pb.h (adapt for the files in your environment.

Also see Issue #1 of serpentine-env.

Showing the (Debug) Output of Veins through the Agent

Normally, Veins-Gym swallows the standard output of veins simulations started by its environments. This reduces output clutter but makes debugging harder as error messages are not visible.

Solution: Enable veins standard output by adjusting gym.register when running your agent:

	# ...
		# ...
		"print_veins_stdout": True,  # enable (debug) output of veins

Starting Veins Simulations Separately

Sometimes you want to run Veins simulations separately, e.g., with custom parameters, in a (different) container, or within a debugger. This is hard to achieve and less flexible when Veins-Gym launches the Veins simulation, as it does by default.

Solution: Disable auto-start of Veins in your agent's environment:

	# ...
		# ...
		"run_veins": False,  # do not start veins through Veins-Gym
		"port": 5555,  # pick a port to use

Then run your veins simulation manually, typically from a scenario directory, in which the omnetpp.ini file is located:

./run -u Cmdenv '--*.gym-connection.port=5555'

Make sure to use the same port there. Also, consider starting Veins first in order to avoid timeouts.

Avoid Timeouts

Veins-Gym expects a request from the Veins simulation after a certain time after env.reset (which may in turn have started the Veins simulation). If the Veins simulation takes a longer amount of (wall-clock) time to reach the point where the request is sent, the agent's environment may have timed out. This is intended to notify about stuck simulations, but may not work as intended if the simulation is more complex or the host' hardware is less powerful than expected.

Solution: Increase the timeout when registering the gym environment.

	# ...
		# ...
		"timeout": 10.0,  # new timeout value (in seconds)

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

veins_gym-0.3.3.tar.gz (18.9 kB view hashes)

Uploaded source

Built Distribution

veins_gym-0.3.3-py3-none-any.whl (18.2 kB view hashes)

Uploaded py3

Supported by

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