HurleyShanabarger Posted February 15, 2022 Share Posted February 15, 2022 (edited) I am trying to solve a "routing" problem. There is a given amount of gates (valves) Each gate either be open or closed Each gate is connected to one, two. three or four other gates With two given gates I would like to know which gates in-between must be opened to have a connection. Not really sure how to approach this - could someone push me in the right direction? I am aware that I could solve this task manually using a truth table, but that would neither be fun nor flexible Smile Edited February 15, 2022 by HurleyShanabarger Link to comment Share on other sites More sharing options...
Developers Jos Posted February 15, 2022 Developers Share Posted February 15, 2022 Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
HurleyShanabarger Posted February 15, 2022 Author Share Posted February 15, 2022 Thanks @Jos. Was not sure about the right place and as my request was without code I thought it might be better placed in the Developer General Discussion. Link to comment Share on other sites More sharing options...
Nine Posted February 15, 2022 Share Posted February 15, 2022 Could you give the input data of this ? Or do you need us to figure out how this could be done ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HurleyShanabarger Posted February 15, 2022 Author Share Posted February 15, 2022 The input data I have is a drawing, I tried to abstract it. I don't request someone to solve this for me, but any help is very much appreciated as well as any solution someone might come up with. Link to comment Share on other sites More sharing options...
Nine Posted February 15, 2022 Share Posted February 15, 2022 Ok, if I understand correctly your drawings, the problem was to open gate 1 to gate 8. So there is 3 possible solutions, right ? Since there is a bridge between 1 and 2, it means that 6 is linked to 4 gates (1,2,5,7), while you said max links is 3... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HurleyShanabarger Posted February 15, 2022 Author Share Posted February 15, 2022 You are right, my mistake. I looked at this wrongly, but four gates is the maximum. I corrected this in my first post. Link to comment Share on other sites More sharing options...
Nine Posted February 15, 2022 Share Posted February 15, 2022 (edited) Here a suggestion how to represent the drawings numerically : 1(2,6) 2(1,3,6,8) 3(2,4,7) 4(3,5) 5(4,6) 6(5,7) 7(3,6) 8(2) So everyone who wishes to play with your riddle can start with the same representation... Edited February 15, 2022 by Nine typo / corrected paths “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
argumentum Posted February 15, 2022 Share Posted February 15, 2022 1 hour ago, HurleyShanabarger said: The input data I have is a drawing, I tried to abstract it. I don't request someone to solve this for me, but any help is very much appreciated is it lemons ? is it car doors ? is it valves in a nuclear station ? is it a hardware or software thing ? Being vague does not aid helping you. Just state what in real life is you need to get done. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
HurleyShanabarger Posted February 15, 2022 Author Share Posted February 15, 2022 That would be a really interesting car But you got close, the gates are actually valves in a hydraulic system. Link to comment Share on other sites More sharing options...
Nine Posted February 15, 2022 Share Posted February 15, 2022 There you go. That was fun . #include <Array.au3> Local $sGates = _ "1(2,6)" & _ "2(1,3,6,8)" & _ "3(2,4,7)" & _ "4(3,5)" & _ "5(4,6)" & _ "6(5,7)" & _ "7(3,6)" & _ "8(2)" Local $aTemp = StringSplit($sGates, ")"), $aArr Local $aGate[$aTemp[0]][2] = [[$aTemp[0] - 1, 0]] For $i = 1 to $aTemp[0] - 1 $aArr = StringSplit($aTemp[$i], "(,", $STR_NOCOUNT) $aGate[$i][0] = $aArr[0] _ArrayDelete($aArr, 0) $aGate[$i][1] = $aArr Next OpenGate(1, "1", 8) Func OpenGate($iStart, $sPath, $iEnd) For $i = 0 to UBound($aGate[$iStart][1]) - 1 If ($aGate[$iStart][1])[$i] = $iEnd Then Return ConsoleWrite($sPath & "|" & $iEnd & @CRLF) If StringInStr($sPath, String(($aGate[$iStart][1])[$i])) Then ContinueLoop OpenGate(($aGate[$iStart][1])[$i], $sPath & "|" & ($aGate[$iStart][1])[$i], $iEnd) Next EndFunc I needed to change the links a bit, since 6 cannot send to 1 and 2. It can receive from 1 and 2, but not send. Untested with other path than from 1 to 8. I'll let you play with my riddle now “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
argumentum Posted February 15, 2022 Share Posted February 15, 2022 ..some of my knowing comes from aviation. Make sure that if an error can create a safety problem, to take measures to attend to that too. Automated systems should include what to default to, or do, in case of failures. So the system may need more than just, send a signal, with the expectancy that what is intended will occur, as it may not behave as expected, outside the lab. with possible real world "oops" . My 2 cents. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
jchd Posted February 15, 2022 Share Posted February 15, 2022 Your problem can be solved by well-known results established by the Graph Theory. Depending on characteristics of your devices/problem, generic solutions and algorithms are likely to apply. For instance, is the flow of hydraulics between valves oriented in all/some/none of the valves? Can cycles occur in the graph? Do you want to get the shortest path between two valves, any path, all possible pathes? Read on about DAGs, Trees, Forests, simple graphs and you'll learn howto tackle this kind of problem This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
HurleyShanabarger Posted February 16, 2022 Author Share Posted February 16, 2022 Thank you all for thje input and your work. 12 hours ago, Nine said: There you go. That was fun . I needed to change the links a bit, since 6 cannot send to 1 and 2. It can receive from 1 and 2, but not send. Untested with other path than from 1 to 8. I'll let you play with my riddle now Glad that you enjoyed it, and this one approach that also crossed my mind. I will try to understand and adapt this for my porpose. 11 hours ago, argumentum said: ..some of my knowing comes from aviation. Make sure that if an error can create a safety problem, to take measures to attend to that too. Automated systems should include what to default to, or do, in case of failures. So the system may need more than just, send a signal, with the expectancy that what is intended will occur, as it may not behave as expected, outside the lab. with possible real world "oops" . My 2 cents. Thanks you for pointing this out. Due to covid and part shortage we are currently not able to the new scenarios on real hardware, which would be the pre-validation. Settings/control of valves ist done by and external control. Within a simulation we want to see in which scenarios sensors connected to the system would measure flow/pressure/temperature depending on the valve position. My goal is to determine this exactly by using some scripting apporach. But I will keep the real world "oopsies" in mind and will use any solution only as guide and have it reviewed/triple checked. 8 hours ago, jchd said: Your problem can be solved by well-known results established by the Graph Theory. Depending on characteristics of your devices/problem, generic solutions and algorithms are likely to apply. For instance, is the flow of hydraulics between valves oriented in all/some/none of the valves? Can cycles occur in the graph? Do you want to get the shortest path between two valves, any path, all possible pathes? Read on about DAGs, Trees, Forests, simple graphs and you'll learn howto tackle this kind of problem That looks interesting. Not really the kind of theory I like, but sometimes what someones likes and what is required to get the job done are completley different things. Thank you very much. I also gave my simplification some thoughts and realized after the feedback from @argumentum and @jchd, that there is more to it than my simplification provides. Once I figured on how to show this I will share it with you! argumentum 1 Link to comment Share on other sites More sharing options...
RTFC Posted February 16, 2022 Share Posted February 16, 2022 (edited) This is just a variant of TSP, see the simulated annealing thread for example code. Edited February 16, 2022 by RTFC My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
HurleyShanabarger Posted February 17, 2022 Author Share Posted February 17, 2022 (edited) After Istarted reading about TSP, Simulated Annealing, Graph Theory and Depth first search I found this: https://www.geeksforgeeks.org/find-paths-given-source-destination/ I think it will help to achieve my goal. Edited February 17, 2022 by HurleyShanabarger argumentum 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now