Created
December 3, 2016 19:17
-
-
Save jakab922/270dd6fcc294a78278dbeb5f2c423508 to your computer and use it in GitHub Desktop.
Parsing flags for the smartcab assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def parse_flags(): | |
from optparse import OptionParser | |
usage = "usage: %prog [options]" | |
parser = OptionParser(usage=usage) | |
parser.add_option( | |
"-v", "--verbose", dest="verbose", | |
help="set to True to display additional output from the simulation", | |
action="store_true", default=False) | |
parser.add_option( | |
"--num_dummies", dest="num_dummies", | |
help="discrete number of dummy agents in the environment, default is 100", | |
type="int", default=100) | |
def parse_tuple(option, opt, value, parser): | |
return tuple(map(int, value)) | |
parser.add_option( | |
"--grid_size", dest="grid_size", | |
help="discrete number of intersections (columns, rows), default is (8, 6). " | |
, nargs=2, type="int", default=(8, 6)) | |
parser.add_option( | |
"-l", "--learning", dest="learning", | |
help="set to True to force the driving agent to use Q-learning", | |
action="store_true", default=False) | |
parser.add_option( | |
"-e", "--epsilon", dest="epsilon", | |
help="continuous value for the exploration factor, default is 1.0", | |
type="float", default=1.0) | |
parser.add_option( | |
"-a", "--alpha", dest="alpha", | |
help="continuous value for the learning rate, default is 0.5", | |
type="float", default=0.5) | |
parser.add_option( | |
"-d", "--enforce_deadline", dest="enforce_deadline", | |
help="set to True to enforce a deadline metric", | |
action="store_true", default=False) | |
parser.add_option( | |
"--update_delay", dest="update_delay", | |
help="continuous time (in seconds) between actions, default is 2.0 seconds", | |
type="float", default=2.0) | |
parser.add_option( | |
"--display", dest="display", | |
help="set to False to disable the GUI if PyGame is enabled", | |
action="store_false", default=True) | |
parser.add_option( | |
"--log_metrics", dest="log_metrics", | |
help="set to True to log trial and simulation results to /logs", | |
action="store_true", default=False) | |
parser.add_option( | |
"--optimized", dest="optimized", | |
help="set to True to change the default log file name", | |
action="store_true", default=False) | |
parser.add_option( | |
"--tolerance", dest="tolerance", | |
help="epsilon tolerance before beginning testing, default is 0.05", | |
type="float", default=0.05) | |
parser.add_option( | |
"--n_test", dest="n_test", | |
help="discrete number of testing trials to perform, default is 0", | |
type="int", default=0) | |
return parser.parse_args()[0] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment