--- "/mnt/user-data/uploads/PixelstoMotors/\343\203\207\343\202\270\343\202\277\343\203\253\343\203\204\343\202\244\343\203\263\345\255\246\347\277\222R2R2R/\343\202\265\343\203\274\343\203\223\343\202\271\343\203\255\343\203\234\343\203\203\343\203\210\345\260\216\345\205\245\343\202\267\343\203\237\343\203\245\343\203\254\343\203\274\343\202\267\343\203\247\343\203\263/simulation/v2_2/haizen_sim.py"	2026-10-21 21:40:46.999091896 +0900
+++ v2_3/haizen_sim.py	2026-10-21 23:01:47.643380827 +0900
@@ -1,8 +1,15 @@
 """
-サービスロボット導入シミュレーション #1 配膳ロボット（試作 v2.2）
+サービスロボット導入シミュレーション #1 配膳ロボット（試作 v2.3）
 
 飲食店のピーク時間を SimPy で再現する。
 
+図面のある店（v2.3）
+  標準ファミレスの中に、店の形（図面）から作った店を6つ足した（store が fam_p0〜fam_p5）。
+  卓の数と、卓ごとの厨房（料理の受け渡し口）から卓までの距離は店の形から取る（layouts/ の *_analysis.json。
+  正は p2m-site の public/sim/layouts/）。来た組には、卓ごとの距離の中から1つを選んで使う。
+  来客のペースとスタッフの人数は、標準ファミレス（35卓）を卓の数に合わせて増減させる。それ以外は標準ファミレスと同じ。
+  今までの5つの店は、乱数の使い方も含めて何も変えていない（数字は v2.2 と同じ）。
+
 入店待ちの内訳と「店が回らない」（v2.2）
   入店待ちは、店に来てから案内されて席に着くまで（entry_wait_mean）。
   そのうち、満席で待った時間（full_wait_mean）と、席は空いているのに片付け（下げ膳・卓拭き）や
@@ -125,6 +132,47 @@
     },
 }
 
+# ---------------------------------------------------------------
+# 図面のある店（v2.3）：標準ファミレスの中の、店の形から作った店
+# ---------------------------------------------------------------
+import os as _os
+LAYOUT_DIR = _os.path.join(_os.path.dirname(_os.path.abspath(__file__)), "layouts")
+LAYOUT_LABELS = {
+    "p0": "② 定番の郊外型", "p1": "③ 効率重視・入口が角", "p2": "④ 効率重視・小さめの店",
+    "p3": "⑤ ゆったり・入口が正面", "p4": "⑥ ゆったり・入口が横", "p5": "⑦ ③の通路を80cmに",
+}
+
+
+def _scale(vals, t, base_t):
+    return [max(1, round(v * t / base_t)) for v in vals]
+
+
+def layout_stores():
+    """layouts/ の店の形から、標準ファミレスをもとにした店を作る"""
+    out = {}
+    base = STORES["family"]
+    names = sorted(f for f in _os.listdir(LAYOUT_DIR) if f.endswith("_analysis.json")) if _os.path.isdir(LAYOUT_DIR) else []
+    for f in names:
+        a = json.load(open(_os.path.join(LAYOUT_DIR, f), encoding="utf-8"))
+        nm = f.split("_")[0]
+        dists = [t["dist"] for t in a["tables"]]
+        if any(d is None for d in dists):
+            raise ValueError(f"{f}: ロボットが届かない卓がある（人が運ぶ卓はまだ試算に入れていない）")
+        t = len(dists)
+        c = max(2, round(base["staff"][1] * t / base["tables"]))      # 真ん中の人数
+        st = {**base}
+        st.update({
+            "label": LAYOUT_LABELS.get(nm, nm), "base": "family", "layout": nm,
+            "tables": t, "dist_m": (round(min(dists), 1), round(max(dists), 1)), "dist_list": dists,
+            "arrivals": _scale(base["arrivals"], t, base["tables"]),
+            "staff": [c - 1, c, c + 1], "staff_all": list(range(max(1, c - 2), c + 5)),
+        })
+        out["fam_" + nm] = st
+    return out
+
+
+STORES.update(layout_stores())
+
 ROBOTS = [0, 1, 2, 3]          # 最初に見せる台数
 ROBOTS_ALL = list(range(7))    # 「その他」で選べる台数（総当たりはこちら）
 MODES = ["serve", "bus", "patrol"]
@@ -386,7 +434,8 @@
         counted = (self.t0 <= arrive < self.t1) if p["sustain"] else True   # 数える時間に来た組だけを記録する
         if counted:
             self.counted += 1
-        d = rng.uniform(*p["dist_m"])
+        # 図面のある店は卓ごとの距離から選ぶ。ほかの店は今までどおり（乱数の使い方も同じ）
+        d = rng.choice(p["dist_list"]) if p.get("dist_list") else rng.uniform(*p["dist_m"])
         self._acc()
         table = self.tables.request()
         yield table
@@ -593,8 +642,10 @@
             try:
                 with open(path, encoding="utf-8") as f:
                     old = json.load(f)
-                if model_sig(old["common"], old["stores"]) == sig and old.get("reps") == REPS:
-                    cache.update({key(r): r for r in old["rows"]})
+                if old.get("reps") == REPS:
+                    osig = model_sig(old["common"], old["stores"])
+                    same = {k for k in sig["stores"] if osig["common"] == sig["common"] and osig["stores"].get(k) == sig["stores"][k]}
+                    cache.update({key(r): r for r in old["rows"] if r["store"] in same})
             except (FileNotFoundError, KeyError, TypeError, json.JSONDecodeError):
                 pass
 
