Skip to content
Snippets Groups Projects
Commit 86ac6d58 authored by Jingyan Ling's avatar Jingyan Ling
Browse files

multi-node dl demo, journal update

parent 224c76c1
Branches
No related merge requests found
......@@ -171,7 +171,7 @@
- Research on KiCAD import needs and python API
### 07/082019 (Mon)
### 07/08/2019 (Mon)
- Debug multi-node path finding:
- some obstacles are ignored
......@@ -179,6 +179,7 @@
- Able to show the learning process:
- Trying different combination of solving order
- Try to give the best order of solving multiple path
##### Auto-routing learning process:
- ![path_learning.gif](journal_media/path_learning.gif)
......@@ -187,4 +188,11 @@
##### Issues and TODO
- Path export from optimization is messed up
- Obstacles setting are incorrect
\ No newline at end of file
- Obstacles setting are incorrect
### 07/09/2019
- Only draw the best path on `dxf` when solution is found for every route.
- ![circuit_dxf](journal_media/dxf_circuit.png)
- Throw warning once a route cannot be found
- ![fail_solution](journal_media/path_fail.gif)
......@@ -34,23 +34,29 @@ class auto_rounter:
self.find_pin()
isolength=2.6 #mm
self.draw_on_pin(isolength)
# self.draw_on_pin(isolength)
self.matrix_shape=(270,210)
self.read_dxf_as_matrix()
self.connections_list=np.array([[0,0],[0,0]]).reshape(1,2,2)
connection_amount=4
for i in range(connection_amount):
s=random.randint(0,len(self.center_arr)-1)
e=random.randint(0,len(self.center_arr)-1)
connections=np.array([[self.center_arr[s],self.center_arr[e]]]).reshape(1,2,2)
self.connections_list=np.append(self.connections_list,connections,axis=0)
# self.connections_list=np.array([[0,0],[0,0]]).reshape(1,2,2)
# connection_amount=4
# for i in range(connection_amount):
# s=random.randint(0,len(self.center_arr)-1)
# e=random.randint(0,len(self.center_arr)-1)
# connections=np.array([[self.center_arr[s],self.center_arr[e]]]).reshape(1,2,2)
# self.connections_list=np.append(self.connections_list,connections,axis=0)
# self.connections_list=np.rint(self.connections_list)[1:]
############for testing and demo purpose #############
self.connections_list=self.test_connections()
self.connections_list=np.rint(self.connections_list)[1:]
# self.matrix_temp=copy.deepcopy(self.matrix)
# self.img=plt.imshow(self.matrix_temp,interpolation='nearest',cmap=cm.Spectral)
# ani=animation.FuncAnimation(self.fig,self.find_multi_path,interval=10)
......@@ -106,7 +112,7 @@ class auto_rounter:
for e in self.msp.query('Arc LINE[layer=="Cut"]'):
if e.dxf.start[0]>=179:
self.msp.delete_entity(e)
def draw_on_pin(self,fulllength): #isolation
iso=self.dwg.blocks.new(name='ISO_BLK')
......@@ -193,11 +199,11 @@ class auto_rounter:
def find_multi_path(self,i):
"""connection list shape : NX2X2 """
E=7
E=20
print("==========Auto rounting start===========")
for episode in range(E):
print 'episode:',episode+1,'==========='
print 'episode:',episode+1,'(/',E,')==========='
self.matrix_temp=copy.deepcopy(self.matrix)
self.Q=0
self.fail_flag=False
......@@ -207,24 +213,26 @@ class auto_rounter:
current_solving=np.array([init_s]).reshape(1,2,2)
con_list_temp=np.delete(self.connections_list,random_ix,axis=0)
self.cur_path=self.find_a_path(self.matrix_temp,init_s[0],init_s[1])
self.draw_a_path(self.cur_path,self.matrix_temp)
cur_path=self.find_a_path(self.matrix_temp,init_s[0],init_s[1])
self.draw_a_path(cur_path,self.matrix_temp)
# self.img.set_array(self.matrix_temp)
cost=self.get_cost(self.cur_path)
cost=self.get_cost(cur_path)
self.Q=self.Q+cost
curpath_temp=[cur_path]
while len(con_list_temp)!=0:
random_ix=random.randint(0,len(con_list_temp)-1)
next_conn=con_list_temp[random_ix]
current_solving=np.append(current_solving,next_conn.reshape(1,2,2),axis=0)
con_list_temp=np.delete(con_list_temp,random_ix,axis=0)
self.curpath=self.find_a_path(self.matrix_temp,next_conn[0],next_conn[1])
self.draw_a_path(self.curpath,self.matrix_temp)
curpath=self.find_a_path(self.matrix_temp,next_conn[0],next_conn[1])
self.draw_a_path(curpath,self.matrix_temp)
curpath_temp.append(curpath)
# self.img.set_array(self.matrix_temp)
cost=self.get_cost(self.curpath)
cost=self.get_cost(curpath)
self.Q=self.Q+cost
if episode==0:
......@@ -232,21 +240,41 @@ class auto_rounter:
if self.Q<=self.Q_buff:
self.Q_buff=copy.deepcopy(self.Q)
self.final_solving=current_solving
self.final_path=self.cur_path
self.final_path=curpath_temp
self.final_fail=self.fail_flag
print 'Current cost:',self.Q,'Best cost',self.Q_buff
episode+=1
if not self.final_fail:
self.draw_a_path(self.final_path,self.matrix,True)
# self.draw_a_path(self.final_path[1],self.matrix,True)
else:
print 'Cannot solve more than one path'
# plt.imshow(self.matrix_temp)
# plt.show()
# if not self.final_fail:
for i in range(len(self.final_path)):
self.draw_a_path(self.final_path[i],self.matrix,True)
# else:
# print 'One or more path cannot be solved'
def test_connections(self):
y=97
x=90
arti_pin_array=np.empty((1,2))
center_pin_conn=np.empty((1,2))
pin_conn=np.empty((1,2,2))
for i in range(10):
arti_pin=(x+i,y)
arti_pin_array=np.append(arti_pin_array,[arti_pin],axis=0)
arti_pin_array=arti_pin_array[1:]
for i in range(len(self.center_arr)):
if self.center_arr[i][1]<60:
center_pin_conn=np.append(center_pin_conn,self.center_arr[i].reshape(1,2),axis=0)
if len(center_pin_conn)>10: break
center_pin_conn=center_pin_conn[1:]
for i in range(10):
pin_conn_temp=np.array([arti_pin_array[i],center_pin_conn[i]]).reshape(1,2,2)
pin_conn=np.append(pin_conn,pin_conn_temp,axis=0)
pin_conn=pin_conn[1:]
return pin_conn
# def main():
path='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/'
......
journal_media/dxf_circuit.png

126 KiB

journal_media/path_fail.gif

748 KiB

This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment