-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (39 loc) · 1.24 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"SAT/cnf"
"SAT/genetic"
"flag"
"fmt"
"os"
)
func main() {
inputArg := flag.String("input", "", "absolute path to the input file")
generationArg := flag.Int("generation", 500, "Number of generations.")
populationArg := flag.Int("population", 50, "The population size.")
randomArg := flag.Int("random", 10, "Number of random individuals in population.")
elitismArg := flag.Int("elitism", 5, "Number of the fittest individuals passed to the next generations.")
tournamentArg := flag.Int("tournament", 10, "Number of contestants in selection tournament.")
mutationArg := flag.Float64("mutation", 0.1, "The mutation rate.")
flag.Parse()
//input := string("/Users/adamzvada/go/src/SAT/input/hard")
//file, err := os.Open(input)
file, err := os.Open(*inputArg)
if err != nil {
fmt.Print(err)
return
}
defer file.Close()
formula, err := cnf.Parse(file)
if err != nil {
fmt.Print(err)
return
}
var numGenerations = *generationArg
var populationSize = *populationArg
var tournamentSize = *tournamentArg
var elitismSize = *elitismArg
var randomSize = *randomArg
var mutationRate = *mutationArg
genetic.Solve(formula, numGenerations, populationSize, randomSize, elitismSize, tournamentSize, mutationRate)
return
}