パッケージ mechanics.optimization

クラス IterativeSimulator

java.lang.Object
mechanics.optimization.IterativeSimulator

public class IterativeSimulator extends Object
Provides two independent iterative optimization loops:
  1. optimizeER(java.util.function.Function<java.util.Map<java.lang.String, java.lang.Double>, simulation.CombatSimulator>, java.util.function.Consumer<simulation.CombatSimulator>, int) – converges on the minimum Energy Recharge needed for each character to burst on rotation. It re-runs the full rotation simulation each pass, reads actual energy deltas via EnergyAnalyzer, and updates the per-character ER targets until consecutive passes agree within 1%.
  2. optimizeJointPartyCrit(java.util.function.Function<java.util.Map<java.lang.String, java.util.Map<model.type.StatType, java.lang.Integer>>, simulation.CombatSimulator>, java.util.function.Consumer<simulation.CombatSimulator>, java.util.Map<java.lang.String, java.util.List<model.type.StatType>>, java.util.Map<java.lang.String, java.lang.Integer>) – a coordinated hill-climbing loop over all DPS characters. ER rolls are pre-reserved (excluded from the hill-climbing budget) so the optimizer cannot trade away ER to gain more crit. Each character is optimized in turn while the rest of the party holds their current best rolls; the outer loop repeats until no further improvement is found.
  • コンストラクタの詳細

    • IterativeSimulator

      public IterativeSimulator()
  • メソッドの詳細

    • optimizeER

      public static Map<String,Double> optimizeER(Function<Map<String,Double>,CombatSimulator> simFactory, Consumer<CombatSimulator> rotationRunner, int maxIterations)
      Runs an iterative simulation to converge on Energy Recharge requirements.

      Each iteration:

      1. Builds a fresh CombatSimulator with the current ER targets via simFactory.
      2. Executes the full rotation via rotationRunner.
      3. Derives the next ER targets from actual energy data using EnergyAnalyzer.calculateERRequirements(simulation.CombatSimulator).
      4. Stops early when every character's ER target changes by less than 1% (absolute) between two consecutive iterations.
      パラメータ:
      simFactory - factory that accepts a map of charName -> minER and returns a configured simulator
      rotationRunner - consumer that drives a complete rotation on the simulator
      maxIterations - upper bound on iterations before returning unconverged
      戻り値:
      converged (or best-so-far) map of charName -> required ER
    • optimizeJointPartyCrit

      public static Map<String,Map<StatType,Integer>> optimizeJointPartyCrit(Function<Map<String,Map<StatType,Integer>>,CombatSimulator> simFactory, Consumer<CombatSimulator> rotationRunner, Map<String,List<StatType>> targetCharsMap, Map<String,Integer> erRollsPerChar)
      Optimizes DPS substat distribution for multiple characters simultaneously.

      ER pre-reservation: The liquid roll budget for each character is 20 - erRollsPerChar[charName]. ER rolls are merged back into the full roll map before every simulation call so the resulting artifact stats are always correct, but the hill-climber never considers ER as a swap candidate. Characters absent from erRollsPerChar retain the full 20-roll budget.

      Hill-climbing strategy: Characters are optimized one at a time in the order defined by targetCharsMap. While one character is being optimized, all others use their current best rolls. The outer loop repeats up to 3 times until a full pass produces no change across any character.

      パラメータ:
      simFactory - factory that accepts the full party roll map and returns a configured simulator
      rotationRunner - consumer that drives a complete rotation on the simulator
      targetCharsMap - map of charName -> stats to optimize defining which characters participate and which substats to vary
      erRollsPerChar - pre-computed liquid ER roll counts per character; characters absent from this map receive the full 20-roll budget; may be null
      戻り値:
      map of charName -> optimal liquid roll distribution (ER rolls are NOT included here; merge them separately for the final simulation)
    • optimizeSubstatsNDim

      public static Map<StatType,Integer> optimizeSubstatsNDim(Function<Map<StatType,Integer>,CombatSimulator> simFactory, Consumer<CombatSimulator> rotationRunner, String charName, List<StatType> statsToOptimize, int totalRolls)
      Finds the optimal liquid roll distribution for a single character using balanced initialization followed by single-roll hill-climbing swaps.

      Algorithm:

      1. Initialization – rolls are spread as evenly as possible across all stats in statsToOptimize (remainder goes to the first stats in list order).
      2. Hill climbing – every possible (source, target) pair is evaluated by moving one roll from source to target. The best-improving swap is committed, and the loop repeats until no swap improves DPS or maxSteps (100) is reached. Each stat is capped at 10 rolls.
      パラメータ:
      simFactory - factory that accepts a roll map and returns a configured simulator; receives only the DPS rolls (ER excluded)
      rotationRunner - consumer that drives a complete rotation on the simulator
      charName - name of the character being optimized (for logging)
      statsToOptimize - the substats the hill-climber is allowed to vary
      totalRolls - liquid roll budget available (20 minus pre-reserved ER rolls)
      戻り値:
      optimal roll distribution across statsToOptimize