-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclockwise.py
More file actions
47 lines (42 loc) · 1.88 KB
/
Copy pathclockwise.py
File metadata and controls
47 lines (42 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
"""Does running the loop clockwise change anything?"""
import json, sys
exec(open("optimiser_core.py").read())
from pacing import STOP
CUT = {"evisa","scala","bodri","galeria","santantonino","ostriconi","lotu"}
full_seq, full_legs = SEQ[:], legs[:]
keep = [k for k,s in enumerate(SEQ) if s not in CUT]
base_seq = [full_seq[k] for k in keep]
base_legs = [sum(full_legs[a:b]) for a,b in zip(keep, keep[1:])]
globals()["ALLOW_STACK"] = False
globals()["BIG_DRIVE"], globals()["NORM_DRIVE"] = 105, 210
def run(label, seq, lg):
SEQ[:] = seq; legs[:] = lg; globals()["N"] = len(seq)
out = {}
for name, hrs in [("Relaxed",7.0),("Steady",8.0),("Standard",9.0),("Brisk",10.5)]:
r = solve(int(hrs*60))
out[name] = (len(r[0]), r[1]/60) if r else None
r = solve(480)
cuts = r[0]
loads = []
for i,j in cuts:
act = sum(STOP[seq[k]]["m"] for k in range(i,j+1))
drv = sum(lg[k] for k in range(i,j))
if i>0: drv += lg[i-1]/2
if j<len(seq)-1: drv += lg[j]/2
loads.append(act+int(drv)+20*(j-i+1)+75)
print(f"\n{label}")
print(f" {'pace':10s} {'days':>5} {'worst':>7}")
for k,v in out.items():
print(f" {k:10s} {v[0]:>5} {v[1]:>6.1f}h" if v else f" {k:10s} infeasible")
print(f" steady: {len(cuts)} days · mean {sum(loads)/len(loads)/60:.1f}h · "
f"worst {max(loads)/60:.1f}h · driving {sum(lg)/60:.1f}h")
return cuts, loads
acw = run("ANTICLOCKWISE (Bastia → Cap Corse → Calvi → west → south → east → Bastia)",
base_seq, base_legs)
cw = run("CLOCKWISE (Bastia → east → south → Ajaccio → west → Calvi → Cap Corse → Bastia)",
base_seq[::-1], base_legs[::-1])
print("\n--- day-by-day, clockwise, steady ---")
seq = base_seq[::-1]
for n,(i,j) in enumerate(cw[0],1):
print(f"{n:>3}. {', '.join(seq[i:j+1]):48s} {cw[1][n-1]/60:>5.1f}h")