import tensorflow as tf
import tensorflow.keras as tk
import nthmc

# compared to i11.py
# triple stepPerTraj

conf = nthmc.Conf(nbatch=256, nepoch=1, nstepEpoch=2048, nstepMixing=64, stepPerTraj = 30,
  initDt=0.4, refreshOpt=False, checkReverse=False, nthr=4)
nthmc.setup(conf)
beta=3.5

action = nthmc.OneD(beta=beta, size=256, transform=nthmc.Ident())
loss = nthmc.LossFun(action, cCosDiff=1.0, cTopoDiff=1.0, dHmin=0.0, topoFourierN=1)
x0 = action.initState(conf.nbatch)
weights=list(map(lambda x:tf.constant(x,dtype=tf.float64),
 [0.5*0.268831031592305,
  beta]))
x1 = nthmc.runInfer(conf, action, loss, weights, x0, detail=False)

action = nthmc.OneD(beta=beta, size=256, transform=nthmc.TransformChain([
  nthmc.OneDNeighbor(mask='even'), nthmc.OneDNeighbor(mask='odd'),
  nthmc.OneDNeighbor(mask='even',distance=2), nthmc.OneDNeighbor(mask='odd',distance=2),
  nthmc.OneDNeighbor(mask='even',distance=4), nthmc.OneDNeighbor(mask='odd',distance=4),
  nthmc.OneDNeighbor(mask='even',distance=8), nthmc.OneDNeighbor(mask='odd',distance=8),
  nthmc.OneDNeighbor(mask='even',distance=16), nthmc.OneDNeighbor(mask='odd',distance=16),
  nthmc.OneDNeighbor(mask='even',distance=32), nthmc.OneDNeighbor(mask='odd',distance=32),
  nthmc.OneDNeighbor(mask='even',order=2), nthmc.OneDNeighbor(mask='odd',order=2),
  nthmc.OneDNeighbor(mask='even',order=2,distance=2), nthmc.OneDNeighbor(mask='odd',order=2,distance=2),
  nthmc.OneDNeighbor(mask='even',order=2,distance=4), nthmc.OneDNeighbor(mask='odd',order=2,distance=4),
  nthmc.OneDNeighbor(mask='even',order=2,distance=8), nthmc.OneDNeighbor(mask='odd',order=2,distance=8),
  nthmc.OneDNeighbor(mask='even',order=2,distance=16), nthmc.OneDNeighbor(mask='odd',order=2,distance=16),
  nthmc.OneDNeighbor(mask='even',order=2,distance=32), nthmc.OneDNeighbor(mask='odd',order=2,distance=32),
  nthmc.OneDNeighbor(mask='even',order=3), nthmc.OneDNeighbor(mask='odd',order=3),
  nthmc.OneDNeighbor(mask='even',order=3,distance=2), nthmc.OneDNeighbor(mask='odd',order=3,distance=2),
  nthmc.OneDNeighbor(mask='even',order=3,distance=4), nthmc.OneDNeighbor(mask='odd',order=3,distance=4),
  nthmc.OneDNeighbor(mask='even',order=3,distance=8), nthmc.OneDNeighbor(mask='odd',order=3,distance=8),
  nthmc.OneDNeighbor(mask='even',order=3,distance=16), nthmc.OneDNeighbor(mask='odd',order=3,distance=16),
  nthmc.OneDNeighbor(mask='even',order=3,distance=32), nthmc.OneDNeighbor(mask='odd',order=3,distance=32),
  nthmc.OneDNeighbor(mask='even',order=4), nthmc.OneDNeighbor(mask='odd',order=4),
  nthmc.OneDNeighbor(mask='even',order=4,distance=2), nthmc.OneDNeighbor(mask='odd',order=4,distance=2),
  nthmc.OneDNeighbor(mask='even',order=4,distance=4), nthmc.OneDNeighbor(mask='odd',order=4,distance=4),
  nthmc.OneDNeighbor(mask='even',order=4,distance=8), nthmc.OneDNeighbor(mask='odd',order=4,distance=8),
  nthmc.OneDNeighbor(mask='even',order=4,distance=16), nthmc.OneDNeighbor(mask='odd',order=4,distance=16),
  nthmc.OneDNeighbor(mask='even',order=4,distance=32), nthmc.OneDNeighbor(mask='odd',order=4,distance=32),
  nthmc.OneDNeighbor(mask='even'), nthmc.OneDNeighbor(mask='odd'),
  nthmc.OneDNeighbor(mask='even',distance=2), nthmc.OneDNeighbor(mask='odd',distance=2),
  nthmc.OneDNeighbor(mask='even',distance=4), nthmc.OneDNeighbor(mask='odd',distance=4),
  nthmc.OneDNeighbor(mask='even',distance=8), nthmc.OneDNeighbor(mask='odd',distance=8),
  nthmc.OneDNeighbor(mask='even',distance=16), nthmc.OneDNeighbor(mask='odd',distance=16),
  nthmc.OneDNeighbor(mask='even',distance=32), nthmc.OneDNeighbor(mask='odd',distance=32),
  nthmc.OneDNeighbor(mask='even',order=2), nthmc.OneDNeighbor(mask='odd',order=2),
  nthmc.OneDNeighbor(mask='even',order=2,distance=2), nthmc.OneDNeighbor(mask='odd',order=2,distance=2),
  nthmc.OneDNeighbor(mask='even',order=2,distance=4), nthmc.OneDNeighbor(mask='odd',order=2,distance=4),
  nthmc.OneDNeighbor(mask='even',order=2,distance=8), nthmc.OneDNeighbor(mask='odd',order=2,distance=8),
  nthmc.OneDNeighbor(mask='even',order=2,distance=16), nthmc.OneDNeighbor(mask='odd',order=2,distance=16),
  nthmc.OneDNeighbor(mask='even',order=2,distance=32), nthmc.OneDNeighbor(mask='odd',order=2,distance=32),
  nthmc.OneDNeighbor(mask='even',order=3), nthmc.OneDNeighbor(mask='odd',order=3),
  nthmc.OneDNeighbor(mask='even',order=3,distance=2), nthmc.OneDNeighbor(mask='odd',order=3,distance=2),
  nthmc.OneDNeighbor(mask='even',order=3,distance=4), nthmc.OneDNeighbor(mask='odd',order=3,distance=4),
  nthmc.OneDNeighbor(mask='even',order=3,distance=8), nthmc.OneDNeighbor(mask='odd',order=3,distance=8),
  nthmc.OneDNeighbor(mask='even',order=3,distance=16), nthmc.OneDNeighbor(mask='odd',order=3,distance=16),
  nthmc.OneDNeighbor(mask='even',order=3,distance=32), nthmc.OneDNeighbor(mask='odd',order=3,distance=32),
  nthmc.OneDNeighbor(mask='even',order=4), nthmc.OneDNeighbor(mask='odd',order=4),
  nthmc.OneDNeighbor(mask='even',order=4,distance=2), nthmc.OneDNeighbor(mask='odd',order=4,distance=2),
  nthmc.OneDNeighbor(mask='even',order=4,distance=4), nthmc.OneDNeighbor(mask='odd',order=4,distance=4),
  nthmc.OneDNeighbor(mask='even',order=4,distance=8), nthmc.OneDNeighbor(mask='odd',order=4,distance=8),
  nthmc.OneDNeighbor(mask='even',order=4,distance=16), nthmc.OneDNeighbor(mask='odd',order=4,distance=16),
  nthmc.OneDNeighbor(mask='even',order=4,distance=32), nthmc.OneDNeighbor(mask='odd',order=4,distance=32),
]))
loss = nthmc.LossFun(action, cCosDiff=1.0, cTopoDiff=1.0, dHmin=0.0, topoFourierN=1)
weights=list(map(lambda x:tf.constant(x,dtype=tf.float64),
 [0.5*0.426161809940765,
 -0.320109120400013,
 -0.32090020243824952,
 -0.031182716984891851,
 -0.036169773339796464,
 0.055714318919392686,
 0.057602389890724234,
 0.029411886986087127,
 0.02048733243498738,
 0.00094839455227904755,
 -0.003336858749749962,
 0.0042831810194401618,
 0.0055589091837478805,
 0.1523380013134244,
 0.15163036003180105,
 0.017450942775123303,
 0.01366963403033924,
 -0.015362176729137129,
 -0.023842410298148348,
 -0.0077312457934894819,
 -0.0013628219442876222,
 0.0011295376199805572,
 -0.00091410054524127253,
 -0.00059341864473508234,
 0.0025111964348351304,
 -0.016444424617664447,
 -0.015570829270105238,
 0.0019647033660882846,
 0.0059393613468408137,
 0.0064600167032926427,
 0.004736273804986227,
 0.0022333630983046664,
 -0.0011657888127998832,
 0.00019669260733786145,
 -0.0030779286401902473,
 0.002774947111944009,
 -9.6433938335267359e-05,
 0.0083785133367789,
 0.0053008391565818914,
 -0.0014080778872983919,
 -0.0024396905236594682,
 -0.0015531026667714104,
 -0.0015796761344081557,
 -0.0012537334878866919,
 -0.0015042727436904697,
 0.0011413533343287735,
 0.00097227804515090984,
 -0.00046677598847423714,
 0.00063556338329312273,
 -0.32071868062103076,
 -0.32148180159296041,
 -0.00986116406882059,
 -0.017335584106134748,
 0.068029369690636679,
 0.066918020242658541,
 0.030819349510999603,
 0.023206203501044503,
 0.0017779135561217525,
 -0.0034133032476216588,
 0.002189343578032792,
 0.00656004530207795,
 0.11256550758203428,
 0.11055222402865708,
 0.049446153758141626,
 0.045658985887769253,
 -0.017581715497940329,
 -0.026933901536123416,
 -0.011986081801134148,
 -0.0048059039456269485,
 0.0017878663762805563,
 -0.0025517310832571327,
 0.00019610673621250042,
 0.003797903258295098,
 -0.04866943996936729,
 -0.045885640197634261,
 -0.030946502446712494,
 -0.025988143680184862,
 0.0058739799141497131,
 0.0044195418882953643,
 0.0029309881330323194,
 -0.0042307734485617391,
 -0.000379102785780568,
 -0.00042006608019470941,
 -0.000890702512832992,
 -0.0015533078274466545,
 0.018431797429963044,
 0.01296582266989706,
 0.0083730807637790484,
 0.0071470949531473186,
 -0.0006280677552497352,
 0.00086911341441850648,
 -0.00011310686430592162,
 0.0010197384364829679,
 -0.00042664791705881658,
 -0.00060594003312396886,
 8.3595033525653663e-05,
 -0.00070533166824918961,
 beta]))
nthmc.runInfer(conf, action, loss, weights, x1, detail=False)
