def main(): args = sys.argv if len(args) != 2: print "usage: python ImportAnalysis.py path_to_root" sys.exit(1) root = args[1] dependencies = set() for dirpath, dirnames, filenames in os.walk(root): # print "dirpath={}, dirnames={}, filenames={}".format(dirpath, dirnames, filenames) for f in filenames: if f[-2:] == "py": if not dirpath.endswith(get_sep()): dirpath += get_sep() dependencies.update(analysis_import(dirpath + f)) print str(dependencies)
def get_parsed(cls, duration=730): sep = get_sep() mdl_dir = sep.join((get_proj_dir(), 'prism_model', 'smalltest.prism')) model = cls.model_constructor._parse(mdl_dir) model.duration = duration return model
def get_parsed(): sep = get_sep() mdl_dir = sep.join((get_proj_dir(), 'prism_model', 'smalltest.prism')) return ModelConstructor().parseModelFile(mdl_dir)
# -*- coding:utf-8 -*- from model.ModelFactory import ModelFactory from experiment.ExperimentWrapper import ExperimentWrapper from checker.Checker import Checker from module.Module import Constant from nn.NNRegressor import BPNeuralNetwork as BPNN from util.PlotHelper import plot_multi from PathHelper import get_prism_model_dir, get_sep, get_log_dir import logging from util.CsvFileHelper import parse_csv_cols logger = logging.getLogger("test parsed regressor log") logger.addHandler(logging.FileHandler(get_log_dir() + get_sep() + "testparsedregre.log", "w")) logger.setLevel(logging.INFO) def get_expr_result_prism(filepath): return parse_csv_cols(filepath) TIME_LIMIT_IN_DAYS = 365 ltl = ["U[1, {}]".format(int(TIME_LIMIT_IN_DAYS * 2)), "T", "failure"] prism_data_path = get_prism_model_dir() + get_sep() + "YEAR1_T_1_5_1" TEST_DATA_X, TEST_DATA_Y = get_expr_result_prism(prism_data_path) thickness_cnsts = map(lambda v: Constant("SCREEN_THICKNESS", v), TEST_DATA_X) SAMPLES_PER_PARAM = 400 def do_expr_built(): model = ModelFactory.get_built() checker = Checker(model=model, ltl=ltl, duration=TIME_LIMIT_IN_DAYS*2)
# -*- coding: utf-8 -*- # 验证思路 # 1. 对day变量随机取n(maybe 10?)个值,对每个模型的失效概率进行记日志,和PRISM中的stimulate结果进行对比,观察是否相同。 import logging from PathHelper import get_log_dir, get_sep from model.ModelFactory import ModelFactory logger = logging.getLogger("test model same logging") logPath = get_log_dir() + get_sep() + "testmodelsame.log" logger.addHandler(logging.FileHandler(logPath)) logger.setLevel(logging.INFO) def test(): built = ModelFactory.get_built() day_vals = range(1, 311, 50) logger.info("day_vals = {}".format(day_vals)) sb_module = built.getModuleByName("SB") sb_fail_cmd = sb_module.getCommand("sb_fail_cmd") s3r_module = built.getModuleByName("S3R") s3r_fail_cmd = s3r_module.getCommand("s3r_fail_cmd") for day_val in day_vals: built.setVariable("day", day_val) sb_fail_prob = sb_fail_cmd.prob()/4.0 s3r_fail_prob = s3r_fail_cmd.prob()/4.0 logger.info("day={}".format(day_val) + ", sb_fail_prob=" + format(sb_fail_prob, '.15e')) logger.info("day={}".format(day_val) + ", s3r_fail_prob=" + format(s3r_fail_prob, '.15e'))