Commits

Alexandru Moșoi committed 6e82fd1

Ran gofix.

  • Participants
  • Parent commits 82aa39d

Comments (0)

Files changed (3)

 		}
 
 		if !satisfied {
-			set[blocked.literal.Neg()] = false, false
+			delete(set, blocked.literal.Neg())
 			set[blocked.literal] = true
 		}
 	}

File lib/reader.go

 import (
 	"bufio"
 	"compress/gzip"
+	"errors"
 	"io"
 	"os"
 	"strconv"
 
 // Reads formula from path. If it ends in .cnf.gz,
 // then the file is gunzipped.
-func ReadFile(path string) (*Formula, os.Error) {
+func ReadFile(path string) (*Formula, error) {
 	file, err := os.Open(path)
 	if err != nil {
 		return nil, err
 }
 
 // Reads a formula from io. Decompresses the input if it is gzipped.
-func ReadIO(io io.Reader, gzipped bool) (*Formula, os.Error) {
+func ReadIO(io io.Reader, gzipped bool) (*Formula, error) {
 	if gzipped {
-		var err os.Error
+		var err error
 		if io, err = gzip.NewReader(io); err != nil {
 			return nil, err
 		}
 		for {
 			frag, isPrefix, err := reader.ReadLine()
 			if err != nil {
-				return nil, os.NewError("Failed to read input file: " + err.String())
+				return nil, errors.New("Failed to read input file: " + err.Error())
 			}
 
 			line += string(frag)
 
 		if line[0] == 'p' { // header
 			if f != nil {
-				return nil, os.NewError("Double header")
+				return nil, errors.New("Double header")
 			}
 
 			fields := strings.Fields(line)
 			if len(fields) != 4 || fields[0] != "p" || fields[1] != "cnf" {
-				return nil, os.NewError("Invalid header \"" + line + "\"")
+				return nil, errors.New("Invalid header \"" + line + "\"")
 			}
 
 			numVars, err := strconv.Atoi(fields[2])
 			if err != nil {
-				return nil, os.NewError("Invalid header \"" + line + "\": " +
-					err.String())
+				return nil, errors.New("Invalid header \"" + line + "\": " +
+					err.Error())
 			}
 
 			numClauses, err = strconv.Atoi(fields[3])
 			if err != nil {
-				return nil, os.NewError("Invalid header \"" + line + "\": " +
-					err.String())
+				return nil, errors.New("Invalid header \"" + line + "\": " +
+					err.Error())
 			}
 
 			f = NewFormula(numVars)
 				has = true
 				value = value*10 + int(line[i]) - '0'
 			} else if line[i] != ' ' {
-				return nil, os.NewError("Expected \" \", found \"" + line[i:i+1] + "\"")
+				return nil, errors.New("Expected \" \", found \"" + line[i:i+1] + "\"")
 			} else if has {
 				lits = append(lits, sign*value)
 				value = 0
 		}
 
 		if lits[len(lits)-1] != 0 {
-			return nil, os.NewError("Clause not ending in 0")
+			return nil, errors.New("Clause not ending in 0")
 		}
 
 		f.AddDIMACSClause(lits[0 : len(lits)-1])

File lib/solve.go

 package gasca
 
 import (
+	"flag"
 	"log"
+	"strings"
 	"time"
-	"flag"
-	"strings"
 )
 
 var gpre = flag.String("gpre", "pu,flp,pu,pl,hl,bce", "preprocessing algorithms")
 		var apply func(*Formula) (bool, Reasoning)
 
 		switch pre {
-		case "bce": apply = BlockedClauseElimination
-		case "pu": apply = PropagateUnits
-		case "flp": apply = FailedLiteralProbing
-		case "hl": apply = HiddenLiterals
-		case "pl": apply = PureLiterals
+		case "bce":
+			apply = BlockedClauseElimination
+		case "pu":
+			apply = PropagateUnits
+		case "flp":
+			apply = FailedLiteralProbing
+		case "hl":
+			apply = HiddenLiterals
+		case "pl":
+			apply = PureLiterals
 		}
 
 		if apply == nil {
 	for {
 		// Runs searcher for numConflicts conflicts.
 		numConflicts := restarter.NextRestartNumConflicts()
-		end := time.Nanoseconds()
+		end := time.Now()
 		solution, assignment := searcher.Search(&numConflicts)
-		start := time.Nanoseconds()
+		start := time.Now()
 
 		log.Printf("conflicts: %d; speed: %.3f c/s; decider: %v",
-			numConflicts, float32(numConflicts)/float32(start-end)*1e9, decider)
+			numConflicts, float32(numConflicts)/float32(start.Sub(end))*1e9, decider)
 
 		// Restarts global state.
 		decider.OnRestart()