コード例 #1
0
ファイル: ModelRealExp2.py プロジェクト: charanpald/wallhack
    def simulateModel(theta):
        """
        The parameter t is the particle index. 
        """
        logging.debug("theta=" + str(theta))
 
        #We start with the observed graph at the start date 
        graph = targetGraph.subgraph(targetGraph.removedIndsAt(startDate)) 
        graph.addVertices(M-graph.size)

        p = Util.powerLawProbs(alpha, zeroVal)
        hiddenDegSeq = Util.randomChoice(p, graph.getNumVertices())
        
        featureInds = numpy.ones(graph.vlist.getNumFeatures(), numpy.bool)
        featureInds[HIVVertices.dobIndex] = False 
        featureInds[HIVVertices.infectionTimeIndex] = False 
        featureInds[HIVVertices.hiddenDegreeIndex] = False 
        featureInds[HIVVertices.stateIndex] = False
        featureInds = numpy.arange(featureInds.shape[0])[featureInds]
        matcher = GraphMatch(matchAlg, alpha=matchAlpha, featureInds=featureInds, useWeightM=False)
        graphMetrics = HIVGraphMetrics2(targetGraph, breakSize, matcher, float(endDate))
        
        recordStep = (endDate-startDate)/float(numRecordSteps)
        rates = HIVRates(graph, hiddenDegSeq)
        model = HIVEpidemicModel(graph, rates, T=float(endDate), T0=float(startDate), metrics=graphMetrics)
        model.setRecordStep(recordStep)
        model.setParams(theta)
        
        model.simulate() 
    
        objective = model.objective()
        return objective
コード例 #2
0
ファイル: UtilTest.py プロジェクト: charanpald/sandbox
    def testPowerLawProbs(self):
        alpha = 3
        zeroVal = 0.1
        maxInt = 100

        p = Util.powerLawProbs(alpha, zeroVal, maxInt)

        self.assertTrue(p.shape[0] == maxInt)
コード例 #3
0
    def testPowerLawProbs(self):
        alpha = 3
        zeroVal = 0.1
        maxInt = 100

        p = Util.powerLawProbs(alpha, zeroVal, maxInt)

        self.assertTrue(p.shape[0] == maxInt)
コード例 #4
0
    def setUp(self):
        numpy.seterr(invalid='raise')
        logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
        numpy.set_printoptions(suppress=True, precision=4, linewidth=100)
        numpy.random.seed(21)

        M = 1000
        undirected = True

        graph = HIVGraph(M, undirected)
        alpha = 2
        zeroVal = 0.9
        p = Util.powerLawProbs(alpha, zeroVal)
        hiddenDegSeq = Util.randomChoice(p, graph.getNumVertices())
        rates = HIVRates(graph, hiddenDegSeq)

        self.numParams = 6
        self.graph = graph
        self.meanTheta = numpy.array([100, 0.9, 0.05, 0.001, 0.1, 0.005])
        self.hivAbcParams = HIVABCParameters(self.meanTheta, self.meanTheta/2)