Ejemplo n.º 1
0
def dpcov(a, b, window):
    valuesA = []
    valuesB = []
    for i in range(len(a)):
        if a[i].timeStamp != b[i].timeStamp:
            print("ERROR in dpcov: timestamp mismatch")
            return -1
    return [DataPoint(a[window+i-1].timeStamp, np.cov(valuesA[i:window+i]), valuesB[i:window+i])[0][1] for i in range(len(a) - window + 1)]
Ejemplo n.º 2
0
    def pass_up(self, data: NetworkDataPoint):
        print("Received data from %d:" % data.address, data.value)
        new_mod = False
        if data.address not in self.modules:
            print("New module! address =", data.address)
            self.modules[data.address] = Module(self, data.address)
            new_mod = True

        idd = data.value[0]
        val = data.value[1:]

        self.modules[data.address].pass_up(DataPoint(idd, val))

        if new_mod:
            self.modules[data.address].subscribe()
Ejemplo n.º 3
0
    def strong_branching(self, model, graph, soln_value, data=False):
        frac_vars = [(index, var[0]) for index, var in soln_value[1].items() if 0 < var[1] < 1]
        obj = soln_value[0]
        sb_scores = {}
        for branch_var in frac_vars:
            lp0 = model.copy()
            lp1 = model.copy()

            var0 = lp0.getVarByName(branch_var[1])
            lp0.addConstr(var0, grb.GRB.EQUAL, 0)

            var1 = lp1.getVarByName(branch_var[1])
            lp1.addConstr(var1, grb.GRB.EQUAL, 1)

            lp0.update()
            lp1.update()

            obj0, lp0_soln = self.node_lower_bound(lp0, self.var_dict, self.graph)
            obj1, lp1_soln = self.node_lower_bound(lp1, self.var_dict, self.graph)

            sb_score = abs(obj - obj0)*abs(obj - obj1)/(obj**2)
            sb_scores[sb_score] = branch_var

        if not sb_scores:
            return None

        print("strong branching scores: ", sb_scores)
        if data:
            lp_solution_values = {index: var[1] for index, var in soln_value[1].items()}
            nx.set_edge_attributes(self.graph, lp_solution_values, name='solution')
            lp_soln = nx.to_numpy_matrix(self.graph, weight='solution')
            soln_adj_mat = lp_soln[lp_soln > 0] = 1
            adj_mat = nx.to_numpy_matrix(self.graph, weight='')
            weight_mat = nx.to_numpy_matrix(self.graph, weight='weight')
            for score, var in sb_scores.items():
                data = DataPoint.DataPoint(len(self.graph), lp_soln, soln_adj_mat, adj_mat, weight_mat, var[0], score)
                data.save()

        best_var = sb_scores[max(sb_scores, key=sb_scores.get)]

        return best_var
Ejemplo n.º 4
0
 def send(self):
     data = DataPoint(self.id, b"")
     self.module.pass_down(data)
Ejemplo n.º 5
0
 def pass_up(self, data: str):
     print("Got PING")
     if data[0] == 1:
         print("Responding PING")
         out = DataPoint(self.id, b"\x02")
         self.module.pass_down(out)
Ejemplo n.º 6
0
#! /usr/bin/env python

import sys
import DataPoint

canopyCenters = []

for line in sys.stdin:
    (kev, value) = line.split("\t")
    dp = DataPoint.DataPoint(value.strip())

    if len(canopyCenters) == False:
        canopyCenters.append(dp)

    else:
        insert = True

        for center in canopyCenters:
            insert = dp.checkT2(center)
            if insert == False:
                break

        if insert == True:
            canopyCenters.append(dp)
canopyCenters.append(dp)

for canopyCenter in canopyCenters:
    print("1\t" + canopyCenter.toString())
Ejemplo n.º 7
0
            summaryFile.close()

            dataValues = []
            # index ~ variable
            # 0 ~ initial volume lost
            # 1 ~ final volumes still lost
            # 2 ~ num bisecting nodes
            # 3 ~ num sprout nodes
            # 4 ~ num active sprout nodes
            # 5 ~ end relative VEGF concentration
            # 6 ~ end relative VEGFR-VEGF concentration
            for line in lines:
                value = float(line.split(",")[1].strip())
                dataValues.append(round(value, 2))

            point = DataPoint(vScale, aScale, dataValues[0] - dataValues[1], dataValues[2], dataValues[3])

            # Find max VEGF from the run
            filePath = dir + "\\Run_" + str(i) + "\\ProteinProfile.txt"
            summaryFile = open(filePath, "r")
            lines = summaryFile.readlines()
            summaryFile.close()

            maxVEGF = max([float(line.split(',')[3].strip()) for line in lines[1:]])
            maxBound = max([float(line.split(',')[5].strip()) for line in lines[1:]])
            point.SetMaxVEGF(maxVEGF)
            point.SetMaxBound(maxBound)
            dataPoints.append(point)

            vScale += paramStep
Ejemplo n.º 8
0
#! /usr/bin/env python

import sys
import DataPoint

file = open("dataPoints.txt","r")
canopyCenters = []

#taking data from the std input

for line in sys.stdin:
	dp = DataPoint.DataPoint(line.strip())

	if len(canopyCenters) == False:
		canopyCenters.append(dp)

	else:

		insert = True
		for center in canopyCenters:
			insert = dp.checkT2(center)
			if insert == False:
				break
		if insert == True:
			canopyCenters.append(dp)
canopyCenters.append(dp)

#printing data std output
for canopyCenter in canopyCenters:
	print("1\t" + canopyCenter.toString())
Ejemplo n.º 9
0
        if paramNum == 9:
            vScale = setScale
            aScale = round(currentParam, 2)
        else: # paramNum == 8
            vScale = round(currentParam, 2)
            aScale = setScale

        # index ~ variable
        # 0 ~ initial volume lost
        # 1 ~ final volumes still lost
        # 2 ~ num bisecting nodes
        # 3 ~ num sprout nodes
        # 4 ~ num active sprout nodes
        # 5 ~ end relative VEGF concentration
        # 6 ~ end relative VEGFR-VEGF concentration
        dataPoint = DataPoint(vScale, aScale, dataValues[0] - dataValues[1], dataValues[2], dataValues[3])
        dataPoints.append(dataPoint)

        currentParam += paramStep

    aValues = [d.aScale for d in dataPoints]
    vValues = [d.vScale for d in dataPoints]
    volumes = [d.volumeGrowth for d in dataPoints]
    bisectors = [d.numBisecting for d in dataPoints]

    axVolume.set_ylabel("Volume Restored")
    if True: # Overlay volumes and bisectors plots
        axVolume.set_ylabel("Volume Restored", color='blue')
        axBisectors.set_ylabel("Num Bisectors", color='orange')
        axBisectors.yaxis.set_major_locator(ticker.MaxNLocator(nbins='auto', integer=True))
        if paramNum == 8: