import os
import argparse

parser = argparse.ArgumentParser(description='The program is used to select the type of tracking to run with '
                                             'tracking-mota.py with NOMAD',
                                 epilog='''NOMAD - A blackbox optimization software: 
                                 C. Audet, S. Le Digabel, C. Tribes and V. Rochon Montplaisir. The NOMAD project. 
                                 Software available at https://www.gerad.ca/nomad.
                                 
                                 S. Le Digabel. Algorithm 909: NOMAD: Nonlinear Optimization with the MADS algorithm. 
                                 ACM Transactions on Mathematical Software, 37(4):44:1–44:15, 2011.''',
                                 formatter_class=argparse.RawDescriptionHelpFormatter)

parser.add_argument('-t', dest='intersections', nargs = '*', type = str, help='name of the intersection for which '
                                                    'the optimization is meant to be ran',
                    required=True)
parser.add_argument('--optimize-grouping-only', dest='optimizeGroupingOnly',
                    help='optimize only the grouping parameters and not the ones associated with feature tracking',
                    action='store_true')

args = parser.parse_args()

with open('arguments.txt', 'w') as f:
    f.write(str(args.intersections))
    f.write("\n")
    f.write(str(args.optimizeGroupingOnly))

os.system('nomad nomad-parameters.txt initial-parameters.txt')

