Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rocoelectrical
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue 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
Jingyan Ling
rocoelectrical
Commits
ff517ce3
Commit
ff517ce3
authored
5 years ago
by
Jingyan Ling
Browse files
Options
Downloads
Patches
Plain Diff
update 0708 journal, script
parent
5a46cc97
Branches
Branches containing commit
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+12
-2
12 additions, 2 deletions
README.md
analyze_dxf.py
+28
-20
28 additions, 20 deletions
analyze_dxf.py
journal_media/path_learning.gif
+0
-0
0 additions, 0 deletions
journal_media/path_learning.gif
silhouette_ele.dxf
+2
-4808
2 additions, 4808 deletions
silhouette_ele.dxf
with
42 additions
and
4830 deletions
README.md
+
12
−
2
View file @
ff517ce3
...
...
@@ -148,7 +148,7 @@
-
break single circuit trace to parallel traces
-
solve the accuracy problem
### 07/0
4
/2019 (Fri)
### 07/0
5
/2019 (Fri)
-
Write out algorithm for multi-node path finding
-
pseudo code:
...
...
@@ -169,4 +169,14 @@
-
Input: NX2X2 array specifies desired pin connections
-
Research on KiCAD import needs and python API
\ No newline at end of file
-
Research on KiCAD import needs and python API
### 07/082019 (Mon)
-
Debug multi-node path finding:
-
some obstacles are ignored
-
too close to each other
-
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
This diff is collapsed.
Click to expand it.
analyze_dxf.py
+
28
−
20
View file @
ff517ce3
...
...
@@ -12,6 +12,8 @@ from pathfinding.finder.a_star import AStarFinder
import
copy
import
matplotlib.pyplot
as
plt
import
matplotlib.animation
as
animation
from
matplotlib
import
cm
from
array2gif
import
write_gif
class
dxf_editor
:
def
__init__
(
self
,
path
,
dxf_file
):
...
...
@@ -39,17 +41,11 @@ class dxf_editor:
self
.
matrix_shape
=
(
270
,
210
)
self
.
read_dxf_as_matrix
()
# start_point_arr=np.rint(self.center_arr[1])
# end_point_arr=(120,172)
# start_point=[start_point_arr[0],start_point_arr[1]]
# end_point=[end_point_arr[0],end_point_arr[1]]
# self.path=self.find_a_path(self.matrix,start_point,end_point)
# self.draw_a_path(self.path,self.matrix,True)
self
.
connections_list
=
np
.
array
([[
0
,
0
],[
0
,
0
]]).
reshape
(
1
,
2
,
2
)
connection_amount
=
5
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
)
...
...
@@ -57,7 +53,14 @@ class dxf_editor:
self
.
connections_list
=
np
.
append
(
self
.
connections_list
,
connections
,
axis
=
0
)
self
.
connections_list
=
np
.
rint
(
self
.
connections_list
)[
1
:]
self
.
find_multi_path
(
self
.
connections_list
)
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
.
dwg
.
saveas
(
self
.
dxf_name
)
# os.system("inkscape -f silhouette_ele.dxf -e silouette_ele.png")
...
...
@@ -65,6 +68,8 @@ class dxf_editor:
# 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
:
...
...
@@ -187,26 +192,27 @@ class dxf_editor:
'
linetype
'
:
'
DASHDOT
'
})
def
get_cost
(
self
,
path
):
if
len
(
path
)
==
0
:
if
len
(
path
)
==
0
:
#if no path found
cost
=
1000
else
:
cost
=
len
(
path
)
return
cost
def
find_multi_path
(
self
,
pin_connections
):
def
find_multi_path
(
self
,
i
):
"""
pin_connection shape : NX2X2
"""
E
=
2
E
=
1
print
(
'
test=========
'
)
for
episode
in
range
(
E
):
self
.
matrix_temp
=
copy
.
deepcopy
(
self
.
matrix
)
self
.
Q
=
0
random_ix
=
random
.
randint
(
0
,
len
(
pin_
connections
)
-
1
)
init_s
=
pin_
connections
[
random_ix
]
con_list_temp
=
np
.
delete
(
pin_
connections
,
random_ix
,
axis
=
0
)
random_ix
=
random
.
randint
(
0
,
len
(
self
.
connections
_list
)
-
1
)
init_s
=
self
.
connections
_list
[
random_ix
]
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
,
True
)
self
.
draw_a_path
(
cur_path
,
self
.
matrix_temp
)
self
.
img
.
set_array
(
self
.
matrix_temp
)
cost
=
self
.
get_cost
(
cur_path
)
self
.
Q
=
self
.
Q
+
cost
...
...
@@ -218,14 +224,16 @@ class dxf_editor:
curpath
=
self
.
find_a_path
(
self
.
matrix_temp
,
next_conn
[
0
],
next_conn
[
1
])
self
.
draw_a_path
(
curpath
,
self
.
matrix_temp
,
True
)
self
.
draw_a_path
(
curpath
,
self
.
matrix_temp
)
self
.
img
.
set_array
(
self
.
matrix_temp
)
cost
=
self
.
get_cost
(
curpath
)
self
.
Q
=
self
.
Q
+
cost
episode
+=
1
plt
.
imshow
(
self
.
matrix_temp
)
plt
.
show
()
# plt.imshow(self.matrix_temp)
# plt.show()
...
...
This diff is collapsed.
Click to expand it.
journal_media/path_learning.gif
0 → 100644
+
0
−
0
View file @
ff517ce3
97.4 KiB
This diff is collapsed.
Click to expand it.
silhouette_ele.dxf
+
2
−
4808
View file @
ff517ce3
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