VROOM-Project / vroom-frontend

Web frontend for VROOM
http://map.vroom-project.org/
BSD 2-Clause "Simplified" License
28 stars 30 forks source link

Json output, ploting solution #68

Closed Guillo667 closed 1 year ago

Guillo667 commented 1 year ago

Hi, I'm working with docker and I managed to link vroom-docker with osrm and the vroom-frontend. But I'm stuck with two problems that I don't exactly know how to solve.

  1. I want to get the solution of the optimization in a json file in my computer using the vroom-frontend.
  2. I want to plot a solution only giving the jobs/car locations and the order. Is that possible?

For the fist one: Here https://github.com/VROOM-Project/vroom-frontend/issues/39 says that you can do it putting the output key but I have tried a lot of things and could't get the file.

For the second one: I searched in the src documents of the vroom-frontend and saw that the "output" key has been changed to "solution" key and I can plot the solution of an output but I don't have the output.

Other way of ploting I think is to use the plan mode ( using options:{"c":true} is that right? ) <-- In this mode how can I put the routes of the vehicle if I want the plot.

What is the difference of using the Solution and the plan mode?

I hope any one could help me.

jcoupey commented 1 year ago

For 1: if you want to store an optimization run, you have to keep both input and output in a single file. You can indeed use this comment (except as you noticed replacing output with solution), then you have a single file that you can upload to the frontend to display both input and solution, without generating a new solving request.

For 2: if you want to provide the task ordering in input, then you should indeed use plan mode. If you want to plot that, then you're back at 1, you just need to append the result to the solution key and upload. For plain loading, it does not really matter if you're doing the solving from inside the frontend or outside.

Guillo667 commented 1 year ago

For 1: I use 01_intentar_salida.json I don't know what is missing because when I load to the frontend the file doesn't change.

For 2: I use 01_steps.json I manage to get the steps. Is there a way to force taking a specific street or pass to certain point that isn't a job or a start, end?

Other thing is that I change the config.yml file to get acces to the plan mode. The "options":{"c":true} in the json file doesn't work I have this in the yml file

cliArgs: geometry: false # retrieve geometry (-g) planmode: true # run vroom in plan mode (-c) if set to true threads: 4 # number of threads to use (-t) explore: 5 # exploration level to use (0..5) (-x) limit: '2mb' # max request size logdir: '/..' # the path for the logs relative to ./src logsize: '100M' # max log file size for rotation maxlocations: 2000 # max number of jobs/shipments locations maxvehicles: 100 # max number of vehicles override: true # allow cli options override (-c, -g, -t and -x) path: '' # VROOM path (if not in $PATH) port: 3000 # expressjs port router: 'osrm' # routing backend (osrm, libosrm or ors) timeout: 300000 # milli-seconds baseurl: '/' #base url for api

01_intentar_salida.json

{ "vehicles": [ { "id": 47, "start": [-78.507064, -0.220673], "end": [-78.507064, -0.220673] } ], "jobs": [ {"id":1001,"location":[-78.512056, -0.220656]}, {"id":1002,"location":[-78.513083, -0.2204802]}, {"id":1003,"location":[-78.509149, -0.218778]}, {"id":1004,"location":[-78.509802, -0.219078]}, {"id":1005,"location":[-78.509699, -0.219141]}, ], "solution":{} }

01_steps.json

{ "vehicles": [ { "id": 47, "start": [-78.507064, -0.220673], "end": [-78.507064, -0.220673], "steps":[{"type":"start"},{"type":"job","id":1001},{"type":"job","id":1002},{"type":"job","id":1003},{"type": "end"}] } ], "jobs": [ {"id":1001,"location":[-78.512056, -0.220656]}, {"id":1002,"location":[-78.513083, -0.2204802]}, {"id":1003,"location":[-78.509149, -0.218778]}, {"id":1004,"location":[-78.509802, -0.219078]}, {"id":1005,"location":[-78.509699, -0.219141]} ] }

Sorry for the text I couldn't load the files and is the first time using github.How did you put the arrow of unroll here. https://github.com/VROOM-Project/vroom-frontend/issues/39#issuecomment-438709945

By the way thanks for the answer.

jcoupey commented 1 year ago

In your example, the value for the solution key is empty so no solution can be loaded. You have to fill this with the actual solution you get when solving. Again see example provided in the comment from #39.

You can inspect the solution that the frontend receives using your browser dev tools (spot solving request in "network" and check the response) and/or log it by adjusting the frontend code.

Guillo667 commented 1 year ago

In the example I was trying to get the solution in the file not loading the (empty) solution.

Ok I'm going to try the dev tools.

Guillo667 commented 1 year ago

Hi again, thanks the dev tools worked. There I could find the output.

The plot also worked and as said I used the "solution" key instead of the "output" key.

The last inconvenient tha I got is that "options":{"c":true} isn't working. In the frontend files I didn't find any part that looks for the "options" key. Any idea of what is happening? (the override in config yml of the vroom is set to true)

jcoupey commented 1 year ago

Yes, "options":{"c":true} is meant to be interpreted by vroom-express. The frontend code has been written way before the plan mode was a thing so it is not handled at all. If you want to use plan mode, I'd suggest you do this outside the frontend, then plot the result afterward. If you have an input.json file describing a problem with vehicles steps:

  1. Solve in plan mode (use the command-line vroom -c -g -i input.json -o solution.json or send the input with "options":{"c":true} directly to vroom-express, e.g. using curl)
  2. Stitch input and output together (the content of solution.json should be added as the value of the solution key in input.json)
  3. Upload to the frontend
Guillo667 commented 1 year ago

Thanks for the answers.