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
1c9edab5
Commit
1c9edab5
authored
2 years ago
by
K Z
Browse files
Options
Download
Email Patches
Plain Diff
opa
parent
2091317c
article_mor
article
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
article/golem_app.py
+6
-8
article/golem_app.py
article/init_pop.py
+19
-1
article/init_pop.py
article/optmizers_config.py
+24
-0
article/optmizers_config.py
rostok/block_builder/node_render.py
+1
-1
rostok/block_builder/node_render.py
rostok/trajectory_optimizer/control_optimizer.py
+2
-2
rostok/trajectory_optimizer/control_optimizer.py
rostok/utils/dataset_materials/material_dataclass_manipulating.py
+1
-1
...tils/dataset_materials/material_dataclass_manipulating.py
with
53 additions
and
13 deletions
+53
-13
article/golem_app.py
View file @
1c9edab5
...
...
@@ -17,7 +17,7 @@ from golem.core.optimisers.genetic.operators.regularization import \
from
golem.core.optimisers.objective
import
Objective
,
ObjectiveEvaluate
from
golem.core.optimisers.optimization_parameters
import
GraphRequirements
from
golem.core.optimisers.optimizer
import
GraphGenerationParams
from
obj_grasp.objects
import
get_obj_hard_ellipsoid
,
get_object_to_grasp_sphere
from
obj_grasp.objects
import
get_obj_hard_ellipsoid
,
get_object_to_grasp_sphere
,
get_obj_hard_large_ellipsoid
,
get_obj_cyl_pos_parametrize
,
get_obj_hard_ellipsoid_move
,
get_obj_hard_mesh
from
optmizers_config
import
get_cfg_graph
from
rule_sets.ruleset_old_style_graph
import
create_rules
from
rule_sets.rule_extention_golem_edition
import
rule_vocab
,
torque_dict
...
...
@@ -58,7 +58,7 @@ for _ in range(15):
init_population_gr
=
init_pop
.
get_population_zoo
()
initial
=
adapter_local
.
adapt
(
init_population_gr
)
cfg
=
get_cfg_graph
(
torque_dict
)
cfg
.
get_rgab_object_callback
=
get_obj
ect_to_grasp_spher
e
cfg
.
get_rgab_object_callback
=
get_obj
_hard_ellipsoid_mov
e
optic
=
ControlOptimizer
(
cfg
)
build_wrapperd
=
partial
(
custom_metriwith_build_mechs
,
optimizer
=
optic
)
...
...
@@ -114,8 +114,8 @@ optimizer_parameters = GPAlgorithmParameters(
custom_mutation_del
],
crossover_types
=
[
CrossoverTypesEnum
.
gg_subtree
],
regularization_type
=
RegularizationTypesEnum
.
none
,
mutation_strength
=
MutationStrengthEnum
.
strong
,
regularization_type
=
RegularizationTypesEnum
.
decremental
,
mutation_strength
=
MutationStrengthEnum
.
mean
,
)
optimizer
=
EvoGraphOptimizer
(
...
...
@@ -135,8 +135,6 @@ name = str(int(time.time()))
name2
=
str
(
optimizer
.
history
.
final_choices
.
data
[
0
].
fitness
)
name2
=
name2
.
replace
(
"."
,
"_"
)
name2
=
name2
.
replace
(
"-"
,
"_"
)
with
open
(
name
2
,
'wb'
)
as
handle
:
name
=
name
+
name_objective
+
name2
with
open
(
name
,
'wb'
)
as
handle
:
pickle
.
dump
(
optimizer
.
history
,
handle
)
rew
=
optic
.
create_reward_function
(
optimized_mech
)
rew
(
optimized_mech
,
True
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
article/init_pop.py
View file @
1c9edab5
...
...
@@ -98,9 +98,27 @@ def get_population_zoo():
for
struct
in
STRUCTURE_ZOO
:
graphs_one_struct
=
[]
for
_
in
range
(
3
):
for
_
in
range
(
4
):
graph_zoo
=
struct
()
rule_vocab
.
make_graph_terminal
(
graph_zoo
)
graphs_one_struct
.
append
(
graph_zoo
)
# for _ in range(3):
# skoka = random.choice([5, 8, 3, 5, 7])
# gr = make_random_graph(skoka, rule_vocab)
# graphs_one_struct.append(gr)
zoo
.
extend
(
graphs_one_struct
)
return
zoo
def
get_pop_simple
():
finger
=
[]
for
_
in
range
(
3
):
nonterminal
=
get_non_terminal_one_finger
()
rule_vocab
.
make_graph_terminal
(
nonterminal
)
finger
.
append
(
nonterminal
)
for
_
in
range
(
3
):
nonterminal
=
get_non_terminal_two_finger_asym
()
rule_vocab
.
make_graph_terminal
(
nonterminal
)
finger
.
append
(
nonterminal
)
return
finger
\ No newline at end of file
This diff is collapsed.
Click to expand it.
article/optmizers_config.py
View file @
1c9edab5
...
...
@@ -107,6 +107,30 @@ def get_cfg_standart_step():
time_step
=
cfg
.
time_step
,
torque
=
CONST_TORQUE
)
cfg
.
criterion_callback
=
criterion_callback
cfg
.
params_to_timesiries_callback
=
traj_generator_fun
return
cfg
def
get_cfg_small_iter_standart
():
WEIGHT
=
hp
.
CRITERION_WEIGHTS
# Init configuration of control optimizing
cfg
=
ConfigVectorJoints
()
cfg
.
bound
=
(
0
,
15
)
cfg
.
time_optimization
=
hp
.
TIME_OPTIMIZATION
cfg
.
iters
=
10
cfg
.
time_step
=
hp
.
TIME_STEP_SIMULATION
cfg
.
time_sim
=
hp
.
TIME_SIMULATION
cfg
.
flags
=
[
FlagMaxTime
(
cfg
.
time_sim
),
FlagNotContact
(
hp
.
FLAG_TIME_NO_CONTACT
),
FlagSlipout
(
hp
.
FLAG_TIME_NO_CONTACT
,
hp
.
FLAG_TIME_SLIPOUT
)]
"""Wraps function call"""
criterion_callback
=
partial
(
criterion_calc
,
weights
=
WEIGHT
)
traj_generator_fun
=
partial
(
create_torque_traj_from_x
,
stop_time
=
cfg
.
time_sim
,
time_step
=
cfg
.
time_step
)
cfg
.
criterion_callback
=
criterion_callback
cfg
.
params_to_timesiries_callback
=
traj_generator_fun
return
cfg
\ No newline at end of file
This diff is collapsed.
Click to expand it.
rostok/block_builder/node_render.py
View file @
1c9edab5
...
...
@@ -557,7 +557,7 @@ class ChronoBodyEnv(ChronoBody):
pos
:
FrameTransform
=
FrameTransform
([
0
,
0.0
,
0
],
[
1
,
0
,
0
,
0
])):
# This parameter redefined by SetMass
MOCK_DENSITY
:
int
=
100
0
# pylint: disable=invalid-name
MOCK_DENSITY
:
int
=
100
# pylint: disable=invalid-name
# Create body
material
=
struct_material2object_material
(
material
)
...
...
This diff is collapsed.
Click to expand it.
rostok/trajectory_optimizer/control_optimizer.py
View file @
1c9edab5
...
...
@@ -60,7 +60,7 @@ class ConfigVectorJoints(_ConfigRewardFunction):
"""
bound
:
tuple
[
float
,
float
]
=
(
-
1
,
1
)
iters
:
int
=
10
optimizer_scipy
=
partial
(
shgo
)
optimizer_scipy
=
partial
(
direct
)
class
ConfigGraphControl
(
_ConfigRewardFunction
):
...
...
@@ -145,7 +145,7 @@ class ControlOptimizer():
if
len
(
multi_bound
)
==
0
:
return
(
0
,
0
)
time_stopper
=
TimeOptimizerStopper
(
self
.
cfg
.
time_optimization
)
result
=
self
.
cfg
.
optimizer_scipy
(
reward_fun
,
multi_bound
,
callback
=
time_stopper
)
#,
maxiter=self.cfg.iters
,
)
result
=
self
.
cfg
.
optimizer_scipy
(
reward_fun
,
multi_bound
,
maxiter
=
self
.
cfg
.
iters
)
return
(
result
.
fun
,
result
.
x
)
elif
isinstance
(
self
.
cfg
,
ConfigGraphControl
):
n_joint
=
num_joints
(
generated_graph
)
...
...
This diff is collapsed.
Click to expand it.
rostok/utils/dataset_materials/material_dataclass_manipulating.py
View file @
1c9edab5
...
...
@@ -19,7 +19,7 @@ class DefaultChronoMaterial(Material):
name
:
str
=
"default"
type_class
:
str
=
"ChMaterialSurfaceNSC"
Friction
=
0.5
DampingF
=
0.
8
DampingF
=
0.
3
def
struct_material2object_material
(
struct_material
:
Material
,
prefix_setter
:
str
=
"Set"
):
...
...
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