-franciskane- Posted August 13, 2020 Share Posted August 13, 2020 I'm helping a friend in developing a project for our alma mater. And its based on this paper: An Enhanced Indoor Positioning Method Based on Wi-Fi RSS Fingerprinting So far 80% of the web app is finished except for the algorithm (We have no experience with algorithms to source code translations) that needs to be implemented in the website. Inside this paper there is this algorithm that the proponents of the research used. (attached as screenshot). The algorithm was converted to code by using MATLAB, but we are trying to use PHP with our project. Based on the pseudo code the calculation of the Euclidean Distance is the core of it. Can anyone help us with the translation just to get it started. Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/ Share on other sites More sharing options...
gw1500se Posted August 13, 2020 Share Posted August 13, 2020 1 and 2 would presumably be input from the web page. The rest would be something like: for ($m=1; $m<=$M; $m++) { for ($l=1; $l<=$L; $l++) { for ($j=1; $j<=$N; $j++) { #do calculation here storing it in a 2D array } # select minimum here (perhaps min() function) } } # use array sort # use PHP vector class # compute distance from vectors # echo results in desired format 2 Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580599 Share on other sites More sharing options...
gizmola Posted August 13, 2020 Share Posted August 13, 2020 Based on this page, the Euclidean distance function requires 2 points (p1, p2) so a function to calculate it would be something like this: function EuclideanDistance($p1x, $p1y, $p2x, $p2y) { return sqrt(pow($p1x - $p2x, 2) + pow($p1y - $p2y, 2)); } 1 Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580601 Share on other sites More sharing options...
gw1500se Posted August 13, 2020 Share Posted August 13, 2020 I assumed that they knew how to calculate the distance and just needed some pointers on how to structure the algorithm in PHP. 1 Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580602 Share on other sites More sharing options...
-franciskane- Posted August 14, 2020 Author Share Posted August 14, 2020 10 hours ago, gw1500se said: I assumed that they knew how to calculate the distance and just needed some pointers on how to structure the algorithm in PHP. Yes! since the formula is (I assume) indicated in the pseudocode. the translation of it to PHP is what we needed. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580604 Share on other sites More sharing options...
-franciskane- Posted August 14, 2020 Author Share Posted August 14, 2020 12 hours ago, gw1500se said: 1 and 2 would presumably be input from the web page. The rest would be something like: for ($m=1; $m<=$M; $m++) { for ($l=1; $l<=$L; $l++) { for ($j=1; $j<=$N; $j++) { #do calculation here storing it in a 2D array } # select minimum here (perhaps min() function) } } # use array sort # use PHP vector class # compute distance from vectors # echo results in desired format In our project the input will be coming from a mobile app that my friend made that scans a room. I don't if its needed but I can provide the documentation of the project here. Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580605 Share on other sites More sharing options...
-franciskane- Posted August 14, 2020 Author Share Posted August 14, 2020 this is some information from the project for better context. Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580606 Share on other sites More sharing options...
gizmola Posted August 14, 2020 Share Posted August 14, 2020 The way that the client/mobile app and the serverside routines will work, need to implement some sort of standard. My suggestion would be that you utilize json. So the webapp should send it's data to the web app in json format. In PHP it is then simply a function call (json_decode) in order to convert the data into either php objects or a php array. Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580614 Share on other sites More sharing options...
-franciskane- Posted August 14, 2020 Author Share Posted August 14, 2020 4 minutes ago, gizmola said: The way that the client/mobile app and the serverside routines will work, need to implement some sort of standard. My suggestion would be that you utilize json. So the webapp should send it's data to the web app in json format. In PHP it is then simply a function call (json_decode) in order to convert the data into either php objects or a php array. Hello! The php script that you sent. is there anything to add there or can we use that as is? and that will be incorporated into json? did I get that right? Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580615 Share on other sites More sharing options...
gw1500se Posted August 14, 2020 Share Posted August 14, 2020 I think you need to start on the mobile side and, as gizmola suggested, create the json formatted data. Post a sample of that so we get a better idea of what it looks like and then we can help you go from there with the PHP side. Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580616 Share on other sites More sharing options...
-franciskane- Posted August 14, 2020 Author Share Posted August 14, 2020 (edited) 3 minutes ago, gw1500se said: I think you need to start on the mobile side and, as gizmola suggested, create the json formatted data. Post a sample of that so we get a better idea of what it looks like and then we can help you go from there with the PHP side. Ok. I'll get the source code of the mobile app from my friend (because she's the one that developed it.) thanks! and we haven't yet tested how the mobile app and the web app will 'meet' Edited August 14, 2020 by -franciskane- Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580617 Share on other sites More sharing options...
-franciskane- Posted August 15, 2020 Author Share Posted August 15, 2020 22 hours ago, gw1500se said: I think you need to start on the mobile side and, as gizmola suggested, create the json formatted data. Post a sample of that so we get a better idea of what it looks like and then we can help you go from there with the PHP side. Hello my friend said the she wrote the mobile app's source code in unity Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580643 Share on other sites More sharing options...
gw1500se Posted August 15, 2020 Share Posted August 15, 2020 (edited) Language doesn't matter. What I want to see is the JSON output or whatever she programmed to be passed to the PHP script. It would be preferable if she programmed it to output it in JSON. Edited August 15, 2020 by gw1500se Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580644 Share on other sites More sharing options...
gizmola Posted August 15, 2020 Share Posted August 15, 2020 4 hours ago, gw1500se said: Language doesn't matter. What I want to see is the JSON output or whatever she programmed to be passed to the PHP script. It would be preferable if she programmed it to output it in JSON. To elaborate a bit, talk to your clientside developer and ask her for some test output. If she is not already outputting the collected data in json, then you want to ask her to modify that. She will need to change the app eventually to send output to the domain/url of the production server anyway. Ideally the url to send data would be configurable in the client so that you can have multiple server side environments (dev, test, prod). Development is the one you are currently working on now. Test would be for automated testing, and prod is of course production. Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580650 Share on other sites More sharing options...
-franciskane- Posted August 18, 2020 Author Share Posted August 18, 2020 (edited) On 8/15/2020 at 11:34 PM, gw1500se said: Language doesn't matter. What I want to see is the JSON output or whatever she programmed to be passed to the PHP script. It would be preferable if she programmed it to output it in JSON. Hello I have the c# files. but I cant upload them here. and from browsing those files I can't find any json file so maybe that she hasn't finished that part. I thought that I can finish first this algorithm then try to connect the website to the mobile app. but I guess my reasoning is wrong. Edited August 18, 2020 by -franciskane- Additional information Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580719 Share on other sites More sharing options...
gw1500se Posted August 18, 2020 Share Posted August 18, 2020 She may have finished but where/what is the output she plans to pass to the PHP script? Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580725 Share on other sites More sharing options...
-franciskane- Posted August 18, 2020 Author Share Posted August 18, 2020 20 minutes ago, gw1500se said: She may have finished but where/what is the output she plans to pass to the PHP script? I don't know if this is something but I browsed the files and I found this file named 'JsonHelper.cs'. Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580726 Share on other sites More sharing options...
gw1500se Posted August 18, 2020 Share Posted August 18, 2020 No, we need to see the actual output and how it plans to call the PHP script. However, it does look like JSON was the intention. Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580731 Share on other sites More sharing options...
-franciskane- Posted August 19, 2020 Author Share Posted August 19, 2020 20 hours ago, gw1500se said: No, we need to see the actual output and how it plans to call the PHP script. However, it does look like JSON was the intention. Ohh. Ok I get it. We aren't on that phase yet because of the pandemic. My friend can't go to our alma mater yet to test the QR Scanner. We are hoping to finish everything first before she can test the mobile app and the website. then debug. Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580760 Share on other sites More sharing options...
gw1500se Posted August 19, 2020 Share Posted August 19, 2020 She can't make up test data? Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580761 Share on other sites More sharing options...
-franciskane- Posted August 20, 2020 Author Share Posted August 20, 2020 On 8/19/2020 at 9:18 PM, gw1500se said: She can't make up test data? The only part the we can make test data for (that I know of) is the login credentials from the db of the website that will also be used by the mobile app. And I wouldn't know how would you test a qr scanner without being there. Quote Link to comment https://forums.phpfreaks.com/topic/311327-help-in-translating-pseudo-code-of-algorithm-to-php-from-a-research-paper/#findComment-1580793 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.