In [ ]:
# include("../hopfield.jl")
include("DevDesc.jl")

In [ ]:
d = Dict{String, Vector{Float64}}()
# for i in 1:15
#   d[String("l$(i)")] = rand(2)
# end
for i in 1:30
  d[String("l$(i)")] = (3.0.*rand(2))-1
end

# draw points
pl=plot(drawLandmPtsLayer(d))

R = 0.5
Mf = 4
angBins=6
rangeBins = 4
K=4 # nubmer of features to try
bLbls, bestDescr = bestDescriptors(d, r=R, Mf=Mf, k=K, angBins=angBins, rangeBins=rangeBins )

if length(bLbls) >= 3
    v1 = bestDescr[bLbls[1]]
    v2 = bestDescr[bLbls[2]]
    v3 = bestDescr[bLbls[3]]
    @show hamming(v1,v2)
    @show hamming(v1,v3)
    @show hamming(v2,v3)
    P = [v1';v2';v3']'
    P = map(Float64,P)

    fm=findMatches(d, P, bLbls, R=R, angBins=angBins, rangeBins=rangeBins, Mf=Mf)
    # [@show fm[i] for i in 1:length(fm)]
    mmlst = convertToMMLst(fm, floor(Int, length(v1)))
    [@show l for l in mmlst]

    # draw so we can see
    for lm in bLbls
    #   push!(pl,circLayer(d[lm],r=R)[1])
        rd = findInRadius(d,lm,r=R)
        drawDictLinesLayers(pl, rd, lm)
    end
else
    warn("not enough description available")
end
pl

In [ ]:
errNoise = 0.04*R

dd = deepcopy(d)
# @show length(d)
for i in 1:length(d)
    dd[String("l$(i)")] = dd[String("l$(i)")] + errNoise*randn(2) 
end
for i in length(d):floor(Int,length(d)*1.1)
  dd[String("l$(i)")] = (3.0*rand(2))-1.0 
end

fm=findMatches(dd, P, bLbls, R=R, angBins=angBins, rangeBins=rangeBins, Mf=Mf)
# [@show fm[i] for i in 1:length(fm)]
mmlst = convertToMMLst(fm, floor(Int, length(v1)/3+0.5))
[@show l for l in mmlst];

In [ ]:
pl2 = deepcopy(pl)
l2 = drawLandmPtsLayer(dd,c="red")
push!(pl2.layers, l2[1])
pl2

In [ ]:
@show bLbls
v1 = bestDescr[bLbls[1]]
v2 = bestDescr[bLbls[2]]
v3 = bestDescr[bLbls[3]]
# v4 = bestDescr[bLbls[4]]
# v5 = bestDescr[bLbls[5]]

P = [v1';v2';v3']'
# P = [v1';v2';v3';v4']'
P = map(Float64,P)

@show hamming(v1,v2)
@show hamming(v1,v3)
@show hamming(v2,v3)

# @show hamming(v1,v4)
# @show hamming(v2,v4)
# @show hamming(v3,v4)

In [ ]:
searchHopfield(P,map(Float64,bestDescr["l11"]))

In [ ]:
mmlst

In [ ]:
length(v1)/4

In [ ]: