-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_paced.py
More file actions
48 lines (44 loc) · 2.04 KB
/
Copy pathbuild_paced.py
File metadata and controls
48 lines (44 loc) · 2.04 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
48
# -*- coding: utf-8 -*-
"""The unrushed variant: re-solve the whole route at a steady pace."""
import json, sys, math
exec(open("optimiser_core.py").read())
from pacing import STOP
# What to leave out, decided on evidence rather than by eye: ten independent
# guides were checked for every stop (data/corroboration.json). Out go the
# ones almost nobody rates; back in come four I had wrongly cut as "padding"
# which turn out to be among the best attested on the island.
CUT = {
"evisa", # 1/10
"scala", # 1/10 -- you drive the gorge anyway, you just don't stop
"bodri", # 2/10
"galeria", # 2/10
"santantonino", # 3/10
"ostriconi", # 4/10, and the Agriates are already covered by Saleccia
"lotu", # 6/10 but the same boat as Saleccia, which is the better beach
}
full_seq, full_legs = SEQ[:], legs[:]
keep = [k for k,s in enumerate(SEQ) if s not in CUT]
SEQ[:] = [full_seq[k] for k in keep]
legs[:] = [sum(full_legs[a:b]) for a,b in zip(keep, keep[1:])]
globals()["N"] = len(SEQ)
globals()["ALLOW_STACK"] = False
globals()["BIG_DRIVE"], globals()["NORM_DRIVE"] = 105, 210
print(f"{len(full_seq)} core stops - {len(CUT)} cut = {len(SEQ)}")
print(f"driving {sum(legs)//60} h {sum(legs)%60} m\n")
for name,hrs in [("Relaxed",7.0),("Steady",8.0),("Standard",9.0)]:
r = solve(int(hrs*60))
print(f" {name:9s} {hrs}h -> {len(r[0]) if r else '—'} days on the road, "
f"worst {r[1]/60:.1f}h" if r else f" {name}: infeasible")
cuts, worst, _ = solve(int(8.0*60))
print(f"\n=== STEADY: {len(cuts)} days on the road (+ferry arrival +buffer = {len(cuts)+1}) ===")
plan=[]
for n,(i,j) in enumerate(cuts,1):
ids=[SEQ[k] for k in range(i,j+1)]
act=sum(STOP[s]["m"] for s in ids)
drv=sum(legs[k] for k in range(i,j))
if i>0: drv+=legs[i-1]/2
if j<N-1: drv+=legs[j]/2
drv=int(drv); tot=act+drv+20*len(ids)+75
plan.append(dict(n=n, ids=ids, act=act, drive=drv, load=tot))
print(f"{n:>3}. {', '.join(ids):50s} {drv:>4}m {act:>4}m {tot/60:>5.1f}h")
json.dump(plan, open("data/paced_plan.json","w"), indent=1)