package solver

import (
	"log"
	"os"
	"strconv"
	"time"
)

// Renders workload for an agent.
// Checks if this feature can be used, otherwise exits.
// Modify solver.row1s so it limits the workload to what is only desired
func (solver *Solver) SelectWorkload() {
	if solver.Controller.Split > len(solver.row1s) {
		log.Println("ERROR: Unable to divide the workload in " + strconv.Itoa(solver.Controller.Split) + " parts, when only " + strconv.Itoa(len(solver.row1s)) + " are available.\n\n")
		os.Exit(1)
	}
	defer solver.timeTrack(time.Now(), "Workload set")
	log.Println("Setting workload")
	log.Println("We are agent " + strconv.Itoa(solver.Controller.Part) + " of " + strconv.Itoa(solver.Controller.Split))
	workloads := solver.splitWorkload()
	solver.setWorkload(workloads)
}
