def getEpsilonElasticityMatrix2(pathwayProxy): """ calculate and return the elasticities (matrix) pathwayProxy: a PathwayProxy instance return elasticityMatrix """ variableList = pathwayProxy.getVariableList() processList = pathwayProxy.getProcessList() elasticityMatrix = numpy.zeros((len(variableList), len(processList)), float) incidentMatrix = pathwayProxy.getIncidentMatrix() independentGroupList = createIndependentGroupList(incidentMatrix) activityBuffer = numpy.zeros(len(processList), float) aSession = pathwayProxy.theEmlSupport.createSession() aSession.theSimulator.initialize() for i in range(len(processList)): activityBuffer[i] = aSession.theSimulator.getEntityProperty(processList[i] + ":Activity") for groupList in independentGroupList: aSession = pathwayProxy.theEmlSupport.createSession() perturbationList = [] for i in groupList: fullPN = variableList[i] + ":Value" value = aSession.theSimulator.getEntityProperty(fullPN) aPerturbation = RELATIVE_PERTURBATION * value + ABSOLUTE_PERTURBATION perturbationList.append(aPerturbation) aSession.theSimulator.setEntityProperty(fullPN, value + aPerturbation) aSession.theSimulator.initialize() for c in range(len(groupList)): i = groupList[c] aPerturbation = perturbationList[c] for j in range(len(processList)): if incidentMatrix[i][j]: elasticityMatrix[i][j] = ( aSession.theSimulator.getEntityProperty(processList[j] + ":Activity") - activityBuffer[j] ) / aPerturbation return elasticityMatrix
def getJacobianMatrix2( pathwayProxy ): ''' calculate and return the Jacobian matrix (array) pathwayProxy: a PathwayProxy instance return aJacobian ''' variableList = pathwayProxy.getVariableList() size = len( variableList ) aJacobianMatrix = numpy.zeros( ( size, size ), float ) incidentMatrix = numpy.dot( pathwayProxy.getIncidentMatrix(), numpy.transpose( pathwayProxy.getIncidentMatrix( 1 ) ) ) independentGroupList = createIndependentGroupList( incidentMatrix ) velocityBuffer = numpy.zeros( size, float ) aSession = pathwayProxy.theEmlSupport.createSession() aSession.theSimulator.initialize() for i in range( size ): velocityBuffer[ i ] = aSession.theSimulator.getEntityProperty( variableList[ i ] + ':Velocity' ) for groupList in independentGroupList: aSession = pathwayProxy.theEmlSupport.createSession() perturbationList = [] for i in groupList: fullPN = variableList[ i ] + ':Value' value = aSession.theSimulator.getEntityProperty( fullPN ) aPerturbation = RELATIVE_PERTURBATION * value + ABSOLUTE_PERTURBATION perturbationList.append( aPerturbation ) aSession.theSimulator.setEntityProperty( fullPN, value + aPerturbation ) aSession.theSimulator.initialize() for c in range( len( groupList ) ): i = groupList[ c ] aPerturbation = perturbationList[ c ] for j in range( len( variableList ) ): if incidentMatrix[ i ][ j ] != 0: aJacobianMatrix[ j ][ i ] = ( aSession.theSimulator.getEntityProperty( variableList[ j ] + ':Velocity' ) - velocityBuffer[ j ] ) / aPerturbation return aJacobianMatrix
def getEpsilonElasticityMatrix2( pathwayProxy ): ''' calculate and return the elasticities (matrix) pathwayProxy: a PathwayProxy instance return elasticityMatrix ''' variableList = pathwayProxy.getVariableList() processList = pathwayProxy.getProcessList() elasticityMatrix = numpy.zeros( ( len( variableList ), len( processList ) ), float ) incidentMatrix = pathwayProxy.getIncidentMatrix() independentGroupList = createIndependentGroupList( incidentMatrix ) activityBuffer = numpy.zeros( len( processList ), float ) aSession = pathwayProxy.theEmlSupport.createSession() aSession.theSimulator.initialize() for i in range( len( processList ) ): activityBuffer[ i ] = aSession.theSimulator.getEntityProperty( processList[ i ] + ':Activity' ) for groupList in independentGroupList: aSession = pathwayProxy.theEmlSupport.createSession() perturbationList = [] for i in groupList: fullPN = variableList[ i ] + ':Value' value = aSession.theSimulator.getEntityProperty( fullPN ) aPerturbation = RELATIVE_PERTURBATION * value + ABSOLUTE_PERTURBATION perturbationList.append( aPerturbation ) aSession.theSimulator.setEntityProperty( fullPN, value + aPerturbation ) aSession.theSimulator.initialize() for c in range( len( groupList ) ): i = groupList[ c ] aPerturbation = perturbationList[ c ] for j in range( len( processList ) ): if incidentMatrix[ i ][ j ]: elasticityMatrix[ i ][ j ] = ( aSession.theSimulator.getEntityProperty( processList[ j ] + ':Activity' ) - activityBuffer[ j ] ) / aPerturbation return elasticityMatrix