Skip to main content

Reinforcement Learning-based VANET simulations

Project description

Veins-Gym

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).

License

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/getting_started.md.

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 .pb.cc 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/veinsgym.pb.cc files (or however they may be called in the environment)
  • re-generate the protobuf-files by running snakemake src/protobuf/veinsgym.pb.cc 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:

gym.register(
	# ...
	kwargs={
		# ...
		"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:

gym.register(
	# ...
	kwargs={
		# ...
		"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.

gym.register(
	# ...
	kwargs={
		# ...
		"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.2.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

veins_gym-0.3.2-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file veins_gym-0.3.2.tar.gz.

File metadata

  • Download URL: veins_gym-0.3.2.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for veins_gym-0.3.2.tar.gz
Algorithm Hash digest
SHA256 65a012c8e837a729308ae7a4684c56a05c0b8fe216c2337926cfe9e2d69b9d52
MD5 c0530a0b59ba100ec04f8c19465fd2e1
BLAKE2b-256 d7851865b379107d03e59fbb02d27d59c38196f04905fef6e5806e844748b159

See more details on using hashes here.

File details

Details for the file veins_gym-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: veins_gym-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for veins_gym-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cee223ec5476fd323496153f2717310a6bb1ec07797d14d3dc27728b50753378
MD5 f908adad287756145d9da4f0d4956315
BLAKE2b-256 70a3c1f86d63119392df62ba7908b08b0cde6f6c795b79c2fd500ec2a6f3bd4d

See more details on using hashes here.

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