Skip to content

Commit

Permalink
[allhic] Sort first in median()
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Jan 7, 2018
1 parent c44633e commit 6fe21e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions base.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import (
"math"
"os"
"path"
"sort"
"strings"

logging "github.com/op/go-logging"
)

const (
// Version is the current version of ALLHIC
Version = "0.8.1"
// Version is the current version of ALLHIC
Version = "0.8.1"
// LB is lower bound for GoldenArray
LB = 18
// UB is upper bound for GoldenArray
Expand Down Expand Up @@ -49,7 +50,7 @@ var GR = [...]int{5778, 9349, 15127, 24476,

var log = logging.MustGetLogger("allhic")
var format = logging.MustStringFormatter(
`%{color}%{time:15:04:05} %{shortfunc} %{level:.4s} %{color:reset} %{message}`,
`%{color}%{time:15:04:05} %{shortfunc} | %{level:.6s} %{color:reset} %{message}`,
)

// Backend is the default stderr output
Expand Down Expand Up @@ -121,6 +122,7 @@ func min(a, b int) int {

// median gets the median value of an array
func median(numbers []float64) float64 {
sort.Float64s(numbers)
middle := len(numbers) / 2
result := numbers[middle]
if len(numbers)%2 == 0 {
Expand Down
9 changes: 5 additions & 4 deletions clm.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ func (r *CLMFile) pruneTour() {
tour, newTour Tour
)

tour = r.Tour
for {
for phase := 1; phase < 3; phase++ {
tour = r.Tour
tourScore := -tour.Evaluate()
log.Noticef("Starting score: %.5f", tourScore)
log10ds := make([]float64, tour.Len()) // Each entry is the log10 of diff
Expand Down Expand Up @@ -278,11 +278,12 @@ func (r *CLMFile) pruneTour() {
invalid++
}
}
log.Noticef("Inactivated %d tigs with log10ds < %.5f",
invalid, lb)

if invalid == 0 {
break
} else {
log.Noticef("Inactivated %d tigs with log10ds < %.5f",
invalid, lb)
}

newTour.Tigs = newTour.Tigs[:0]
Expand Down

0 comments on commit 6fe21e7

Please sign in to comment.