func main() {

	giftFile := flag.String("g", "", "Gift file")
	subFile := flag.String("s", "", "Submission file")
	quiet := flag.Bool("q", false, "Only print result")
	flag.Parse()

	if *giftFile == "" || *subFile == "" {
		fmt.Println("Error: missing gift or submission file argument")
		os.Exit(1)

	}

	if !*quiet {
		fmt.Println("Using gift file ", *giftFile)
		fmt.Println("Using sub file ", *subFile)
	}

	// LOAD FILES -----------------------------------------------------------
	gifts, err := gift.LoadGifts(*giftFile)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	sub = submission.NewSubmission()
	err = sub.LoadFile(*subFile)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	if !*quiet {
		fmt.Println("Read ", len(gifts), " gifts")
		fmt.Println("Read ", sub.NumTrips(), " trips")
	}

	// VALIDATE ------------------------------------------------------------
	if !sub.Validate(&gifts) {
		fmt.Println("Solution is NOT valid")
	}

	// SCORE ---------------------------------------------------------------
	totalWRW := sub.Score(&gifts)
	if !*quiet {
		fmt.Printf("Total WRW ")
	}
	fmt.Printf("%f\n", totalWRW)

}
func main() {

	giftFile := flag.String("g", "", "Gift file")
	subFile := flag.String("s", "", "Submission file")
	alg := flag.String("a", "", "Algorithm")
	seed := flag.Int64("r", 1, "Random Seed")
	quiet := flag.Bool("q", false, "Only print result")
	flag.Parse()

	if *giftFile == "" || *subFile == "" || *alg == "" {
		fmt.Println("Error: missing gift, submission, or alg argument")
		os.Exit(1)
	}

	if !*quiet {
		fmt.Println("Using gift file: ", *giftFile)
		fmt.Println(" Using sub file: ", *subFile)
		fmt.Println("Using algorithm: ", *alg)
		fmt.Println("     Using seed: ", *seed)
	}

	rand.Seed(*seed)

	// LOAD GIFTS ------------------------------------------------------------
	gifts, err := gift.LoadGifts(*giftFile)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	if !*quiet {
		fmt.Println("Number of Gifts: ", len(gifts), " gifts")
	}

	// RUN SELECTED ALGORITHM -----------------------------------------------
	s := (algs.Algs[*alg])(&gifts)

	// OPTIMIZE -------------------------------------------------------------
	s.OptimizeTrips(&gifts)

	// SCORE AND SAVE -------------------------------------------------------
	fmt.Println("Number of trips: ", s.NumTrips())
	fmt.Println(" Solution Score: ", s.Score(&gifts))

	s.SaveFile(*subFile)
}