User:Dsekercioglu/MEA

From Robowiki
< User:Dsekercioglu
Revision as of 10:48, 24 September 2017 by Dsekercioglu (talk | contribs) (Little fix)
Jump to navigation Jump to search
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.
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.sin(angle) / (bulletSpeed / 8 - Math.cos(angle));
            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 = -3.508129323E-5;
        double b = 2.460363294E-3;
        double c = -6.666318894E-2;
        double d = 8.545020365E-1;
        double e = -3.337830707;
        double angle = a * Math.pow(x, 4) + b * Math.pow(x, 3) + c * Math.pow(x, 2) + d * x + e;
        return Math.sin(angle) / (bulletSpeed / 8 - Math.cos(angle));
Here are some results.
Bullet Velocity/Type Traditional MEA Perfect Orbit MEA Brute Force MEA Fast Accurate MEA
11.0 0.8143399421265254 0.7272727272727273 1.0596258856320087 1.0596258725889567
11.5 0.7693273435231462 0.6956521739130435 0.9683640522574986 0.968363900596335
12.0 0.7297276562269663 0.6666666666666666 0.894427190975601 0.8944271125817973
12.5 0.694498265626556 0.64 0.8329267300655651 0.8329267278277855
13.0 0.6628738236501358 0.6153846153846154 0.7807200583557125 0.780720043134266
13.5 0.634273648122496 0.5925925925925926 0.7356807837876015 0.7356807492372547
14.0 0.6082455789102096 0.5714285714285714 0.6963106238213576 0.6963105997202048
14.5 0.5844300733415584 0.5517241379310345 0.6615185844552328 0.6615185795887975
15.0 0.5625362445438555 0.5333333333333333 0.6304883249909795 0.6304883242101953
15.5 0.5423253027748484 0.5161290322580645 0.6025948617234669 0.6025948511581146
16.0 0.5235987755982989 0.5 0.5773502691896257 0.5773502519499172
16.5 0.5061899196266034 0.48484848484848486 0.5543671429174404 0.554367131856091
17.0 0.4899573262537283 0.47058823529411764 0.5333333333085944 0.5333333322391546
17.5 0.47478007356550933 0.45714285714285713 0.513994052961485 0.5139940493814433
18.0 0.4605539916813224 0.4444444444444444 0.49613893835306566 0.4961389212446966
18.5 0.44718874522671376 0.43243243243243246 0.47959251946407533 0.47959250502886874
19.0 0.43460552560736715 0.42105263157894735 0.4642070825481933 0.46420708019143475
19.5 0.42273520519034663 0.41025641025641024 0.44985724569216 0.4498570266324053
As you can see it gives higher results than Perfect orbit 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.