Commit 1c9edab5 authored by K Z's avatar K Z
Browse files

opa

No related merge requests found
Showing with 53 additions and 13 deletions
+53 -13
......@@ -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_object_to_grasp_sphere
cfg.get_rgab_object_callback = get_obj_hard_ellipsoid_move
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(name2, '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
......@@ -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
......@@ -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
......@@ -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 = 1000 # pylint: disable=invalid-name
MOCK_DENSITY: int = 100 # pylint: disable=invalid-name
# Create body
material = struct_material2object_material(material)
......
......@@ -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)
......
......@@ -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"):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment