mapbox / node-or-tools

Node.js bindings for or-tools vehicle routing problems
MIT License
146 stars 48 forks source link

Vehicle Specific Capacities #17

Open daniel-j-h opened 7 years ago

daniel-j-h commented 7 years ago

At the moment we expose a single vehicleCapacity property. With it users can set the capacities for all their vehicles. What we should do instead is expose a vehicleCapacities property (parallel array coinciding with the vehicles) where the user can specify a capacity on a per vehicle basis.

Related: Heterogeneous Fleets https://github.com/mapbox/node-or-tools/issues/11

cc @karenzshea

Abhishekrana254 commented 7 years ago

Daniel can you help me getting started with code for this issue. i have ubuntu 16.04 installed

daniel-j-h commented 7 years ago

Sure, here's how to get started on this task:

Hope that helps - feel free to post back if you need more details or have questions :)

Abhishekrana254 commented 7 years ago

hey daniel the work is almost done .. but i m having a tough time debugging . Can you suggest a way to debug nodejs coupled with c++ addons.

daniel-j-h commented 7 years ago

What I can recommend is:

then you should be able to attach a debugger and step through it. I can also recommend you forking this repo. and making a pull request early on so we can have some eyes on it and give you some hints early on.

Abhishekrana254 commented 7 years ago

hey man .. sorry to bother you but i have re-cloned the repository and rebuild from source .. but this time it is giving me this error ... Error in `node': munmap_chunk(): invalid pointer: 0x00007f4b71e2ea00 ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f4b8af2d7e5] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x1a8)[0x7f4b8af3a698] node(_ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE21_M_insert_unique_nodeEmmPNS4_10_Hash_nodeIS2_Lb0EEE+0x129)[0x1262049] /home/abhishek/Documents/abhishek-vrp/node-or-tools/lib/binding/node_or_tools.node(_ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE10_M_emplaceIJS2_EEES0_INS4_14_Node_iteratorIS2_Lb0ELb0EEEbESt17integralconstantIbLb1EEDpOT+0x9f)[0x7f4b739215ff] /home/abhishek/Documents/abhishek-vrp/node-or-tools/lib/binding/node_or_tools.node(_ZN19operations_research21RoutingModelInspector13EndVisitModelERKSs+0x8d)[0x7f4b7391eabd] /home/abhishek/Documents/abhishek-vrp/node-or-tools/lib/binding/node_or_tools.node(_ZNK19operations_research6Solver6AcceptEPNS_12ModelVisitorE+0x1f)[0x7f4b73970c5f] /home/abhishek/Documents/abhishek-vrp/node-or-tools/lib/binding/node_or_tools.node(_ZN19operations_research12RoutingModel24CloseModelWithParametersERKNS_23RoutingSearchParametersE+0xc40)[0x7f4b739083b0] /home/abhishek/Documents/abhishek-vrp/node-or-tools/lib/binding/node_or_tools.node(_ZN19operations_research12RoutingModel10CloseModelEv+0x22)[0x7f4b73907742] /home/abhishek/Documents/abhishek-vrp/node-or-tools/lib/binding/node_or_tools.node(_ZN9VRPWorker7ExecuteEv+0x518)[0x7f4b738d3dec] /home/abhishek/Documents/abhishek-vrp/node-or-tools/lib/binding/node_or_tools.node(_ZN3Nan12AsyncExecuteEP9uv_work_s+0x2e)[0x7f4b738c9d3d] node[0x131a881] node[0x13299b9] /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f4b8b2876ba] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f4b8afbd3dd] ======= Memory map: ======== 00400000-01bf5000 r-xp 00000000 08:03 1192648 /home/abhishek/.nvm/versions/node/v6.10.3/bin/node 01df4000-01e0d000 rw-p 017f4000 08:03 1192648 /home/abhishek/.nvm/versions/node/v6.10.3/bin/node 01e0d000-01e21000 rw-p 00000000 00:00 0 02c79000-032f1000 rw-p 00000000 00:00 0 [heap] 63c8ca00000-63c8cb00000 ---p 00000000 00:00 0 cd0b5800000-cd0b5900000 rw-p 00000000 00:00 0 fcb48c00000-fcb48d00000 rw-p 00000000 00:00 0 18cd26100000-18cd26200000 ---p 00000000 00:00 0 1f142e800000-1f142e900000 ---p 00000000 00:00 0 229122e00000-229122f00000 rw-p 00000000 00:00 0 23097a900000-23097aa00000 rw-p 00000000 00:00 0 2619614a7000-2619618a7000 rw-p 00000000 00:00 0 29831dd00000-29831de00000 rw-p 00000000 00:00 0 2b0a1ce00000-2b0a1cf00000 rw-p 00000000 00:00 0 2d6337500000-2d6337600000 rw-p 00000000 00:00 0 2e0667c00000-2e0667d00000 rw-p 00000000 00:00 0 37a8d1500000-37a8d1600000 rw-p 00000000 00:00 0 37e2a18cb000-37e2a1900000 ---p 00000000 00:00 0 37e2a1900000-37e2a1905000 rw-p 00000000 00:00 0 37e2a1905000-37e2a1906000 ---p 00000000 00:00 0 37e2a1906000-37e2a1907000 rwxp 00000000 00:00 0 37e2a1907000-37e2a1a00000 ---p 00000000 00:00 0 37e2a1a00000-37e2a1a05000 rw-p 00000000 00:00 0 37e2a1a05000-37e2a1a06000 ---p 00000000 00:00 0 37e2a1a06000-37e2a1a07000 rwxp 00000000 00:00 0 37e2a1a07000-37e2a1b00000 ---p 00000000 00:00 0 37e2a1b00000-37e2a1b05000 rw-p 00000000 00:00 0 37e2a1b05000-37e2a1b06000 ---p 00000000 00:00 0 37e2a1b06000-37e2a1b07000 rwxp 00000000 00:00 0 37e2a1b07000-37e2a1c00000 ---p 00000000 00:00 0 37e2a1c00000-37e2a1c05000 rw-p 00000000 00:00 0 37e2a1c05000-37e2a1c06000 ---p 00000000 00:00 0 37e2a1c06000-37e2a1c4b000 rwxp 00000000 00:00 0 37e2a1c4b000-37e2a1d00000 ---p 00000000 00:00 0 37e2a1d00000-37e2a1d05000 rw-p 00000000 00:00 0 37e2a1d05000-37e2a1d06000 ---p 00000000 00:00 0 37e2a1d06000-37e2a1dff000 rwxp 00000000 00:00 0 37e2a1dff000-37e2a1e00000 ---p 00000000 00:00 0 37e2a1e00000-37e2a1e05000 rw-p 00000000 00:00 0 37e2a1e05000-37e2a1e06000 ---p 00000000 00:00 0 37e2a1e06000-37e2a1eff000 rwxp 00000000 00:00 0 37e2a1eff000-37e2c18cb000 ---p 00000000 00:00 0 396ae0500000-396ae0600000 rw-p 00000000 00:00 0 3af22cf00000-3af22cf14000 rw-p 00000000 00:00 0 3ba6a23ff000-3ba6a2400000 ---p 00000000 00:00 0 3ba6a2400000-3ba6a2420000 rw-p 00000000 00:00 0 3ba6a2420000-3ba6a243f000 ---p 00000000 00:00 0 3c50a0c00000-3c50a0cf5000 rw-p 00000000 00:00 0 7f4b6c000000-7f4b6c026000 rw-p 00000000 00:00 0 7f4b6c026000-7f4b70000000 ---p 00000000 00:00 0 7f4b7162f000-7f4b71630000 ---p 00000000 00:00 0 7f4b71630000-7f4b71e30000 rw-p 00000000 00:00 0 7f4b71e30000-7f4b71e31000 ---p 00000000 00:00 0 7f4b71e31000-7f4b72631000 rw-p 00000000 00:00 0 7f4b72631000-7f4b72632000 ---p 00000000 00:00 0 7f4b72632000-7f4b72e32000 rw-p 00000000 00:00 0 7f4b72e32000-7f4b72e33000 ---p 00000000 00:00 0 7f4b72e33000-7f4b73633000 rw-p 00000000 00:00 0 7f4b73633000-7f4b73dce000 r-xp 00000000 08:03 2666046 /home/abhishek/Documents/abhishek-vrp/node-or-tools/lib/binding/node_or_tools.node 7f4b73dce000-7f4b73fcd000 ---p 0079b000 08:03 2666046 /home/abhishek/Documents/abhishek-vrp/node-or-tools/lib/binding/node_or_tools.node 7f4b73fcd000-7f4b73fff000 r--p 0079a000 08:03 2666046 /home/abhishek/Documents/abhishek-vrp/node-or-tools/lib/binding/node_or_tools.node 7f4b73fff000-7f4b74000000 rw-p 007cc000 08:03 2666046 /home/abhishek/Documents/abhishek-vrp/node-or-tools/lib/binding/node_or_tools.node 7f4b74000000-7f4b74103000 rw-p 00000000 00:00 0 7f4b74103000-7f4b78000000 ---p 00000000 00:00 0 7f4b78000000-7f4b78050000 rw-p 00000000 00:00 0 7f4b78050000-7f4b7c000000 ---p 00000000 00:00 0 7f4b7c000000-7f4b7c09b000 rw-p 00000000 00:00 0 7f4b7c09b000-7f4b80000000 ---p 00000000 00:00 0 7f4b80000000-7f4b80072000 rw-p 00000000 00:00 0 7f4b80072000-7f4b84000000 ---p 00000000 00:00 0 7f4b84000000-7f4b84021000 rw-p 00000000 00:00 0 7f4b84021000-7f4b88000000 ---p 00000000 00:00 0 7f4b88497000-7f4b884b0000 r-xp 00000000 08:03 5771765 /lib/x86_64-linux-gnu/libz.so.1.2.8 7f4b884b0000-7f4b886af000 ---p 00019000 08:03 5771765 /lib/x86_64-linux-gnu/libz.so.1.2.8 7f4b886af000-7f4b886b0000 r--p 00018000 08:03 5771765 /lib/x86_64-linux-gnu/libz.so.1.2.8 7f4b886b0000-7f4b886b1000 rw-p 00019000 08:03 5771765 /lib/x86_64-linux-gnu/libz.so.1.2.8 7f4b886b1000-7f4b886b2000 ---p 00000000 00:00 0 7f4b886b2000-7f4b88eb2000 rw-p 00000000 00:00 0 7f4b88eb2000-7f4b88eb3000 ---p 00000000 00:00 0 7f4b88eb3000-7f4b896b3000 rw-p 00000000 00:00 0 7f4b896b3000-7f4b896b4000 ---p 00000000 00:00 0 7f4b896b4000-7f4b89eb4000 rw-p 00000000 00:00 0 7f4b89eb4000-7f4b89eb5000 ---p 00000000 00:00 0 7f4b89eb5000-7f4b8a6b5000 rw-p 00000000 00:00 0 7f4b8a6b5000-7f4b8a6b6000 ---p 00000000 00:00 0 7f4b8a6b6000-7f4b8aeb6000 rw-p 00000000 00:00 0 7f4b8aeb6000-7f4b8b076000 r-xp 00000000 08:03 5771960 /lib/x86_64-linux-gnu/libc-2.23.so 7f4b8b076000-7f4b8b276000 ---p 001c0000 08:03 5771960 /lib/x86_64-linux-gnu/libc-2.23.so 7f4b8b276000-7f4b8b27a000 r--p 001c0000 08:03 5771960 /lib/x86_64-linux-gnu/libc-2.23.so 7f4b8b27a000-7f4b8b27c000 rw-p 001c4000 08:03 5771960 /lib/x86_64-linux-gnu/libc-2.23.so 7f4b8b27c000-7f4b8b280000 rw-p 00000000 00:00 0 7f4b8b280000-7f4b8b298000 r-xp 00000000 08:03 5771801 /lib/x86_64-linux-gnu/libpthread-2.23.so 7f4b8b298000-7f4b8b497000 ---p 00018000 08:03 5771801 /lib/x86_64-linux-gnu/libpthread-2.23.so 7f4b8b497000-7f4b8b498000 r--p 00017000 08:03 5771801 /lib/x86_64-linux-gnu/libpthread-2.23.so 7f4b8b498000-7f4b8b499000 rw-p 00018000 08:03 5771801 /lib/x86_64-linux-gnu/libpthread-2.23.so 7f4b8b499000-7f4b8b49d000 rw-p 00000000 00:00 0 7f4b8b49d000-7f4b8b4b3000 r-xp 00000000 08:03 5771824 /lib/x86_64-linux-gnu/libgcc_s.so.1 7f4b8b4b3000-7f4b8b6b2000 ---p 00016000 08:03 5771824 /lib/x86_64-linux-gnu/libgcc_s.so.1 7f4b8b6b2000-7f4b8b6b3000 rw-p 00015000 08:03 5771824 /lib/x86_64-linux-gnu/libgcc_s.so.1 7f4b8b6b3000-7f4b8b7bb000 r-xp 00000000 08:03 5771932 /lib/x86_64-linux-gnu/libm-2.23.so 7f4b8b7bb000-7f4b8b9ba000 ---p 00108000 08:03 5771932 /lib/x86_64-linux-gnu/libm-2.23.so 7f4b8b9ba000-7f4b8b9bb000 r--p 00107000 08:03 5771932 /lib/x86_64-linux-gnu/libm-2.23.so 7f4b8b9bb000-7f4b8b9bc000 rw-p 00108000 08:03 5771932 /lib/x86_64-linux-gnu/libm-2.23.so 7f4b8b9bc000-7f4b8bb2e000 r-xp 00000000 08:03 2888489 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 7f4b8bb2e000-7f4b8bd2e000 ---p 00172000 08:03 2888489 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 7f4b8bd2e000-7f4b8bd38000 r--p 00172000 08:03 2888489 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 7f4b8bd38000-7f4b8bd3a000 rw-p 0017c000 08:03 2888489 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 7f4b8bd3a000-7f4b8bd3e000 rw-p 00000000 00:00 0 7f4b8bd3e000-7f4b8bd45000 r-xp 00000000 08:03 5771826 /lib/x86_64-linux-gnu/librt-2.23.so 7f4b8bd45000-7f4b8bf44000 ---p 00007000 08:03 5771826 /lib/x86_64-linux-gnu/librt-2.23.so 7f4b8bf44000-7f4b8bf45000 r--p 00006000 08:03 5771826 /lib/x86_64-linux-gnu/librt-2.23.so 7f4b8bf45000-7f4b8bf46000 rw-p 00007000 08:03 5771826 /lib/x86_64-linux-gnu/librt-2.23.so 7f4b8bf46000-7f4b8bf49000 r-xp 00000000 08:03 5771879 /lib/x86_64-linux-gnu/libdl-2.23.so 7f4b8bf49000-7f4b8c148000 ---p 00003000 08:03 5771879 /lib/x86_64-linux-gnu/libdl-2.23.so 7f4b8c148000-7f4b8c149000 r--p 00002000 08:03 5771879 /lib/x86_64-linux-gnu/libdl-2.23.so 7f4b8c149000-7f4b8c14a000 rw-p 00003000 08:03 5771879 /lib/x86_64-linux-gnu/libdl-2.23.so 7f4b8c14a000-7f4b8c170000 r-xp 00000000 08:03 5771700 /lib/x86_64-linux-gnu/ld-2.23.so 7f4b8c332000-7f4b8c338000 rw-p 00000000 00:00 0 7f4b8c36c000-7f4b8c36f000 rw-p 00000000 00:00 0 7f4b8c36f000-7f4b8c370000 r--p 00025000 08:03 5771700 /lib/x86_64-linux-gnu/ld-2.23.so 7f4b8c370000-7f4b8c371000 rw-p 00026000 08:03 5771700 /lib/x86_64-linux-gnu/ld-2.23.so 7f4b8c371000-7f4b8c372000 rw-p 00000000 00:00 0 7ffc2e0a1000-7ffc2e0c4000 rw-p 00000000 00:00 0 [stack] 7ffc2e1b3000-7ffc2e1b5000 r--p 00000000 00:00 0 [vvar] 7ffc2e1b5000-7ffc2e1b7000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] Aborted (core dumped)

could you check if it is giving you the same error or is it just on my system?

daniel-j-h commented 7 years ago

Can you give us some more details - how did you build the bindings, what's the compiler and stdlib you are using, which operating system and distribution are you on etc.

Abhishekrana254 commented 7 years ago

I first checked the install script whether it is as u mentioned ... the i ran the command npm install ...and then npm install --build-from-source --debug as u mentioned and it is giving me above error in building. i am using ubuntu 16.04 LTS , and i have gcc version 5.4.0 20160609 installed.

daniel-j-h commented 7 years ago

Can you commit your work on a branch and then push it - I can't help you much without being able to reproduce it locally or have a look at what's going on.

Abhishekrana254 commented 7 years ago

Never mind daniel, that was sorted ... but there was one thing that was bothering me ... i am confused about the demands matrix as what does it means ... according to me if it was a demand array it would more clear to me as demand[i] at node i. I tried thinking like the vehicle carrying the load from a node to another node might change due to pickups . But they are all assinged to 1 except from depot, which also doesnt make sense to me ... please help... and i ll soon commit the work on a branch .. sorry i was occupied somewhere.

daniel-j-h commented 7 years ago

Check the docs in API.md - it's 2-dimensional for future features - not used right now. Set the second dimension to a constant value.

Abhishekrana254 commented 7 years ago

hey daniel hi, today i created a pull request .. it failed in travis build ... It is working in my system .

abhishek-rana-quifers commented 7 years ago

hey hi daniel, i had one query, Right now .. the node-or-tools is capable of deploying one order to exactly one location and only one vehicle carrying ... i want it .. to be able to take multiple orders at a given location, and with the given vehicles they can be delivered to the same location via one vehicle or more depending upon the constraints .Can this be possible, using the or-tools, i really need you advice on this to move forward.

daniel-j-h commented 7 years ago

You should be able to use multiple vehicles and then use the pickup and delivery feature to specify delivery and pickup constraints. If you want multiple vehicles to serve the same location you can add artificial locations internally and then collapse them again after you get the solution.

carlosen14 commented 6 years ago

What was about this?

dcoellarb commented 4 years ago

Hi, was wondering if this feature is supported, i don't see the new vehicleCapacities property in the documentation