コード例 #1
0
    def plot_checked(self):
        import pylab as pl
        pl.ioff()
        from statistics import expectation
        exp = []

        # The expectation plotter
        if len(self._stored_t) != 0:
            pl.figure(2)
            pl.title(" Method %s" % ("OFSP"))
            pl.xlabel("Time, t")
            pl.ylabel("Expectation")

            for i in range(len(self._stored_t)):
                exp.append(
                    expectation(
                        (self._stored_domain_states[i], self._stored_p[i])))

            EXP = np.array(exp).T

            for i in range(EXP.shape[0]):
                pl.plot(self._stored_t,
                        EXP[i, :],
                        'x-',
                        label=self.model.species[i])
            pl.legend()

        # The probability plotter
        if len(self._probed_t) != 0:
            pl.figure(3)
            pl.title(" Method %s | Probing States over Time " % ("OFSP"))
            pl.xlabel("Time, t")
            pl.ylabel("Probability")

            probs = np.array(self._probed_probs).T

            for i in range(probs.shape[0]):
                pl.plot(self._probed_t,
                        probs[i, :],
                        'x-',
                        label=str(self._probed_states[0][:, i]))
            pl.legend()

        pl.show()
コード例 #2
0
ファイル: Hybrid_FSP.py プロジェクト: oaarscorp/CME
    def set_initial_values(self, domain_states, p, t=0.0):
        """
		initialise the hybrid solver with the OFSP state space and probabiltiy. The function will automatically do the projection.

		Parameters
		----------------------
		domain_states 	: numpy.ndarray
							shape = (num of species x num of states)
		p 				: numpy.ndarray
							shape = (num of states,)
		t 				: numpy.ndarray
							Default = 0.0
		"""

        from Hybrid.Support_Expander import positions

        # We project them down

        from Hybrid.proj import project_to_Hybrid as POH
        from statistics import expectation

        clean = p > 1e-9
        domain_states = domain_states[:, clean]
        p = p[clean]

        self.t = t

        self._X, self._w = POH(domain_states, p, self.stoc_vector)

        if self.model_name == "HL":
            self._X[self.deter_vector, :] = expectation(
                (domain_states, p))[self.deter_vector, np.newaxis]

        # These are the key hashing components needed to find adjacent states.

        self.domain_enum = Hybrid.state_enum.StateEnum(self._X,
                                                       self.stoc_vector)
        self._valid, self._position = positions(self._X, self._V_s,
                                                self.stoc_vector,
                                                self.domain_enum)
コード例 #3
0
ファイル: Hybrid_FSP.py プロジェクト: SysSynBio/PyME
	def set_initial_values(self,domain_states,p,t = 0.0):
		"""
		initialise the hybrid solver with the OFSP state space and probabiltiy. The function will automatically do the projection.

		Parameters
		----------------------
		domain_states 	: numpy.ndarray
							shape = (num of species x num of states)
		p 				: numpy.ndarray
							shape = (num of states,)
		t 				: numpy.ndarray
							Default = 0.0
		"""

		from Hybrid.Support_Expander import positions

		# We project them down

		from Hybrid.proj import project_to_Hybrid as POH
		from statistics import expectation

		clean = p > 1e-9
		domain_states = domain_states[:,clean]
		p = p[clean]

		self.t = t

		self._X, self._w = POH(domain_states,p,self.stoc_vector)

		if self.model_name == "HL":
			self._X[self.deter_vector,:] =  expectation((domain_states,p))[self.deter_vector,np.newaxis]

		# These are the key hashing components needed to find adjacent states.

		self.domain_enum = Hybrid.state_enum.StateEnum(self._X,self.stoc_vector)
		self._valid, self._position = positions(self._X, self._V_s, self.stoc_vector, self.domain_enum)
コード例 #4
0
ファイル: OFSP.py プロジェクト: SysSynBio/PyME
	def plot_checked(self):
		import pylab as pl
		pl.ioff()
		from statistics import expectation
		exp = []

		# The expectation plotter
		if len(self._stored_t) != 0:
			pl.figure(2)
			pl.title(" Method %s"%("OFSP"))
			pl.xlabel("Time, t")
			pl.ylabel("Expectation")

			for i in range(len(self._stored_t)):
				exp.append(expectation((self._stored_domain_states[i],self._stored_p[i])))

			EXP = np.array(exp).T

			for i in range(EXP.shape[0]):
				pl.plot(self._stored_t,EXP[i,:],'x-',label=self.model.species[i])
			pl.legend()

		# The probability plotter
		if len(self._probed_t) != 0:
			pl.figure(3)
			pl.title(" Method %s | Probing States over Time "%("OFSP"))
			pl.xlabel("Time, t")
			pl.ylabel("Probability")

			probs = np.array(self._probed_probs).T

			for i in range(probs.shape[0]):
				pl.plot(self._probed_t,probs[i,:],'x-',label=str(self._probed_states[0][:,i]))
			pl.legend()

		pl.show()
コード例 #5
0
ファイル: OFSP.py プロジェクト: rkosarwal/isp
    def plot_checked(self):
        import pylab as pl
        pl.ioff()
        from statistics import expectation
        exp = []

        # The expectation plotter
        if len(self._stored_t) != 0:
            pl.figure(2)
            pl.title(" Method %s" % ("OFSP"))
            pl.xlabel("Time, t")
            pl.ylabel("Expectation")
            pl.grid(True)

            for i in range(len(self._stored_t)):
                exp.append(
                    expectation(
                        (self._stored_domain_states[i], self._stored_p[i])))

            EXP = np.array(exp).T

            expect_value_data = []
            for i in range(EXP.shape[0]):
                expect_value_data.append(EXP[i, :])
                pl.plot(self._stored_t,
                        EXP[i, :],
                        'x-',
                        label=self.model.species[i])
            pl.legend()
            pl.savefig("figureExpectation.png", dpi=180, bbox_width="tight")
            pl.clf()
            pl.close()

            expectation_data = []
            expectation_data.append(self._stored_t)
            for data in expect_value_data:
                expectation_data.append(data.tolist())
            np.savetxt('dataexpectation.csv',
                       np.column_stack(expectation_data),
                       delimiter=',')

        # The probability plotter
        if len(self._probed_t) != 0:
            pl.figure(3)
            pl.title(" Method %s | Probing States over Time " % ("OFSP"))
            pl.xlabel("Time, t")
            pl.ylabel("Probability")
            pl.grid(True)
            probs = np.array(self._probed_probs).T

            probabilities_data = []
            for i in range(probs.shape[0]):
                probabilities_data.append(probs[i, :])
                pl.plot(self._probed_t,
                        probs[i, :],
                        'x-',
                        label=str(self._probed_states[0][:, i]))
            pl.legend()
            pl.savefig("figureStatesExaming.png", dpi=180, bbox_width="tight")
            pl.clf()
            pl.close()

            isp_position_data = []
            isp_position_data.append(self._stored_t)
            for data in probabilities_data:
                isp_position_data.append(data.tolist())
            np.savetxt('dataStatesExaming.csv',
                       np.column_stack(isp_position_data),
                       delimiter=',')