lionyouko / veinsgym_lowerloss

This repo is an example of scenario using veinsgym tool
GNU General Public License v3.0
1 stars 0 forks source link

veinsgym_lowerloss

(I am not supporting this repo anymore. It was used for thesis 2 years ago)

This repo is an example of scenario using veinsgym tool

If you already have veinsgym, gym, omnet, protobuf and their dependencies installed, just import this project to omnet and it may work just fine. You can also simply start the venv you use to run the python scripts and run TrivialRL.

If you aren't familiar with all above, try the following steps (that are guided to linux/ubuntu, so you may need to adapt to your system):

To run this project, it is needed to:

  1. Install omnetpp dependencies

  2. Install omnet++

  3. Download INET

  4. Download Veins

  5. Import INET and Veins to omnet++ (using gui, right click in Project Explorer > import).

  6. Build INET and Veins (Right Click each > Build Configurations > Build Selected).

  7. Download or clone this Project.

  8. Import this project to omnet.

  9. If not Project Referenced, right click the project, then Properties > Projects Reference > INET + Veins.

  10. Install ZMQ and Protobuf dependencies:

    1. ZMQ (at: https://zeromq.org/download/).
    2. First check protobuf version(s) on your machine with: "which protoc" and "locate protolib" (you may need to install mlocate: "sudo apt-get update" and "sudo apt-get install mlocate")
    3. It is better to download and install the same version being use by the system (for example if system uses libprotobuf.so.17 and usr is using libprotobug.so.26.), so you won't have conflicts with some INET packages at linking time (your omnet IDE will warn you about it and will raise an error 139 when you try to run the simulation).
    4. Build protobuf after downloading it. You can skip this part if you have a fully working protobuf.
  11. Go to the project, Properties > Omnet++ > Makemake > click src:makemake(deep, recursive) and Build > Options, then: 11.1 At Compile tab, check all. 11.2 At Link tab > additional libraries > add "zmq" and "protobuf". 11.3 At Custom tab add: MSGC:=$(MSGC) --msg6

  12. Build the project

  13. Go to agent dir, start a new venv, activate it and pip install gym and veinsgym

Now it is ready to be used by AI Agent.

  1. With venv activated at agent dir, just type python TrivialRL.py and run.

You may want to recompile/rebuild if not working with the binaries here.

You will want to run either noconnection config or MultipleGymsOne config. MultipleGyms is a postponed idea. Make sure to put 5555 port at TrivialRL if you will try General config.

Extra:

  1. If you want to use the DQN agent, you also will need to pip install stable_baselines3 at you venv. Also, you will need to open your venv libs, find veinsgym dir and change the file init.py at line 377 to "return StepResult(observation, float(reward[0]), False, {})"

Attention that there is no snakemake or similar, so it must be compiled using omnet IDE for now.