Cap sim now avoids optimization when running for cap graph request
This commit is contained in:
@@ -46,6 +46,10 @@ class CapSimulator:
|
||||
self.saved_changes = ()
|
||||
self.saved_changes_internal = None
|
||||
|
||||
# Reports if sim was stopped due to detecting stability early
|
||||
self.optimize_repeats = True
|
||||
self.result_optimized_repeats = None
|
||||
|
||||
def scale_activation(self, duration, capNeed):
|
||||
for res in self.scale_resolutions:
|
||||
mod = duration % res
|
||||
@@ -73,6 +77,7 @@ class CapSimulator:
|
||||
"""Reset the simulator state"""
|
||||
self.state = []
|
||||
self.saved_changes_internal = {}
|
||||
self.result_optimized_repeats = False
|
||||
mods = {}
|
||||
period = 1
|
||||
disable_period = False
|
||||
@@ -175,7 +180,8 @@ class CapSimulator:
|
||||
# history is repeating itself, so if we have more cap now than last
|
||||
# time this happened, it is a stable setup.
|
||||
awaitingInjectorsCounterNow = Counter(awaitingInjectors)
|
||||
if cap >= cap_wrap and awaitingInjectorsCounterNow == awaitingInjectorsCounterWrap:
|
||||
if self.optimize_repeats and cap >= cap_wrap and awaitingInjectorsCounterNow == awaitingInjectorsCounterWrap:
|
||||
self.result_optimized_repeats = True
|
||||
break
|
||||
cap_wrap = round(cap, stability_precision)
|
||||
awaitingInjectorsCounterWrap = awaitingInjectorsCounterNow
|
||||
|
||||
@@ -1284,12 +1284,16 @@ class Fit:
|
||||
|
||||
def getCapSimData(self, startingCap):
|
||||
if startingCap not in self.__savedCapSimData:
|
||||
self.__runCapSim(startingCap=startingCap)
|
||||
self.__runCapSim(startingCap=startingCap, tMax=3600, optimizeRepeats=False)
|
||||
return self.__savedCapSimData[startingCap]
|
||||
|
||||
def __runCapSim(self, drains=None, startingCap=None):
|
||||
def __runCapSim(self, drains=None, startingCap=None, tMax=None, optimizeRepeats=True):
|
||||
if drains is None:
|
||||
drains, nil, nil = self.__generateDrain()
|
||||
if tMax is None:
|
||||
tMax = 6 * 60 * 60 * 1000
|
||||
else:
|
||||
tMax *= 1000
|
||||
sim = capSim.CapSimulator()
|
||||
sim.init(drains)
|
||||
sim.capacitorCapacity = self.ship.getModifiedItemAttr("capacitorCapacity")
|
||||
@@ -1297,10 +1301,13 @@ class Fit:
|
||||
sim.startingCapacity = startingCap = self.ship.getModifiedItemAttr("capacitorCapacity") if startingCap is None else startingCap
|
||||
sim.stagger = True
|
||||
sim.scale = False
|
||||
sim.t_max = 6 * 60 * 60 * 1000
|
||||
sim.t_max = tMax
|
||||
sim.reload = self.factorReload
|
||||
sim.optimize_repeats = optimizeRepeats
|
||||
sim.run()
|
||||
self.__savedCapSimData[startingCap] = sim.saved_changes
|
||||
# We do not want to store partial results
|
||||
if not sim.result_optimized_repeats:
|
||||
self.__savedCapSimData[startingCap] = sim.saved_changes
|
||||
return sim
|
||||
|
||||
def getRemoteReps(self, spoolOptions=None):
|
||||
|
||||
Reference in New Issue
Block a user