Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
7112634b
Commit
7112634b
authored
May 12, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e5aef07a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+11
-6
No files found.
wcfs/internal/xbtree.py
View file @
7112634b
...
...
@@ -84,6 +84,9 @@ import itertools
import
re
inf
=
float
(
'inf'
)
import
numpy
as
np
import
scipy.optimize
# Tree represents a tree node.
class
Tree
(
object
):
...
...
@@ -241,18 +244,18 @@ def Restructure(ztree, newStructure):
assert
isinstance
(
rzn
.
node
,
(
ztreeType
,
zbucketType
))
for
rn
in
RNv
:
assert
isinstance
(
rn
,
_NodeInRange
)
assert
isinstance
(
rn
.
node
,
(
Tree
|
Bucket
))
assert
isinstance
(
rn
.
node
,
(
Tree
,
Bucket
))
assert
not
hasattr
(
rn
.
node
,
'Z'
)
rn
.
node
.
Z
=
None
# prepare cost matrix
C
=
np
.
zeros
((
len
(
RNv
),
len
(
RZv
)))
for
j
in
range
(
RNv
):
# "workers"
for
i
in
range
(
RZv
):
# "jobs"
C
[
j
,
i
]
=
D
(
A
[
i
],
B
[
j
])
C
[
j
,
i
]
=
D
(
RZv
[
i
],
RNv
[
j
])
# find the assignments.
# TODO try to avoid scipy dependency; we could also probably make
# assignments more efficiently taking that Av and Bv are key↑ and the
# property of D function so that if B2 > B1 (all keys in B2 > all keys
...
...
@@ -275,10 +278,12 @@ def Restructure(ztree, newStructure):
zn
=
zbucketType
()
n
.
Z
=
zn
if
len
(
Av
)
==
len
(
Bv
):
# XXX assert the result is 1-1 mapping
if
len
(
RZv
)
==
len
(
RNv
):
# assert the result is 1-1 mapping
for
j
in
range
(
len
(
RNv
)):
assert
RNv
[
j
].
node
.
Z
is
RZv
[
j
].
node
# XXX assert assignments are in key↑ order
# XXX assert assignments are in key↑ order
?
zrlevelv
=
list
(
__zwalkBFS
(
ztree
))
# [] of _NodeInRange
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment