diff --git a/README.md b/README.md index 622636024e..f85e9f23df 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,8 @@ If you want to contribute to Revolve, be sure to review the [contribution guidelines](CONTRIBUTING.md). By participating, you are expected to uphold this code. +[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/ci-group/revolve) + We use [GitHub issues](https://github.com/ci-group/revolve/issues) for tracking requests and bugs. diff --git a/cpprevolve/revolve/gazebo/brains/NeuralNetwork.cpp b/cpprevolve/revolve/gazebo/brains/NeuralNetwork.cpp index 94fd84f372..e809c06bf1 100644 --- a/cpprevolve/revolve/gazebo/brains/NeuralNetwork.cpp +++ b/cpprevolve/revolve/gazebo/brains/NeuralNetwork.cpp @@ -379,6 +379,9 @@ void NeuralNetwork::Step(const double _time) /* set output to be in [0.5 - gain/2, 0.5 + gain/2] */ nextState->at(i) = (0.5 - (gain / 2.0) + nextState->at(i) * gain); + + // add IN connections to oscillators + nextState->at(i) = nextState->at(i) + curNeuronActivation; } break; default: diff --git a/experiments/Environmental_influences_on_evolvable_robots/.DS_Store b/experiments/Environmental_influences_on_evolvable_robots/.DS_Store new file mode 100644 index 0000000000..7c4ca6919d Binary files /dev/null and b/experiments/Environmental_influences_on_evolvable_robots/.DS_Store differ diff --git a/experiments/Environmental_influences_on_evolvable_robots/baseline2.py b/experiments/Environmental_influences_on_evolvable_robots/baseline2.py new file mode 100755 index 0000000000..ab45e23c31 --- /dev/null +++ b/experiments/Environmental_influences_on_evolvable_robots/baseline2.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 100 + population_size = 100 + offspring_size = 50 + front = 'total_slaves' + + # environment world and z-start + environments = {'plane': 0.03, + 'tilted5': 0.1 + } + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=False, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_plane(robot_manager, robot): + #contacts = measures.contacts(robot_manager, robot) + #assert(contacts != 0) + return fitness.displacement_velocity_hill(robot_manager, robot) + + + fitness_function = {'plane': fitness_function_plane, + 'tilted5': fitness_function_plane} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/experiments/Environmental_influences_on_evolvable_robots/bestrobots_summary_renders_journal1_tilted.r b/experiments/Environmental_influences_on_evolvable_robots/bestrobots_summary_renders_journal1_tilted.r new file mode 100644 index 0000000000..89f7fcdc8e --- /dev/null +++ b/experiments/Environmental_influences_on_evolvable_robots/bestrobots_summary_renders_journal1_tilted.r @@ -0,0 +1,86 @@ + +library(sqldf) +require('magick') + +##### change paths/labels/params here ##### + + +paths = c( 'flat', 'tilted', 'baseline2') + +environments = list(c( 'plane'), + c( 'tilted5'), + c( 'plane') +) + +base_directory <- paste('data/', sep='') + +experiments = c(1:20) +gens = 100 +pop = 100 +num_top = 1 + +analysis = 'analysis_journal1_tilted' + +##### change paths/labels/params here ##### + +output_directory = paste(base_directory,analysis, sep='') + + +file <-file(paste(output_directory,'/best.txt',sep=''), open="w") + +# for each method +for(m in 1:length(paths)) +{ + # for each repetition + for (exp in experiments) + { + + input_directory1 <- paste(base_directory, paths[m],'_',exp, '/data_fullevolution/',environments[[m]][1],sep='') + input_directory2 <- paste(base_directory, paths[m],'_',exp, '/selectedpop_', sep='') + + ids_gens = data.frame() + list = strsplit(list.files(paste(input_directory2, environments[[m]][1],'/selectedpop_',gens-1, sep='')), ' ') + for(geno in 1:pop) + { + genome = data.frame(cbind(c(gens), c(strsplit(strsplit(list [[geno]],'_')[[1]][3],'.png')[[1]][1] ))) + names(genome)<-c('generation','robot_id') + ids_gens = rbind(ids_gens,genome) + } + + measures = read.table(paste(input_directory1,"/all_measures.tsv", sep=''), header = TRUE) + bests = sqldf(paste("select robot_id, cons_fitness from measures inner join ids_gens using (robot_id) order by cons_fitness desc limit",num_top)) + + for(b in 1:nrow(bests)) + { + + writeLines( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] ), file ) + print( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] )) + + phenotype= bests[b,'robot_id'] + + for (env in 1:length(environments[[m]])) + { + patha = paste(input_directory2, environments[[m]][env], "/selectedpop_",gens-1,sep="") + + body <- list.files(patha, paste("body_robot_",phenotype,".png$",sep=""), full.names = TRUE) + body = image_read(body) + body = image_scale(body, "100x100") + body = image_border(image_background(body, "white"), "white", "5x5") + + if(b == 1 && env == 1) + { + bodies = body + }else{ + bodies = c(bodies, body) + } + } + } + + side_by_side = image_append(bodies, stack=F) + image_write(side_by_side, path = paste(output_directory,"/",paths[m],'_', environments[[m]][env], "_bodies_best_",exp,".png",sep=''), format = "png") + + } +} + + +close(file) diff --git a/experiments/Environmental_influences_on_evolvable_robots/consolidate_experiments.py b/experiments/Environmental_influences_on_evolvable_robots/consolidate_experiments.py new file mode 100644 index 0000000000..8b5189f207 --- /dev/null +++ b/experiments/Environmental_influences_on_evolvable_robots/consolidate_experiments.py @@ -0,0 +1,138 @@ +import os +import math + +# set these variables according to your experiments # +dirpath = 'data/' +experiments_type = [ + 'baseline2', + 'flat', + 'tilted' +] +environments = { + 'baseline2': ['plane','tilted5'], + 'flat': ['plane'], + 'tilted': ['tilted5'] } + +runs = range(1, 21) + + +# set these variables according to your experiments # + +def build_headers(path1, path2): + + file_summary = open(path1 + "/all_measures.tsv", "w+") + file_summary.write('robot_id\t') + + behavior_headers = [] + behavior_headers.append('velocity') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('displacement_velocity') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('displacement_velocity_hill') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('head_balance') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('contacts') + file_summary.write(behavior_headers[-1]+'\t') + # use this instead? but what if the guy is none? + # with open(path + '/data_fullevolution/descriptors/behavior_desc_robot_1.txt') as file: + # for line in file: + # measure, value = line.strip().split(' ') + # behavior_headers.append(measure) + # file_summary.write(measure+'\t') + + phenotype_headers = [] + with open(path1 + '/descriptors/phenotype_desc_robot_1.txt') as file: + for line in file: + measure, value = line.strip().split(' ') + phenotype_headers.append(measure) + file_summary.write(measure+'\t') + file_summary.write('fitness\t cons_fitness\n') + file_summary.close() + + file_summary = open(path2 + "/snapshots_ids.tsv", "w+") + file_summary.write('generation\trobot_id\n') + file_summary.close() + + return behavior_headers, phenotype_headers + +for exp in experiments_type: + + for env in environments[exp]: + + for run in runs: + + path0 = dirpath + str(exp) + '_' + str(run) + '/data_fullevolution' + path1 = dirpath + str(exp) + '_' + str(run) + '/data_fullevolution/' + env + path2 = dirpath + str(exp) + '_' + str(run) + '/selectedpop_' + env + + behavior_headers, phenotype_headers = build_headers(path1, path2) + + file_summary = open(path1 + "/all_measures.tsv", "a") + for r, d, f in os.walk(path0+'/consolidated_fitness'): + for file in f: + + robot_id = file.split('.')[0].split('_')[-1] + file_summary.write(robot_id+'\t') + + bh_file = path1+'/descriptors/behavior_desc_robot_'+robot_id+'.txt' + if os.path.isfile(bh_file): + with open(bh_file) as file: + for line in file: + if line != 'None': + measure, value = line.strip().split(' ') + file_summary.write(value+'\t') + else: + for h in behavior_headers: + file_summary.write('None'+'\t') + else: + for h in behavior_headers: + file_summary.write('None'+'\t') + + pt_file = path1+'/descriptors/phenotype_desc_robot_'+robot_id+'.txt' + if os.path.isfile(pt_file): + with open(pt_file) as file: + for line in file: + measure, value = line.strip().split(' ') + file_summary.write(value+'\t') + else: + for h in phenotype_headers: + file_summary.write('None'+'\t') + + f_file = open(path1+'/fitness/fitness_robot_'+robot_id+'.txt', 'r') + fitness = f_file.read() + file_summary.write(fitness + '\t') + + cf_file = open(path0+'/consolidated_fitness/consolidated_fitness_robot_'+robot_id+'.txt', 'r') + cons_fitness = cf_file.read() + file_summary.write(cons_fitness + '\n') + + num_files = len(f) + list_gens = [] + for r, d, f in os.walk(path2): + for dir in d: + if 'selectedpop' in dir: + gen = dir.split('_')[1] + list_gens.append(int(gen)) + list_gens.sort() + if len(list_gens)>0: + gen = list_gens[-1] + else: + gen = -1 + print(exp, run, num_files, gen, num_files-(gen*50+100)) + + file_summary.close() + + file_summary = open(path2 + "/snapshots_ids.tsv", "a") + for r, d, f in os.walk(path2): + for dir in d: + if 'selectedpop' in dir: + gen = dir.split('_')[1] + for r2, d2, f2 in os.walk(path2 + '/selectedpop_' + str(gen)): + for file in f2: + if 'body' in file: + id = file.split('.')[0].split('_')[-1] + file_summary.write(gen+'\t'+id+'\n') + + file_summary.close() + diff --git a/experiments/Environmental_influences_on_evolvable_robots/flat.py b/experiments/Environmental_influences_on_evolvable_robots/flat.py new file mode 100755 index 0000000000..b9fcb277b8 --- /dev/null +++ b/experiments/Environmental_influences_on_evolvable_robots/flat.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 100 + population_size = 100 + offspring_size = 50 + front = None + + # environment world and z-start + environments = {'plane': 0.03} + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=False, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_plane(robot_manager, robot): + #contacts = measures.contacts(robot_manager, robot) + #assert(contacts != 0) + return fitness.displacement_velocity_hill(robot_manager, robot) + + fitness_function = {'plane': fitness_function_plane} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/experiments/Environmental_influences_on_evolvable_robots/run-experiments b/experiments/Environmental_influences_on_evolvable_robots/run-experiments new file mode 100755 index 0000000000..6a69187b26 --- /dev/null +++ b/experiments/Environmental_influences_on_evolvable_robots/run-experiments @@ -0,0 +1,79 @@ + #!/bin/bash + +while true + do + for i in {1..5}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_$i --run $i --manager experiments/karines_experiments/baseline2.py --n-cores 4 --port-start 11000 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {6..10}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_$i --run $i --manager experiments/karines_experiments/baseline2.py --n-cores 4 --port-start 11050 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {11..15}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_$i --run $i --manager experiments/karines_experiments/baseline2.py --n-cores 4 --port-start 11100 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {16..20}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_$i --run $i --manager experiments/karines_experiments/baseline2.py --n-cores 4 --port-start 11150 --evaluation-time 50; + + sleep 5s + done +done + + + +while true + do + for i in {1..10}; do + ./revolve.py --experiment-name karines_experiments/data/flat_$i --run $i --manager experiments/karines_experiments/flat.py --n-cores 4 --port-start 11400 --evaluation-time 50; + + sleep 5s + done +done + +while true + do + for i in {11..20}; do + ./revolve.py --experiment-name karines_experiments/data/flat_$i --run $i --manager experiments/karines_experiments/flat.py --n-cores 4 --port-start 11500 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {1..10}; do + ./revolve.py --experiment-name karines_experiments/data/tilted_$i --run $i --manager experiments/karines_experiments/tilted.py --n-cores 4 --port-start 11600 --evaluation-time 50; + + sleep 5s + done +done + +while true + do + for i in {11..20}; do + ./revolve.py --experiment-name karines_experiments/data/tilted_$i --run $i --manager experiments/karines_experiments/tilted.py --n-cores 4 --port-start 11700 --evaluation-time 50; + + sleep 5s + done +done \ No newline at end of file diff --git a/experiments/Environmental_influences_on_evolvable_robots/summary_measures_journal1_tilted.R b/experiments/Environmental_influences_on_evolvable_robots/summary_measures_journal1_tilted.R new file mode 100644 index 0000000000..18883e700c --- /dev/null +++ b/experiments/Environmental_influences_on_evolvable_robots/summary_measures_journal1_tilted.R @@ -0,0 +1,578 @@ +library(ggplot2) +library(sqldf) +library(plyr) +library(dplyr) +library(trend) +library(purrr) +library(ggsignif) + +base_directory <-paste('data', sep='') + +analysis = 'analysis_journal1_tilted' + +output_directory = paste(base_directory,'/',analysis ,sep='') + +#### CHANGE THE PARAMETERS HERE #### + + +experiments_type = c('flat', 'tilted','baseline2') + +environments = list( c( 'plane'), + c('tilted5'), + c( 'plane','tilted5') ) + +methods = c() +for (exp in 1:length(experiments_type)) +{ + for (env in 1:length(environments[[exp]])) + { + methods = c(methods, paste(experiments_type[exp], environments[[exp]][env], sep='_')) + } +} + +initials = c( 'bp', 'bt', 'pp', 'pt') + +experiments_labels = c( 'Static: Flat', 'Static: Tilted', + 'Seasonal: Flat', 'Seasonal: Tilted') + +experiments_labels2 = c( 'Static: Flat', 'Static: Tilted', + 'Seasonal', 'Seasonal') + +runs = list( c(1:20) , + c(1:20) , + c(1:20) ) + +gens = 100 +pop = 100 + +#### CHANGE THE PARAMETERS HERE #### + +sig = 0.05 +line_size = 30 +show_markers = FALSE +show_legends = FALSE +experiments_type_colors = c( '#00e700' , '#009900', '#ffb83b', '#fd8a3b') # DARK: light green,dark green, light red, dark red + +measures_names = c( + 'displacement_velocity_hill', + 'head_balance', + 'contacts', + 'displacement_velocity', + 'branching', + 'branching_modules_count', + 'limbs', + 'extremities', + 'length_of_limbs', + 'extensiveness', + 'coverage', + 'joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'proportion', + 'width', + 'height', + 'absolute_size', + 'sensors', + 'symmetry', + 'avg_period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'fitness', + 'cons_fitness' +) + +# add proper labels soon... +measures_labels = c( + 'Speed (cm/s)', + 'Balance', + 'Contacts', + 'displacement_velocity', + 'Branching', + 'branching_modules_count', + 'Rel number of limbs', + 'extremities', + 'Rel. Length of Limbs', + 'extensiveness', + 'coverage', + 'Rel. Number of Joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'Proportion', + 'width', + 'height', + 'Size', + 'sensors', + 'Symmetry', + 'Average Period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'Fitness', + 'Number of slaves' +) + + +measures_snapshots_all = NULL + +for (exp in 1:length(experiments_type)) +{ + for(run in runs[[exp]]) + { + for (env in 1:length(environments[[exp]])) + { + input_directory <- paste(base_directory, '/', + experiments_type[exp], '_',sep='') + + measures = read.table(paste(input_directory, run, '/data_fullevolution/', + environments[[exp]][env], "/all_measures.tsv", sep=''), header = TRUE, fill=TRUE) + for( m in 1:length(measures_names)) + { + measures[measures_names[m]] = as.numeric(as.character(measures[[measures_names[m]]])) + } + + snapshots = read.table(paste(input_directory, run,'/selectedpop_', + environments[[exp]][env],"/snapshots_ids.tsv", sep=''), header = TRUE) + + measures_snapshots = sqldf('select * from snapshots inner join measures using(robot_id) order by generation') + + measures_snapshots$run = run + measures_snapshots$displacement_velocity_hill = measures_snapshots$displacement_velocity_hill*100 + measures_snapshots$run = as.factor(measures_snapshots$run) + measures_snapshots$method = paste(experiments_type[exp], environments[[exp]][env],sep='_') + + if ( is.null(measures_snapshots_all)){ + measures_snapshots_all = measures_snapshots + }else{ + measures_snapshots_all = rbind(measures_snapshots_all, measures_snapshots) + } + } + } +} + + +fail_test = sqldf(paste("select method,run,generation,count(*) as c from measures_snapshots_all group by 1,2,3 having c<",gens," order by 4")) + + +measures_snapshots_all = sqldf("select * from measures_snapshots_all where generation<=99 and cons_fitness IS NOT NULL") + + + + +# densities + +measures_snapshots_all_densities = sqldf(paste("select * from measures_snapshots_all where generation=99 + and method !='", methods[length(methods)],"'",sep='' )) + +measures_names_densities = c('length_of_limbs','proportion', 'absolute_size','head_balance','joints', 'limbs') +measures_labels_densities = c('Rel. Length of Limbs','Proportion', 'Size','Balance','Rel. Number of Joints', 'Rel. Number of Limbs') + +for (i in 1:length(measures_names_densities)) +{ + + for (j in 1:length(measures_names_densities)) + { + + if(i != j) + { + + graph <- ggplot(measures_snapshots_all_densities, aes_string(x=measures_names_densities[j], y= measures_names_densities[i]))+ + geom_density_2d(aes(colour = method ), alpha=0.7, size=3 )+ + scale_color_manual(values = c(experiments_type_colors[4:4], experiments_type_colors[1:2]) )+ + labs( x = measures_labels_densities[j], y= measures_labels_densities[i] )+ + theme(legend.position="none" , axis.text=element_text(size=21),axis.title=element_text(size=22), + plot.subtitle=element_text(size=25 )) + + coord_cartesian(ylim = c(0, 1), xlim = c(0, 1)) + ggsave(paste( output_directory ,'/density_',measures_names_densities[i],'_', measures_names_densities[j],'.png', sep=''), graph , + device='png', height = 6, width = 6) + } + + } +} + + + +measures_averages_gens_1 = list() +measures_averages_gens_2 = list() + +measures_ini = list() +measures_fin = list() + +for (met in 1:length(methods)) +{ + + measures_aux = c() + query ='select run, generation' + for (i in 1:length(measures_names)) + { + query = paste(query,', avg(',measures_names[i],') as ', methods[met], '_',measures_names[i],'_avg', sep='') + } + query = paste(query,' from measures_snapshots_all + where method="', methods[met],'" group by run, generation', sep='') + + temp = sqldf(query) + + measures_averages_gens_1[[met]] = temp + + temp = measures_averages_gens_1[[met]] + + temp$generation = as.numeric(temp$generation) + + measures_ini[[met]] = sqldf(paste("select * from temp where generation=0")) + measures_fin[[met]] = sqldf(paste("select * from temp where generation=",gens-1)) + query = 'select generation' + for (i in 1:length(measures_names)) + { + # later renames vars _avg_SUMMARY, just to make it in the same style as the quantile variables + query = paste(query,', avg(', methods[met], '_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_avg', sep='') + query = paste(query,', max(', methods[met],'_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_max', sep='') + query = paste(query,', stdev(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_stdev', sep='') + query = paste(query,', median(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_median', sep='') + + measures_aux = c(measures_aux, paste(methods[met],'_',measures_names[i],'_avg', sep='') ) + } + query = paste(query,' from temp group by generation', sep="") + + temp2 = sqldf(query) + + p <- c(0.25, 0.75) + p_names <- map_chr(p, ~paste0('Q',.x*100, sep="")) + p_funs <- map(p, ~partial(quantile, probs = .x, na.rm = TRUE)) %>% + set_names(nm = p_names) + + quantiles = data.frame(temp %>% + group_by(generation) %>% + summarize_at(vars(measures_aux), funs(!!!p_funs)) ) + + measures_averages_gens_2[[met]] = sqldf('select * from temp2 inner join quantiles using (generation)') + +} + + +for (met in 1:length(methods)) +{ + if(met==1){ + measures_averages_gens = measures_averages_gens_2[[1]] + }else{ + measures_averages_gens = merge(measures_averages_gens, measures_averages_gens_2[[met]], all=TRUE, by = "generation") + } +} + +file <-file(paste(output_directory,'/trends.txt',sep=''), open="w") + +#tests trends in curves and difference between ini and fin generations + + +# ini VS fin +array_wilcoxon = list() +array_wilcoxon2 = list() + +# curve +array_mann = list() + + +for (m in 1:length(methods)) +{ + + array_wilcoxon[[m]] = list() + array_mann[[m]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(experiments_type[m],measures_names[i],'ini avg ',as.character( + mean(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon[[m]][[i]] = wilcox.test(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'iniVSfin',measures_names[i],'wilcox p: ',as.character(round(array_wilcoxon[[m]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'iniVSfin',measures_names[i],'wilcox est: ',as.character(round(array_wilcoxon[[m]][[i]]$statistic,4)), sep=' ') + + ), file) + + + #tests trends + array_mann[[m]][[i]] = mk.test(c(array(measures_averages_gens_2[[m]][paste(methods[m],"_",measures_names[i],'_median',sep='')]) )[[1]], + continuity = TRUE) + + + writeLines(c( + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median p', as.character(round(array_mann[[m]][[i]]$p.value,4)),sep=' '), + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median s', as.character(round(array_mann[[m]][[i]]$statistic,4)),sep=' ') + ), file) + + } + +} + + + +# tests final generation among experiments_type + +aux_m = length(methods) + +if (aux_m>1) +{ + + # fins + array_wilcoxon2[[1]] = list() + array_wilcoxon2[[2]] = list() + + aux_m = aux_m -1 + count_pairs = 0 + for(m in 1:aux_m) + { + aux = m+1 + for(m2 in aux:length(methods)) + { + + count_pairs = count_pairs+1 + array_wilcoxon2[[1]][[count_pairs]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + writeLines(paste(methods[m2],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon2[[1]][[count_pairs]][[i]] = wilcox.test(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'VS',methods,measures_names[i],'fin avg wilcox p: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'VS',methods[m2],measures_names[i],'fin avg wilcox est: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$statistic,4)), sep=' ') + + ), file) + + } + + + array_wilcoxon2[[2]][[count_pairs]] = paste(initials[m],initials[m2],sep='') + + } + } + +} + +close(file) + + + +# plots measures + +for (type_summary in c('means','quants')) +{ + + + for (i in 1:length(measures_names)) + { + tests1 = '' + tests2 = '' + tests3 = '' + break_aux = 0 + + graph <- ggplot(data=measures_averages_gens, aes(x=generation)) + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg','-',methods[m],'_',measures_names[i],'_stdev',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg','+',methods[m],'_',measures_names[i],'_stdev',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + }else + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg_Q25',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg_Q75',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + } + } + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep=''), colour=shQuote(experiments_labels[m]) ), size=2) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep='') ),size=2, color = experiments_type_colors[m]) + } + + }else{ + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') , colour=shQuote(experiments_labels[m]) ),size=2 ) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') ),size=2, color = experiments_type_colors[m] ) + } + } + + if (length(array_mann)>0) + { + if (length(array_mann[[m]])>0) + { + if(!is.na(array_mann[[m]][[i]]$p.value)) + { + if(array_mann[[m]][[i]]$p.value<=sig) + { + if(array_mann[[m]][[i]]$statistic>0){ direction = "/ "} else { direction = "\\ "} + tests1 = paste(tests1, initials[m],direction,sep="") + } + } + } + } + } + + if (length(array_wilcoxon[[m]])>0) + { + for(m in 1:length(methods)) + { + if(!is.na(array_wilcoxon[[m]][[i]]$p.value)) + { + if(array_wilcoxon[[m]][[i]]$p.value<=sig) + { + tests2 = paste(tests2, initials[m],'C ', sep='') + } + } + } + } + + if (length(array_wilcoxon2)>0) + { + for(p in 1:length(array_wilcoxon2[[1]])) + { + if (length(array_wilcoxon2[[1]][[p]])>0) + { + if(!is.na(array_wilcoxon2[[1]][[p]][[i]]$p.value)) + { + if(array_wilcoxon2[[1]][[p]][[i]]$p.value<=sig) + { + if(nchar(tests3)>line_size && break_aux == 0){ + tests3 = paste(tests3, '\n') + break_aux = 1 + } + tests3 = paste(tests3, array_wilcoxon2[[2]][[p]],'D ',sep='') + } + } + } + } + } + + max_y = 0 + + graph = graph + labs( y=measures_labels[i], x="Generation") + if (max_y>0) { + graph = graph + coord_cartesian(ylim = c(min_y, max_y)) + } + + if(show_markers == TRUE){ + graph = graph + labs( y=measures_labels[i], x="Generation", subtitle = paste(tests1,'\n', tests2, '\n', tests3, sep='')) + } + graph = graph + theme(legend.position="bottom" , legend.text=element_text(size=20), axis.text=element_text(size=30),axis.title=element_text(size=39), + plot.subtitle=element_text(size=25 )) + + ggsave(paste( output_directory,'/',type_summary,'_' ,measures_names[i],'_generations.pdf', sep=''), graph , device='pdf', height = 10, width = 10) + } + +} + + + + +for (i in 1:length(measures_names)) +{ + + all_final_values = data.frame() + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') { fin=length(methods) + }else{ fin=length(methods)-1 } + + for (exp in 1:fin) + { + temp = data.frame( c(measures_fin[[exp]][paste(methods[exp],'_',measures_names[i],'_avg', sep='')])) + colnames(temp) <- 'values' + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') + { temp$type = experiments_labels[exp] + }else{ temp$type = experiments_labels2[exp] } + + all_final_values = rbind(all_final_values, temp) + } + + + max_y = max(all_final_values$values) * 1.1 + + g1 <- ggplot(data=all_final_values, aes(x= type , y=values, color=type )) + + geom_boxplot(position = position_dodge(width=0.9),lwd=2, outlier.size = 4) + #notch=TRUE + labs( x="Environment", y=measures_labels[i], title="Final generation") + + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') + { g1 = g1 + scale_color_manual(values=c(experiments_type_colors[3:4], experiments_type_colors[1:2]) ) + }else{ g1 = g1 + scale_color_manual(values= c(experiments_type_colors[4:4],experiments_type_colors[1:2])) } + + + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') { comps = list(c("Static: Flat", "Seasonal: Flat"), + c("Static: Tilted", "Seasonal: Tilted"), + c("Static: Tilted", "Static: Flat"), + c("Seasonal: Tilted", "Seasonal: Flat")) + aux_width=15 + border_l = 2.5 + }else{ comps = list(c("Static: Flat", "Static: Tilted"), + c("Static: Flat", "Seasonal"), + c("Static: Tilted", "Seasonal")) + aux_width=11 + border_l = 1.3 + } + + + g1 = g1 + theme(legend.position="none" , text = element_text(size=45) , + plot.title=element_text(size=40), axis.text=element_text(size=45), + axis.title=element_text(size=50), + axis.text.x = element_text(angle = 20, hjust = 1 ), + plot.margin=margin(t = 0.5, r = 0.5, b = 0.5, l = border_l, unit = "cm") + )+ + stat_summary(fun.y = mean, geom="point" ,shape = 16, size=11) + + g1 = g1 + geom_signif( test="wilcox.test", size=2, textsize=22, + comparisons = comps, + map_signif_level=c("***"=0.001,"**"=0.01, "*"=0.05) ) + if (max_y>0) { + g1 = g1 + coord_cartesian(ylim = c(0, max_y)) + } + g1 + ggsave(paste(output_directory,"/",measures_names[i],"_boxes.pdf",sep = ""), g1, device = "pdf", height=18, width = aux_width) + +} + diff --git a/experiments/Environmental_influences_on_evolvable_robots/tilted.py b/experiments/Environmental_influences_on_evolvable_robots/tilted.py new file mode 100755 index 0000000000..2f8700f0c2 --- /dev/null +++ b/experiments/Environmental_influences_on_evolvable_robots/tilted.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 100 + population_size = 100 + offspring_size = 50 + front = None + + # environment world and z-start + environments = {'tilted5': 0.1} + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=False, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_tilted(robot_manager, robot): + #contacts = measures.contacts(robot_manager, robot) + #assert(contacts != 0) + return fitness.displacement_velocity_hill(robot_manager, robot) + + fitness_function = {'tilted5': fitness_function_tilted} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/experiments/examples/consolidate_experiments.py b/experiments/examples/consolidate_experiments.py index b512d681e0..a64a7d14b8 100644 --- a/experiments/examples/consolidate_experiments.py +++ b/experiments/examples/consolidate_experiments.py @@ -16,11 +16,22 @@ def build_headers(path): file_summary.write('robot_id\t') behavior_headers = [] - with open(path + '/data_fullevolution/descriptors/behavior_desc_robot_1.txt') as file: - for line in file: - measure, value = line.strip().split(' ') - behavior_headers.append(measure) - file_summary.write(measure+'\t') + behavior_headers.append('velocity') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('displacement_velocity') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('displacement_velocity_hill') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('head_balance') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('contacts') + file_summary.write(behavior_headers[-1]+'\t') + # use this instead? but what if the guy is none? + # with open(path + '/data_fullevolution/descriptors/behavior_desc_robot_1.txt') as file: + # for line in file: + # measure, value = line.strip().split(' ') + # behavior_headers.append(measure) + # file_summary.write(measure+'\t') phenotype_headers = [] with open(path + '/data_fullevolution/descriptors/phenotype_desc_robot_1.txt') as file: @@ -56,8 +67,12 @@ def build_headers(path): if os.path.isfile(bh_file): with open(bh_file) as file: for line in file: - measure, value = line.strip().split(' ') - file_summary.write(value+'\t') + if line != 'None': + measure, value = line.strip().split(' ') + file_summary.write(value+'\t') + else: + for h in behavior_headers: + file_summary.write('None'+'\t') else: for h in behavior_headers: file_summary.write('None'+'\t') @@ -87,4 +102,4 @@ def build_headers(path): if 'body' in file: id = file.split('.')[0].split('_')[-1] file_summary.write(gen+'\t'+id+'\n') - file_summary.close() + file_summary.close() \ No newline at end of file diff --git a/experiments/examples/stuck-experiments_watchman.py b/experiments/examples/stuck-experiments_watchman.py index 6b0a2a4fc7..60f6ab1ea4 100644 --- a/experiments/examples/stuck-experiments_watchman.py +++ b/experiments/examples/stuck-experiments_watchman.py @@ -33,8 +33,9 @@ files.sort() youngest.append(files[-1]) - if files[-1] > time_ago: - some_has_been_updated = True + if len(files)>0: + if files[-1] > time_ago: + some_has_been_updated = True if not some_has_been_updated: youngest.sort() diff --git a/experiments/examples/summary_measures.R b/experiments/examples/summary_measures.R index 184eea80d9..be33009560 100644 --- a/experiments/examples/summary_measures.R +++ b/experiments/examples/summary_measures.R @@ -5,19 +5,19 @@ library(dplyr) library(trend) base_directory <- paste('../', sep='') - output_directory = base_directory + +#### CHANGE THE PARAMETERS HERE #### + experiments_type = c( 'default_experiment' ) - initials = c('d') experiments_labels = c('default_experiment') - runs = c(1,2,3,4,5,6,7,8,9,10) gens = 100 pop = 100 @@ -27,6 +27,10 @@ show_markers = TRUE show_legends = TRUE experiments_type_colors = c( '#009900', '#FF8000', '#BA1616', '#000099') # DARK:green, orange, red, blue +#### CHANGE THE PARAMETERS HERE #### + + + measures_names = c( 'displacement_velocity_hill', 'head_balance', @@ -134,10 +138,11 @@ for (exp in 1:length(experiments_type)) } +fail_test = sqldf(paste("select method,run,generation,count(*) as c from measures_snapshots_all group by 1,2,3 having c<",gens," order by 4")) + measures_snapshots_all = sqldf("select * from measures_snapshots_all where fitness IS NOT NULL") -fail_test = sqldf(paste("select method,run,generation,count(*) as c from measures_snapshots_all group by 1,2,3 having c<",gens," order by 4")) measures_averages_gens_1 = list() @@ -190,8 +195,6 @@ for (exp in 1:length(experiments_type)) } } - - file <-file(paste(output_directory,'/trends.txt',sep=''), open="w") #tests trends in curves and difference between ini and fin generations @@ -328,45 +331,55 @@ for (i in 1:length(measures_names)) } # graph = graph + geom_line(aes_string(y=paste(experiments_type[m],'_',measures_names[i],'_median',sep='') ),size=2, color = colors_median[m]) - if(!is.na(array_mann[[m]][[i]]$p.value)) + if (length(array_mann)>0) { - if(array_mann[[m]][[i]]$p.value<=sig) + if (length(array_mann[[m]])>0) { - if(array_mann[[m]][[i]]$statistic>0){ direction = "/ "} else { direction = "\\ "} - tests1 = paste(tests1, initials[m],direction,sep="") + if(!is.na(array_mann[[m]][[i]]$p.value)) + { + if(array_mann[[m]][[i]]$p.value<=sig) + { + if(array_mann[[m]][[i]]$statistic>0){ direction = "/ "} else { direction = "\\ "} + tests1 = paste(tests1, initials[m],direction,sep="") + } + } } } } - for(m in 1:length(experiments_type)) + + if (length(array_wilcoxon[[m]])>0) { - if(!is.na(array_wilcoxon[[m]][[i]]$p.value)) + for(m in 1:length(experiments_type)) { - if(array_wilcoxon[[m]][[i]]$p.value<=sig) + if(!is.na(array_wilcoxon[[m]][[i]]$p.value)) { - tests2 = paste(tests2, initials[m],'C ', sep='') + if(array_wilcoxon[[m]][[i]]$p.value<=sig) + { + tests2 = paste(tests2, initials[m],'C ', sep='') + } } } } if (length(array_wilcoxon2)>0) { - for(p in 1:length(array_wilcoxon2[[1]])) { - if(!is.na(array_wilcoxon2[[1]][[p]][[i]]$p.value)) + if (length(array_wilcoxon2[[1]][[p]])>0) { - if(array_wilcoxon2[[1]][[p]][[i]]$p.value<=sig) + if(!is.na(array_wilcoxon2[[1]][[p]][[i]]$p.value)) { - if(nchar(tests3)>line_size && break_aux == 0){ - tests3 = paste(tests3, '\n') - break_aux = 1 + if(array_wilcoxon2[[1]][[p]][[i]]$p.value<=sig) + { + if(nchar(tests3)>line_size && break_aux == 0){ + tests3 = paste(tests3, '\n') + break_aux = 1 + } + tests3 = paste(tests3, array_wilcoxon2[[2]][[p]],'D ',sep='') } - tests3 = paste(tests3, array_wilcoxon2[[2]][[p]],'D ',sep='') } } - } - } graph = graph + @@ -378,7 +391,7 @@ for (i in 1:length(measures_names)) graph = graph + theme(legend.position="bottom" , legend.text=element_text(size=20), axis.text=element_text(size=30),axis.title=element_text(size=39), plot.subtitle=element_text(size=25 )) - ggsave(paste( output_directory,'/' ,measures_names[i],'_generations.pdf', sep=''), graph , device='pdf', height = 8, width = 8) + ggsave(paste( output_directory,'/' ,measures_names[i],'_generations.pdf', sep=''), graph , device='pdf', height = 8, width = 10) } diff --git a/experiments/karines_experiments/baseline2.py b/experiments/karines_experiments/baseline2.py new file mode 100755 index 0000000000..ab45e23c31 --- /dev/null +++ b/experiments/karines_experiments/baseline2.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 100 + population_size = 100 + offspring_size = 50 + front = 'total_slaves' + + # environment world and z-start + environments = {'plane': 0.03, + 'tilted5': 0.1 + } + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=False, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_plane(robot_manager, robot): + #contacts = measures.contacts(robot_manager, robot) + #assert(contacts != 0) + return fitness.displacement_velocity_hill(robot_manager, robot) + + + fitness_function = {'plane': fitness_function_plane, + 'tilted5': fitness_function_plane} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/experiments/karines_experiments/baseline2_lava.py b/experiments/karines_experiments/baseline2_lava.py new file mode 100755 index 0000000000..24b4c02736 --- /dev/null +++ b/experiments/karines_experiments/baseline2_lava.py @@ -0,0 +1,160 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 100 + population_size = 100 + offspring_size = 50 + front = 'total_slaves' + + # environment world and z-start + environments = {'plane': 0.03, + 'lava': 0.03 + } + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=False, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_plane(robot_manager, robot): + #contacts = measures.contacts(robot_manager, robot) + #assert(contacts != 0) + return fitness.displacement_velocity_hill(robot_manager, robot) + + def fitness_function_lava(robot_manager, robot): + contacts = measures.contacts(robot_manager, robot) + assert(contacts != 0) + return fitness.floor_is_lava(robot_manager, robot) + + fitness_function = {'plane': fitness_function_plane, + 'lava': fitness_function_lava} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/experiments/karines_experiments/bestrobots_summary_renders_journal1_lava.r b/experiments/karines_experiments/bestrobots_summary_renders_journal1_lava.r new file mode 100644 index 0000000000..3f80de3e00 --- /dev/null +++ b/experiments/karines_experiments/bestrobots_summary_renders_journal1_lava.r @@ -0,0 +1,86 @@ + +library(sqldf) +require('magick') + +##### change paths/labels/params here ##### + + +paths = c( 'flat', 'lava', 'baseline2_lava') + +environments = list(c( 'plane'), + c( 'lava'), + c( 'plane') +) + +base_directory <- paste('data/', sep='') + +experiments = c(1:20) +gens = 42#100 +pop = 100 +num_top = 1 + +analysis = 'analysis_journal1_tilted' + +##### change paths/labels/params here ##### + +output_directory = paste(base_directory,analysis, sep='') + + +file <-file(paste(output_directory,'/best.txt',sep=''), open="w") + +# for each method +for(m in 1:length(paths)) +{ + # for each repetition + for (exp in experiments) + { + + input_directory1 <- paste(base_directory, paths[m],'_',exp, '/data_fullevolution/',environments[[m]][1],sep='') + input_directory2 <- paste(base_directory, paths[m],'_',exp, '/selectedpop_', sep='') + + ids_gens = data.frame() + list = strsplit(list.files(paste(input_directory2, environments[[m]][1],'/selectedpop_',gens-1, sep='')), ' ') + for(geno in 1:pop) + { + genome = data.frame(cbind(c(gens), c(strsplit(strsplit(list [[geno]],'_')[[1]][3],'.png')[[1]][1] ))) + names(genome)<-c('generation','robot_id') + ids_gens = rbind(ids_gens,genome) + } + + measures = read.table(paste(input_directory1,"/all_measures.tsv", sep=''), header = TRUE) + bests = sqldf(paste("select robot_id, cons_fitness from measures inner join ids_gens using (robot_id) order by cons_fitness desc limit",num_top)) + + for(b in 1:nrow(bests)) + { + + writeLines( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] ), file ) + print( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] )) + + phenotype= bests[b,'robot_id'] + + for (env in 1:length(environments[[m]])) + { + patha = paste(input_directory2, environments[[m]][env], "/selectedpop_",gens-1,sep="") + + body <- list.files(patha, paste("body_robot_",phenotype,".png$",sep=""), full.names = TRUE) + body = image_read(body) + body = image_scale(body, "100x100") + body = image_border(image_background(body, "white"), "white", "5x5") + + if(b == 1 && env == 1) + { + bodies = body + }else{ + bodies = c(bodies, body) + } + } + } + + side_by_side = image_append(bodies, stack=F) + image_write(side_by_side, path = paste(output_directory,"/",paths[m],'_', environments[[m]][env], "_bodies_best_",exp,".png",sep=''), format = "png") + + } +} + + +close(file) diff --git a/experiments/karines_experiments/bestrobots_summary_renders_journal1_tilted.r b/experiments/karines_experiments/bestrobots_summary_renders_journal1_tilted.r new file mode 100644 index 0000000000..89f7fcdc8e --- /dev/null +++ b/experiments/karines_experiments/bestrobots_summary_renders_journal1_tilted.r @@ -0,0 +1,86 @@ + +library(sqldf) +require('magick') + +##### change paths/labels/params here ##### + + +paths = c( 'flat', 'tilted', 'baseline2') + +environments = list(c( 'plane'), + c( 'tilted5'), + c( 'plane') +) + +base_directory <- paste('data/', sep='') + +experiments = c(1:20) +gens = 100 +pop = 100 +num_top = 1 + +analysis = 'analysis_journal1_tilted' + +##### change paths/labels/params here ##### + +output_directory = paste(base_directory,analysis, sep='') + + +file <-file(paste(output_directory,'/best.txt',sep=''), open="w") + +# for each method +for(m in 1:length(paths)) +{ + # for each repetition + for (exp in experiments) + { + + input_directory1 <- paste(base_directory, paths[m],'_',exp, '/data_fullevolution/',environments[[m]][1],sep='') + input_directory2 <- paste(base_directory, paths[m],'_',exp, '/selectedpop_', sep='') + + ids_gens = data.frame() + list = strsplit(list.files(paste(input_directory2, environments[[m]][1],'/selectedpop_',gens-1, sep='')), ' ') + for(geno in 1:pop) + { + genome = data.frame(cbind(c(gens), c(strsplit(strsplit(list [[geno]],'_')[[1]][3],'.png')[[1]][1] ))) + names(genome)<-c('generation','robot_id') + ids_gens = rbind(ids_gens,genome) + } + + measures = read.table(paste(input_directory1,"/all_measures.tsv", sep=''), header = TRUE) + bests = sqldf(paste("select robot_id, cons_fitness from measures inner join ids_gens using (robot_id) order by cons_fitness desc limit",num_top)) + + for(b in 1:nrow(bests)) + { + + writeLines( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] ), file ) + print( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] )) + + phenotype= bests[b,'robot_id'] + + for (env in 1:length(environments[[m]])) + { + patha = paste(input_directory2, environments[[m]][env], "/selectedpop_",gens-1,sep="") + + body <- list.files(patha, paste("body_robot_",phenotype,".png$",sep=""), full.names = TRUE) + body = image_read(body) + body = image_scale(body, "100x100") + body = image_border(image_background(body, "white"), "white", "5x5") + + if(b == 1 && env == 1) + { + bodies = body + }else{ + bodies = c(bodies, body) + } + } + } + + side_by_side = image_append(bodies, stack=F) + image_write(side_by_side, path = paste(output_directory,"/",paths[m],'_', environments[[m]][env], "_bodies_best_",exp,".png",sep=''), format = "png") + + } +} + + +close(file) diff --git a/experiments/karines_experiments/bestrobots_summary_renders_journal2_lava.r b/experiments/karines_experiments/bestrobots_summary_renders_journal2_lava.r new file mode 100644 index 0000000000..331fab5186 --- /dev/null +++ b/experiments/karines_experiments/bestrobots_summary_renders_journal2_lava.r @@ -0,0 +1,85 @@ + +library(sqldf) +require('magick') + +##### change paths/labels/params here ##### + + +paths = c( 'baseline2_lava', 'plastic2_lava') + +environments = list(c( 'plane','lava'), + c( 'plane','lava') +) + +base_directory <- paste('data/', sep='') + +experiments = c(1:20) +gens = 42#100 +pop = 100 +num_top = 1 + +analysis = 'analysis_journal2_lava' + +##### change paths/labels/params here ##### + +output_directory = paste(base_directory,analysis, sep='') + + +file <-file(paste(output_directory,'/best.txt',sep=''), open="w") + +# for each method +for(m in 1:length(paths)) +{ + # for each repetition + for (exp in experiments) + { + + input_directory1 <- paste(base_directory, paths[m],'_',exp, '/data_fullevolution/',environments[[m]][1],sep='') + input_directory2 <- paste(base_directory, paths[m],'_',exp, '/selectedpop_', sep='') + + ids_gens = data.frame() + list = strsplit(list.files(paste(input_directory2, environments[[m]][1],'/selectedpop_',gens-1, sep='')), ' ') + for(geno in 1:pop) + { + genome = data.frame(cbind(c(gens), c(strsplit(strsplit(list [[geno]],'_')[[1]][3],'.png')[[1]][1] ))) + names(genome)<-c('generation','robot_id') + ids_gens = rbind(ids_gens,genome) + } + + measures = read.table(paste(input_directory1,"/all_measures.tsv", sep=''), header = TRUE) + bests = sqldf(paste("select robot_id, cons_fitness from measures inner join ids_gens using (robot_id) order by cons_fitness desc limit",num_top)) + + for(b in 1:nrow(bests)) + { + + writeLines( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] ), file ) + print( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] )) + + phenotype= bests[b,'robot_id'] + + for (env in 1:length(environments[[m]])) + { + patha = paste(input_directory2, environments[[m]][env], "/selectedpop_",gens-1,sep="") + + body <- list.files(patha, paste("body_robot_",phenotype,".png$",sep=""), full.names = TRUE) + body = image_read(body) + body = image_scale(body, "100x100") + body = image_border(image_background(body, "white"), "white", "5x5") + + if(b == 1 && env == 1) + { + bodies = body + }else{ + bodies = c(bodies, body) + } + } + } + + side_by_side = image_append(bodies, stack=F) + image_write(side_by_side, path = paste(output_directory,"/",paths[m],'_', environments[[m]][env], "_bodies_best_",exp,".png",sep=''), format = "png") + + } +} + + +close(file) diff --git a/experiments/karines_experiments/bestrobots_summary_renders_journal2_tilted.r b/experiments/karines_experiments/bestrobots_summary_renders_journal2_tilted.r new file mode 100644 index 0000000000..7f33f63c47 --- /dev/null +++ b/experiments/karines_experiments/bestrobots_summary_renders_journal2_tilted.r @@ -0,0 +1,85 @@ + +library(sqldf) +require('magick') + +##### change paths/labels/params here ##### + + +paths = c( 'baseline2', 'plastic2') + +environments = list(c( 'plane','tilted5'), + c( 'plane','tilted5') +) + +base_directory <- paste('data/', sep='') + +experiments = c(1:20) +gens = 42#100 +pop = 100 +num_top = 1 + +analysis = 'analysis_journal2_tilted' + +##### change paths/labels/params here ##### + +output_directory = paste(base_directory,analysis, sep='') + + +file <-file(paste(output_directory,'/best.txt',sep=''), open="w") + +# for each method +for(m in 1:length(paths)) +{ + # for each repetition + for (exp in experiments) + { + + input_directory1 <- paste(base_directory, paths[m],'_',exp, '/data_fullevolution/',environments[[m]][1],sep='') + input_directory2 <- paste(base_directory, paths[m],'_',exp, '/selectedpop_', sep='') + + ids_gens = data.frame() + list = strsplit(list.files(paste(input_directory2, environments[[m]][1],'/selectedpop_',gens-1, sep='')), ' ') + for(geno in 1:pop) + { + genome = data.frame(cbind(c(gens), c(strsplit(strsplit(list [[geno]],'_')[[1]][3],'.png')[[1]][1] ))) + names(genome)<-c('generation','robot_id') + ids_gens = rbind(ids_gens,genome) + } + + measures = read.table(paste(input_directory1,"/all_measures.tsv", sep=''), header = TRUE) + bests = sqldf(paste("select robot_id, cons_fitness from measures inner join ids_gens using (robot_id) order by cons_fitness desc limit",num_top)) + + for(b in 1:nrow(bests)) + { + + writeLines( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] ), file ) + print( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] )) + + phenotype= bests[b,'robot_id'] + + for (env in 1:length(environments[[m]])) + { + patha = paste(input_directory2, environments[[m]][env], "/selectedpop_",gens-1,sep="") + + body <- list.files(patha, paste("body_robot_",phenotype,".png$",sep=""), full.names = TRUE) + body = image_read(body) + body = image_scale(body, "100x100") + body = image_border(image_background(body, "white"), "white", "5x5") + + if(b == 1 && env == 1) + { + bodies = body + }else{ + bodies = c(bodies, body) + } + } + } + + side_by_side = image_append(bodies, stack=F) + image_write(side_by_side, path = paste(output_directory,"/",paths[m],'_', environments[[m]][env], "_bodies_best_",exp,".png",sep=''), format = "png") + + } +} + + +close(file) diff --git a/experiments/karines_experiments/consolidate_experiments.py b/experiments/karines_experiments/consolidate_experiments.py index e7d713d137..4fe53384ac 100644 --- a/experiments/karines_experiments/consolidate_experiments.py +++ b/experiments/karines_experiments/consolidate_experiments.py @@ -1,92 +1,147 @@ import os - +import math # set these variables according to your experiments # -dirpath = 'data' +dirpath = 'data/' experiments_type = [ - 'plane', - 'lava' - ] -runs = 10 -# set these variables according to your experiments # + # 'baseline2', + # 'plastic2', + # 'flat', + # 'tilted' + 'lava', + 'baseline2_lava', + 'plastic2_lava' +] +environments = { + # 'baseline2': ['plane','tilted5'], + # 'plastic2': ['plane','tilted5'], + # 'flat': ['plane'], + # 'tilted': ['tilted5'], + 'baseline2': ['plane','lava'], + 'plastic2': ['plane','lava'], + 'lava': ['lava'] + } + +runs = range(1, 21) -def build_headers(path): +# set these variables according to your experiments # - print(path + "/all_measures.txt") - file_summary = open(path + "/all_measures.tsv", "w+") +def build_headers(path1, path2): + + file_summary = open(path1 + "/all_measures.tsv", "w+") file_summary.write('robot_id\t') behavior_headers = [] - with open(path + '/data_fullevolution/descriptors/behavior_desc_robot_1.txt') as file: - for line in file: - measure, value = line.strip().split(' ') - behavior_headers.append(measure) - file_summary.write(measure+'\t') + behavior_headers.append('velocity') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('displacement_velocity') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('displacement_velocity_hill') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('head_balance') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('contacts') + file_summary.write(behavior_headers[-1]+'\t') + # use this instead? but what if the guy is none? + # with open(path + '/data_fullevolution/descriptors/behavior_desc_robot_1.txt') as file: + # for line in file: + # measure, value = line.strip().split(' ') + # behavior_headers.append(measure) + # file_summary.write(measure+'\t') phenotype_headers = [] - with open(path + '/data_fullevolution/descriptors/phenotype_desc_robot_1.txt') as file: + with open(path1 + '/descriptors/phenotype_desc_robot_1.txt') as file: for line in file: measure, value = line.strip().split(' ') phenotype_headers.append(measure) file_summary.write(measure+'\t') - file_summary.write('fitness\n') + file_summary.write('fitness\t cons_fitness\n') file_summary.close() - file_summary = open(path + "/snapshots_ids.tsv", "w+") + file_summary = open(path2 + "/snapshots_ids.tsv", "w+") file_summary.write('generation\trobot_id\n') file_summary.close() return behavior_headers, phenotype_headers - for exp in experiments_type: - for run in range(1, runs+1): - - print(exp, run) - path = os.path.join(dirpath, str(exp), str(run)) - behavior_headers, phenotype_headers = build_headers(path) - - file_summary = open(path + "/all_measures.tsv", "a") - for r, d, f in os.walk(path+'/data_fullevolution/fitness'): - for file in f: - - robot_id = file.split('.')[0].split('_')[-1] - file_summary.write(robot_id+'\t') - - bh_file = path+'/data_fullevolution/descriptors/behavior_desc_robot_'+robot_id+'.txt' - if os.path.isfile(bh_file): - with open(bh_file) as file: - for line in file: - measure, value = line.strip().split(' ') - file_summary.write(value+'\t') - else: - for h in behavior_headers: - file_summary.write('None'+'\t') - - pt_file = path+'/data_fullevolution/descriptors/phenotype_desc_robot_'+robot_id+'.txt' - if os.path.isfile(pt_file): - with open(pt_file) as file: - for line in file: - measure, value = line.strip().split(' ') - file_summary.write(value+'\t') - else: - for h in phenotype_headers: - file_summary.write('None'+'\t') - - file = open(path+'/data_fullevolution/fitness/fitness_robot_'+robot_id+'.txt', 'r') - fitness = file.read() - file_summary.write(fitness + '\n') - file_summary.close() - - file_summary = open(path + "/snapshots_ids.tsv", "a") - for r, d, f in os.walk(path): - for dir in d: - if 'selectedpop' in dir: - gen = dir.split('_')[1] - for r2, d2, f2 in os.walk(path + '/selectedpop_' + str(gen)): - for file in f2: - if 'body' in file: - id = file.split('.')[0].split('_')[-1] - file_summary.write(gen+'\t'+id+'\n') - file_summary.close() \ No newline at end of file + + for env in environments[exp]: + + for run in runs: + + path0 = dirpath + str(exp) + '_' + str(run) + '/data_fullevolution' + path1 = dirpath + str(exp) + '_' + str(run) + '/data_fullevolution/' + env + path2 = dirpath + str(exp) + '_' + str(run) + '/selectedpop_' + env + + behavior_headers, phenotype_headers = build_headers(path1, path2) + + file_summary = open(path1 + "/all_measures.tsv", "a") + for r, d, f in os.walk(path0+'/consolidated_fitness'): + for file in f: + + robot_id = file.split('.')[0].split('_')[-1] + file_summary.write(robot_id+'\t') + + bh_file = path1+'/descriptors/behavior_desc_robot_'+robot_id+'.txt' + if os.path.isfile(bh_file): + with open(bh_file) as file: + for line in file: + if line != 'None': + measure, value = line.strip().split(' ') + file_summary.write(value+'\t') + else: + for h in behavior_headers: + file_summary.write('None'+'\t') + else: + for h in behavior_headers: + file_summary.write('None'+'\t') + + pt_file = path1+'/descriptors/phenotype_desc_robot_'+robot_id+'.txt' + if os.path.isfile(pt_file): + with open(pt_file) as file: + for line in file: + measure, value = line.strip().split(' ') + file_summary.write(value+'\t') + else: + for h in phenotype_headers: + file_summary.write('None'+'\t') + + f_file = open(path1+'/fitness/fitness_robot_'+robot_id+'.txt', 'r') + fitness = f_file.read() + file_summary.write(fitness + '\t') + + cf_file = open(path0+'/consolidated_fitness/consolidated_fitness_robot_'+robot_id+'.txt', 'r') + cons_fitness = cf_file.read() + file_summary.write(cons_fitness + '\n') + + num_files = len(f) + list_gens = [] + for r, d, f in os.walk(path2): + for dir in d: + if 'selectedpop' in dir: + gen = dir.split('_')[1] + list_gens.append(int(gen)) + list_gens.sort() + if len(list_gens)>0: + gen = list_gens[-1] + else: + gen = -1 + print(exp, run, num_files, gen, num_files-(gen*50+100)) + + file_summary.close() + + file_summary = open(path2 + "/snapshots_ids.tsv", "a") + for r, d, f in os.walk(path2): + for dir in d: + if 'selectedpop' in dir: + gen = dir.split('_')[1] + for r2, d2, f2 in os.walk(path2 + '/selectedpop_' + str(gen)): + for file in f2: + if 'body' in file: + id = file.split('.')[0].split('_')[-1] + file_summary.write(gen+'\t'+id+'\n') + + file_summary.close() + diff --git a/experiments/karines_experiments/densities_tilted.R b/experiments/karines_experiments/densities_tilted.R new file mode 100644 index 0000000000..2491e45f7e --- /dev/null +++ b/experiments/karines_experiments/densities_tilted.R @@ -0,0 +1,100 @@ + + + library(ggplot2) + library(sqldf) + library(plyr) + library(dplyr) + library(trend) + library(purrr) + + base_directory <- paste('data', sep='') #paste('projects/revolve/experiments/karines_experiments/data', sep='') + + analysis = 'analysis2_plane_tilted' + + output_directory = paste(base_directory,'/',analysis ,sep='') + + #### CHANGE THE PARAMETERS HERE #### + + + experiments_type_colors = c('#FF8000', '#009900') # DARK: green, orange + + experiments_type = c( 'plane', 'tilted5') + + experiments_type_label = c( '2-Plane', '1-Tilted') + + + runs = c(1:60) + gens = 100 + pop = 100 + + #### CHANGE THE PARAMETERS HERE #### + + sig = 0.05 + line_size = 30 + show_markers = TRUE + show_legends = FALSE + + + measures_names = c('length_of_limbs','proportion', 'absolute_size','head_balance','joints', 'limbs') + + measures_labels = c('Rel. Length of Limbs','Proportion', 'Size','Balance','Rel. Number of Joints', 'Rel. Number of Limbs') + + measures_snapshots_all = NULL + + for (exp in 1:length(experiments_type)) + { + for(run in runs) + { + input_directory <- paste(base_directory, '/', experiments_type[exp], '_', run, sep='') + measures = read.table(paste(input_directory,"/all_measures.tsv", sep=''), header = TRUE) + for( m in 1:length(measures_names)) + { + measures[measures_names[m]] = as.numeric(as.character(measures[[measures_names[m]]])) + } + + snapshots = read.table(paste(input_directory,"/snapshots_ids.tsv", sep=''), header = TRUE) + measures_snapshots = sqldf('select * from snapshots inner join measures using(robot_id) order by generation') + + measures_snapshots$run = run + measures_snapshots$run = as.factor(measures_snapshots$run) + measures_snapshots$method = experiments_type_label[exp] + + if ( is.null(measures_snapshots_all)){ + measures_snapshots_all = measures_snapshots + }else{ + measures_snapshots_all = rbind(measures_snapshots_all, measures_snapshots) + } + } + } + + measures_snapshots_all_final = sqldf("select * from measures_snapshots_all where generation=99") + + + for (i in 1:length(measures_names)) + { + + for (j in 1:length(measures_names)) + { + + if(i != j) + { + + graph <- ggplot(measures_snapshots_all_final, aes_string(x=measures_names[j], y= measures_names[i]))+ + geom_density_2d(aes(colour = method ), alpha=0.7, size=3 )+ + scale_color_manual(values = experiments_type_colors )+ + labs( x = measures_labels[j], y= measures_labels[i] )+ + theme(legend.position="none" , axis.text=element_text(size=21),axis.title=element_text(size=22), + plot.subtitle=element_text(size=25 )) + + coord_cartesian(ylim = c(0, 1), xlim = c(0, 1)) + ggsave(paste( output_directory ,'/',measures_names[i],'_', measures_names[j],'.tiff', sep=''), graph , + device='tiff', height = 6, width = 6) + } + + } + } + + + + + + \ No newline at end of file diff --git a/experiments/karines_experiments/flat.py b/experiments/karines_experiments/flat.py new file mode 100755 index 0000000000..b9fcb277b8 --- /dev/null +++ b/experiments/karines_experiments/flat.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 100 + population_size = 100 + offspring_size = 50 + front = None + + # environment world and z-start + environments = {'plane': 0.03} + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=False, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_plane(robot_manager, robot): + #contacts = measures.contacts(robot_manager, robot) + #assert(contacts != 0) + return fitness.displacement_velocity_hill(robot_manager, robot) + + fitness_function = {'plane': fitness_function_plane} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/experiments/karines_experiments/manager_pop_lava.py b/experiments/karines_experiments/lava.py similarity index 73% rename from experiments/karines_experiments/manager_pop_lava.py rename to experiments/karines_experiments/lava.py index 0d5ab20a5b..cacd1eb200 100755 --- a/experiments/karines_experiments/manager_pop_lava.py +++ b/experiments/karines_experiments/lava.py @@ -15,8 +15,9 @@ from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig from pyrevolve.tol.manage import measures from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue from pyrevolve.custom_logging.logger import logger - +import sys async def run(): """ @@ -27,9 +28,14 @@ async def run(): num_generations = 100 population_size = 100 offspring_size = 50 + front = None + + # environment world and z-start + environments = {'lava': 0.03} genotype_conf = PlasticodingConfig( - max_structural_modules=100, + max_structural_modules=15, + plastic=False, ) mutation_conf = MutationConfig( @@ -44,13 +50,14 @@ async def run(): # Parse command line / file input arguments settings = parser.parse_args() - experiment_management = ExperimentManagement(settings) + experiment_management = ExperimentManagement(settings, environments) do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) if do_recovery: - gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, offspring_size) + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) if gen_num == num_generations-1: logger.info('Experiment is already complete.') @@ -59,11 +66,13 @@ async def run(): gen_num = 0 next_robot_id = 1 - def fitness_function(robot_manager, robot): + def fitness_function_lava(robot_manager, robot): contacts = measures.contacts(robot_manager, robot) assert(contacts != 0) return fitness.floor_is_lava(robot_manager, robot) + fitness_function = {'lava': fitness_function_lava} + population_conf = PopulationConfig( population_size=population_size, genotype_constructor=random_initialization, @@ -73,27 +82,51 @@ def fitness_function(robot_manager, robot): mutation_conf=mutation_conf, crossover_operator=standard_crossover, crossover_conf=crossover_conf, - selection=lambda individuals: tournament_selection(individuals, 2), - parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection), + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), population_management=steady_state_population_management, population_management_selector=tournament_selection, evaluation_time=settings.evaluation_time, offspring_size=offspring_size, experiment_name=settings.experiment_name, experiment_management=experiment_management, + environments=environments, + front=front ) settings = parser.parse_args() - simulator_queue = SimulatorQueue(settings.n_cores, settings, settings.port_start) - await simulator_queue.start() - population = Population(population_conf, simulator_queue, next_robot_id) + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) if do_recovery: - # loading a previous state of the experiment - await population.load_snapshot(gen_num) + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + if has_offspring: individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) gen_num += 1 diff --git a/experiments/karines_experiments/plastic2.py b/experiments/karines_experiments/plastic2.py new file mode 100755 index 0000000000..754fd4c9e5 --- /dev/null +++ b/experiments/karines_experiments/plastic2.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys +import time + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 100 + population_size = 100 + offspring_size = 50 + front = 'total_slaves' + + # environment world and z-start + environments = {'plane': 0.03, + 'tilted5': 0.1 + } + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=True, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_plane(robot_manager, robot): + #contacts = measures.contacts(robot_manager, robot) + #assert(contacts != 0) + return fitness.displacement_velocity_hill(robot_manager, robot) + + fitness_function = {'plane': fitness_function_plane, + 'tilted5': fitness_function_plane} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/experiments/karines_experiments/plastic2_lava.py b/experiments/karines_experiments/plastic2_lava.py new file mode 100755 index 0000000000..df0652c531 --- /dev/null +++ b/experiments/karines_experiments/plastic2_lava.py @@ -0,0 +1,160 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 100 + population_size = 100 + offspring_size = 50 + front = 'total_slaves' + + # environment world and z-start + environments = {'plane': 0.03, + 'lava': 0.03 + } + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=True, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_plane(robot_manager, robot): + contacts = measures.contacts(robot_manager, robot) + assert(contacts != 0) + return fitness.displacement_velocity_hill(robot_manager, robot) + + def fitness_function_lava(robot_manager, robot): + contacts = measures.contacts(robot_manager, robot) + assert(contacts != 0) + return fitness.floor_is_lava(robot_manager, robot) + + fitness_functions = {'plane': fitness_function_plane, + 'lava': fitness_function_lava} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_functions, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/experiments/karines_experiments/run-experiments b/experiments/karines_experiments/run-experiments index 2499bbd4cc..27b46e2f08 100755 --- a/experiments/karines_experiments/run-experiments +++ b/experiments/karines_experiments/run-experiments @@ -1,10 +1,264 @@ -#!/bin/bash + #!/bin/bash + +# BASELINE MEANS BASELINE+FLAT-TILTED + +while true + do + for i in {1..5}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_$i --run $i --manager experiments/karines_experiments/baseline2.py --n-cores 4 --port-start 11000 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {6..10}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_$i --run $i --manager experiments/karines_experiments/baseline2.py --n-cores 4 --port-start 11050 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {11..15}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_$i --run $i --manager experiments/karines_experiments/baseline2.py --n-cores 4 --port-start 11100 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {16..20}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_$i --run $i --manager experiments/karines_experiments/baseline2.py --n-cores 4 --port-start 11150 --evaluation-time 50; + + sleep 5s + done +done + + + +# PLASTIC MEANS PLASTIC+FLAT-TILTED + +while true + do + for i in {1..5}; do + ./revolve.py --experiment-name karines_experiments/data/plastic2_$i --run $i --manager experiments/karines_experiments/plastic2.py --n-cores 4 --port-start 11200 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {6..10}; do + ./revolve.py --experiment-name karines_experiments/data/plastic2_$i --run $i --manager experiments/karines_experiments/plastic2.py --n-cores 4 --port-start 11250 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {11..15}; do + ./revolve.py --experiment-name karines_experiments/data/plastic2_$i --run $i --manager experiments/karines_experiments/plastic2.py --n-cores 4 --port-start 11300 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {16..20}; do + ./revolve.py --experiment-name karines_experiments/data/plastic2_$i --run $i --manager experiments/karines_experiments/plastic2.py --n-cores 4 --port-start 11350 --evaluation-time 50; + + sleep 5s + done +done + + + + while true do for i in {1..10}; do - ./revolve.py --experiment_name karines_experiments/data/lava_$i --run $i --manager experiments/karines_experiments/manager_pop_lava.py --n-cores 5; + ./revolve.py --experiment-name karines_experiments/data/flat_$i --run $i --manager experiments/karines_experiments/flat.py --n-cores 4 --port-start 11400 --evaluation-time 50; + + sleep 5s + done +done + +while true + do + for i in {11..20}; do + ./revolve.py --experiment-name karines_experiments/data/flat_$i --run $i --manager experiments/karines_experiments/flat.py --n-cores 4 --port-start 11500 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {1..10}; do + ./revolve.py --experiment-name karines_experiments/data/tilted_$i --run $i --manager experiments/karines_experiments/tilted.py --n-cores 4 --port-start 11600 --evaluation-time 50; + + sleep 5s + done +done + +while true + do + for i in {11..20}; do + ./revolve.py --experiment-name karines_experiments/data/tilted_$i --run $i --manager experiments/karines_experiments/tilted.py --n-cores 4 --port-start 11700 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {1..5}; do + ./revolve.py --experiment-name karines_experiments/data/lava_$i --run $i --manager experiments/karines_experiments/lava.py --n-cores 4 --port-start 11111 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {6..10}; do + ./revolve.py --experiment-name karines_experiments/data/lava_$i --run $i --manager experiments/karines_experiments/lava.py --n-cores 4 --port-start 11121 --evaluation-time 50; + + sleep 5s + done +done + + + +while true + do + for i in {11..15}; do + ./revolve.py --experiment-name karines_experiments/data/lava_$i --run $i --manager experiments/karines_experiments/lava.py --n-cores 4 --port-start 11131 --evaluation-time 50; + + sleep 5s + done +done + + + +while true + do + for i in {16..20}; do + ./revolve.py --experiment-name karines_experiments/data/lava_$i --run $i --manager experiments/karines_experiments/lava.py --n-cores 4 --port-start 11141 --evaluation-time 50; + + sleep 5s + done +done + +### + + +while true + do + for i in {1..2}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_lava_$i --run $i --manager experiments/karines_experiments/baseline2_lava.py --n-cores 4 --port-start 11111 --evaluation-time 50; + sleep 5s - ./revolve.py --experiment_name karines_experiments/data/plane_$i --run $i --manager experiments/karines_experiments/manager_pop.py --n-cores 5; + done +done + + +while true + do + for i in {3..4}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_lava_$i --run $i --manager experiments/karines_experiments/baseline2_lava.py --n-cores 4 --port-start 11121 --evaluation-time 50; + sleep 5s done -done \ No newline at end of file +done + + + +while true + do + for i in {5..6}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_lava_$i --run $i --manager experiments/karines_experiments/baseline2_lava.py --n-cores 4 --port-start 11131 --evaluation-time 50; + + sleep 5s + done +done + + + +while true + do + for i in {7..8}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_lava_$i --run $i --manager experiments/karines_experiments/baseline2_lava.py --n-cores 4 --port-start 11141 --evaluation-time 50; + + sleep 5s + done +done + +while true + do + for i in {9..11}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_lava_$i --run $i --manager experiments/karines_experiments/baseline2_lava.py --n-cores 4 --port-start 11151 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {12..14}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_lava_$i --run $i --manager experiments/karines_experiments/baseline2_lava.py --n-cores 4 --port-start 11161 --evaluation-time 50; + + sleep 5s + done +done + + + +while true + do + for i in {15..17}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_lava_$i --run $i --manager experiments/karines_experiments/baseline2_lava.py --n-cores 4 --port-start 11171 --evaluation-time 50; + + sleep 5s + done +done + + + +while true + do + for i in {18..20}; do + ./revolve.py --experiment-name karines_experiments/data/baseline2_lava_$i --run $i --manager experiments/karines_experiments/baseline2_lava.py --n-cores 4 --port-start 11181 --evaluation-time 50; + + sleep 5s + done +done + + + +while true + do + sleep 900s; + kill $( ps aux | grep 'gzserver' | awk '{print $2}'); + kill $( ps aux | grep 'revolve.py' | awk '{print $2}'); + sleep 60s; +done + + diff --git a/experiments/karines_experiments/scatter.R b/experiments/karines_experiments/scatter.R new file mode 100644 index 0000000000..e5a678305a --- /dev/null +++ b/experiments/karines_experiments/scatter.R @@ -0,0 +1,72 @@ + +library(ggplot2) +library(sqldf) + +base_directory <-paste('data', sep='') + +analysis = 'analysis_journal2_tilted' + +output_directory = paste(base_directory,'/',analysis ,sep='') + +experiments_type = c( 'baseline2','plastic2') + +labels_type = c( 'Baseline','Plastic') + +environments = c( 'plane','tilted5') + +labels = c('Speed (cm/s) in Flat', 'Speed (cm/s) in Tilted') + + +runs = list( c(1:20), + c(1:20)) + + + +measures_all = NULL + +for (exp in 1:length(experiments_type)) +{ + for(run in runs[[exp]]) + { + measures_envs = NULL + for (env in 1:length(environments)) + { + input_directory <- paste(base_directory, '/', + experiments_type[exp], '_',sep='') + + measures = read.table(paste(input_directory, run, '/data_fullevolution/', + environments[env], "/all_measures.tsv", sep=''), header = TRUE) + measures = sqldf('select robot_id, displacement_velocity_hill from measures') + measures[paste('speed_',environments[env],sep='')] = as.numeric(as.character(measures[['displacement_velocity_hill']])) + measures[paste('speed_',environments[env],sep='')] = measures[paste('speed_',environments[env],sep='')] * 100 + measures$run = run + + if(env==1){ + measures_envs = measures + }else{ + measures_envs = merge(measures_envs, measures, by = "robot_id") + } + + } + + if ( is.null(measures_all)){ + measures_all = measures_envs + }else{ + measures_all = rbind(measures_all, measures_envs) + } + } + + + measures_all = sqldf('select * from measures_all order by robot_id ') + + graph = ggplot(measures_all, aes(x=speed_plane, y=speed_tilted5, colour=robot_id))+ + geom_point(alpha=0.5, size=3)+ + labs(subtitle=labels_type[exp], x=labels[1], y=labels[2])+ + coord_cartesian(ylim = c(-5, 5), xlim = c(-5, 5)) + + ggsave(paste( output_directory,'/',experiments_type[exp],'_scatter.pdf', sep=''), graph , device='pdf', height = 10, width = 10) + +} + + + diff --git a/experiments/karines_experiments/scatter2.R b/experiments/karines_experiments/scatter2.R new file mode 100644 index 0000000000..4203e22a28 --- /dev/null +++ b/experiments/karines_experiments/scatter2.R @@ -0,0 +1,80 @@ + +library(ggplot2) +library(sqldf) + +base_directory <-paste('data', sep='') + +analysis = 'analysis_journal2_tilted' + +output_directory = paste(base_directory,'/',analysis ,sep='') + +experiments_type = c( 'baseline2','plastic2') + +labels_type = c( 'Baseline','Plastic') + +environments = c( 'plane','tilted5') + +labels = c('Speed (cm/s) in Flat', 'Speed (cm/s) in Tilted') + + +runs = list( c(1:20), c(1:20)) + + + + +measures_all = NULL + +for (exp in 1:length(experiments_type)) +{ + for(run in runs[[exp]]) + { + measures_envs = NULL + for (env in 1:length(environments)) + { + input_directory <- paste(base_directory, '/', + experiments_type[exp], '_',sep='') + + measures = read.table(paste(input_directory, run, '/data_fullevolution/', + environments[env], "/all_measures.tsv", sep=''), header = TRUE) + measures = sqldf('select robot_id, displacement_velocity_hill from measures') + measures[paste('speed_',environments[env],sep='')] = as.numeric(as.character(measures[['displacement_velocity_hill']])) + measures[paste('speed_',environments[env],sep='')] = measures[paste('speed_',environments[env],sep='')] * 100 + measures$run = run + + snapshots = read.table(paste(input_directory, run,'/selectedpop_', + environments[env],"/snapshots_ids.tsv", sep=''), header = TRUE) + + measures_snapshots = sqldf('select * from snapshots inner join measures using(robot_id) order by generation') + + #measures_snapshots = sqldf('select * from measures_snapshots where generation in (0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 99)') + measures_snapshots = sqldf('select * from measures_snapshots where generation in (0, 30, 60, 99)') + + if(env==1){ + measures_envs = measures_snapshots + }else{ + measures_envs = merge(measures_envs, measures_snapshots, by = "robot_id") + } + + } + + if ( is.null(measures_all)){ + measures_all = measures_envs + }else{ + measures_all = rbind(measures_all, measures_envs) + } + } + + + measures_all = sqldf('select * from measures_all order by robot_id ') + + graph = ggplot(measures_all, aes(x=speed_plane, y=speed_tilted5, colour=generation.x))+ + geom_point(alpha=0.5, size=3)+ + labs(subtitle=labels_type[exp], x=labels[1], y=labels[2])+ + coord_cartesian(ylim = c(-2, 2), xlim = c(-2.5, 3.5)) + + ggsave(paste( output_directory,'/',experiments_type[exp],'_scatter.pdf', sep=''), graph , device='pdf', height = 10, width = 10) + +} + + + diff --git a/experiments/karines_experiments/stuck-experiments_watchman.py b/experiments/karines_experiments/stuck-experiments_watchman.py index 272d59a67a..af46e77214 100644 --- a/experiments/karines_experiments/stuck-experiments_watchman.py +++ b/experiments/karines_experiments/stuck-experiments_watchman.py @@ -34,8 +34,9 @@ files.sort() youngest.append(files[-1]) - if files[-1] > time_ago: - some_has_been_updated = True + if len(files)>0: + if files[-1] > time_ago: + some_has_been_updated = True if not some_has_been_updated: youngest.sort() diff --git a/experiments/karines_experiments/summary_measures.R b/experiments/karines_experiments/summary_measures.R deleted file mode 100644 index b9a396edee..0000000000 --- a/experiments/karines_experiments/summary_measures.R +++ /dev/null @@ -1,383 +0,0 @@ -library(ggplot2) -library(sqldf) -library(plyr) -library(dplyr) -library(trend) - -base_directory <- paste('projects/revolve/experiments/karines_experiments/data', sep='') - -output_directory = base_directory - -experiments_type = c( - 'plane', - 'lava' - ) - -initials = c('p', 'l') - -experiments_labels = c('Plane', 'Floor is lava') - -runs = c(1,2,3,4,5,6,7,8,9,10) -gens = 100 -pop = 100 -sig = 0.05 -line_size = 30 -show_markers = TRUE -show_legends = TRUE -experiments_type_colors = c( '#009900', '#FF8000', '#BA1616', '#000099') # DARK:green, orange, red, blue - -measures_names = c( - 'displacement_velocity_hill', - 'head_balance', - 'contacts', - 'displacement_velocity', - 'branching', - 'branching_modules_count', - 'limbs', - 'extremities', - 'length_of_limbs', - 'extensiveness', - 'coverage', - 'joints', - 'hinge_count', - 'active_hinges_count', - 'brick_count', - 'touch_sensor_count', - 'brick_sensor_count', - 'proportion', - 'width', - 'height', - 'absolute_size', - 'sensors', - 'symmetry', - 'avg_period', - 'dev_period', - 'avg_phase_offset', - 'dev_phase_offset', - 'avg_amplitude', - 'dev_amplitude', - 'avg_intra_dev_params', - 'avg_inter_dev_params', - 'sensors_reach', - 'recurrence', - 'synaptic_reception', - 'fitness' -) - -# add proper labels soon... -measures_labels = c( - 'Speed', - 'Balance', - 'Contacts', - 'displacement_velocity', - 'branching', - 'branching_modules_count', - 'limbs', - 'extremities', - 'length_of_limbs', - 'extensiveness', - 'coverage', - 'joints', - 'hinge_count', - 'active_hinges_count', - 'brick_count', - 'touch_sensor_count', - 'brick_sensor_count', - 'proportion', - 'width', - 'height', - 'absolute_size', - 'sensors', - 'symmetry', - 'avg_period', - 'dev_period', - 'avg_phase_offset', - 'dev_phase_offset', - 'avg_amplitude', - 'dev_amplitude', - 'avg_intra_dev_params', - 'avg_inter_dev_params', - 'sensors_reach', - 'recurrence', - 'synaptic_reception', - 'Fitness' -) - - -measures_snapshots_all = NULL - -for (exp in 1:length(experiments_type)) -{ - for(run in runs) - { - input_directory <- paste(base_directory, '/', experiments_type[exp], '_', run, sep='') - measures = read.table(paste(input_directory,"/all_measures.tsv", sep=''), header = TRUE) - for( m in 1:length(measures_names)) - { - measures[measures_names[m]] = as.numeric(as.character(measures[[measures_names[m]]])) - } - - snapshots = read.table(paste(input_directory,"/snapshots_ids.tsv", sep=''), header = TRUE) - measures_snapshots = sqldf('select * from snapshots inner join measures using(robot_id) order by generation') - - measures_snapshots$run = run - measures_snapshots$run = as.factor(measures_snapshots$run) - measures_snapshots$method = experiments_type[exp] - - if ( is.null(measures_snapshots_all)){ - measures_snapshots_all = measures_snapshots - }else{ - measures_snapshots_all = rbind(measures_snapshots_all, measures_snapshots) - } - } -} - - - -measures_snapshots_all = sqldf("select * from measures_snapshots_all where fitness IS NOT NULL") - -fail_test = sqldf(paste("select method,run,generation,count(*) as c from measures_snapshots_all group by 1,2,3 having c<",gens," order by 4")) - - -measures_averages_gens_1 = list() -measures_averages_gens_2 = list() - -measures_ini = list() -measures_fin = list() - -for (exp in 1:length(experiments_type)) -{ - - query ='select run, generation' - for (i in 1:length(measures_names)) - { - query = paste(query,', avg(',measures_names[i],') as ',experiments_type[exp],'_',measures_names[i],'_avg', sep='') - } - query = paste(query,' from measures_snapshots_all - where method="',experiments_type[exp],'" group by run, generation', sep='') - - - measures_averages_gens_1[[exp]] = sqldf(query) - - temp = measures_averages_gens_1[[exp]] - - measures_ini[[exp]] = sqldf(paste("select * from temp where generation=1")) - measures_fin[[exp]] = sqldf(paste("select * from temp where generation=",gens-1)) - query = 'select generation' - for (i in 1:length(measures_names)) - { - query = paste(query,', avg(',experiments_type[exp],'_',measures_names[i],'_avg) as ',experiments_type[exp],'_',measures_names[i],'_avg', sep='') - query = paste(query,', max(',experiments_type[exp],'_',measures_names[i],'_avg) as ',experiments_type[exp],'_',measures_names[i],'_max', sep='') - query = paste(query,', stdev(',experiments_type[exp],'_',measures_names[i],'_avg) as ',experiments_type[exp],'_',measures_names[i],'_stdev', sep='') - query = paste(query,', median(',experiments_type[exp],'_',measures_names[i],'_avg) as ',experiments_type[exp],'_',measures_names[i],'_median', sep='') - } - query = paste(query,' from temp group by generation', sep="") - - measures_averages_gens_2[[exp]] = sqldf(query) - - measures_averages_gens_2[[exp]]$generation = as.numeric(measures_averages_gens_2[[exp]]$generation) - -} - - -for (exp in 1:length(experiments_type)) -{ - if(exp==1){ - measures_averages_gens = measures_averages_gens_2[[1]] - }else{ - measures_averages_gens = merge(measures_averages_gens, measures_averages_gens_2[[exp]], by = "generation") - } -} - - - -file <-file(paste(output_directory,'/trends.txt',sep=''), open="w") - -#tests trends in curves and difference between ini and fin generations - - -# ini VS fin -array_wilcoxon = list() -array_wilcoxon2 = list() - -# curve -array_mann = list() - - -for (m in 1:length(experiments_type)) -{ - - array_wilcoxon[[m]] = list() - array_mann[[m]] = list() - - for (i in 1:length(measures_names)) - { - - writeLines(paste(experiments_type[m],measures_names[i],'ini avg ',as.character( - mean(c(array(measures_ini[[m]][paste(experiments_type[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) - - - writeLines(paste(experiments_type[m],measures_names[i],'fin avg ',as.character( - mean(c(array(measures_fin[[m]][paste(experiments_type[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) - - array_wilcoxon[[m]][[i]] = wilcox.test(c(array(measures_ini[[m]][paste(experiments_type[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , - c(array(measures_fin[[m]][paste(experiments_type[m],"_",measures_names[i],"_avg",sep='')]))[[1]] - ) - - writeLines(c( - paste(experiments_type[m],'iniVSfin',measures_names[i],'wilcox p: ',as.character(round(array_wilcoxon[[m]][[i]]$p.value,4)), sep=' ') - ,paste(experiments_type[m],'iniVSfin',measures_names[i],'wilcox est: ',as.character(round(array_wilcoxon[[m]][[i]]$statistic,4)), sep=' ') - - ), file) - - - #tests trends - array_mann[[m]][[i]] = mk.test(c(array(measures_averages_gens_2[[m]][paste(experiments_type[m],"_",measures_names[i],'_median',sep='')]) )[[1]], - continuity = TRUE) - - - writeLines(c( - paste(experiments_type[m],measures_names[i], ' Mann-Kendall median p', as.character(round(array_mann[[m]][[i]]$p.value,4)),sep=' '), - paste(experiments_type[m],measures_names[i], ' Mann-Kendall median s', as.character(round(array_mann[[m]][[i]]$statistic,4)),sep=' ') - ), file) - - } - -} - - - -# tests final generation among experiments_type - -aux_m = length(experiments_type) - -if (aux_m>1) -{ - - # fins - array_wilcoxon2[[1]] = list() - array_wilcoxon2[[2]] = list() - -aux_m = aux_m -1 -count_pairs = 0 -for(m in 1:aux_m) -{ - aux = m+1 - for(m2 in aux:length(experiments_type)) - { - - count_pairs = count_pairs+1 - array_wilcoxon2[[1]][[count_pairs]] = list() - - for (i in 1:length(measures_names)) - { - - writeLines(paste(experiments_type[m],measures_names[i],'fin avg ',as.character( - mean(c(array(measures_fin[[m]][paste(experiments_type[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) - - writeLines(paste(experiments_type[m2],measures_names[i],'fin avg ',as.character( - mean(c(array(measures_fin[[m2]][paste(experiments_type[m2],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) - - array_wilcoxon2[[1]][[count_pairs]][[i]] = wilcox.test(c(array(measures_fin[[m]][paste(experiments_type[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , - c(array(measures_fin[[m2]][paste(experiments_type[m2],"_",measures_names[i],"_avg",sep='')]))[[1]] - ) - - writeLines(c( - paste(experiments_type[m],'VS',experiments_type[m2],measures_names[i],'fin avg wilcox p: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$p.value,4)), sep=' ') - ,paste(experiments_type[m],'VS',experiments_type[m2],measures_names[i],'fin avg wilcox est: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$statistic,4)), sep=' ') - - ), file) - - } - - - array_wilcoxon2[[2]][[count_pairs]] = paste(initials[m],initials[m2],sep='') - - } -} - -} - -close(file) - -# plots measures - -for (i in 1:length(measures_names)) -{ - tests1 = '' - tests2 = '' - tests3 = '' - break_aux = 0 - - graph <- ggplot(data=measures_averages_gens, aes(x=generation)) - for(m in 1:length(experiments_type)) - { - graph = graph + geom_errorbar(aes_string(ymin=paste(experiments_type[m],'_',measures_names[i],'_avg','-',experiments_type[m],'_',measures_names[i],'_stdev',sep=''), - ymax=paste(experiments_type[m],'_',measures_names[i],'_avg','+',experiments_type[m],'_',measures_names[i],'_stdev',sep='') ), - color=experiments_type_colors[m], - alpha=0.35,size=0.5,width=0.001) - } - - for(m in 1:length(experiments_type)) - { - if(show_legends == TRUE){ - graph = graph + geom_line(aes_string(y=paste(experiments_type[m],'_',measures_names[i],'_avg',sep=''), colour=shQuote(experiments_labels[m]) ), size=2) - }else{ - graph = graph + geom_line(aes_string(y=paste(experiments_type[m],'_',measures_names[i],'_avg',sep='') ),size=2, color = experiments_type_colors[m]) - } - # graph = graph + geom_line(aes_string(y=paste(experiments_type[m],'_',measures_names[i],'_median',sep='') ),size=2, color = colors_median[m]) - - if(!is.na(array_mann[[m]][[i]]$p.value)) - { - if(array_mann[[m]][[i]]$p.value<=sig) - { - if(array_mann[[m]][[i]]$statistic>0){ direction = "/ "} else { direction = "\\ "} - tests1 = paste(tests1, initials[m],direction,sep="") - } - } - } - for(m in 1:length(experiments_type)) - { - if(!is.na(array_wilcoxon[[m]][[i]]$p.value)) - { - if(array_wilcoxon[[m]][[i]]$p.value<=sig) - { - tests2 = paste(tests2, initials[m],'C ', sep='') - } - } - } - - if (length(array_wilcoxon2)>0) - { - - for(p in 1:length(array_wilcoxon2[[1]])) - { - if(!is.na(array_wilcoxon2[[1]][[p]][[i]]$p.value)) - { - if(array_wilcoxon2[[1]][[p]][[i]]$p.value<=sig) - { - if(nchar(tests3)>line_size && break_aux == 0){ - tests3 = paste(tests3, '\n') - break_aux = 1 - } - tests3 = paste(tests3, array_wilcoxon2[[2]][[p]],'D ',sep='') - } - } - - } - - } - - graph = graph + - #coord_cartesian(ylim = c(0, 1))+ - labs( y=measures_labels[i], x="Generation") - if(show_markers == TRUE){ - graph = graph + labs( y=measures_labels[i], x="Generation", subtitle = paste(tests1,'\n', tests2, '\n', tests3, sep='')) - } - graph = graph + theme(legend.position="bottom" , legend.text=element_text(size=20), axis.text=element_text(size=30),axis.title=element_text(size=39), - plot.subtitle=element_text(size=25 )) - - ggsave(paste( output_directory,'/' ,measures_names[i],'_generations.pdf', sep=''), graph , device='pdf', height = 8, width = 8) -} - - diff --git a/experiments/karines_experiments/summary_measures_journal1_lava.R b/experiments/karines_experiments/summary_measures_journal1_lava.R new file mode 100644 index 0000000000..dbdc8ab835 --- /dev/null +++ b/experiments/karines_experiments/summary_measures_journal1_lava.R @@ -0,0 +1,575 @@ +library(ggplot2) +library(sqldf) +library(plyr) +library(dplyr) +library(trend) +library(purrr) +library(ggsignif) + +base_directory <-paste('data', sep='') + +analysis = 'analysis_journal1_lava' + +output_directory = paste(base_directory,'/',analysis ,sep='') + +#### CHANGE THE PARAMETERS HERE #### + + +experiments_type = c('flat', 'lava','baseline2_lava') + +environments = list( c( 'plane'), + c('lava'), + c( 'plane','lava') ) + +methods = c() +for (exp in 1:length(experiments_type)) +{ + for (env in 1:length(environments[[exp]])) + { + methods = c(methods, paste(experiments_type[exp], environments[[exp]][env], sep='_')) + } +} + +initials = c( 'bp', 'bt', 'pp', 'pt') + +experiments_labels = c( 'Non-S: Flat', 'Non-S: Lava', + 'Seasonal: Flat', 'Seasonal: Lava') + +experiments_labels2 = c( 'Non-S: Flat', 'Non-S: Lava', + 'Seasonal', 'Seasonal') + +runs = list( c(1:20) , + c(1:20) , + c(1:20) ) + +gens = 1#100 +pop = 100 + +#### CHANGE THE PARAMETERS HERE #### + +sig = 0.05 +line_size = 30 +show_markers = TRUE#FALSE +show_legends = FALSE +experiments_type_colors = c( '#00e700' , '#009900', '#ffb83b', '#fd8a3b') # DARK: light green,dark green, light red, dark red + +measures_names = c( + 'displacement_velocity_hill', + 'head_balance', + 'contacts', + 'displacement_velocity', + 'branching', + 'branching_modules_count', + 'limbs', + 'extremities', + 'length_of_limbs', + 'extensiveness', + 'coverage', + 'joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'proportion', + 'width', + 'height', + 'absolute_size', + 'sensors', + 'symmetry', + 'avg_period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'fitness', + 'cons_fitness' +) + +# add proper labels soon... +measures_labels = c( + 'Speed (cm/s)', + 'Balance', + 'Contacts', + 'displacement_velocity', + 'Branching', + 'branching_modules_count', + 'Rel number of limbs', + 'extremities', + 'Rel. Length of Limbs', + 'extensiveness', + 'coverage', + 'Rel. Number of Joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'Proportion', + 'width', + 'height', + 'Size', + 'sensors', + 'Symmetry', + 'Average Period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'Fitness', + 'Number of slaves' +) + + +measures_snapshots_all = NULL + +for (exp in 1:length(experiments_type)) +{ + for(run in runs[[exp]]) + { + for (env in 1:length(environments[[exp]])) + { + input_directory <- paste(base_directory, '/', + experiments_type[exp], '_',sep='') + + measures = read.table(paste(input_directory, run, '/data_fullevolution/', + environments[[exp]][env], "/all_measures.tsv", sep=''), header = TRUE, fill=TRUE) + for( m in 1:length(measures_names)) + { + measures[measures_names[m]] = as.numeric(as.character(measures[[measures_names[m]]])) + } + + snapshots = read.table(paste(input_directory, run,'/selectedpop_', + environments[[exp]][env],"/snapshots_ids.tsv", sep=''), header = TRUE) + + measures_snapshots = sqldf('select * from snapshots inner join measures using(robot_id) order by generation') + + measures_snapshots$run = run + measures_snapshots$displacement_velocity_hill = measures_snapshots$displacement_velocity_hill*100 + measures_snapshots$run = as.factor(measures_snapshots$run) + measures_snapshots$method = paste(experiments_type[exp], environments[[exp]][env],sep='_') + + if ( is.null(measures_snapshots_all)){ + measures_snapshots_all = measures_snapshots + }else{ + measures_snapshots_all = rbind(measures_snapshots_all, measures_snapshots) + } + } + } +} + + +fail_test = sqldf(paste("select method,run,generation,count(*) as c from measures_snapshots_all group by 1,2,3 having c<",gens," order by 4")) + + +measures_snapshots_all = sqldf("select * from measures_snapshots_all where cons_fitness IS NOT NULL") + + +# densities + +measures_snapshots_all_densities = sqldf(paste("select * from measures_snapshots_all where generation=42 + and method !='", methods[length(methods)],"'",sep='' )) #99!!!! + +measures_names_densities = c('length_of_limbs','proportion', 'absolute_size','head_balance','joints', 'limbs') +measures_labels_densities = c('Rel. Length of Limbs','Proportion', 'Size','Balance','Rel. Number of Joints', 'Rel. Number of Limbs') + +for (i in 1:length(measures_names_densities)) +{ + + for (j in 1:length(measures_names_densities)) + { + + if(i != j) + { + + graph <- ggplot(measures_snapshots_all_densities, aes_string(x=measures_names_densities[j], y= measures_names_densities[i]))+ + geom_density_2d(aes(colour = method ), alpha=0.7, size=3 )+ + scale_color_manual(values = c(experiments_type_colors[4:4], experiments_type_colors[1:2]) )+ + labs( x = measures_labels_densities[j], y= measures_labels_densities[i] )+ + theme(legend.position="bottom" , axis.text=element_text(size=21),axis.title=element_text(size=22), + plot.subtitle=element_text(size=25 )) + + coord_cartesian(ylim = c(0, 1), xlim = c(0, 1)) + ggsave(paste( output_directory ,'/density_',measures_names_densities[i],'_', measures_names_densities[j],'.png', sep=''), graph , + device='png', height = 6, width = 6) + } + + } +} + + + +measures_averages_gens_1 = list() +measures_averages_gens_2 = list() + +measures_ini = list() +measures_fin = list() + +for (met in 1:length(methods)) +{ + + measures_aux = c() + query ='select run, generation' + for (i in 1:length(measures_names)) + { + query = paste(query,', avg(',measures_names[i],') as ', methods[met], '_',measures_names[i],'_avg', sep='') + } + query = paste(query,' from measures_snapshots_all + where method="', methods[met],'" group by run, generation', sep='') + + temp = sqldf(query) + + measures_averages_gens_1[[met]] = temp + + temp = measures_averages_gens_1[[met]] + + temp$generation = as.numeric(temp$generation) + + measures_ini[[met]] = sqldf(paste("select * from temp where generation=0")) + measures_fin[[met]] = sqldf(paste("select * from temp where generation=",gens-1)) + query = 'select generation' + for (i in 1:length(measures_names)) + { + # later renames vars _avg_SUMMARY, just to make it in the same style as the quantile variables + query = paste(query,', avg(', methods[met], '_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_avg', sep='') + query = paste(query,', max(', methods[met],'_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_max', sep='') + query = paste(query,', stdev(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_stdev', sep='') + query = paste(query,', median(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_median', sep='') + + measures_aux = c(measures_aux, paste(methods[met],'_',measures_names[i],'_avg', sep='') ) + } + query = paste(query,' from temp group by generation', sep="") + + temp2 = sqldf(query) + + p <- c(0.25, 0.75) + p_names <- map_chr(p, ~paste0('Q',.x*100, sep="")) + p_funs <- map(p, ~partial(quantile, probs = .x, na.rm = TRUE)) %>% + set_names(nm = p_names) + + quantiles = data.frame(temp %>% + group_by(generation) %>% + summarize_at(vars(measures_aux), funs(!!!p_funs)) ) + + measures_averages_gens_2[[met]] = sqldf('select * from temp2 inner join quantiles using (generation)') + +} + + +for (met in 1:length(methods)) +{ + if(met==1){ + measures_averages_gens = measures_averages_gens_2[[1]] + }else{ + measures_averages_gens = merge(measures_averages_gens, measures_averages_gens_2[[met]], all=TRUE, by = "generation") + } +} + +file <-file(paste(output_directory,'/trends.txt',sep=''), open="w") + +#tests trends in curves and difference between ini and fin generations + + +# ini VS fin +array_wilcoxon = list() +array_wilcoxon2 = list() + +# curve +array_mann = list() + + +for (m in 1:length(methods)) +{ + + array_wilcoxon[[m]] = list() + array_mann[[m]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(experiments_type[m],measures_names[i],'ini avg ',as.character( + mean(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon[[m]][[i]] = wilcox.test(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'iniVSfin',measures_names[i],'wilcox p: ',as.character(round(array_wilcoxon[[m]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'iniVSfin',measures_names[i],'wilcox est: ',as.character(round(array_wilcoxon[[m]][[i]]$statistic,4)), sep=' ') + + ), file) + + + #tests trends + array_mann[[m]][[i]] = mk.test(c(array(measures_averages_gens_2[[m]][paste(methods[m],"_",measures_names[i],'_median',sep='')]) )[[1]], + continuity = TRUE) + + + writeLines(c( + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median p', as.character(round(array_mann[[m]][[i]]$p.value,4)),sep=' '), + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median s', as.character(round(array_mann[[m]][[i]]$statistic,4)),sep=' ') + ), file) + + } + +} + + + +# tests final generation among experiments_type + +aux_m = length(methods) + +if (aux_m>1) +{ + + # fins + array_wilcoxon2[[1]] = list() + array_wilcoxon2[[2]] = list() + + aux_m = aux_m -1 + count_pairs = 0 + for(m in 1:aux_m) + { + aux = m+1 + for(m2 in aux:length(methods)) + { + + count_pairs = count_pairs+1 + array_wilcoxon2[[1]][[count_pairs]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + writeLines(paste(methods[m2],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon2[[1]][[count_pairs]][[i]] = wilcox.test(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'VS',methods,measures_names[i],'fin avg wilcox p: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'VS',methods[m2],measures_names[i],'fin avg wilcox est: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$statistic,4)), sep=' ') + + ), file) + + } + + + array_wilcoxon2[[2]][[count_pairs]] = paste(initials[m],initials[m2],sep='') + + } + } + +} + +close(file) + +# plots measures + +for (type_summary in c('means','quants')) +{ + + + for (i in 1:length(measures_names)) + { + tests1 = '' + tests2 = '' + tests3 = '' + break_aux = 0 + + graph <- ggplot(data=measures_averages_gens, aes(x=generation)) + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg','-',methods[m],'_',measures_names[i],'_stdev',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg','+',methods[m],'_',measures_names[i],'_stdev',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + }else + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg_Q25',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg_Q75',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + } + } + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep=''), colour=shQuote(experiments_labels[m]) ), size=2) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep='') ),size=2, color = experiments_type_colors[m]) + } + + }else{ + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') , colour=shQuote(experiments_labels[m]) ),size=2 ) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') ),size=2, color = experiments_type_colors[m] ) + } + } + + if (length(array_mann)>0) + { + if (length(array_mann[[m]])>0) + { + if(!is.na(array_mann[[m]][[i]]$p.value)) + { + if(array_mann[[m]][[i]]$p.value<=sig) + { + if(array_mann[[m]][[i]]$statistic>0){ direction = "/ "} else { direction = "\\ "} + tests1 = paste(tests1, initials[m],direction,sep="") + } + } + } + } + } + + if (length(array_wilcoxon[[m]])>0) + { + for(m in 1:length(methods)) + { + if(!is.na(array_wilcoxon[[m]][[i]]$p.value)) + { + if(array_wilcoxon[[m]][[i]]$p.value<=sig) + { + tests2 = paste(tests2, initials[m],'C ', sep='') + } + } + } + } + + if (length(array_wilcoxon2)>0) + { + for(p in 1:length(array_wilcoxon2[[1]])) + { + if (length(array_wilcoxon2[[1]][[p]])>0) + { + if(!is.na(array_wilcoxon2[[1]][[p]][[i]]$p.value)) + { + if(array_wilcoxon2[[1]][[p]][[i]]$p.value<=sig) + { + if(nchar(tests3)>line_size && break_aux == 0){ + tests3 = paste(tests3, '\n') + break_aux = 1 + } + tests3 = paste(tests3, array_wilcoxon2[[2]][[p]],'D ',sep='') + } + } + } + } + } + + max_y = 0 + min_y = 0 + if(measures_names[i]=='displacement_velocity_hill' ){ + max_y = 3 + min_y = -0.5 + } + + graph = graph + labs( y=measures_labels[i], x="Generation") + if (max_y>0) { + graph = graph + coord_cartesian(ylim = c(min_y, max_y)) + } + + if(show_markers == TRUE){ + graph = graph + labs( y=measures_labels[i], x="Generation", subtitle = paste(tests1,'\n', tests2, '\n', tests3, sep='')) + } + graph = graph + theme(legend.position="bottom" , legend.text=element_text(size=20), axis.text=element_text(size=30),axis.title=element_text(size=39), + plot.subtitle=element_text(size=25 )) + + ggsave(paste( output_directory,'/',type_summary,'_' ,measures_names[i],'_generations.pdf', sep=''), graph , device='pdf', height = 10, width = 10) + } + +} + + + + +for (i in 1:length(measures_names)) +{ + + all_final_values = data.frame() + if (measures_names[i] == 'displacement_velocity_hill') { fin=length(methods) + }else{ fin=length(methods)-1 } + + for (exp in 1:fin) + { + temp = data.frame( c(measures_fin[[exp]][paste(methods[exp],'_',measures_names[i],'_avg', sep='')])) + colnames(temp) <- 'values' + if (measures_names[i] == 'displacement_velocity_hill') { temp$type = experiments_labels[exp] + }else{ temp$type = experiments_labels2[exp] } + + all_final_values = rbind(all_final_values, temp) + } + + + max_y = 0 + # if(measures_names[i]=='proportion' || measures_names[i]=='head_balance' || measures_names[i]=='joints' ){ max_y = 1.1 } + + g1 <- ggplot(data=all_final_values, aes(x= type , y=values, color=type )) + + geom_boxplot(position = position_dodge(width=0.9),lwd=2, outlier.size = 4, notch=TRUE) + + labs( x="Environment", y=measures_labels[i], title="Final generation") + + if (measures_names[i] == 'displacement_velocity_hill') { g1 = g1 + scale_color_manual(values=experiments_type_colors) + }else{ g1 = g1 + scale_color_manual(values= c(experiments_type_colors[1:2],experiments_type_colors[4:4])) } + + g1 = g1 + theme(legend.position="none" , text = element_text(size=45) , + plot.title=element_text(size=40), axis.text=element_text(size=45), + axis.title=element_text(size=50), + axis.text.x = element_text(angle = 20, hjust = 1 ), + plot.margin=margin(t = 0.5, r = 0.5, b = 0.5, l = 0.5, unit = "cm") + )+ + stat_summary(fun.y = mean, geom="point" ,shape = 16, size=11) + + if (measures_names[i] == 'displacement_velocity_hill') { comps = list(c("Non-S: Flat", "Seasonal: Flat"), + c("Non-S: Lava", "Seasonal: Lava"), + c("Non-S: Lava", "Non-S: Flat"), + c("Seasonal: Lava", "Seasonal: Flat")) + aux_width=13 + }else{ comps = list(c("Non-S: Flat", "Non-S: Lava"), + c("Non-S: Flat", "Seasonal"), + c("Non-S: Lava", "Seasonal")) + aux_width=10 + } + + + g1 = g1 + geom_signif( test="wilcox.test", size=2, textsize=22, + comparisons = comps, + map_signif_level=c("***"=0.001,"**"=0.01, "*"=0.05) ) + if (max_y>0) { + g1 = g1 + coord_cartesian(ylim = c(0, max_y)) + } + + ggsave(paste(output_directory,"/",measures_names[i],"_boxes.pdf",sep = ""), g1, device = "pdf", height=18, width = aux_width) + +} + diff --git a/experiments/karines_experiments/summary_measures_journal1_tilted.R b/experiments/karines_experiments/summary_measures_journal1_tilted.R new file mode 100644 index 0000000000..a57ff469ef --- /dev/null +++ b/experiments/karines_experiments/summary_measures_journal1_tilted.R @@ -0,0 +1,575 @@ +library(ggplot2) +library(sqldf) +library(plyr) +library(dplyr) +library(trend) +library(purrr) +library(ggsignif) + +base_directory <-paste('data', sep='') + +analysis = 'analysis_journal1_tilted' + +output_directory = paste(base_directory,'/',analysis ,sep='') + +#### CHANGE THE PARAMETERS HERE #### + + +experiments_type = c('flat', 'tilted','baseline2') + +environments = list( c( 'plane'), + c('tilted5'), + c( 'plane','tilted5') ) + +methods = c() +for (exp in 1:length(experiments_type)) +{ + for (env in 1:length(environments[[exp]])) + { + methods = c(methods, paste(experiments_type[exp], environments[[exp]][env], sep='_')) + } +} + +initials = c( 'bp', 'bt', 'pp', 'pt') + +experiments_labels = c( 'Non-S: Flat', 'Non-S: Tilted', + 'Seasonal: Flat', 'Seasonal: Tilted') + +experiments_labels2 = c( 'Non-S: Flat', 'Non-S: Tilted', + 'Seasonal', 'Seasonal') + +runs = list( c(1:20) , + c(1:20) , + c(1:20) ) + +gens = 100 +pop = 100 + +#### CHANGE THE PARAMETERS HERE #### + +sig = 0.05 +line_size = 30 +show_markers = FALSE +show_legends = FALSE +experiments_type_colors = c( '#00e700' , '#009900', '#ffb83b', '#fd8a3b') # DARK: light green,dark green, light red, dark red + +measures_names = c( + 'displacement_velocity_hill', + 'head_balance', + 'contacts', + 'displacement_velocity', + 'branching', + 'branching_modules_count', + 'limbs', + 'extremities', + 'length_of_limbs', + 'extensiveness', + 'coverage', + 'joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'proportion', + 'width', + 'height', + 'absolute_size', + 'sensors', + 'symmetry', + 'avg_period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'fitness', + 'cons_fitness' +) + +# add proper labels soon... +measures_labels = c( + 'Speed (cm/s)', + 'Balance', + 'Contacts', + 'displacement_velocity', + 'Branching', + 'branching_modules_count', + 'Rel number of limbs', + 'extremities', + 'Rel. Length of Limbs', + 'extensiveness', + 'coverage', + 'Rel. Number of Joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'Proportion', + 'width', + 'height', + 'Size', + 'sensors', + 'Symmetry', + 'Average Period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'Fitness', + 'Number of slaves' +) + + +measures_snapshots_all = NULL + +for (exp in 1:length(experiments_type)) +{ + for(run in runs[[exp]]) + { + for (env in 1:length(environments[[exp]])) + { + input_directory <- paste(base_directory, '/', + experiments_type[exp], '_',sep='') + + measures = read.table(paste(input_directory, run, '/data_fullevolution/', + environments[[exp]][env], "/all_measures.tsv", sep=''), header = TRUE, fill=TRUE) + for( m in 1:length(measures_names)) + { + measures[measures_names[m]] = as.numeric(as.character(measures[[measures_names[m]]])) + } + + snapshots = read.table(paste(input_directory, run,'/selectedpop_', + environments[[exp]][env],"/snapshots_ids.tsv", sep=''), header = TRUE) + + measures_snapshots = sqldf('select * from snapshots inner join measures using(robot_id) order by generation') + + measures_snapshots$run = run + measures_snapshots$displacement_velocity_hill = measures_snapshots$displacement_velocity_hill*100 + measures_snapshots$run = as.factor(measures_snapshots$run) + measures_snapshots$method = paste(experiments_type[exp], environments[[exp]][env],sep='_') + + if ( is.null(measures_snapshots_all)){ + measures_snapshots_all = measures_snapshots + }else{ + measures_snapshots_all = rbind(measures_snapshots_all, measures_snapshots) + } + } + } +} + + +fail_test = sqldf(paste("select method,run,generation,count(*) as c from measures_snapshots_all group by 1,2,3 having c<",gens," order by 4")) + + +measures_snapshots_all = sqldf("select * from measures_snapshots_all where generation<=99 and cons_fitness IS NOT NULL") + + + + +# densities + +measures_snapshots_all_densities = sqldf(paste("select * from measures_snapshots_all where generation=99 + and method !='", methods[length(methods)],"'",sep='' )) + +measures_names_densities = c('length_of_limbs','proportion', 'absolute_size','head_balance','joints', 'limbs') +measures_labels_densities = c('Rel. Length of Limbs','Proportion', 'Size','Balance','Rel. Number of Joints', 'Rel. Number of Limbs') + +for (i in 1:length(measures_names_densities)) +{ + + for (j in 1:length(measures_names_densities)) + { + + if(i != j) + { + + graph <- ggplot(measures_snapshots_all_densities, aes_string(x=measures_names_densities[j], y= measures_names_densities[i]))+ + geom_density_2d(aes(colour = method ), alpha=0.7, size=3 )+ + scale_color_manual(values = c(experiments_type_colors[4:4], experiments_type_colors[1:2]) )+ + labs( x = measures_labels_densities[j], y= measures_labels_densities[i] )+ + theme(legend.position="bottom" , axis.text=element_text(size=21),axis.title=element_text(size=22), + plot.subtitle=element_text(size=25 )) + + coord_cartesian(ylim = c(0, 1), xlim = c(0, 1)) + ggsave(paste( output_directory ,'/density_',measures_names_densities[i],'_', measures_names_densities[j],'.png', sep=''), graph , + device='png', height = 6, width = 6) + } + + } +} + + + +measures_averages_gens_1 = list() +measures_averages_gens_2 = list() + +measures_ini = list() +measures_fin = list() + +for (met in 1:length(methods)) +{ + + measures_aux = c() + query ='select run, generation' + for (i in 1:length(measures_names)) + { + query = paste(query,', avg(',measures_names[i],') as ', methods[met], '_',measures_names[i],'_avg', sep='') + } + query = paste(query,' from measures_snapshots_all + where method="', methods[met],'" group by run, generation', sep='') + + temp = sqldf(query) + + measures_averages_gens_1[[met]] = temp + + temp = measures_averages_gens_1[[met]] + + temp$generation = as.numeric(temp$generation) + + measures_ini[[met]] = sqldf(paste("select * from temp where generation=0")) + measures_fin[[met]] = sqldf(paste("select * from temp where generation=",gens-1)) + query = 'select generation' + for (i in 1:length(measures_names)) + { + # later renames vars _avg_SUMMARY, just to make it in the same style as the quantile variables + query = paste(query,', avg(', methods[met], '_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_avg', sep='') + query = paste(query,', max(', methods[met],'_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_max', sep='') + query = paste(query,', stdev(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_stdev', sep='') + query = paste(query,', median(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_median', sep='') + + measures_aux = c(measures_aux, paste(methods[met],'_',measures_names[i],'_avg', sep='') ) + } + query = paste(query,' from temp group by generation', sep="") + + temp2 = sqldf(query) + + p <- c(0.25, 0.75) + p_names <- map_chr(p, ~paste0('Q',.x*100, sep="")) + p_funs <- map(p, ~partial(quantile, probs = .x, na.rm = TRUE)) %>% + set_names(nm = p_names) + + quantiles = data.frame(temp %>% + group_by(generation) %>% + summarize_at(vars(measures_aux), funs(!!!p_funs)) ) + + measures_averages_gens_2[[met]] = sqldf('select * from temp2 inner join quantiles using (generation)') + +} + + +for (met in 1:length(methods)) +{ + if(met==1){ + measures_averages_gens = measures_averages_gens_2[[1]] + }else{ + measures_averages_gens = merge(measures_averages_gens, measures_averages_gens_2[[met]], all=TRUE, by = "generation") + } +} + +file <-file(paste(output_directory,'/trends.txt',sep=''), open="w") + +#tests trends in curves and difference between ini and fin generations + + +# ini VS fin +array_wilcoxon = list() +array_wilcoxon2 = list() + +# curve +array_mann = list() + + +for (m in 1:length(methods)) +{ + + array_wilcoxon[[m]] = list() + array_mann[[m]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(experiments_type[m],measures_names[i],'ini avg ',as.character( + mean(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon[[m]][[i]] = wilcox.test(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'iniVSfin',measures_names[i],'wilcox p: ',as.character(round(array_wilcoxon[[m]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'iniVSfin',measures_names[i],'wilcox est: ',as.character(round(array_wilcoxon[[m]][[i]]$statistic,4)), sep=' ') + + ), file) + + + #tests trends + array_mann[[m]][[i]] = mk.test(c(array(measures_averages_gens_2[[m]][paste(methods[m],"_",measures_names[i],'_median',sep='')]) )[[1]], + continuity = TRUE) + + + writeLines(c( + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median p', as.character(round(array_mann[[m]][[i]]$p.value,4)),sep=' '), + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median s', as.character(round(array_mann[[m]][[i]]$statistic,4)),sep=' ') + ), file) + + } + +} + + + +# tests final generation among experiments_type + +aux_m = length(methods) + +if (aux_m>1) +{ + + # fins + array_wilcoxon2[[1]] = list() + array_wilcoxon2[[2]] = list() + + aux_m = aux_m -1 + count_pairs = 0 + for(m in 1:aux_m) + { + aux = m+1 + for(m2 in aux:length(methods)) + { + + count_pairs = count_pairs+1 + array_wilcoxon2[[1]][[count_pairs]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + writeLines(paste(methods[m2],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon2[[1]][[count_pairs]][[i]] = wilcox.test(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'VS',methods,measures_names[i],'fin avg wilcox p: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'VS',methods[m2],measures_names[i],'fin avg wilcox est: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$statistic,4)), sep=' ') + + ), file) + + } + + + array_wilcoxon2[[2]][[count_pairs]] = paste(initials[m],initials[m2],sep='') + + } + } + +} + +close(file) + + + +# plots measures + +for (type_summary in c('means','quants')) +{ + + + for (i in 1:length(measures_names)) + { + tests1 = '' + tests2 = '' + tests3 = '' + break_aux = 0 + + graph <- ggplot(data=measures_averages_gens, aes(x=generation)) + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg','-',methods[m],'_',measures_names[i],'_stdev',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg','+',methods[m],'_',measures_names[i],'_stdev',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + }else + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg_Q25',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg_Q75',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + } + } + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep=''), colour=shQuote(experiments_labels[m]) ), size=2) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep='') ),size=2, color = experiments_type_colors[m]) + } + + }else{ + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') , colour=shQuote(experiments_labels[m]) ),size=2 ) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') ),size=2, color = experiments_type_colors[m] ) + } + } + + if (length(array_mann)>0) + { + if (length(array_mann[[m]])>0) + { + if(!is.na(array_mann[[m]][[i]]$p.value)) + { + if(array_mann[[m]][[i]]$p.value<=sig) + { + if(array_mann[[m]][[i]]$statistic>0){ direction = "/ "} else { direction = "\\ "} + tests1 = paste(tests1, initials[m],direction,sep="") + } + } + } + } + } + + if (length(array_wilcoxon[[m]])>0) + { + for(m in 1:length(methods)) + { + if(!is.na(array_wilcoxon[[m]][[i]]$p.value)) + { + if(array_wilcoxon[[m]][[i]]$p.value<=sig) + { + tests2 = paste(tests2, initials[m],'C ', sep='') + } + } + } + } + + if (length(array_wilcoxon2)>0) + { + for(p in 1:length(array_wilcoxon2[[1]])) + { + if (length(array_wilcoxon2[[1]][[p]])>0) + { + if(!is.na(array_wilcoxon2[[1]][[p]][[i]]$p.value)) + { + if(array_wilcoxon2[[1]][[p]][[i]]$p.value<=sig) + { + if(nchar(tests3)>line_size && break_aux == 0){ + tests3 = paste(tests3, '\n') + break_aux = 1 + } + tests3 = paste(tests3, array_wilcoxon2[[2]][[p]],'D ',sep='') + } + } + } + } + } + + max_y = 0 + + graph = graph + labs( y=measures_labels[i], x="Generation") + if (max_y>0) { + graph = graph + coord_cartesian(ylim = c(min_y, max_y)) + } + + if(show_markers == TRUE){ + graph = graph + labs( y=measures_labels[i], x="Generation", subtitle = paste(tests1,'\n', tests2, '\n', tests3, sep='')) + } + graph = graph + theme(legend.position="bottom" , legend.text=element_text(size=20), axis.text=element_text(size=30),axis.title=element_text(size=39), + plot.subtitle=element_text(size=25 )) + + ggsave(paste( output_directory,'/',type_summary,'_' ,measures_names[i],'_generations.pdf', sep=''), graph , device='pdf', height = 10, width = 10) + } + +} + + + + +for (i in 1:length(measures_names)) +{ + + all_final_values = data.frame() + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') { fin=length(methods) + }else{ fin=length(methods)-1 } + + for (exp in 1:fin) + { + temp = data.frame( c(measures_fin[[exp]][paste(methods[exp],'_',measures_names[i],'_avg', sep='')])) + colnames(temp) <- 'values' + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') + { temp$type = experiments_labels[exp] + }else{ temp$type = experiments_labels2[exp] } + + all_final_values = rbind(all_final_values, temp) + } + + + max_y = max(all_final_values$values) * 1.1 + + g1 <- ggplot(data=all_final_values, aes(x= type , y=values, color=type )) + + geom_boxplot(position = position_dodge(width=0.9),lwd=2, outlier.size = 4) + #notch=TRUE + labs( x="Environment", y=measures_labels[i], title="Final generation") + + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') + { g1 = g1 + scale_color_manual(values=experiments_type_colors) + }else{ g1 = g1 + scale_color_manual(values= c(experiments_type_colors[1:2],experiments_type_colors[4:4])) } + + g1 = g1 + theme(legend.position="none" , text = element_text(size=45) , + plot.title=element_text(size=40), axis.text=element_text(size=45), + axis.title=element_text(size=50), + axis.text.x = element_text(angle = 20, hjust = 1 ), + plot.margin=margin(t = 0.5, r = 0.5, b = 0.5, l = 0.9, unit = "cm") + )+ + stat_summary(fun.y = mean, geom="point" ,shape = 16, size=11) + + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') { comps = list(c("Non-S: Flat", "Seasonal: Flat"), + c("Non-S: Tilted", "Seasonal: Tilted"), + c("Non-S: Tilted", "Non-S: Flat"), + c("Seasonal: Tilted", "Seasonal: Flat")) + aux_width=13 + }else{ comps = list(c("Non-S: Flat", "Non-S: Tilted"), + c("Non-S: Flat", "Seasonal"), + c("Non-S: Tilted", "Seasonal")) + aux_width=10 + } + + + g1 = g1 + geom_signif( test="wilcox.test", size=2, textsize=22, + comparisons = comps, + map_signif_level=c("***"=0.001,"**"=0.01, "*"=0.05) ) + if (max_y>0) { + g1 = g1 + coord_cartesian(ylim = c(0, max_y)) + } + + ggsave(paste(output_directory,"/",measures_names[i],"_boxes.pdf",sep = ""), g1, device = "pdf", height=18, width = aux_width) + +} + diff --git a/experiments/karines_experiments/summary_measures_journal2_lava.R b/experiments/karines_experiments/summary_measures_journal2_lava.R new file mode 100644 index 0000000000..58ebe2efa3 --- /dev/null +++ b/experiments/karines_experiments/summary_measures_journal2_lava.R @@ -0,0 +1,566 @@ + library(ggplot2) + library(sqldf) + library(plyr) + library(dplyr) + library(trend) + library(purrr) + library(ggsignif) + + base_directory <-paste('data', sep='') + +analysis = 'analysis_journal2_lava' + +output_directory = paste(base_directory,'/',analysis ,sep='') + +#### CHANGE THE PARAMETERS HERE #### + + +experiments_type = c( 'baseline2_lava', 'plastic2_lava') + +environments = list(c( 'plane','lava'), c( 'plane','lava') ) + +methods = c() +for (exp in 1:length(experiments_type)) +{ + for (env in 1:length(environments[[exp]])) + { + methods = c(methods, paste(experiments_type[exp], environments[[exp]][env], sep='_')) + } +} + +initials = c( 'bp', 'bt', 'pp', 'pt') + +experiments_labels = c( 'Baseline: Flat', 'Baseline: Lava', + 'Plastic: Flat', 'Plastic: Lava') + +experiments_labels2 = c( 'Baseline', 'Baseline', + 'Plastic: Flat', 'Plastic: Lava') + + runs = list( c(1:20), c(1:20) ) + + gens = 10#100 + pop = 100 + + #### CHANGE THE PARAMETERS HERE #### + + sig = 0.05 + line_size = 30 + show_markers = TRUE#FALSE + show_legends = FALSE + experiments_type_colors = c( '#00e700' , '#009900', '#ffb83b', '#fd8a3b') # DARK: light green,dark green, light red, dark red + + measures_names = c( + 'displacement_velocity_hill', + 'head_balance', + 'contacts', + 'displacement_velocity', + 'branching', + 'branching_modules_count', + 'limbs', + 'extremities', + 'length_of_limbs', + 'extensiveness', + 'coverage', + 'joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'proportion', + 'width', + 'height', + 'absolute_size', + 'sensors', + 'symmetry', + 'avg_period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'fitness', + 'cons_fitness' + ) + + # add proper labels soon... + measures_labels = c( + 'Speed (cm/s)', + 'Balance', + 'Contacts', + 'displacement_velocity', + 'Branching', + 'branching_modules_count', + 'Rel number of limbs', + 'extremities', + 'Rel. Length of Limbs', + 'extensiveness', + 'coverage', + 'Rel. Number of Joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'Proportion', + 'width', + 'height', + 'Size', + 'sensors', + 'Symmetry', + 'Average Period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'Fitness', + 'Number of slaves' + ) + + + measures_snapshots_all = NULL + + for (exp in 1:length(experiments_type)) + { + for(run in runs[[exp]]) + { + for (env in 1:length(environments[[exp]])) + { + input_directory <- paste(base_directory, '/', + experiments_type[exp], '_',sep='') + + measures = read.table(paste(input_directory, run, '/data_fullevolution/', + environments[[exp]][env], "/all_measures.tsv", sep=''), header = TRUE, fill=TRUE) + for( m in 1:length(measures_names)) + { + measures[measures_names[m]] = as.numeric(as.character(measures[[measures_names[m]]])) + } + + snapshots = read.table(paste(input_directory, run,'/selectedpop_', + environments[[exp]][env],"/snapshots_ids.tsv", sep=''), header = TRUE) + + measures_snapshots = sqldf('select * from snapshots inner join measures using(robot_id) order by generation') + + measures_snapshots$run = run + measures_snapshots$displacement_velocity_hill = measures_snapshots$displacement_velocity_hill*100 + measures_snapshots$run = as.factor(measures_snapshots$run) + measures_snapshots$method = paste(experiments_type[exp], environments[[exp]][env],sep='_') + + if ( is.null(measures_snapshots_all)){ + measures_snapshots_all = measures_snapshots + }else{ + measures_snapshots_all = rbind(measures_snapshots_all, measures_snapshots) + } + } + } + } + + + fail_test = sqldf(paste("select method,run,generation,count(*) as c from measures_snapshots_all group by 1,2,3 having c<",gens," order by 4")) + + + measures_snapshots_all = sqldf("select * from measures_snapshots_all where cons_fitness IS NOT NULL") + + + # densities + + measures_snapshots_all_densities = sqldf(paste("select * from measures_snapshots_all where generation=42 + and method !='", methods[length(methods)],"'",sep='' )) #99!!!! + + measures_names_densities = c('length_of_limbs','proportion', 'absolute_size','head_balance','joints', 'limbs') + measures_labels_densities = c('Rel. Length of Limbs','Proportion', 'Size','Balance','Rel. Number of Joints', 'Rel. Number of Limbs') + + for (i in 1:length(measures_names_densities)) + { + + for (j in 1:length(measures_names_densities)) + { + + if(i != j) + { + + graph <- ggplot(measures_snapshots_all_densities, aes_string(x=measures_names_densities[j], y= measures_names_densities[i]))+ + geom_density_2d(aes(colour = method ), alpha=0.7, size=3 )+ + scale_color_manual(values = experiments_type_colors[-1] )+ + labs( x = measures_labels_densities[j], y= measures_labels_densities[i] )+ + theme(legend.position="bottom" , axis.text=element_text(size=21),axis.title=element_text(size=22), + plot.subtitle=element_text(size=25 )) + + coord_cartesian(ylim = c(0, 1), xlim = c(0, 1)) + ggsave(paste( output_directory ,'/density_',measures_names_densities[i],'_', measures_names_densities[j],'.png', sep=''), graph , + device='png', height = 6, width = 6) + } + + } + } + + + + measures_averages_gens_1 = list() + measures_averages_gens_2 = list() + + measures_ini = list() + measures_fin = list() + + for (met in 1:length(methods)) + { + + measures_aux = c() + query ='select run, generation' + for (i in 1:length(measures_names)) + { + query = paste(query,', avg(',measures_names[i],') as ', methods[met], '_',measures_names[i],'_avg', sep='') + } + query = paste(query,' from measures_snapshots_all + where method="', methods[met],'" group by run, generation', sep='') + + temp = sqldf(query) + + measures_averages_gens_1[[met]] = temp + + temp = measures_averages_gens_1[[met]] + + temp$generation = as.numeric(temp$generation) + + measures_ini[[met]] = sqldf(paste("select * from temp where generation=0")) + measures_fin[[met]] = sqldf(paste("select * from temp where generation=",gens-1)) + query = 'select generation' + for (i in 1:length(measures_names)) + { + # later renames vars _avg_SUMMARY, just to make it in the same style as the quantile variables + query = paste(query,', avg(', methods[met], '_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_avg', sep='') + query = paste(query,', max(', methods[met],'_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_max', sep='') + query = paste(query,', stdev(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_stdev', sep='') + query = paste(query,', median(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_median', sep='') + + measures_aux = c(measures_aux, paste(methods[met],'_',measures_names[i],'_avg', sep='') ) + } + query = paste(query,' from temp group by generation', sep="") + + temp2 = sqldf(query) + + p <- c(0.25, 0.75) + p_names <- map_chr(p, ~paste0('Q',.x*100, sep="")) + p_funs <- map(p, ~partial(quantile, probs = .x, na.rm = TRUE)) %>% + set_names(nm = p_names) + + quantiles = data.frame(temp %>% + group_by(generation) %>% + summarize_at(vars(measures_aux), funs(!!!p_funs)) ) + + measures_averages_gens_2[[met]] = sqldf('select * from temp2 inner join quantiles using (generation)') + + } + + + for (met in 1:length(methods)) + { + if(met==1){ + measures_averages_gens = measures_averages_gens_2[[1]] + }else{ + measures_averages_gens = merge(measures_averages_gens, measures_averages_gens_2[[met]], by = "generation") + } + } + + file <-file(paste(output_directory,'/trends.txt',sep=''), open="w") + + #tests trends in curves and difference between ini and fin generations + + + # ini VS fin + array_wilcoxon = list() + array_wilcoxon2 = list() + + # curve + array_mann = list() + + + for (m in 1:length(methods)) + { + + array_wilcoxon[[m]] = list() + array_mann[[m]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(experiments_type[m],measures_names[i],'ini avg ',as.character( + mean(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon[[m]][[i]] = wilcox.test(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'iniVSfin',measures_names[i],'wilcox p: ',as.character(round(array_wilcoxon[[m]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'iniVSfin',measures_names[i],'wilcox est: ',as.character(round(array_wilcoxon[[m]][[i]]$statistic,4)), sep=' ') + + ), file) + + + #tests trends + array_mann[[m]][[i]] = mk.test(c(array(measures_averages_gens_2[[m]][paste(methods[m],"_",measures_names[i],'_median',sep='')]) )[[1]], + continuity = TRUE) + + + writeLines(c( + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median p', as.character(round(array_mann[[m]][[i]]$p.value,4)),sep=' '), + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median s', as.character(round(array_mann[[m]][[i]]$statistic,4)),sep=' ') + ), file) + + } + + } + + + + # tests final generation among experiments_type + + aux_m = length(methods) + + if (aux_m>1) + { + + # fins + array_wilcoxon2[[1]] = list() + array_wilcoxon2[[2]] = list() + + aux_m = aux_m -1 + count_pairs = 0 + for(m in 1:aux_m) + { + aux = m+1 + for(m2 in aux:length(methods)) + { + + count_pairs = count_pairs+1 + array_wilcoxon2[[1]][[count_pairs]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + writeLines(paste(methods[m2],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon2[[1]][[count_pairs]][[i]] = wilcox.test(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'VS',methods,measures_names[i],'fin avg wilcox p: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'VS',methods[m2],measures_names[i],'fin avg wilcox est: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$statistic,4)), sep=' ') + + ), file) + + } + + + array_wilcoxon2[[2]][[count_pairs]] = paste(initials[m],initials[m2],sep='') + + } + } + + } + + close(file) + + # plots measures + + for (type_summary in c('means','quants')) + { + + + for (i in 1:length(measures_names)) + { + tests1 = '' + tests2 = '' + tests3 = '' + break_aux = 0 + + graph <- ggplot(data=measures_averages_gens, aes(x=generation)) + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg','-',methods[m],'_',measures_names[i],'_stdev',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg','+',methods[m],'_',measures_names[i],'_stdev',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + }else + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg_Q25',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg_Q75',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + } + } + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep=''), colour=shQuote(experiments_labels[m]) ), size=2) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep='') ),size=2, color = experiments_type_colors[m]) + } + + }else{ + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') , colour=shQuote(experiments_labels[m]) ),size=2 ) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') ),size=2, color = experiments_type_colors[m] ) + } + } + + if (length(array_mann)>0) + { + if (length(array_mann[[m]])>0) + { + if(!is.na(array_mann[[m]][[i]]$p.value)) + { + if(array_mann[[m]][[i]]$p.value<=sig) + { + if(array_mann[[m]][[i]]$statistic>0){ direction = "/ "} else { direction = "\\ "} + tests1 = paste(tests1, initials[m],direction,sep="") + } + } + } + } + } + + if (length(array_wilcoxon[[m]])>0) + { + for(m in 1:length(methods)) + { + if(!is.na(array_wilcoxon[[m]][[i]]$p.value)) + { + if(array_wilcoxon[[m]][[i]]$p.value<=sig) + { + tests2 = paste(tests2, initials[m],'C ', sep='') + } + } + } + } + + if (length(array_wilcoxon2)>0) + { + for(p in 1:length(array_wilcoxon2[[1]])) + { + if (length(array_wilcoxon2[[1]][[p]])>0) + { + if(!is.na(array_wilcoxon2[[1]][[p]][[i]]$p.value)) + { + if(array_wilcoxon2[[1]][[p]][[i]]$p.value<=sig) + { + if(nchar(tests3)>line_size && break_aux == 0){ + tests3 = paste(tests3, '\n') + break_aux = 1 + } + tests3 = paste(tests3, array_wilcoxon2[[2]][[p]],'D ',sep='') + } + } + } + } + } + + max_y = 0 + min_y = 0 + if(measures_names[i]=='displacement_velocity_hill' ){ + max_y = 3 + min_y = -0.5 + } + + graph = graph + labs( y=measures_labels[i], x="Generation") + if (max_y>0) { + graph = graph + coord_cartesian(ylim = c(min_y, max_y)) + } + + if(show_markers == TRUE){ + graph = graph + labs( y=measures_labels[i], x="Generation", subtitle = paste(tests1,'\n', tests2, '\n', tests3, sep='')) + } + graph = graph + theme(legend.position="bottom" , legend.text=element_text(size=20), axis.text=element_text(size=30),axis.title=element_text(size=39), + plot.subtitle=element_text(size=25 )) + + ggsave(paste( output_directory,'/',type_summary,'_' ,measures_names[i],'_generations.pdf', sep=''), graph , device='pdf', height = 10, width = 10) + } + + } + + + + + for (i in 1:length(measures_names)) + { + + all_final_values = data.frame() + if (measures_names[i] == 'displacement_velocity_hill') { ini=1 + }else{ ini=2 } + + for (exp in ini:length(methods)) + { + temp = data.frame( c(measures_fin[[exp]][paste(methods[exp],'_',measures_names[i],'_avg', sep='')])) + colnames(temp) <- 'values' + if (measures_names[i] == 'displacement_velocity_hill') { temp$type = experiments_labels[exp] + }else{ temp$type = experiments_labels2[exp] } + + all_final_values = rbind(all_final_values, temp) + } + + + max_y = 0 + # min_y = -0.5 + #if(measures_names[i]=='displacement_velocity_hill' ){ max_y = 3 } + + g1 <- ggplot(data=all_final_values, aes(x= type , y=values, color=type )) + + geom_boxplot(position = position_dodge(width=0.9),lwd=2, outlier.size = 4, notch=TRUE) + + labs( x="Environment", y=measures_labels[i], title="Final generation") + + if (measures_names[i] == 'displacement_velocity_hill') { g1 = g1 + scale_color_manual(values=experiments_type_colors) + }else{ g1 = g1 + scale_color_manual(values=experiments_type_colors[-1]) } + + g1 = g1 + theme(legend.position="none" , text = element_text(size=45) , + plot.title=element_text(size=40), axis.text=element_text(size=45), + axis.title=element_text(size=50), + axis.text.x = element_text(angle = 20, hjust = 1))+ + stat_summary(fun.y = mean, geom="point" ,shape = 16, size=11) + + if (measures_names[i] == 'displacement_velocity_hill') { comps = list(c("Baseline: Flat", "Plastic: Flat"), + c("Baseline: Lava", "Plastic: Lava")) + }else{ comps = list(c("Baseline", "Plastic: Flat"), + c("Baseline", "Plastic: Lava"), + c("Plastic: Flat", "Plastic: Lava")) } + + + g1 = g1 + geom_signif( test="wilcox.test", size=2, textsize=22, + comparisons = comps, + map_signif_level=c("***"=0.001,"**"=0.01, "*"=0.05) ) + if (max_y>0) { + g1 = g1 + coord_cartesian(ylim = c(0, max_y)) + } + + ggsave(paste(output_directory,"/",measures_names[i],"_boxes.pdf",sep = ""), g1, device = "pdf", height=18, width = 10) + + } + + \ No newline at end of file diff --git a/experiments/karines_experiments/summary_measures_journal2_tilted.R b/experiments/karines_experiments/summary_measures_journal2_tilted.R new file mode 100644 index 0000000000..b877ed6701 --- /dev/null +++ b/experiments/karines_experiments/summary_measures_journal2_tilted.R @@ -0,0 +1,561 @@ + library(ggplot2) + library(sqldf) + library(plyr) + library(dplyr) + library(trend) + library(purrr) + library(ggsignif) + + base_directory <-paste('data', sep='') + +analysis = 'analysis_journal2_tilted' + +output_directory = paste(base_directory,'/',analysis ,sep='') + +#### CHANGE THE PARAMETERS HERE #### + + +experiments_type = c( 'baseline2', 'plastic2') + +environments = list(c( 'plane','tilted5'), c( 'plane','tilted5') ) + +methods = c() +for (exp in 1:length(experiments_type)) +{ + for (env in 1:length(environments[[exp]])) + { + methods = c(methods, paste(experiments_type[exp], environments[[exp]][env], sep='_')) + } +} + +initials = c( 'bp', 'bt', 'pp', 'pt') + +experiments_labels = c( 'Baseline: Flat', 'Baseline: Tilted', + 'Plastic: Flat', 'Plastic: Tilted') + +experiments_labels2 = c( 'Baseline', 'Baseline', + 'Plastic: Flat', 'Plastic: Tilted') + + runs = list( c(1:20), c(1:20) ) + + gens = 100 + pop = 100 + + #### CHANGE THE PARAMETERS HERE #### + + sig = 0.05 + line_size = 30 + show_markers = TRUE#FALSE + show_legends = FALSE + experiments_type_colors = c( '#00e700' , '#009900', '#ffb83b', '#fd8a3b') # DARK: light green,dark green, light red, dark red + + measures_names = c( + 'displacement_velocity_hill', + 'head_balance', + 'contacts', + 'displacement_velocity', + 'branching', + 'branching_modules_count', + 'limbs', + 'extremities', + 'length_of_limbs', + 'extensiveness', + 'coverage', + 'joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'proportion', + 'width', + 'height', + 'absolute_size', + 'sensors', + 'symmetry', + 'avg_period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'fitness', + 'cons_fitness' + ) + + # add proper labels soon... + measures_labels = c( + 'Speed (cm/s)', + 'Balance', + 'Contacts', + 'displacement_velocity', + 'Branching', + 'branching_modules_count', + 'Rel number of limbs', + 'extremities', + 'Rel. Length of Limbs', + 'extensiveness', + 'coverage', + 'Rel. Number of Joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'Proportion', + 'width', + 'height', + 'Size', + 'sensors', + 'Symmetry', + 'Average Period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'Fitness', + 'Number of slaves' + ) + + + measures_snapshots_all = NULL + + for (exp in 1:length(experiments_type)) + { + for(run in runs[[exp]]) + { + for (env in 1:length(environments[[exp]])) + { + input_directory <- paste(base_directory, '/', + experiments_type[exp], '_',sep='') + + measures = read.table(paste(input_directory, run, '/data_fullevolution/', + environments[[exp]][env], "/all_measures.tsv", sep=''), header = TRUE, fill=TRUE) + for( m in 1:length(measures_names)) + { + measures[measures_names[m]] = as.numeric(as.character(measures[[measures_names[m]]])) + } + + snapshots = read.table(paste(input_directory, run,'/selectedpop_', + environments[[exp]][env],"/snapshots_ids.tsv", sep=''), header = TRUE) + + measures_snapshots = sqldf('select * from snapshots inner join measures using(robot_id) order by generation') + + measures_snapshots$run = run + measures_snapshots$displacement_velocity_hill = measures_snapshots$displacement_velocity_hill*100 + measures_snapshots$run = as.factor(measures_snapshots$run) + measures_snapshots$method = paste(experiments_type[exp], environments[[exp]][env],sep='_') + + if ( is.null(measures_snapshots_all)){ + measures_snapshots_all = measures_snapshots + }else{ + measures_snapshots_all = rbind(measures_snapshots_all, measures_snapshots) + } + } + } + } + + + fail_test = sqldf(paste("select method,run,generation,count(*) as c from measures_snapshots_all group by 1,2,3 having c<",gens," order by 4")) + + + measures_snapshots_all = sqldf("select * from measures_snapshots_all where generation<= 99 and cons_fitness IS NOT NULL") + + + + # densities + + measures_snapshots_all_densities = sqldf(paste("select * from measures_snapshots_all where generation=99 + and method !='", methods[1],"'",sep='' )) + + measures_names_densities = c('length_of_limbs','proportion', 'absolute_size','head_balance','joints', 'limbs') + measures_labels_densities = c('Rel. Length of Limbs','Proportion', 'Size','Balance','Rel. Number of Joints', 'Rel. Number of Limbs') + + for (i in 1:length(measures_names_densities)) + { + + for (j in 1:length(measures_names_densities)) + { + + if(i != j) + { + + graph <- ggplot(measures_snapshots_all_densities, aes_string(x=measures_names_densities[j], y= measures_names_densities[i]))+ + geom_density_2d(aes(colour = method ), alpha=0.7, size=3 )+ + scale_color_manual(values = experiments_type_colors[-1] )+ + labs( x = measures_labels_densities[j], y= measures_labels_densities[i] )+ + theme(legend.position="bottom" , axis.text=element_text(size=21),axis.title=element_text(size=22), + plot.subtitle=element_text(size=25 )) + + coord_cartesian(ylim = c(0, 1), xlim = c(0, 1)) + ggsave(paste( output_directory ,'/density_',measures_names_densities[i],'_', measures_names_densities[j],'.png', sep=''), graph , + device='png', height = 6, width = 6) + } + + } + } + + + + measures_averages_gens_1 = list() + measures_averages_gens_2 = list() + + measures_ini = list() + measures_fin = list() + + for (met in 1:length(methods)) + { + + measures_aux = c() + query ='select run, generation' + for (i in 1:length(measures_names)) + { + query = paste(query,', avg(',measures_names[i],') as ', methods[met], '_',measures_names[i],'_avg', sep='') + } + query = paste(query,' from measures_snapshots_all + where method="', methods[met],'" group by run, generation', sep='') + + temp = sqldf(query) + + measures_averages_gens_1[[met]] = temp + + temp = measures_averages_gens_1[[met]] + + temp$generation = as.numeric(temp$generation) + + measures_ini[[met]] = sqldf(paste("select * from temp where generation=0")) + measures_fin[[met]] = sqldf(paste("select * from temp where generation=",gens-1)) + query = 'select generation' + for (i in 1:length(measures_names)) + { + # later renames vars _avg_SUMMARY, just to make it in the same style as the quantile variables + query = paste(query,', avg(', methods[met], '_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_avg', sep='') + query = paste(query,', max(', methods[met],'_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_max', sep='') + query = paste(query,', stdev(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_stdev', sep='') + query = paste(query,', median(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_median', sep='') + + measures_aux = c(measures_aux, paste(methods[met],'_',measures_names[i],'_avg', sep='') ) + } + query = paste(query,' from temp group by generation', sep="") + + temp2 = sqldf(query) + + p <- c(0.25, 0.75) + p_names <- map_chr(p, ~paste0('Q',.x*100, sep="")) + p_funs <- map(p, ~partial(quantile, probs = .x, na.rm = TRUE)) %>% + set_names(nm = p_names) + + quantiles = data.frame(temp %>% + group_by(generation) %>% + summarize_at(vars(measures_aux), funs(!!!p_funs)) ) + + measures_averages_gens_2[[met]] = sqldf('select * from temp2 inner join quantiles using (generation)') + + } + + + for (met in 1:length(methods)) + { + if(met==1){ + measures_averages_gens = measures_averages_gens_2[[1]] + }else{ + measures_averages_gens = merge(measures_averages_gens, measures_averages_gens_2[[met]], by = "generation") + } + } + + file <-file(paste(output_directory,'/trends.txt',sep=''), open="w") + + #tests trends in curves and difference between ini and fin generations + + + # ini VS fin + array_wilcoxon = list() + array_wilcoxon2 = list() + + # curve + array_mann = list() + + + for (m in 1:length(methods)) + { + + array_wilcoxon[[m]] = list() + array_mann[[m]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(experiments_type[m],measures_names[i],'ini avg ',as.character( + mean(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon[[m]][[i]] = wilcox.test(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'iniVSfin',measures_names[i],'wilcox p: ',as.character(round(array_wilcoxon[[m]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'iniVSfin',measures_names[i],'wilcox est: ',as.character(round(array_wilcoxon[[m]][[i]]$statistic,4)), sep=' ') + + ), file) + + + #tests trends + array_mann[[m]][[i]] = mk.test(c(array(measures_averages_gens_2[[m]][paste(methods[m],"_",measures_names[i],'_median',sep='')]) )[[1]], + continuity = TRUE) + + + writeLines(c( + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median p', as.character(round(array_mann[[m]][[i]]$p.value,4)),sep=' '), + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median s', as.character(round(array_mann[[m]][[i]]$statistic,4)),sep=' ') + ), file) + + } + + } + + + + # tests final generation among experiments_type + + aux_m = length(methods) + + if (aux_m>1) + { + + # fins + array_wilcoxon2[[1]] = list() + array_wilcoxon2[[2]] = list() + + aux_m = aux_m -1 + count_pairs = 0 + for(m in 1:aux_m) + { + aux = m+1 + for(m2 in aux:length(methods)) + { + + count_pairs = count_pairs+1 + array_wilcoxon2[[1]][[count_pairs]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + writeLines(paste(methods[m2],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon2[[1]][[count_pairs]][[i]] = wilcox.test(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'VS',methods,measures_names[i],'fin avg wilcox p: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'VS',methods[m2],measures_names[i],'fin avg wilcox est: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$statistic,4)), sep=' ') + + ), file) + + } + + + array_wilcoxon2[[2]][[count_pairs]] = paste(initials[m],initials[m2],sep='') + + } + } + + } + + close(file) + + # plots measures + + for (type_summary in c('means','quants')) + { + + + for (i in 1:length(measures_names)) + { + tests1 = '' + tests2 = '' + tests3 = '' + break_aux = 0 + + graph <- ggplot(data=measures_averages_gens, aes(x=generation)) + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg','-',methods[m],'_',measures_names[i],'_stdev',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg','+',methods[m],'_',measures_names[i],'_stdev',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + }else + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg_Q25',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg_Q75',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + } + } + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep=''), colour=shQuote(experiments_labels[m]) ), size=2) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep='') ),size=2, color = experiments_type_colors[m]) + } + + }else{ + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') , colour=shQuote(experiments_labels[m]) ),size=2 ) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') ),size=2, color = experiments_type_colors[m] ) + } + } + + if (length(array_mann)>0) + { + if (length(array_mann[[m]])>0) + { + if(!is.na(array_mann[[m]][[i]]$p.value)) + { + if(array_mann[[m]][[i]]$p.value<=sig) + { + if(array_mann[[m]][[i]]$statistic>0){ direction = "/ "} else { direction = "\\ "} + tests1 = paste(tests1, initials[m],direction,sep="") + } + } + } + } + } + + if (length(array_wilcoxon[[m]])>0) + { + for(m in 1:length(methods)) + { + if(!is.na(array_wilcoxon[[m]][[i]]$p.value)) + { + if(array_wilcoxon[[m]][[i]]$p.value<=sig) + { + tests2 = paste(tests2, initials[m],'C ', sep='') + } + } + } + } + + if (length(array_wilcoxon2)>0) + { + for(p in 1:length(array_wilcoxon2[[1]])) + { + if (length(array_wilcoxon2[[1]][[p]])>0) + { + if(!is.na(array_wilcoxon2[[1]][[p]][[i]]$p.value)) + { + if(array_wilcoxon2[[1]][[p]][[i]]$p.value<=sig) + { + if(nchar(tests3)>line_size && break_aux == 0){ + tests3 = paste(tests3, '\n') + break_aux = 1 + } + tests3 = paste(tests3, array_wilcoxon2[[2]][[p]],'D ',sep='') + } + } + } + } + } + + max_y = 0 + min_y = 0 + + + graph = graph + labs( y=measures_labels[i], x="Generation") + if (max_y>0) { + graph = graph + coord_cartesian(ylim = c(min_y, max_y)) + } + + if(show_markers == TRUE){ + graph = graph + labs( y=measures_labels[i], x="Generation", subtitle = paste(tests1,'\n', tests2, '\n', tests3, sep='')) + } + graph = graph + theme(legend.position="bottom" , legend.text=element_text(size=20), axis.text=element_text(size=30),axis.title=element_text(size=39), + plot.subtitle=element_text(size=25 )) + + ggsave(paste( output_directory,'/',type_summary,'_' ,measures_names[i],'_generations.pdf', sep=''), graph , device='pdf', height = 10, width = 10) + } + + } + + + + + for (i in 1:length(measures_names)) + { + + all_final_values = data.frame() + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') { ini=1 + }else{ ini=2 } + + for (exp in ini:length(methods)) + { + temp = data.frame( c(measures_fin[[exp]][paste(methods[exp],'_',measures_names[i],'_avg', sep='')])) + colnames(temp) <- 'values' + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') { temp$type = experiments_labels[exp] + }else{ temp$type = experiments_labels2[exp] } + + all_final_values = rbind(all_final_values, temp) + } + + + max_y = max(all_final_values$values) * 1.1 + + g1 <- ggplot(data=all_final_values, aes(x= type , y=values, color=type )) + + geom_boxplot(position = position_dodge(width=0.9),lwd=2, outlier.size = 4) + + labs( x="Environment", y=measures_labels[i], title="Final generation") + + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') { g1 = g1 + scale_color_manual(values=experiments_type_colors) + }else{ g1 = g1 + scale_color_manual(values=experiments_type_colors[-1]) } + + g1 = g1 + theme(legend.position="none" , text = element_text(size=45) , + plot.title=element_text(size=40), axis.text=element_text(size=45), + axis.title=element_text(size=50), + axis.text.x = element_text(angle = 20, hjust = 1))+ + stat_summary(fun.y = mean, geom="point" ,shape = 16, size=11) + + if (measures_names[i] == 'displacement_velocity_hill' || measures_names[i] == 'head_balance') { comps = list(c("Baseline: Flat", "Plastic: Flat"), + c("Baseline: Tilted", "Plastic: Tilted")) + }else{ comps = list(c("Baseline", "Plastic: Flat"), + c("Baseline", "Plastic: Tilted"), + c("Plastic: Flat", "Plastic: Tilted")) } + + g1 = g1 + geom_signif( test="wilcox.test", size=2, textsize=22, + comparisons = comps, + map_signif_level=c("***"=0.001,"**"=0.01, "*"=0.05) ) + if (max_y>0) { + g1 = g1 + coord_cartesian(ylim = c(0, max_y)) + } + + ggsave(paste(output_directory,"/",measures_names[i],"_boxes.pdf",sep = ""), g1, device = "pdf", height=18, width = 10) + + } + + \ No newline at end of file diff --git a/experiments/karines_experiments/tilted.py b/experiments/karines_experiments/tilted.py new file mode 100755 index 0000000000..2f8700f0c2 --- /dev/null +++ b/experiments/karines_experiments/tilted.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 100 + population_size = 100 + offspring_size = 50 + front = None + + # environment world and z-start + environments = {'tilted5': 0.1} + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=False, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_tilted(robot_manager, robot): + #contacts = measures.contacts(robot_manager, robot) + #assert(contacts != 0) + return fitness.displacement_velocity_hill(robot_manager, robot) + + fitness_function = {'tilted5': fitness_function_tilted} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/experiments/karines_experiments/watch_best.py b/experiments/karines_experiments/watch_best.py new file mode 100755 index 0000000000..e0b2997bee --- /dev/null +++ b/experiments/karines_experiments/watch_best.py @@ -0,0 +1,146 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys +import time +import numpy as np + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 100 + population_size = 100 + offspring_size = 50 + front = 'slaves' + + # environment world and z-start + environments = {'plane': 0.03, + 'tilted5': 0.1 + } + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=True, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params #load_individual + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + + def fitness_function(robot_manager, robot): + #contacts = measures.contacts(robot_manager, robot) + #assert(contacts != 0) + return fitness.displacement_velocity_hill(robot_manager, robot) + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, 1) + + # choose a snapshot here. and the maximum best individuals you wish to watch + generation = 61#99 + max_best = 3#10 + await population.load_snapshot(generation) + + values = [] + for ind in population.individuals: + # define a criteria here + for environment in environments: + ind[environment].evaluated = False + values.append(ind[list(environments.keys())[-1]].consolidated_fitness) + #values.append(ind['plane'].phenotype._behavioural_measurements.displacement_velocity_hill) + + values = np.array(values) + + ini = len(population.individuals)-max_best + fin = len(population.individuals) + + population.individuals = np.array(population.individuals) + # highest + population.individuals = population.individuals[np.argsort(values)[ini:fin]] + # lowest + #population.individuals = population.individuals[np.argsort(values)[0:max_best]] + + for ind in population.individuals: + print(ind[list(environments.keys())[-1]].phenotype.id) + print('consolidated_fitness', ind[list(environments.keys())[-1]].consolidated_fitness) + + for environment in environments: + print(environment) + await population.evaluate(new_individuals=population.individuals, gen_num=generation, + environment=environment, type_simulation='watch') diff --git a/experiments/karines_experiments/watch_best_robots.py b/experiments/karines_experiments/watch_best_robots.py deleted file mode 100755 index 5f84e81562..0000000000 --- a/experiments/karines_experiments/watch_best_robots.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env python3 -import asyncio - -from pyrevolve import parser -from pyrevolve.evolution import fitness -from pyrevolve.evolution.selection import multiple_selection, tournament_selection -from pyrevolve.evolution.population import Population, PopulationConfig -from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management -from pyrevolve.experiment_management import ExperimentManagement -from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig -from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover -from pyrevolve.genotype.plasticoding.initialization import random_initialization -from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig -from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation -from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig -from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue -import numpy as np - - -async def run(): - """ - The main coroutine, which is started below. - """ - # Parse command line / file input arguments - - - genotype_conf = PlasticodingConfig( - max_structural_modules=100, - ) - - mutation_conf = MutationConfig( - mutation_prob=0.8, - genotype_conf=genotype_conf, - ) - - crossover_conf = CrossoverConfig( - crossover_prob=0.8, - ) - - settings = parser.parse_args() - experiment_management = ExperimentManagement(settings) - - population_conf = PopulationConfig( - population_size=100, - genotype_constructor=random_initialization, - genotype_conf=genotype_conf, - fitness_function=fitness.displacement_velocity_hill, - mutation_operator=standard_mutation, - mutation_conf=mutation_conf, - crossover_operator=standard_crossover, - crossover_conf=crossover_conf, - selection=lambda individuals: tournament_selection(individuals, 2), - parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection), - population_management=steady_state_population_management, - population_management_selector=tournament_selection, - evaluation_time=settings.evaluation_time, - offspring_size=50, - experiment_name=settings.experiment_name, - experiment_management=experiment_management, - ) - - settings = parser.parse_args() - simulator_queue = SimulatorQueue(settings.n_cores, settings, settings.port_start) - await simulator_queue.start() - - population = Population(population_conf, simulator_queue, 0) - - # choose a snapshot here. and the maximum best individuals you wish to watch - generation = 99 - max_best = 10 - await population.load_snapshot(generation) - - values = [] - for ind in population.individuals: - # define a criteria here - #values.append(ind.fitness) - values.append(ind.phenotype._behavioural_measurements.contacts) - values = np.array(values) - - ini = len(population.individuals)-max_best - fin = len(population.individuals) - - population.individuals = np.array(population.individuals) - population.individuals = population.individuals[np.argsort(values)[ini:fin]] - - for ind in population.individuals: - print(ind.phenotype.id) - print('contacts', ind.phenotype._behavioural_measurements.contacts) - - await population.evaluate(population.individuals, generation, 'watch') diff --git a/experiments/plasticoding_frontiers2020/.DS_Store b/experiments/plasticoding_frontiers2020/.DS_Store new file mode 100644 index 0000000000..5008ddfcf5 Binary files /dev/null and b/experiments/plasticoding_frontiers2020/.DS_Store differ diff --git a/experiments/plasticoding_frontiers2020/baseline_big.py b/experiments/plasticoding_frontiers2020/baseline_big.py new file mode 100644 index 0000000000..c40c150d36 --- /dev/null +++ b/experiments/plasticoding_frontiers2020/baseline_big.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys +import time + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 200 + population_size = 100 + offspring_size = 100 + front = 'slaves' + + # environment world and z-start + environments = {'plane': 0.03, + 'tilted5': 0.1 + } + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=False, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_plane(robot_manager, robot): + return fitness.displacement_velocity_hill(robot_manager, robot) + + fitness_function = {'plane': fitness_function_plane, + 'tilted5': fitness_function_plane} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/experiments/plasticoding_frontiers2020/bestrobots_summary_renders_journal2_tilted_big.r b/experiments/plasticoding_frontiers2020/bestrobots_summary_renders_journal2_tilted_big.r new file mode 100644 index 0000000000..eff7bed226 --- /dev/null +++ b/experiments/plasticoding_frontiers2020/bestrobots_summary_renders_journal2_tilted_big.r @@ -0,0 +1,86 @@ + +library(sqldf) +require('magick') + +##### change paths/labels/params here ##### + + +paths = c( 'baseline_big', 'plastic_big' ) + +environments = list( + c( 'plane','tilted5'), + c( 'plane','tilted5') +) + +base_directory <- paste('journal2/', sep='') + +runs = list( c(1:20), c(1:20) ) +gens = 200 +pop = 100 +num_top = 1 + +analysis = 'nonstatic/images' + +##### change paths/labels/params here ##### + +output_directory = paste(base_directory,analysis, sep='') + + +file <-file(paste(output_directory,'/best.txt',sep=''), open="w") + +# for each method +for(m in 1:length(paths)) +{ + # for each repetition + for (exp in runs[[m]]) + { + + input_directory1 <- paste(base_directory, paths[m],'_',exp, '/data_fullevolution/',environments[[m]][1],sep='') + input_directory2 <- paste(base_directory, paths[m],'_',exp, '/selectedpop_', sep='') + + ids_gens = data.frame() + list = strsplit(list.files(paste(input_directory2, environments[[m]][1],'/selectedpop_',gens-1, sep='')), ' ') + for(geno in 1:pop) + { + genome = data.frame(cbind(c(gens), c(strsplit(strsplit(list [[geno]],'_')[[1]][3],'.png')[[1]][1] ))) + names(genome)<-c('generation','robot_id') + ids_gens = rbind(ids_gens,genome) + } + + measures = read.table(paste(input_directory1,"/all_measures.tsv", sep=''), header = TRUE, fill=TRUE) + bests = sqldf(paste("select robot_id, cons_fitness from measures inner join ids_gens using (robot_id) order by cons_fitness desc limit",num_top)) + + for(b in 1:nrow(bests)) + { + + writeLines( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] ), file ) + print( paste(paths[m],'exp',exp,bests[b,'robot_id'] ,bests[b,'cons_fitness'] )) + + phenotype= bests[b,'robot_id'] + + for (env in 1:length(environments[[m]])) + { + patha = paste(input_directory2, environments[[m]][env], "/selectedpop_",gens-1,sep="") + + body <- list.files(patha, paste("body_robot_",phenotype,".png$",sep=""), full.names = TRUE) + body = image_read(body) + body = image_scale(body, "100x100") + body = image_border(image_background(body, "white"), "white", "5x5") + + if(b == 1 && env == 1) + { + bodies = body + }else{ + bodies = c(bodies, body) + } + } + } + + side_by_side = image_append(bodies, stack=F) + image_write(side_by_side, path = paste(output_directory,"/",paths[m],'_', environments[[m]][env], "_bodies_best_",exp,".png",sep=''), format = "png") + + } +} + + +close(file) diff --git a/experiments/plasticoding_frontiers2020/consolidate_experiments.py b/experiments/plasticoding_frontiers2020/consolidate_experiments.py new file mode 100644 index 0000000000..fbdd9dc878 --- /dev/null +++ b/experiments/plasticoding_frontiers2020/consolidate_experiments.py @@ -0,0 +1,140 @@ +import os +import math + +# set these variables according to your experiments # +dirpath = 'data/' +experiments_type = [ + 'flat_big', +'tilted_big', + 'plastic_big' +,'baseline_big' +] +environments = { + 'flat_big': ['plane'], +'tilted_big': ['tilted5'], + 'plastic_big': ['plane','tilted5'] + ,'baseline_big': ['plane','tilted5'] + } +runs = range(1, 21) + + +# set these variables according to your experiments # + +def build_headers(path1, path2): + + file_summary = open(path1 + "/all_measures.tsv", "w+") + file_summary.write('robot_id\t') + + behavior_headers = [] + behavior_headers.append('velocity') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('displacement_velocity') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('displacement_velocity_hill') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('head_balance') + file_summary.write(behavior_headers[-1]+'\t') + behavior_headers.append('contacts') + file_summary.write(behavior_headers[-1]+'\t') + # use this instead? but what if the guy is none? + # with open(path + '/data_fullevolution/descriptors/behavior_desc_robot_1.txt') as file: + # for line in file: + # measure, value = line.strip().split(' ') + # behavior_headers.append(measure) + # file_summary.write(measure+'\t') + + phenotype_headers = [] + with open(path1 + '/descriptors/phenotype_desc_robot_1.txt') as file: + for line in file: + measure, value = line.strip().split(' ') + phenotype_headers.append(measure) + file_summary.write(measure+'\t') + file_summary.write('fitness\t cons_fitness\n') + file_summary.close() + + file_summary = open(path2 + "/snapshots_ids.tsv", "w+") + file_summary.write('generation\trobot_id\n') + file_summary.close() + + return behavior_headers, phenotype_headers + +for exp in experiments_type: + + for env in environments[exp]: + + for run in runs: + + path0 = dirpath + str(exp) + '_' + str(run) + '/data_fullevolution' + path1 = dirpath + str(exp) + '_' + str(run) + '/data_fullevolution/' + env + path2 = dirpath + str(exp) + '_' + str(run) + '/selectedpop_' + env + + behavior_headers, phenotype_headers = build_headers(path1, path2) + + file_summary = open(path1 + "/all_measures.tsv", "a") + for r, d, f in os.walk(path0+'/consolidated_fitness'): + for file in f: + + robot_id = file.split('.')[0].split('_')[-1] + file_summary.write(robot_id+'\t') + + bh_file = path1+'/descriptors/behavior_desc_robot_'+robot_id+'.txt' + if os.path.isfile(bh_file): + with open(bh_file) as file: + for line in file: + if line != 'None': + measure, value = line.strip().split(' ') + file_summary.write(value+'\t') + else: + for h in behavior_headers: + file_summary.write('None'+'\t') + else: + for h in behavior_headers: + file_summary.write('None'+'\t') + + pt_file = path1+'/descriptors/phenotype_desc_robot_'+robot_id+'.txt' + if os.path.isfile(pt_file): + with open(pt_file) as file: + for line in file: + measure, value = line.strip().split(' ') + file_summary.write(value+'\t') + else: + for h in phenotype_headers: + file_summary.write('None'+'\t') + + f_file = open(path1+'/fitness/fitness_robot_'+robot_id+'.txt', 'r') + fitness = f_file.read() + file_summary.write(fitness + '\t') + + cf_file = open(path0+'/consolidated_fitness/consolidated_fitness_robot_'+robot_id+'.txt', 'r') + cons_fitness = cf_file.read() + file_summary.write(cons_fitness + '\n') + + num_files = len(f) + list_gens = [] + for r, d, f in os.walk(path2): + for dir in d: + if 'selectedpop' in dir: + gen = dir.split('_')[1] + list_gens.append(int(gen)) + list_gens.sort() + if len(list_gens)>0: + gen = list_gens[-1] + else: + gen = -1 + print(exp, run, num_files, gen, num_files-(gen*100+100)) + + file_summary.close() + + file_summary = open(path2 + "/snapshots_ids.tsv", "a") + for r, d, f in os.walk(path2): + for dir in d: + if 'selectedpop' in dir: + gen = dir.split('_')[1] + for r2, d2, f2 in os.walk(path2 + '/selectedpop_' + str(gen)): + for file in f2: + if 'body' in file: + id = file.split('.')[0].split('_')[-1] + file_summary.write(gen+'\t'+id+'\n') + + file_summary.close() + diff --git a/experiments/karines_experiments/manager_pop.py b/experiments/plasticoding_frontiers2020/flat_big.py old mode 100755 new mode 100644 similarity index 71% rename from experiments/karines_experiments/manager_pop.py rename to experiments/plasticoding_frontiers2020/flat_big.py index 2c82914acd..35369c12e5 --- a/experiments/karines_experiments/manager_pop.py +++ b/experiments/plasticoding_frontiers2020/flat_big.py @@ -15,8 +15,9 @@ from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig from pyrevolve.tol.manage import measures from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue from pyrevolve.custom_logging.logger import logger - +import sys async def run(): """ @@ -24,12 +25,17 @@ async def run(): """ # experiment params # - num_generations = 100 + num_generations = 200 population_size = 100 - offspring_size = 50 + offspring_size = 100 + front = None + + # environment world and z-start + environments = {'plane': 0.03} genotype_conf = PlasticodingConfig( - max_structural_modules=100, + max_structural_modules=15, + plastic=False, ) mutation_conf = MutationConfig( @@ -44,13 +50,14 @@ async def run(): # Parse command line / file input arguments settings = parser.parse_args() - experiment_management = ExperimentManagement(settings) + experiment_management = ExperimentManagement(settings, environments) do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) if do_recovery: - gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, offspring_size) + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) if gen_num == num_generations-1: logger.info('Experiment is already complete.') @@ -59,11 +66,11 @@ async def run(): gen_num = 0 next_robot_id = 1 - def fitness_function(robot_manager, robot): - contacts = measures.contacts(robot_manager, robot) - assert(contacts != 0) + def fitness_function_plane(robot_manager, robot): return fitness.displacement_velocity_hill(robot_manager, robot) + fitness_function = {'plane': fitness_function_plane} + population_conf = PopulationConfig( population_size=population_size, genotype_constructor=random_initialization, @@ -73,27 +80,51 @@ def fitness_function(robot_manager, robot): mutation_conf=mutation_conf, crossover_operator=standard_crossover, crossover_conf=crossover_conf, - selection=lambda individuals: tournament_selection(individuals, 2), - parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection), + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), population_management=steady_state_population_management, population_management_selector=tournament_selection, evaluation_time=settings.evaluation_time, offspring_size=offspring_size, experiment_name=settings.experiment_name, experiment_management=experiment_management, + environments=environments, + front=front ) settings = parser.parse_args() - simulator_queue = SimulatorQueue(settings.n_cores, settings, settings.port_start) - await simulator_queue.start() - population = Population(population_conf, simulator_queue, next_robot_id) + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) if do_recovery: - # loading a previous state of the experiment - await population.load_snapshot(gen_num) + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + if has_offspring: individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) gen_num += 1 diff --git a/experiments/plasticoding_frontiers2020/plastic_big.py b/experiments/plasticoding_frontiers2020/plastic_big.py new file mode 100644 index 0000000000..927a9e1cb5 --- /dev/null +++ b/experiments/plasticoding_frontiers2020/plastic_big.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys +import time + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 200 + population_size = 100 + offspring_size = 100 + front = 'slaves' + + # environment world and z-start + environments = {'plane': 0.03, + 'tilted5': 0.1 + } + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=True, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_plane(robot_manager, robot): + return fitness.displacement_velocity_hill(robot_manager, robot) + + fitness_function = {'plane': fitness_function_plane, + 'tilted5': fitness_function_plane} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/experiments/plasticoding_frontiers2020/run-experiments b/experiments/plasticoding_frontiers2020/run-experiments new file mode 100644 index 0000000000..a48cea1da7 --- /dev/null +++ b/experiments/plasticoding_frontiers2020/run-experiments @@ -0,0 +1,44 @@ + #!/bin/bash + + +while true + do + for i in {1..20}; do + ./revolve.py --experiment-name karines_experiments/data/baseline_big_$i --run $i --manager experiments/karines_experiments/baseline_big.py --n-cores 4 --port-start 11000 --evaluation-time 50; + + sleep 5s + done +done + + +while true + do + for i in {1..20}; do + ./revolve.py --experiment-name karines_experiments/data/plastic_big_$i --run $i --manager experiments/karines_experiments/plastic_big.py --n-cores 4 --port-start 11141 --evaluation-time 50; + + sleep 5s + done +done + + while true + do + for i in {1..20}; do + ./revolve.py --experiment-name karines_experiments/data/flat_big_$i --run $i --manager experiments/karines_experiments/flat_big.py --n-cores 4 --port-start 11141 --evaluation-time 50; + + sleep 5s + done +done + + + while true + do + for i in {1..20}; do + ./revolve.py --experiment-name karines_experiments/data/tilted_big_$i --run $i --manager experiments/karines_experiments/tilted_big.py --n-cores 4 --port-start 11141 --evaluation-time 50; + + sleep 5s + done +done + + + + diff --git a/experiments/plasticoding_frontiers2020/summary_measures_journal2_tilted_big_1.R b/experiments/plasticoding_frontiers2020/summary_measures_journal2_tilted_big_1.R new file mode 100644 index 0000000000..0beb61d404 --- /dev/null +++ b/experiments/plasticoding_frontiers2020/summary_measures_journal2_tilted_big_1.R @@ -0,0 +1,528 @@ + library(ggplot2) + library(sqldf) + library(plyr) + library(dplyr) + library(trend) + library(purrr) + library(ggsignif) + + base_directory <-paste('journal2', sep='') + +analysis = 'analysis_journal2_tilted_big_1' + +output_directory = paste(base_directory,'/',analysis ,sep='') + +#### CHANGE THE PARAMETERS HERE #### + + +experiments_type = c( 'flat_big', 'tilted_big' ) + +environments = list(c( 'plane'), c('tilted5') ) + +methods = c() +for (exp in 1:length(experiments_type)) +{ + for (env in 1:length(environments[[exp]])) + { + methods = c(methods, paste(experiments_type[exp], environments[[exp]][env], sep='_')) + } +} + +initials = c( 'p', 't' ) + +experiments_labels = c( 'Static: Flat', 'Static: Tilted') + + runs = list( c(1:20), c(1:20) ) + + gens = 200 + pop = 100 + + #### CHANGE THE PARAMETERS HERE #### + + sig = 0.05 + line_size = 30 + show_markers = TRUE#FALSE + show_legends = FALSE + experiments_type_colors = c( '#009999' , '#cc9900' ) # weird green and weird yellow + + measures_names = c( + 'displacement_velocity_hill', + 'head_balance', + 'contacts', + 'displacement_velocity', + 'branching', + 'branching_modules_count', + 'limbs', + 'extremities', + 'length_of_limbs', + 'extensiveness', + 'coverage', + 'joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'proportion', + 'width', + 'height', + 'absolute_size', + 'sensors', + 'symmetry', + 'avg_period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'fitness', + 'cons_fitness' + ) + + # add proper labels soon... + measures_labels = c( + 'Speed (cm/s)', + 'Balance', + 'Contacts', + 'displacement_velocity', + 'Branching', + 'branching_modules_count', + 'Rel number of limbs', + 'extremities', + 'Rel. Length of Limbs', + 'extensiveness', + 'coverage', + 'Rel. Number of Joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'Proportion', + 'width', + 'height', + 'Size', + 'sensors', + 'Symmetry', + 'Average Period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'Fitness', + 'Number of slaves' + ) + + + measures_snapshots_all = NULL + + for (exp in 1:length(experiments_type)) + { + for(run in runs[[exp]]) + { + for (env in 1:length(environments[[exp]])) + { + input_directory <- paste(base_directory, '/', + experiments_type[exp], '_',sep='') + + measures = read.table(paste(input_directory, run, '/data_fullevolution/', + environments[[exp]][env], "/all_measures.tsv", sep=''), header = TRUE, fill=TRUE) + for( m in 1:length(measures_names)) + { + measures[measures_names[m]] = as.numeric(as.character(measures[[measures_names[m]]])) + } + + snapshots = read.table(paste(input_directory, run,'/selectedpop_', + environments[[exp]][env],"/snapshots_ids.tsv", sep=''), header = TRUE) + + measures_snapshots = sqldf('select * from snapshots inner join measures using(robot_id) order by generation') + + measures_snapshots$run = run + measures_snapshots$displacement_velocity_hill = measures_snapshots$displacement_velocity_hill*100 + measures_snapshots$run = as.factor(measures_snapshots$run) + measures_snapshots$method = paste(experiments_type[exp], environments[[exp]][env],sep='_') + + if ( is.null(measures_snapshots_all)){ + measures_snapshots_all = measures_snapshots + }else{ + measures_snapshots_all = rbind(measures_snapshots_all, measures_snapshots) + } + } + } + } + + + fail_test = sqldf(paste("select method,run,generation,count(*) as c from measures_snapshots_all group by 1,2,3 having c<",gens," order by 4")) + + + measures_snapshots_all = sqldf("select * from measures_snapshots_all where cons_fitness IS NOT NULL") + + + + + measures_averages_gens_1 = list() + measures_averages_gens_2 = list() + + measures_ini = list() + measures_fin = list() + + for (met in 1:length(methods)) + { + + measures_aux = c() + query ='select run, generation' + for (i in 1:length(measures_names)) + { + query = paste(query,', avg(',measures_names[i],') as ', methods[met], '_',measures_names[i],'_avg', sep='') + } + query = paste(query,' from measures_snapshots_all + where method="', methods[met],'" group by run, generation', sep='') + + temp = sqldf(query) + + measures_averages_gens_1[[met]] = temp + + temp = measures_averages_gens_1[[met]] + + temp$generation = as.numeric(temp$generation) + + measures_ini[[met]] = sqldf(paste("select * from temp where generation=0")) + measures_fin[[met]] = sqldf(paste("select * from temp where generation=",gens-1)) + query = 'select generation' + for (i in 1:length(measures_names)) + { + # later renames vars _avg_SUMMARY, just to make it in the same style as the quantile variables + query = paste(query,', avg(', methods[met], '_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_avg', sep='') + query = paste(query,', max(', methods[met],'_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_max', sep='') + query = paste(query,', stdev(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_stdev', sep='') + query = paste(query,', median(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_median', sep='') + + measures_aux = c(measures_aux, paste(methods[met],'_',measures_names[i],'_avg', sep='') ) + } + query = paste(query,' from temp group by generation', sep="") + + temp2 = sqldf(query) + + p <- c(0.25, 0.75) + p_names <- map_chr(p, ~paste0('Q',.x*100, sep="")) + p_funs <- map(p, ~partial(quantile, probs = .x, na.rm = TRUE)) %>% + set_names(nm = p_names) + + quantiles = data.frame(temp %>% + group_by(generation) %>% + summarize_at(vars(measures_aux), funs(!!!p_funs)) ) + + measures_averages_gens_2[[met]] = sqldf('select * from temp2 inner join quantiles using (generation)') + + } + + + for (met in 1:length(methods)) + { + if(met==1){ + measures_averages_gens = measures_averages_gens_2[[1]] + }else{ + measures_averages_gens = merge(measures_averages_gens, measures_averages_gens_2[[met]], all=TRUE, by = "generation") + } + } + + file <-file(paste(output_directory,'/trends.txt',sep=''), open="w") + + #tests trends in curves and difference between ini and fin generations + + + # ini VS fin + array_wilcoxon = list() + array_wilcoxon2 = list() + + # curve + array_mann = list() + + + for (m in 1:length(methods)) + { + + array_wilcoxon[[m]] = list() + array_mann[[m]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(experiments_type[m],measures_names[i],'ini avg ',as.character( + mean(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon[[m]][[i]] = wilcox.test(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'iniVSfin',measures_names[i],'wilcox p: ',as.character(round(array_wilcoxon[[m]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'iniVSfin',measures_names[i],'wilcox est: ',as.character(round(array_wilcoxon[[m]][[i]]$statistic,4)), sep=' ') + + ), file) + + + #tests trends + array_mann[[m]][[i]] = mk.test(c(array(measures_averages_gens_2[[m]][paste(methods[m],"_",measures_names[i],'_median',sep='')]) )[[1]], + continuity = TRUE) + + + writeLines(c( + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median p', as.character(round(array_mann[[m]][[i]]$p.value,4)),sep=' '), + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median s', as.character(round(array_mann[[m]][[i]]$statistic,4)),sep=' ') + ), file) + + } + + } + + + + # tests final generation among experiments_type + + aux_m = length(methods) + + if (aux_m>1) + { + + # fins + array_wilcoxon2[[1]] = list() + array_wilcoxon2[[2]] = list() + + aux_m = aux_m -1 + count_pairs = 0 + for(m in 1:aux_m) + { + aux = m+1 + for(m2 in aux:length(methods)) + { + + count_pairs = count_pairs+1 + array_wilcoxon2[[1]][[count_pairs]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + writeLines(paste(methods[m2],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon2[[1]][[count_pairs]][[i]] = wilcox.test(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'VS',methods[m],measures_names[i],'fin avg wilcox p: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'VS',methods[m2],measures_names[i],'fin avg wilcox est: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$statistic,4)), sep=' ') + + ), file) + + } + + + array_wilcoxon2[[2]][[count_pairs]] = paste(initials[m],initials[m2],sep='') + + } + } + + } + + close(file) + + # plots measures + + for (type_summary in c('means','quants')) + { + + + for (i in 1:length(measures_names)) + { + tests1 = '' + tests2 = '' + tests3 = '' + break_aux = 0 + + graph <- ggplot(data=measures_averages_gens, aes(x=generation)) + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg','-',methods[m],'_',measures_names[i],'_stdev',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg','+',methods[m],'_',measures_names[i],'_stdev',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + }else + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg_Q25',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg_Q75',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + } + } + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep=''), colour=shQuote(experiments_labels[m]) ), size=2) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep='') ),size=2, color = experiments_type_colors[m]) + } + + }else{ + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') , colour=shQuote(experiments_labels[m]) ),size=2 ) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') ),size=2, color = experiments_type_colors[m] ) + } + } + + if (length(array_mann)>0) + { + if (length(array_mann[[m]])>0) + { + if(!is.na(array_mann[[m]][[i]]$p.value)) + { + if(array_mann[[m]][[i]]$p.value<=sig) + { + if(array_mann[[m]][[i]]$statistic>0){ direction = "/ "} else { direction = "\\ "} + tests1 = paste(tests1, initials[m],direction,sep="") + } + } + } + } + } + + if (length(array_wilcoxon[[m]])>0) + { + for(m in 1:length(methods)) + { + if(!is.na(array_wilcoxon[[m]][[i]]$p.value)) + { + if(array_wilcoxon[[m]][[i]]$p.value<=sig) + { + tests2 = paste(tests2, initials[m],'C ', sep='') + } + } + } + } + + if (length(array_wilcoxon2)>0) + { + for(p in 1:length(array_wilcoxon2[[1]])) + { + if (length(array_wilcoxon2[[1]][[p]])>0) + { + if(!is.na(array_wilcoxon2[[1]][[p]][[i]]$p.value)) + { + if(array_wilcoxon2[[1]][[p]][[i]]$p.value<=sig) + { + if(nchar(tests3)>line_size && break_aux == 0){ + tests3 = paste(tests3, '\n') + break_aux = 1 + } + tests3 = paste(tests3, array_wilcoxon2[[2]][[p]],'D ',sep='') + } + } + } + } + } + + max_y = 0 + min_y = 0 + if (measures_names[i] == 'displacement_velocity_hill' ) { + max_y = 6 + min_y = -0.5} + if (measures_names[i] == 'head_balance' || measures_names[i] == 'limbs' || measures_names[i] == 'joints') { max_y = 1.1} + if (measures_names[i] == 'proportion' ) { max_y = 1} + if (measures_names[i] == 'absolute_size' ) { max_y = 16} + + + graph = graph + labs( y=measures_labels[i], x="Generation") + if (max_y>0) { + graph = graph + coord_cartesian(ylim = c(min_y, max_y)) + } + + if(show_markers == TRUE){ + graph = graph + labs( y=measures_labels[i], x="Generation", subtitle = paste(tests1,'\n', tests2, '\n', tests3, sep='')) + } + graph = graph + theme(legend.position="bottom" , legend.text=element_text(size=20), axis.text=element_text(size=27),axis.title=element_text(size=25), + plot.subtitle=element_text(size=25 )) + + ggsave(paste( output_directory,'/',type_summary,'_' ,measures_names[i],'_generations.pdf', sep=''), graph , device='pdf', height = 10, width = 10) + } + + } + + + + + for (i in 1:length(measures_names)) + { + + max_y = 0 + min_y = 0 + if (measures_names[i] == 'displacement_velocity_hill' ) { + max_y = 6 + min_y = -0.5} + if (measures_names[i] == 'head_balance' || measures_names[i] == 'limbs' || measures_names[i] == 'joints') { max_y = 1.1} + if (measures_names[i] == 'proportion' ) { max_y = 1} + if (measures_names[i] == 'absolute_size' ) { max_y = 16} + + all_final_values = data.frame() + for (exp in 1:length(methods)) + { + temp = data.frame( c(measures_fin[[exp]][paste(methods[exp],'_',measures_names[i],'_avg', sep='')])) + colnames(temp) <- 'values' + + temp$type = experiments_labels[exp] + all_final_values = rbind(all_final_values, temp) + } + + g1 <- ggplot(data=all_final_values, aes(x= type , y=values, color=type )) + + geom_boxplot(position = position_dodge(width=0.9),lwd=2, outlier.size = 4) + + labs( x="Environment", y=measures_labels[i]) + + g1 = g1 + scale_color_manual(values=experiments_type_colors) + + g1 = g1 + theme(legend.position="none" , text = element_text(size=45) , + plot.title=element_text(size=40), axis.text=element_text(size=45), + axis.title=element_text(size=50), + axis.text.x = element_text(angle = 20, hjust = 1))+ + stat_summary(fun.y = mean, geom="point" ,shape = 16, size=11) + + comps = list(c( 'Static: Flat', 'Static: Tilted') ) + + g1 = g1 + geom_signif( test="wilcox.test", size=2, textsize=22, + comparisons = comps, + map_signif_level=c("***"=0.001,"**"=0.01, "*"=0.05) ) + if (max_y>0) { + g1 = g1 + coord_cartesian(ylim = c(min_y, max_y)) + } + + ggsave(paste(output_directory,"/",measures_names[i],"_boxes.pdf",sep = ""), g1, device = "pdf", height=18, width = 10) + + } + + \ No newline at end of file diff --git a/experiments/plasticoding_frontiers2020/summary_measures_journal2_tilted_big_2.R b/experiments/plasticoding_frontiers2020/summary_measures_journal2_tilted_big_2.R new file mode 100644 index 0000000000..81216b481e --- /dev/null +++ b/experiments/plasticoding_frontiers2020/summary_measures_journal2_tilted_big_2.R @@ -0,0 +1,577 @@ + library(ggplot2) + library(sqldf) + library(plyr) + library(dplyr) + library(trend) + library(purrr) + library(ggsignif) + + base_directory <-paste('journal2', sep='') + +analysis = 'nonstatic/analysis_journal2_tilted_big_2' + +output_directory = paste(base_directory,'/',analysis ,sep='') + +#### CHANGE THE PARAMETERS HERE #### + +experiments_type = c('baseline_big', 'plastic_big' ) + +environments = list( c( 'plane'), c( 'plane') ) + +methods = c() +for (exp in 1:length(experiments_type)) +{ + for (env in 1:length(environments[[exp]])) + { + methods = c(methods, paste(experiments_type[exp], environments[[exp]][env], sep='_')) + } +} + +initials = c( 'b', 'p' ) + +experiments_labels = c( 'Baseline' , 'Plastic') +experiments_labels2 = c( 'Baseline: Flat' , 'Plastic: Flat') + + runs = list( c(1:20), c(1:20) ) + + gens = 200 + pop = 100 + + #### CHANGE THE PARAMETERS HERE #### + + sig = 0.05 + line_size = 30 + show_markers = FALSE + show_legends = FALSE + experiments_type_colors = c( '#00ff00', '#006600' ) # light green; dark green; + + measures_names = c( + 'displacement_velocity_hill', + 'head_balance', + 'contacts', + 'displacement_velocity', + 'branching', + 'branching_modules_count', + 'limbs', + 'extremities', + 'length_of_limbs', + 'extensiveness', + 'coverage', + 'joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'proportion', + 'width', + 'height', + 'absolute_size', + 'sensors', + 'symmetry', + 'avg_period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'fitness', + 'cons_fitness' + ) + + # add proper labels soon... + measures_labels = c( + 'Speed (cm/s)', + 'Balance', + 'Contacts', + 'displacement_velocity', + 'Branching', + 'branching_modules_count', + 'Rel number of limbs', + 'extremities', + 'Rel. Length of Limbs', + 'extensiveness', + 'coverage', + 'Rel. Number of Joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'Proportion', + 'width', + 'height', + 'Size', + 'Sensors', + 'Symmetry', + 'Average Period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'Sensors Reach', + 'Recurrence', + 'synaptic_reception', + 'Fitness', + 'Number of slaves' + ) + + + measures_snapshots_all = NULL + + for (exp in 1:length(experiments_type)) + { + for(run in runs[[exp]]) + { + for (env in 1:length(environments[[exp]])) + { + input_directory <- paste(base_directory, '/', + experiments_type[exp], '_',sep='') + + measures = read.table(paste(input_directory, run, '/data_fullevolution/', + environments[[exp]][env], "/all_measures.tsv", sep=''), header = TRUE, fill=TRUE) + for( m in 1:length(measures_names)) + { + measures[measures_names[m]] = as.numeric(as.character(measures[[measures_names[m]]])) + } + + snapshots = read.table(paste(input_directory, run,'/selectedpop_', + environments[[exp]][env],"/snapshots_ids.tsv", sep=''), header = TRUE) + + measures_snapshots = sqldf('select * from snapshots inner join measures using(robot_id) order by generation') + + measures_snapshots$run = run + measures_snapshots$displacement_velocity_hill = measures_snapshots$displacement_velocity_hill*100 + measures_snapshots$run = as.factor(measures_snapshots$run) + measures_snapshots$method = paste(experiments_type[exp], environments[[exp]][env],sep='_') + measures_snapshots$method_label = experiments_labels2[exp] + + if ( is.null(measures_snapshots_all)){ + measures_snapshots_all = measures_snapshots + }else{ + measures_snapshots_all = rbind(measures_snapshots_all, measures_snapshots) + } + } + } + } + + + fail_test = sqldf(paste("select method,run,generation,count(*) as c from measures_snapshots_all group by 1,2,3 having c<",gens," order by 4")) + + + measures_snapshots_all = sqldf("select * from measures_snapshots_all where cons_fitness IS NOT NULL") + + + + # densities + + measures_snapshots_all_densities = sqldf(paste("select * from measures_snapshots_all where generation=199",sep='' )) + + measures_names_densities = c('length_of_limbs','proportion', 'absolute_size','head_balance','joints', 'limbs', 'recurrence', 'sensors', 'sensors_reach','displacement_velocity_hill') + measures_labels_densities = c('Rel. Length of Limbs','Proportion', 'Size','Balance','Rel. Number of Joints', 'Rel. Number of Limbs', 'Recurrence', 'Sensors', 'Sensors Reach', 'Speed (cm/s)') + + for (i in 1:length(measures_names_densities)) + { + + for (j in 1:length(measures_names_densities)) + { + + if(i != j) + { + + summary = sqldf(paste('select method_label,',measures_names_densities[j], ' as x,', measures_names_densities[i], + " as y, count(*) as n from measures_snapshots_all_densities + group by 1,2 order by n", sep='')) + + graph = ggplot(data=summary,aes(x=x ,y=y ,fill=n)) + + stat_density_2d(geom = "raster", aes(fill = stat(density)), contour = FALSE)+ + labs( x = measures_labels_densities[j], y= measures_labels_densities[i] )+ + theme(legend.position="none" , strip.text = element_text( size = 20 ), plot.title=element_text(size=25), + axis.text=element_text(size=17),axis.title=element_text(size=20) ) + + coord_cartesian(ylim = c(0, 1), xlim = c(0, 1))+ facet_grid(. ~ method_label) + + ggsave(paste( output_directory ,'/density_',measures_names_densities[i],'_', measures_names_densities[j],'.png', sep=''), graph , + device='png', height = 6, width = 10) + + } + + } + } + + measures_averages_gens_1 = list() + measures_averages_gens_2 = list() + + measures_ini = list() + measures_fin = list() + + for (met in 1:length(methods)) + { + + measures_aux = c() + query ='select run, generation' + for (i in 1:length(measures_names)) + { + query = paste(query,', avg(',measures_names[i],') as ', methods[met], '_',measures_names[i],'_avg', sep='') + } + query = paste(query,' from measures_snapshots_all + where method="', methods[met],'" group by run, generation', sep='') + + temp = sqldf(query) + + measures_averages_gens_1[[met]] = temp + + temp = measures_averages_gens_1[[met]] + + temp$generation = as.numeric(temp$generation) + + measures_ini[[met]] = sqldf(paste("select * from temp where generation=0")) + measures_fin[[met]] = sqldf(paste("select * from temp where generation=",gens-1)) + query = 'select generation' + for (i in 1:length(measures_names)) + { + # later renames vars _avg_SUMMARY, just to make it in the same style as the quantile variables + query = paste(query,', avg(', methods[met], '_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_avg', sep='') + query = paste(query,', max(', methods[met],'_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_max', sep='') + query = paste(query,', stdev(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_stdev', sep='') + query = paste(query,', median(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_median', sep='') + + measures_aux = c(measures_aux, paste(methods[met],'_',measures_names[i],'_avg', sep='') ) + } + query = paste(query,' from temp group by generation', sep="") + + temp2 = sqldf(query) + + p <- c(0.25, 0.75) + p_names <- map_chr(p, ~paste0('Q',.x*100, sep="")) + p_funs <- map(p, ~partial(quantile, probs = .x, na.rm = TRUE)) %>% + set_names(nm = p_names) + + quantiles = data.frame(temp %>% + group_by(generation) %>% + summarize_at(vars(measures_aux), funs(!!!p_funs)) ) + + measures_averages_gens_2[[met]] = sqldf('select * from temp2 inner join quantiles using (generation)') + + } + + + for (met in 1:length(methods)) + { + if(met==1){ + measures_averages_gens = measures_averages_gens_2[[1]] + }else{ + measures_averages_gens = merge(measures_averages_gens, measures_averages_gens_2[[met]], all=TRUE, by = "generation") + } + } + + file <-file(paste(output_directory,'/trends.txt',sep=''), open="w") + + #tests trends in curves and difference between ini and fin generations + + + # ini VS fin + array_wilcoxon = list() + array_wilcoxon2 = list() + + # curve + array_mann = list() + + + for (m in 1:length(methods)) + { + + array_wilcoxon[[m]] = list() + array_mann[[m]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(experiments_type[m],measures_names[i],'ini avg ',as.character( + mean(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon[[m]][[i]] = wilcox.test(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'iniVSfin',measures_names[i],'wilcox p: ',as.character(round(array_wilcoxon[[m]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'iniVSfin',measures_names[i],'wilcox est: ',as.character(round(array_wilcoxon[[m]][[i]]$statistic,4)), sep=' ') + + ), file) + + + #tests trends + array_mann[[m]][[i]] = mk.test(c(array(measures_averages_gens_2[[m]][paste(methods[m],"_",measures_names[i],'_median',sep='')]) )[[1]], + continuity = TRUE) + + + writeLines(c( + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median p', as.character(round(array_mann[[m]][[i]]$p.value,4)),sep=' '), + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median s', as.character(round(array_mann[[m]][[i]]$statistic,4)),sep=' ') + ), file) + + } + + } + + + + # tests final generation among experiments_type + + aux_m = length(methods) + + if (aux_m>1) + { + + # fins + array_wilcoxon2[[1]] = list() + array_wilcoxon2[[2]] = list() + + aux_m = aux_m -1 + count_pairs = 0 + for(m in 1:aux_m) + { + aux = m+1 + for(m2 in aux:length(methods)) + { + + count_pairs = count_pairs+1 + array_wilcoxon2[[1]][[count_pairs]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + writeLines(paste(methods[m2],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon2[[1]][[count_pairs]][[i]] = wilcox.test(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'VS',methods[m],measures_names[i],'fin avg wilcox p: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'VS',methods[m2],measures_names[i],'fin avg wilcox est: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$statistic,4)), sep=' ') + + ), file) + + } + + + array_wilcoxon2[[2]][[count_pairs]] = paste(initials[m],initials[m2],sep='') + + } + } + + } + + close(file) + + + + # plots measures + + for (type_summary in c('means','quants')) + { + + + for (i in 1:length(measures_names)) + { + tests1 = '' + tests2 = '' + tests3 = '' + break_aux = 0 + + graph <- ggplot(data=measures_averages_gens, aes(x=generation)) + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg','-',methods[m],'_',measures_names[i],'_stdev',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg','+',methods[m],'_',measures_names[i],'_stdev',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + }else + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg_Q25',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg_Q75',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + } + } + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep=''), colour=shQuote(experiments_labels[m]) ), size=2) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep='') ),size=2, color = experiments_type_colors[m]) + } + + }else{ + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') , colour=shQuote(experiments_labels[m]) ),size=2 ) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') ),size=2, color = experiments_type_colors[m] ) + } + } + + if (length(array_mann)>0) + { + if (length(array_mann[[m]])>0) + { + if(!is.na(array_mann[[m]][[i]]$p.value)) + { + if(array_mann[[m]][[i]]$p.value<=sig) + { + if(array_mann[[m]][[i]]$statistic>0){ direction = "/ "} else { direction = "\\ "} + tests1 = paste(tests1, initials[m],direction,sep="") + } + } + } + } + } + + if (length(array_wilcoxon[[m]])>0) + { + for(m in 1:length(methods)) + { + if(!is.na(array_wilcoxon[[m]][[i]]$p.value)) + { + if(array_wilcoxon[[m]][[i]]$p.value<=sig) + { + tests2 = paste(tests2, initials[m],'C ', sep='') + } + } + } + } + + if (length(array_wilcoxon2)>0) + { + for(p in 1:length(array_wilcoxon2[[1]])) + { + if (length(array_wilcoxon2[[1]][[p]])>0) + { + if(!is.na(array_wilcoxon2[[1]][[p]][[i]]$p.value)) + { + if(array_wilcoxon2[[1]][[p]][[i]]$p.value<=sig) + { + if(nchar(tests3)>line_size && break_aux == 0){ + tests3 = paste(tests3, '\n') + break_aux = 1 + } + tests3 = paste(tests3, array_wilcoxon2[[2]][[p]],'D ',sep='') + } + } + } + } + } + + + max_y = 0 + min_y = 0 + if (measures_names[i] == 'displacement_velocity_hill' ) { + max_y = 2.5 + min_y = -0.5} + if (measures_names[i] == 'head_balance' ) { + max_y = 1 + min_y = 0.6} + if (measures_names[i] == 'absolute_size' ) { max_y = 16} + if (measures_names[i] == 'recurrence' ) { max_y = 0.3} + if (measures_names[i] == 'sensors' ) { max_y = 0.3 } + if (measures_names[i] == 'sensors_reach' ) { max_y = 1 } + + graph = graph + labs( y=measures_labels[i], x="Generation", title="Flat Season") + if (max_y>0) { + graph = graph + coord_cartesian(ylim = c(min_y, max_y)) + } + + if(show_markers == TRUE){ + graph = graph + labs( y=measures_labels[i], x="Generation", subtitle = paste(tests1,'\n', tests2, '\n', tests3, sep='')) + } + graph = graph + theme(legend.position="bottom" , legend.text=element_text(size=20), axis.text=element_text(size=27),axis.title=element_text(size=25), + plot.subtitle=element_text(size=25 ),plot.title=element_text(size=25 )) + + ggsave(paste( output_directory,'/',type_summary,'_' ,measures_names[i],'_generations.pdf', sep=''), graph , device='pdf', height = 10, width = 10) + + } + + } + + + + for (i in 1:length(measures_names)) + { + + + all_final_values = data.frame() + for (exp in 1:length(methods)) + { + temp = data.frame( c(measures_fin[[exp]][paste(methods[exp],'_',measures_names[i],'_avg', sep='')])) + colnames(temp) <- 'values' + + temp$type = experiments_labels[exp] + all_final_values = rbind(all_final_values, temp) + } + + g1 <- ggplot(data=all_final_values, aes(x= type , y=values, color=type )) + + geom_boxplot(position = position_dodge(width=0.9),lwd=2, outlier.size = 4) + + labs( x="Environment", y=measures_labels[i], title="Flat Season") + + max_y = 0 + min_y = 0 + if (measures_names[i] == 'displacement_velocity_hill' ) { + g1 = g1 + geom_hline(yintercept=3.63, linetype="dashed", color = "red", size=2) + max_y = 4.8 + min_y = -0.5} + if (measures_names[i] == 'head_balance'){ + max_y = 1.15 + min_y = 0.55 + } + if (measures_names[i] == 'sensors_reach') { max_y = 1.15} + if (measures_names[i] == 'recurrence' ) { max_y = 0.8} + if (measures_names[i] == 'sensors' ) { max_y = 0.6} + if (measures_names[i] == 'absolute_size' ) { max_y = 16} + + g1 = g1 + scale_color_manual(values= experiments_type_colors ) + + g1 = g1 + theme(legend.position="none" , text = element_text(size=45) , + plot.title=element_text(size=45), axis.text=element_text(size=45), + axis.title=element_text(size=50), + axis.text.x = element_text(angle = 20, hjust = 0.9), + plot.margin=margin(t = 0.5, r = 0.5, b = 0.5, l = 1.3, unit = "cm"))+ + stat_summary(fun.y = mean, geom="point" ,shape = 16, size=11) + + comps = list( c( 'Baseline', 'Plastic') ) + + g1 = g1 + geom_signif( test="wilcox.test", size=2, textsize=22, + comparisons = comps, + map_signif_level=c("***"=0.001,"**"=0.01, "*"=0.05) ) + if (max_y>0) { + g1 = g1 + coord_cartesian(ylim = c(min_y, max_y)) + } + + ggsave(paste(output_directory,"/",measures_names[i],"_boxes.pdf",sep = ""), g1, device = "pdf", height=18, width = 10) + + } + + \ No newline at end of file diff --git a/experiments/plasticoding_frontiers2020/summary_measures_journal2_tilted_big_3.R b/experiments/plasticoding_frontiers2020/summary_measures_journal2_tilted_big_3.R new file mode 100644 index 0000000000..aef75a5867 --- /dev/null +++ b/experiments/plasticoding_frontiers2020/summary_measures_journal2_tilted_big_3.R @@ -0,0 +1,578 @@ + library(ggplot2) + library(sqldf) + library(plyr) + library(dplyr) + library(trend) + library(purrr) + library(ggsignif) + + base_directory <-paste('journal2', sep='') + +analysis = 'nonstatic/analysis_journal2_tilted_big_3' + +output_directory = paste(base_directory,'/',analysis ,sep='') + +#### CHANGE THE PARAMETERS HERE #### + +experiments_type = c( 'baseline_big', 'plastic_big' ) +experiments_labels2 = c( 'Baseline: Tilted' , 'Plastic: Tilted') + +environments = list( c( 'tilted5'), c( 'tilted5') ) + +methods = c() +for (exp in 1:length(experiments_type)) +{ + for (env in 1:length(environments[[exp]])) + { + methods = c(methods, paste(experiments_type[exp], environments[[exp]][env], sep='_')) + } +} + +initials = c( 'b', 'p' ) + +experiments_labels = c( 'Baseline' , 'Plastic') +experiments_labels2 = c( 'Baseline: Tilted' , 'Plastic: Tilted') + + runs = list( c(1:20),c(1:20) ) + + gens = 200 + pop = 100 + + #### CHANGE THE PARAMETERS HERE #### + + sig = 0.05 + line_size = 30 + show_markers = FALSE + show_legends = FALSE + experiments_type_colors = c( '#ff9933', '#cc0000' ) # orange ; dark red + + measures_names = c( + 'displacement_velocity_hill', + 'head_balance', + 'contacts', + 'displacement_velocity', + 'branching', + 'branching_modules_count', + 'limbs', + 'extremities', + 'length_of_limbs', + 'extensiveness', + 'coverage', + 'joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'proportion', + 'width', + 'height', + 'absolute_size', + 'sensors', + 'symmetry', + 'avg_period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'sensors_reach', + 'recurrence', + 'synaptic_reception', + 'fitness', + 'cons_fitness' + ) + + # add proper labels soon... + measures_labels = c( + 'Speed (cm/s)', + 'Balance', + 'Contacts', + 'displacement_velocity', + 'Branching', + 'branching_modules_count', + 'Rel number of limbs', + 'extremities', + 'Rel. Length of Limbs', + 'extensiveness', + 'coverage', + 'Rel. Number of Joints', + 'hinge_count', + 'active_hinges_count', + 'brick_count', + 'touch_sensor_count', + 'brick_sensor_count', + 'Proportion', + 'width', + 'height', + 'Size', + 'Sensors', + 'Symmetry', + 'Average Period', + 'dev_period', + 'avg_phase_offset', + 'dev_phase_offset', + 'avg_amplitude', + 'dev_amplitude', + 'avg_intra_dev_params', + 'avg_inter_dev_params', + 'Sensors Reach', + 'Recurrence', + 'synaptic_reception', + 'Fitness', + 'Number of slaves' + ) + + + measures_snapshots_all = NULL + + for (exp in 1:length(experiments_type)) + { + for(run in runs[[exp]]) + { + for (env in 1:length(environments[[exp]])) + { + input_directory <- paste(base_directory, '/', + experiments_type[exp], '_',sep='') + + measures = read.table(paste(input_directory, run, '/data_fullevolution/', + environments[[exp]][env], "/all_measures.tsv", sep=''), header = TRUE, fill=TRUE) + for( m in 1:length(measures_names)) + { + measures[measures_names[m]] = as.numeric(as.character(measures[[measures_names[m]]])) + } + + snapshots = read.table(paste(input_directory, run,'/selectedpop_', + environments[[exp]][env],"/snapshots_ids.tsv", sep=''), header = TRUE) + + measures_snapshots = sqldf('select * from snapshots inner join measures using(robot_id) order by generation') + + measures_snapshots$run = run + measures_snapshots$displacement_velocity_hill = measures_snapshots$displacement_velocity_hill*100 + measures_snapshots$run = as.factor(measures_snapshots$run) + measures_snapshots$method = paste(experiments_type[exp], environments[[exp]][env],sep='_') + measures_snapshots$method_label = experiments_labels2[exp] + + if ( is.null(measures_snapshots_all)){ + measures_snapshots_all = measures_snapshots + }else{ + measures_snapshots_all = rbind(measures_snapshots_all, measures_snapshots) + } + } + } + } + + + fail_test = sqldf(paste("select method,run,generation,count(*) as c from measures_snapshots_all group by 1,2,3 having c<",gens," order by 4")) + + + measures_snapshots_all = sqldf("select * from measures_snapshots_all where cons_fitness IS NOT NULL") + + + + # densities + + measures_snapshots_all_densities = sqldf(paste("select * from measures_snapshots_all where generation=199",sep='' )) + + measures_names_densities = c('length_of_limbs','proportion', 'absolute_size','head_balance','joints', 'limbs', 'recurrence', 'sensors', 'sensors_reach','displacement_velocity_hill') + measures_labels_densities = c('Rel. Length of Limbs','Proportion', 'Size','Balance','Rel. Number of Joints', 'Rel. Number of Limbs', 'Recurrence', 'Sensors', 'Sensors Reach', 'Speed (cm/s)') + + for (i in 1:length(measures_names_densities)) + { + + for (j in 1:length(measures_names_densities)) + { + + if(i != j) + { + + summary = sqldf(paste('select method_label,',measures_names_densities[j], ' as x,', measures_names_densities[i], + " as y, count(*) as n from measures_snapshots_all_densities + group by 1,2 order by n", sep='')) + + graph = ggplot(data=summary,aes(x=x ,y=y ,fill=n)) + + stat_density_2d(geom = "raster", aes(fill = stat(density)), contour = FALSE)+ + labs( x = measures_labels_densities[j], y= measures_labels_densities[i] )+ + theme(legend.position="none" , strip.text = element_text( size = 20 ), plot.title=element_text(size=25), + axis.text=element_text(size=17),axis.title=element_text(size=20) ) + + coord_cartesian(ylim = c(0, 1), xlim = c(0, 1))+ facet_grid(. ~ method_label) + + ggsave(paste( output_directory ,'/density_',measures_names_densities[i],'_', measures_names_densities[j],'.png', sep=''), graph , + device='png', height = 6, width = 10) + + + } + + } + } + + + + measures_averages_gens_1 = list() + measures_averages_gens_2 = list() + + measures_ini = list() + measures_fin = list() + + for (met in 1:length(methods)) + { + + measures_aux = c() + query ='select run, generation' + for (i in 1:length(measures_names)) + { + query = paste(query,', avg(',measures_names[i],') as ', methods[met], '_',measures_names[i],'_avg', sep='') + } + query = paste(query,' from measures_snapshots_all + where method="', methods[met],'" group by run, generation', sep='') + + temp = sqldf(query) + + measures_averages_gens_1[[met]] = temp + + temp = measures_averages_gens_1[[met]] + + temp$generation = as.numeric(temp$generation) + + measures_ini[[met]] = sqldf(paste("select * from temp where generation=0")) + measures_fin[[met]] = sqldf(paste("select * from temp where generation=",gens-1)) + query = 'select generation' + for (i in 1:length(measures_names)) + { + # later renames vars _avg_SUMMARY, just to make it in the same style as the quantile variables + query = paste(query,', avg(', methods[met], '_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_avg', sep='') + query = paste(query,', max(', methods[met],'_',measures_names[i],'_avg) as ' + ,methods[met],'_',measures_names[i],'_max', sep='') + query = paste(query,', stdev(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_stdev', sep='') + query = paste(query,', median(', methods[met],'_',measures_names[i],'_avg) as ' + , methods[met],'_',measures_names[i],'_median', sep='') + + measures_aux = c(measures_aux, paste(methods[met],'_',measures_names[i],'_avg', sep='') ) + } + query = paste(query,' from temp group by generation', sep="") + + temp2 = sqldf(query) + + p <- c(0.25, 0.75) + p_names <- map_chr(p, ~paste0('Q',.x*100, sep="")) + p_funs <- map(p, ~partial(quantile, probs = .x, na.rm = TRUE)) %>% + set_names(nm = p_names) + + quantiles = data.frame(temp %>% + group_by(generation) %>% + summarize_at(vars(measures_aux), funs(!!!p_funs)) ) + + measures_averages_gens_2[[met]] = sqldf('select * from temp2 inner join quantiles using (generation)') + + } + + + for (met in 1:length(methods)) + { + if(met==1){ + measures_averages_gens = measures_averages_gens_2[[1]] + }else{ + measures_averages_gens = merge(measures_averages_gens, measures_averages_gens_2[[met]], all=TRUE, by = "generation") + } + } + + file <-file(paste(output_directory,'/trends.txt',sep=''), open="w") + + #tests trends in curves and difference between ini and fin generations + + + # ini VS fin + array_wilcoxon = list() + array_wilcoxon2 = list() + + # curve + array_mann = list() + + + for (m in 1:length(methods)) + { + + array_wilcoxon[[m]] = list() + array_mann[[m]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(experiments_type[m],measures_names[i],'ini avg ',as.character( + mean(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon[[m]][[i]] = wilcox.test(c(array(measures_ini[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'iniVSfin',measures_names[i],'wilcox p: ',as.character(round(array_wilcoxon[[m]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'iniVSfin',measures_names[i],'wilcox est: ',as.character(round(array_wilcoxon[[m]][[i]]$statistic,4)), sep=' ') + + ), file) + + + #tests trends + array_mann[[m]][[i]] = mk.test(c(array(measures_averages_gens_2[[m]][paste(methods[m],"_",measures_names[i],'_median',sep='')]) )[[1]], + continuity = TRUE) + + + writeLines(c( + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median p', as.character(round(array_mann[[m]][[i]]$p.value,4)),sep=' '), + paste(experiments_type[m],measures_names[i], ' Mann-Kendall median s', as.character(round(array_mann[[m]][[i]]$statistic,4)),sep=' ') + ), file) + + } + + } + + + + # tests final generation among experiments_type + + aux_m = length(methods) + + if (aux_m>1) + { + + # fins + array_wilcoxon2[[1]] = list() + array_wilcoxon2[[2]] = list() + + aux_m = aux_m -1 + count_pairs = 0 + for(m in 1:aux_m) + { + aux = m+1 + for(m2 in aux:length(methods)) + { + + count_pairs = count_pairs+1 + array_wilcoxon2[[1]][[count_pairs]] = list() + + for (i in 1:length(measures_names)) + { + + writeLines(paste(methods[m],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + writeLines(paste(methods[m2],measures_names[i],'fin avg ',as.character( + mean(c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]) )[[1]]) ) ,sep=" "), file ) + + array_wilcoxon2[[1]][[count_pairs]][[i]] = wilcox.test(c(array(measures_fin[[m]][paste(methods[m],"_",measures_names[i],"_avg",sep='')]))[[1]] , + c(array(measures_fin[[m2]][paste(methods[m2],"_",measures_names[i],"_avg",sep='')]))[[1]] + ) + + writeLines(c( + paste(methods[m],'VS',methods[m],measures_names[i],'fin avg wilcox p: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$p.value,4)), sep=' ') + ,paste(methods[m],'VS',methods[m2],measures_names[i],'fin avg wilcox est: ',as.character(round(array_wilcoxon2[[1]][[count_pairs]][[i]]$statistic,4)), sep=' ') + + ), file) + + } + + + array_wilcoxon2[[2]][[count_pairs]] = paste(initials[m],initials[m2],sep='') + + } + } + + } + + close(file) + + # plots measures + + for (type_summary in c('means','quants')) + { + for (i in 1:length(measures_names)) + { + tests1 = '' + tests2 = '' + tests3 = '' + break_aux = 0 + + graph <- ggplot(data=measures_averages_gens, aes(x=generation)) + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg','-',methods[m],'_',measures_names[i],'_stdev',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg','+',methods[m],'_',measures_names[i],'_stdev',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + }else + { + graph = graph + geom_ribbon(aes_string(ymin=paste(methods[m],'_',measures_names[i],'_avg_Q25',sep=''), + ymax=paste(methods[m],'_',measures_names[i],'_avg_Q75',sep='') ), + fill=experiments_type_colors[m] , color=experiments_type_colors[m],alpha=0.2) + } + } + + for(m in 1:length(methods)) + { + if(type_summary == 'means') + { + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep=''), colour=shQuote(experiments_labels[m]) ), size=2) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_avg',sep='') ),size=2, color = experiments_type_colors[m]) + } + + }else{ + if(show_legends == TRUE){ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') , colour=shQuote(experiments_labels[m]) ),size=2 ) + }else{ + graph = graph + geom_line(aes_string(y=paste(methods[m],'_',measures_names[i],'_median',sep='') ),size=2, color = experiments_type_colors[m] ) + } + } + + if (length(array_mann)>0) + { + if (length(array_mann[[m]])>0) + { + if(!is.na(array_mann[[m]][[i]]$p.value)) + { + if(array_mann[[m]][[i]]$p.value<=sig) + { + if(array_mann[[m]][[i]]$statistic>0){ direction = "/ "} else { direction = "\\ "} + tests1 = paste(tests1, initials[m],direction,sep="") + } + } + } + } + } + + if (length(array_wilcoxon[[m]])>0) + { + for(m in 1:length(methods)) + { + if(!is.na(array_wilcoxon[[m]][[i]]$p.value)) + { + if(array_wilcoxon[[m]][[i]]$p.value<=sig) + { + tests2 = paste(tests2, initials[m],'C ', sep='') + } + } + } + } + + if (length(array_wilcoxon2)>0) + { + for(p in 1:length(array_wilcoxon2[[1]])) + { + if (length(array_wilcoxon2[[1]][[p]])>0) + { + if(!is.na(array_wilcoxon2[[1]][[p]][[i]]$p.value)) + { + if(array_wilcoxon2[[1]][[p]][[i]]$p.value<=sig) + { + if(nchar(tests3)>line_size && break_aux == 0){ + tests3 = paste(tests3, '\n') + break_aux = 1 + } + tests3 = paste(tests3, array_wilcoxon2[[2]][[p]],'D ',sep='') + } + } + } + } + } + + + max_y = 0 + min_y = 0 + if (measures_names[i] == 'displacement_velocity_hill' ) { + max_y = 2.5 + min_y = -0.5} + if (measures_names[i] == 'head_balance' ) { + max_y = 1 + min_y = 0.6} + if (measures_names[i] == 'absolute_size' ) { max_y = 16} + if (measures_names[i] == 'recurrence' ) { max_y = 0.3} + if (measures_names[i] == 'sensors' ) { max_y = 0.3 } + if (measures_names[i] == 'sensors_reach' ) { max_y = 1 } + + + graph = graph + labs( y=measures_labels[i], x="Generation", title="Tilted Season") + if (max_y>0) { + graph = graph + coord_cartesian(ylim = c(min_y, max_y)) + } + + if(show_markers == TRUE){ + graph = graph + labs( y=measures_labels[i], x="Generation", subtitle = paste(tests1,'\n', tests2, '\n', tests3, sep='')) + } + graph = graph + theme(legend.position="bottom" , legend.text=element_text(size=20), axis.text=element_text(size=27),axis.title=element_text(size=25), + plot.subtitle=element_text(size=25 ),plot.title=element_text(size=25 )) + + ggsave(paste( output_directory,'/',type_summary,'_' ,measures_names[i],'_generations.pdf', sep=''), graph , device='pdf', height = 10, width = 10) + + } + + } + + + + for (i in 1:length(measures_names)) + { + + + all_final_values = data.frame() + for (exp in 1:length(methods)) + { + temp = data.frame( c(measures_fin[[exp]][paste(methods[exp],'_',measures_names[i],'_avg', sep='')])) + colnames(temp) <- 'values' + + temp$type = experiments_labels[exp] + all_final_values = rbind(all_final_values, temp) + } + + g1 <- ggplot(data=all_final_values, aes(x= type , y=values, color=type )) + + geom_boxplot(position = position_dodge(width=0.9),lwd=2, outlier.size = 4) + + labs( x="Environment", y=measures_labels[i], title="Tilted Season") + + max_y = 0 + min_y = 0 + if (measures_names[i] == 'displacement_velocity_hill' ) { + g1 = g1 + geom_hline(yintercept=1.32, linetype="dashed", color = "red", size=2) + max_y = 4.8 + min_y = -0.5} + if (measures_names[i] == 'head_balance'){ + max_y = 1.15 + min_y = 0.55 + } + if (measures_names[i] == 'sensors_reach') { max_y = 1.15} + if (measures_names[i] == 'recurrence' ) { max_y = 0.8} + if (measures_names[i] == 'sensors' ) { max_y = 0.6} + if (measures_names[i] == 'absolute_size' ) { max_y = 16} + + + g1 = g1 + scale_color_manual(values= experiments_type_colors ) + + g1 = g1 + theme(legend.position="none" , text = element_text(size=45) , + plot.title=element_text(size=45), axis.text=element_text(size=45), + axis.title=element_text(size=50), + axis.text.x = element_text(angle = 20, hjust = 0.9), + plot.margin=margin(t = 0.5, r = 0.5, b = 0.5, l = 1.3, unit = "cm"))+ + stat_summary(fun.y = mean, geom="point" ,shape = 16, size=11) + + comps = list( c( 'Baseline', 'Plastic') ) + + g1 = g1 + geom_signif( test="wilcox.test", size=2, textsize=22, + comparisons = comps, + map_signif_level=c("***"=0.001,"**"=0.01, "*"=0.05) ) + if (max_y>0) { + g1 = g1 + coord_cartesian(ylim = c(min_y, max_y)) + } + ggsave(paste(output_directory,"/",measures_names[i],"_boxes.pdf",sep = ""), g1, device = "pdf", height=18, width = 10) + + } + + \ No newline at end of file diff --git a/experiments/plasticoding_frontiers2020/tilted_big.py b/experiments/plasticoding_frontiers2020/tilted_big.py new file mode 100644 index 0000000000..fcc769c2ce --- /dev/null +++ b/experiments/plasticoding_frontiers2020/tilted_big.py @@ -0,0 +1,150 @@ +#!/usr/bin/env python3 +import asyncio + +from pyrevolve import parser +from pyrevolve.evolution import fitness +from pyrevolve.evolution.selection import multiple_selection, tournament_selection +from pyrevolve.evolution.population import Population, PopulationConfig +from pyrevolve.evolution.pop_management.steady_state import steady_state_population_management +from pyrevolve.experiment_management import ExperimentManagement +from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig +from pyrevolve.genotype.plasticoding.crossover.standard_crossover import standard_crossover +from pyrevolve.genotype.plasticoding.initialization import random_initialization +from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig +from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation +from pyrevolve.genotype.plasticoding.plasticoding import PlasticodingConfig +from pyrevolve.tol.manage import measures +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue +from pyrevolve.custom_logging.logger import logger +import sys + +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 200 + population_size = 100 + offspring_size = 100 + front = None + + # environment world and z-start + environments = {'tilted5': 0.1} + + genotype_conf = PlasticodingConfig( + max_structural_modules=15, + plastic=False, + ) + + mutation_conf = MutationConfig( + mutation_prob=0.8, + genotype_conf=genotype_conf, + ) + + crossover_conf = CrossoverConfig( + crossover_prob=0.8, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings, environments) + do_recovery = settings.recovery_enabled and not experiment_management.experiment_is_new() + + logger.info('Activated run '+settings.run+' of experiment '+settings.experiment_name) + + if do_recovery: + gen_num, has_offspring, next_robot_id = experiment_management.read_recovery_state(population_size, + offspring_size) + + if gen_num == num_generations-1: + logger.info('Experiment is already complete.') + return + else: + gen_num = 0 + next_robot_id = 1 + + def fitness_function_tilted(robot_manager, robot): + return fitness.displacement_velocity_hill(robot_manager, robot) + + fitness_function = {'tilted5': fitness_function_tilted} + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness_function, + mutation_operator=standard_mutation, + mutation_conf=mutation_conf, + crossover_operator=standard_crossover, + crossover_conf=crossover_conf, + selection=lambda individuals: tournament_selection(individuals, environments, 2), + parent_selection=lambda individuals: multiple_selection(individuals, 2, tournament_selection, environments), + population_management=steady_state_population_management, + population_management_selector=tournament_selection, + evaluation_time=settings.evaluation_time, + offspring_size=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + environments=environments, + front=front + ) + + settings = parser.parse_args() + + simulator_queue = {} + analyzer_queue = None + + previous_port = None + for environment in environments: + + settings.world = environment + settings.z_start = environments[environment] + + if previous_port is None: + port = settings.port_start + previous_port = port + else: + port = previous_port+settings.n_cores + previous_port = port + + simulator_queue[environment] = SimulatorQueue(settings.n_cores, settings, port) + await simulator_queue[environment].start() + + analyzer_queue = AnalyzerQueue(1, settings, port+settings.n_cores) + await analyzer_queue.start() + + population = Population(population_conf, simulator_queue, analyzer_queue, next_robot_id) + + if do_recovery: + + if gen_num >= 0: + # loading a previous state of the experiment + await population.load_snapshot(gen_num) + logger.info('Recovered snapshot '+str(gen_num)+', pop with ' + str(len(population.individuals))+' individuals') + + if has_offspring: + individuals = await population.load_offspring(gen_num, population_size, offspring_size, next_robot_id) + gen_num += 1 + logger.info('Recovered unfinished offspring '+str(gen_num)) + + if gen_num == 0: + await population.init_pop(individuals) + else: + population = await population.next_gen(gen_num, individuals) + + experiment_management.export_snapshots(population.individuals, gen_num) + else: + # starting a new experiment + experiment_management.create_exp_folders() + await population.init_pop() + experiment_management.export_snapshots(population.individuals, gen_num) + + while gen_num < num_generations-1: + gen_num += 1 + population = await population.next_gen(gen_num) + experiment_management.export_snapshots(population.individuals, gen_num) + + # output result after completing all generations... diff --git a/pyrevolve/evolution/fitness.py b/pyrevolve/evolution/fitness.py index 95be1c03cf..f939acb2db 100644 --- a/pyrevolve/evolution/fitness.py +++ b/pyrevolve/evolution/fitness.py @@ -57,21 +57,26 @@ def online_old_revolve(robot_manager): return v if v <= fitness_limit else 0.0 +def size_penalty(robot_manager, robot): + _size_penalty = 1 / robot.phenotype._morphological_measurements.measurements_to_dict()['absolute_size'] + + return _size_penalty + + def displacement_velocity_hill(robot_manager, robot): - _displacement_velocity_hill = measures.displacement_velocity_hill(robot_manager) - if _displacement_velocity_hill < 0: - _displacement_velocity_hill /= 10 - elif _displacement_velocity_hill == 0: - _displacement_velocity_hill = -0.1 - # temp elif - # elif _displacement_velocity_hill > 0: - # _displacement_velocity_hill *= _displacement_velocity_hill + fitness = measures.displacement_velocity_hill(robot_manager) - return _displacement_velocity_hill + if fitness == 0 or robot.phenotype._morphological_measurements.measurements_to_dict()['hinge_count'] == 0: + fitness = -0.1 + + elif fitness < 0: + fitness /= 10 + + return fitness def floor_is_lava(robot_manager, robot): - _displacement_velocity_hill = measures.displacement_velocity_hill(robot_manager) + _displacement_velocity_hill = displacement_velocity_hill(robot_manager, robot) _contacts = measures.contacts(robot_manager, robot) _contacts = max(_contacts, 0.0001) diff --git a/pyrevolve/evolution/individual.py b/pyrevolve/evolution/individual.py index c2448b3423..89cc542d82 100644 --- a/pyrevolve/evolution/individual.py +++ b/pyrevolve/evolution/individual.py @@ -1,27 +1,29 @@ # (G,P) +import pickle class Individual: + def __init__(self, genotype, phenotype=None): """ Creates an Individual object with the given genotype and optionally the phenotype. - :param genotype: genotype of the individual :param phenotype (optional): phenotype of the individual """ self.genotype = genotype self.phenotype = phenotype self.fitness = None + self.consolidated_fitness = None + self.evaluated = False self.parents = None self.failed_eval_attempt_count = 0 - def develop(self): + def develop(self, environment): """ Develops genotype into a intermediate phenotype - """ if self.phenotype is None: - self.phenotype = self.genotype.develop() + self.phenotype = self.genotype.develop(environment) @property def id(self): @@ -47,6 +49,15 @@ def export_fitness(self, folder): with open(f'{folder}/fitness_{self.id}.txt', 'w') as f: f.write(str(self.fitness)) + def export_consolidated_fitness(self, folder): + with open(f'{folder}/consolidated_fitness_{self.id}.txt', 'w') as f: + f.write(str(self.consolidated_fitness)) + + def export_individual(self, folder): + f = open(f'{folder}/individuals/individual_{self.id}.pkl', "wb") + pickle.dump(self, f) + f.close() + def export(self, folder): self.export_genotype(folder) self.export_phenotype(folder) diff --git a/pyrevolve/evolution/pop_management/steady_state.py b/pyrevolve/evolution/pop_management/steady_state.py index 1f675664c7..b4e357d7d3 100644 --- a/pyrevolve/evolution/pop_management/steady_state.py +++ b/pyrevolve/evolution/pop_management/steady_state.py @@ -1,8 +1,7 @@ from pyrevolve.evolution.selection import multiple_selection -def steady_state_population_management(old_individuals, new_individuals, selector): - pop_size = len(old_individuals) - selection_pool = old_individuals + new_individuals +def steady_state_population_management(selection_pool, selector, conf): + pop_size = conf.population_size - return multiple_selection(selection_pool, pop_size, selector) + return multiple_selection(selection_pool, pop_size, selector, conf.environments) diff --git a/pyrevolve/evolution/population.py b/pyrevolve/evolution/population.py index 45ad959032..8f869d919a 100644 --- a/pyrevolve/evolution/population.py +++ b/pyrevolve/evolution/population.py @@ -1,12 +1,11 @@ # [(G,P), (G,P), (G,P), (G,P), (G,P)] from pyrevolve.evolution.individual import Individual -from pyrevolve.SDF.math import Vector3 -from pyrevolve.tol.manage import measures from ..custom_logging.logger import logger -import time import asyncio +import copy import os +import pickle class PopulationConfig: @@ -26,6 +25,8 @@ def __init__(self, evaluation_time, experiment_name, experiment_management, + environments, + front, offspring_size=None, next_robot_id=1): """ @@ -61,11 +62,14 @@ def __init__(self, self.evaluation_time = evaluation_time self.experiment_name = experiment_name self.experiment_management = experiment_management + self.environments = environments + self.front = front self.offspring_size = offspring_size self.next_robot_id = next_robot_id class Population: + def __init__(self, conf: PopulationConfig, simulator_queue, analyzer_queue=None, next_robot_id=1): """ Creates a Population object that initialises the @@ -85,58 +89,54 @@ def __init__(self, conf: PopulationConfig, simulator_queue, analyzer_queue=None, self.next_robot_id = next_robot_id def _new_individual(self, genotype): - individual = Individual(genotype) - individual.develop() - self.conf.experiment_management.export_genotype(individual) - self.conf.experiment_management.export_phenotype(individual) - self.conf.experiment_management.export_phenotype_images(os.path.join('data_fullevolution', 'phenotype_images'), individual) - individual.phenotype.measure_phenotype() - individual.phenotype.export_phenotype_measurements(self.conf.experiment_management.data_folder) + + individual = {} + individual_temp = Individual(genotype) + + for environment in self.conf.environments: + + individual[environment] = copy.deepcopy(individual_temp) + individual[environment].develop(environment) + + if len(individual) == 1: + self.conf.experiment_management.export_genotype(individual[environment]) + + for environment in self.conf.environments: + + self.conf.experiment_management.export_phenotype(individual[environment], environment) + self.conf.experiment_management.export_phenotype_images(os.path.join('data_fullevolution', + environment, 'phenotype_images'), + individual[environment]) + individual[environment].phenotype.measure_phenotype(self.conf.experiment_name) + individual[environment].phenotype.export_phenotype_measurements(self.conf.experiment_name, environment) + self.conf.experiment_management.export_individual(individual[environment], environment) return individual async def load_individual(self, id): - data_path = self.conf.experiment_management.data_folder - genotype = self.conf.genotype_constructor(self.conf.genotype_conf, id) - genotype.load_genotype(os.path.join(data_path, 'genotypes', f'genotype_{id}.txt')) - - individual = Individual(genotype) - individual.develop() - individual.phenotype.measure_phenotype() - - with open(os.path.join(data_path, 'fitness', f'fitness_{id}.txt')) as f: - data = f.readlines()[0] - individual.fitness = None if data == 'None' else float(data) - - with open(os.path.join(data_path, 'descriptors', f'behavior_desc_{id}.txt')) as f: - lines = f.readlines() - if lines[0] == 'None': - individual.phenotype._behavioural_measurements = None - else: - individual.phenotype._behavioural_measurements = measures.BehaviouralMeasurements() - for line in lines: - if line.split(' ')[0] == 'velocity': - individual.phenotype._behavioural_measurements.velocity = float(line.split(' ')[1]) - #if line.split(' ')[0] == 'displacement': - # individual.phenotype._behavioural_measurements.displacement = float(line.split(' ')[1]) - if line.split(' ')[0] == 'displacement_velocity': - individual.phenotype._behavioural_measurements.displacement_velocity = float(line.split(' ')[1]) - if line.split(' ')[0] == 'displacement_velocity_hill': - individual.phenotype._behavioural_measurements.displacement_velocity_hill = float(line.split(' ')[1]) - if line.split(' ')[0] == 'head_balance': - individual.phenotype._behavioural_measurements.head_balance = float(line.split(' ')[1]) - if line.split(' ')[0] == 'contacts': - individual.phenotype._behavioural_measurements.contacts = float(line.split(' ')[1]) + path = 'experiments/'+self.conf.experiment_name+'/data_fullevolution' + + individual = {} + for environment in self.conf.environments: + try: + file_name = os.path.join(path, environment,'individuals','individual_'+id+'.pkl') + file = open(file_name, 'rb') + individual[environment] = pickle.load(file) + except EOFError: + print('bad pickle for robot', id, ' was replaced for new robot with None fitness') + individual = self._new_individual( + self.conf.genotype_constructor(self.conf.genotype_conf, id)) return individual async def load_snapshot(self, gen_num): """ - Recovers all genotypes and fitnesses of robots in the lastest selected population + Recovers all genotypes and fitnesses of robots in the latest selected population :param gen_num: number of the generation snapshot to recover """ - data_path = self.conf.experiment_management.experiment_folder - for r, d, f in os.walk(data_path +'/selectedpop_'+str(gen_num)): + path = 'experiments/'+self.conf.experiment_name + for r, d, f in os.walk(os.path.join(path,'selectedpop_'+ + list(self.conf.environments.keys())[-1],'selectedpop_'+str(gen_num))): for file in f: if 'body' in file: id = file.split('.')[0].split('_')[-2]+'_'+file.split('.')[0].split('_')[-1] @@ -158,21 +158,112 @@ async def load_offspring(self, last_snapshot, population_size, offspring_size, n for robot_id in range(n_robots+1, next_robot_id): individuals.append(await self.load_individual('robot_'+str(robot_id))) - self.next_robot_id = next_robot_id return individuals + async def consolidate_fitness(self, individuals): + + last_environment = list(self.conf.environments.keys())[-1] + + if len(self.conf.environments) == 1: + for individual in individuals: + individual[last_environment].consolidated_fitness = individual[last_environment].fitness + + # if there are multiple seasons (environments) + else: + for individual_ref in individuals: + + slaves = 0 + total_slaves = 0 + total_masters = 0 + masters = 0 + + # this BIZARRE logic works only for two seasons! shame on me! fix it later! + for individual_comp in individuals: + + equal = 0 + better = 0 + + for environment in self.conf.environments: + if individual_ref[environment].fitness is None \ + and individual_comp[environment].fitness is None: + equal += 1 + + if individual_ref[environment].fitness is None \ + and individual_comp[environment].fitness is not None: + equal += -1 + + if individual_ref[environment].fitness is not None \ + and individual_comp[environment].fitness is None: + better += 1 + + if individual_ref[environment].fitness is not None \ + and individual_comp[environment].fitness is not None: + + if individual_ref[environment].fitness > individual_comp[environment].fitness: + better += 1 + + if individual_ref[environment].fitness < individual_comp[environment].fitness: + equal += -1 + + if individual_ref[environment].fitness == individual_comp[environment].fitness: + equal += 1 + + # if it ref is not worse in any objective, and better in at least one, the comp becomes slave of ref + if equal >= 0 and better > 0: + slaves += 1 + + # if better in all objectives + if better == len(self.conf.environments): + total_slaves += 1 + + # if it is totally worse + if equal < 0 and better == 0: + total_masters += 1 + + # if it is worse + if equal <= 0 and better == 0: + masters += 1 + + if self.conf.front == 'slaves': + individual_ref[last_environment].consolidated_fitness = slaves + + if self.conf.front == 'total_slaves': + individual_ref[last_environment].consolidated_fitness = total_slaves + + if self.conf.front == 'total_masters': + if total_masters == 0: + individual_ref[last_environment].consolidated_fitness = 0 + else: + individual_ref[last_environment].consolidated_fitness = 1/total_masters + + if self.conf.front == 'masters': + if masters == 0: + individual_ref[last_environment].consolidated_fitness = 0 + else: + individual_ref[last_environment].consolidated_fitness = 1/masters + + for individual in individuals: + self.conf.experiment_management.export_consolidated_fitness(individual[last_environment]) + + self.conf.experiment_management.export_individual(individual[last_environment], last_environment) + async def init_pop(self, recovered_individuals=[]): """ Populates the population (individuals list) with Individual objects that contains their respective genotype. """ for i in range(self.conf.population_size-len(recovered_individuals)): - individual = self._new_individual(self.conf.genotype_constructor(self.conf.genotype_conf, self.next_robot_id)) + individual = self._new_individual( + self.conf.genotype_constructor(self.conf.genotype_conf, self.next_robot_id)) self.individuals.append(individual) self.next_robot_id += 1 - await self.evaluate(self.individuals, 0) self.individuals = recovered_individuals + self.individuals + for environment in self.conf.environments: + await self.evaluate(new_individuals=self.individuals, gen_num=0, environment=environment) + + await self.consolidate_fitness(self.individuals) + async def next_gen(self, gen_num, recovered_individuals=[]): """ Creates next generation of the population through selection, mutation, crossover @@ -189,7 +280,10 @@ async def next_gen(self, gen_num, recovered_individuals=[]): # Crossover if self.conf.crossover_operator is not None: parents = self.conf.parent_selection(self.individuals) - child_genotype = self.conf.crossover_operator(parents, self.conf.genotype_conf, self.conf.crossover_conf) + child_genotype = self.conf.crossover_operator(self.conf.environments, + parents, + self.conf.genotype_conf, + self.conf.crossover_conf) child = Individual(child_genotype) else: child = self.conf.selection(self.individuals) @@ -198,30 +292,39 @@ async def next_gen(self, gen_num, recovered_individuals=[]): self.next_robot_id += 1 # Mutation operator - child_genotype = self.conf.mutation_operator(child.genotype, self.conf.mutation_conf) + child_genotype = self.conf.mutation_operator(child.genotype, + self.conf.mutation_conf) + # Insert individual in new population individual = self._new_individual(child_genotype) - new_individuals.append(individual) + new_individuals = recovered_individuals + new_individuals + # evaluate new individuals - await self.evaluate(new_individuals, gen_num) + for environment in self.conf.environments: + await self.evaluate(new_individuals=new_individuals, gen_num=gen_num, environment=environment) - new_individuals = recovered_individuals + new_individuals + selection_pool = self.individuals + new_individuals + + await self.consolidate_fitness(selection_pool) # create next population if self.conf.population_management_selector is not None: - new_individuals = self.conf.population_management(self.individuals, new_individuals, - self.conf.population_management_selector) + new_individuals = self.conf.population_management(selection_pool, + self.conf.population_management_selector, + self.conf) else: - new_individuals = self.conf.population_management(self.individuals, new_individuals) + new_individuals = self.conf.population_management(self.individuals, new_individuals, self.conf) + new_population = Population(self.conf, self.simulator_queue, self.analyzer_queue, self.next_robot_id) new_population.individuals = new_individuals + logger.info(f'Population selected in gen {gen_num} with {len(new_population.individuals)} individuals...') return new_population - async def evaluate(self, new_individuals, gen_num, type_simulation = 'evolve'): + async def evaluate(self, new_individuals, gen_num, environment, type_simulation = 'evolve'): """ Evaluates each individual in the new gen population @@ -231,14 +334,20 @@ async def evaluate(self, new_individuals, gen_num, type_simulation = 'evolve'): # Parse command line / file input arguments # await self.simulator_connection.pause(True) robot_futures = [] + to_evaluate = [] for individual in new_individuals: - logger.info(f'Evaluating individual (gen {gen_num}) {individual.genotype.id} ...') - robot_futures.append(asyncio.ensure_future(self.evaluate_single_robot(individual))) + if not individual[environment].evaluated: + logger.info(f'Evaluating individual (gen {gen_num}) {individual[environment].genotype.id} ...') + to_evaluate.append(individual) + robot_futures.append(asyncio.ensure_future(self.evaluate_single_robot(individual[environment], + environment))) + individual[environment].evaluated = True await asyncio.sleep(1) for i, future in enumerate(robot_futures): - individual = new_individuals[i] + individual = to_evaluate[i][environment] + logger.info(f'Evaluation of Individual {individual.phenotype.id}') individual.fitness, individual.phenotype._behavioural_measurements = await future @@ -246,24 +355,44 @@ async def evaluate(self, new_individuals, gen_num, type_simulation = 'evolve'): assert (individual.fitness is None) if type_simulation == 'evolve': - self.conf.experiment_management.export_behavior_measures(individual.phenotype.id, individual.phenotype._behavioural_measurements) + self.conf.experiment_management.export_behavior_measures(individual.phenotype.id, + individual.phenotype._behavioural_measurements, + environment) logger.info(f'Individual {individual.phenotype.id} has a fitness of {individual.fitness}') if type_simulation == 'evolve': - self.conf.experiment_management.export_fitness(individual) - - async def evaluate_single_robot(self, individual): + self.conf.experiment_management.export_fitness(individual, environment) + self.conf.experiment_management.export_individual(individual, environment) + + # async def evaluate_single_robot(self, individual, environment): + # """ + # :param individual: individual + # :return: Returns future of the evaluation, future returns (fitness, [behavioural] measurements) + # """ + # + # if self.analyzer_queue is not None: + # collisions, _bounding_box = await self.analyzer_queue.test_robot(individual, + # self.conf) + # if collisions > 0: + # logger.info(f"discarding robot {individual} because there are {collisions} self collisions") + # return None, None + # + # return await self.simulator_queue[environment].test_robot(individual, self.conf) + + async def evaluate_single_robot(self, individual, environment): """ :param individual: individual :return: Returns future of the evaluation, future returns (fitness, [behavioural] measurements) """ - if individual.phenotype is None: - individual.develop() + + conf = copy.deepcopy(self.conf) + conf.fitness_function = conf.fitness_function[environment] if self.analyzer_queue is not None: - collisions, _bounding_box = await self.analyzer_queue.test_robot(individual, self.conf) + collisions, _bounding_box = await self.analyzer_queue.test_robot(individual, + conf) if collisions > 0: logger.info(f"discarding robot {individual} because there are {collisions} self collisions") return None, None - return await self.simulator_queue.test_robot(individual, self.conf) + return await self.simulator_queue[environment].test_robot(individual, conf) \ No newline at end of file diff --git a/pyrevolve/evolution/selection.py b/pyrevolve/evolution/selection.py index 9b3e06cb8c..631aad5fe0 100644 --- a/pyrevolve/evolution/selection.py +++ b/pyrevolve/evolution/selection.py @@ -3,13 +3,18 @@ _neg_inf = -float('Inf') -def _compare_maj_fitness(indiv_1, indiv_2): - fit_1 = _neg_inf if indiv_1.fitness is None else indiv_1.fitness - fit_2 = _neg_inf if indiv_2.fitness is None else indiv_2.fitness +def _compare_maj_fitness(indiv_1, indiv_2, environments): + environment = list(environments.keys())[-1] + fit_1 = indiv_1[environment].consolidated_fitness + fit_2 = indiv_2[environment].consolidated_fitness + + fit_1 = _neg_inf if fit_1 is None else fit_1 + fit_2 = _neg_inf if fit_2 is None else fit_2 + return fit_1 > fit_2 -def tournament_selection(population, k=2): +def tournament_selection(population, environments, k=2): """ Perform tournament selection and return best individual :param k: amount of individuals to participate in tournament @@ -17,12 +22,12 @@ def tournament_selection(population, k=2): best_individual = None for _ in range(k): individual = population[randint(0, len(population) - 1)] - if (best_individual is None) or (_compare_maj_fitness(individual, best_individual)): + if (best_individual is None) or (_compare_maj_fitness(individual, best_individual, environments)): best_individual = individual return best_individual -def multiple_selection(population, selection_size, selection_function): +def multiple_selection(population, selection_size, selection_function, environments): """ Perform selection on population of distinct group, can be used in the form parent selection or survival selection :param population: parent selection in population @@ -34,7 +39,7 @@ def multiple_selection(population, selection_size, selection_function): for _ in range(selection_size): new_individual = False while new_individual is False: - selected_individual = selection_function(population) + selected_individual = selection_function(population, environments) if selected_individual not in selected_individuals: selected_individuals.append(selected_individual) new_individual = True diff --git a/pyrevolve/experiment_management.py b/pyrevolve/experiment_management.py index af9f38207c..dca4305370 100644 --- a/pyrevolve/experiment_management.py +++ b/pyrevolve/experiment_management.py @@ -8,51 +8,56 @@ class ExperimentManagement: # ids of robots in the name of all types of files are always phenotype ids, and the standard for id is 'robot_ID' - def __init__(self, settings): + def __init__(self, settings, environments): self.settings = settings - manager_folder = os.path.dirname(self.settings.manager) - self._experiment_folder = os.path.join(manager_folder, 'data', self.settings.experiment_name, self.settings.run) - self._data_folder = os.path.join(self._experiment_folder, 'data_fullevolution') + self.environments = environments + self.dirpath = os.path.join('experiments', self.settings.experiment_name) def create_exp_folders(self): - if os.path.exists(self.experiment_folder): - shutil.rmtree(self.experiment_folder) - os.makedirs(self.experiment_folder) - os.mkdir(self.data_folder) - os.mkdir(os.path.join(self.data_folder, 'genotypes')) - os.mkdir(os.path.join(self.data_folder, 'phenotypes')) - os.mkdir(os.path.join(self.data_folder, 'descriptors')) - os.mkdir(os.path.join(self.data_folder, 'fitness')) - os.mkdir(os.path.join(self.data_folder, 'phenotype_images')) - os.mkdir(os.path.join(self.data_folder, 'failed_eval_robots')) - - @property - def experiment_folder(self): - return self._experiment_folder - - @property - def data_folder(self): - return self._data_folder + if os.path.exists(self.dirpath): + shutil.rmtree(self.dirpath) + os.mkdir(self.dirpath) + os.mkdir(self.dirpath+'/data_fullevolution') + os.mkdir(self.dirpath+'/data_fullevolution/genotypes') + os.mkdir(self.dirpath+'/data_fullevolution/consolidated_fitness') + os.mkdir(self.dirpath+'/data_fullevolution/failed_eval_robots') + for environment in self.environments: + os.mkdir(self.dirpath+'/selectedpop_'+environment) + os.mkdir(self.dirpath+'/data_fullevolution/'+environment) + os.mkdir(self.dirpath+'/data_fullevolution/'+environment+'/individuals') + os.mkdir(self.dirpath+'/data_fullevolution/'+environment+'/phenotypes') + os.mkdir(self.dirpath+'/data_fullevolution/'+environment+'/descriptors') + os.mkdir(self.dirpath+'/data_fullevolution/'+environment+'/fitness') + os.mkdir(self.dirpath+'/data_fullevolution/'+environment+'/phenotype_images') + + def _experiment_folder(self): + return self.dirpath + + def _data_folder(self): + return os.path.join(self.dirpath, 'data_fullevolution') def export_genotype(self, individual): if self.settings.recovery_enabled: - individual.export_genotype(self.data_folder) + individual.export_genotype(self._data_folder()) - def export_phenotype(self, individual): + def export_phenotype(self, individual, environment): if self.settings.export_phenotype: - individual.export_phenotype(self.data_folder) + individual.export_phenotype(self._data_folder()+'/'+environment) - def export_fitnesses(self, individuals): - folder = self.data_folder - for individual in individuals: - individual.export_fitness(folder) - - def export_fitness(self, individual): - folder = os.path.join(self.data_folder, 'fitness') + def export_fitness(self, individual, environment): + folder = os.path.join(self._data_folder(), environment, 'fitness') individual.export_fitness(folder) - def export_behavior_measures(self, _id, measures): - filename = os.path.join(self.data_folder, 'descriptors', f'behavior_desc_{_id}.txt') + def export_consolidated_fitness(self, individual): + folder = os.path.join(self._data_folder(), 'consolidated_fitness') + individual.export_consolidated_fitness(folder) + + def export_individual(self, individual, environment): + folder = self._data_folder()+'/'+environment + individual.export_individual(folder) + + def export_behavior_measures(self, _id, measures, environment): + filename = os.path.join(self._data_folder()+'/'+environment, 'descriptors', f'behavior_desc_{_id}.txt') with open(filename, "w") as f: if measures is None: f.write(str(None)) @@ -61,41 +66,51 @@ def export_behavior_measures(self, _id, measures): f.write(f"{key} {val}\n") def export_phenotype_images(self, dirpath, individual): - individual.phenotype.render_body(os.path.join(self.experiment_folder, dirpath, f'body_{individual.phenotype.id}.png')) - individual.phenotype.render_brain(os.path.join(self.experiment_folder, dirpath, f'brain_{individual.phenotype.id}.png')) + individual.phenotype.render_body(self._experiment_folder()+'/'+dirpath+f'/body_{individual.phenotype.id}.png') + individual.phenotype.render_brain(self._experiment_folder()+'/'+dirpath+f'/brain_{individual.phenotype.id}') def export_failed_eval_robot(self, individual): - individual.genotype.export_genotype(os.path.join(self.data_folder, 'failed_eval_robots', f'genotype_{individual.phenotype.id}.txt')) - individual.phenotype.save_file(os.path.join(self.data_folder, 'failed_eval_robots', f'phenotype_{individual.phenotype.id}.yaml')) - individual.phenotype.save_file(os.path.join(self.data_folder, 'failed_eval_robots', f'phenotype_{individual.phenotype.id}.sdf'), conf_type='sdf') + individual.genotype.export_genotype(f'{self._data_folder()}/failed_eval_robots/genotype_{str(individual.phenotype.id)}.txt') + individual.phenotype.save_file(f'{self._data_folder()}/failed_eval_robots/phenotype_{str(individual.phenotype.id)}.yaml') + individual.phenotype.save_file(f'{self._data_folder()}/failed_eval_robots/phenotype_{str(individual.phenotype.id)}.sdf', conf_type='sdf') def export_snapshots(self, individuals, gen_num): if self.settings.recovery_enabled: - path = os.path.join(self.experiment_folder, f'selectedpop_{gen_num}') - if os.path.exists(path): - shutil.rmtree(path) - os.mkdir(path) - for ind in individuals: - self.export_phenotype_images(f'selectedpop_{str(gen_num)}', ind) - logger.info(f'Exported snapshot {str(gen_num)} with {str(len(individuals))} individuals') + for environment in self.environments: + path = os.path.join(self._experiment_folder()+'/selectedpop_'+environment, f'selectedpop_{gen_num}') + if os.path.exists(path): + shutil.rmtree(path) + os.mkdir(path) + + for ind in individuals: + self.export_phenotype_images('selectedpop_'+environment+'/'+f'selectedpop_{str(gen_num)}', ind[environment]) + logger.info(f'Exported snapshot {str(gen_num)} with {str(len(individuals))} individuals') def experiment_is_new(self): - if not os.path.exists(self.experiment_folder): + if not os.path.exists(self._experiment_folder()): return True - path, dirs, files = next(os.walk(os.path.join(self.data_folder, 'fitness'))) - if len(files) == 0: - return True - else: - return False + # if any robot in any environment has been finished + for environment in self.environments: + path, dirs, files = next(os.walk(os.path.join(self._data_folder()+'/'+environment, 'individuals'))) + if len(files) > 0: + return False + + return True def read_recovery_state(self, population_size, offspring_size): snapshots = [] - for r, d, f in os.walk(self.experiment_folder): + # checks existent robots using the last environment of the dict as reference + path = self._experiment_folder()+'/selectedpop_'+list(self.environments.keys())[-1] + for r, d, f in os.walk(path): for dir in d: if 'selectedpop' in dir: - exported_files = len([name for name in os.listdir(os.path.join(self.experiment_folder, dir)) if os.path.isfile(os.path.join(self.experiment_folder, dir, name))]) - if exported_files == (population_size * 2): # body and brain files + exported_files = len([name for name in os.listdir(os.path.join(path, + dir)) + if os.path.isfile(os.path.join(path, dir, name))]) + + # snapshot is complete if all body/brain files exist + if exported_files == (population_size * 2): snapshots.append(int(dir.split('_')[1])) if len(snapshots) > 0: @@ -107,8 +122,11 @@ def read_recovery_state(self, population_size, offspring_size): last_snapshot = -1 n_robots = 0 + # if a robot is developed in the last environment robot_ids = [] - for r, d, f in os.walk(os.path.join(self.data_folder, 'fitness')): + last_id = 0 + environment = list(self.environments.keys())[-1] + for r, d, f in os.walk(os.path.join(self._data_folder()+'/'+environment, 'individuals')): for file in f: robot_ids.append(int(file.split('.')[0].split('_')[-1])) last_id = np.sort(robot_ids)[-1] diff --git a/pyrevolve/experiment_management_tmp.py b/pyrevolve/experiment_management_tmp.py new file mode 100644 index 0000000000..4a0066d9b7 --- /dev/null +++ b/pyrevolve/experiment_management_tmp.py @@ -0,0 +1,144 @@ +import os +import shutil +import numpy as np +from pyrevolve.custom_logging.logger import logger +import sys + + +class ExperimentManagement: + # ids of robots in the name of all types of files are always phenotype ids, and the standard for id is 'robot_ID' + + def __init__(self, settings, environments): + self.settings = settings + self.environments = environments + manager_folder = os.path.dirname(self.settings.manager) + self._experiment_folder = os.path.join(manager_folder, 'data', self.settings.experiment_name, self.settings.run) + self._data_folder = os.path.join(self._experiment_folder, 'data_fullevolution') + + def create_exp_folders(self): + if os.path.exists(self.experiment_folder): + shutil.rmtree(self.experiment_folder) + os.makedirs(self.experiment_folder) + os.mkdir(self.data_folder) + os.mkdir(os.path.join(self.data_folder, 'genotypes')) + os.mkdir(os.path.join(self.data_folder, 'failed_eval_robots')) + + for environment in self.environments: + os.mkdir(os.path.join(self.experiment_folder, f'selectedpop_{environment}')) + os.mkdir(os.path.join(self.data_folder, environment)) + os.mkdir(os.path.join(self.data_folder, environment, 'individuals')) + os.mkdir(os.path.join(self.data_folder, environment, 'phenotypes')) + os.mkdir(os.path.join(self.data_folder, environment, 'descriptors')) + os.mkdir(os.path.join(self.data_folder, environment, 'fitness')) + os.mkdir(os.path.join(self.data_folder, environment, 'phenotype_images')) + + @property + def experiment_folder(self): + return self._experiment_folder + + @property + def data_folder(self): + return self._data_folder + + def export_genotype(self, individual): + if self.settings.recovery_enabled: + individual.export_genotype(self.data_folder) + + def export_phenotype(self, individual, environment): + if self.settings.export_phenotype: + individual.export_phenotype(os.path.join(self.data_folder, environment)) + + def export_fitnesses(self, individuals, environment): + folder = self.data_folder + for individual in individuals: + individual.export_fitness(os.path.join(folder, environment)) + + def export_fitness(self, individual, environment): + folder = os.path.join(self.data_folder, environment, 'fitness') + individual.export_fitness(folder) + + def export_individual(self, individual, environment): + folder = os.path.join(self.data_folder, environment) + individual.export_individual(folder) + + def export_behavior_measures(self, _id, measures, environment): + filename = os.path.join(self.data_folder, environment, 'descriptors', f'behavior_desc_{_id}.txt') + with open(filename, "w") as f: + if measures is None: + f.write(str(None)) + else: + for key, val in measures.items(): + f.write(f"{key} {val}\n") + + def export_phenotype_images(self, dirpath, individual): + individual.phenotype.render_body(os.path.join(self.experiment_folder, dirpath, f'body_{individual.phenotype.id}.png')) + individual.phenotype.render_brain(os.path.join(self.experiment_folder, dirpath, f'brain_{individual.phenotype.id}.png')) + + def export_failed_eval_robot(self, individual): + individual.genotype.export_genotype(os.path.join(self.data_folder, 'failed_eval_robots', f'genotype_{individual.phenotype.id}.txt')) + individual.phenotype.save_file(os.path.join(self.data_folder, 'failed_eval_robots', f'phenotype_{individual.phenotype.id}.yaml')) + individual.phenotype.save_file(os.path.join(self.data_folder, 'failed_eval_robots', f'phenotype_{individual.phenotype.id}.sdf'), conf_type='sdf') + + def export_snapshots(self, individuals, gen_num): + if self.settings.recovery_enabled: + for environment in self.environments: + path = os.path.join(self.experiment_folder, f'selectedpop{environment}', f'selectedpop_{gen_num}') + if os.path.exists(path): + shutil.rmtree(path) + os.mkdir(path) + + for ind in individuals: + self.export_phenotype_images(os.path.join(f'selectedpop_{environment}', f'selectedpop_{str(gen_num)}', ind[environment])) + logger.info(f'Exported snapshot {str(gen_num)} with {str(len(individuals))} individuals') + + def experiment_is_new(self): + if not os.path.exists(self.experiment_folder): + return True + # if any robot in any environment has been finished + for environment in self.environments: + path, dirs, files = next(os.walk(os.path.join(self.data_folder, environment, 'individuals'))) + if len(files) > 0: + return False + return True + + def read_recovery_state(self, population_size, offspring_size): + snapshots = [] + + # checks existent robots using the last environment of the dict as reference + last_env = list(self.environments.keys())[-1] + environment_snapshot_path = os.path.join(self.experiment_folder, f'selectedpop_{last_env}') + for r, d, f in os.walk(environment_snapshot_path): + for dir in d: + if 'selectedpop' in dir: + exported_files = len([name for name in os.listdir(os.path.join(environment_snapshot_path, dir)) + if os.path.isfile(os.path.join(environment_snapshot_path, dir, name))]) + + # snapshot is complete if all body/brain files exist + if exported_files == (population_size * 2): + snapshots.append(int(dir.split('_')[1])) + + if len(snapshots) > 0: + # the latest complete snapshot + last_snapshot = np.sort(snapshots)[-1] + # number of robots expected until the snapshot + n_robots = population_size + last_snapshot * offspring_size + else: + last_snapshot = -1 + n_robots = 0 + + # if a robot is developed in any of the environments, then it exists + robot_ids = [] + for environment in self.environments: + for r, d, f in os.walk(os.path.join(self.data_folder, environment, 'individuals')): + for file in f: + robot_ids.append(int(file.split('.')[0].split('_')[-1])) + last_id = np.sort(robot_ids)[-1] + + # if there are more robots to recover than the number expected in this snapshot + if last_id > n_robots: + # then recover also this partial offspring + has_offspring = True + else: + has_offspring = False + + return last_snapshot, has_offspring, last_id+1 diff --git a/pyrevolve/genotype/genotype.py b/pyrevolve/genotype/genotype.py index 4317fad3f4..1f632f69b0 100644 --- a/pyrevolve/genotype/genotype.py +++ b/pyrevolve/genotype/genotype.py @@ -5,7 +5,7 @@ def clone(self): """ raise NotImplementedError("Method must be implemented by genome") - def develop(self): + def develop(self, environment): """ Develops the genome into a revolve_bot (proto-phenotype) @@ -23,7 +23,12 @@ def __init__(self, weight_min, weight_max, oscillator_param_min, - oscillator_param_max): + oscillator_param_max, + max_clauses, + max_terms_clause, + plastic, + environmental_conditions, + logic_operators): self.e_max_groups = e_max_groups self.axiom_w = axiom_w self.i_iterations = i_iterations @@ -31,3 +36,8 @@ def __init__(self, self.weight_max = weight_max self.oscillator_param_min = oscillator_param_min self.oscillator_param_max = oscillator_param_max + self.max_clauses = max_clauses + self.max_terms_clause = max_terms_clause + self.plastic = plastic + self.environmental_conditions = environmental_conditions + self.logic_operators = logic_operators diff --git a/pyrevolve/genotype/plasticoding/crossover/standard_crossover.py b/pyrevolve/genotype/plasticoding/crossover/standard_crossover.py index d95ad6286c..2c0afad436 100644 --- a/pyrevolve/genotype/plasticoding/crossover/standard_crossover.py +++ b/pyrevolve/genotype/plasticoding/crossover/standard_crossover.py @@ -27,15 +27,18 @@ def generate_child_genotype(parent_genotypes, genotype_conf, crossover_conf): return genotype.clone() -def standard_crossover(parent_individuals, genotype_conf, crossover_conf): +def standard_crossover(environments, parent_individuals, genotype_conf, crossover_conf): """ Creates an child (individual) through crossover with two parents :param parent_genotypes: genotypes of the parents to be used for crossover :return: genotype result of the crossover """ - parent_genotypes = [p.genotype for p in parent_individuals] + first_environment = list(environments.keys())[-1] + + parent_genotypes = [p[first_environment].genotype for p in parent_individuals] new_genotype = generate_child_genotype(parent_genotypes, genotype_conf, crossover_conf) + #TODO what if you have more than 2 parents? fix log genotype_logger.info( f'crossover: for genome {new_genotype.id} - p1: {parent_genotypes[0].id} p2: {parent_genotypes[1].id}.') diff --git a/pyrevolve/genotype/plasticoding/initialization.py b/pyrevolve/genotype/plasticoding/initialization.py index 7f784313f0..f5583f231c 100644 --- a/pyrevolve/genotype/plasticoding/initialization.py +++ b/pyrevolve/genotype/plasticoding/initialization.py @@ -1,6 +1,7 @@ from pyrevolve.genotype.plasticoding.plasticoding import Plasticoding from pyrevolve.genotype.plasticoding.plasticoding import Alphabet import random +import pprint def _generate_random_grammar(conf): @@ -47,6 +48,86 @@ def _generate_random_grammar(conf): return grammar +def _generate_random_plastic_grammar(conf): + """ + Initializing a new genotype, + :param conf: e_max_groups, maximum number of groups of symbols + :return: a random new Genome + :rtype: dictionary + """ + s_segments = random.randint(1, conf.e_max_groups) + + grammar = {} + + for symbol in Alphabet.modules(): + + grammar[symbol[0]] = [] + + # generates clause and rule for each flavor of the letter + for flavor in range(0, conf.max_clauses): + + grammar[symbol[0]].append([]) + + if symbol[0] == conf.axiom_w: + grammar[symbol[0]][-1].extend([build_clause(conf.environmental_conditions, + conf.logic_operators, + conf.max_terms_clause), + [[conf.axiom_w, []]]]) + else: + grammar[symbol[0]][-1].extend([build_clause(conf.environmental_conditions, + conf.logic_operators, + conf.max_terms_clause), + []]) + + for s in range(0, s_segments): + + symbol_module = random.randint( + 1, len(Alphabet.modules()) - 1) + symbol_mounting = random.randint( + 0, len(Alphabet.morphology_mounting_commands()) - 1) + symbol_morph_moving = random.randint( + 0, len(Alphabet.morphology_moving_commands()) - 1) + symbol_contr_moving = random.randint( + 0, len(Alphabet.controller_moving_commands()) - 1) + symbol_changing = random.randint( + 0, len(Alphabet.controller_changing_commands()) - 1) + + grammar[symbol[0]][-1][1].extend([ + Plasticoding.build_symbol( + Alphabet.controller_moving_commands()[symbol_contr_moving], conf), + Plasticoding.build_symbol( + Alphabet.controller_changing_commands()[symbol_changing], conf), + Plasticoding.build_symbol( + Alphabet.morphology_mounting_commands()[symbol_mounting], conf), + Plasticoding.build_symbol( + Alphabet.modules()[symbol_module], conf), + Plasticoding.build_symbol( + Alphabet.morphology_moving_commands()[symbol_morph_moving], conf), + ]) + + return grammar + + +def build_clause(environmental_conditions, logic_operators, max_terms_clause): + + clause = [] + + num_terms_clause = random.choice(range(1, max_terms_clause+1)) + for term_idx in range(1, num_terms_clause+1): + + # selects a random term and makes a random comparison + term = random.choice(environmental_conditions) + state = random.choice([True, False]) + + clause.append([term, '==', state]) + + # adds logical operators if there are multiple terms + if term_idx < num_terms_clause: + clause.append([random.choice(logic_operators)]) + + return clause + + def random_initialization(conf, next_robot_id): """ Initializing a random genotype. @@ -55,6 +136,10 @@ def random_initialization(conf, next_robot_id): :rtype: Plasticoding """ genotype = Plasticoding(conf, next_robot_id) - genotype.grammar = _generate_random_grammar(conf) + + if conf.plastic: + genotype.grammar = _generate_random_plastic_grammar(conf) + else: + genotype.grammar = _generate_random_grammar(conf) return genotype diff --git a/pyrevolve/genotype/plasticoding/mutation/standard_mutation.py b/pyrevolve/genotype/plasticoding/mutation/standard_mutation.py index e877a947a1..77f778666c 100644 --- a/pyrevolve/genotype/plasticoding/mutation/standard_mutation.py +++ b/pyrevolve/genotype/plasticoding/mutation/standard_mutation.py @@ -1,16 +1,13 @@ import random from pyrevolve.genotype.plasticoding.plasticoding import Alphabet, Plasticoding from ....custom_logging.logger import genotype_logger - - +import sys def handle_deletion(genotype): """ Deletes symbols from genotype - :param genotype: genotype to be modified - :return: genotype """ target_production_rule = random.choice(list(genotype.grammar)) @@ -26,9 +23,7 @@ def handle_deletion(genotype): def handle_swap(genotype): """ Swaps symbols within the genotype - :param genotype: genotype to be modified - :return: genotype """ target_production_rule = random.choice(list(genotype.grammar)) @@ -46,6 +41,97 @@ def handle_swap(genotype): return genotype +def handle_addition(genotype, genotype_conf): + """ + Adds symbol to genotype + :param genotype: genotype to add to + :param genotype_conf: configuration for the genotype + :return: genotype + """ + target_production_rule = random.choice(list(genotype.grammar)) + if target_production_rule == Alphabet.CORE_COMPONENT: + addition_index = random.randint(1, len(genotype.grammar[target_production_rule]) - 1) + else: + addition_index = random.randint(0, len(genotype.grammar[target_production_rule]) - 1) + symbol_to_add = generate_symbol(genotype_conf) + genotype.grammar[target_production_rule].insert(addition_index, symbol_to_add) + genotype_logger.info( + f'mutation: add {symbol_to_add} in {genotype.id} for {target_production_rule} at {addition_index}.') + return genotype + + +def handle_deletion_plastic(genotype): + """ + Deletes symbols from genotype + + :param genotype: genotype to be modified + + :return: genotype + """ + + target_letter = random.choice(list(genotype.grammar)) + target_clause = random.choice(range(0, len(genotype.grammar[target_letter]))) + + if (len(genotype.grammar[target_letter][target_clause][1])) > 1: + symbol_to_delete = random.choice(genotype.grammar[target_letter][target_clause][1]) + if symbol_to_delete[0] != Alphabet.CORE_COMPONENT: + genotype.grammar[target_letter][target_clause][1].remove(symbol_to_delete) + genotype_logger.info( + f'mutation: remove in {genotype.id} for {target_letter} in {target_clause} at {symbol_to_delete[0]}.') + return genotype + + +def handle_swap_plastic(genotype): + """ + Swaps symbols within the genotype + + :param genotype: genotype to be modified + + :return: genotype + """ + + target_letter = random.choice(list(genotype.grammar)) + target_clause = random.choice(range(0, len(genotype.grammar[target_letter]))) + + if (len(genotype.grammar[target_letter][target_clause][1])) > 1: + symbols_to_swap = random.choices(population=genotype.grammar[target_letter][target_clause][1], k=2) + for symbol in symbols_to_swap: + if symbol[0] == Alphabet.CORE_COMPONENT: + return genotype + item_index_1 = genotype.grammar[target_letter][target_clause][1].index(symbols_to_swap[0]) + item_index_2 = genotype.grammar[target_letter][target_clause][1].index(symbols_to_swap[1]) + genotype.grammar[target_letter][target_clause][1][item_index_2], genotype.grammar[target_letter][target_clause][1][item_index_1] = \ + genotype.grammar[target_letter][target_clause][1][item_index_1], genotype.grammar[target_letter][target_clause][1][item_index_2] + genotype_logger.info( + f'mutation: swap in {genotype.id} for {target_letter} in {target_clause} between {symbols_to_swap[0]} and {symbols_to_swap[1]}.') + return genotype + + +def handle_addition_plastic(genotype, genotype_conf): + """ + Adds symbol to genotype + + :param genotype: genotype to add to + :param genotype_conf: configuration for the genotype + + :return: genotype + """ + + target_letter = random.choice(list(genotype.grammar)) + target_clause = random.choice(range(0, len(genotype.grammar[target_letter]))) + + if target_letter == Alphabet.CORE_COMPONENT: + addition_index = random.randint(1, len(genotype.grammar[target_letter][target_clause][1]) - 1) + else: + addition_index = random.randint(0, len(genotype.grammar[target_letter][target_clause][1]) - 1) + symbol_to_add = generate_symbol(genotype_conf) + genotype.grammar[target_letter][target_clause][1].insert(addition_index, symbol_to_add) + + genotype_logger.info( + f'mutation: add {symbol_to_add} in {genotype.id} for {target_letter} in {target_clause} at {addition_index}.') + return genotype + + def generate_symbol(genotype_conf): """ Generates a symbol for addition @@ -82,24 +168,60 @@ def generate_symbol(genotype_conf): return symbol -def handle_addition(genotype, genotype_conf): - """ - Adds symbol to genotype +def handle_clause(genotype, mutation_conf): - :param genotype: genotype to add to - :param genotype_conf: configuration for the genotype + max_terms_clause = mutation_conf.genotype_conf.max_terms_clause + + target_letter = random.choice(list(genotype.grammar)) + target_clause = random.choice(range(0, len(genotype.grammar[target_letter]))) + + environmental_conditions = mutation_conf.genotype_conf.environmental_conditions + logic_operators = mutation_conf.genotype_conf.logic_operators + + # defines which mutations are possible + + possible_mutations = ['flipping_value'] + + if len(genotype.grammar[target_letter][target_clause][0]) > 1: + possible_mutations.append('deletion') + possible_mutations.append('flipping_operator') + + if len(genotype.grammar[target_letter][target_clause][0]) < max_terms_clause: + possible_mutations.append('addition') + + mutation_type = random.choice(possible_mutations) + + # deletes terms items and logic operator + if mutation_type == 'deletion': + position_delete = random.choice(range(0, len(genotype.grammar[target_letter][target_clause][0]) + 1, 2)) + genotype.grammar[target_letter][target_clause][0].pop(position_delete) + if position_delete == 0: + genotype.grammar[target_letter][target_clause][0].pop(position_delete) + else: + genotype.grammar[target_letter][target_clause][0].pop(position_delete-1) + + if mutation_type == 'addition': + + term = random.choice(environmental_conditions) + state = random.choice([True, False]) + + genotype.grammar[target_letter][target_clause][0].append([random.choice(logic_operators)]) + genotype.grammar[target_letter][target_clause][0].append([term, '==', state]) + + if mutation_type == 'flipping_value': + position_flip = random.choice(range(0, len(genotype.grammar[target_letter][target_clause][0]) + 1, 2)) + if genotype.grammar[target_letter][target_clause][0][position_flip][2]: + genotype.grammar[target_letter][target_clause][0][position_flip][2] = False + else: + genotype.grammar[target_letter][target_clause][0][position_flip][2] = True + + if mutation_type == 'flipping_operator': + position_flip = random.choice(range(1, len(genotype.grammar[target_letter][target_clause][0]), 2)) + if genotype.grammar[target_letter][target_clause][0][position_flip][0] == 'and': + genotype.grammar[target_letter][target_clause][0][position_flip][0] = 'or' + else: + genotype.grammar[target_letter][target_clause][0][position_flip][0] = 'and' - :return: genotype - """ - target_production_rule = random.choice(list(genotype.grammar)) - if target_production_rule == Alphabet.CORE_COMPONENT: - addition_index = random.randint(1, len(genotype.grammar[target_production_rule]) - 1) - else: - addition_index = random.randint(0, len(genotype.grammar[target_production_rule]) - 1) - symbol_to_add = generate_symbol(genotype_conf) - genotype.grammar[target_production_rule].insert(addition_index, symbol_to_add) - genotype_logger.info( - f'mutation: add {symbol_to_add} in {genotype.id} for {target_production_rule} at {addition_index}.') return genotype @@ -116,15 +238,36 @@ def standard_mutation(genotype, mutation_conf): mutation_attempt = random.uniform(0.0, 1.0) if mutation_attempt > mutation_conf.mutation_prob: return new_genotype + else: - mutation_type = random.randint(1, 3) # NTS: better way? - if mutation_type == 1: - modified_genotype = handle_deletion(new_genotype) - elif mutation_type == 2: - modified_genotype = handle_swap(new_genotype) - elif mutation_type == 3: - modified_genotype = handle_addition(new_genotype, mutation_conf.genotype_conf) + + if mutation_conf.genotype_conf.plastic: + + mutation_type = random.randint(1, 4) + + if mutation_type == 1: + modified_genotype = handle_deletion_plastic(new_genotype) + elif mutation_type == 2: + modified_genotype = handle_swap_plastic(new_genotype) + elif mutation_type == 3: + modified_genotype = handle_addition_plastic(new_genotype, mutation_conf.genotype_conf) + elif mutation_type == 4: + modified_genotype = handle_clause(new_genotype, mutation_conf) + else: + raise Exception( + 'mutation_type value was not in the expected range (1,4). The value was: {}'.format(mutation_type)) else: - raise Exception( - 'mutation_type value was not in the expected range (1,3). The value was: {}'.format(mutation_type)) + + mutation_type = random.randint(1, 3) + + if mutation_type == 1: + modified_genotype = handle_deletion(new_genotype) + elif mutation_type == 2: + modified_genotype = handle_swap(new_genotype) + elif mutation_type == 3: + modified_genotype = handle_addition(new_genotype, mutation_conf.genotype_conf) + else: + raise Exception( + 'mutation_type value was not in the expected range (1,3). The value was: {}'.format(mutation_type)) + return modified_genotype diff --git a/pyrevolve/genotype/plasticoding/plasticoding.py b/pyrevolve/genotype/plasticoding/plasticoding.py index 5cd314997d..98ff6eeec2 100644 --- a/pyrevolve/genotype/plasticoding/plasticoding.py +++ b/pyrevolve/genotype/plasticoding/plasticoding.py @@ -17,7 +17,8 @@ import math import copy import itertools - +import sys +import json class Alphabet(Enum): @@ -150,21 +151,9 @@ def load_genotype(self, genotype_file): self.grammar[repleceable_symbol].append([symbol, params]) def export_genotype(self, filepath): - file = open(filepath, 'w+') - for key, rule in self.grammar.items(): - line = key.value + ' ' - for item_rule in range(0, len(rule)): - symbol = rule[item_rule][self.index_symbol].value - if len(rule[item_rule][self.index_params]) > 0: - params = '_' - for param in range(0, len(rule[item_rule][self.index_params])): - params += str(rule[item_rule][self.index_params][param]) - if param < len(rule[item_rule][self.index_params])-1: - params += '|' - symbol += params - line += symbol + ' ' - file.write(line+'\n') - file.close() + f = open(filepath, "w") + f.write(str(self.grammar)) + f.close() def load_and_develop(self, load, genotype_path='', id_genotype=None): @@ -182,15 +171,68 @@ def check_validity(self): if self.phenotype._morphological_measurements.measurement_to_dict()['hinge_count'] > 0: self.valid = True - def develop(self): - self.early_development() + def develop(self, environment): + self.early_development(environment) phenotype = self.late_development() return phenotype - def early_development(self): + def early_development(self, environment): + + if self.conf.plastic: + + grammar = {} + for letter in self.grammar: + if environment == 'plane': + hill = False + hot = False + if environment == 'tilted5': + hill = True + hot = False + if environment == 'lava': + hill = False + hot = True + if environment == 'lavatilted5': + hill = True + hot = True + + + true_clauses = [] + clause_is_true = None + for flavor in range(0, len(self.grammar[letter])): + clause = '' + for item in self.grammar[letter][flavor][0]: + for subitem in item: + clause += str(subitem) + ' ' + + clause_is_true = eval(clause) + + if clause_is_true: + true_clauses.append(flavor) + + # if no clause is true, letter doesnt get expressed + if len(true_clauses) == 0: + grammar[letter] = [] + + # actually...for now, it is safer to just express the first rule + # because this could result in tiny robots, which could be exploited in the hill + #grammar[letter] = self.grammar[letter][0][1] + else: + # if multiple clauses are true, all get expressed + for idx in range(0, len(true_clauses)): + if idx == 0: + grammar[letter] = self.grammar[letter][true_clauses[idx]][1] + else: + if letter == Alphabet.CORE_COMPONENT: + aux_list = self.grammar[letter][true_clauses[idx]][1][1:] + else: + aux_list = self.grammar[letter][true_clauses[idx]][1] + grammar[letter].extend(aux_list) - self.intermediate_phenotype = [[self.conf.axiom_w, []]] + else: + + grammar = self.grammar + self.intermediate_phenotype = [[self.conf.axiom_w, []]] for i in range(0, self.conf.i_iterations): position = 0 @@ -198,16 +240,20 @@ def early_development(self): symbol = self.intermediate_phenotype[position] if [symbol[self.index_symbol], []] in Alphabet.modules(): - # removes symbol - self.intermediate_phenotype.pop(position) - # replaces by its production rule - for ii in range(0, len(self.grammar[symbol[self.index_symbol]])): - self.intermediate_phenotype.insert(position+ii, - self.grammar[symbol[self.index_symbol]][ii]) + + ii = 0 + if len(grammar[symbol[self.index_symbol]]) > 0: + # removes symbol + self.intermediate_phenotype.pop(position) + # replaces it by its production rule + for ii in range(0, len(grammar[symbol[self.index_symbol]])): + self.intermediate_phenotype.insert(position+ii, + grammar[symbol[self.index_symbol]][ii]) position = position+ii+1 else: position = position + 1 - # logger.info('Robot ' + str(self.id) + ' was early-developed.') + + logger.info('Robot ' + str(self.id) + ' was early-developed.') def late_development(self): @@ -513,8 +559,12 @@ def new_module(self, slot, new_module_type, symbol): if not intersection: self.mounting_reference.children[slot] = module self.morph_mounting_container = None - self.mounting_reference_stack.append(self.mounting_reference) - self.mounting_reference = module + + # moves turtle to new module + if self.conf.move_to_new: + self.mounting_reference_stack.append(self.mounting_reference) + self.mounting_reference = module + if new_module_type == Alphabet.JOINT_HORIZONTAL \ or new_module_type == Alphabet.JOINT_VERTICAL: self.decode_brain_node(symbol, module.id) @@ -676,7 +726,7 @@ def __init__(self): class PlasticodingConfig: def __init__(self, initialization_genome=initialization.random_initialization, - e_max_groups=3, + e_max_groups=4, oscillator_param_min=1, oscillator_param_max=10, weight_param_min=-1, @@ -686,7 +736,13 @@ def __init__(self, axiom_w=Alphabet.CORE_COMPONENT, i_iterations=3, max_structural_modules=100, - robot_id=0 + robot_id=0, + move_to_new=False, + max_clauses=2, + max_terms_clause=2, + plastic=False, + environmental_conditions=['hill'], + logic_operators=['and', 'or'] ): self.initialization_genome = initialization_genome self.e_max_groups = e_max_groups @@ -700,3 +756,9 @@ def __init__(self, self.i_iterations = i_iterations self.max_structural_modules = max_structural_modules self.robot_id = robot_id + self.move_to_new = move_to_new + self.max_clauses = max_clauses + self.max_terms_clause = max_terms_clause + self.plastic = plastic + self.environmental_conditions = environmental_conditions + self.logic_operators = logic_operators diff --git a/pyrevolve/revolve_bot/revolve_bot.py b/pyrevolve/revolve_bot/revolve_bot.py index f9b59456dc..ce9dda6a53 100644 --- a/pyrevolve/revolve_bot/revolve_bot.py +++ b/pyrevolve/revolve_bot/revolve_bot.py @@ -68,7 +68,7 @@ def measure_behaviour(self): """ pass - def measure_phenotype(self): + def measure_phenotype(self, experiment_name): self._morphological_measurements = self.measure_body() self._brain_measurements = self.measure_brain() logger.info('Robot ' + str(self.id) + ' was measured.') @@ -86,13 +86,14 @@ def measure_body(self): except Exception as e: logger.exception('Failed measuring body') - def export_phenotype_measurements(self, data_path): - filepath = os.path.join(data_path, 'descriptors', f'phenotype_desc_{self.id}.txt') - with open(filepath, 'w+') as file: + def export_phenotype_measurements(self, path, environment): + with open('experiments/' + path + '/data_fullevolution/'+environment+'/descriptors/' + + 'phenotype_desc_' + str(self.id) + '.txt', 'w+') as file: + for key, value in self._morphological_measurements.measurements_to_dict().items(): - file.write(f'{key} {value}\n') + file.write('{} {}\n'.format(key, value)) for key, value in self._brain_measurements.measurements_to_dict().items(): - file.write(f'{key} {value}\n') + file.write('{} {}\n'.format(key, value)) def measure_brain(self): """ diff --git a/pyrevolve/tol/manage/robotmanager.py b/pyrevolve/tol/manage/robotmanager.py index 78200e0010..703db3ee27 100644 --- a/pyrevolve/tol/manage/robotmanager.py +++ b/pyrevolve/tol/manage/robotmanager.py @@ -30,14 +30,13 @@ def __init__( :param robot: RevolveBot :param position: :type position: Vector3 - :param time: + :param time: time the robot was created :type time: Time :param battery_level: Battery charge for this robot :type battery_level: float :return: """ - time = conf.evaluation_time if time is None else time - speed_window = int(float(time) * conf.pose_update_frequency) + 1 if position_log_size is None \ + speed_window = int(float(conf.evaluation_time) * conf.pose_update_frequency) + 1 if position_log_size is None \ else position_log_size super(RobotManager, self).__init__( robot=robot, diff --git a/pyrevolve/util/supervisor/simulator_queue.py b/pyrevolve/util/supervisor/simulator_queue.py index 8f69eb52a9..2ee13517ac 100644 --- a/pyrevolve/util/supervisor/simulator_queue.py +++ b/pyrevolve/util/supervisor/simulator_queue.py @@ -27,7 +27,7 @@ def __init__(self, n_cores: int, settings, port_start=11345, simulator_cmd=None) def _simulator_supervisor(self, simulator_name_postfix): return DynamicSimSupervisor( - world_file=self._settings.world, + world_file='worlds/'+self._settings.world+'.world', simulator_cmd=self._simulator_cmd, simulator_args=["--verbose"], plugins_dir_path=os.path.join('.', 'build', 'lib'), diff --git a/worlds/lava.world b/worlds/lava.world new file mode 100644 index 0000000000..07330739c3 --- /dev/null +++ b/worlds/lava.world @@ -0,0 +1,43 @@ + + + + + 0 + 0 + + + + 0.005 + + + 0 + + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + world + + + + + + + + + model://sun + + + model://tol_ground + + + + + diff --git a/worlds/plasticoding/plane.realtime.world b/worlds/plasticoding/plane.realtime.world new file mode 100644 index 0000000000..4a710a7b58 --- /dev/null +++ b/worlds/plasticoding/plane.realtime.world @@ -0,0 +1,43 @@ + + + + + 0 + 0 + + + + 0.005 + + + 1000 + + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + world + + + + + + + + + model://sun + + + model://tol_ground + + + + + diff --git a/worlds/plasticoding/planeobstacles.realtime.world b/worlds/plasticoding/planeobstacles.realtime.world new file mode 100644 index 0000000000..167cbaee98 --- /dev/null +++ b/worlds/plasticoding/planeobstacles.realtime.world @@ -0,0 +1,7632 @@ + + + + + 0 + 0 + + + 0.005 + + + 5000 + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + quick + + + + + -1 -1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 -0.87 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 -0.74 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 -0.61 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 -0.48 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 -0.22 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 -0.0899999999999999 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 0.0400000000000001 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 0.17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 0.43 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 0.56 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 0.69 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 0.82 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 0.95 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.82 -0.93 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 -0.8 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 -0.67 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 -0.54 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 -0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 -0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 -0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 0.63 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 0.76 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 0.89 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.57 -1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 -0.87 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 -0.74 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 -0.61 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 -0.48 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 -0.22 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 -0.0899999999999999 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 0.0400000000000001 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 0.17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 0.43 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 0.56 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 0.69 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 0.82 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 0.95 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.32 -0.93 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 -0.8 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 -0.67 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 -0.54 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 -0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 -0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 -0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 0.63 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 0.76 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 0.89 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.14 -1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 -0.87 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 -0.74 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 -0.61 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 -0.48 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 -0.22 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 -0.0899999999999999 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 0.0400000000000001 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 0.17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 0.43 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 0.56 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 0.69 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 0.82 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 0.95 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 -0.93 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 -0.8 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 -0.67 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 -0.54 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 -0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 -0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 -0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 0.63 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 0.76 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 0.89 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.29 -1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 -0.87 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 -0.74 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 -0.61 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 -0.48 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 -0.22 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 -0.0899999999999999 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 0.0400000000000001 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 0.17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 0.43 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 0.56 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 0.69 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 0.82 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 0.95 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.54 -0.93 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 -0.8 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 -0.67 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 -0.54 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 -0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 -0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 -0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 0.63 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 0.76 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 0.89 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.72 -1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 -0.87 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 -0.74 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 -0.61 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 -0.48 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 -0.22 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 -0.0899999999999999 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 0.0400000000000001 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 0.17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 0.43 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 0.56 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 0.69 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 0.82 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 0.95 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.9 -0.93 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 -0.8 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 -0.67 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 -0.54 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 -0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 -0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 -0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 0.63 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 0.76 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 0.89 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + + model://sun + + + model://tol_ground + + + + diff --git a/worlds/plasticoding/planeobstacles.world b/worlds/plasticoding/planeobstacles.world new file mode 100644 index 0000000000..d0350221f5 --- /dev/null +++ b/worlds/plasticoding/planeobstacles.world @@ -0,0 +1,12344 @@ + + + + + 0 + 0 + + + 0.005 + + + 0.0 + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + quick + + + + + + + + -1 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.93 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -1 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.93 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -1 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.93 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -1 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.93 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.82 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.75 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.82 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.75 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.82 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.75 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.82 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.75 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.64 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.57 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.64 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.57 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.64 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.57 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.64 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.57 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.46 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.39 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.46 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.39 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.46 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.39 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.46 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.39 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.28 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.21 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.28 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.21 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.28 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.21 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.28 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.21 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + -0.0999999999999998 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.0299999999999998 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.0999999999999998 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.0299999999999998 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.0999999999999998 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.0299999999999998 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.0999999999999998 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + -0.0299999999999998 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.0800000000000002 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.15 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.0800000000000002 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.15 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.0800000000000002 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.15 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.0800000000000002 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.15 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.26 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.33 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.26 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.33 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.26 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.33 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.26 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.33 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.44 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.51 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.44 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.51 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.44 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.51 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.44 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.51 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.62 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.69 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.62 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.69 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.62 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.69 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.62 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.69 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.8 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.87 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.8 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.87 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.8 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.87 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.8 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.87 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.03 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.03 + + + + + + + 0 + 0 + 1 + + + + 0.98 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 1.05 -0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.98 -0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 1.05 -0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.98 0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 1.05 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 0.98 0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + 1.05 0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.06 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.06 + + + + + + + 0 + 0 + 1 + + + + + + + + + -1 -1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 -0.87 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 -0.74 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 -0.61 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 -0.48 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 -0.22 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 -0.0899999999999999 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 0.0400000000000001 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 0.17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 0.43 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 0.56 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 0.69 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -1 0.82 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.93 0.95 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.82 -0.93 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 -0.8 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 -0.67 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 -0.54 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 -0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 -0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 -0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 0.63 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.75 0.76 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.82 0.89 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.57 -1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 -0.87 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 -0.74 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 -0.61 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 -0.48 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 -0.22 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 -0.0899999999999999 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 0.0400000000000001 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 0.17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 0.43 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 0.56 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 0.69 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.5 0.82 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.57 0.95 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.32 -0.93 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 -0.8 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 -0.67 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 -0.54 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 -0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 -0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 -0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 0.63 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.32 0.76 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.25 0.89 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.14 -1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 -0.87 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 -0.74 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 -0.61 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 -0.48 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 -0.22 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 -0.0899999999999999 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 0.0400000000000001 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 0.17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 0.43 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 0.56 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 0.69 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.14 0.82 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0699999999999999 0.95 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 -0.93 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 -0.8 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 -0.67 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 -0.54 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 -0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 -0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 -0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 0.63 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.11 0.76 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0400000000000001 0.89 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.29 -1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 -0.87 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 -0.74 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 -0.61 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 -0.48 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 -0.22 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 -0.0899999999999999 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 0.0400000000000001 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 0.17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 0.43 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 0.56 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 0.69 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.36 0.82 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.29 0.95 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.54 -0.93 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 -0.8 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 -0.67 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 -0.54 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 -0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 -0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 -0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 0.63 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.54 0.76 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.61 0.89 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.72 -1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 -0.87 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 -0.74 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 -0.61 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 -0.48 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 -0.22 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 -0.0899999999999999 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 0.0400000000000001 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 0.17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 0.43 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 0.56 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 0.69 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.72 0.82 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.79 0.95 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.9 -0.93 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 -0.8 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 -0.67 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 -0.54 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 -0.41 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 -0.28 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 -0.02 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 0.11 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 0.24 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 0.37 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 0.63 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.97 0.76 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.9 0.89 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.03 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.03 0.02 + + + + + + + 0 + 0 + 1 + + + + + model://sun + + + model://tol_ground + + + + diff --git a/worlds/plasticoding/planeobstacles2.realtime.world b/worlds/plasticoding/planeobstacles2.realtime.world new file mode 100644 index 0000000000..6ff1a76298 --- /dev/null +++ b/worlds/plasticoding/planeobstacles2.realtime.world @@ -0,0 +1,2781 @@ + + + + + 0 + 0 + + + 0.005 + + + 1000 + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + quick + + + + + -0.6 -0.6 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.53 -0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.6 -0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.53 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.6 6.93889390390723e-17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.53 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.6 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.53 0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.42 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.35 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.42 -0.2 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.35 -0.05 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.42 0.1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.35 0.25 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.42 0.4 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.35 0.55 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.24 -0.6 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.17 -0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.24 -0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.17 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.24 6.93889390390723e-17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.17 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.24 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.17 0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0599999999999999 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0100000000000001 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.0599999999999999 -0.2 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0100000000000001 -0.05 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.0599999999999999 0.1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0100000000000001 0.25 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.0599999999999999 0.4 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0100000000000001 0.55 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.12 -0.6 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.19 -0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.12 -0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.19 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.12 6.93889390390723e-17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.19 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.12 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.19 0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.3 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.37 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.3 -0.2 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.37 -0.05 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.3 0.1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.37 0.25 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.3 0.4 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.37 0.55 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.48 -0.6 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.55 -0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.48 -0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.55 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.48 6.93889390390723e-17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.55 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.48 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.55 0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + + model://sun + + + model://tol_ground + + + + diff --git a/worlds/plasticoding/planeobstacles2.world b/worlds/plasticoding/planeobstacles2.world new file mode 100644 index 0000000000..c8b893892c --- /dev/null +++ b/worlds/plasticoding/planeobstacles2.world @@ -0,0 +1,2781 @@ + + + + + 0 + 0 + + + 0.005 + + + 0.0 + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + quick + + + + + -0.6 -0.6 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.53 -0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.6 -0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.53 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.6 6.93889390390723e-17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.53 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.6 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.53 0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.42 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.35 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.42 -0.2 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.35 -0.05 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.42 0.1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.35 0.25 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.42 0.4 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.35 0.55 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.24 -0.6 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.17 -0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.24 -0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.17 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.24 6.93889390390723e-17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.17 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.24 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.17 0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + -0.0599999999999999 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0100000000000001 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.0599999999999999 -0.2 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0100000000000001 -0.05 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.0599999999999999 0.1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0100000000000001 0.25 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + -0.0599999999999999 0.4 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.0100000000000001 0.55 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.12 -0.6 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.19 -0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.12 -0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.19 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.12 6.93889390390723e-17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.19 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.12 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.19 0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.3 -0.5 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.37 -0.35 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.3 -0.2 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.37 -0.05 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.3 0.1 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.37 0.25 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.3 0.4 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.37 0.55 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.02 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.02 + + + + + + + 0 + 0 + 1 + + + + 0.48 -0.6 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.55 -0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.48 -0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.55 -0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.48 6.93889390390723e-17 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.55 0.15 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.48 0.3 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + 0.55 0.45 0 0 0 0 + + + 1 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0.03 0.05 0.01 + + + 10 + + + + + + + + + + + + + + 0.03 0.05 0.01 + + + + + + + 0 + 0 + 1 + + + + + model://sun + + + model://tol_ground + + + + diff --git a/worlds/plasticoding/tilted10.realtime.world b/worlds/plasticoding/tilted10.realtime.world new file mode 100644 index 0000000000..75ae943e00 --- /dev/null +++ b/worlds/plasticoding/tilted10.realtime.world @@ -0,0 +1,41 @@ + + + + + 0 + 0 + + + 0.005 + + + 1000 + + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + quick + + + + + + + + model://sun + + + model://tilted10 + + + + + diff --git a/worlds/plasticoding/tilted10.world b/worlds/plasticoding/tilted10.world new file mode 100644 index 0000000000..29ee9f85bd --- /dev/null +++ b/worlds/plasticoding/tilted10.world @@ -0,0 +1,40 @@ + + + + + 0 + 0 + + + 0.005 + + + 0 + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + quick + + + + + + + + model://sun + + + model://tilted10 + + + + + diff --git a/worlds/plasticoding/tilted15.realtime.world b/worlds/plasticoding/tilted15.realtime.world new file mode 100644 index 0000000000..02a4f994bb --- /dev/null +++ b/worlds/plasticoding/tilted15.realtime.world @@ -0,0 +1,40 @@ + + + + + 0 + 0 + + + 0.001 + + + 5000 + + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + quick + + + + + + + + model://sun + + + model://tilted15 + + + + diff --git a/worlds/plasticoding/tilted15.world b/worlds/plasticoding/tilted15.world new file mode 100644 index 0000000000..5f596916f8 --- /dev/null +++ b/worlds/plasticoding/tilted15.world @@ -0,0 +1,40 @@ + + + + + 0 + 0 + + + 0.005 + + + 0 + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + quick + + + + + + + + model://sun + + + model://tilted15 + + + + + diff --git a/worlds/plasticoding/tilted5.realtime.world b/worlds/plasticoding/tilted5.realtime.world new file mode 100644 index 0000000000..95d13320a5 --- /dev/null +++ b/worlds/plasticoding/tilted5.realtime.world @@ -0,0 +1,40 @@ + + + + + 0 + 0 + + + 0.005 + + + 1000 + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + quick + + + + + + + + model://sun + + + model://tilted5 + + + + + diff --git a/worlds/plasticoding/tilted5.world b/worlds/plasticoding/tilted5.world new file mode 100644 index 0000000000..6810efd7d2 --- /dev/null +++ b/worlds/plasticoding/tilted5.world @@ -0,0 +1,40 @@ + + + + + 0 + 0 + + + 0.003 + + + 0 + + + + 0.1 + 10e-6 + + + 100 + 1e-8 + + + quick + + + + + + + + model://sun + + + model://tilted5 + + + + +