Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mining in Logarithmic Space
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOISON Benjamin
Mining in Logarithmic Space
Commits
b5833c06
Unverified
Commit
b5833c06
authored
1 year ago
by
Benjamin Loison
Browse files
Options
Downloads
Patches
Plain Diff
First try to correct `KEEPING_ALL_BLOCKS_SINCE_LAST_M_HIGHER_BLOCK`
parent
b752053e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mining_in_logarithmic_space.py
+27
-22
27 additions, 22 deletions
mining_in_logarithmic_space.py
with
27 additions
and
22 deletions
mining_in_logarithmic_space.py
+
27
−
22
View file @
b5833c06
...
...
@@ -32,17 +32,6 @@ def Dissolve(m, k, C, previous_score, previous_ℓ):
else
:
CStar
[
CIndex
].
level_min
-=
1
break
if
KEEPING_ALL_BLOCKS_SINCE_LAST_M_HIGHER_BLOCK
:
D
[
ℓ
]
=
uparrow
(
CStar
,
ℓ
)
previousCStarμ
=
D
[
ℓ
]
for
μ
in
range
(
ℓ
-
1
,
-
1
,
-
1
):
b
=
previousCStarμ
[
-
m
]
CStarμ
=
uparrow
(
CStar
,
μ
)
CStarμSinceb
=
[
block
for
block
in
CStarμ
if
block
.
height
>=
b
.
height
]
chains
=
{
chainsIndex
:
chain
for
chainsIndex
,
chain
in
enumerate
([
CStarμ
[
-
2
*
m
:],
CStarμSinceb
])}
D
[
μ
]
=
U
(
chains
)
previousCStarμ
=
CStarμ
else
:
for
μ
in
range
(
ℓ
+
1
):
D
[
μ
]
=
uparrow
(
CStar
,
μ
)
else
:
...
...
@@ -51,7 +40,7 @@ def Dissolve(m, k, C, previous_score, previous_ℓ):
CStarScore
=
score
(
CStar
,
ℓ
)
if
(
IS_EPSILON_TARGET_DEFINITION
and
(
previous_score
-
CStarScore
)
>=
sanityTargetDifferenceThreshold
)
or
(
not
IS_EPSILON_TARGET_DEFINITION
and
CStarScore
<
previous_score
):
print
(
f
'
score decreasing! previous:
{
previous_score
}
, newest:
{
CStarScore
}
'
)
exit
(
2
)
#
exit(2)
χ
=
C
[
-
k
:]
return
(
D
,
ℓ
,
χ
,
CStarScore
)
...
...
@@ -67,6 +56,22 @@ def getFirstBlockExceedingBlocksPerLevel(C, maximumBlocksPerLevel, ℓ):
ℓ
-=
1
blocksPerLevel
=
[
0
]
*
κ
firstBlockIndexPerLevel
=
[
None
]
*
κ
# Could maybe merge both cases if doesn't unoptimize much.
if
KEEPING_ALL_BLOCKS_SINCE_LAST_M_HIGHER_BLOCK
:
# Could maybe optimize by only keeping last `m` blocks height per level but due to Python list implementation I have doubts.
# Could maybe get rid of `blocksPerLevel` but only use `blocksHeightPerLevel` if don't apply just above optimization.
blocksHeightPerLevel
=
[[]]
*
κ
for
CIndex
,
block
in
enumerate
(
C
):
for
level
in
range
(
block
.
level_min
,
min
(
block
.
level
,
ℓ
)
+
1
):
blocksPerLevel
[
level
]
+=
1
blocksHeightPerLevel
[
level
]
+=
[
C
[
CIndex
].
height
]
if
firstBlockIndexPerLevel
[
level
]
==
None
:
firstBlockIndexPerLevel
[
level
]
=
CIndex
firstBlockLevelIndex
=
firstBlockIndexPerLevel
[
level
]
if
blocksPerLevel
[
level
]
>
maximumBlocksPerLevel
and
blocksPerLevel
[
level
+
1
]
>=
m
and
C
[
firstBlockLevelIndex
].
height
<
blocksHeightPerLevel
[
level
+
1
][
-
m
]:
return
firstBlockLevelIndex
,
level
return
None
,
None
else
:
for
CIndex
,
block
in
enumerate
(
C
):
for
level
in
range
(
block
.
level_min
,
min
(
block
.
level
,
ℓ
)
+
1
):
blocksPerLevel
[
level
]
+=
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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