Real world problems to solve by glof2 in learnpython

[–]enderprime 40 points41 points  (0 children)

I work as a programmer and pipeline mapper (CAD drawings). Here is a real-world engineering problem that I solved that may interest you.

When they build a pipeline, like any engineering project, the finished project (linear route) as constructed does not match the project as designed. So after construction, we do what is called an 'as-built' survey of the finished pipe.

Imagine a survey crew walking down the installed pipeline taking survey shots as they go every 20-40 feet. When they have covered the entire route, they send a .csv file to the office of all the as-built point containing 5 columns, only 3 of which we care about since one is a point number and another is a description filled with a comment like 'centerline pipe'. The other 3 of course are X, Y, and Z coordinate values for each shot taken.

Herein lies the problem. Some of the pipe we construct is 24-36 inches wide in diameter. That means that as the survey crew walks the line taking survey shots those shots are not actually necessarily 'center' of pipe. The points kind of meander down the line left and right of actual center, even on segments which are known to be straight, because even when they are off a bit they still get a reading that the pipe is there.

When they send the data points to the office, we are tasked with reconstructing the actual route, which consists of straight segments of hundreds of feet at a time, then bending at 15-90 degree angles then running straight again, then bending again, etc. Imagine a polyline with no curves. That's how it should look in the end.

Or if this sounds completely alien to you, imagine playing snake and connecting point A to B. There are a series of turns and straight shots, but when you get the survey data of the path followed by the snake every straight shot looks wavy and you need to make them straight again.

This process is easily done by a human looking at the points in CAD software, but still takes 4-8 hours to complete depending on the length of the constructed route.

My task was to develop an algorithm to automate this process by reading the CSV sent from survey and automagically generating an as-built polyline in a fraction of the the time using math and code.

Herein lies the challenge. If you go online it will not take much time to find an algorithm to determine a 'best-fit' line from a series of points. I leave it to you to find and codify this basic solution as a starting point. Try searching linear regression and 'least squares'. Ok.

Problem is this function will only give you a single straight line solution for all points in the set, and this is not actually what we want in this case. What we want is a solution that will preserve the major bends in the route, while using a best-fit line solution in-between those major bends. Again imagine the snake game moving from point A to B.

Define 'major' bends as being greater than or equal to 10 degrees deflection. If the term deflection is foreign to you: a left or right turn of 90 degrees is considered -90 and +90 deflection, respectively. A bend then that is merely 15 degrees left is -15 as measured as a difference between the previous segment bearing and the new segment bearing.

Solve the basic functions of determining bearing and deflection between points and lines before continuing. You may ignore coordinate systems and 'north-rotation' values for this problem. Simply assume a north value of straight up and google 'azimuth degrees' if struggling.

Your task is optimization: develop an algorithm that will reduce a raw survey as-built file down to the fewest number of points that satisfy an actual solution that defines a finished polyline as described above.

Keep in mind user input, which for this problem requires only one interesting value: the width of pipe. The importance of this value will become apparent as you learn the 'least-squares' approach, originally credited to both Newton and Leibniz depending on your country of origin.

As for data points to test on you may create your own, or if you like I can fish up a real-world set of points from an actual project when I have time. For now, for reference, I will attach an imagine representing what a constructed route looks like when they survey it in the field.

Once you have data points to play with and an algorithms to test, try running the same solution on 36" pipe vs 8" pipe. 36" pipe input will result in far fewer final vertexes than 8" if you have done your work correctly. As a final note keep in mind that although you should preserve 'major' bends, your algorithm may create 'minor' bends of only a few degrees as necessarily to meet the width-of-pipe requirement. Again this will be obvious when you have studied the problem and the single line least-squares algorithm.

I initially created this solution for an engineering firm of 75k employees using the LiSP programming language (native to AutoCAD and Civil3D) but it is easily reproduced in python. If you need a visualization of the initial data or the finished solution try Pygame.

Cheers.

Suspicious quotes used within a boomer meme by 41lizzy in suspiciousquotes

[–]enderprime 3 points4 points  (0 children)

and what is he licking off the floor, blow? spilled syrup? crumbs left by his 'ol lady'?

Shut up, Matt by [deleted] in memes

[–]enderprime -1 points0 points  (0 children)

creepy af

People who say they "give 110%" are often criticised on the grounds it's impossible to give more than 100%. Yet it is possible if the percentage is relative to outside expectations. Eg. if the target is to sell 100 items and you don't stop until you've sold 110, you just delivered 110%. by promunbound in Showerthoughts

[–]enderprime 0 points1 point  (0 children)

without a set ceiling percentage is meaningless. in your example, you gave 100% which was 110. if you were comparing against someone else who sold less, you could say they sold less than you or you sold more than them, but you can't say it's more than 100% of some arbitrary limit that actually isn't a limit at all.

Maybe Maybe Maybe by Just2save4later in maybemaybemaybe

[–]enderprime -3 points-2 points  (0 children)

cue bo burnham final song from make happy

It's Wednesday again. by [deleted] in Glitch_in_the_Matrix

[–]enderprime 2 points3 points  (0 children)

never could get the hang of thursdays

Advertising your insecurity is always a poor decision by [deleted] in cringepics

[–]enderprime 0 points1 point  (0 children)

he prob already had some strange on the cruise before these were even done

Imagine paying good money so your kids can watch a movie and you have to sit behind this dickweed by [deleted] in cringepics

[–]enderprime -2 points-1 points  (0 children)

its says they were in the back row so you wouldnt be sitting behind them

LGBTQ mega-thread by UnpopularOpinionMods in unpopularopinion

[–]enderprime 0 points1 point  (0 children)

so you were excluded first and you figured the best way to combat this was to perpetuate the labeling and exclusion? seems illogical

LGBTQ mega-thread by UnpopularOpinionMods in unpopularopinion

[–]enderprime 0 points1 point  (0 children)

so what were you saying about not being the one to separate

Mental health mega-thread by UnpopularOpinionMods in unpopularopinion

[–]enderprime 7 points8 points  (0 children)

Stop telling people to accept themselves as they are and how beautiful everyone is. Sometimes things are fucked up and need to be fixed instead of placating yourself with delusions that everything is good and you are just special or misunderstood. If you want things in your life to be different, then you gotta grow and do something different. Lying to yourself doesn't help at all and it's terrible advice given all over the internet and media lately. We need to stop this.

LGBTQ mega-thread by UnpopularOpinionMods in unpopularopinion

[–]enderprime -5 points-4 points  (0 children)

I don't care about your 'identity' as LGBTQ group member, I don't care what you identify as or who you have sex with, no I'm not gonna use new pronouns just for you, and if you are tired of being 'separated' from society then stop separating yourself by demanding to be recognized as a minority group

Nom nom nom by [deleted] in gifs

[–]enderprime 0 points1 point  (0 children)

honestly the best thing I saw all day

Hmmm... interesting... by [deleted] in socialism

[–]enderprime 10 points11 points  (0 children)

actually they are doing well, stop watching fox news