define-problem macro - without fleet-size
Opened this issue · 3 comments
Hi marc
I wrote code to support TSPLIB vrp file. However, the macro define-problem was rewritten. How can I define-problem without fleet size ? I worked on an old version of Open-VRP.
The code link :
https://github.com/ckairaba/Open-VRP/blob/master/lib/read-cvrp.lisp
An instance:
https://github.com/ckairaba/Open-VRP/blob/master/test-cases/Christofides_01.vrp
Hi Kairaba,
Thanks for sharing the read-cvrp.lisp. It looks like quite a robust and flexible reader. However, I run into problems when I'm not in the open-vrp.util package, because the checks are done based on symbols. I managed to get it to work by switching packages, but perhaps a different compare would make it more robust? Perhaps `(string 'EXACT_2D) on the symbols before comparing?
The define-problem macro requires fleet-size, because the way it is implemented now is static. The network of nodes and the fleet of vehicles are created beforehand. Perhaps something to look into in the future is to make it dynamic and add vehicles to the fleet as needed?
Apologies for the plenty rewrites, I'm still constantly working on it. The latest version requires 3 parameters at the minimum: name
(which can be a symbol, as it will be converted to string), node-coords-list
and fleet-size
. Additional parameters are key-words, so if you have a list of demands, pass it to :demands
.
Either way, a short-term workaround is to set fleet-size to something large, say 20. print-routes
and plot-solution
will neglect the empty vehicles. When you're writing your algo, you can use get-busy-vehicles
and empty-routep
to filter them out.
At the moment, the keyword parameters only accept lists. So for :capacities, the list must be of equal length as fleet-size (which allows for heterogenous fleets). Actually, it should be able to accept a single number -- this is a feature that I've been wanting to implement. (See Issue #13). Short-term hack - (make-list fleet-size :initial-element capacity)
.
See: 177c4e4
Cheers! It's great to have you involved!
Marc
On Sat, Feb 11, 2012 at 4:29 PM, Karaba Ciss <
reply@reply.github.com
wrote:
Hi marc
I wrote code to support TSPLIB vrp file. However, the macro define-problem
was rewritten. How can I define-problem without fleet size ? I worked on an
old version of Open-VRP.
The code link :
https://github.com/ckairaba/Open-VRP/blob/master/lib/read-cvrp.lisp
An instance:https://github.com/ckairaba/Open-VRP/blob/master/test-cases/Christofides_01.vrp
Reply to this email directly or view it on GitHub:
https://github.com/mck-/Open-VRP/issues/12
Hi
I commited some corrections. The files open-vrp.asd, open-vrp-lib.asd, packages.lisp, test-cases.lisp, lib/read-cvrp.lisp have been modified. I exported the symbol :load-tsplib-vrp and defined the variables christofides01 and christofides01. So, you can easily run in your repl :
(solve-plot christofides01 (make-instance 'tabu-search :iterations 10 :animate T))
It works :)
Oops : in TSPLIB file node number does not start to zero ...
That's great, thanks, I'll pull it in :)
hehe yes I noticed that as well.. it's quite easy to make the count start at 1 optionally.. do you look at the nrs?