Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
itmo-sai-code
rostok
Commits
69c6eb1a
Commit
69c6eb1a
authored
2 years ago
by
Mikhail Chaikovskii
Browse files
Options
Download
Email Patches
Plain Diff
fix merge
parent
559f74ec
master
ClosedLinkage
alternative_builder
app_with_pictures
article
article3-accurate-mass-geometric
article3-exception
article3-mcts-tree-random
article3-parallel_core
article3-shaker-and-show-results
article3-tune_hyperparameters
article_3
article_3_K
article_3_add_optimizer_holy_3
article_3_k2_hull
article_3_k_parallel
article_force_Kirill
article_learning
article_mor
article_trajectories
builder_update
embedding/graph-pyg
feature/golem_casessss
feature/paralel_script_for_run
feature/split_my_shue
feature/tendon_controller1
fix-readme-badges
fix/length_fix
fix_examples_grasping
functional_controller
graph-heurisric-search
graph/embedding
gym_enviroment
industrial/grab-pipe-one-robot
optimzation/logging
prototype/tendon_ext_force
scripts_of_running
sensor_tests
simple_simulation
spatial-math-toolbox-integrated
test_designs
test_run
5 merge requests
!68
Adds MCTSReporter class
,
!74
Reporter and graph comparison
,
!81
Mcts helper v2
,
!80
Mcts helper and Saveable class
,
!67
add seen rewards to mcts
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/app.py
+1
-1
app/app.py
app/rule_extention.py
+2
-2
app/rule_extention.py
rostok/graph_generators/graph_environment.py
+13
-1
rostok/graph_generators/graph_environment.py
rostok/graph_grammar/node.py
+15
-5
rostok/graph_grammar/node.py
with
31 additions
and
9 deletions
+31
-9
app/app.py
View file @
69c6eb1a
...
...
@@ -58,7 +58,7 @@ control_optimizer = ControlOptimizer(cfg)
# %% Init mcts parameters
# Hyperparameters mctss
iteration_limit
=
2
0
iteration_limit
=
5
0
# Initialize MCTS
searcher
=
mcts
.
mcts
(
iterationLimit
=
iteration_limit
)
...
...
This diff is collapsed.
Click to expand it.
app/rule_extention.py
View file @
69c6eb1a
...
...
@@ -185,8 +185,8 @@ def init_extension_rules():
rule_vocab
.
create_rule
(
"InitMechanism_3_R_A"
,
[
"ROOT"
],
[
"F"
,
"SML"
,
"SMRPA"
,
"SMRMA"
,
"EM"
,
"EM"
,
"EM"
],
0
,
0
,[(
0
,
1
),(
0
,
2
),(
0
,
3
),(
1
,
4
),(
2
,
5
),(
3
,
6
)])
rule_vocab
.
create_rule
(
"InitMechanism_3_L"
,
[
"ROOT"
],
[
"F"
,
"SMLP"
,
"SMLM"
,
"SMR"
,
"EM"
,
"EM"
,
"EM"
],
0
,
0
,
[(
0
,
1
),(
0
,
2
),(
0
,
3
),(
1
,
4
),(
2
,
5
),(
3
,
6
)])
rule_vocab
.
create_rule
(
"InitMechanism_3_L_A"
,
[
"ROOT"
],
[
"F"
,
"SMLPA"
,
"SMLMA"
,
"SMR"
,
"EM"
,
"EM"
,
"EM"
],
0
,
0
,
[(
0
,
1
),(
0
,
2
),(
0
,
3
),(
1
,
4
),(
2
,
5
),(
3
,
6
)])
#
rule_vocab.create_rule("InitMechanism_4", ["ROOT"], ["F", "SMLP","SMLM", "SMRP","SMRM","EM","EM","EM","EM"], 0 , 0, [(0,1),(0,2),(0,3),(0,4),(1,5),(2,6),(3,7),(4,8)])
#
rule_vocab.create_rule("InitMechanism_4_A", ["ROOT"], ["F", "SMLPA","SMLMA", "SMRPA","SMRMA","EM","EM","EM","EM"], 0 , 0, [(0,1),(0,2),(0,3),(0,4),(1,5),(2,6),(3,7),(4,8)])
rule_vocab
.
create_rule
(
"InitMechanism_4"
,
[
"ROOT"
],
[
"F"
,
"SMLP"
,
"SMLM"
,
"SMRP"
,
"SMRM"
,
"EM"
,
"EM"
,
"EM"
,
"EM"
],
0
,
0
,
[(
0
,
1
),(
0
,
2
),(
0
,
3
),(
0
,
4
),(
1
,
5
),(
2
,
6
),(
3
,
7
),(
4
,
8
)])
rule_vocab
.
create_rule
(
"InitMechanism_4_A"
,
[
"ROOT"
],
[
"F"
,
"SMLPA"
,
"SMLMA"
,
"SMRPA"
,
"SMRMA"
,
"EM"
,
"EM"
,
"EM"
,
"EM"
],
0
,
0
,
[(
0
,
1
),(
0
,
2
),(
0
,
3
),(
0
,
4
),(
1
,
5
),(
2
,
6
),(
3
,
7
),(
4
,
8
)])
rule_vocab
.
create_rule
(
"FingerUpper"
,
[
"EM"
],
[
"J"
,
"L"
,
"EM"
],
0
,
2
,
[(
0
,
1
),(
1
,
2
)])
rule_vocab
.
create_rule
(
"TerminalFlat1"
,
[
"F"
],
[
"F1"
],
0
,
0
)
...
...
This diff is collapsed.
Click to expand it.
rostok/graph_generators/graph_environment.py
View file @
69c6eb1a
...
...
@@ -214,16 +214,28 @@ class GraphVocabularyEnvironment(GraphEnvironment):
return
list
(
possible_actions
)
def
getReward
(
self
):
if
len
(
seen_graphs
)
>
0
:
seen_graphs_t
=
list
(
zip
(
*
seen_graphs
))
i
=
0
for
graph
in
seen_graphs_t
[
0
]:
if
graph
==
self
.
graph
:
self
.
reward
=
seen_graphs_t
[
1
][
i
]
self
.
movments_trajectory
=
seen_graphs_t
[
2
][
i
]
reporter
.
add_reward
(
self
.
state
,
self
.
reward
,
self
.
movments_trajectory
)
print
(
'seen reward:'
,
self
.
reward
)
return
self
.
reward
i
+=
1
result_optimizer
=
self
.
optimizer
.
start_optimisation
(
self
.
graph
)
self
.
reward
=
-
result_optimizer
[
0
]
self
.
movments_trajectory
=
result_optimizer
[
1
]
seen_graphs
.
append
([
deepcopy
(
self
.
graph
),
self
.
reward
,
deepcopy
(
self
.
movments_trajectory
)])
reporter
.
add_reward
(
self
.
state
,
self
.
reward
,
self
.
movments_trajectory
)
if
self
.
reward
>
reporter
.
best_reward
:
reporter
.
best_reward
=
self
.
reward
reporter
.
best_control
=
self
.
movments_trajectory
reporter
.
best_state
=
self
.
state
print
(
self
.
reward
)
return
self
.
reward
...
...
This diff is collapsed.
Click to expand it.
rostok/graph_grammar/node.py
View file @
69c6eb1a
...
...
@@ -323,9 +323,19 @@ class GraphGrammar(nx.DiGraph):
return
list
(
dfs_preorder_nodes
(
self
,
self
.
get_root_id
()))
def
__eq__
(
self
,
__o
)
->
bool
:
if
isinstance
(
__o
,
GraphGrammar
):
is_node_eq
=
__o
.
nodes
==
self
.
nodes
is_edge_eq
=
__o
.
edges
==
self
.
edges
return
is_edge_eq
and
is_node_eq
def
__eq__
(
self
,
__rhs
)
->
bool
:
if
isinstance
(
__rhs
,
GraphGrammar
):
self_dfs_paths
=
self
.
graph_partition_dfs
()
self_dfs_paths_lbl
=
[]
for
path
in
self_dfs_paths
:
self_dfs_paths_lbl
.
append
([
self
.
get_node_by_id
(
x
).
label
for
x
in
path
])
self_dfs_paths_lbl
.
sort
(
key
=
lambda
x
:
""
.
join
(
x
))
rhs_dfs_paths
=
__rhs
.
graph_partition_dfs
()
rhs_dfs_paths_lbl
=
[]
for
path
in
rhs_dfs_paths
:
rhs_dfs_paths_lbl
.
append
([
__rhs
.
get_node_by_id
(
x
).
label
for
x
in
path
])
rhs_dfs_paths_lbl
.
sort
(
key
=
lambda
x
:
""
.
join
(
x
))
return
self_dfs_paths_lbl
==
rhs_dfs_paths_lbl
return
False
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help