예제 #1
0
table_name,describe,x_name,y_name,chart=sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4],sys.argv[5]
conn=MySQLdb.connect(host='localhost',port=3306,user='******',passwd='Db10204!!',db='dataVisDB',charset='utf8')
cur=conn.cursor()
# print table_name
column_num=cur.execute('describe `'+table_name+'`')
desc=cur.fetchall()
names=[]
types=[]
for i in range(column_num):
    names.append(desc[i][0])
    types.append(Type.getType(desc[i][1].lower()))
tuple_num=cur.execute('select * from `'+table_name+'`')
instance=Instance(table_name,column_num,tuple_num,names,types)
table=Table(instance,'False','','')
table.column_num,table.tuple_num,table.names,table.types=column_num,tuple_num,names,types
table.origins=[i for i in range(column_num)]
instance.D=map(list,cur.fetchall())
cur.close()
conn.close()

#calculate features and get D
table.D=instance.D
table.getFeatures()
instance.addTable(table)

navigation=Navigation(instance,describe,x_name,y_name,chart)
navigation.changeX()
navigation.changeY()
navigation.changeBin()
navigation.changeChart()
navigation.findSimilar()
예제 #2
0
if __name__ == "__main__":
    arg = Arguments(sys.argv, prefix="murray_")

    if not arg.E:
        inst = Instance(arg.instance)
    else:
        inst = Instance(arg.instance, E=arg.E)

    # quick instance adaptation for Murray's format (with an extra index for the depot)
    inst.V = inst.V + [len(inst.V)]
    inst.A = set([(i, j)
                  for i in inst.V[:-1]
                  for j in inst.V[1:] if i != j])
    inst.D = set([(i, j, k)
                  for i in inst.V[:-1]
                  for j in inst.V_drone
                  for k in inst.V[1:]
                  if inst.tau_drone[i][j] + inst.tau_drone[j][k] <= inst.E - inst.sr
                  and i != j != k])

    if arg.sol and arg.validate_only:
        solution = Solution(inst, murray_rules=True)
        solution.read(arg.sol)
        solution.print_solution()
        solution.write(arg.out)
        exit(0)

    start_time = time.time()

    # creating folders 'logs' and 'solutions' if they don't exist already
    if not os.path.exists('logs'):
        os.makedirs('logs')