Example #1
0
def buck2(L,log,log_dia,gui_mode):
    prices = buckPCh.get_prices()

    Li = [L,0,0,0,0,0]              #length iterators

                                    #Lengths-to-Check Vector (255 terminated)
    LCV = [36,40,38,34,32,30,28,26,24,22,20,18,16,255]

    p16 = prices[0]
    p30 = prices[1]
    p36 = prices[2]

    it = [255,255,255,255,255,255]  #iteration tracker (this currently is used
                                    #   to track index of LCV)

    p = [0,0,0,0,0,0]               #price tracker
    p1 = [0,0,0,0,0,0]
    p2 = [0,0,0,0,0,0]
    v = [0,0,0,0,0,0]               #volume tracker
    v1 = [0,0,0,0,0,0]
    v2 = [0,0,0,0,0,0]
    td = [0,0,0,0,0,0]              #top diameter tracker
    td1 = [0,0,0,0,0,0]
    td2 = [0,0,0,0,0,0]
    Lf = [0,0,0,0,0,0]              #lengths tracker
    Lf2 = [0,0,0,0,0,0]             #secondary lengths tracker

    lognum = 5                  #log number control variable

    min_length = 100                #minimum log length variable
    for entry in LCV:               #find minimum length
        if min_length > entry:
	    min_length = entry

    s=0
    while s >= 0:

        if it[s] == 255:                #eg "top" of tree
            it[s] = 0                   # (there will never be 255 LCV elements)
            for entry in LCV:
                if (entry + 0.8333) <= Li[s]:
                    Li[s] = entry + 0.8333
                    it[s] = it[s] + 1
                    break
                it[s] = it[s] + 1                     
            it[s] = it[s] - 1
            if entry == 255:
                print "\n Too short!\n"
                break
        else:                               #middle of tree
            Li[s] = 0
            Li[s+1] = 0
            it[s] = it[s] + 1
            while (L - sum(Li)) < (LCV[it[s]] + 0.8333):
                if (LCV[it[s]] == 255):
                    break
                it[s] = it[s] + 1

            if (LCV[it[s]] == 255) & (s == 0):
                break                        # END! QUIT! VAMOS! NOW!
            if (LCV[it[s]] == 255):
                 #clear all previous log lengths from the top of the tree
                if (s+1) < len(Li):
                    Li[s+1] = 0
                Li[s] = 0   
                p[s] = 0
                v[s] = 0
                td[s] = 0
                it[s] = 255 # there will never be 255 LCV elements
                s = s - 1
                sum_Li = sum(Li)
                continue

            Li[s] = LCV[it[s]] + 0.8333
#        print "s:",s,"Li:",Li,"it:",it


#        print 'log loop %i\n' %s
#        print 'Li[s] = %0.4f\n' %Li[s]
#        print 'it[s] = %i\n' %it[s]

                                    #calculate length price
        dia = interpolate.interpolate(sum(Li),log,log_dia)
        dia = int(dia)      #-->FIXME: Look at this later
        td[s] = dia
        v[s] = logvolume_2.logvolume_2(Li[s],dia)
        p[s] = buck1p.buck1p(Li[s],v[s],p16,p30,p36)
        Li[s+1] = L - sum(Li)    #bump remaining length ahead
        sum_p = sum(p)


        if sum_p >= sum(p1):
            p2 = copy(p1)
            p1 = copy(p)
            v2 = copy(v1)
            v1 = copy(v)
            td2 = copy(td1)
            td1 = copy(td)
            Lf2 = copy(Lf)
            Lf = copy(Li)
        elif sum_p >= sum(p2):
            p2 = copy(p)
            v2 = copy(v)
            td2 = copy(td)
            Lf2 = copy(Li)


        if (Li[s+1] >= (min_length + 0.8333)) & (s < (lognum - 1)):
            s = s + 1


    if gui_mode == 1 :
        # make grandios graphical table of data...
        file = open(sys.path[0]+os.sep+"output.txt",mode='w')

        i = 0
        for entry in v1:  # clean up output to be more user-friendly (clarity)
            if entry == 0:
                Lf[i] = 0
            i = i + 1

        i = 0
        for entry in v2:  # clean up output to be more user-friendly (clarity)
            if entry == 0:
                Lf2[i] = 0
            i = i + 1

        print >>file
        print >>file, "first choice..."
        print >>file, "Lengths are: [%i, %i, %i, %i, %i]" %(Lf[0], Lf[1], Lf[2], Lf[3], Lf[4]), "total:", sum(Lf)
        print >>file, "Volumes are:", v1, "total:", sum(v1)
        print >>file, "Top diams are:", td1
        print >>file, "Prices are: [%3.3f, %3.3f, %3.3f, %3.3f, %3.3f]" %(p1[0], p1[1], p1[2], p1[3], p1[4]), "total:", sum(p1)
        print >>file 
        print >>file, "second choice..."
        print >>file, "Lengths are: [%i, %i, %i, %i, %i]" %(Lf2[0], Lf2[1], Lf2[2], Lf2[3], Lf2[4]), "total:", sum(Lf2)
        print >>file, "Volumes are:", v2, "total:", sum(v2)
        print >>file, "Top diams are:", td2
        print >>file, "Prices are: [%3.3f, %3.3f, %3.3f, %3.3f, %3.3f]" %(p2[0], p2[1], p2[2], p2[3], p2[4]), "total:", sum(p2)
        print >>file 
#        print >>file, "catch_loop:", catch_loop 
#        print >>file 

        file.close()
        os.system("zenity --title=\"Best Buck Lengths\" --info --no-wrap --text=\"`cat "+sys.path[0]+os.sep+"output.txt`\" &")


    else:
        print
        print "first choice..."
        print "Lengths are: [%i, %i, %i, %i, %i]" %(Lf[0], Lf[1], Lf[2], Lf[3], Lf[4]), "total:", sum(Lf)
        print "Volumes are:", v1, "total:", sum(v1)
        print "Top diams are:", td1
        print "Prices are: [%3.3f, %3.3f, %3.3f, %3.3f, %3.3f]" %(p1[0], p1[1], p1[2], p1[3], p1[4]), "total:", sum(p1)
        print
        print "second choice..."
        print "Lengths are: [%i, %i, %i, %i, %i]" %(Lf2[0], Lf2[1], Lf2[2], Lf2[3], Lf2[4]), "total:", sum(Lf2)
        print "Volumes are:", v2, "total:", sum(v2)
        print "Top diams are:", td2
        print "Prices are: [%3.3f, %3.3f, %3.3f, %3.3f, %3.3f]" %(p2[0], p2[1], p2[2], p2[3], p2[4]), "total:", sum(p2)
        print
Example #2
0
def gui_process_logs():

    lengths = [0, 0, 0, 0, 0]
    diameters = [0, 0, 0, 0, 0]
    volumes = [0, 0, 0, 0, 0]
    values = [0, 0, 0, 0, 0]

    prices = buckPCh.get_prices()

    L1 = L1_entry.get()
    L2 = L2_entry.get()
    L3 = L3_entry.get()
    L4 = L4_entry.get()
    L5 = L5_entry.get()
    D1 = D1_entry.get()
    D2 = D2_entry.get()
    D3 = D3_entry.get()
    D4 = D4_entry.get()
    D5 = D5_entry.get()

    if L1 == "":
        lengths[0] = 0
    else:
        lengths[0] = float(L1) + 0.8333  # putting it here fixes 0-length output
    if L2 == "":
        lengths[1] = 0
    else:
        lengths[1] = float(L2) + 0.8333
    if L3 == "":
        lengths[2] = 0
    else:
        lengths[2] = float(L3) + 0.8333
    if L4 == "":
        lengths[3] = 0
    else:
        lengths[3] = float(L4) + 0.8333
    if L5 == "":
        lengths[4] = 0
    else:
        lengths[4] = float(L5) + 0.8333
    if D1 == "":
        D1 = 0
    if D2 == "":
        D2 = 0
    if D3 == "":
        D3 = 0
    if D4 == "":
        D4 = 0
    if D5 == "":
        D5 = 0

    diameters[0] = int(D1)
    diameters[1] = int(D2)
    diameters[2] = int(D3)
    diameters[3] = int(D4)
    diameters[4] = int(D5)

    i = 0
    for entry in lengths:
        volumes[i] = logvolume_2.logvolume_2(lengths[i], diameters[i])
        values[i] = buck1p.buck1p(lengths[i], volumes[i], prices[0], prices[1], prices[2])
        i = i + 1

    # make grandios graphical table of data...
    file = open(sys.path[0] + os.sep + "val_output.txt", mode="w")

    print >> file
    print >> file, "Your choices..."
    print >> file, "Lengths are: [%i, %i, %i, %i, %i]" % (
        lengths[0],
        lengths[1],
        lengths[2],
        lengths[3],
        lengths[4],
    ), "total:", sum(lengths)
    print >> file, "Volumes are:", volumes, "total:", sum(volumes)
    print >> file, "Top diams are:", diameters
    print >> file, "Prices are: [%3.3f, %3.3f, %3.3f, %3.3f, %3.3f]" % (
        values[0],
        values[1],
        values[2],
        values[3],
        values[4],
    ), "total:", sum(values)
    print >> file

    file.close()
    os.system(
        'zenity --title="Your Buck Values" --info --no-wrap --text="`cat ' + sys.path[0] + os.sep + 'val_output.txt`" &'
    )
Example #3
0
def buck(L,log,log_dia):
    (prices,price_skew) = buckPCh.get_prices()
        
    Li = [L,0,0,0,0,0]              #length iterators

                                    #Lengths-to-Check Vector (255 terminated)
    LCV = [36,40,38,34,32,30,28,26,24,22,20,18,16,255]

    p16 = prices[0]
    p30 = prices[1]
    p36 = prices[2]

    it = [255,255,255,255,255,255]  #iteration tracker (this currently is used
                                    #   to track index of LCV)

    p = [0,0,0,0,0,0]               #price tracker
    p1 = [0,0,0,0,0,0]
    p2 = [0,0,0,0,0,0]
    v = [0,0,0,0,0,0]               #volume tracker
    v1 = [0,0,0,0,0,0]
    v2 = [0,0,0,0,0,0]
    td = [0,0,0,0,0,0]              #top diameter tracker
    td1 = [0,0,0,0,0,0]
    td2 = [0,0,0,0,0,0]
    Lf = [0,0,0,0,0,0]              #lengths tracker
    Lf2 = [0,0,0,0,0,0]             #secondary lengths tracker

    lognum = 5                  #log number control variable

    min_length = 100                #minimum log length variable
    for entry in LCV:               #find minimum length
        if min_length > entry:
	    min_length = entry

    s=0
    while s >= 0:

        if it[s] == 255:                #eg "top" of tree
            it[s] = 0                   # (there will never be 255 LCV elements)
            for entry in LCV:
                if (entry + 0.8333) <= Li[s]:
                    Li[s] = entry + 0.8333
                    it[s] = it[s] + 1
                    break
                it[s] = it[s] + 1                     
            it[s] = it[s] - 1
            if entry == 255:
                print "\n Too short!\n"
                break
        else:                               #middle of tree
            Li[s] = 0
            Li[s+1] = 0
            it[s] = it[s] + 1
            while (L - sum(Li)) < (LCV[it[s]] + 0.8333):
                if (LCV[it[s]] == 255):
                    break
                it[s] = it[s] + 1

            if (LCV[it[s]] == 255) & (s == 0):
                break                        # END! QUIT! VAMOS! NOW!
            if (LCV[it[s]] == 255):
                 #clear all previous log lengths from the top of the tree
                if (s+1) < len(Li):
                    Li[s+1] = 0
                Li[s] = 0   
                p[s] = 0
                v[s] = 0
                td[s] = 0
                it[s] = 255 # there will never be 255 LCV elements
                s = s - 1
                sum_Li = sum(Li)
                continue

            Li[s] = LCV[it[s]] + 0.8333


#        print 'log loop %i\n' %s
#        print 'Li[s] = %0.4f\n' %Li[s]
#        print 'it[s] = %i\n' %it[s]

                                    #calculate length price
        dia = interpolate.interpolate(sum(Li),log,log_dia)
        dia = int(dia)      #-->FIXME: Look at this later
        td[s] = dia
        v[s] = logvolume_2.logvolume_2(Li[s],dia)
        p[s] = buck1p.buck1p(Li[s],v[s],p16,p30,p36,price_skew)
        Li[s+1] = L - sum(Li)    #bump remaining length ahead
        sum_p = sum(p)


        if sum_p >= sum(p1):
            p2 = copy(p1)
            p1 = copy(p)
            v2 = copy(v1)
            v1 = copy(v)
            td2 = copy(td1)
            td1 = copy(td)
            Lf2 = copy(Lf)
            Lf = copy(Li)
        elif sum_p >= sum(p2):
            p2 = copy(p)
            v2 = copy(v)
            td2 = copy(td)
            Lf2 = copy(Li)


        if (Li[s+1] >= (min_length + 0.8333)) & (s < (lognum - 1)):
            s = s + 1

    return (Lf,v1,td1,p1,Lf2,v2,td2,p2)
Example #4
0
def buck_1_4(L,log,log_dia,gui_mode):
    prices = buckPCh.get_prices()

    Li = [L,0,0,0,0,0]              #length iterators

    p16 = prices[0]
    p30 = prices[1]
    p36 = prices[2]

    it = [0,0,0,0,0,0]              #iteration tracker
    p = [0,0,0,0,0,0]               #price tracker
    p1 = [0,0,0,0,0,0]
    v = [0,0,0,0,0,0]               #volume tracker
    v1 = [0,0,0,0,0,0]
    td = [0,0,0,0,0,0]              #top diameter tracker
    td1 = [0,0,0,0,0,0]
    Lf = [0,0,0,0,0,0]              #lengths tracker
    Lf2 = [0,0,0,0,0,0]             #secondary lengths tracker

    lognum = 2                  #log number control variable

    s=0
    while s >= 0:
        if Li[s] <= (16 + (0.8333)):
            it[s] = 0
            s = s - 1


        if it[s] == 0:                      #either load start length or
            if Li[s] <= (40 + (0.8333)):    #if log is within 40ft long 
                                            #    use the total
                Li[s] = round(Li[s] - ((0.8333) - 0.5)) 
                               #normalize the rounding to 10inch over
                Li[s] = Li[s] - (1 - (0.8333))  
                                #ensure length divisible by 2
                if ((1e-5) <= (math.fmod(Li[s],2) - (0.8333))):
                                #set start log length
                    Li[s] = Li[s] - 1
            else:
                Li[s] = (40 + (0.8333))
        else:
            Li[s] = Li[s] - 2       #decrease length by one value

        it[s] = it[s] + 1
#        print 'log loop %i\n' %s
#        print 'Li[s] = %0.4f\n' %Li[s]

                                    #calculate length price
        dia = interpolate.interpolate(sum(Li),log,log_dia)
        dia = int(dia)      #-->FIXME: Look at this later
        td[s] = dia
        v[s] = logvolume_2.logvolume_2(Li[s],dia)
        p[s] = buck1p.buck1p(Li[s],v[s],p16,p30,p36)
        Li[s+1] = L - sum(Li)   #bump remaining length ahead
        sum_p = sum(p)


        if sum_p >= sum(p1):
            p2 = copy(p1)
            p1 = copy(p)
            v2 = copy(v1)
            v1 = copy(v)
            td2 = copy(td1)
            td1 = copy(td)
            Lf2 = copy(Lf)
            Lf = copy(Li)
        elif sum_p > sum(p2):
            p2 = copy(p)
            v2 = copy(v)
            td2 = copy(td)
            Lf2 = copy(Li)


        if s <= (lognum):
            s = s + 1
            while (((s >= 0) & (Li[s] <= 16.8333)) | (s == lognum)):
                Li[s] = 0   
                 #clear all previous log lengths from the top of the tree
                if (s+1) < len(Li):
                    Li[s+1] = 0
                p[s] = 0
                v[s] = 0
                td[s] = 0
                it[s] = 0
                s = s - 1

    if gui_mode == 1 :
        # make grandios graphical table of data...
        file = open(sys.path[0]+os.sep+"output.txt",mode='w')

        i = 0
        for entry in v1:  # clean up output to be more user-friendly (clarity)
            if entry == 0:
                Lf[i] = 0
            i = i + 1

        i = 0
        for entry in v2:  # clean up output to be more user-friendly (clarity)
            if entry == 0:
                Lf2[i] = 0
            i = i + 1

        print >>file
        print >>file, "first choice..."
        print >>file, "Lengths are: [%i, %i, %i, %i, %i]" %(Lf[0], Lf[1], Lf[2], Lf[3], Lf[4]), "total:", sum(Lf)
        print >>file, "Volumes are:", v1, "total:", sum(v1)
        print >>file, "Top diams are:", td1
        print >>file, "Prices are: [%3.3f, %3.3f, %3.3f, %3.3f, %3.3f]" %(p1[0], p1[1], p1[2], p1[3], p1[4]), "total:", sum(p1)
        print >>file 
        print >>file, "second choice..."
        print >>file, "Lengths are: [%i, %i, %i, %i, %i]" %(Lf2[0], Lf2[1], Lf2[2], Lf2[3], Lf2[4]), "total:", sum(Lf2)
        print >>file, "Volumes are:", v2, "total:", sum(v2)
        print >>file, "Top diams are:", td2
        print >>file, "Prices are: [%3.3f, %3.3f, %3.3f, %3.3f, %3.3f]" %(p2[0], p2[1], p2[2], p2[3], p2[4]), "total:", sum(p2)
        print >>file 

        file.close()
        os.system("kwrite "+sys.path[0]+os.sep+"output.txt &")


    else:
        print
        print "first choice..."
        print "Lengths are: [%i, %i, %i, %i, %i]" %(Lf[0], Lf[1], Lf[2], Lf[3], Lf[4]), "total:", sum(Lf)
        print "Volumes are:", v1, "total:", sum(v1)
        print "Top diams are:", td1
        print "Prices are: [%3.3f, %3.3f, %3.3f, %3.3f, %3.3f]" %(p1[0], p1[1], p1[2], p1[3], p1[4]), "total:", sum(p1)
        print
        print "second choice..."
        print "Lengths are: [%i, %i, %i, %i, %i]" %(Lf2[0], Lf2[1], Lf2[2], Lf2[3], Lf2[4]), "total:", sum(Lf2)
        print "Volumes are:", v2, "total:", sum(v2)
        print "Top diams are:", td2
        print "Prices are: [%3.3f, %3.3f, %3.3f, %3.3f, %3.3f]" %(p2[0], p2[1], p2[2], p2[3], p2[4]), "total:", sum(p2)
        print