Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rocoelectrical
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rocoelec
rocoelectrical
Commits
224c76c1
Commit
224c76c1
authored
5 years ago
by
Jingyan Ling
Browse files
Options
Downloads
Patches
Plain Diff
multi-node path-finding algorithm done
parent
ff517ce3
Branches
Branches containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+9
-1
9 additions, 1 deletion
README.md
analyze_dxf.py
+43
-32
43 additions, 32 deletions
analyze_dxf.py
journal_media/learning_episodes.gif
+0
-0
0 additions, 0 deletions
journal_media/learning_episodes.gif
silhouette_ele.dxf
+416
-2
416 additions, 2 deletions
silhouette_ele.dxf
with
468 additions
and
35 deletions
README.md
+
9
−
1
View file @
224c76c1
...
...
@@ -179,4 +179,12 @@
-
Able to show the learning process:
-
Trying different combination of solving order
-
Try to give the best order of solving multiple path
-
!
[
path_learning.gif
](
journal_media/path_learning.gif
)
\ No newline at end of file
##### Auto-routing learning process:
-
!
[
path_learning.gif
](
journal_media/path_learning.gif
)
-
Comparison between episodes and choose best combo of paths
-
!
[
learning_episodes.gif
](
journal_media/learning_episodes.gif
)
##### Issues and TODO
-
Path export from optimization is messed up
-
Obstacles setting are incorrect
\ No newline at end of file
This diff is collapsed.
Click to expand it.
analyze_dxf.py
+
43
−
32
View file @
224c76c1
...
...
@@ -15,15 +15,12 @@ import matplotlib.animation as animation
from
matplotlib
import
cm
from
array2gif
import
write_gif
class
dxf_edito
r
:
class
auto_rounte
r
:
def
__init__
(
self
,
path
,
dxf_file
):
self
.
dwg
=
ezdxf
.
readfile
(
path
+
dxf_file
)
self
.
msp
=
self
.
dwg
.
modelspace
()
self
.
dxf_name
=
'
silhouette_ele.dxf
'
self
.
fig
=
plt
.
figure
()
# self.fig.show()
# self.img_name='silouette_ele.png'
self
.
fail_flag
=
False
#return True when path not found
self
.
create_layer
(
'
Cut
'
,
5
)
...
...
@@ -54,22 +51,15 @@ class dxf_editor:
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
)
plt
.
show
()
# 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)
# plt.show()
self
.
find_multi_path
(
1
)
self
.
dwg
.
saveas
(
self
.
dxf_name
)
# os.system("inkscape -f silhouette_ele.dxf -e silouette_ele.png")
# self.img=cv2.imread(path+self.img_name)
# print(self.img)
def
update_img
(
self
,
i
):
self
.
img
.
set_array
(
i
)
def
create_layer
(
self
,
layer_name
,
color
):
if
not
layer_name
in
self
.
dwg
.
layers
:
...
...
@@ -193,6 +183,8 @@ class dxf_editor:
def
get_cost
(
self
,
path
):
if
len
(
path
)
==
0
:
#if no path found
print
(
'
one path not found
'
)
self
.
fail_flag
=
True
cost
=
1000
else
:
cost
=
len
(
path
)
...
...
@@ -200,37 +192,56 @@ class dxf_editor:
def
find_multi_path
(
self
,
i
):
"""
pin_connection shape : NX2X2
"""
E
=
1
print
(
'
test=========
'
)
"""
connection list shape : NX2X2
"""
E
=
7
print
(
"
==========Auto rounting start===========
"
)
for
episode
in
range
(
E
):
print
'
episode:
'
,
episode
+
1
,
'
===========
'
self
.
matrix_temp
=
copy
.
deepcopy
(
self
.
matrix
)
self
.
Q
=
0
self
.
fail_flag
=
False
random_ix
=
random
.
randint
(
0
,
len
(
self
.
connections_list
)
-
1
)
init_s
=
self
.
connections_list
[
random_ix
]
current_solving
=
np
.
array
([
init_s
]).
reshape
(
1
,
2
,
2
)
con_list_temp
=
np
.
delete
(
self
.
connections_list
,
random_ix
,
axis
=
0
)
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
)
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
)
#
self.img.set_array(self.matrix_temp)
cost
=
self
.
get_cost
(
cur_path
)
cost
=
self
.
get_cost
(
self
.
cur_path
)
self
.
Q
=
self
.
Q
+
cost
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
)
curpath
=
self
.
find_a_path
(
self
.
matrix_temp
,
next_conn
[
0
],
next_conn
[
1
])
self
.
draw_a_path
(
curpath
,
self
.
matrix_temp
)
self
.
img
.
set_array
(
self
.
matrix_temp
)
self
.
curpath
=
self
.
find_a_path
(
self
.
matrix_temp
,
next_conn
[
0
],
next_conn
[
1
])
self
.
draw_a_path
(
self
.
curpath
,
self
.
matrix_temp
)
#
self.img.set_array(self.matrix_temp)
cost
=
self
.
get_cost
(
curpath
)
cost
=
self
.
get_cost
(
self
.
curpath
)
self
.
Q
=
self
.
Q
+
cost
if
episode
==
0
:
self
.
Q_buff
=
copy
.
deepcopy
(
self
.
Q
)
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_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()
...
...
@@ -240,7 +251,7 @@ class dxf_editor:
# def main():
path
=
'
/home/jingyan/Documents/summer_intern_lemur/roco_electrical/
'
dxf_file
=
'
graph-silhouette.dxf
'
edit
=
dxf_edito
r
(
path
,
dxf_file
)
router
=
auto_rounte
r
(
path
,
dxf_file
)
# animation.FuncAnimation(edit.fig,plt.imshow(edit.matrix_temp))
# plt.show()
...
...
This diff is collapsed.
Click to expand it.
journal_media/learning_episodes.gif
0 → 100644
+
0
−
0
View file @
224c76c1
161 KiB
This diff is collapsed.
Click to expand it.
silhouette_ele.dxf
+
416
−
2
View file @
224c76c1
...
...
@@ -53,11 +53,11 @@ $HANDLING
9
$TDUPDATE
40
2458673.
53419
2458673.
68162
9
$HANDSEED
5
3
0B
3
22
9
$DWGCODEPAGE
3
...
...
@@ -10513,6 +10513,420 @@ ISO_BLK
67
0
0
LINE
5
30B
8
Circuit
10
97.0
20
186.0
11
98.0
21
186.0
6
DASHDOT
67
0
0
LINE
5
30C
8
Circuit
10
98.0
20
186.0
11
99.0
21
186.0
6
DASHDOT
67
0
0
LINE
5
30D
8
Circuit
10
99.0
20
186.0
11
100.0
21
186.0
6
DASHDOT
67
0
0
LINE
5
30E
8
Circuit
10
100.0
20
186.0
11
101.0
21
186.0
6
DASHDOT
67
0
0
LINE
5
30F
8
Circuit
10
101.0
20
186.0
11
102.0
21
187.0
6
DASHDOT
67
0
0
LINE
5
310
8
Circuit
10
102.0
20
187.0
11
103.0
21
188.0
6
DASHDOT
67
0
0
LINE
5
311
8
Circuit
10
103.0
20
188.0
11
104.0
21
188.0
6
DASHDOT
67
0
0
LINE
5
312
8
Circuit
10
104.0
20
188.0
11
105.0
21
188.0
6
DASHDOT
67
0
0
LINE
5
313
8
Circuit
10
105.0
20
188.0
11
106.0
21
188.0
6
DASHDOT
67
0
0
LINE
5
314
8
Circuit
10
106.0
20
188.0
11
107.0
21
189.0
6
DASHDOT
67
0
0
LINE
5
315
8
Circuit
10
107.0
20
189.0
11
108.0
21
189.0
6
DASHDOT
67
0
0
LINE
5
316
8
Circuit
10
108.0
20
189.0
11
109.0
21
189.0
6
DASHDOT
67
0
0
LINE
5
317
8
Circuit
10
109.0
20
189.0
11
110.0
21
190.0
6
DASHDOT
67
0
0
LINE
5
318
8
Circuit
10
110.0
20
190.0
11
111.0
21
191.0
6
DASHDOT
67
0
0
LINE
5
319
8
Circuit
10
111.0
20
191.0
11
112.0
21
192.0
6
DASHDOT
67
0
0
LINE
5
31A
8
Circuit
10
112.0
20
192.0
11
113.0
21
192.0
6
DASHDOT
67
0
0
LINE
5
31B
8
Circuit
10
113.0
20
192.0
11
114.0
21
193.0
6
DASHDOT
67
0
0
LINE
5
31C
8
Circuit
10
114.0
20
193.0
11
115.0
21
193.0
6
DASHDOT
67
0
0
LINE
5
31D
8
Circuit
10
115.0
20
193.0
11
116.0
21
193.0
6
DASHDOT
67
0
0
LINE
5
31E
8
Circuit
10
116.0
20
193.0
11
117.0
21
194.0
6
DASHDOT
67
0
0
LINE
5
31F
8
Circuit
10
117.0
20
194.0
11
118.0
21
195.0
6
DASHDOT
67
0
0
LINE
5
320
8
Circuit
10
118.0
20
195.0
11
119.0
21
195.0
6
DASHDOT
67
0
0
LINE
5
321
8
Circuit
10
119.0
20
195.0
11
120.0
21
196.0
6
DASHDOT
67
0
0
VIEWPORT
5
27
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment