Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Melodic
melodic-upperware
Commits
1ce46825
Commit
1ce46825
authored
Apr 23, 2020
by
Michal Jankowski
Browse files
Memory limiter queue control when deleting empty solutions.
parent
b9954f07
Changes
4
Hide whitespace changes
Inline
Side-by-side
zpp-solver/mcts-solver/src/main/java/eu/melodic/upperware/mcts_solver/solver/mcts/tree/MemoryLimiter.java
View file @
1ce46825
...
...
@@ -11,4 +11,6 @@ public interface MemoryLimiter {
void
decreaseCount
(
int
count
);
// Creates node with certain value.
Node
createNode
(
int
value
);
// Removes node from queue, does nothing if it's not in queue.
void
removeNodeFromQueue
(
Node
node
);
}
\ No newline at end of file
zpp-solver/mcts-solver/src/main/java/eu/melodic/upperware/mcts_solver/solver/mcts/tree/Tree.java
View file @
1ce46825
...
...
@@ -89,6 +89,7 @@ public abstract class Tree {
node
.
getParent
().
removeChild
(
node
);
if
(
node
.
getParent
()
!=
root
&&
node
.
getParent
().
getChildrenSize
()
==
0
)
{
memoryLimiter
.
removeNodeFromQueue
(
node
.
getParent
());
removeLeaf
(
node
.
getParent
());
}
// There's a corner case in which root can lose its all children.
...
...
zpp-solver/mcts-solver/src/main/java/eu/melodic/upperware/mcts_solver/solver/mcts/tree_impl/MemoryLimiterImpl.java
View file @
1ce46825
...
...
@@ -12,14 +12,17 @@ public class MemoryLimiterImpl implements MemoryLimiter {
this
.
limit
=
limit
;
}
@Override
public
boolean
shouldPruneTree
()
{
return
count
>
limit
&&
!
accessQueue
.
empty
();
}
@Override
public
Node
popNodeToPrune
()
{
return
accessQueue
.
popFront
();
}
@Override
public
void
updateRecentlyAccessedNodes
(
Node
startingNode
)
{
Node
current
=
startingNode
;
...
...
@@ -31,15 +34,22 @@ public class MemoryLimiterImpl implements MemoryLimiter {
}
}
@Override
public
void
decreaseCount
(
int
count
)
{
this
.
count
-=
count
;
}
@Override
public
Node
createNode
(
int
value
)
{
count
++;
return
new
NodeImpl
(
value
);
}
@Override
public
void
removeNodeFromQueue
(
Node
node
)
{
accessQueue
.
removeNodeFromQueue
((
NodeImpl
)
node
);
}
private
void
updateRecentlyAccessedNode
(
Node
node
)
{
accessQueue
.
pushBack
(
node
);
}
...
...
zpp-solver/mcts-solver/src/main/java/eu/melodic/upperware/mcts_solver/solver/mcts/tree_impl/Queue.java
View file @
1ce46825
...
...
@@ -42,7 +42,7 @@ public class Queue {
return
front
==
null
;
}
p
rivate
void
removeNodeFromQueue
(
NodeImpl
node
)
{
p
ublic
void
removeNodeFromQueue
(
NodeImpl
node
)
{
NodeImpl
previous
=
node
.
getQueueLinker
().
getPrevious
();
NodeImpl
next
=
node
.
getQueueLinker
().
getNext
();
...
...
Write
Preview
Supports
Markdown
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