Esempio n. 1
0
    def test_default_scramble_strategy(self):

        bn = template_behaviour_generator(5, 2, 0.5, 0.0, 1, 0).new()
        bn_copy = BooleanNetwork.from_json(bn.to_json())

        bn_copy, flips = bn_scramble_strategy(bn_copy, 1)

        self.assertFalse(bn.to_json() == bn_copy.to_json())

        bn_copy = edit_boolean_network(bn_copy, flips)

        self.assertTrue(bn.to_json() == bn_copy.to_json())
Esempio n. 2
0
    def test_bn_update(self):
        bn = template_behaviour_generator(5, 2, 0.5, 0.0, 1, 0).new()

        bn_copy = BooleanNetwork.from_json(bn.to_json())

        matching_states = []

        for _ in range(10):

            s1 = binstate(bn.update())
            s2 = binstate(bn_copy.update())

            matching_states.append(s1 == s2)

        self.assertTrue(all(matching_states))
Esempio n. 3
0
from pathlib import Path
from pandas import DataFrame
from pprint import pprint
from bncontroller.sim.utils import GLOBALS, load_global_config
from bncontroller.boolnet.selector import SelectiveBooleanNetwork
from bncontroller.boolnet.structures import BooleanNetwork
from bncontroller.jsonlib.utils import read_json
from bncontroller.filelib.utils import get_dir

if __name__ == "__main__":

    load_global_config()

    for path in get_dir(GLOBALS.bn_model_path).iterdir():

        if path.is_file():
            bn: BooleanNetwork = BooleanNetwork.from_json(read_json(path))

            print(str(path))
            print(DataFrame(bn.atm.dtableau).T)
            print(bn.atm.tableau)
            for k, a in bn.atm.dattractors.items():
                print(k, a)
            print(bn.atm.attractors)
Esempio n. 4
0
    def test_ebnf(self):
        bn = template_behaviour_generator(5, 2, 0.5, 0.0, 1, 0).new()

        bn_copy = BooleanNetwork.from_json(bn.to_json())

        self.assertTrue(bn.to_ebnf(), bn_copy.to_ebnf())
Esempio n. 5
0
 def c2no1(bnname, c):
     # bnname, c = cols
     print(bnname)
     bn = BooleanNetwork.from_json(
         read_json(GLOBALS.bn_model_path / 'stats/models' / bnname))
     return c if len(bn.atm.attractors) > 1 else False