def synthesize_with_dreal(crn):
    derivatives = [{"variable": 'PThree', "order": 1, "is_variance": False, "name": "PThree_dot"}]
    flow = crn.flow(False, derivatives)

    #specification_dreal = [('', '', 'PThree > 0.4 '), ('', '', 'PThree < 0.3')]
    specification_dreal = [('','PThree_dot >= 0','and (PThree_dot < 0.01) (PThree > 0.4) '),('','PThree_dot <= 0','(PThree < 0.3)')]
    #specification_dreal = [('', 'PThree_dot >= 0', '(and (PThree > 0.3) (PThree_dot = 0))'), ('', 'PThree_dot <= 0', '(and (PThree >= 0)(PThree < 0.1))')]

    drh = iSATParser.constructdReal(crn, specification_dreal, flow, other_constraints='(PThree < 0.4)',scale_factor=1)
    with open('sixreactionnetwork.drh', 'w') as file:
        file.write(drh)

    sc = SolverCallerDReal("./sixreactionnetwork.drh", dreal_path="../dReal-3.16.09.01-linux/bin/dReach")
    result_files = sc.single_synthesis(cost=0, precision=0.1)

    for file_name in result_files:
            vals, all_vals = sc.getCRNValues('./sixreactionnetwork_1_0.smt2.proof')
            initial_conditions, parametrised_flow = sc.get_full_solution(crn, flow, all_vals)

            print("Initial Conditions", initial_conditions)
            print("Flow:", parametrised_flow)
            t, sol, variable_names = sc.simulate_solutions(initial_conditions, parametrised_flow,
                                                           plot_name=file_name + "-simulationdreal.png", t = linspace(0, 10, 1000))
            print("\n\n")
            print(variable_names)
            print(sol)
            savetxt(file_name + "-simulationdreal.csv", sol, delimiter=",")
Beispiel #2
0
def synthesize_with_dreal(crn):

    isLNA = False
    derivatives = []
    #specification_dreal = [('','','')]
    specification_dreal = [('', '', '(and (inputTime > 70)(cIts > 10))')]
    flow = crn.flow(False, derivatives)
    drh = iSATParser.constructdReal(crn,
                                    specification_dreal,
                                    flow,
                                    max_time=100)
    with open('toggleswitch.drh', 'w') as file:
        file.write(drh)

    sc = SolverCallerDReal("./toggleswitch.drh",
                           dreal_path="../dReal-3.16.09.01-linux/bin/dReach")
    result_files = sc.single_synthesis(cost=0, precision=0.1)

    for file_name in result_files:
        vals, all_vals = sc.getCRNValues('./toggleswitch_0_0.smt2.proof')
        initial_conditions, parametrised_flow = sc.get_full_solution(
            crn, flow, all_vals)

        print("Initial Conditions", initial_conditions)
        print("Flow:", parametrised_flow)
        t, sol, variable_names = sc.simulate_solutions(
            initial_conditions,
            parametrised_flow,
            plot_name=file_name + "-simulationdreal.png",
            t=linspace(0, 100, 200))  # mode_times=all_vals["time"])

        print("\n\n")
        print(variable_names)
        print(sol)
        savetxt(file_name + "-simulationdreal.csv", sol, delimiter=",")
Beispiel #3
0
def synthesize_with_dreal(crn):
    derivatives = []
    flow = crn.flow(False, derivatives)

    specification_dreal = [('', '', '(X < 0.1)')]
    drh = iSATParser.constructdReal(crn, specification_dreal, flow)
    with open('simple.drh', 'w') as file:
        file.write(drh)

    sc = SolverCallerDReal("./simple.drh", dreal_path="../dReal-3.16.09.01-linux/bin/dReach")
    result_files = sc.single_synthesis(cost=0)

    for file_name in result_files:
        print("\n\n")
        # print(sc.getCRNValues(file_name))

        vals, all_vals = sc.getCRNValues(file_name)
        initial_conditions, parametrised_flow = sc.get_full_solution(crn, flow, all_vals)

        print("Initial Conditions", initial_conditions)
        print("Flow:", parametrised_flow)

        t, sol, variable_names = sc.simulate_solutions(initial_conditions, parametrised_flow,
                                                       plot_name=file_name + "-simulationdreal.png")
        print("\n\n")
        print(variable_names)
        print(sol)
        savetxt(file_name + "-simulationdreal.csv", sol, delimiter=",")
def synthesize_with_dreal(crn):


    derivatives = [{"variable": 'PThreeStar', "order": 1, "is_variance": False, "name": "PThreeStar_dot"}]
    flow = crn.flow(False, derivatives)


    specification_dreal = [('', '', '(inputTime > 20)'),
                           ('', '(PThreeStar_dot > 0)', '(and (PThreeStar > 0.5)(abs(PThreeStar_dot) < 0.01))'),
                           ('', 'abs(PThreeStar_dot) < 0.01', 'inputTime > 100')]

    #flow = crn.flow(False, derivatives)
    #specification_dreal = [('', '', '')]

    drh = iSATParser.constructdReal(crn, specification_dreal, flow, max_time=350, other_constraints='', scale_factor=1)
    with open('switch.drh', 'w') as file:
        file.write(drh)

    sc = SolverCallerDReal("./switch.drh", dreal_path="../dReal-3.16.09.01-linux/bin/dReach")
    result_files = sc.single_synthesis(cost=0, precision=0.1, max_depth=len(specification_dreal))

    for file_name in result_files:
        vals, all_vals = sc.getCRNValues('./switch_2_0.smt2.proof')
        initial_conditions, parametrised_flow = sc.get_full_solution(crn, flow, all_vals)

        print("Initial Conditions", initial_conditions)
        print("Flow:", parametrised_flow)
        t, sol, variable_names = sc.simulate_solutions(initial_conditions, parametrised_flow,
                                                       plot_name=file_name + "-simulationdreal.png",
                                                       t=linspace(0, 300, 1000))
        print("\n\n")
        print(variable_names)
        print(sol)
        savetxt(file_name + "-simulationdreal.csv", sol, delimiter=",")
def synthesize_with_dreal(crn):
    derivatives = []
    flow = crn.flow(True, derivatives)

    specification_dreal = [('', 'varA >= A', 'A > 0.3')]
    #specification_dreal = [('','','')]
    drh = iSATParser.constructdReal(crn,
                                    specification_dreal,
                                    flow,
                                    max_time=20)
    with open('superpoisson.drh', 'w') as file:
        file.write(drh)

    sc = SolverCallerDReal("./superpoisson.drh",
                           dreal_path="../dReal-3.16.09.01-linux/bin/dReach")
    result_files = sc.single_synthesis(cost=0, precision=0.1)

    for file_name in result_files:
        vals, all_vals = sc.getCRNValues('./superpoisson_0_0.smt2.proof')
        initial_conditions, parametrised_flow = sc.get_full_solution(
            crn, flow, all_vals)

        print("Initial Conditions", initial_conditions)
        print("Flow:", parametrised_flow)
        t, sol, variable_names = sc.simulate_solutions(initial_conditions,
                                                       parametrised_flow,
                                                       plot_name=file_name +
                                                       "-simulationdreal.png",
                                                       t=linspace(0, 20, 100),
                                                       lna=True)
        print("\n\n")
        print(variable_names)
        print(sol)
        savetxt(file_name + "-simulationdreal.csv", sol, delimiter=",")
def synthesize_with_dreal(crn):

    derivatives = [{
        "variable": 'PThreeStar',
        "order": 1,
        "is_variance": False,
        "name": "PThreeStar_dot"
    }]
    flow = crn.flow(False, derivatives)

    # specification_dreal = [('', '', 'PThree > 0.4 '), ('', '', 'PThree < 0.3')]
    # specification_dreal = [('','','(PThreeStar > 0.5) '),('','','(PThreeStar < 0.4)')]
    # specification_dreal = [('', 'PThree_dot >= 0', '(and (PThree > 0.3) (PThree_dot = 0))'), ('', 'PThree_dot <= 0', '(and (PThree >= 0)(PThree < 0.1))')]
    # specification_dreal = [('', '', '(and ((inputTime > 100)(PThreeStar < 0.75))'),
    #  ('', '', '(PThreeStar > 0.9)')]

    specification_dreal = [('', '', 'inputTime > 20'),
                           ('', 'PThreeStar_dot < 0', '(PThreeStar_dot=0)'),
                           ('', 'PThreeStar_dot > 0', '(PThreeStar_dot=0)'),
                           ('', 'PThreeStar_dot < 0', 'PThreeStar_dot = 0'),
                           ('', 'PThreeStar_dot = 0', 'inputTime > 100')]

    #flow = crn.flow(False, [])

    drh = iSATParser.constructdReal(crn,
                                    specification_dreal,
                                    flow,
                                    max_time=350,
                                    other_constraints='',
                                    scale_factor=1)
    with open('topology365.drh', 'w') as file:
        file.write(drh)

    sc = SolverCallerDReal("./topology365.drh",
                           dreal_path="../dReal-3.16.09.01-linux/bin/dReach")
    result_files = sc.single_synthesis(cost=0, precision=0.1)

    for file_name in result_files:
        vals, all_vals = sc.getCRNValues('./topology365_0_0.smt2.proof')
        initial_conditions, parametrised_flow = sc.get_full_solution(
            crn, flow, all_vals)

        print("Initial Conditions", initial_conditions)
        print("Flow:", parametrised_flow)
        t, sol, variable_names = sc.simulate_solutions(
            initial_conditions,
            parametrised_flow,
            plot_name=file_name + "-simulationdreal.png",
            t=linspace(0, 300, 1000),
            hidden_variables="POne,POneStar,PTwo,PTwoStar,PThree")
        print("\n\n")
        print(variable_names)
        print(sol)
        savetxt(file_name + "-simulationdreal.csv", sol, delimiter=",")
Beispiel #7
0
def synthesize_with_dreal(crn, name, specification_dreal, result_file):

    derivatives = [{
        "variable": 'PThreeStar',
        "order": 1,
        "is_variance": False,
        "name": "PThreeStar_dot"
    }]
    flow = crn.flow(False, derivatives)

    #flow = crn.flow(False, derivatives)
    #specification_dreal = [('', '', '')]

    drh = iSATParser.constructdReal(crn,
                                    specification_dreal,
                                    flow,
                                    max_time=350 / SF,
                                    other_constraints='',
                                    scale_factor=SF)
    with open(name, 'w') as file:
        file.write(drh)

    #sc = SolverCallerDReal(name, dreal_path="/code/dReal-3.16.06.02-linux/bin/dReach")
    sc = SolverCallerDReal(
        name, dreal_path="/code/dReal-3.16.09.01-linux/bin/dReach")
    result_files = sc.single_synthesis(cost=0, precision=0.1)

    for file_name in [result_file]:  # TODO: remove ths aegument

        print file_name

        # './inverted-bell_3_0.smt2.proof'
        vals, all_vals = sc.getCRNValues(file_name)
        initial_conditions, parametrised_flow = sc.get_full_solution(
            crn, flow, all_vals)

        print("Initial Conditions", initial_conditions)
        print("Flow:", parametrised_flow)
        t, sol, variable_names = sc.simulate_solutions(
            initial_conditions,
            parametrised_flow,
            plot_name=file_name + "-simulationdreal.png",
            t=linspace(0, 350, 1000),
            mode_times=all_vals["time"],
            hidden_variables="POne,POneStar,PTwo,PTwoStar,PThree")
        print("\n\n")
        print(variable_names)
        print(sol)
        savetxt(file_name + "-simulationdreal.csv", sol, delimiter=",")
Beispiel #8
0
def synthesize_with_dreal(crn):
    derivatives = [{
        "variable": 'L3p',
        "order": 1,
        "is_variance": False,
        "name": "L3p_dot"
    }, {
        "variable": 'L3p',
        "order": 2,
        "is_variance": False,
        "name": "L3p_dot_dot"
    }]
    flow = crn.flow(False, derivatives)

    specification_dreal = [('', '(and (L3p_dot >= 0)(L3p_dot_dot >= 0))',
                            '(and (L3p_dot_dot = 0)(B > 4/SF))'),
                           ('', '(and (L3p_dot >= 0)(L3p_dot_dot <= 0))', '')]
    #specification_dreal = [('','','')]
    drh = iSATParser.constructdReal(crn,
                                    specification_dreal,
                                    flow,
                                    max_time=50 / SF,
                                    scale_factor=SF)
    with open('phosphorelay.drh', 'w') as file:
        file.write(drh)

    sc = SolverCallerDReal("./phosphorelay.drh",
                           dreal_path="../dReal-3.16.09.01-linux/bin/dReach")
    result_files = sc.single_synthesis(cost=0, precision=0.1)

    for file_name in result_files:
        vals, all_vals = sc.getCRNValues('./phosphorelay_1_0.smt2.proof')
        initial_conditions, parametrised_flow = sc.get_full_solution(
            crn, flow, all_vals, scale_factor=SF)

        print("Initial Conditions", initial_conditions)
        print("Flow:", parametrised_flow)
        t, sol, variable_names = sc.simulate_solutions(
            initial_conditions,
            parametrised_flow,
            plot_name=file_name + "-simulationdreal.png",
            t=linspace(0, 50 / SF, 100),
            mode_times=all_vals["time"],
            hidden_variables="B")
        print("\n\n")
        print(variable_names)
        print(sol)
        savetxt(file_name + "-simulationdreal.csv", sol, delimiter=",")