Loading testing/context.py 0 → 100644 +21 −0 Original line number Diff line number Diff line import os import sys if sys.platform == "win32": soar_path = os.path.join(r"C:\Users\tjf\Documents\01_gitlab_repos\soar\python") elif sys.platform == "linux": soar_path = os.path.join("/home/tjf/01_nawi/soar/python") if soar_path not in sys.path: sys.path.insert(0, soar_path) else: print("soar toolbox already in path") # add module path module_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if module_path not in sys.path: sys.path.insert(0, module_path) else: print("path already in sys.path") testing/generate_pareto_front.py +29 −19 Original line number Diff line number Diff line Loading @@ -5,26 +5,27 @@ import logging import argparse # soar_integration tools from tools.soar_utilities import get_pareto_front() from tools.soar_utilities import get_pareto_front def generate_pareto_front( sys_name="ccro", objective= "linear", n_criteria=2, red_deficit=True, exhaustive=True, overwrite=False ): # check that pareto front exists pareto_path = os.path.join( module_path, "testing", "pareto_front", module_path, "testing", "pareto_fronts", f"{sys_name}_{objective}_{str(n_criteria)}_pareto_front.pkl" ) if os.path.exists(pareto_path): if overwrite: logging.warning(f"WARNING: file {pgraph_path} already exists, overwriting file") logging.warning(f"WARNING: file {pareto_path} already exists, overwriting file") else: raise Exception(f"ERROR: file {pgraph_path} already exists and overwrite not specified. Aborting.") raise Exception(f"ERROR: file {pareto_path} already exists and overwrite not specified. Aborting.") # check if pgraph exists pgraph_path = os.path.join(module_path, "testing", "process_graphs", f"{sys_name}_pgraph.pkl") Loading @@ -41,6 +42,7 @@ def generate_pareto_front( objective=objective, n_criteria = n_criteria, red_deficit=red_deficit, exhaustive=exhaustive, save_results=False, return_all=True, verbose=5 Loading @@ -51,24 +53,32 @@ def generate_pareto_front( if __name__ == "__main__": parser = argparse.ArgumentParser(description="Generates a pickle file for a soar processGraph") parser.add_argument('--sysname', type=str, help='Name of the system', required=True) parser.add_argument('--objective', type=str, help='objective (linear, bilinear)', required=True) parser.add_argument('--criteria', type=int, help='criteria (1=nsensors, 2=obs+nsensors, 3=obs+red+nsensors)', required=True) parser.add_argument('--reddeficit', action='store_true', help="redundancy defecit") parser.add_argument('--overwrite', action='store_true', help='overwrite existing pickle file') args = parser.parse_args() generate_pareto_front( sys_name=args.sysname, objective= args.objective, n_criteria=args.criteria, red_deficit=args.reddefecit, overwrite=args.overwrite sys_name="ccro", objective="linear", n_criteria=2, red_deficit=True, exhaustive=False, overwrite=True ) # parser = argparse.ArgumentParser(description="Generates a pickle file for a soar processGraph") # parser.add_argument('--sysname', type=str, help='Name of the system', required=True) # parser.add_argument('--objective', type=str, help='objective (linear, bilinear)', required=True) # parser.add_argument('--criteria', type=int, help='criteria (1=nsensors, 2=obs+nsensors, 3=obs+red+nsensors)', required=True) # parser.add_argument('--reddeficit', action='store_true', help="redundancy defecit") # parser.add_argument('--overwrite', action='store_true', help='overwrite existing pickle file') # args = parser.parse_args() # generate_pareto_front( # sys_name=args.sysname, # objective= args.objective, # n_criteria=args.criteria, # red_deficit=args.reddeficit, # overwrite=args.overwrite # ) Loading Loading
testing/context.py 0 → 100644 +21 −0 Original line number Diff line number Diff line import os import sys if sys.platform == "win32": soar_path = os.path.join(r"C:\Users\tjf\Documents\01_gitlab_repos\soar\python") elif sys.platform == "linux": soar_path = os.path.join("/home/tjf/01_nawi/soar/python") if soar_path not in sys.path: sys.path.insert(0, soar_path) else: print("soar toolbox already in path") # add module path module_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if module_path not in sys.path: sys.path.insert(0, module_path) else: print("path already in sys.path")
testing/generate_pareto_front.py +29 −19 Original line number Diff line number Diff line Loading @@ -5,26 +5,27 @@ import logging import argparse # soar_integration tools from tools.soar_utilities import get_pareto_front() from tools.soar_utilities import get_pareto_front def generate_pareto_front( sys_name="ccro", objective= "linear", n_criteria=2, red_deficit=True, exhaustive=True, overwrite=False ): # check that pareto front exists pareto_path = os.path.join( module_path, "testing", "pareto_front", module_path, "testing", "pareto_fronts", f"{sys_name}_{objective}_{str(n_criteria)}_pareto_front.pkl" ) if os.path.exists(pareto_path): if overwrite: logging.warning(f"WARNING: file {pgraph_path} already exists, overwriting file") logging.warning(f"WARNING: file {pareto_path} already exists, overwriting file") else: raise Exception(f"ERROR: file {pgraph_path} already exists and overwrite not specified. Aborting.") raise Exception(f"ERROR: file {pareto_path} already exists and overwrite not specified. Aborting.") # check if pgraph exists pgraph_path = os.path.join(module_path, "testing", "process_graphs", f"{sys_name}_pgraph.pkl") Loading @@ -41,6 +42,7 @@ def generate_pareto_front( objective=objective, n_criteria = n_criteria, red_deficit=red_deficit, exhaustive=exhaustive, save_results=False, return_all=True, verbose=5 Loading @@ -51,24 +53,32 @@ def generate_pareto_front( if __name__ == "__main__": parser = argparse.ArgumentParser(description="Generates a pickle file for a soar processGraph") parser.add_argument('--sysname', type=str, help='Name of the system', required=True) parser.add_argument('--objective', type=str, help='objective (linear, bilinear)', required=True) parser.add_argument('--criteria', type=int, help='criteria (1=nsensors, 2=obs+nsensors, 3=obs+red+nsensors)', required=True) parser.add_argument('--reddeficit', action='store_true', help="redundancy defecit") parser.add_argument('--overwrite', action='store_true', help='overwrite existing pickle file') args = parser.parse_args() generate_pareto_front( sys_name=args.sysname, objective= args.objective, n_criteria=args.criteria, red_deficit=args.reddefecit, overwrite=args.overwrite sys_name="ccro", objective="linear", n_criteria=2, red_deficit=True, exhaustive=False, overwrite=True ) # parser = argparse.ArgumentParser(description="Generates a pickle file for a soar processGraph") # parser.add_argument('--sysname', type=str, help='Name of the system', required=True) # parser.add_argument('--objective', type=str, help='objective (linear, bilinear)', required=True) # parser.add_argument('--criteria', type=int, help='criteria (1=nsensors, 2=obs+nsensors, 3=obs+red+nsensors)', required=True) # parser.add_argument('--reddeficit', action='store_true', help="redundancy defecit") # parser.add_argument('--overwrite', action='store_true', help='overwrite existing pickle file') # args = parser.parse_args() # generate_pareto_front( # sys_name=args.sysname, # objective= args.objective, # n_criteria=args.criteria, # red_deficit=args.reddeficit, # overwrite=args.overwrite # ) Loading