Skip to content

Commit

Permalink
[allhic] Add crossRate in GARun()
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Jan 7, 2018
1 parent 597e1fa commit 31dc3ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"os"
"sort"

"github.com/MaxHalford/gago"
"../gago"
)

// LIMIT determines the largest distance for two tigs to add to total score
Expand Down Expand Up @@ -200,7 +200,7 @@ func (r Tour) Shuffle() {
}

// GARun set up the Genetic Algorithm and run it
func (r *CLMFile) GARun(fwtour *os.File, npop, ngen int, mutrate float64, phase int) Tour {
func (r *CLMFile) GARun(fwtour *os.File, npop, ngen int, mutRate, crossRate float64, phase int) Tour {
MakeTour := func(rng *rand.Rand) gago.Genome {
c := r.Tour.Clone()
return c
Expand All @@ -214,13 +214,15 @@ func (r *CLMFile) GARun(fwtour *os.File, npop, ngen int, mutrate float64, phase
Selector: gago.SelTournament{
NContestants: 3,
},
MutRate: mutrate,
MutRate: mutRate,
CrossRate: crossRate,
},
ParallelEval: true,
}
ga.Initialize()

log.Noticef("GA initialized (npop: %v, ngen: %v, mu: %.3f)", npop, ngen, mutrate)
log.Noticef("GA initialized (npop: %v, ngen: %v, mu: %.3f, cx: %.3f)",
npop, ngen, mutRate, crossRate)

gen := 1
best := 0.0
Expand Down
2 changes: 1 addition & 1 deletion optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (r *Optimizer) Run() {

// OptimizeOrdering changes the ordering of contigs by Genetic Algorithm
func (r *CLMFile) OptimizeOrdering(fwtour *os.File, phase int) {
r.GARun(fwtour, 100, 5000, .25, phase)
r.GARun(fwtour, 100, 5000, .2, .7, phase)
r.pruneTour()
}

Expand Down

0 comments on commit 31dc3ca

Please sign in to comment.