User talk:Voidious/Optimal Velocity

From Robowiki
< User talk:Voidious
Revision as of 09:43, 1 July 2010 by RednaxelaBot (talk | contribs) (Using <syntaxhighlight>.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

I did a quick one-liner which gives almost exactly the same results as your getMaxVelocity(distance):

       private static final double maxVel(double distance){
         return Math.floor((Math.sqrt(1 + 4*2/Rules.DECELERATION*distance) - 1));
         
      }

The difference is that mine gives integer results, rather than all the 0.5s 0.33333s 0.25s and 0.666667s.

Distance  Skilgannon    Voidious
0          0.0           0.0
1          1.0           1.0
2          2.0           2.0
3          2.0           2.5
4          3.0           3.0
5          3.0           3.5
6          4.0           4.0
7          4.0           4.333333333333333
8          4.0           4.666666666666667
9          5.0           5.0
10          5.0           5.333333333333333
11          5.0           5.666666666666667
12          6.0           6.0
13          6.0           6.25
14          6.0           6.5
15          6.0           6.75
16          7.0           7.0
17          7.0           7.25
18          7.0           7.5
19          7.0           7.75
20          8.0           8.0

--Skilgannon 10:00, 16 July 2009 (UTC)

Hey Skilgannon, I did a test with your one-liner with the formula's on Positive/Optimal Velocity:

StartVelocity = 0.0; StartDistance = 6.0;

velocity = 0.0; distance=6.0
velocity = 1.0; distance=5.0
velocity = 2.0; distance=3.0
velocity = 2.0; distance=1.0
velocity = 1.0; distance=0.0

StartVelocity = 0.0; StartDistance = 10.0;

velocity = 0.0; distance=10.0
velocity = 1.0; distance=9.0
velocity = 2.0; distance=7.0
velocity = 3.0; distance=4.0
velocity = 3.0; distance=1.0
velocity = 1.0; distance=0.0

StartVelocity = -1.9; StartDistance = 10.0;

velocity = -1.9; distance=10.0
velocity = 0.10000000000000009; distance=9.9
velocity = 1.1; distance=8.8
velocity = 2.1; distance=6.700000000000001
velocity = 3.1; distance=3.600000000000001
velocity = 2.0; distance=1.600000000000001
velocity = 1.600000000000001; distance=0.0

StartVelocity = 8.0; StartDistance = -2.0;

velocity = 8.0; distance=-2.0
velocity = 6.0; distance=-8.0
velocity = 4.0; distance=-12.0
velocity = 2.0; distance=-14.0
velocity = -0.0; distance=-14.0
velocity = -1.0; distance=-13.0
velocity = -2.0; distance=-11.0
velocity = -3.0; distance=-8.0
velocity = -4.0; distance=-4.0
velocity = -3.0; distance=-1.0
velocity = -1.0; distance=0.0

StartVelocity = 5.0; StartDistance = 40.0;

velocity = 5.0; distance=40.0
velocity = 6.0; distance=34.0
velocity = 7.0; distance=27.0
velocity = 8.0; distance=19.0
velocity = 7.0; distance=12.0
velocity = 6.0; distance=6.0
velocity = 4.0; distance=2.0
velocity = 2.0; distance=0.0

Your solution and Voidious's one seem to preform about the same. Interesting. :) By the way, I did adjust your function to:

    private static final double maxVel(double distance){
    	if(distance<0)
    		return -maxVel(-distance);
    	if(distance<=Rules.DECELERATION)
    		return distance;
        return Math.floor((Math.sqrt(1 + 4*2/Rules.DECELERATION*distance) - 1));
     }

Otherwise it gives nextVel=0.0 on distance==0.6. --Positive 10:50, 16 July 2009 (UTC)

To tell the truth, I actually like the results Voidious's version gives better, as it keeps a slightly higher velocity the whole way through to minimise any possible gap at the end. =) I've made a simplified version of the whole predictor based on your ideas, I'll post it just now. --Skilgannon 11:19, 16 July 2009 (UTC)

Wow, that's pretty neat. While I know that, theoretically, you don't need to go max speed in every case, it's become a warning sign to me of a probable bug in solutions to this problem. For instance, for d=19.9, yours gives v=7, which will cause an extra tick (7, 6, 4, 2, d=0.9 remaining). Nevertheless, pretty cool. You darn students and your non-rusty math chops! =) --Voidious 14:07, 16 July 2009 (UTC)