if args.seed != -1: np.random.seed(args.seed) pi = np.random.permutation(size) if args.seed is not None else np.array( [i for i in range(size)]) rng = default_rng() metricList = [Metric.Energy, Metric.Consensus] state = '$r_{stable}$' c_len = 'length' data = {c_len: [], state: [], 'fct': []} for metric in metricList: data[metric.name] = [] conf = create_config(c_type, n=args.n) states = states_per_magnet(size, 0.0) conf.set_states(states) for i, p in enumerate(r_factor): rules = rules_per_ratio(size, p) conf.set_rules(rules) evol, metrics = evolve(config=conf, perm=pi, steps=args.steps, metricList=metricList, cycleBreak=True) data[c_len].append(cycle_length(evol)[0]) rstab = p / (size - p) if size != p else np.inf data[state].append(rstab) data['fct'].append(p)
np.random.seed(args.seed) pi = np.random.permutation(args.n) metricList = [Metric.Energy, Metric.Consensus] magnetList = [0, 0.2, 0.4, 0.6, 0.8] agree = { 'init_magnet': [], 'length': [], 'Magnetization_mean': [], 'Magnetization_min': [], 'Magnetization_max': [], 'Magnetization_std': [], 'SpinGlass': [], 'unstables': [] } conf = create_config(ConfigType.Ring, n=args.n) for i, mag in enumerate(magnetList): init_states = [State.ON] * round((size * (0.5 + mag / 2)) - 10** (-9)) + [State.OFF] * round( (size * (0.5 - mag / 2) + 10**(-9))) np.random.seed() np.random.shuffle(init_states) init_rule = np.array([Rule.STABLE] * size) curr_rule = init_rule conf.set_rules(init_rule) conf.set_states(init_states) curr_magnet = mag stables = [0] while curr_magnet < 1 and stables != []: array, out = evolve(conf,
np.random.seed(args.seed) pi = np.random.permutation(size) metricList = [Metric.Energy, Metric.Consensus] magnetList = [0, 0.2, 0.4, 0.6, 0.8] agree = { 'init_magnet': [], 'length': [], 'Magnetization_mean': [], 'Magnetization_min': [], 'Magnetization_max': [], 'Magnetization_std': [], 'SpinGlass': [], 'unstables': [] } conf = create_config(ConfigType.Torus, n=args.n) rng = default_rng() for i, mag in enumerate(magnetList): init_states = [State.ON] * round((size * (0.5 + mag / 2)) - 10** (-9)) + [State.OFF] * round( (size * (0.5 - mag / 2) + 10**(-9))) rng.shuffle(init_states) init_rule = np.array([Rule.STABLE] * size) curr_rule = init_rule conf.set_rules(init_rule) conf.set_states(init_states) curr_magnet = mag stables = [0] while curr_magnet < 1 and stables != []:
type=int, default=0, help='first majority preference') parser.add_argument("-s", '--second', type=int, default=1, help='second majority preference') args = parser.parse_args() assert (args.first != args.second) size = args.n**2 c_type = ConfigType.Torus config = create_config(configType=c_type, n=args.n) magnetList = [-0.4, -0.3, -0.2, -0.1] stabList = [0.0, 0.2, 0.4, 0.5, 0.6, 0.8] pi = np.random.permutation(size) rules, metrics = setup() le = 'length' out = { 'init_magnet': [], 'Energy': [], 'Density': [], 'order': [], 'init_stab': [], le: [] }