ortools规划任务分配示例

本文涉及的产品
模型在线服务 PAI-EAS,A10/V100等 500元 1个月
交互式建模 PAI-DSW,每月250计算时 3个月
模型训练 PAI-DLC,100CU*H 3个月
简介: ortools规划任务分配示例
from__future__importprint_functionimporttimefromortools.linear_solverimportpywraplpimportnumpyasnpimportpandasaspddefget_data(date=20200301):
#收件需求&派件需求# data_3=pd.read_csv('pred20201130.csv',encoding='gbk',usecols=['date_str', 'aoi_id', 'pai_num', 'shou_num', 'zone_id'])  #Index(['Unnamed: 0', 'date_str', 'aoi_id', 'pai_num', 'shou_num', 'zone_id'], dtype='object')## data_3['date_str']=data_3['date_str'].apply(lambda x:int(x.replace('-','')))# data_tmp=data_3[data_3['date_str']==date]# print(data_tmp.shape)# data_tmp=data_tmp.groupby(by=['zone_id'])['pai_num','shou_num'].agg('sum')# print(data_tmp)# data_3 = pd.read_csv(#     'forecast_20200814.csv')  # Index(['Unnamed: 0', 'date_str', 'aoi_id', 'pai_num', 'shou_num', 'zone_id'], dtype='object')data_3=pd.read_csv('forecast_20200829.csv')  #Index(['Unnamed: 0', 'date_str', 'aoi_id', 'pai_num', 'shou_num', 'zone_id'], dtype='object')# print(data_3)data_3['date_str']=data_3['date_str'].apply(lambdax:int(str(x).replace('-','')))
# data_3['date_str']=data_3['date_str'].apply(lambda  x: x.replace('/',''))# data_3['date_str']=data_3['date_str'].apply(lambda  x: x.replace('/',''))# data_3['date_str'] = data_3['date_str'].apply(lambda x: x[:4]+'0'+x[4:])data_3['pai_num'] =data_3['pai_num'].apply(lambdax: round(x))
data_3['shou_num'] =data_3['shou_num'].apply(lambdax:round(x))
print(data_3)
print(str(date))
data_tmp=data_3[data_3['date_str']==date]
print(data_tmp)
data_tmp.index=data_tmp['zone_id']
li=list(data_tmp.index)
li=sorted(li, key=lambdax: int(x.split('_')[1]))
data_tmp=data_tmp.apply(li)
sizes_shou=list(data_tmp['shou_num'])
sizes_pai=list(data_tmp['pai_num'])
#小哥最大收件量#小哥最大派件量#小哥保底工资data_6=pd.read_csv('worker.csv',usecols=['小哥id', '收件能力', '派件能力', '保底收入', '收件成本',
'派件成本'])  # Index(['Unnamed: 0', 'date_str', 'aoi_id', 'pai_num', 'shou_num', 'zone_id'], dtype='object')worker_max_shou=list(data_6['收件能力'])
worker_max_pai=list(data_6['派件能力'])
worker_min_wage=list(data_6['保底收入'])
worker_cost_shou=list(data_6['收件成本'])
worker_cost_pai=list(data_6['派件成本'])
cost_shou=np.array([int(i) foriinworker_cost_shou] *len(sizes_shou)).reshape(-1, len(worker_cost_shou)).T.tolist()
cost_pai=np.array([int(i) foriinworker_cost_pai] *len(sizes_pai)).reshape(-1, len(worker_cost_pai)).T.tolist()
returncost_shou,cost_pai,sizes_shou,sizes_pai,worker_max_shou,worker_max_pai,worker_min_wagedefprint_score(file_path,sizes_shou,worker_max_shou,sizes_pai,worker_max_pai,worker_min_wage):
# data = pd.read_csv('E:\\Pycharm_projects\\xiaoge\\best_policy.csv')data=pd.read_csv(file_path)
data=data.sort_values(by=['task'])
worker_list=data['Worker'].tolist()
task_list=data['task'].tolist()
print('----------目标函数测试---------------')
print('任务:', task_list)
print('工人:', worker_list)
shou_requirement= {}
shou_provide= {}
pai_requirement= {}
pai_provide= {}
# cast1 成本fort,winzip(task_list,worker_list):
iftnotinshou_requirement:
shou_requirement[t] =sizes_shou[t]
shou_provide[t] =shou_provide.get(t, 0) +worker_max_shou[w]
iftnotinpai_requirement:
pai_requirement[t] =sizes_pai[t]
pai_provide[t] =pai_provide.get(t, 0) +worker_max_pai[w]
print('收件任务需求',(sum(list(shou_requirement.values())),len(list(shou_requirement.values()))))
print(list(shou_requirement.values()))
print('收件任务分配:', (sum(list(shou_provide.values())),len(list(shou_provide.values()))))
print( list(shou_provide.values()))
print('派件任务需求:', (sum(list(pai_requirement.values())),len(list(pai_requirement.values()))))
print( list(pai_requirement.values()))
print('派件任务分配:', (sum(list(pai_provide.values())),len(list(pai_provide.values()))))
print(list(pai_provide.values()))
cast1=[]
cast2= []
cast3= []
cast4= []
fortinlist(set(task_list)):
# cast3 溢出成本收cast1.append( min(shou_requirement[t], shou_provide[t]))
shou_err=shou_requirement[t] -shou_provide[t]
ifshou_err>0:
cast3.append(18*shou_err)
print('收件件任务分配的员工成本:', (sum(cast1),len(cast1)))
print(cast1)
fortinlist(set(task_list)):
# cast4 溢出成本派cast1.append( min(pai_requirement[t], pai_provide[t]))
pai_err=pai_requirement[t] -pai_provide[t]
ifpai_err>0:
cast4.append( 12*pai_err)
print('派件件任务分配的员工成本:', (sum(cast1),len(cast1)))
print(cast1)
print('收件溢出成本:', (sum(cast3), len(cast3)))
print(cast3)
print('派件溢出成本:', (sum(cast4), len(cast4)))
print(cast4)
# cast2 保底工资forwinlist(set(worker_list)):
cast2.append(worker_min_wage[w])
cast1_sum=sum(cast1)
cast2_sum=sum(cast2)
cast3_sum=sum(cast3)
cast4_sum=sum(cast4)
cast=cast1_sum+cast2_sum+cast3_sum+cast4_sumprint('cast1_sum:', cast1_sum)
print('cast2_sum:', cast2_sum)
print('cast3_sum:', cast3_sum)
print('cast4_sum:', cast4_sum)
print('cast:',cast)
print('cast1:', cast1)
print('cast2:', cast2)
print('cast3:', cast3)
print('cast4:', cast4)
defmain(date_tag):
solver=pywraplp.Solver('SolveAssignmentProblem',
pywraplp.Solver.SCIP_MIXED_INTEGER_PROGRAMMING)
# solver = pywraplp.Solver('SolveAssignmentProblem',#                          pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)start=time.time()
# 成本矩阵给出了工人i执行任务j的成本cost_shou= [[1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1]]
# size向量给出了每个任务的大小sizes_shou= [10, 4, 8, 6, 7, 12, 5, 11]
# total_size_max是任何单个工作者执行的任务的总大小的上限worker_max_shou= [20, 23, 8, 17, 12, 5, 7, 9, 12, 14]
# 成本矩阵给出了工人i执行任务j的成本cost_pai= [[1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1]]
# size向量给出了每个任务的大小sizes_pai= [10, 4, 8, 6, 7, 12, 5, 11]
# total_size_max是任何单个工作者执行的任务的总大小的上限worker_max_pai= [20, 23, 8, 17, 12, 5, 7, 9, 12, 14]
worker_min_wage= [10, 15, 5, 1, 14, 12, 8, 7, 13, 11]
cost_shou,cost_pai,sizes_shou,sizes_pai,worker_max_shou,worker_max_pai,worker_min_wage=get_data(date=date_tag)
print(cost_shou)
print(cost_pai)
print(sizes_shou)
print(sizes_pai)
print(worker_max_shou)
print(worker_max_pai)
print(worker_min_wage)
# 任务数量和工人数量num_workers=len(cost_shou)
num_tasks=len(cost_shou[1])
# Variablesx_shou= []
foriinrange(num_workers):
t= []
forjinrange(num_tasks):
t.append(solver.IntVar(0, 1, "shou[%i,%i]"% (i, j)))
x_shou.append(t)
x_pai= []
foriinrange(num_workers):
t= []
forjinrange(num_tasks):
t.append(solver.IntVar(0, 1, "pai[%i,%i]"% (i, j)))
x_pai.append(t)
    [solver.Add(sum(x_shou[i][j] foriinrange(num_workers)) >=1)
forjinrange(num_tasks)]
    [solver.Add(sum(x_pai[i][j] foriinrange(num_workers)) >=1)
forjinrange(num_tasks)]
# 添加约束,每个小哥最多被分配一个收件或者派件任务    [solver.Add(sum(x_shou[i][j] forjinrange(num_tasks)) <=1) foriinrange(num_workers)]
    [solver.Add(sum(x_pai[i][j] forjinrange(num_tasks)) <=1) foriinrange(num_workers)]
    [solver.Add((x_pai[i][j] -x_shou[i][j] ==0)) forjinrange(num_tasks) foriinrange(num_workers)]
# 收派件成本&保底工资################################################################################### cast1=solver.Sum([cost_shou[i][j] * x_shou[i, j] for i in range(num_workers)#                             for j in range(num_tasks)])# cast2 = solver.Sum([cost_pai[i][j] * x_pai[i, j] for i in range(num_workers)#                     for j in range(num_tasks)])##################################################################################compare_task1= []
forjinrange(num_tasks):
compare_task1.append([])
compare_task1[j].append(solver.IntVar(0, solver.infinity(), "sizes_shou_[%i]"% (j)))
compare_task1[j].append(solver.IntVar(0, solver.infinity(), "worker_max_shou_[%i]"% (j)))
solver.Add(compare_task1[j][0] ==sizes_shou[j])
solver.Add(compare_task1[j][1]==sum([worker_max_shou[i]*sum([x_shou[i][j]]) foriinrange(num_workers)]))
target1= []
forjinrange(num_tasks):
target1.append(solver.IntVar(0, solver.infinity(), "target1[%i]"% (j)))
forjinrange(num_tasks):
solver.Add(compare_task1[j][1] >=sizes_shou[j])
forjinrange(num_tasks):
solver.Add(target1[j] ==sizes_shou[j])
compare_task2= []
forjinrange(num_tasks):
compare_task2.append([])
compare_task2[j].append(solver.IntVar(0, solver.infinity(), "sizes_pai_[%i]"% (j)))
compare_task2[j].append(solver.IntVar(0, solver.infinity(), "worker_max_pai_[%i]"% (j)))
solver.Add(compare_task2[j][0] ==sizes_pai[j])
solver.Add(
compare_task2[j][1] ==sum([worker_max_pai[i] *sum([x_pai[i][j]]) foriinrange(num_workers)]))
target2= []
forjinrange(num_tasks):
target2.append(solver.IntVar(0, solver.infinity(), "target2[%i]"% (j)))
forjinrange(num_tasks):
solver.Add(compare_task2[j][1] >=sizes_pai[j])
forjinrange(num_tasks):
solver.Add(target2[j] ==sizes_pai[j])
target3= []
forjinrange(num_tasks):
target3.append(solver.IntVar(-solver.infinity(), solver.infinity(), "target3[%i]"% (j)))
# 供应量大于需求量,溢出成本为0不需要计算,供应量小于需求量,计算溢出成本forjinrange(num_tasks):
solver.Add(target3[j] == (18* (sizes_shou[j] -compare_task1[j][1])))
target4= []
forjinrange(num_tasks):
target4.append(solver.IntVar(-solver.infinity(), solver.infinity(), "target4[%i]"% (j)))
# 供应量大于需求量,溢出成本为0不需要计算,供应量小于需求量,计算溢出成本forjinrange(num_tasks):
solver.Add(target4[j] ==12* (sizes_pai[j] -compare_task2[j][1]))
cast1=sum(target1) +sum(target2)
cast3=sum(target3)
cast4=sum(target4)
cast2=sum([sum([np.dot(worker_min_wage[i], x_shou[i][j]) foriinrange(num_workers)]) forjinrange(num_tasks)])
# cast1 = sum(target1)solver.Minimize(
cast1+cast2+cast3+cast4)
# solver.Minimize( cast1+cast2+cast3+cast4 +sum([i[1] for i in compare_task1])+sum([i[1] for i in compare_task2]))# solver.Minimize(cast2)status=solver.Solve()
plain={}
forjinrange(num_tasks):
plain[j]=[x_shou[i][j].solution_value() foriinrange(num_workers)]
## print('---------------目标函数------------------------')print('任务分配人工:')
print([vfork,vinplain.items()])
print( [[indexforindex,iinenumerate(v) if (i==1) ] fork,vinplain.items()])
shou_task2= {}
pai_task2= {}
forjinrange(num_tasks):
shou_task2[j] =solver.Sum(
            [worker_max_shou[i] *x_shou[i][j].solution_value() foriinrange(num_workers)]).solution_value()
print('收件任务需求:', (sum(sizes_shou), len(sizes_shou)))
print(sizes_shou)
print('收件任务分配:', (sum(list(shou_task2.values())), len(list(shou_task2.values()))))
print(list(shou_task2.values()))
forjinrange(num_tasks):
pai_task2[j] =solver.Sum([worker_max_pai[i] *x_pai[i][j] foriinrange(num_workers)]).solution_value()
print('派件任务需求:', (sum(sizes_pai), len(sizes_pai)))
print(sizes_pai)
print('派件任务分配:', (sum(list(pai_task2.values())), len(list(pai_task2.values()))))
print(list(pai_task2.values()))
print('【status】:',status)
ifstatus==solver.OPTIMAL  :
print('Minimum cost = %i'%solver.Objective().Value())
print()
result= {'date':[],'Worker': [], 'task': [],'cast1': [], 'cast2': [],'cast3': [], 'cast4': []}
foriinrange(num_workers):
forjinrange(num_tasks):
ifx_shou[i][j].solution_value() ==1:
result['date'].append(date_tag)
result['Worker'].append(i)
result['task'].append(j)
result['cast1'].append(cast1.solution_value())
result['cast2'].append(cast2.solution_value())
result['cast3'].append(cast3.solution_value())
result['cast4'].append(cast4.solution_value())
print('Worker ', i, ' assigned to shou_task ', j, '  Cost1 = ', cost_shou[i][j], '  Cost2 = ',
worker_min_wage[i])
print()
end=time.time()
print("Time = ", round(end-start, 4), "seconds")
data=pd.DataFrame(result)
data.to_csv('best_policy.csv', index=None)
print('model_cast1:', cast1.solution_value())
print('model_cast2:', cast2.solution_value())
print('model_cast3:', cast3.solution_value())
print('model_cast4:', cast4.solution_value())
print_score('best_policy.csv', sizes_shou, worker_max_shou, sizes_pai, worker_max_pai, worker_min_wage)
returncost_shou,cost_pai,sizes_shou,sizes_pai,worker_max_shou,worker_max_pai,worker_min_wagedefouput_result(path='best_policy.csv'):
# data = pd.read_csv('best_policy.csv')data=pd.read_csv('best_policy.csv')
result= {}
fordindata.iterrows():
dd=d[1]
time=str(dd['date'])
time=time[:4] +'-'+time[4:6] +'-'+time[6:-2]
zone='zone_'+str(dd['task'])[:-2]
worker='id_'+str(dd['Worker'])[:-2]
result[time] =result.get(time, {})
result[time][zone] =result[time].get(zone, [])
result[time][zone].append(worker)
result_str=json.dumps(result).replace('{', '{\n').replace('],', '],\n').replace('},', '},\n').replace('}', '}\n')
print(result_str)
withopen('result_str.txt', 'w') asf:
f.write(result_str)
returnresultdefcreate_data_model():
"""Create the data for the example."""data= {}
shou= [49, 9, 42, 36, 36, 48, 42, 42, 36]
pai= [15, 30, 25, 50, 35, 30, 15, 40, 30]
chengben= [10, 30, 2, 5, 3, 30, 15, 4, 30]
data['shou'] =shoudata['pai'] =paidata['chengben'] =chengbendata['items'] =list(range(len(shou)))
data['num_items'] =len(shou)
num_bins=1data['bins'] =list(range(num_bins))
data['bin_capacities'] = [100, 150]
returndatadefpackbag(data):
# data = create_data_model()# Create the mip solver with the CBC backend.solver=pywraplp.Solver.CreateSolver('CBC')
# Variables# x[i, j] = 1 if item i is packed in bin j.x= {}
foriindata['items']:
forjindata['bins']:
x[(i, j)] =solver.IntVar(0, 1, 'x_%i_%i'% (i, j))
forjindata['bins']:
solver.Add(sum(x[(i, j)] *data['shou'][i]
foriindata['items']) >=1*data['bin_capacities'][0])
solver.Add(sum(x[(i, j)] *data['pai'][i]
foriindata['items']) >=1*data['bin_capacities'][1])
# Objectiveobjective=solver.Objective()
foriindata['items']:
forjindata['bins']:
objective.SetCoefficient(x[(i, j)], data['chengben'][i])
objective.SetMinimization()
status=solver.Solve()
leave_worker=[]
ifstatus==pywraplp.Solver.OPTIMAL:
# print('Total packed value:', objective.Value())total_cast=0forjindata['bins']:
shou_list=0pai_list=0bin_chengben=0# print('Bin ', j)foriindata['items']:
ifx[i, j].solution_value() >0:
leave_worker.append(i)
shou_list+=data['shou'][i]
pai_list+=data['pai'][i]
# print('Item', i, '- shou:', data['shou'][i], ' value:',#       data['pai'][i])bin_chengben+=data['chengben'][i]
bin_shou=data['bin_capacities'][0]
bin_pai=data['bin_capacities'][1]
# print('Packed bin shou:', bin_weight)# print('Packed bin pai:', bin_value)# print('Packed bin chengben:', bin_chengben)print()
print('供大于求:',(shou_list+pai_list,bin_shou+bin_pai,shou_list-bin_shou+pai_list-bin_pai,(shou_list-bin_shou+pai_list-bin_pai)/(bin_shou+bin_pai)))
print('供大于求:',(shou_list,bin_shou,shou_list-bin_shou,(shou_list-bin_shou)/(bin_shou)))
print('供大于求:',(pai_list,bin_pai,pai_list-bin_pai,(pai_list-bin_pai)/(bin_pai)) )
total_cast+=bin_shou+bin_pai+bin_chengben# print('Total packed cast:', total_weight)# print()else:
print('The problem does not have an optimal solution.')
returnleave_worker,total_cast,bin_shou,bin_pai,bin_chengbendefclear_task(task_id,worker_list,data2):
"""Create the data for the example."""data= {}
shou= [data2['worker_max_shou'][i] foriinworker_list]
pai= [data2['worker_max_pai'][i] foriinworker_list]
chengben= [data2['worker_min_wage'][i] foriinworker_list]
print('【task_id】:',task_id)
data['sizes_shou']=data2['sizes_shou']
data['sizes_pai'] =data2['sizes_pai']
data['shou'] =shoudata['pai'] =paidata['chengben'] =chengbendata['items'] =list(range(len(shou)))
data['num_items'] =len(shou)
num_bins=1data['bins'] =list(range(num_bins))
data['bin_capacities'] = [data2['sizes_shou'][task_id],data2['sizes_pai'][task_id]]
leave_worker,new_cast,bin_shou,bin_pai,bin_chengben=packbag(data)
leave_worker=['id_'+str(worker_list[i]) foriinleave_worker]
returnleave_worker,new_cast,bin_shou,bin_pai,bin_chengbendefclear_result(result,sizes_shou,sizes_pai,worker_max_shou,worker_max_pai,worker_min_wage):
"""Create the data for the example."""data={}
data['sizes_shou']=sizes_shoudata['sizes_pai'] =sizes_paidata['worker_max_shou'] =worker_max_shoudata['worker_max_pai'] =worker_max_paidata['worker_min_wage'] =worker_min_wagenew_result={}
new_cast=[]
new_bin_shou=[]
new_bin_pai=[]
new_bin_chengben=[]
fortime,policyinresult.items():
new_result[time]={}
fortask_id ,worker_listinpolicy.items():
task_id_tmp=int(task_id.split('_')[1])
worker_list_tmp=[int(i.split('_')[1]) foriinworker_list]
new_result[time][task_id],cast_,bin_shou,bin_pai,bin_chengben=clear_task(task_id_tmp, worker_list_tmp,data)
new_cast.append(cast_)
new_bin_shou.append(bin_shou)
new_bin_pai.append(bin_pai)
new_bin_chengben.append(bin_chengben)
fortask_idinrange(30):
# for task_id in [1,5,14,4,15,27]:id='zone_'+str(task_id)
ifidinresult[time]:
new_result[time][id]=result[time][id]
returnnew_result,new_cast,new_bin_shou,new_bin_pai,new_bin_chengbendefmake_commit(date_tag=20200511):
print('背包调整....')
# date_tag = 20200511cost_shou= [[1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1],
                 [1, 1, 1, 1, 1, 1, 1, 1]]
# size向量给出了每个任务的大小sizes_shou= [10, 4, 8, 6, 7, 12, 5, 11]
# total_size_max是任何单个工作者执行的任务的总大小的上限worker_max_shou= [20, 23, 8, 17, 12, 5, 7, 9, 12, 14]
# 成本矩阵给出了工人i执行任务j的成本cost_pai= [[1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1]]
# size向量给出了每个任务的大小sizes_pai= [10, 4, 8, 6, 7, 12, 5, 11]
# total_size_max是任何单个工作者执行的任务的总大小的上限worker_max_pai= [20, 23, 8, 17, 12, 5, 7, 9, 12, 14]
worker_min_wage= [10, 15, 5, 1, 14, 12, 8, 7, 13, 11]
# 线性规划cost_shou, cost_pai, sizes_shou, sizes_pai, worker_max_shou, worker_max_pai, worker_min_wage=get_data(
date=date_tag)
main(date_tag)
# 生成输出格式方案result=ouput_result()
print(result)
print('----------------------------')
# 去掉多余人力result, cast, bin_shou, bin_pai, bin_chengben=clear_result(result, sizes_shou, sizes_pai, worker_max_shou,
worker_max_pai, worker_min_wage)
# for i in range(30):#     zone = "zone_%s" % i#     tt=str(date_tag)[:4] + '-' + str(date_tag)[4:6] + '-' + str(date_tag)[6:]#     if zone  not in result[tt]:#         result[tt][zone]=[]result_str=json.dumps(result).replace('{', '{\n').replace('],', '],\n').replace('},', '},\n').replace('}', '}\n')
print(result_str)
withopen('sche_{0}.json'.format(date_tag), 'w') asf:
f.write(result_str)
print('更新之后cast:', sum(cast))
print('new_cast1:', sum(bin_shou) +sum(bin_pai))
print('bin_shou:', sum(bin_shou))
print('bin_pai:', sum(bin_pai))
print('new_cast2:', sum(bin_chengben))
# print(bin_shou)# print(bin_pai)# data=create_data_model()# packbag(data)returnresult,sum(cast)
importjsonif__name__=='__main__':
limit=[20200829,20200830,20200831]
results={}
casts=[]
forlinlimit:
r,c=make_commit(l)
results.update(r)
casts.append(c)
print(casts)
result_str=json.dumps(results).replace('{', '{\n').replace('],', '],\n').replace('},', '},\n').replace('}', '}\n')
print(result_str)
withopen('out/sche.json', 'w') asf:
f.write(result_str)
shell_code='python calc_score.py -w  worker.csv  -d out -dates 'fortinlimit:
shell_code+=str(t)[:4] +'-'+str(t)[4:6] +'-'+str(t)[6:]+'  'print(shell_code)
相关实践学习
使用PAI-EAS一键部署ChatGLM及LangChain应用
本场景中主要介绍如何使用模型在线服务(PAI-EAS)部署ChatGLM的AI-Web应用以及启动WebUI进行模型推理,并通过LangChain集成自己的业务数据。
机器学习概览及常见算法
机器学习(Machine Learning, ML)是人工智能的核心,专门研究计算机怎样模拟或实现人类的学习行为,以获取新的知识或技能,重新组织已有的知识结构使之不断改善自身的性能,它是使计算机具有智能的根本途径,其应用遍及人工智能的各个领域。 本课程将带你入门机器学习,掌握机器学习的概念和常用的算法。
目录
相关文章
|
16天前
|
监控 测试技术 项目管理
项目管理的规划,你真的做对了吗?
本文深入解析了项目管理的全流程,从启动、规划、执行与监控到收尾四个阶段,详细阐述了各阶段的核心目标与任务。强调了项目管理中风险控制、团队协作及经验总结的重要性,指出了常见“雷区”及应对策略,旨在帮助产品经理提升项目管理能力。
|
1月前
|
监控 前端开发 项目管理
从零到一:独立项目如何规划、资源分配与进度监控?
本文从规划、资源分配、进度监控三方面详细解读独立项目运作的过程步骤,旨在帮助读者从零到一掌握项目管理的全流程。同时,推荐了三款实用的项目管理工具——板栗看板、Trello 和 Asana,助力项目高效执行。
38 3
|
7月前
|
弹性计算 运维 Shell
自动化客服任务分配与优先级管理
【4月更文挑战第30天】
73 0
|
敏捷开发 前端开发 算法
基于业务场景、组织和规划| 学习笔记
快速学习基于业务场景、组织和规划
基于业务场景、组织和规划| 学习笔记
如何使用看板来规划自己的计划
如何使用看板来规划自己的计划
145 0
如何使用看板来规划自己的计划
|
前端开发 NoSQL JavaScript
1. 初步规划
因为目前正从事测试平台开发的相关工作,但是苦于市场上的大多数产品的针对性太强,或多或少没有一个通用的方案。于是想利用自己的空余时间,写一个web测试平台,也顺便记录下自己的学习历程。至于是否太监,就不得而知了。先暂且将他命名为lamb吧~~
1. 初步规划
|
机器学习/深度学习 人工智能 JavaScript
【运筹学】运输规划 ( 运输规划问题模型及变化 | 表上作业法引入 )
【运筹学】运输规划 ( 运输规划问题模型及变化 | 表上作业法引入 )
287 0
【运筹学】运输规划 ( 运输规划问题模型及变化 | 表上作业法引入 )
|
供应链 算法 Java
普通企业的规划类项目中,OptaPlanner更适合作为APS的规划优化引擎
在企业的规划、优化场景中,均需要开发规划类的项目,实现从从种可能方案中找出相对最优方案。如排班、生产计划(包括高层次的供应链优化,到细粒度的车间甚至机台作业指令)、车辆调度等。因为这类场景需要解决的问题,均可以归约为数学中的NP-C或NP-Hard问题。
1786 0
|
项目管理
艾伟也谈项目管理,工作感言:任务分配及管理
前面说到过,刚开始带小组,接到一个任务,我就估算了我大概要多少时间,然后小组多少个人就算是多少个我,估算时间=我要的总时间"小组人数(好笨的想法呀,不用时间跟组员交待任务的吗?个个组员都是我吗,比我强的还好,顶多做完了休息,差一点的就麻烦了),结果实际时间多了很多,而且小组里有的人做完了无事可做,有的人则忙得焦头烂额,容易打击组员的积极性,造成组员之间的不满。
1388 0
|
算法 Java Maven
Optaplanner规划引擎的工作原理及简单示例(2)
开篇       在前面一篇关于规划引擎Optapalnner的文章里(Optaplanner规划引擎的工作原理及简单示例(1)),老农介绍了应用Optaplanner过程中需要掌握的一些基本概念,这些概念有且于后面的内容的理解,特别是关于将约束应用于业务规则上的理解。
2836 0