Lawfare Group → Knowledge Institute → Lawfare Academy
Reproduce the worked examples
Copy the complete code below into a UTF-8 file named verify.py and run python verify.py with Python 3. It uses only the standard library and performs exact or rational synthetic calculations. It does not access a network or learner records. Assertions fail if the expected synthetic results change.
These checks verify the stated arithmetic and query behavior, not independent academic acceptance or production migration safety.
"""Cedar synthetic project laboratory. No production or learner access."""
from fractions import Fraction as F
import json
checks={}
def check(n,a,b):
assert a==b,(n,a,b)
checks[n]=str(a)
dur={'A':2,'B':3,'C':4,'D':5,'E':3,'F':2}
pred={'A':[],'B':['A'],'C':['A'],'D':['B'],'E':['C','D'],'F':['E']}
def network(d,p):
assert set(d)==set(p) and all(k in d for v in p.values() for k in v)
order=[];pending=set(d);es={};ef={}
while pending:
ready=sorted(k for k in pending if all(x in ef for x in p[k]))
if not ready:raise ValueError('Cycle or invalid dependencies')
for k in ready:
es[k]=max((ef[x] for x in p[k]),default=0);ef[k]=es[k]+d[k];order.append(k);pending.remove(k)
finish=max(ef.values());succ={k:[x for x in p if k in p[x]] for k in d};ls={};lf={}
for k in reversed(order):
lf[k]=min((ls[x] for x in succ[k]),default=finish);ls[k]=lf[k]-d[k]
return dict(finish=finish,ES=es,EF=ef,LS=ls,LF=lf,float={k:ls[k]-es[k] for k in d})
n=network(dur,pred)
check('base finish',n['finish'],15)
check('baseES',n['ES'],dict(A=0,B=2,C=2,D=5,E=10,F=13))
check('baseEF',n['EF'],dict(A=2,B=5,C=6,D=10,E=13,F=15))
check('baseLS',n['LS'],dict(A=0,B=2,C=6,D=5,E=10,F=13))
check('baseLF',n['LF'],dict(A=2,B=5,C=10,D=10,E=13,F=15))
check('base floatC',n['float']['C'],4)
check('critical path duration',sum(dur[k] for k in ['A','B','D','E','F']),15)
check('other path duration',sum(dur[k] for k in ['A','C','E','F']),11)
longC=network({**dur,'C':8},pred)
check('changedC finish',longC['finish'],15)
check('changedC float',longC['float']['C'],0)
check('noncritical shortening finish',network({**dur,'C':3},pred)['finish'],15)
check('critical shortening finish',network({**dur,'D':3},pred)['finish'],13)
bc=network(dur,{**pred,'C':['A','B']})
cb=network(dur,{**pred,'B':['A','C']})
check('analystB thenC finish',bc['finish'],15)
check('analystB thenC data interval',(bc['ES']['C'],bc['EF']['C']),(5,9))
check('analystC thenB finish',cb['finish'],19)
check('analystC thenB configuration interval',(cb['ES']['D'],cb['EF']['D']),(9,14))
budget=dict(A=1000,B=3000,C=4000,D=6000,E=4000,F=2000)
BAC=sum(budget.values());check('budget reconciliation',BAC,20000)
PV=sum(budget[k] for k in ['A','B','C'])+4000
EV=sum(budget[k] for k in ['A','B','C'])+1000
AC=10000
check('PV',PV,12000);check('EV',EV,9000)
check('CV',EV-AC,-1000);check('SV',EV-PV,-3000)
CPI=F(EV,AC);SPI=F(EV,PV)
check('CPI',CPI,F(9,10));check('SPI',SPI,F(3,4))
check('continuing efficiencyEAC',BAC/CPI,F(200000,9))
check('equivalent continuingEAC',AC+F(BAC-EV)/CPI,F(200000,9))
check('remaining at budgetEAC',AC+BAC-EV,21000)
check('terminalSPI',F(BAC,BAC),1)
check('unmitigated expected cost',F(1,4)*4000,1000)
check('mitigated expected total',300+F(1,10)*4000,700)
check('changed mitigation effectiveness',300+F(1,5)*4000,1100)
extension=network({**dur,'G':3},{**pred,'G':['F']})
check('specified serial extension finish',extension['finish'],18)
check('authorized revised budget',BAC+2000,22000)
print(json.dumps(dict(passed=True,checks=checks,baseNetwork=n,analystBThenC=bc,analystCThenB=cb,limits='All durations, budgets, probabilities, milestones and authority boundaries are synthetic assumptions. Network and arithmetic validation do not establish actual resources, estimate validity, legal authority, project success, causal benefits, independent subject review or observed learner testing.'),indent=2))
Related chapters
- Authorize a bounded project and define what success will mean
- Decompose accepted scope into accountable work packages
- Calculate the critical path and then test resource feasibility
- Measure accepted progress against a preserved baseline
- Link uncertainty to accountable responses and affected stakeholders
- Close the project on accepted evidence and transfer remaining responsibilities
- Project clinic: defend scope, schedule, cost, risk and acceptance together