Loading documenting_failures/setup_example_soar.py +4 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,10 @@ import sys import os from sympy import symbols 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_wwtp/soar/python/soar") if soar_path not in sys.path: sys.path.insert(0, soar_path) Loading documenting_failures/soar_pgraphs/generate_pgraph.py 0 → 100644 +118 −0 Original line number Diff line number Diff line import os import sys import pickle import random import traceback import yaml import numpy as np from time import time 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_wwtp/soar/python/soar") if soar_path not in sys.path: sys.path.insert(0, soar_path) else: print("soar toolbox already in path") # add module_path = os.path.dirname(os.path.abspath("")) if module_path not in sys.path: sys.path.insert(0, module_path) else: print("path already in sys.path") from soar.graph_labeling.genobs.fGenObs import general_observability from soar.graph_labeling.genred.fGenRed import genred from soar.graph_labeling.fDefineSystem import ProcessGraph from setup_example_soar import define_system, get_pareto_front, get_one_result from soar.optimization.fEvaluate import evaluate_obs_red # for plotting from soar.graph_labeling.fPlotGraph import plot_graph import matplotlib.pyplot as plt from numerical_labelling.labelling import * # compare to soar from build_test_cases_nl import build_test_case_nl, make_layout import soar.optimization.fEvaluate as feval import matplotlib.pyplot as plt # save the pgraph object so we don't have to wait for 7 minutes each time import pickle def check_incidence(iIncidence): """ simple check that in nodes equal to out nodes (graph is closed) """ for row in iIncidence: assert sum(row) == 0, f"Incidence matrix row sums to {sum(row)}" # establish pilot graph: # 12 nodes: # mix (a), pump (b), mem 1 (c), # mem 2 (d), mix 2 (e), # mem 3 (f), mix 3 (g), # mem 4 (h), mix 4 (i), # split 1 (j), recyc valve (k) # environment (l) verbose = 5 iIncidence = np.array( [ # a b c d e f g h i j k l [+1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1], # 1 [-1, +1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], # 2 [ 0, -1, +1, 0, 0, 0, 0, 0, 0, 0, 0, 0], # 3 [ 0, 0, -1, 0, +1, 0, 0, 0, 0, 0, 0, 0], # 4 [ 0, 0, -1, +1, 0, 0, 0, 0, 0, 0, 0, 0], # 5 [ 0, 0, 0, -1, +1, 0, 0, 0, 0, 0, 0, 0], # 6 [ 0, 0, 0, 0, -1, 0, +1, 0, 0, 0, 0, 0], # 7 [ 0, 0, 0, -1, 0, +1, 0, 0, 0, 0, 0, 0], # 8 [ 0, 0, 0, 0, 0, -1, +1, 0, 0, 0, 0, 0], # 9 [ 0, 0, 0, 0, 0, 0, -1, 0, +1, 0, 0, 0], # 10 [ 0, 0, 0, 0, 0, -1, 0, +1, 0, 0, 0, 0], # 11 [ 0, 0, 0, 0, 0, 0, 0, -1, +1, 0, 0, 0], # 12 [ 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, +1], # 13 [ 0, 0, 0, 0, 0, 0, 0, -1, 0, +1, 0, 0], # 14 [ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, +1], # 15 [ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, +1, 0], # 16 [+1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0], # 17 ] ) check_incidence(iIncidence) # define coordinates for plotting process graph coordinates = np.array([ [ 0, 0], # a [ 1, 0], # b [ 2, 0], # c [ 3, 0], # d [ 3,-1], # e [ 4, 0], # f [ 4,-1], # g [ 5, 0], # h [ 5,-1], # i [ 5, 1], # j [ 1, 1], # k [ 2, 1.25], # l ] ) pgraph = define_system( iIncidence=iIncidence, coordinates = coordinates, verbose=verbose, arcSplitter =[[14 - 1, 15 - 1, 16 - 1]], arcEqualComposition = [[2-1, 3-1], [14 - 1, 15 - 1, 16 - 1, 17 - 1]], numberOfComponents = 3, ) pgraph.add_graph_info(verbose=5) xMeasured_default = pgraph.xMeasured # plot pgraph_path = os.path.join(module_path, "documenting_failures", "soar_pgraphs", "pilot_pgraph.pkl") if not os.path.exists(pgraph_path): with open(pgraph_path, "wb") as f: pickle.dump(pgraph, f) else: with open(pgraph_path, "rb") as f: pgraph = pickle.load(f) No newline at end of file Loading
documenting_failures/setup_example_soar.py +4 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,10 @@ import sys import os from sympy import symbols 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_wwtp/soar/python/soar") if soar_path not in sys.path: sys.path.insert(0, soar_path) Loading
documenting_failures/soar_pgraphs/generate_pgraph.py 0 → 100644 +118 −0 Original line number Diff line number Diff line import os import sys import pickle import random import traceback import yaml import numpy as np from time import time 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_wwtp/soar/python/soar") if soar_path not in sys.path: sys.path.insert(0, soar_path) else: print("soar toolbox already in path") # add module_path = os.path.dirname(os.path.abspath("")) if module_path not in sys.path: sys.path.insert(0, module_path) else: print("path already in sys.path") from soar.graph_labeling.genobs.fGenObs import general_observability from soar.graph_labeling.genred.fGenRed import genred from soar.graph_labeling.fDefineSystem import ProcessGraph from setup_example_soar import define_system, get_pareto_front, get_one_result from soar.optimization.fEvaluate import evaluate_obs_red # for plotting from soar.graph_labeling.fPlotGraph import plot_graph import matplotlib.pyplot as plt from numerical_labelling.labelling import * # compare to soar from build_test_cases_nl import build_test_case_nl, make_layout import soar.optimization.fEvaluate as feval import matplotlib.pyplot as plt # save the pgraph object so we don't have to wait for 7 minutes each time import pickle def check_incidence(iIncidence): """ simple check that in nodes equal to out nodes (graph is closed) """ for row in iIncidence: assert sum(row) == 0, f"Incidence matrix row sums to {sum(row)}" # establish pilot graph: # 12 nodes: # mix (a), pump (b), mem 1 (c), # mem 2 (d), mix 2 (e), # mem 3 (f), mix 3 (g), # mem 4 (h), mix 4 (i), # split 1 (j), recyc valve (k) # environment (l) verbose = 5 iIncidence = np.array( [ # a b c d e f g h i j k l [+1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1], # 1 [-1, +1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], # 2 [ 0, -1, +1, 0, 0, 0, 0, 0, 0, 0, 0, 0], # 3 [ 0, 0, -1, 0, +1, 0, 0, 0, 0, 0, 0, 0], # 4 [ 0, 0, -1, +1, 0, 0, 0, 0, 0, 0, 0, 0], # 5 [ 0, 0, 0, -1, +1, 0, 0, 0, 0, 0, 0, 0], # 6 [ 0, 0, 0, 0, -1, 0, +1, 0, 0, 0, 0, 0], # 7 [ 0, 0, 0, -1, 0, +1, 0, 0, 0, 0, 0, 0], # 8 [ 0, 0, 0, 0, 0, -1, +1, 0, 0, 0, 0, 0], # 9 [ 0, 0, 0, 0, 0, 0, -1, 0, +1, 0, 0, 0], # 10 [ 0, 0, 0, 0, 0, -1, 0, +1, 0, 0, 0, 0], # 11 [ 0, 0, 0, 0, 0, 0, 0, -1, +1, 0, 0, 0], # 12 [ 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, +1], # 13 [ 0, 0, 0, 0, 0, 0, 0, -1, 0, +1, 0, 0], # 14 [ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, +1], # 15 [ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, +1, 0], # 16 [+1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0], # 17 ] ) check_incidence(iIncidence) # define coordinates for plotting process graph coordinates = np.array([ [ 0, 0], # a [ 1, 0], # b [ 2, 0], # c [ 3, 0], # d [ 3,-1], # e [ 4, 0], # f [ 4,-1], # g [ 5, 0], # h [ 5,-1], # i [ 5, 1], # j [ 1, 1], # k [ 2, 1.25], # l ] ) pgraph = define_system( iIncidence=iIncidence, coordinates = coordinates, verbose=verbose, arcSplitter =[[14 - 1, 15 - 1, 16 - 1]], arcEqualComposition = [[2-1, 3-1], [14 - 1, 15 - 1, 16 - 1, 17 - 1]], numberOfComponents = 3, ) pgraph.add_graph_info(verbose=5) xMeasured_default = pgraph.xMeasured # plot pgraph_path = os.path.join(module_path, "documenting_failures", "soar_pgraphs", "pilot_pgraph.pkl") if not os.path.exists(pgraph_path): with open(pgraph_path, "wb") as f: pickle.dump(pgraph, f) else: with open(pgraph_path, "rb") as f: pgraph = pickle.load(f) No newline at end of file