Go to Post A lack of knowledge is okay; a lack of initiative to learn more is not. - Madison [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-10-2016, 08:20
Foster Foster is offline
Engineering Program Management
VRC #8081 (STEMRobotics)
Team Role: Mentor
 
Join Date: Jul 2007
Rookie Year: 2005
Location: Delaware
Posts: 1,392
Foster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond repute
Optimization, when to stop

I'm a big Ether fan, most of his posts are set out to make the reader think. One of his posts got me thinking about software optimization.

Backstory: Stacy from FRC 1318 built a set interfaces to allow data from the FIRST API server to be pulled into the stat package/language R for processing. This would be a good thing for scouting teams, they could get data from FIRST and apply it to their match.

Later on, Ether wanted to get the World OPR calculations done. He had worked on it and wasn't successful, I gave it a shot, but I had approached the problem the wrong way and I wasn't successful.

Stacy came out with code that processed the WOPR in about 13 seconds. Pretty cool, this would allow WOPR discussions to take place during long breaks of matches and be discussed by color commentators.

I was impressed, both that Stacy had gotten it to work and that it ran in 13 seconds. Ether suggested that the time get cut in half and then in a later post by a factor of 10. Both which may be reasonable goals. But are they really?

When I've been asked in the past to do some optimization's I start looking at how many times the the transaction will run and by how many people.

XKCD has a good cartoon that covers this situation.



So lets look at the situation. We want to shave about 5 seconds off (cut time in half). If it's just Ether doing the WOPR run after Worlds, then we should spend about 25 seconds working on it. If we want to get it to about a second, we can work about a minute on it.

So clearly for the "just Ether case", it's not worth it.

But lets take the other extreme. After every match at every event we are going to calculate WOPR. Lets go with 70 events and about 70 matches per event 4900, lets call it 5000 matches.

Spreading them across 7 weeks and 7 days gives us about 100 times per day. Looking at the chart, saving 5 seconds gives us about 10 days of time we can spend on this. (If you were to spread them across a year, you would get 13 per day or the ability to spend 2 hours on the task).

A more likely case is wanting WOPR for District Champs / World Championships and events that bring big teams together like IRI and Cheesy Champs. Lets call it 12 events and 70 matches that gives us about 50 times a day we will do WOPR, so we can spend about 5 days on the optimization. (Likewise if you were to spread it across the year, you can spend about 20 minutes, you may have already blown most of that time reading this article. )

The above discussion assumes that you are doing the work and that you are doing the activity, you are "reaping" the time saved. In our case of WOPR everywhere / every match, unless you are Koko Ed, you are not going to all those events. So your efforts are paying into the system.

If you have 5 days to spend and if you think that WOPR calculations will become a thing to do thousands of times in a year, take up Ether's challenge to cut the time in 1/2.
__________________
Foster - VEX Delaware - 17 teams -- Chief Roboteer STEMRobotics.org
2010 - Mentor of the Year - VEX Clean Sweep World Championship
2006-2016, a decade of doing VEX, time really flies while having fun
Downingtown Area Robotics Web site and VEXMen Team Site come see what we can do for you.
Reply With Quote
  #2   Spotlight this post!  
Unread 25-10-2016, 09:10
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,756
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Optimization, when to stop

You might also factor in the number of teams that might individually be utilizing this task concurrently for their own scouting purposes no matter who optimized it.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #3   Spotlight this post!  
Unread 25-10-2016, 09:24
Aren Siekmeier's Avatar
Aren Siekmeier Aren Siekmeier is offline
on walkabout
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Apr 2008
Rookie Year: 2008
Location: 대한민국
Posts: 735
Aren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond repute
Re: Optimization, when to stop

Sometimes we have to forgive the theoretically minded for exploring the realm of possibilities.

In your situation, your argument makes sense. But what I think Ether was after is that OPR can be computed much more quickly, and perhaps this makes it possible to do that computation much more often for a higher reward. Such as in projections, or monte carlo simulations, or in navigating some some sort of decision tree (ok so I'm making some things up here). But in fact, linear solvers constitute a large field in their own right, enjoying applications in embedded electronics, supercomputing, computational science research, computer vision, artificial intelligence, engineering simulations, and more and more and more. The point is, you can certainly stop optimizing once your particular application no longer benefits from further optimization, in fact your boss may compel you to. But other applications may become feasible if you can massively reduce the cost of the process.

After all, how many quotes are there about never needing 100 KB, oh wait nevermind 100 MB, oh wait nevermind 100 GB of storage space? Similarly for internet speeds, global travel times, the cost of goods and services, etc. When you need a certain result, do what gets the job done. But a little research into how to do it better can put much bigger results on the table.

Last edited by Aren Siekmeier : 25-10-2016 at 09:26.
Reply With Quote
  #4   Spotlight this post!  
Unread 25-10-2016, 11:26
Turing'sEgo Turing'sEgo is offline
Registered User
no team
 
Join Date: Jan 2016
Rookie Year: 2010
Location: Boulder
Posts: 47
Turing'sEgo can only hope to improve
Re: Optimization, when to stop

https://en.wikipedia.org/wiki/Wirth%27s_law
Reply With Quote
  #5   Spotlight this post!  
Unread 28-10-2016, 13:37
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,044
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Optimization, when to stop



Thanks for the encouraging words Foster.

Having done this computation in Octave (Matlab), SciLab, and Python, I knew how long it should take. But my initial R implementation was a factor of 10 (or more) slower. I wasn't willing to accept this.

So while I was awaiting input from the R community here on CD, I researched it myself and got R to do the computation just as fast. In so doing, I learned a lot about R. And that was the whole point of the exercise because, echoing what Aren said, what I learned makes R a far more powerful tool for me to use for other large problems I may encounter in the future.

As I said, I'm not an R guru, so my solution was actually a hybrid. I used the AWK scripting language to pre-process the 8column data into three files: Aij.dat, b.dat, and T.dat. Then my R code reads those three files and computes the OPR.

For the large 8column data set linked above, the AWK script execution time is about 270 miliseconds. The R script execution time is about 660 milliseconds.

If some R guru will take this pseudo-code and write an equivalent R script that runs as fast as my AWK script, I will combine that with my R OPR script and post it here on CD for all R mavens to study and perhaps improve.

Fair deal?


Attached Files
File Type: doc 8col_processing.doc (635 Bytes, 18 views)

Last edited by Ether : 28-10-2016 at 18:36. Reason: added attachment
Reply With Quote
  #6   Spotlight this post!  
Unread 29-10-2016, 21:00
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,044
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Optimization, when to stop

Quote:
Originally Posted by Ether View Post
I used the AWK scripting language to pre-process the 8column data into three files: Aij.dat, b.dat, and T.dat.
Here is a ZIP of Aij.dat, b.dat, and T.dat


Attached Files
File Type: zip Aij b T.zip (153.9 KB, 3 views)
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:46.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi