45 lines
965 B
Go

package solver
import (
"log"
"runtime"
"strconv"
)
// The main loop that orchastrates all the logic.
func Run() {
// Instantiate the Solver interface
solver := Solver{}
// Parse and handle flags
solver.parse_flags()
// Report number of CPUs being used, if set.
if runtime.NumCPU() != solver.numcpus {
log.Println("Using " + strconv.Itoa(solver.numcpus) + " CPUs, (was " + strconv.Itoa(runtime.NumCPU()) + ")")
}
// Load blocks from CSV file
solver.load_blocks()
// Find rows that fit with the entered rows
solver.populate_blocks()
// If needed, split the workload
// May exit and throw an error if the work load isn't viable
if solver.split != 1 {
solver.select_workload()
}
// Print the total number of solutions to validate
log.Println("Number of (potential) solutions:", solver.iter)
// Check the number of solutions
go solver.check_combinations()
solver.tracker()
// Print the valid solutions
solver.print_solutions()
}