輸入格式如下,以csv儲存:
sku_id
長s寬s
高s重量
箱子長s
箱子寬s
箱子高s
2195809
27058
34130
1400
1200
1810
python**如下:
# -*- coding: utf-8 -*-
"""created on wed dec 20 17:19:04 2017
@author: zhangchaoyu
"""import re
import copy
import os
def num_f(f):
flines = -1
for i in f:
flines = flines + 1
return flines
def read_csv(f,num_f):
data =
#標題不讀
f.readline()
for i in range(num_f):
row = f.readline()
row = re.split(',', row)
for k in range(1,len(row)):
row[k] = int(float(row[k]))
return data
def isnan(num):
return num != num
#二維裝箱
def sub_boxpacking(cl,cw,ch,l,w,h):
#簡單碼放模式作為下界
n1 = (cl//l)*(cw//w) + (cl%l//w)*(cw//l)
n2 = (cw//l)*(cl//w) + (cw%l//w)*(cl//l)
n = max(n1,n2)
if(cl*cw/l/w >= n+1 and cw > l+w):
up1 = int(cl//l)
up2 = int(cl//w)
up3 = int(cw//l)
up4 = int(cw//w)
for x1 in range(1,up1+1):
x2 = (cl-x1*l)//w
for y1 in range(1,up4+1):
y4 = (cw-y1*w)//l
for y2 in range(1,up3+1):
y3 = (cw-y2*l)//w
for x3 in range(1,up1+1):
x4 = (cl-x3*l)//w
if (y1*w <= y2*l and x2*w <= x3*l and y3*w <= y4*l and x4*w <= x1*l):
if((y1+y3)*w>cw or (x2+x4)*w>cl):
continue
n3 = x1*y1+x2*y2+x3*y3+x4*y4
#if(n3>n):
#print([x1,y1,x2,y2,x3,y3,x4,y4])
n = max(n3,n)
if (y1*w >= y2*l and x2*w >= x3*l and y3*w >= y4*l and x4*w >= x1*l):
if((x1+x3)*l>cl or (y2+y4)*l>cw):
continue
n3 = x1*y1+x2*y2+x3*y3+x4*y4
#if(n3>n):
#print([x1,y1,x2,y2,x3,y3,x4,y4])
n = max(n3,n)
return n
def boxpacking(data):
#碼盤件數、#碼垛層數、每層件數、利用率
num =
num_levels =
num_eachlevel =
fl =
flag = 1;
for sku in data:
print("正在計算第",flag,"個,總共",len(data),"個,佔比",flag*10000//len(data)/100,"%")
flag += 1
e1,e2,e3 = sku[1],sku[2],sku[3]
if e1<=10 or e2<=10 or e3<=10 or isnan(e1) or isnan(e2) or isnan(e3):
continue
cl = sku[5]
cw = sku[6]
ch = sku[7]
n1 = sub_boxpacking(cl,cw,ch,e1,e2,e3)
n2 = sub_boxpacking(cl,cw,ch,e2,e3,e1)
n3 = sub_boxpacking(cl,cw,ch,e3,e1,e2)
n_el = n1
n_l = ch//e3
if(n_el*n_ln_el = n2
n_l = ch//e1
if(n_el*n_ln_el = n3
n_l = ch//e2
if n_l == 0:
else:
return [num,num_levels,num_eachlevel,fl]
def output(data,result):
output = copy.deepcopy(data)
for i in range(len(output)):
output[i] += [result[0][i],result[1][i],result[2][i],result[3][i]]
if os.path.exists("碼盤結果彙總.csv"):
os.remove("碼盤結果彙總.csv")
f1 = open("碼盤結果彙總.csv","a")
f1.write('sku_id,長s,寬s,高s,重量,箱子長s,箱子寬s,箱子高s,碼盤件數,碼垛層數,每層件數,體積利用率\n')
for i in range(len(output)):
for j in range(len(output[i])):
f1.write(str(output[i][j]))
f1.write(',')
f1.write('\n')
f1.close()
if __name__ == '__main__':
print("檔案錄入")
num_f = num_f(open(r'輸入格式.csv'))
data = read_csv(open(r'輸入格式.csv'),num_f)
print("檔案錄入完成,開始計算")
result = boxpacking(data)
print("計算完成,輸出檔案")
output(data,result)
adb 工具關閉程式包,開啟程式包,查詢程式包
1.關閉程式包 關閉的是google搜尋的包 命令是 adb shell am force stop com.android.quicksearchbox 2.開啟程式包 開啟的是google搜尋的包 命令是 adb shell am start w n com.android.quicksearc...
程式包例子
create or replace package test package is procedure pro test01 num arg in number function fun test02 return number end test package create or replace ...
程式包例子
儲存過程 procedure create procedure 過程名 引數列表 as is begin exception end or replace 如果存在該過程,則重構該過程 過程引數的三種模式 in 用於接受呼叫程式的值,預設的引數模式 out 用於向呼叫程式返回值 in out用於接受...