ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
how to use Dijkstra algorithm to conveyor system;
how to use Dijkstra to conveyor system;
in my project,conveying material from one place to another place there are a lot of routes in my conveyor system; so i want to use Dijkstra to conveyor system;or use usercommands and the first parameter is first conveyor and the second parameter is the last conveyor,the materials can search available routes and conveying in my conveyor system; i know we can use itemtype ,label or global table to contol out port ,but it is too troublesome I do not knows where code control the op travling network node, i think my problem can use some internal code like control "the op travling network node" and i want to use binary seartch tree to write usercommands my project is big raw material yard can you give me some advise?do anyone do this before? |
#2
|
|||
|
|||
To use this dynamically to route from 'a' to 'b' you'd need to keep the port sequence on the item or execute it on the sendto of every conveyor, so my approach would be to automatically create a lookup table on each conveyor (as a variable or label) that tells me which port has the shortest route to the item's destination, and then find the port to return in the sendto trigger. The lookup table is like a signpost at a junction.
Pre-populate the lookup table using the Dijkstra algorithm or similar that marks conveyors as 'visited' when recursing through the conveyor port network and returns its own length plus the downstream conveyors returned lengths for the various destinations. When the output conveyor is marked as visited you know not to go down that branch. When receiving the port-destination-distances back, compare with the best so far and update the ports listed in the table to reflect improvements and add new destinations. Last edited by Jason Lightfoot; 03-08-2010 at 08:32 AM. Reason: clarification |
The Following User Says Thank You to Jason Lightfoot For This Useful Post: | ||
Lars-Olof Leven (03-08-2010) |
#3
|
|||
|
|||
Actual Situation is different,some pathes share some conveys,if conveting some material use one path and use
these sharing conveys, some other pathes can not use these sharing conveys,so if you want use one route,you must reserve this route,and this route must shortest in available route. Sorry, I didn't express clearly, so i want to use usercommands to achieve " the first parameter is first conveyor and the second parameter is the last conveyor,the materials can search available routes and conveying in my conveyor system" This is the first step like these: creatconveylist(treenode firstconvey,treenode endconvey,treenode table,int i,int portnum) { int n=0; int k=0; n=nrop(firstconvey); if(n=0) return 0; if(tonum(firstconvey)==tonum(endconvey)) { return 1; } settablenum(table,1,k,tonum(firstconvey)); settablenum(table,2,k,portnum); k++; for(int i=0;i<n;i++) { if(content(Outobject(firstconvey,i)==0) creatconveylist(Outobject(firstconvey,i), endconvey,table,i,portnum) } } but usercommands don't support nested loop do you have other ideas? how to use flexsimscript to support nested loop? Last edited by LINWEIXU; 03-14-2010 at 08:16 AM. |
#4
|
|||
|
|||
I don't know how to realize "Pre-populate the lookup table using the Dijkstra algorithm or similar that marks conveyors as 'visited' when recursing through the conveyor port network and returns its own length plus the downstream conveyors returned lengths for the various destinations. When the output conveyor is marked as visited you know not to go down that branch. When receiving the port-destination-distances back, compare with the best so far and update the ports listed in the table to reflect improvements and add new destinations."
can you give me a example or pseudocode? thank you very much Last edited by LINWEIXU; 03-14-2010 at 11:32 PM. |
#6
|
|||
|
|||
A* implementation example for network nodes
Here is the shortest path example - only I thought maybe Dijkstra would be a little inefficient for huge networks, so I've implemented the A* algorithm (Dijkstra is a simplification of this without the ability to 'leave early' as I understand it).
The results are stored on the 'Start' network node under a label called routes so as more queries are run the routes build up. You could then check this routes table before you ask to find the route for further efficiency. There are two user commands - getRoute (the A* algorithm) and writeRoute, which writes the results and opens a table view of the route found. The user only needs to call getRoute and pass it the start and finish objects - it calls writeRoute itslelf. Changing it to work with conveyors should just be a matter of reading the length of the conveyor instead of the distance node of the connectionsout ( the line where 'newdist' is assigned) - although you'll probably want to revise the estimator too. I've not fully checked the logic yet so let me know if anyone finds something I've missed. Thanks. Last edited by Jason Lightfoot; 03-18-2010 at 07:09 PM. |
#9
|
|||
|
|||
Createcoupling creates two nodes with values that point to each other. It's a mechanism used for creating relationships that persist between model saves and compilation (where the memory address changes), and is the basis for connections between objects in the model - eg. ports, members of a timetable, and also stations on network nodes.
For more information see the command help. |
The Following 2 Users Say Thank You to Jason Lightfoot For This Useful Post: | ||
Tom David (03-22-2010) |
Thread | Thread Starter | Forum | Replies | Last Post |
Can embedding genetic algorithm in Flexsim ? | ankus d | Q&A | 7 | 03-10-2015 10:09 PM |
What is the difference between a Conveyor and Basic Conveyor | shivrash | Q&A | 2 | 07-21-2009 04:09 AM |
Can I write to the system console? | Steven Hamoen | Q&A | 2 | 11-26-2008 06:37 AM |
Concept Training System | Brandon Peterson | User Development | 0 | 11-14-2008 12:02 PM |
shortest path algorithm | Vinay Mehendiratta | Q&A | 5 | 01-25-2008 11:42 AM |