45 lines
965 B
Go
Raw Normal View History

package solver
import (
2025-01-21 21:43:27 +01:00
"log"
"runtime"
"strconv"
)
2025-01-27 18:41:15 +01:00
// The main loop that orchastrates all the logic.
func Run() {
2025-01-21 21:44:21 +01:00
// Instantiate the Solver interface
solver := Solver{}
2025-01-21 21:37:53 +01:00
2025-01-23 22:39:59 +01:00
// Parse and handle flags
solver.parse_flags()
2025-01-23 20:26:43 +01:00
// 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()) + ")")
}
2025-01-21 21:32:50 +01:00
// Load blocks from CSV file
solver.load_blocks()
// Find rows that fit with the entered rows
2025-01-21 21:32:50 +01:00
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
2025-01-23 20:26:43 +01:00
log.Println("Number of (potential) solutions:", solver.iter)
2025-01-21 21:37:53 +01:00
// Check the number of solutions
2025-01-23 20:26:43 +01:00
go solver.check_combinations()
solver.tracker()
2025-01-21 21:37:53 +01:00
// Print the valid solutions
2025-01-23 20:26:43 +01:00
solver.print_solutions()
}