@tscircuit/capacity-autorouter 0.0.86 → 0.0.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1581,6 +1581,8 @@ declare class CapacityPathingMultiSectionSolver extends BaseSolver {
1581
1581
  endingScore: number;
1582
1582
  endingHighestNodePf: number;
1583
1583
  }>;
1584
+ cacheHits: number;
1585
+ cacheMisses: number;
1584
1586
  };
1585
1587
  OPTIMIZATION_SCHEDULE: {
1586
1588
  MAX_ATTEMPTS_PER_NODE: number;
package/dist/index.js CHANGED
@@ -13522,6 +13522,7 @@ var CachedHyperCapacityPathingSingleSectionSolver = class extends HyperCapacityP
13522
13522
  });
13523
13523
  const terminals = {};
13524
13524
  const cacheSpaceToRealConnectionId = /* @__PURE__ */ new Map();
13525
+ const connectionPairMap = /* @__PURE__ */ new Map();
13525
13526
  for (const conn of this.constructorParams.sectionConnectionTerminals) {
13526
13527
  const cacheStartNodeId = realToCacheSpaceNodeIdMap.get(conn.startNodeId);
13527
13528
  const cacheEndNodeId = realToCacheSpaceNodeIdMap.get(conn.endNodeId);
@@ -13529,7 +13530,10 @@ var CachedHyperCapacityPathingSingleSectionSolver = class extends HyperCapacityP
13529
13530
  cacheStartNodeId,
13530
13531
  cacheEndNodeId
13531
13532
  ].sort();
13532
- const cacheSpaceConnectionId = `${sortedStartId}->${sortedEndId}`;
13533
+ const pairKey = `${sortedStartId}->${sortedEndId}`;
13534
+ const pairIndex = connectionPairMap.get(pairKey) ?? 0;
13535
+ connectionPairMap.set(pairKey, pairIndex + 1);
13536
+ const cacheSpaceConnectionId = `${sortedStartId}->${sortedEndId}::${pairIndex}`;
13533
13537
  terminals[cacheSpaceConnectionId] = {
13534
13538
  start: sortedStartId,
13535
13539
  end: sortedEndId
@@ -13796,9 +13800,11 @@ var CapacityPathingMultiSectionSolver = class extends BaseSolver {
13796
13800
  endingHighestNodePf: 0,
13797
13801
  sectionAttempts: 0
13798
13802
  })
13799
- )
13803
+ ),
13804
+ cacheHits: 0,
13805
+ cacheMisses: 0
13800
13806
  };
13801
- this.MAX_ITERATIONS = 1e7;
13807
+ this.MAX_ITERATIONS = params.MAX_ITERATIONS ?? 1e7;
13802
13808
  this.cacheProvider = params.cacheProvider;
13803
13809
  this.simpleRouteJson = params.simpleRouteJson;
13804
13810
  this.nodes = params.nodes;
@@ -13943,6 +13949,13 @@ var CapacityPathingMultiSectionSolver = class extends BaseSolver {
13943
13949
  );
13944
13950
  }
13945
13951
  this.sectionSolver.step();
13952
+ if (this.sectionSolver.failed || this.sectionSolver.solved) {
13953
+ if (this.sectionSolver.cacheHit) {
13954
+ this.stats.cacheHits++;
13955
+ } else {
13956
+ this.stats.cacheMisses++;
13957
+ }
13958
+ }
13946
13959
  if (this.sectionSolver.failed) {
13947
13960
  console.warn(
13948
13961
  `Section solver failed for node ${this.currentSection.centerNodeId}. Error: ${this.sectionSolver.error}`