Scott's version

KnotTheoryPath = "~/projects/KnotTheory/trunk/";
AppendTo[$Path, KnotTheoryPath];
<< KnotTheory`

KnotTheoryDirectory[]

Kh[Knot[3,1],Program->"FastKh"][q,t]

Kh[Knot[3,1],Program->"JavaKh-v1"][q,t]

Kh[Knot[3,1],Program->"JavaKh-v2"][q,t]

With[{K=Knot[3,1],program="JavaKh-v1"},Kh[K,Program->program][q,t]-Kh[K,Program->program,Modulus->2][q,t]]

With[{K=Knot[3,1],program="JavaKh-v2"},Kh[K,Program->program][q,t]-Kh[K,Program->program,Modulus->2][q,t]]

Clear[BenchmarkData]

BenchmarkData[tag_String]:={}

BenchmarkData[tag_String,n_]:=Cases[BenchmarkData[tag],{_,n,___}]

KnotWidth[K_]:=First[BR[K]]
KnotLength[K_]:=Length[BR[K][[2]]]

echo[x_]:=(Print[x];x)

Off[Unset::norep]

Off[Unset::write]

Clear[benchmark]

benchmark[tag_,invariantFunction_,K_]:=Module[{data},
If[MemberQ[BenchmarkData[tag],{K,___}],Return[]];
data={K,KnotWidth[K],KnotLength[K],Sequence@@(AbsoluteTiming[invariantFunction[BR[K]]]/.Second->1)};
invariantFunction[K]=.;
If[data[[4]]>0.5,
Print[data];
AppendTo[BenchmarkData[tag],data];
];
];

benchmark[tag_,invariantFunction_,knots_List]:=(benchmark[tag,invariantFunction,#]&/@knots;)

benchmark["FastKh",Kh[#,Program->"FastKh","chaff"->Random[]][q,t]&,Take[AllKnots[{11,11}],-10]]

Khv1=Function[{K},Kh[K,Program->"JavaKh-v1","chaff"->Random[]][q,t]];
Khv2=Function[{K},Kh[K,Program->"JavaKh-v2","chaff"->Random[]][q,t]];

KhU=Function[{K},UniversalKh[PD[K]]];

benchmarkComparision:=Show[Plot[x,{x,0,100}],ListPlot[Cases[Flatten[BenchmarkData["JavaKh-v1"]/.{K_,w_,l_,T1_,Except[$Failed[q,t]]}:>Cases[BenchmarkData["JavaKh-v2"],{K,w,l,T2_,Except[$Failed[q,t]]}:>{T1,T2}],1],{_,_}]],AspectRatio->1,PlotRange->All]

benchmarkComparision

Cases[Flatten[BenchmarkData["UniversalKh"]/.{K_,w_,l_,T1_,Except[$Failed[q,t]]}:>Cases[BenchmarkData["JavaKh-v2"],{K,w,l,T2_,Except[$Failed[q,t]]}:>{T1,T2}],1],{_,_}]

%/.{a_,b_}:>a/b

benchmarkComparision2:=Show[Plot[x,{x,0,100}],ListPlot[Cases[Flatten[BenchmarkData["UniversalKh"]/.{K_,w_,l_,T1_,Except[$Failed[q,t]]}:>Cases[BenchmarkData["JavaKh-v2"],{K,w,l,T2_,Except[$Failed[q,t]]}:>{T1,T2}],1],{_,_}]],AspectRatio->1,PlotRange->All]

benchmarkComparision2

SetDirectory[ToFileName[ToFileName[KnotTheoryDirectory[],".."],"testing"]]

FileNames["*.m"]

<<benchmarkdata.m;

Save["benchmarkdata.m",BenchmarkData]

({benchmark["JavaKh-v1",Khv1,#],benchmark["JavaKh-v2",Khv2,#],benchmark["UniversalKh",KhU,#]};Print[benchmarkComparision2])&/@RandomSample[AllKnots[{15,15}],40]

({benchmark["JavaKh-v1",Khv1,#],benchmark["JavaKh-v2",Khv2,#]};Print[benchmarkComparision])&/@RandomSample[AllKnots[{12,15}],100]

Map[{#[[3]],#[[4]]}&,Split[SortBy[BenchmarkData["FastKh"],#[[2]]&],#1[[2]]==#2[[2]]&],{2}]

ListPlot/@Map[{#[[3]],#[[4]]}&,Split[SortBy[BenchmarkData["FastKh"],#[[2]]&],#1[[2]]==#2[[2]]&],{2}]

ListPlot/@Map[{#[[3]],#[[4]]}&,Split[SortBy[DeleteCases[BenchmarkData["JavaKh-v1"],$Failed[q,t]],#[[2]]&],#1[[2]]==#2[[2]]&],{2}]

ListPlot/@Map[{#[[3]],#[[4]]}&,Split[SortBy[DeleteCases[BenchmarkData["JavaKh-v2"],$Failed[q,t]],#[[2]]&],#1[[2]]==#2[[2]]&],{2}]

RandomKnot[n_]:=Module[{k},
k=Random[Integer,{1,NumberOfKnots[n]}];
If[k≤NumberOfKnots[n,Alternating],
Knot[n,Alternating,k],
Knot[n,NonAlternating,k-NumberOfKnots[n,Alternating]]
]
]

QuantumKnotInvariantSplit[K,Γ,Irrep[Γ][λ]]

QuantumKnotInvariantSplit[#,(Subscript[A, 2]),Irrep[(Subscript[A, 2])][{1,0}]]&[Knot[7,2]]

benchmark["QuantumA2",QuantumKnotInvariantSplit[#,(Subscript[A, 2]),Irrep[(Subscript[A, 2])][{1,0}]]&,Table[TorusKnot[n,5],{n,5,100}]]

benchmark["Jones",Jones,TorusKnots[100]]

benchmark["HOMFLYPT",HOMFLYPT,TorusKnots[100]]

benchmark["A2Invariant",A2Invariant,TorusKnots[100]]

benchmark["A2Invariant",A2Invariant,Table[TorusKnot[n,4],{n,6,100}]]

BenchmarkData["A2Invariant"]

Sort[{#[[2]],#[[3]],((#[[4]])/((#[[3]])^2))}&/@BenchmarkData["A2Invariant"]]

Sort[{#[[2]],#[[3]],((#[[4]])/((#[[3]])^3))}&/@BenchmarkData["A2Invariant"]]

Sort[{#[[2]],#[[3]],((#[[4]])/((#[[3]])^5.5))}&/@BenchmarkData["A2Invariant"]]

Sort[{#[[2]],#[[3]],((#[[4]])/((#[[3]])^3))}&/@BenchmarkData["QuantumA2",3]]

Sort[{#[[2]],#[[3]],((#[[4]])/((#[[3]])^4.5))}&/@BenchmarkData["QuantumA2",4]]

Sort[{#[[2]],#[[3]],((#[[4]])/((#[[3]])^9.5))}&/@BenchmarkData["HOMFLYPT",2]]

Sort[{#[[2]],#[[3]],((#[[4]])/(((1.67))^(#[[3]])))}&/@BenchmarkData["HOMFLYPT",2]]

{EstimatedVariance,BestFitParameters}/.NonlinearRegress[BenchmarkData["Jones",5][[All,{2,3}]],α (l^n),{l},{α,n},RegressionReport->{BestFitParameters,EstimatedVariance}]

Sort[{#[[2]],#[[3]],((#[[4]])/((#[[3]])^2.6))}&/@BenchmarkData["Jones",5]]

model[power]:={α (l^n) ,{l},{α,n}}

<<Statistics`NonlinearFit`

tryModel[tag_,width_,model_List]:={EstimatedVariance,BestFitParameters}/.NonlinearRegress[BenchmarkData[tag,width][[All,{3,4}]],Sequence@@model,RegressionReport->{BestFitParameters,EstimatedVariance}]

tryModel["A2Invariant",3,model[power]]

<<Graphics`Graphics3D`

graphModel[tag_,width_,model_List,options___]:=Module[{f=model[[1]]/.tryModel[tag,width,model][[2]],modulePlot,dataPlot},
modelPlot=Plot[f,Evaluate[{l,Min[#],Max[#]}&[BenchmarkData[tag,width][[All,{3,4}]]],PlotRange->All,DisplayFunction->Identity]];
dataPlot=ListPlot[BenchmarkData[tag,width][[All,{3,4}]],PlotJoined->True,DisplayFunction->Identity];
Show[modelPlot,dataPlot,options,DisplayFunction->$DisplayFunction]
]

BenchmarkData["A2Invariant",3]

tryModel["A2Invariant",3,model[power]]

graphModel["A2Invariant",3,model[power]]

BenchmarkData["A2Invariant",4]

tryModel["A2Invariant",4,model[power]]

graphModel["A2Invariant",4,model[power]]

BenchmarkData["QuantumA2",4]

tryModel["QuantumA2",4,model[power]]

graphModel["QuantumA2",4,model[power]]

Sort[BenchmarkData["QuantumA2",5]]

tryModel["QuantumA2",5,model[power]]

graphModel["QuantumA2",5,model[power]]