Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Parameter for ORS #310

Closed
dooley opened this issue Mar 8, 2020 · 13 comments
Closed

Question: Parameter for ORS #310

dooley opened this issue Mar 8, 2020 · 13 comments

Comments

@dooley
Copy link

dooley commented Mar 8, 2020

Is it possible to add additional parameter to VROOM's input, when using ORS as routing backend? If yes, can someone please provide a example?

For example if i would optimize hgv with dynamic restrictions like maxweight and maxheight, i must set options.profile_params.restrictions:

{ "preference": "fastest", "instructions": true, "geometry": true, "units": "m", "attributes": [ "detourfactor", "percentage" ], "instructions_format": "html", "elevation": true, "options": { "profile_params": { "restrictions": { "height": "3", "weight": "7" } }, "vehicle_type": "hgv" }, "coordinates": [ [ 8.706011, 48.830232 ], [ 8.708618, 48.827859 ] ], "extra_info": [ "steepness", "waytype", "surface" ] }

@nilsnolde
Copy link
Contributor

nilsnolde commented Mar 8, 2020

No that's not possible. ORS can't respect any restrictions for matrix requests. Not yet anyways, we're working towards it at some point:
GIScience/openrouteservice#385

However, you CAN do it with Valhalla (and only with Valhalla of all FOSS routers) and vroom's custom matrix capabilities. You could also sponsor #306, then it'd be possible natively.

And even #219 to be able to use Mapbox or our hosted ORS directly. Almost forgot about that..

@dooley
Copy link
Author

dooley commented Mar 8, 2020

Too bad ORS don't support that. Valhalla is to slow. I use OSRM with VROOM for car and foot and in progress to extend the services to hgv. So i'm stuck with OSRM and 3 different fixed hvg-profiles :-(

Anyway, thanks for clarification.

@dooley dooley closed this as completed Mar 8, 2020
@stefanocudini
Copy link

hi i am using vroom and as ORS backend ..
I understand that vroom only uses the api matrix from ORS.

in my use case I don't need to be dynamic for every requests, because the profile of the vehicle I use is always the same.

I would like for example some predefined preference values, for example:
preference = 'shortest' instead 'fastest',
and some of these
restrictions = width = 3m, height = 2m, weight = 2.5t

can I make sure to enter these preferences for all requests to the api matrix? and therefore to have them also in the vroom result?

or is there another way to switch these preferences from vroom to ors?

I'm using ors-python bindings

@nilsnolde
Copy link
Contributor

Well, vroom uses the Matrix service, where all of these settings are not applicable. Matrix is pretty much the opposite of dynamic for the time being...

If you really want restrictions, you'll need to request /directions requests, one-by-one, for all possible combinations of vehicles an locations, i.e. re-create a matrix request, and post a custom matrix to vroom, without choosing a routing provider.

And do note, that shortest doesn't make much sense with vroom (I think), as distance is not available as objective, only time. So you'd optimize wrong assumptions.

@stefanocudini
Copy link

hi @nilsnolde tnks for your suggestions!

mmh interesting considerations..

In my use case of vroom I have only the capacity of vehicles and the amounts of jobs, without timing limits.. or time windows..

I was thinking that as a good temporary solution if I calculate the order of execution of jobs with vroom and then pass the vroom output coordinates(in the same order) to a normal ors directions request?

would it make sense in your opinion?

@stefanocudini
Copy link

my outputs is this..
vroom

@jcoupey
Copy link
Collaborator

jcoupey commented Mar 26, 2020

I understand that vroom only uses the api matrix from ORS.

Not exactly, we fire a matrix request prior to optimization, but if you use the -g flag then we'll send one route request per vehicle to add extra information for all routes (distances and geometry).

I was thinking that as a good temporary solution if I calculate the order of execution of jobs with vroom and then pass the vroom output coordinates(in the same order) to a normal ors directions request?

That's pretty much what -g does for you, using those parameters.

When using OSRM, all the "predefined preference values" are baked in the profile so you end up with consistent responses for table and route requests. I think the simplest way would be to use the same approach with ORS:

  • define a custom ORS profile with the defaults you wish so they're taken into account for both matrix and route requests
  • serve this custom profile somehow
  • point vroom to the specific profile using -r ors -a my-profile:host -p my-profile:port
  • specify "profile": "my-profile" for vehicles in your input problems

@stefanocudini
Copy link

stefanocudini commented Mar 26, 2020

hi @jcoupey VROOM is really powerful for my use case, great job!

That's pretty much what -g does for you, using those parameters.

I'm using VROOM with my own instance of OpenRouteService and I connect it through ORS python bindings.

import openrouteservice as ors
clientVrp = ors.Client(base_url='http://localhot:8081/', key='')
optimized = clientVrp.optimization (
     vehicles = vehicles,
     jobs = jobs,
     geometry = True
)

can I use the G flag you are talking about in python bindings?
My VROOM config is here:
https://github.com/DigitalCommonsLab/docker-ors-vroom/blob/master/vroom/config.js
can I add ors parameters in this config file? what format?

many tnks

@jcoupey
Copy link
Collaborator

jcoupey commented Mar 26, 2020

can I use the G flag you are talking about attracting bindings?

From your vroom-express config here, it looks like you already do. An easy check would be to run a sample query and see if you have a distance key in the summary object in output.

You could use the same steps as in my previous message, but replace the third point by passing the profile config at the vroom-express level:

const routingServers = {
  'my-profile': {
    host: 'ors',
    port: '8080'
  },
  ...
  }

@nilsnolde
Copy link
Contributor

nilsnolde commented Mar 26, 2020

@stefanocudini

can I use the G flag you are talking about in python bindings?

You already do, geometry=True does exactly that, as defined here.

can I add ors parameters in this config file? what format?

No, not possible. As I said in the first comment, you can't use parameters with the matrix API! What @jcoupey suggests (to create a separate profile & graph hard-coded with those parameters) is indeed the best way. You shouldn't be afraid of Java though;)

@stefanocudini
Copy link

You shouldn't be afraid of Java though;)
I am allergic to Java :)

many thanks for your patience! @nilsnolde && @jcoupey
is very very interesting to understand how these two tools ors + vroom work!

maybe I have not explained well my problem is much simpler.. from the docs I have not understood well where I can to insert the default parameters for my HGV profile.
I have this simple file(renamed in config.json but is the app.config of ors) with two profiles but basically I want use only HGV:
https://github.com/DigitalCommonsLab/docker-ors-vroom/blob/master/ors/config.json

within this default configuration how can I enter the parameters of the vehicle like: height, weight, width? the docs... is not clear about this :(

if I understand correctly the solution I can insert them in the my app.json file and then regenerate the graphs and also my api matrix will use these parameters, is it right?

@nilsnolde
Copy link
Contributor

That goes a little too much off-topic for vroom and I'd refer you to our forum: https://ask.openrouteservice.org. In short: no, that's not how you do it. You have to create it in Java and recompile the source, i.e. clone this and adapt: https://github.com/GIScience/openrouteservice/blob/master/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/HeavyVehicleFlagEncoder.java. Then change a few entrypoints for the API etc. It's involved and sorry, we can't give any support for custom stuff like that, which goes way beyond any normal usage.

@stefanocudini
Copy link

stefanocudini commented Mar 31, 2020

I understood, thanks

for this reason I had written also here: GIScience/openrouteservice#385

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants