def gen_a_instance(wid, arguments): for numAgents, numTasks, seedNum, gNum, csv_dpath, pkl_dpath, json_dpath in arguments: prefix = 'na%03d-nt%03d-ca%03d-sn%02d' % ( numAgents, numTasks, DEFAULT_VOLUME_CAPACITY, seedNum) agents = gen_agents(seedNum, prefix, gNum, numAgents, dpath=csv_dpath) tasks = gen_tasks(seedNum, prefix, numTasks, agents, dpath=csv_dpath) prob = gen_problemInstance(prefix, agents, tasks, tb_ratio=1.05) prob_pkl2json(prob, dpath=json_dpath)
def test(): gNum, seedNum = 0, 0 numAgents = 5 numTasks = 10 problemName = 'g%d-na%03d-sn%02d' % (gNum, numAgents, seedNum) agents = gen_agents(seedNum, problemName, gNum, numAgents, dpath='_temp') tasks = gen_tasks(seedNum, problemName, numTasks, agents, dpath='_temp') tb_ratio = 1.05 # gen_problemInstance(problemName, agents, tasks, tb_ratio)
def get_a_instance_givenSeedNums(wid, seedNums): capacity = 5 numAgents = 10 for seedNum in seedNums: gNum = seedNum % NUM_GROUP prefix = 'na%03d-sn%02d' % (numAgents, seedNum) agents = gen_agents(seedNum, prefix, gNum, numAgents, dpath=csv_dpath) for numTasks in range(20, 101, 20): prefix = 'na%03d-nt%03d-ca%03d-sn%02d' % (numAgents, numTasks, capacity, seedNum) tasks = gen_tasks(seedNum, prefix, numTasks, agents, dpath=csv_dpath) prob = gen_problemInstance(prefix, agents, tasks, tb_ratio=1.05, volume_capacity=capacity, weight_capacity=capacity) prob_pkl2json(prob, dpath=json_dpath)
'Lat': loc_lat, 'Lng': loc_lng, 'Note': loc_name } with open(csv_fpath, 'a') as w_csvfile: writer = csv.writer(w_csvfile, lineterminator='\n') writer.writerow([ instance[attr] for attr in [ 'tid', 'Region', 'PlanningArea', 'SubZone', 'Lat', 'Lng', 'Note' ] ]) tasks.append(instance) # with open(pkl_fpath, 'wb') as fp: pickle.dump(tasks, fp) return tasks if __name__ == '__main__': from genAG import gen_agents gNum, numAgents, seedNum = 0, 5, 0 numTasks = 3 prefix = 'g%d-na%03d-sn%02d' % (gNum, numAgents, seedNum) agents = gen_agents(seedNum, prefix, gNum, numAgents, dpath='_temp') tasks = gen_tasks(seedNum, prefix, numTasks, agents, dpath='_temp') with open(opath.join('_temp', '%s.pkl' % prefix), 'wb') as fp: pickle.dump([agents, tasks], fp)