Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAH v3 #689

Merged
merged 6 commits into from
Dec 1, 2016
Merged

RAH v3 #689

merged 6 commits into from
Dec 1, 2016

Conversation

MrNukealizer
Copy link
Contributor

New Reactive Armor Hardener code that should work correctly and give an accurate result. Based heavily on @Ebag333's file.
Refer to issue #680 for details.

New Reactive Armor Hardener code that should work correctly.
@Ebag333
Copy link
Contributor

Ebag333 commented Jul 29, 2016

Well, it doesn't "correctly" handle uniform damage types.

(Correctly in quotes because uniform damage would cause the RAH to adjust, but we need to handle it as a "default" scenario.) For uniform damage type, it should't be in the loop at all.

You also adjust the damage down twice by resists, once initially and once on your first loop, before the RAH adjusts (notice Damage taken this cycle has been adjusted down again):

2016-07-29 09:14:00,477 eos.effects.adaptivearmorhardener ERROR    Damage Pattern: 0.000000/26.400000/17.600000/26.400000
2016-07-29 09:14:00,477 eos.effects.adaptivearmorhardener ERROR    Original Armor Resists: 0.203507/0.227674/0.225000/0.120000
2016-07-29 09:14:00,479 eos.effects.adaptivearmorhardener ERROR    Damage Adjusted for Armor Resists: 0.000000/6.010585/3.960000/3.168000
2016-07-29 09:14:00,479 eos.effects.adaptivearmorhardener ERROR    Starting cycle %d.
2016-07-29 09:14:00,479 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 0.000000/5.108997/3.366000/2.692800
2016-07-29 09:14:00,480 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.910000/0.790000/0.790000/0.910000
# The strange order is to emulate the ingame sorting when different types have taken the same amount of damage.

Maybe @ccplarrikin can confirm/deny this sorting order. We currently don't cover it at all, but it's a pretty deep edge case unless someone goes hunting for it. It's much more of an issue with a cycling RAH vs a static one as it will be far more likely to hit a "tie" scenario.

The other issue with this is responsiveness. I haven't done profiling on this, but it's adding a significant amount of time to the process.

It's made worse when initially opening a ship, as the effects files are run through three times instead of once. Add on the fact that effect files are hit for each booster, and worst case scenario it appears to be adding a several second delay.

@MrNukealizer
Copy link
Contributor Author

In what situations is it not correctly handling uniform damage? I did a bunch of tests shooting various ships with a Gecko and it gives the correct results for all them. I don't understand your "default scenario" idea.

The damage is adjusted multiple times. It first gets adjusted for the ship's resistances with all the other mods except the RAH, then each cycle it multiples that by the RAH profile to get the actual incoming damage (ignoring stacking penalties with Damage Controls).

As for the several second delay, something seems wrong there. In the log snippet you showed it says ERROR instead of DEBUG and %d instead of the cycle number. Did you tweak the debug logging? That's probably the performance issue, and in hindsight I should've disabled the logging code for performance reasons.
If the logging isn't the issue, there's something else going on because I saw no difference in responsiveness between ships with a RAH and those without.

@Ebag333
Copy link
Contributor

Ebag333 commented Jul 29, 2016

In what situations is it not correctly handling uniform damage? I did a bunch of tests shooting various ships with a Gecko and it gives the correct results for all them. I don't understand your "default scenario" idea.

In the scenario of I don't want the RAH to adjust at all, I want to see what it's like at 15/15/15/15.

Basically, if the damage profile is 25/25/25/25 we need to reset it back. Uniform damage doesn't necessarily mean we want the RAH to adjust, it could mean that we want to see what it looks like before it adjusts. We have to be able to handle that scenario, and traditionally we've done it with the uniform profile.

So you are absolutely correct that the RAH will handle uniform resists. The problem is that we want an exception to the rule, and for it to not handle it.

We could look at putting some sort of toggle switch on it (like we do with reload timers), but that adds a lot of complexity.

The damage is adjusted multiple times. It first gets adjusted for the ship's resistances with all the other mods except the RAH, then each cycle it multiples that by the RAH profile to get the actual incoming damage (ignoring stacking penalties with Damage Controls).

And that's part of the problem. Unless you recreate the entire fitting engine (which I don't think you can do in just a few lines), it's not going to handle stacking properly.

As for the several second delay, something seems wrong there. In the log snippet you showed it says ERROR instead of DEBUG and %d instead of the cycle number. Did you tweak the debug logging?

I switched from debug to error because it was faster to do that than change my command line. :)
(That was the only change I made.)

As for %d instead of the cycle number:

logger.error("Starting cycle %d.")

You don't have a number to insert.

That's probably the performance issue, and in hindsight I should've disabled the logging code for performance reasons.
If the logging isn't the issue, there's something else going on because I saw no difference in responsiveness between ships with a RAH and those without.

It's not the logging. I mean, sure, it doesn't help any, but it's not the primary cause.

As an example, fit that has a RAH with 3 boosting ships each with a RAH. Pyfa is freshly launched, so no extra lag from have 20 fit windows open.

v2

2016-07-29 15:32:19,734
<snip>
2016-07-29 15:32:20,947

v3

2016-07-29 15:29:46,910
<snip>
2016-07-29 15:29:48,151

Since both have logging enabled (though, granted, v3 has a couple more lines than v2), that's not much of a factor.

But yeah, the looping adds about 2 seconds to the initial fit open time. Subsequent fit opens are better, though still delayed. Since Pyfa already has performance issues, this is a pretty big hit.

It's a bit of an edge case (not too many people will have 4 fits all using RAH), but it won't be unheard of in armor fleets either.

@blitzmann
Copy link
Collaborator

blitzmann commented Jul 29, 2016

So you are absolutely correct that the RAH will handle uniform resists. The problem is that we want an exception to the rule, and for it to not handle it.

This makes sense as there really isn't anything in the game that does complete omni damage. I think users who use a uniform damage profile will want to see an average scenario. However, it's technically an incorrect calculation - we are knowingly introducing a bug that inevitably will be reported by someone. It may be possible to have some sort of setting (such as factor reload time into calculations) where we can have the RAH adjust or not adjust. Thoughts?

Otherwise this is great stuff. Still haven't had a chance to dig into it yet though

edit: I got to the point quoted and left a comment. Literally the next line down:

We could look at putting some sort of toggle switch on it (like we do with reload timers), but that adds a lot of complexity.

🤦 However I don't think it'll add a lot of complexity. It's a setting in service.fit, and can be access via the fit object in the effect. The only :effort: would come from adding it to the context menu.

@MrNukealizer
Copy link
Contributor Author

As for %d instead of the cycle number:
logger.error("Starting cycle %d.")
You don't have a number to insert.

Oops, I accidentally deleted the end of that line when deleting the next line.

After this discussion it's apparent I need to fix a couple things. I'll close this pull request and put in a new one once they're fixed.

@blitzmann
Copy link
Collaborator

You don't have to close this one. Just add commits to the branch you used to create this pull request and push :D

@MrNukealizer
Copy link
Contributor Author

MrNukealizer commented Jul 30, 2016

Ok, I commented out the logging and made a couple minor tweaks. On my system (famous last words) the RAH calculations reliably run in a millisecond, so there shouldn't be any noticeable performance issues.

Here's the log of loading a fit with a RAH, three different boosters with their own RAHs, and two projected fits with RAHs:

2016-07-29 22:46:29,450 eos.saveddata.fit        DEBUG    Starting fit calculation on: Fit(ID=396, ship=Nestor, name=Nestor fit) at 0x9f23af0, withBoosters: True
2016-07-29 22:46:29,451 eos.saveddata.fit        DEBUG    Fleet is set, gathering gang boosts
2016-07-29 22:46:29,453 eos.saveddata.fit        DEBUG    Starting fit calculation on: Fit(ID=393, ship=Astarte, name=RAH booster) at 0x999c630, withBoosters: False
2016-07-29 22:46:29,618 eos.saveddata.fit        DEBUG    Timer - Fit: 393, RAH booster - Done with runtime: early - 165.00ms (165.00ms elapsed)
2016-07-29 22:46:29,647 eos.saveddata.fit        DEBUG    Timer - Fit: 393, RAH booster - Done with runtime: normal - 29.00ms (194.00ms elapsed)
2016-07-29 22:46:29,657 eos.saveddata.fit        DEBUG    Timer - Fit: 393, RAH booster - Done with runtime: late - 11.00ms (205.00ms elapsed)
2016-07-29 22:46:29,658 eos.saveddata.fit        DEBUG    Timer - Fit: 393, RAH booster - Done with fit calculation - 1.00ms (206.00ms elapsed)
2016-07-29 22:46:29,661 eos.saveddata.fit        DEBUG    Starting fit calculation on: Fit(ID=394, ship=Astarte, name=RAH booster copy) at 0x9e44f50, withBoosters: False
2016-07-29 22:46:29,673 eos.saveddata.fit        DEBUG    Timer - Fit: 394, RAH booster copy - Done with runtime: early - 10.00ms (10.00ms elapsed)
2016-07-29 22:46:29,686 eos.saveddata.fit        DEBUG    Timer - Fit: 394, RAH booster copy - Done with runtime: normal - 14.00ms (24.00ms elapsed)
2016-07-29 22:46:29,690 eos.saveddata.fit        DEBUG    Timer - Fit: 394, RAH booster copy - Done with runtime: late - 4.00ms (28.00ms elapsed)
2016-07-29 22:46:29,690 eos.saveddata.fit        DEBUG    Timer - Fit: 394, RAH booster copy - Done with fit calculation - 1.00ms (29.00ms elapsed)
2016-07-29 22:46:29,694 eos.saveddata.fit        DEBUG    Starting fit calculation on: Fit(ID=395, ship=Astarte, name=RAH booster copy 2) at 0x9c8f0b0, withBoosters: False
2016-07-29 22:46:29,704 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with runtime: early - 11.00ms (11.00ms elapsed)
2016-07-29 22:46:29,720 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with runtime: normal - 15.00ms (26.00ms elapsed)
2016-07-29 22:46:29,723 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with runtime: late - 3.00ms (29.00ms elapsed)
2016-07-29 22:46:29,726 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with fit calculation - 3.00ms (32.00ms elapsed)
2016-07-29 22:46:29,730 eos.saveddata.fit        DEBUG    Timer - Fit: 396, Nestor fit - Done calculating gang boosts for Fit(ID=396, ship=Nestor, name=Nestor fit) at 0x9f23af0 - 280.00ms (280.00ms elapsed)
2016-07-29 22:46:29,732 eos.saveddata.fit        DEBUG    Applying gang boosts in `early` runtime for Fit(ID=396, ship=Nestor, name=Nestor fit) at 0x9f23af0
2016-07-29 22:46:29,744 eos.saveddata.fit        DEBUG    Timer - Fit: 396, Nestor fit - Done with runtime: early - 14.00ms (294.00ms elapsed)
2016-07-29 22:46:29,746 eos.saveddata.fit        DEBUG    Applying gang boosts in `normal` runtime for Fit(ID=396, ship=Nestor, name=Nestor fit) at 0x9f23af0
2016-07-29 22:46:29,773 eos.saveddata.fit        DEBUG    Timer - Fit: 396, Nestor fit - Done with runtime: normal - 28.00ms (322.00ms elapsed)
2016-07-29 22:46:29,773 eos.saveddata.fit        DEBUG    Applying gang boosts in `late` runtime for Fit(ID=396, ship=Nestor, name=Nestor fit) at 0x9f23af0
2016-07-29 22:46:29,779 eos.saveddata.fit        DEBUG    Timer - Fit: 396, Nestor fit - Done with runtime: late - 7.00ms (329.00ms elapsed)
2016-07-29 22:46:29,780 eos.saveddata.fit        DEBUG    Starting fit calculation on: Fit(ID=374, ship=Megathron Navy Issue, name=sfda) at 0x504a990, withBoosters: True
2016-07-29 22:46:29,780 eos.saveddata.fit        DEBUG    Applying projections to target: Fit(ID=396, ship=Nestor, name=Nestor fit) at 0x9f23af0
2016-07-29 22:46:29,782 eos.saveddata.fit        DEBUG    ProjectionInfo: ProjectedFit(sourceID=374, victimID=396, amount=1, active=True) at 0x9f23050
2016-07-29 22:46:29,786 eos.saveddata.fit        DEBUG    Timer - Fit: 374, sfda - Done with runtime: early - 5.00ms (5.00ms elapsed)
2016-07-29 22:46:29,801 eos.saveddata.fit        DEBUG    Timer - Fit: 374, sfda - Done with runtime: normal - 15.00ms (20.00ms elapsed)
2016-07-29 22:46:29,802 eos.saveddata.fit        DEBUG    Timer - Fit: 374, sfda - Done with runtime: late - 2.00ms (22.00ms elapsed)
2016-07-29 22:46:29,802 eos.saveddata.fit        DEBUG    Timer - Fit: 374, sfda - Done with fit calculation - 0.00ms (22.00ms elapsed)
2016-07-29 22:46:29,803 eos.saveddata.fit        DEBUG    Starting fit calculation on: Fit(ID=391, ship=Stratios, name=RAH test) at 0x9930510, withBoosters: True
2016-07-29 22:46:29,803 eos.saveddata.fit        DEBUG    Applying projections to target: Fit(ID=396, ship=Nestor, name=Nestor fit) at 0x9f23af0
2016-07-29 22:46:29,805 eos.saveddata.fit        DEBUG    ProjectionInfo: ProjectedFit(sourceID=391, victimID=396, amount=1, active=True) at 0x9f23f50
2016-07-29 22:46:29,812 eos.saveddata.fit        DEBUG    Timer - Fit: 391, RAH test - Done with runtime: early - 8.00ms (8.00ms elapsed)
2016-07-29 22:46:29,826 eos.saveddata.fit        DEBUG    Timer - Fit: 391, RAH test - Done with runtime: normal - 15.00ms (23.00ms elapsed)
2016-07-29 22:46:29,828 eos.saveddata.fit        DEBUG    Timer - Fit: 391, RAH test - Done with runtime: late - 2.00ms (25.00ms elapsed)
2016-07-29 22:46:29,828 eos.saveddata.fit        DEBUG    Timer - Fit: 391, RAH test - Done with fit calculation - 0.00ms (25.00ms elapsed)
2016-07-29 22:46:29,890 service.fit              DEBUG    ==========recalc==========
2016-07-29 22:46:29,890 eos.saveddata.fit        DEBUG    Starting fit calculation on: Fit(ID=395, ship=Astarte, name=RAH booster copy 2) at 0x9c8f0b0, withBoosters: True
2016-07-29 22:46:29,892 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with runtime: early - 3.00ms (3.00ms elapsed)
2016-07-29 22:46:29,905 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with runtime: normal - 13.00ms (16.00ms elapsed)
2016-07-29 22:46:29,907 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with runtime: late - 2.00ms (18.00ms elapsed)
2016-07-29 22:46:29,907 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with fit calculation - 0.00ms (18.00ms elapsed)
2016-07-29 22:46:29,913 service.fit              DEBUG    ==========recalc==========
2016-07-29 22:46:29,914 eos.saveddata.fit        DEBUG    Starting fit calculation on: Fit(ID=395, ship=Astarte, name=RAH booster copy 2) at 0x9c8f0b0, withBoosters: True
2016-07-29 22:46:29,915 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with runtime: early - 2.00ms (2.00ms elapsed)
2016-07-29 22:46:29,930 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with runtime: normal - 14.00ms (16.00ms elapsed)
2016-07-29 22:46:29,931 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with runtime: late - 2.00ms (18.00ms elapsed)
2016-07-29 22:46:29,931 eos.saveddata.fit        DEBUG    Timer - Fit: 395, RAH booster copy 2 - Done with fit calculation - 0.00ms (18.00ms elapsed)

@MrNukealizer MrNukealizer reopened this Jul 30, 2016
@Ebag333
Copy link
Contributor

Ebag333 commented Jul 30, 2016

I commented out the logging

Again, it's not the logging that's the cause. The RAH is complex enough that it's well worth adding quite a bit of debug logging.

2016-07-29 23:10:09,553 eos.effects.adaptivearmorhardener ERROR    Damage Pattern: 79.200000/0.000000/8.800000/17.600000
2016-07-29 23:10:09,617 eos.effects.adaptivearmorhardener ERROR    Loop found: 11-11

It's a bit faster, but still clocks in at almost a second and a half. So improvement in the right direction.

@MrNukealizer
Copy link
Contributor Author

MrNukealizer commented Jul 30, 2016

What exactly is taking a second and a half? Is it loading a particular fit, toggling the RAH, or something else? If you use the same fit but take the RAH off the ship and any boosters/projectors, how long does it take?

Could you go in debug mode (-d in the arguments when launching) and see how long it takes to do the various steps of calculating the fit, like I pasted above?

2016-07-29 23:10:09,553 eos.effects.adaptivearmorhardener ERROR Damage Pattern: 79.200000/0.000000/8.800000/17.600000
2016-07-29 23:10:09,617 eos.effects.adaptivearmorhardener ERROR Loop found: 11-11

It's interesting that took 64ms. It would need to get 9 attributes between those lines, which seems very slow the first time (and slow in general since it's a dictionary lookup with a string key). I believe your code also needs to get the same data (or hard code things that could change in a patch...). Try putting a logging line right before the loop and one right after it. The loop part should be very fast, with the getting and setting attributes part being slowish.

As for the "Loop found: 11-11" bit, the numbers are probably wrong since I commented that out before tweaking things that affect the indices it uses.

@Ebag333
Copy link
Contributor

Ebag333 commented Jul 30, 2016

What exactly is taking a second and a half? Is it loading a particular fit, toggling the RAH, or something else? If you use the same fit but take the RAH off the ship and any boosters/projectors, how long does it take?

Initial load of a fit.

Profiling wise, I'm comparing it to the times for v2. (v1 runs slightly slower than v2, but they're both close enough to be negligible.) Code is otherwise the same (each is a branch off Pyfa-Master with only the one file changed).

I'll see about running in debug mode for additional logging, I actually want to go through and add debug logging through out the application so we can better profile/troubleshoot issues like this one.

I copy/pasted the wrong lines. The two posted above are for one run through of the RAH effect.

Here's the first to final debug line.

2016-07-29 23:10:09,553 eos.effects.adaptivearmorhardener ERROR    Damage Pattern: 79.200000/0.000000/8.800000/17.600000

2016-07-29 23:10:10,963 eos.effects.adaptivearmorhardener ERROR    Setting new resist profile: 0.460000/1.000000/1.000000/0.940000

Profiling wise, at the end of the first time the adaptivearmorhardener effect is hit there is a very odd delay:

2016-07-29 23:10:09,618 eos.effects.adaptivearmorhardener ERROR    Setting new resist profile: 0.460000/1.000000/1.000000/0.940000
2016-07-29 23:10:10,029 eos.effects.adaptivearmorhardener ERROR    Damage Pattern: 79.200000/0.000000/8.800000/17.600000

That's very nearly a half second delay right there.

Here's the full log dump if you're curious:


2016-07-29 23:10:09,553 eos.effects.adaptivearmorhardener ERROR    Damage Pattern: 79.200000/0.000000/8.800000/17.600000
2016-07-29 23:10:09,607 eos.effects.adaptivearmorhardener ERROR    Original Armor Resists: 0.179471/0.200783/0.184521/0.098411
2016-07-29 23:10:09,608 eos.effects.adaptivearmorhardener ERROR    Damage Adjusted for Armor Resists: 14.214089/0.000000/1.623782/1.732035
2016-07-29 23:10:09,608 eos.effects.adaptivearmorhardener ERROR    Starting cycle 0.
2016-07-29 23:10:09,608 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 12.081976/0.000000/1.380215/1.472229
2016-07-29 23:10:09,608 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.790000/0.910000/0.910000/0.790000
2016-07-29 23:10:09,608 eos.effects.adaptivearmorhardener ERROR    Starting cycle 1.
2016-07-29 23:10:09,608 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 11.229130/0.000000/1.477642/1.368307
2016-07-29 23:10:09,608 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.730000/0.970000/0.850000/0.850000
2016-07-29 23:10:09,608 eos.effects.adaptivearmorhardener ERROR    Starting cycle 2.
2016-07-29 23:10:09,609 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 10.376285/0.000000/1.380215/1.472229
2016-07-29 23:10:09,609 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.685000/1.000000/0.910000/0.805000
2016-07-29 23:10:09,609 eos.effects.adaptivearmorhardener ERROR    Starting cycle 3.
2016-07-29 23:10:09,611 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 9.736651/0.000000/1.477642/1.394288
2016-07-29 23:10:09,611 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.655000/1.000000/0.880000/0.865000
2016-07-29 23:10:09,611 eos.effects.adaptivearmorhardener ERROR    Starting cycle 4.
2016-07-29 23:10:09,611 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 9.310228/0.000000/1.428929/1.498210
2016-07-29 23:10:09,611 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.625000/1.000000/0.940000/0.835000
2016-07-29 23:10:09,611 eos.effects.adaptivearmorhardener ERROR    Starting cycle 5.
2016-07-29 23:10:09,611 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 8.883806/0.000000/1.526356/1.446249
2016-07-29 23:10:09,611 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.595000/1.000000/0.910000/0.895000
2016-07-29 23:10:09,612 eos.effects.adaptivearmorhardener ERROR    Starting cycle 6.
2016-07-29 23:10:09,612 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 8.457383/0.000000/1.477642/1.550171
2016-07-29 23:10:09,612 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.565000/1.000000/0.970000/0.865000
2016-07-29 23:10:09,614 eos.effects.adaptivearmorhardener ERROR    Starting cycle 7.
2016-07-29 23:10:09,614 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 8.030960/0.000000/1.575069/1.498210
2016-07-29 23:10:09,614 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.535000/1.000000/0.940000/0.925000
2016-07-29 23:10:09,614 eos.effects.adaptivearmorhardener ERROR    Starting cycle 8.
2016-07-29 23:10:09,615 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 7.604538/0.000000/1.526356/1.602132
2016-07-29 23:10:09,615 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.505000/1.000000/1.000000/0.895000
2016-07-29 23:10:09,615 eos.effects.adaptivearmorhardener ERROR    Starting cycle 9.
2016-07-29 23:10:09,615 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 7.178115/0.000000/1.623782/1.550171
2016-07-29 23:10:09,615 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.475000/1.000000/0.970000/0.955000
2016-07-29 23:10:09,615 eos.effects.adaptivearmorhardener ERROR    Starting cycle 10.
2016-07-29 23:10:09,615 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 6.751692/0.000000/1.575069/1.654093
2016-07-29 23:10:09,615 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.460000/1.000000/1.000000/0.940000
2016-07-29 23:10:09,617 eos.effects.adaptivearmorhardener ERROR    Starting cycle 11.
2016-07-29 23:10:09,617 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 6.538481/0.000000/1.623782/1.628113
2016-07-29 23:10:09,617 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.460000/1.000000/1.000000/0.940000
2016-07-29 23:10:09,617 eos.effects.adaptivearmorhardener ERROR    Loop found: 11-11
2016-07-29 23:10:09,618 eos.effects.adaptivearmorhardener ERROR    Setting new resist profile: 0.460000/1.000000/1.000000/0.940000
2016-07-29 23:10:10,029 eos.effects.adaptivearmorhardener ERROR    Damage Pattern: 79.200000/0.000000/8.800000/17.600000
2016-07-29 23:10:10,029 eos.effects.adaptivearmorhardener ERROR    Original Armor Resists: 0.179471/0.200783/0.184521/0.098411
2016-07-29 23:10:10,030 eos.effects.adaptivearmorhardener ERROR    Damage Adjusted for Armor Resists: 14.214089/0.000000/1.623782/1.732035
2016-07-29 23:10:10,030 eos.effects.adaptivearmorhardener ERROR    Starting cycle 0.
2016-07-29 23:10:10,030 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 12.081976/0.000000/1.380215/1.472229
2016-07-29 23:10:10,032 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.790000/0.910000/0.910000/0.790000
2016-07-29 23:10:10,032 eos.effects.adaptivearmorhardener ERROR    Starting cycle 1.
2016-07-29 23:10:10,032 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 11.229130/0.000000/1.477642/1.368307
2016-07-29 23:10:10,032 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.730000/0.970000/0.850000/0.850000
2016-07-29 23:10:10,032 eos.effects.adaptivearmorhardener ERROR    Starting cycle 2.
2016-07-29 23:10:10,032 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 10.376285/0.000000/1.380215/1.472229
2016-07-29 23:10:10,032 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.685000/1.000000/0.910000/0.805000
2016-07-29 23:10:10,033 eos.effects.adaptivearmorhardener ERROR    Starting cycle 3.
2016-07-29 23:10:10,033 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 9.736651/0.000000/1.477642/1.394288
2016-07-29 23:10:10,033 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.655000/1.000000/0.880000/0.865000
2016-07-29 23:10:10,033 eos.effects.adaptivearmorhardener ERROR    Starting cycle 4.
2016-07-29 23:10:10,035 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 9.310228/0.000000/1.428929/1.498210
2016-07-29 23:10:10,035 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.625000/1.000000/0.940000/0.835000
2016-07-29 23:10:10,035 eos.effects.adaptivearmorhardener ERROR    Starting cycle 5.
2016-07-29 23:10:10,036 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 8.883806/0.000000/1.526356/1.446249
2016-07-29 23:10:10,036 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.595000/1.000000/0.910000/0.895000
2016-07-29 23:10:10,036 eos.effects.adaptivearmorhardener ERROR    Starting cycle 6.
2016-07-29 23:10:10,036 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 8.457383/0.000000/1.477642/1.550171
2016-07-29 23:10:10,036 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.565000/1.000000/0.970000/0.865000
2016-07-29 23:10:10,036 eos.effects.adaptivearmorhardener ERROR    Starting cycle 7.
2016-07-29 23:10:10,038 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 8.030960/0.000000/1.575069/1.498210
2016-07-29 23:10:10,038 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.535000/1.000000/0.940000/0.925000
2016-07-29 23:10:10,039 eos.effects.adaptivearmorhardener ERROR    Starting cycle 8.
2016-07-29 23:10:10,039 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 7.604538/0.000000/1.526356/1.602132
2016-07-29 23:10:10,039 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.505000/1.000000/1.000000/0.895000
2016-07-29 23:10:10,039 eos.effects.adaptivearmorhardener ERROR    Starting cycle 9.
2016-07-29 23:10:10,039 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 7.178115/0.000000/1.623782/1.550171
2016-07-29 23:10:10,039 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.475000/1.000000/0.970000/0.955000
2016-07-29 23:10:10,039 eos.effects.adaptivearmorhardener ERROR    Starting cycle 10.
2016-07-29 23:10:10,039 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 6.751692/0.000000/1.575069/1.654093
2016-07-29 23:10:10,040 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.460000/1.000000/1.000000/0.940000
2016-07-29 23:10:10,040 eos.effects.adaptivearmorhardener ERROR    Starting cycle 11.
2016-07-29 23:10:10,042 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 6.538481/0.000000/1.623782/1.628113
2016-07-29 23:10:10,042 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.460000/1.000000/1.000000/0.940000
2016-07-29 23:10:10,042 eos.effects.adaptivearmorhardener ERROR    Loop found: 11-11
2016-07-29 23:10:10,042 eos.effects.adaptivearmorhardener ERROR    Setting new resist profile: 0.460000/1.000000/1.000000/0.940000
2016-07-29 23:10:10,950 eos.effects.adaptivearmorhardener ERROR    Damage Pattern: 79.200000/0.000000/8.800000/17.600000
2016-07-29 23:10:10,950 eos.effects.adaptivearmorhardener ERROR    Original Armor Resists: 0.179471/0.200783/0.184521/0.098411
2016-07-29 23:10:10,950 eos.effects.adaptivearmorhardener ERROR    Damage Adjusted for Armor Resists: 14.214089/0.000000/1.623782/1.732035
2016-07-29 23:10:10,950 eos.effects.adaptivearmorhardener ERROR    Starting cycle 0.
2016-07-29 23:10:10,950 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 12.081976/0.000000/1.380215/1.472229
2016-07-29 23:10:10,951 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.790000/0.910000/0.910000/0.790000
2016-07-29 23:10:10,951 eos.effects.adaptivearmorhardener ERROR    Starting cycle 1.
2016-07-29 23:10:10,951 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 11.229130/0.000000/1.477642/1.368307
2016-07-29 23:10:10,953 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.730000/0.970000/0.850000/0.850000
2016-07-29 23:10:10,953 eos.effects.adaptivearmorhardener ERROR    Starting cycle 2.
2016-07-29 23:10:10,953 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 10.376285/0.000000/1.380215/1.472229
2016-07-29 23:10:10,953 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.685000/1.000000/0.910000/0.805000
2016-07-29 23:10:10,953 eos.effects.adaptivearmorhardener ERROR    Starting cycle 3.
2016-07-29 23:10:10,953 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 9.736651/0.000000/1.477642/1.394288
2016-07-29 23:10:10,954 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.655000/1.000000/0.880000/0.865000
2016-07-29 23:10:10,954 eos.effects.adaptivearmorhardener ERROR    Starting cycle 4.
2016-07-29 23:10:10,954 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 9.310228/0.000000/1.428929/1.498210
2016-07-29 23:10:10,956 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.625000/1.000000/0.940000/0.835000
2016-07-29 23:10:10,956 eos.effects.adaptivearmorhardener ERROR    Starting cycle 5.
2016-07-29 23:10:10,956 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 8.883806/0.000000/1.526356/1.446249
2016-07-29 23:10:10,957 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.595000/1.000000/0.910000/0.895000
2016-07-29 23:10:10,957 eos.effects.adaptivearmorhardener ERROR    Starting cycle 6.
2016-07-29 23:10:10,957 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 8.457383/0.000000/1.477642/1.550171
2016-07-29 23:10:10,957 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.565000/1.000000/0.970000/0.865000
2016-07-29 23:10:10,959 eos.effects.adaptivearmorhardener ERROR    Starting cycle 7.
2016-07-29 23:10:10,959 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 8.030960/0.000000/1.575069/1.498210
2016-07-29 23:10:10,959 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.535000/1.000000/0.940000/0.925000
2016-07-29 23:10:10,960 eos.effects.adaptivearmorhardener ERROR    Starting cycle 8.
2016-07-29 23:10:10,960 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 7.604538/0.000000/1.526356/1.602132
2016-07-29 23:10:10,960 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.505000/1.000000/1.000000/0.895000
2016-07-29 23:10:10,960 eos.effects.adaptivearmorhardener ERROR    Starting cycle 9.
2016-07-29 23:10:10,960 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 7.178115/0.000000/1.623782/1.550171
2016-07-29 23:10:10,960 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.475000/1.000000/0.970000/0.955000
2016-07-29 23:10:10,960 eos.effects.adaptivearmorhardener ERROR    Starting cycle 10.
2016-07-29 23:10:10,961 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 6.751692/0.000000/1.575069/1.654093
2016-07-29 23:10:10,961 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.460000/1.000000/1.000000/0.940000
2016-07-29 23:10:10,961 eos.effects.adaptivearmorhardener ERROR    Starting cycle 11.
2016-07-29 23:10:10,963 eos.effects.adaptivearmorhardener ERROR    Damage taken this cycle: 6.538481/0.000000/1.623782/1.628113
2016-07-29 23:10:10,963 eos.effects.adaptivearmorhardener ERROR    Resistances shifted to 0.460000/1.000000/1.000000/0.940000
2016-07-29 23:10:10,963 eos.effects.adaptivearmorhardener ERROR    Loop found: 11-11
2016-07-29 23:10:10,963 eos.effects.adaptivearmorhardener ERROR    Setting new resist profile: 0.460000/1.000000/1.000000/0.940000

@MrNukealizer
Copy link
Contributor Author

MrNukealizer commented Jul 30, 2016

2016-07-29 23:10:09,553 eos.effects.adaptivearmorhardener ERROR    Damage Pattern: 79.200000/0.000000/8.800000/17.600000
2016-07-29 23:10:09,618 eos.effects.adaptivearmorhardener ERROR    Setting new resist profile: 0.460000/1.000000/1.000000/0.940000

2016-07-29 23:10:10,029 eos.effects.adaptivearmorhardener ERROR    Damage Pattern: 79.200000/0.000000/8.800000/17.600000
2016-07-29 23:10:10,042 eos.effects.adaptivearmorhardener ERROR    Setting new resist profile: 0.460000/1.000000/1.000000/0.940000

2016-07-29 23:10:10,950 eos.effects.adaptivearmorhardener ERROR    Damage Pattern: 79.200000/0.000000/8.800000/17.600000
2016-07-29 23:10:10,963 eos.effects.adaptivearmorhardener ERROR    Setting new resist profile: 0.460000/1.000000/1.000000/0.940000

So getting the attributes and simulating the RAH cycles took 64ms the first time then 13ms the next two. That's several times longer than it takes for me, but it still only accounts for 15% of the total time.
The other 85% of the time is being spent somewhere other than the body of the RAH effect, and I'm pretty sure

for i, damagePatternType in enumerate(('Em', 'Thermal', 'Kinetic', 'Explosive')):
            attr = "armor%sDamageResonance" % damagePatternType
            module.forceItemAttr(attr, average[i])
            fit.ship.multiplyItemAttr(attr, module.getModifiedItemAttr(attr), stackingPenalties=True, penaltyGroup="preMul")

isn't taking that much time. Though it does seem those lines could be made a bit more efficient.

@Ebag333
Copy link
Contributor

Ebag333 commented Jul 30, 2016

So getting the attributes and simulating the RAH cycles took 64ms the first time then 13ms the next two. That's several times longer than it takes for me, but it still only accounts for 15% of the total time.
The other 85% of the time is being spent somewhere other than the body of the RAH effect, and I'm pretty sure

for i, damagePatternType in enumerate(('Em', 'Thermal', 'Kinetic', 'Explosive')):
            attr = "armor%sDamageResonance" % damagePatternType
            module.forceItemAttr(attr, average[i])
            fit.ship.multiplyItemAttr(attr, module.getModifiedItemAttr(attr), stackingPenalties=True, penaltyGroup="preMul")

isn't taking that much time.

Which goes back to what I said to on the issue thread:

It's not the debugging. And while the code could be optimized, at the heart it's not really the code. It's the inefficient nature of Pyfa, and the extremely complex fitting engine behind it.

There's something in here that's causing it to take much longer (3-4 times as long) than the v1 or v2 versions, at least for a few particular fits. I don't have the cycles at the moment to troubleshoot what that is exactly, as it's a bigger issue than this one effect file.

A holistic effort to enable debugging across Pyfa is on my short list of things to do, and at least part of this will go away if/when CCP kills fleet boosts (since the booster also gets hit by the RAH effect code, though interestingly enough it doesn't fire for projected fits). But either of those isn't in the very near future.

@MrNukealizer
Copy link
Contributor Author

MrNukealizer commented Jul 30, 2016

That being said there's something in here that's causing it to take much longer (3-4 times as long) than the v1 or v2 versions, at least for this particular fit. I don't have the cycles at the moment to troubleshoot what that is exactly, as it's a bigger issue than this one effect file.

Assuming the v2 you referred to is what you have up on your pull request, there should be no difference except what happens between the logged cycle start and end times, and the RAH resistances when it's done. The effect body can be ruled out as the source of the long delay since it happens between the end and beginning of the log entries, so that leaves whatever code uses the RAH resistances (or something that runs the code without logging, which I doubt exists). Is there perhaps a bug in the code that displays the RAH stats in the UI?

I wish I could replicate your performance problems. I don't see any difference in timing between the three versions.

@Ebag333
Copy link
Contributor

Ebag333 commented Jul 30, 2016

Assuming the v2 you referred to is what you have up on your pull request, there should be no difference except what happens between the logged cycle start and end times, and the RAH resistances when it's done.

Correct.

The effect body can be ruled out as the source of the long delay since it happens between the end and beginning of the log entries

Well, I don't think we can rule anything out yet. Clearly it's triggered by something in the RAH code, even if it's external to that code block.

so that leaves whatever code uses the RAH resistances (or something that runs the code without logging, which I doubt exists).

Most likely it's something along the lines of the rest of the fit recalculating from the RAH changes. But without profiling, it's impossible to say what.

Is there perhaps a bug in the code that displays the RAH stats in the UI?

Bugs? What bugs? I only see features.

@MrNukealizer
Copy link
Contributor Author

MrNukealizer commented Jul 30, 2016

Most likely it's something along the lines of the rest of the fit recalculating from the RAH changes. But without profiling, it's impossible to say what.

Since the RAH code is on "late" runtime, wouldn't that all be in the line

fit.ship.multiplyItemAttr(attr, module.getModifiedItemAttr(attr), stackingPenalties=True, penaltyGroup="preMul")

which is the same between our versions?

It seems like everything else would just take the modified ship attributes after that, not caring about such differences.

@Ebag333
Copy link
Contributor

Ebag333 commented Jul 30, 2016

vOv

Your guess is as good as mine at this point.

Since the RAH code is on "late" runtime, wouldn't that all be in the line

Late refers to when it's run in the whole fitting engine cycle. There's early (start of cycle) and late (end of cycle). Initially it was early, which means that when the effects file for adaptivearmorhardener was run, you only saw base resists for the ship (which would do us no good). By switching it to a late runtime, it shows the resists post mods/skills/rigs/etc.

There is still a question if fleet boosts will affect it, since they are also a late runtime. Basically it's a toss up if anything that's flagged as late will come before or after the RAH.

This still works the same, but I think I changed a couple things that didn't look right.
@MrNukealizer
Copy link
Contributor Author

MrNukealizer commented Jul 30, 2016

Well I've confirmed with my trusty Megathron Navy Issue and Depleted Uranium test (and the other simulator) that the stacking penalties with damage controls can indeed make the result inaccurate.

It wouldn't be hard to compensate for that, but it would involve modifying eos.ModifiedAttributeDict to expose the existing stacking-penalized effects so the RAH effect could see if there's anything stacking with it. I'm not sure how wise it is to go doing such things, so I'll leave that alone.

@Ebag333
Copy link
Contributor

Ebag333 commented Jul 30, 2016

Well I've confirmed with my trusty Megathron Navy Issue and Depleted Uranium test (and the other simulator) that the stacking penalties with damage controls can indeed make the result inaccurate.

Yeah. It doesn't actually run the fitting engine to recalculate the fit.

I don't know if you can set the values and tell it to recalc without leaving the loop. I have a feeling that will recursively run through the effects.

This is probably something we just simply have to accept as something that will be off for the RAH.

@MrNukealizer
Copy link
Contributor Author

It doesn't need to rerun the whole fit calculation, it just needs to find out if there's anything else stacking with it and compensate for that part of the calculation. It's just getting that information that seems a little questionable since the most reasonable way would involve tweaking the effect manager to expose more information that doesn't really have use except in this case.

@Ebag333
Copy link
Contributor

Ebag333 commented Jul 31, 2016

You are assuming that there is nothing else that changes it. This may or may not be true currently, and definitely could change as CCP adds modules/effects.

There's not much we can do about it though, kicking off an entire refit calc would be a brutal force method, but I don't see another way to guarantee that there's no stacking issue or other modules/effects coming into play.

@MrNukealizer
Copy link
Contributor Author

Yep. Just looking at solutions to current issues, and this one is quite doable but starting to get a bit extreme for what it does.

@blitzmann
Copy link
Collaborator

@MrNukealizer:

Well I've confirmed with my trusty Megathron Navy Issue and Depleted Uranium test (and the other simulator) that the stacking penalties with damage controls can indeed make the result inaccurate.

It wouldn't be hard to compensate for that, but it would involve modifying eos.ModifiedAttributeDict to expose the existing stacking-penalized effects so the RAH effect could see if there's anything stacking with it. I'm not sure how wise it is to go doing such things, so I'll leave that alone.

Can I get a summary of the problem here and your ideas on fixing it? As I understand it, we have an issue with stacking with damage control?

@MrNukealizer
Copy link
Contributor Author

MrNukealizer commented Aug 7, 2016

Can I get a summary of the problem here and your ideas on fixing it? As I understand it, we have an issue with stacking with damage control?

The problem is that when a ship has a damage control and an RAH the resistances in the RAH cycle simulation are a bit off due to not accounting for stacking penalties. In some cases that changes the outcome.
For example, when shooting this:

[Megathron Navy Issue, Target]

Reactive Armor Hardener
Armor Thermal Hardener II
Armor Thermal Hardener II
Armor Kinetic Hardener II
Armor Explosive Hardener II
Prototype Armor Explosive Hardener I
Prototype Armor Explosive Hardener I

Large Anti-Thermal Pump II
Large Anti-EM Pump I
Large Anti-EM Pump I

with Depleted Uranium ammo, the RAH cycles between 0/0/34.5/25.5, 0/3/37.5/19.5, 0/0/39/21, and 0/3/33/24. Add a DC2 and it stops at 0/0/34.5/25.5 because the stacking penalties make the explosive resistance slightly lower relative to thermal. That results in the RAH profile being 0/0/34.5/25.5 instead of effectively 0/1.5/36/22.5. It's a tiny difference on that fit, but on others it could potentially mean the difference between say, stopping at 0/30/30/0 or going to 0/48/9/3.

The easiest and most efficient way to fix it would be to check if the ship has a damage control (or for forward compatibility, anything in the same penalty group) and account for the varying stacking penalties in each cycle of the loop.
The simplest way to achieve that would be to modify eos.ModifiedAttributeDict to allow querying the list of existing stacking-penalized multipliers on a ship attribute, basically tbl on line 319 of eos\modifiedAttributeDict.py.

Seeing as eos is apparently a separate project and such an ability would be of limited use, I'm not sure how reasonable that would be to do.

@blitzmann
Copy link
Collaborator

blitzmann commented Aug 8, 2016

Seeing as eos is apparently a separate project and such an ability would be of limited use, I'm not sure how reasonable that would be to do.

It's not really a separate project. It used to be, but then it was merged into pyfa proper years ago. There's another Eos repo that Kadesh works on every now and then that is a completely new fitting engine that everyone gets confused with the current eos.

So basically we have the reactive armor hardener stacking with damage control and we don't want that... In that case (and I haven't tried this), couldn't we just specify a special-case stacking group for the RAH? Right now it's set as preMul, which is the same group as the damage control. IIRC, this it just the key to a dictionary of stacking penalties, and supplying a value unique to RAH should stick it into it's own penalty group.

If that doesn't work, then feel free to add the changes to need to in modifiedAttributesDict.py and commit - I can take a look over it and make sure it's sound. :)

EDIT: penalty group is found on this line: https://github.com/pyfa-org/Pyfa/pull/689/files#diff-189776af73b44511f6de68f6b32214faR109 Changing it to rah might work. Technically not the correct way to do it as it's not an "EVE" penalty group, but this module is already a special snowflake, might as well go balls out with the accommodations :D

@Ebag333
Copy link
Contributor

Ebag333 commented Aug 8, 2016

So basically we have the reactive armor hardener stacking with damage control and we don't want that... In that case (and I haven't tried this), couldn't we just specify a special-case stacking group for the RAH?

No. We do want it to stack. The problem is that we we need to recalculate the stacking penalty every loop, which we don't do now. The easiest solution would be to set a global variable to flag that we're inside the adaptivearmorhardener and skip it so we don't get in an infinite loop, and fully recalculate the fit each loop. This would be what EVE does essentially, but EVE can do it every 5 seconds while we're trying to do it instantly.

Perhaps a further wrinkle is that CCP is adding more modules in that line. They added a selectable damage DCU, and a DCU that sets resists to 99%.

So who knows what else that will impact.

@Ebag333 Ebag333 mentioned this pull request Sep 15, 2016
@blitzmann
Copy link
Collaborator

@MrNukealizer, @Ebag333

k. Let me begin by stating congrats to both of you for having contributed some very good data and discussion on this topic. Hopefully anyone who does a google search for RAH Mechanics will land on this data.

After reading and re-reading all the discussions regarding the RAH and code review, these are the conclusions I have come up with:

  • Both contributions improve on the current implementation
  • Both handle 1 and 2 resist damage patterns in much the same way
  • Even when they differ, both achieve results that are very similar (except maybe in a few minor edge cases)

That being said, I've decided to merge this PR. It was pretty difficult to decide as they are both good solutions to a complex problem. It really came down to two things for me (keeping in mind this is a simulation and thus accuracy is never going to be guaranteed): the resist loop, and (to a much lesser extent) performance.

  • The issue on how to handle a resist loop. Neither solution is more correct than the other; @Ebag333's method is creative, and @MrNukealizer is straightforward. They both do what they need to do in different ways and get to similar results. There's points that I like about each and points that I dislike about each. The both (usualy) reach the same conclusion within a couple of percentage points. For now, though, I'm going to apply the KISS principle and keep things simple and straightforward.
  • In my testing, I've found v3 to be an order of magnitude faster than v4 in most situations. Granted, this is comparing 0.02ms to 0.20ms, so it's not too much of a deciding factor.

One difference between the two is how to handle Uniform damage. I tend to lean towards @Ebag333's method of ignoring it as we might want to show what it's like at it's unmodified default, but I can also see the other side in that we might want to know how it would handle IRL... I keep flipping between which route to go. For now, I think it's fine to leave it as-is and maybe tweak it if needs to be (like, we get a lot of folks who are expecting it a certain way).

And with that, I hope to put RAH stuff behind me xD

@blitzmann blitzmann merged commit b76e8df into pyfa-org:master Dec 1, 2016
@MrNukealizer MrNukealizer deleted the RAH-v3 branch December 3, 2016 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants