Skip to content

Commit

Permalink
Hopefully fixed a synchronisation bug in balDet
Browse files Browse the repository at this point in the history
  • Loading branch information
cem-okulmus committed Dec 24, 2019
1 parent 80eac89 commit 54d06f2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
4 changes: 2 additions & 2 deletions algorithms/balDetKDecomp.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ OUTER:
continue OUTER
}
}
// log.Println("Sub Sep chosen: ", balsep, "Vertices: ", PrintVertices(balsep.Vertices()), " of ", balsepOrig, " , ", Sp)
// log.Println("Sub Sep chosen: ", balsep, "Vertices: ", PrintVertices(balsep.Vertices()), " of ", balsepOrig, " , ", Sp)
continue INNER
}

Expand All @@ -183,7 +183,7 @@ OUTER:
} else {
decomp.Root = decomp.Root.Reroot(Node{Bag: balsep.Vertices(), Cover: balsep})
decomp.Root = decomp.Root.Children[0]
// log.Printf("Produced Decomp (with balsep %v): %+v\n", balsep, decomp)
// log.Printf("Produced Decomp (with balsep %v): %+v\n", balsep, decomp)
}

subtrees = append(subtrees, decomp)
Expand Down
46 changes: 32 additions & 14 deletions algorithms/detKDecomp.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func baseCaseDetK(g Graph, H Graph, Sp []Special) Decomp {

func (d *DetKDecomp) findDecomp(K int, H Graph, oldSep []int, Sp []Special) Decomp {
verticesCurrent := append(H.Vertices(), VerticesSpecial(Sp)...)
verticesExtended := append(verticesCurrent, oldSep...)
conn := Inter(oldSep, verticesCurrent)
compVertices := Diff(verticesCurrent, oldSep)
bound := FilterVertices(d.Graph.Edges, conn)
Expand Down Expand Up @@ -137,7 +138,7 @@ OUTER:
log.Panicln("Cover messed up! 137")
}

// log.Println("Next Cover ", sep)
// log.Println("Next Cover ", sep)

addEdges := false

Expand All @@ -160,7 +161,7 @@ OUTER:
sepActual = sep
}

// sepActualOrigin := sepActual
// sepActualOrigin := sepActual
var sepSub *SepSub
var sepConst []Edge
var sepChanging []Edge
Expand All @@ -180,7 +181,7 @@ OUTER:
subEdges:
for true {

// log.Println("Sep chosen ", sepActual, " out ", out)
// log.Println("Sep chosen ", sepActual, " out ", out)
comps, compsSp, _ := H.GetComponents(sepActual, Sp)

//check chache for previous encounters
Expand All @@ -207,10 +208,27 @@ OUTER:
}
}

// log.Printf("Comps of Sep: %v\n", comps)
// log.Printf("Comps of Sep: %v\n", comps)

var subtrees []Node
bag := Inter(sepActual.Vertices(), append(oldSep, verticesCurrent...))
bag := Inter(sepActual.Vertices(), verticesExtended)

// log.Println("sep", sep, "\nsepActual", sepActual, "\n B of SepActual", PrintVertices(sepActual.Vertices()), "\noldSep ", PrintVertices(oldSep),
// "\nvertices of C", PrintVertices(verticesCurrent), "\n\nunion o both", PrintVertices(verticesExtended), "\n bag: ", PrintVertices(bag))

// for i := range sepActual.Vertices() {
// if Mem(verticesCurrent, sepActual.Vertices()[i]) && !Mem(bag, sepActual.Vertices()[i]) {

// fmt.Println("Another union: ", PrintVertices(append(oldSep, verticesCurrent...)))

// fmt.Println("Another intersect: ", PrintVertices(Inter(sepActual.Vertices(), verticesExtended)))

// fmt.Println("sep", sep, "\nsepActual", sepActual, "\n B of SepActual", PrintVertices(sepActual.Vertices()), "\noldSep ", PrintVertices(oldSep),
// "\nvertices of C", PrintVertices(verticesCurrent), "\n\nunion o both", PrintVertices(verticesExtended), "\n bag: ", PrintVertices(bag))

// log.Panicln("something is not right in the state of this program!")
// }
// }

for i := range comps {
decomp := d.findDecomp(K, comps[i], bag, compsSp[i])
Expand All @@ -233,17 +251,17 @@ OUTER:
if sepSub.HasNext() {
sepActual = sepSub.GetCurrent()
sepActual = NewEdges(append(sepActual.Slice(), sepConst...))
// log.Printf("Testing SSep: %v of %v , Special Edges %v \n", Graph{Edges: sepActual}, Graph{Edges: sepActualOrigin}, Sp)
// //log.Println("Sep const: ", sepConst, "sepChang ", sepChanging)
// // log.Println("SubSep: ")
// // for _, s := range sepSub.Edges {
// // log.Println(s.Combination)
// // }
log.Printf("Testing SSep: %v of %v , Special Edges %v \n", Graph{Edges: sepActual}, Graph{Edges: sepActualOrigin}, Sp)
//log.Println("Sep const: ", sepConst, "sepChang ", sepChanging)
// log.Println("SubSep: ")
// for _, s := range sepSub.Edges {
// log.Println(s.Combination)
// }
if connectingSep(sepActual.Vertices(), conn, compVertices) {
nextBalsepFound = true
}
} else {
// log.Printf("No SubSep found for %v with Sp %v \n", Graph{Edges: sepActualOrigin}, Sp)
log.Printf("No SubSep found for %v with Sp %v \n", Graph{Edges: sepActualOrigin}, Sp)
if addEdges {
i_add++
continue addingEdges
Expand All @@ -252,7 +270,7 @@ OUTER:
}
}
}
// log.Printf("Sub Sep chosen: %vof %v , %v \n", Graph{Edges: sepActual}, Graph{Edges: sepActualOrigin}, Sp)
log.Printf("Sub Sep chosen: %vof %v , %v \n", Graph{Edges: sepActual}, Graph{Edges: sepActualOrigin}, Sp)
continue subEdges
}

Expand All @@ -266,7 +284,7 @@ OUTER:
//cache[sepActual.Hash()].Succ = append(cache[sepActual.Hash()].Succ, comps[i].Edges.Hash())
//d.addPositive(sepActual, comps[i])

// log.Printf("Produced Decomp: %v\n", decomp)
// log.Printf("Produced Decomp: %v\n", decomp)
subtrees = append(subtrees, decomp.Root)
}

Expand Down

0 comments on commit 54d06f2

Please sign in to comment.