예제 #1
0
    except:
        subprocess.call(['python3', 'run_mixing.py', f'{T}', f'{args.dir}', f'{args.graph}', \
                        '--maxcorrtime', '10000', \
                        '--maxmixing', '10000'])
        mixingResults = IO.loadResults(targetDirectory, 'mixingResults')
        corrTimeSettings = IO.loadResults(targetDirectory, 'corrTimeSettings')
        burninSteps = mixingResults['burninSteps']
        distSamples = mixingResults['distSamples']


    systemSnapshotSettings = dict( \
        nSnapshots    = args.snapshots, \
        burninSteps   = int(burninSteps), \
        distSamples   = int(distSamples)
    )
    IO.saveSettings(targetDirectory, systemSnapshotSettings, 'systemSnapshots')

    selected_nodes = []
    remaining_nodes = list(graph)
    nodes_array = np.array(remaining_nodes)

    mi_greedy = {}
    h_greedy = {}

    mi_random = {}
    h_random = {}

    mi_brute_force = {}
    h_brute_force = {}

    if args.bruteForce:
예제 #2
0
    temps = np.linspace(args.minT, args.maxT, args.numT)
    nSamples      = int(1e4)
    burninSteps   = int(1e4)
    magSide       = ''
    updateType    = 'async'


    targetDirectory = f'{os.getcwd()}/{args.dir}'
    os.makedirs(targetDirectory, exist_ok=True)

    settings = dict(
        nSamples         = nSamples, \
        burninSteps      = burninSteps, \
        updateMethod     = updateType
        )
    IO.saveSettings(targetDirectory, settings)

    for i, g in enumerate(ensemble):

        graph = nx.read_gpickle(g)
        filename = os.path.split(g)[-1].strip('.gpickle')

        modelSettings = dict(\
                             graph       = graph,\
                             updateType  = updateType,\
                             magSide     = magSide
                             )
        model = fastIsing.Ising(**modelSettings)

        Tc = Tc_idx = -1
        while Tc < 0:
    args = parser.parse_args()

    T = args.T  #float(sys.argv[1])
    targetDirectory = args.dir  #sys.argv[2]
    os.makedirs(targetDirectory, exist_ok=True)

    # load network
    graph = nx.read_gpickle(args.graph)
    N = len(graph)

    networkSettings = dict( \
        path = args.graph, \
        nNodes = N
    )
    IO.saveSettings(targetDirectory, networkSettings, 'network')

    # setup Ising model with nNodes spin flip attempts per simulation step
    modelSettings = dict( \
        temperature     = T, \
        updateType      = 'async' ,\
        magSide         = ''
    )
    #IO.saveSettings(targetDirectory, modelSettings, 'model')
    model = fastIsing.Ising(graph, **modelSettings)

    #print(model.mapping)
    #print(list(graph))

    # determine mixing/correlation time
    mixingTimeSettings = dict( \
예제 #4
0
                snapshots.append(s)

            MI, HX = computeMI_cond(model, node, minDist, maxDist,
                                    allNeighbours_G, snapshots, nTrials,
                                    nSamples, modelSettings)
            MIs_cond[T] = MI

            snapshotSettingsJoint = dict( \
                nSamples    = args.numSamplesJoint, \
                repeats     = args.repeats, \
                burninSteps = args.burninSteps, \
                distSamples = args.distSamples, \
                maxDist     = maxDist, \
                nBins       = args.bins
            )
            IO.saveSettings(targetDirectory, snapshotSettingsJoint,
                            'jointSnapshots')

            allNeighbours_G_allNodes = model.neighboursAtDistAllNodes(
                nodes, maxDist)

            avgSnapshots, avgSystemSnapshots, fullSnapshots = simulation.getJointSnapshotsPerDistNodes(model, nodes, \
                                                                                allNeighbours_G_allNodes, \
                                                                                **snapshotSettingsJoint, threads=nthreads, \
                                                                                initStateIdx=1, getFullSnapshots=1)

            MI, corr = infoTheory.pairwiseMI_allNodes(
                model,
                nodes,
                fullSnapshots.reshape(
                    (args.repeats * args.numSamplesJoint, -1)),
                distMax=maxDist)