def WriteConnections(lCollapsedSamples, sCollapsedSampleFile, bAppend = False, bWritePredictions = False, bPosOnly = True):
        if not bPosOnly and config.get_float('ALL_TEXT_PRECISION') != 0:
            fAllTextPrecision = config.get_float('ALL_TEXT_PRECISION');
            iPos, iNeg = CalcAllTextPosNeg(lCollapsedSamples);
            fFracNegToWrite = (float(1-fAllTextPrecision)/float(fAllTextPrecision))*float(iPos)/float(iNeg);
            print "Writing All Text with Precision:", fAllTextPrecision, "Raw Precision:", iPos/float(iPos+iNeg), "FracNeg:", fFracNegToWrite;
        else:
            fFracNegToWrite = 1.0;

        print "Writing Positive Collapsed To:", sCollapsedSampleFile;
        if bAppend:
            fOut = open(sCollapsedSampleFile, 'a');
        else:
            fOut = open(sCollapsedSampleFile, 'w');
        for colsamp in lCollapsedSamples:
            if not bPosOnly:
                # write all connections if ALL_TEXT_PRECISION == 0 else write all pos and fFracToWrite fraction of the negs
                if colsamp.bPos or (random.random() <= fFracNegToWrite):
                    colsamp.WritePddlConnections(fOut);
            elif bWritePredictions:
                if colsamp.bPredPos:
                    colsamp.WritePddlConnections(fOut);
            else:        
                if colsamp.bPos:
                    colsamp.WritePddlConnections(fOut);
Exemple #2
0
    def __init__(self):
        exchange_name = config.get_string('grid', 'name')
        symbol = config.get_string('grid', 'symbol')
        super(Grid, self).__init__(exchange_name, symbol)
        self.base_line = config.get_float('grid', 'base_line')  # 当前价格基准线
        self.one_hand = config.get_float('grid', 'one_hand')  # 一手买多少

        logging.info("交易所:%s" % exchange_name)
        logging.info("交易对:%s" % symbol)
        logging.info("基线:%f" % self.base_line)
        logging.info("一格:%f" % self.one_hand)
def ComputeMultiplier(dConnRewards, bPos):
    iPosTotal = 0;
    iNegTotal = 0;
    for cr in dConnRewards.values():
        iPosTotal += cr.GetNumPos();
        iNegTotal += cr.GetNumNeg();
    if bPos:
        fMult = float(iNegTotal)/float(iPosTotal);
    else:
        fMult = float(iPosTotal)/float(iNegTotal);
    if config.get_float('REWARDS_NEG_MULT') != -1:
        assert(not bPos);
        fMult = config.get_float('REWARDS_NEG_MULT');
    print "fMult:", fMult;
    return fMult;
Exemple #4
0
def tempvalue(section):

    name = config.get(section, 'name')

    try:
        tempfile = open('sys/bus/w1/devices/' + str(name) + 'w1_slave')
        line = tempfile.readline()
        if re.match(r"[0-9a-f{2} ){9}: crc=[0-9a-f]{2} YES", line):
            line = tempfile.readline()
            m = re.match(r"[0-9a-f{2} ){9}t=([+-]?[0-9]+)", line)
            if m:
                value = float(m.group(2)) / 1000.0
                config.set(section, 'value', str(value))
                return value
    except (IOError):
        print("File not found")
        value = config.get_float(section, 'default')
        config.set(section, 'value', str(value))
        return value