Difference between revisions of "User:Dsekercioglu/MEA"

From Robowiki
Jump to navigation Jump to search
(Little fix)
Line 1: Line 1:
:After brute force MEA calculations, I realised that moving fully orbital wasn't the best option to maximise the [[MEA]]. I found a function with polynomial regression which works very well.
+
:Thanks [[Xor]]. I found a bug with the orbital one which gave 2 times more advancing velocity and fixed the calculation.
 +
:After brute force MEA calculations, I realised that moving perpendicular wasn't the best option to maximise the [[MEA]]. I found a function with polynomial regression which works very well.
  
 
;Old Brute Force [[MEA]]
 
;Old Brute Force [[MEA]]
Line 6: Line 7:
 
         for (int a = 0; a < 360000; a++) { // For higher accuracy. Normal value is 360.
 
         for (int a = 0; a < 360000; a++) { // For higher accuracy. Normal value is 360.
 
             double angle = Math.toRadians(a / 1000.0);
 
             double angle = Math.toRadians(a / 1000.0);
             double mea = Math.sin(angle) / (bulletSpeed / 8 - Math.cos(angle));
+
             double mea = Math.asin(Math.sin(angle) / (bulletSpeed / 8 - Math.cos(angle) / 2));
 
             if (mea > highestMea) {
 
             if (mea > highestMea) {
 
                 highestMea = mea;
 
                 highestMea = mea;
Line 18: Line 19:
 
<pre>
 
<pre>
 
         double x = bulletSpeed;
 
         double x = bulletSpeed;
         double a = -3.508129323E-5;
+
         double a = 4.626248824E-7;
         double b = 2.460363294E-3;
+
        double b = -4.203721619E-5;
         double c = -6.666318894E-2;
+
         double c = 1.571662957E-3;
         double d = 8.545020365E-1;
+
         double d = -3.085855208E-2;
         double e = -3.337830707;
+
         double e = 3.337262571E-1;
         double angle = a * Math.pow(x, 4) + b * Math.pow(x, 3) + c * Math.pow(x, 2) + d * x + e;
+
         double f = -2.893934846E-1;
         return Math.sin(angle) / (bulletSpeed / 8 - Math.cos(angle));
+
         double angle = a * Math.pow(x, 5) + b * Math.pow(x, 4) + c * Math.pow(x, 3) + d * Math.pow(x, 2) + e * x + f;
 +
         return = Math.asin(Math.sin(angle) / (bulletSpeed / 8 - Math.cos(angle) / 2));
 
</pre>  
 
</pre>  
 
:Here are some results.
 
:Here are some results.
 
{| class="wikitable"
 
{| class="wikitable"
! style="font-weight: bold;" | Bullet Velocity/Type
+
! BulletSpeed/Type
! style="font-weight: bold;" | Traditional MEA
+
! Traditional
! style="font-weight: bold;" | Perfect Orbit MEA
+
! Perfect Orbit
! style="font-weight: bold;" | Brute Force MEA
+
! Brute Force
! style="font-weight: bold;" | Fast Accurate MEA
+
! Fast Accurate MEA
 +
!
 +
!
 
|-
 
|-
| style="font-weight: bold;" | 11.0
+
| 11.0
 
| 0.8143399421265254
 
| 0.8143399421265254
 
| 0.7272727272727273
 
| 0.7272727272727273
| 1.0596258856320087
+
| 0.8958173020564033
| 1.0596258725889567
+
| 0.8958173020565081
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 11.5
+
| 11.5
 
| 0.7693273435231462
 
| 0.7693273435231462
 
| 0.6956521739130435
 
| 0.6956521739130435
| 0.9683640522574986
+
| 0.8360222463105106
| 0.968363900596335
+
| 0.8360222462765713
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 12.0
+
| 12.0
 
| 0.7297276562269663
 
| 0.7297276562269663
 
| 0.6666666666666666
 
| 0.6666666666666666
| 0.894427190975601
+
| 0.7853981633891073
| 0.8944271125817973
+
| 0.7853981633902923
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 12.5
+
| 12.5
 
| 0.694498265626556
 
| 0.694498265626556
 
| 0.64
 
| 0.64
| 0.8329267300655651
+
| 0.7416704288178478
| 0.8329267278277855
+
| 0.7416704288001901
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 13.0
+
| 13.0
 
| 0.6628738236501358
 
| 0.6628738236501358
 
| 0.6153846153846154
 
| 0.6153846153846154
| 0.7807200583557125
+
| 0.703330828084537
| 0.780720043134266
+
| 0.7033308280352042
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 13.5
+
| 13.5
 
| 0.634273648122496
 
| 0.634273648122496
 
| 0.5925925925925926
 
| 0.5925925925925926
| 0.7356807837876015
+
| 0.6693206919818205
| 0.7356807492372547
+
| 0.669320691948796
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 14.0
+
| 14.0
 
| 0.6082455789102096
 
| 0.6082455789102096
 
| 0.5714285714285714
 
| 0.5714285714285714
| 0.6963106238213576
+
| 0.638865144210421
| 0.6963105997202048
+
| 0.638865144223163
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 14.5
+
| 14.5
 
| 0.5844300733415584
 
| 0.5844300733415584
 
| 0.5517241379310345
 
| 0.5517241379310345
| 0.6615185844552328
+
| 0.6113785029510655
| 0.6615185795887975
+
| 0.6113785029690175
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 15.0
+
| 15.0
 
| 0.5625362445438555
 
| 0.5625362445438555
 
| 0.5333333333333333
 
| 0.5333333333333333
| 0.6304883249909795
+
| 0.586406643219448
| 0.6304883242101953
+
| 0.5864066432158043
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 15.5
+
| 15.5
 
| 0.5423253027748484
 
| 0.5423253027748484
 
| 0.5161290322580645
 
| 0.5161290322580645
| 0.6025948617234669
+
| 0.5635900430367358
| 0.6025948511581146
+
| 0.5635900430387886
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 16.0
+
| 16.0
 
| 0.5235987755982989
 
| 0.5235987755982989
 
| 0.5
 
| 0.5
| 0.5773502691896257
+
| 0.5426391022263398
| 0.5773502519499172
+
| 0.5426391022493595
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 16.5
+
| 16.5
 
| 0.5061899196266034
 
| 0.5061899196266034
 
| 0.48484848484848486
 
| 0.48484848484848486
| 0.5543671429174404
+
| 0.5233170954861992
| 0.554367131856091
+
| 0.5233170954933015
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 17.0
+
| 17.0
 
| 0.4899573262537283
 
| 0.4899573262537283
 
| 0.47058823529411764
 
| 0.47058823529411764
| 0.5333333333085944
+
| 0.5054280633854913
| 0.5333333322391546
+
| 0.5054280633707354
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 17.5
+
| 17.5
 
| 0.47478007356550933
 
| 0.47478007356550933
 
| 0.45714285714285713
 
| 0.45714285714285713
| 0.513994052961485
+
| 0.4888080038530859
| 0.5139940493814433
+
| 0.48880800383339884
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 18.0
+
| 18.0
 
| 0.4605539916813224
 
| 0.4605539916813224
 
| 0.4444444444444444
 
| 0.4444444444444444
| 0.49613893835306566
+
| 0.47331833170002513
| 0.4961389212446966
+
| 0.4733183317049672
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 18.5
+
| 18.5
 
| 0.44718874522671376
 
| 0.44718874522671376
 
| 0.43243243243243246
 
| 0.43243243243243246
| 0.47959251946407533
+
| 0.45884093498067674
| 0.47959250502886874
+
| 0.4588409349816298
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 19.0
+
| 19.0
 
| 0.43460552560736715
 
| 0.43460552560736715
 
| 0.42105263157894735
 
| 0.42105263157894735
| 0.4642070825481933
+
| 0.4452743791524153
| 0.46420708019143475
+
| 0.44527437914716245
 +
|
 +
|
 
|-
 
|-
| style="font-weight: bold;" | 19.5
+
| 19.5
 
| 0.42273520519034663
 
| 0.42273520519034663
 
| 0.41025641025641024
 
| 0.41025641025641024
| 0.44985724569216
+
| 0.43253095218979704
| 0.4498570266324053
+
| 0.43253095218741416
 
|}
 
|}
  
:As you can see it gives higher results than ''Perfect orbit'' and very accurate according to the results.
+
:As you can see it gives higher results than ''Perfect orbit'' and ''Traditional MEA'' and very accurate according to the results.
  
 
;Pros
 
;Pros

Revision as of 18:52, 24 September 2017

Thanks Xor. I found a bug with the orbital one which gave 2 times more advancing velocity and fixed the calculation.
After brute force MEA calculations, I realised that moving perpendicular wasn't the best option to maximise the MEA. I found a function with polynomial regression which works very well.
Old Brute Force MEA
        double highestMea;
        for (int a = 0; a < 360000; a++) { // For higher accuracy. Normal value is 360.
            double angle = Math.toRadians(a / 1000.0);
            double mea = Math.asin(Math.sin(angle) / (bulletSpeed / 8 - Math.cos(angle) / 2));
            if (mea > highestMea) {
                highestMea = mea;
            }
        }
        return highestMea;
This function is slow because of many iterations.
Fast Accurate MEA
By using WolframAlpha and Polynomial Regression, I found a function which gives very close results to the Brute Force MEA.
        double x = bulletSpeed;
        double a = 4.626248824E-7;
        double b = -4.203721619E-5;
        double c = 1.571662957E-3;
        double d = -3.085855208E-2;
        double e = 3.337262571E-1;
        double f = -2.893934846E-1;
        double angle = a * Math.pow(x, 5) + b * Math.pow(x, 4) + c * Math.pow(x, 3) + d * Math.pow(x, 2) + e * x + f;
        return = Math.asin(Math.sin(angle) / (bulletSpeed / 8 - Math.cos(angle) / 2));
Here are some results.
BulletSpeed/Type Traditional Perfect Orbit Brute Force Fast Accurate MEA
11.0 0.8143399421265254 0.7272727272727273 0.8958173020564033 0.8958173020565081
11.5 0.7693273435231462 0.6956521739130435 0.8360222463105106 0.8360222462765713
12.0 0.7297276562269663 0.6666666666666666 0.7853981633891073 0.7853981633902923
12.5 0.694498265626556 0.64 0.7416704288178478 0.7416704288001901
13.0 0.6628738236501358 0.6153846153846154 0.703330828084537 0.7033308280352042
13.5 0.634273648122496 0.5925925925925926 0.6693206919818205 0.669320691948796
14.0 0.6082455789102096 0.5714285714285714 0.638865144210421 0.638865144223163
14.5 0.5844300733415584 0.5517241379310345 0.6113785029510655 0.6113785029690175
15.0 0.5625362445438555 0.5333333333333333 0.586406643219448 0.5864066432158043
15.5 0.5423253027748484 0.5161290322580645 0.5635900430367358 0.5635900430387886
16.0 0.5235987755982989 0.5 0.5426391022263398 0.5426391022493595
16.5 0.5061899196266034 0.48484848484848486 0.5233170954861992 0.5233170954933015
17.0 0.4899573262537283 0.47058823529411764 0.5054280633854913 0.5054280633707354
17.5 0.47478007356550933 0.45714285714285713 0.4888080038530859 0.48880800383339884
18.0 0.4605539916813224 0.4444444444444444 0.47331833170002513 0.4733183317049672
18.5 0.44718874522671376 0.43243243243243246 0.45884093498067674 0.4588409349816298
19.0 0.43460552560736715 0.42105263157894735 0.4452743791524153 0.44527437914716245
19.5 0.42273520519034663 0.41025641025641024 0.43253095218979704 0.43253095218741416
As you can see it gives higher results than Perfect orbit and Traditional MEA and very accurate according to the results.
Pros
  • It is fast.
  • It is accurate.
  • You can also get the best lateral/advancing velocity because it calculates the retreat angle first.
Cons
  • Robot velocity is fixed to 8.
  • Hard to interpret or improve.
  • The max value you can enter is 19.7 and the min value you can enter is 11.