diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000..7be0f2909a Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index cbe513bdf1..4e03811add 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ env/ develop-eggs/ dist/ downloads/ +yaml_temp/ eggs/ .eggs/ lib/ @@ -70,4 +71,4 @@ target/ # Revolve related *.sdf -*.urdf \ No newline at end of file +*.urdf diff --git a/cpprevolve/CMakeLists.txt b/cpprevolve/CMakeLists.txt index 4b57545b53..2e96a56fa3 100644 --- a/cpprevolve/CMakeLists.txt +++ b/cpprevolve/CMakeLists.txt @@ -66,6 +66,9 @@ include_directories(${Boost_INCLUDE_DIRS}) find_package(Eigen3 REQUIRED) include_directories(${EIGEN3_INCLUDE_DIR}) +find_package( OpenCV REQUIRED ) +include_directories( ${OpenCV_INCLUDE_DIRS} ) + # Find NLOpt - Non Linear Optimization pkg_check_modules(NLOpt REQUIRED nlopt>=2.4) include_directories(${NLOpt_INCLUDE_DIRS}) @@ -76,6 +79,10 @@ set(LIMBO_DIR ../thirdparty/limbo) set(LIMBO_DEFINES USE_NLOPT) include_directories(${LIMBO_DIR}/src) +# Find galgo library for EA +set(GALGO_DIR ../thirdparty/galgo) +include_directories(${GALGO_DIR}) + # Find GSL - GNU Scientific Library find_package(GSL REQUIRED) include_directories(${GSL_INCLUDE_DIRS}) @@ -87,16 +94,25 @@ include_directories(${YAML_CPP_INCLUDE_DIR}) # Find Gazebo # LOCAL_GAZEBO_DIR can be set to a path with a gazebo-config.cmake if (LOCAL_GAZEBO_DIR) - find_package(gazebo 9 REQUIRED CONFIG + find_package(gazebo 10 REQUIRED CONFIG PATHS "${LOCAL_GAZEBO_DIR}" NO_DEFAULT_PATH) message(WARNING "Using local Gazebo @ ${gazebo_DIR}") else() - find_package(gazebo 9 REQUIRED) + find_package(gazebo 10 REQUIRED) endif() include_directories(${GAZEBO_INCLUDE_DIRS}) link_directories(${GAZEBO_LIBRARY_DIRS}) +pkg_check_modules(libavcodec libavcodec) +if (NOT libavcodec_FOUND) + BUILD_WARNING("libavcodec not found.") +else() + include_directories(${libavcodec_INCLUDE_DIRS}) + link_directories(${libavcodec_LIBRARY_DIRS}) +endif () + + # Find Protobuf # TODO: This part is currently a mess, and it should be handeled better find_package(Protobuf REQUIRED) diff --git a/cpprevolve/revolve/gazebo/brains/DifferentialCPG.cpp b/cpprevolve/revolve/gazebo/brains/DifferentialCPG.cpp index 88d4a69bc1..293e783aad 100644 --- a/cpprevolve/revolve/gazebo/brains/DifferentialCPG.cpp +++ b/cpprevolve/revolve/gazebo/brains/DifferentialCPG.cpp @@ -42,6 +42,11 @@ #include #include +#include +#include +#include +//#include + // Project headers #include "../motors/Motor.h" @@ -64,6 +69,49 @@ using Init_t = limbo::init::LHS; using Kernel_t = limbo::kernel::MaternFiveHalves; using GP_t = limbo::model::GP; +///**************** configuration galgo real value ***************/// +template +void set_my_config(galgo::ConfigInfo<_TYPE>& config, double mutrate) +{ + // override some defaults + config.mutinfo._sigma = 1.0; + config.mutinfo._sigma_lowest = 0.001; //cannot too small that change nothing + config.mutinfo._ratio_boundary = 0.10; + //ea: 0.4, 0.6, boea: + config.covrate = 0.4; // 0.0 if no cros-over + config.mutrate = 0.8; // mutation rate usually is 1.0 for real-valued + config.recombination_ratio = 0.70; //Real Valued crossover ratio, can't be 0.5 because 0.5 will generate two same offsprings after Xover + + config.elitpop = 1; + config.tntsize = 2; //k-tournament size k=2/4, higher value higher pressure + config.Selection = TNT; + config.CrossOver = RealValuedSimpleArithmeticRecombination; + config.mutinfo._type = galgo::MutationType::MutationGAM_UncorrelatedNStepSizeBoundary; + + config.popsize = 20; + config.nbgen = 125; //The num of gens for EA, 131+19, 125+25, 122+28 + config.output = true; +} + +template +class objective_function +{ + public: + static std::vector Objective(const std::vector& x) + { + size_t dim_in = 20; + // auto xx = x; + // //transfer interval from [0, 1] to [-3, 3] [-2, 2] [-5, 5] + // for (int i = 0; i < dim_in; i++) + // xx[i] = 4. * x[i] - 2.; + // double f = 10. * dim_in; + // for (size_t i = 0; i < dim_in; ++i) + // f += xx[i] * xx[i] - 10. * std::cos(2 * M_PI * xx[i]); + return {0}; //maximum = 0 with (0, 0, 0, 0); + } +}; + + /** * Constructor for DifferentialCPG class. * @@ -121,21 +169,23 @@ DifferentialCPG::DifferentialCPG( this->signal_factor_mid = std::stod(controller->GetAttribute("signal_factor_mid")->GetAsString()); this->signal_factor_left_right = std::stod(controller->GetAttribute("signal_factor_left_right")->GetAsString()); - // Limbo BO Learner parameters - this->kernel_noise_ = std::stod(learner->GetAttribute("kernel_noise")->GetAsString()); - this->kernel_optimize_noise_ = std::stoi(learner->GetAttribute("kernel_optimize_noise")->GetAsString()); - this->kernel_sigma_sq_ = std::stod(learner->GetAttribute("kernel_sigma_sq")->GetAsString()); - this->kernel_l_ = std::stod(learner->GetAttribute("kernel_l")->GetAsString()); - this->kernel_squared_exp_ard_k_ = std::stoi(learner->GetAttribute("kernel_squared_exp_ard_k")->GetAsString()); - this->acqui_gpucb_delta_ = std::stod(learner->GetAttribute("acqui_gpucb_delta")->GetAsString()); - this->acqui_ucb_alpha_ = std::stod(learner->GetAttribute("acqui_ucb_alpha")->GetAsString()); - this->acqui_ei_jitter_ = std::stod(learner->GetAttribute("acqui_ei_jitter")->GetAsString()); - - // Non-limbo BO learner para - this->n_init_samples = std::stoi(learner->GetAttribute("n_init_samples")->GetAsString()); - this->n_learning_iterations = std::stoi(learner->GetAttribute("n_learning_iterations")->GetAsString()); - this->n_cooldown_iterations = std::stoi(learner->GetAttribute("n_cooldown_iterations")->GetAsString()); - this->init_method = learner->GetAttribute("init_method")->GetAsString(); + // Limbo BO Learner parameters + this->kernel_noise_ = std::stod(learner->GetAttribute("kernel_noise")->GetAsString()); + this->kernel_optimize_noise_ = std::stoi(learner->GetAttribute("kernel_optimize_noise")->GetAsString()); + this->kernel_sigma_sq_ = std::stod(learner->GetAttribute("kernel_sigma_sq")->GetAsString()); + this->kernel_l_ = std::stod(learner->GetAttribute("kernel_l")->GetAsString()); + this->kernel_squared_exp_ard_k_ = std::stoi(learner->GetAttribute("kernel_squared_exp_ard_k")->GetAsString()); + this->acqui_gpucb_delta_ = std::stod(learner->GetAttribute("acqui_gpucb_delta")->GetAsString()); + this->acqui_ucb_alpha_ = std::stod(learner->GetAttribute("acqui_ucb_alpha")->GetAsString()); + this->acqui_ei_jitter_ = std::stod(learner->GetAttribute("acqui_ei_jitter")->GetAsString()); + this->gaussian_step_size_ = std::stod(learner->GetAttribute("gaussian_step_size")->GetAsString()); + this->mutrate_ = std::stod(learner->GetAttribute("mutrate")->GetAsString()); + + // Non-limbo BO learner para + this->n_init_samples = std::stoi(learner->GetAttribute("n_init_samples")->GetAsString()); + this->n_learning_iterations = std::stoi(learner->GetAttribute("n_learning_iterations")->GetAsString()); + this->n_cooldown_iterations = std::stoi(learner->GetAttribute("n_cooldown_iterations")->GetAsString()); + this->init_method = learner->GetAttribute("init_method")->GetAsString(); // Meta parameters this->startup_time = std::stoi(controller->GetAttribute("startup_time")->GetAsString()); @@ -283,7 +333,7 @@ DifferentialCPG::DifferentialCPG( this->directory_name = controller->GetAttribute("output_directory")->GetAsString(); if(this->directory_name.empty()) { - this->directory_name = "output/cpg_bo/"; + this->directory_name = "output/cpg_boea/"; this->directory_name += std::to_string(time(0)) + "/"; } @@ -347,11 +397,25 @@ DifferentialCPG::DifferentialCPG( { std::cout << "Don't load existing brain" << std::endl; } - - // Initialize BO - this->bo_init_sampling(); + if(learner_algorithm == "BO") + { + // Initialize BO + this->bo_init_sampling(); + } + if(learner_algorithm == "EA") + { + // Initialize EA. create initial samples + this->ea_init_sampling(); + } + if(learner_algorithm == "BOEA") + { + this->bo_init_sampling(); + } } + // Save parameters + this->save_parameters(); + // Initiate the cpp Evaluator this->evaluator.reset(new Evaluator(this->evaluation_rate)); this->evaluator->directory_name = this->directory_name; @@ -371,17 +435,121 @@ DifferentialCPG::~DifferentialCPG() * Dummy function for limbo */ struct DifferentialCPG::evaluation_function{ + // TODO: Make this neat. I don't know how though. // Number of input dimension (samples.size()) - BO_PARAM(size_t, dim_in, 18); + //spider9:18,spider13:26,spider17:34,gecko7:13,gecko12:23,gecko17:33,babyA:16,babyB:22,babyC:32,one+:12 + //nihedssnake6:6,nihedssnake8:8,nihedssnake10:10 + BO_PARAM(size_t, dim_in, 20); // number of dimensions of the fitness BO_PARAM(size_t, dim_out, 1); Eigen::VectorXd operator()(const Eigen::VectorXd &x) const { - return limbo::tools::make_vector(0); + return limbo::tools::make_vector(0); }; }; +/** + * Performs the initial random sampling for EA + */ +void DifferentialCPG::ea_init_sampling(){ + if(this->verbose) + { + // We only want to optimize the weights for now. + std::cout << "Number of weights = connections/2 + n_motors are " + << this->connections.size()/2 + << " + " + << this->n_motors + << std::endl; + } + + // Random sampling + if(this->init_method == "RS") + { + std::cout << "This is RS ...." << std::endl; + for (size_t i = 0; i < this->n_init_samples; i++) + { + // Working variable to hold a random number for each weight to be optimized + Eigen::VectorXd init_sample(this->n_weights); + + // For all weights + for (size_t j = 0; j < this->n_weights; j++) + { + // Generate a random number in [0, 1]. Transform later + double f = ((double) rand() / (RAND_MAX)); + + // Append f to vector + init_sample(j) = f; + } + + // Save vector in samples. + this->samples.push_back(init_sample); + } + } + // Latin Hypercube Sampling + else if(this->init_method == "LHS") + { + std::cout << "This is LHS ...." << std::endl; + // Working variable + double my_range = 1.f/this->n_init_samples; + + // If we have n dimensions, create n such vectors that we will permute + std::vector> all_dimensions; + + // Fill vectors + for (size_t i=0; i < this->n_weights; i++) + { + std::vector one_dimension; + + // Prepare for vector permutation + for (size_t j = 0; j < this->n_init_samples; j++) + { + one_dimension.push_back(j); + } + + // Vector permutation + std::random_shuffle(one_dimension.begin(), one_dimension.end() ); + + // Save permuted vector + all_dimensions.push_back(one_dimension); + } + + // For all samples + for (size_t i = 0; i < this->n_init_samples; i++) + { + // Initialize Eigen::VectorXd here. + Eigen::VectorXd init_sample(this->n_weights); + + // For all dimensions + for (size_t j = 0; j < this->n_weights; j++) + { + // Take a LHS + init_sample(j) = all_dimensions.at(j).at(i)*my_range + ((double) rand() / (RAND_MAX))*my_range; + } + + // Append sample to samples + this->samples.push_back(init_sample); + } + } + else + { + std::cout << "Please provide a choice of init_method in {LHS, RS}" << std::endl; + } + + // Print samples + if(this->verbose) + { + for(auto init_sample :this->samples) + { + for (int h = 0; h < init_sample.size(); h++) + { + std::cout << init_sample(h) << ", "; + } + std::cout << std::endl; + } + } +} + /** * Performs the initial random sampling for BO */ @@ -396,8 +564,7 @@ void DifferentialCPG::bo_init_sampling(){ << std::endl; // Information purposes - std::cout << std::endl << "Sample method: " << this->init_method << ". Initial " - "samples are: " << std::endl; + std::cout << std::endl << "Sample method: " << this->init_method << ". Initial samples are: " << std::endl; } // Random sampling @@ -409,6 +576,9 @@ void DifferentialCPG::bo_init_sampling(){ Eigen::VectorXd init_sample(this->n_weights); // For all weights + srand((unsigned)time(NULL)); + // trash first one, because it could be the same and I do not know why + auto trash_first = rand(); for (size_t j = 0; j < this->n_weights; j++) { // Generate a random number in [0, 1]. Transform later @@ -417,7 +587,6 @@ void DifferentialCPG::bo_init_sampling(){ // Append f to vector init_sample(j) = f; } - // Save vector in samples. this->samples.push_back(init_sample); } @@ -489,11 +658,24 @@ void DifferentialCPG::bo_init_sampling(){ * Function that obtains the current fitness by calling the evaluator and stores it */ void DifferentialCPG::save_fitness(){ - // Get fitness +// std::cout << "save_fitness().... "; + // calculate the fitness function double fitness = this->evaluator->Fitness(); - + //filter the noise in evaluation, keep the elitism to next generation + if((learner_algorithm == "EA") or (learner_algorithm == "BOEA" and (this->current_iteration > switch_num))) + { + if((this->current_iteration % pop_size == 1) and (this->current_iteration not_eq 1)) + { + std::cout << "current_iteration: " << this->current_iteration + << " fitness: " << fitness << std::endl; + if(fitness < this->best_fitness) + { + fitness = 0.5 * (fitness + this->best_fitness); + } + } + } // Save sample if it is the best seen so far - if(fitness >this->best_fitness) + if(fitness > this->best_fitness) { this->best_fitness = fitness; this->best_sample = this->samples.back(); @@ -501,8 +683,8 @@ void DifferentialCPG::save_fitness(){ if (this->verbose) { - std::cout << "Iteration number " << this->current_iteration << " has fitness " << - fitness << ". Best fitness: " << this->best_fitness << std::endl; + std::cout << "Iteration: " << this->current_iteration << ", fitness " << + fitness << ", Best fitness: " << this->best_fitness << std::endl; } // Limbo requires fitness value to be of type Eigen::VectorXd @@ -515,11 +697,67 @@ void DifferentialCPG::save_fitness(){ // Write fitness to file std::ofstream fitness_file; fitness_file.open(this->directory_name + "fitnesses.txt", std::ios::app); - fitness_file << fitness << std::endl; + fitness_file << std::fixed << fitness << std::endl; + fitness_file.flush(); fitness_file.close(); } - +/** + * Wrapper function that makes calls to limbo to solve the current BO + * iteration and returns the best sample + */ +void DifferentialCPG::ea_step(){ + // CONFIG + using _TYPE = float; //float, double, char, int, long + const int NBIT = 64; // Has to remain between 1 and 64, 32:float + galgo::ConfigInfo<_TYPE> config; // A new instance of config get initial defaults + set_my_config<_TYPE>(config, this->mutrate_); // Override some defaults + + // initializing parameters lower and upper bounds + galgo::Parameter< _TYPE, NBIT > par1({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par2({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par3({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par4({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par5({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par6({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par7({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par8({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par9({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par10({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par11({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par12({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par13({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par14({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par15({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par16({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par17({(_TYPE)0.0, (_TYPE)1.0}); + galgo::Parameter< _TYPE, NBIT > par18({(_TYPE)0.0, (_TYPE)1.0}); + // galgo::Parameter< _TYPE, NBIT > par19({(_TYPE)0.0, (_TYPE)1.0}); + // galgo::Parameter< _TYPE, NBIT > par20({(_TYPE)0.0, (_TYPE)1.0}); + + galgo::GeneticAlgorithm< _TYPE > ga(config, par1, par2, par3, par4, par5, par6, par7, par8, par9, par10, par11, par12, par13, par14, par15, par16, + par17, + par18 + // par19, + // par20 + ); + ga.run(this->learner_algorithm, this->current_iteration, this->gaussian_step_size_, this->switch_num, this->samples, this->observations); + + // clear old samples and observations before pass new individuals to samples + this->samples.clear(); + this->observations.clear(); + + //return the populations to samples one by one + std::cout << "The new samples from EA after ga.run() .... " << std::endl; + Eigen::VectorXd x; + for(int i = 0; i < pop_size; i++) + { + x = ga.get_sample(i); //return the last sample in _samples + // Save this x_hat_star, samples: All samples seen so far + this->samples.push_back(x); +// std::cout << "samples[" << i << "]: " << samples[i] << std::endl; + } +} /** * Struct that holds the parameters on which BO is called. This is required @@ -641,15 +879,13 @@ void DifferentialCPG::bo_step(){ this->observations); x = boptimizer.last_sample(); - // Write parametesr to verify thread-stability after the run - std::ofstream dyn_parameters_file; - dyn_parameters_file.open(this->directory_name + "dynamic_parameters.txt", std::ios::app); - dyn_parameters_file << Params::acqui_ucb::alpha() << ","; - dyn_parameters_file << Params::kernel_maternfivehalves::sigma_sq() << ","; - dyn_parameters_file << Params::kernel_maternfivehalves::l() << std::endl; - dyn_parameters_file.close(); - - + // Write parametesr to verify thread-stability after the run + std::ofstream dyn_parameters_file; + dyn_parameters_file.open(this->directory_name + "dynamic_parameters.txt", std::ios::app); + dyn_parameters_file << Params::acqui_ucb::alpha() << ","; + dyn_parameters_file << Params::kernel_maternfivehalves::sigma_sq() << ","; + dyn_parameters_file << Params::kernel_maternfivehalves::l() << std::endl; + dyn_parameters_file.close(); } // else if(this->acquisition_function == "GP_UCB") // { @@ -724,16 +960,17 @@ void DifferentialCPG::Update( // this->evaluator->Update(this->robot->WorldPose(), _time, _step); this->start_fitness_recording = false; } - // Evaluate policy on certain time limit, or if we just started + // Evaluate policy on certain time limit, or if we just started. run at the end of 60s if ((elapsed_evaluation_time > this->evaluation_rate) or ((_time - _step) < 0.001)) { // Update position // this->evaluator->Update(this->robot->WorldPose(), _time, _step); this->start_fitness_recording = true; - // Get and save fitness (but not at start) + // Get and save fitness (but not at start): (_time > _step=0.125) if(not (_time - _step < 0.001 )) { + // obtains the current fitness by calling the evaluator and stores it this->save_fitness(); } @@ -753,7 +990,6 @@ void DifferentialCPG::Update( { this->reset_neuron_state(); } - // If we are still learning if(this->current_iteration < this->n_init_samples + this->n_learning_iterations) { @@ -761,23 +997,63 @@ void DifferentialCPG::Update( { if (this->current_iteration < this->n_init_samples) { - std::cout << std::endl << "Evaluating initial random sample" << std::endl; + std::cout << "Evaluating initial random sample" << std::endl; } else { - std::cout << std::endl << "I am learning " << std::endl; + std::cout << "I am learning " << std::endl; } } - // Get new sample (weights) and add sample - this->bo_step(); - - // Set new weights - this->set_ode_matrix(); + if(learner_algorithm == "BO") + { + // Get new sample (weights) and add sample +// if (this->current_iteration >= this->n_init_samples) +// { + this->bo_step(); //return new sample to samples +// } + // Set new weights + this->set_ode_matrix(); + } + if(learner_algorithm == "EA") + { + //only run EA to generate new populations once each popsize + if((this->current_iteration % pop_size == 0) and (this->current_iteration not_eq 0)) + { + // Get new samples (weights) (return all individuals to samples) + this->ea_step(); + } + //Set new weights (in a sample) specifies weight from neuron i to neuron j + this->set_ode_matrix(); + } + if(learner_algorithm == "BOEA") + { + // run BO +// if((this->current_iteration >= this->n_init_samples) and (this->current_iteration < switch_num)) + if(this->current_iteration < switch_num) + { + this->bo_step(); + } + // run EA + if(this->current_iteration >= switch_num) + { + if(this->current_iteration % pop_size == 0) + { + std::cout << "current_iteration: " << this->current_iteration << std::endl; + this->ea_step(); + } + } + // update the controller + this->set_ode_matrix(); + } + if(learner_algorithm == "HyperNEAT") + { + ////TODO + } // Update position // this->evaluator->Update(this->robot->WorldPose(), _time, _step); } - // If we are finished learning but are cooling down - reset once + // If we are finished learning but are cooling down - reset once else if((this->current_iteration >= (this->n_init_samples + this->n_learning_iterations)) and (this->current_iteration < (this->n_init_samples + @@ -820,6 +1096,20 @@ void DifferentialCPG::Update( this->start_time = _time; this->evaluator->Reset(); this->current_iteration += 1; + + // get the end time of an evaluation and learning process + if(not (_time - _step < 0.001 )) + { + gettimeofday(&timeEnd,NULL); + timeDiff = timeEnd.tv_sec - timeStart.tv_sec + 0.000001 * (timeEnd.tv_usec - timeStart.tv_usec); + // Write overhead time to file + std::ofstream ctime_file; + ctime_file.open(this->directory_name + "ctime.txt", std::ios::app); + ctime_file << std::fixed << timeDiff << std::endl; + ctime_file.close(); + } + // get the starting time of an evaluation + gettimeofday(&timeStart,NULL); } // Send new signals to the motors @@ -827,9 +1117,12 @@ void DifferentialCPG::Update( p = 0; for (const auto &motor: _motors) { +// this->output[p] = -1; motor->Update(this->output + p, _step); +// std::cout << '\t' << *(this->output+p); p += motor->Outputs(); } +// std::cout << std::endl; } /** @@ -851,9 +1144,33 @@ void DifferentialCPG::set_ode_matrix(){ } matrix.push_back(row); } - // Process A<->B connections - int index = 0; + auto index = 0; + + auto num_sample = 0; + if(this->learner_algorithm == "BO") + { + num_sample = this->current_iteration; + } + if(this->learner_algorithm == "EA") + { + num_sample = this->current_iteration % this->pop_size; + } + if(this->learner_algorithm == "BOEA") + { + if(this->current_iteration < switch_num) + { + num_sample = this->current_iteration; + } + if(this->current_iteration >= switch_num) + { + num_sample = this->current_iteration % this->pop_size; + } + } +// std::cout << "current_iteration: " << this->current_iteration +// << " num_sample: " << num_sample << std::endl; +// std::cout << "samples[" << num_sample << "]: " +// << this->samples[num_sample] << std::endl; for(size_t i =0; i neurons.size(); i++) { // Get correct index @@ -864,15 +1181,15 @@ void DifferentialCPG::set_ode_matrix(){ else{ c = i - 1; } - // Add a/b connection weight index = (int)(i/2); - auto w = this->samples.at(this->current_iteration)(index) * - (this->range_ub - this->range_lb) + this->range_lb; + +// std::cout << "i: " << i << " index: " << index << std::endl; +// std::cout << this->samples.at(num_sample)(index) << " "; + auto w = this->samples.at(num_sample)(index) * (this->range_ub - this->range_lb) + this->range_lb; matrix[i][c] = w; matrix[c][i] = -w; } - // A<->A connections index++; int k = 0; @@ -924,7 +1241,7 @@ void DifferentialCPG::set_ode_matrix(){ } // Get weight - auto w = this->samples.at(this->current_iteration)(index + k) * + auto w = this->samples.at(num_sample)(index + k) * (this->range_ub - this->range_lb) + this->range_lb; // Set connection in weight matrix @@ -942,7 +1259,7 @@ void DifferentialCPG::set_ode_matrix(){ // Save this sample to file std::ofstream samples_file; samples_file.open(this->directory_name + "samples.txt", std::ios::app); - auto sample = this->samples.at(this->current_iteration); + auto sample = this->samples.at(num_sample); for(size_t j = 0; j < this->n_weights; j++) { samples_file << sample(j) << ", "; @@ -951,7 +1268,6 @@ void DifferentialCPG::set_ode_matrix(){ samples_file.close(); } - /** * Set states back to original value (that is on the unit circle) */ @@ -1056,7 +1372,7 @@ void DifferentialCPG::step( this->next_state[i] = x[i]; } - // Loop over all neurons to actually update their states. Note that this is a new outer for loop + // Loop over all neurons to actually update their states. Note that this is a new outer for loop auto i = 0; auto j = 0; for (auto &neuron : this->neurons) { @@ -1081,7 +1397,6 @@ void DifferentialCPG::step( // Use frame of reference if(use_frame_of_reference) { - if (std::abs(frame_of_reference) == 1) { this->output[j] = this->signal_factor_left_right*this->abs_output_bound*((2.0)/(1.0 + std::pow(2.718, -2.0*x/this->abs_output_bound)) -1); @@ -1165,7 +1480,10 @@ void DifferentialCPG::save_parameters(){ parameters_file << "EXP-ARD Kernel k: "<< Params::kernel_squared_exp_ard::k() << std::endl; parameters_file << "EXP-ARD Kernel sigma_sq: "<< Params::kernel_squared_exp_ard::sigma_sq() << std::endl; parameters_file << "MFH Kernel sigma_sq: "<< Params::kernel_maternfivehalves::sigma_sq() << std::endl; - parameters_file << "MFH Kernel l: "<< Params::kernel_maternfivehalves::l() << std::endl << std::endl; + parameters_file << "MFH Kernel l: "<< Params::kernel_maternfivehalves::l() << std::endl; + parameters_file << "gaussian_step_size: "<< this->gaussian_step_size_ << std::endl; + parameters_file << "mutrate: "<< this->mutrate_ << std::endl << std::endl; + parameters_file.close(); } diff --git a/cpprevolve/revolve/gazebo/brains/DifferentialCPG.h b/cpprevolve/revolve/gazebo/brains/DifferentialCPG.h index 2595f83621..1910ec91dc 100644 --- a/cpprevolve/revolve/gazebo/brains/DifferentialCPG.h +++ b/cpprevolve/revolve/gazebo/brains/DifferentialCPG.h @@ -142,9 +142,15 @@ namespace revolve /// \brief Init BO loop public: void bo_init_sampling(); + /// \brief Init EA loop + public: void ea_init_sampling(); + /// \brief Main BO loop public: void bo_step(); + /// \brief Main EA loop + public: void ea_step(); + /// \brief evaluation rate private: double evaluation_rate; @@ -169,6 +175,12 @@ namespace revolve /// \brief Starting time private: double start_time; + /// \brief time interval evaluating and learning for each iteration + private: double timeDiff; + + /// \brief the time stamp of starting and end. + private: struct timeval timeStart, timeEnd; + /// \brief BO attributes private: size_t current_iteration = 0; @@ -178,6 +190,15 @@ namespace revolve /// \brief Number of initial samples private: size_t n_init_samples; + /// \brief Population size of Evolutionary Algorithm + private: size_t pop_size = 10; + + /// \brief Population size of Evolutionary Algorithm + private: size_t switch_num = 300; + + /// \brief The type of learning algorithm + private: std::string learner_algorithm = "BOEA"; + /// \brief Cool down period private: size_t n_cooldown_iterations; @@ -259,15 +280,20 @@ namespace revolve /// \brief Use frame of reference {-1,0,1} version or not private: bool use_frame_of_reference; - // BO Learner parameters - private: double kernel_noise_; - private: bool kernel_optimize_noise_; - public: double kernel_sigma_sq_; - public: double kernel_l_; - private: int kernel_squared_exp_ard_k_; - private: double acqui_gpucb_delta_ ; - public: double acqui_ucb_alpha_; - private: double acqui_ei_jitter_; + // BO Learner parameters + private: double kernel_noise_; + private: bool kernel_optimize_noise_; + public: double kernel_sigma_sq_; + public: double kernel_l_; + private: int kernel_squared_exp_ard_k_; + private: double acqui_gpucb_delta_ ; + public: double acqui_ucb_alpha_; + private: double acqui_ei_jitter_; + + //EA Learner parameters + public: double gaussian_step_size_; + public: double mutrate_; + }; } } diff --git a/cpprevolve/revolve/gazebo/brains/DifferentialCPG_BO.h b/cpprevolve/revolve/gazebo/brains/DifferentialCPG_BO.h index c859415630..3e19160d28 100644 --- a/cpprevolve/revolve/gazebo/brains/DifferentialCPG_BO.h +++ b/cpprevolve/revolve/gazebo/brains/DifferentialCPG_BO.h @@ -19,6 +19,8 @@ #include #include +#include + namespace limbo { namespace defaults { struct bayes_opt_boptimizer { @@ -86,61 +88,59 @@ namespace limbo { template void optimize(const StateFunction& sfun, std::vector all_samples, std::vector all_observations, const AggregatorFunction& afun = AggregatorFunction(), bool reset = true) { - this->_init(sfun, afun, reset); //reset - - // Maarten: set observations and samples - this->_samples = all_samples; - this->_observations = all_observations; - - if (!this->_observations.empty()) { - _model.compute(this->_samples, this->_observations); - } - else { - std::cout << "OBSERVATION SET IS EMPTY \n"; - _model = model_t(StateFunction::dim_in(), StateFunction::dim_out()); - } - acqui_optimizer_t acqui_optimizer; + this->_init(sfun, afun, reset); //reset - struct timeval timeStart, timeEnd; - double timeDiff; + // Maarten: set observations and samples + this->_samples = all_samples; + this->_observations = all_observations; - while (!this->_stop(*this, afun)) { + if (!this->_observations.empty()) { + _model.compute(this->_samples, this->_observations); + } + else { + std::cout << "OBSERVATION SET IS EMPTY \n"; + _model = model_t(StateFunction::dim_in(), StateFunction::dim_out()); + } + acqui_optimizer_t acqui_optimizer; - gettimeofday(&timeStart,NULL); + struct timeval timeStart, timeEnd; + double timeDiff; - acquisition_function_t acqui(_model, this->_current_iteration); + while (!this->_stop(*this, afun)) { + gettimeofday(&timeStart,NULL); + acquisition_function_t acqui(_model, this->_current_iteration); - auto acqui_optimization = - [&](const Eigen::VectorXd& x, bool g) { return acqui(x, afun, g); }; - Eigen::VectorXd starting_point = tools::random_vector(StateFunction::dim_in(), Params::bayes_opt_bobase::bounded()); + auto acqui_optimization = + [&](const Eigen::VectorXd& x, bool g) { return acqui(x, afun, g); }; + Eigen::VectorXd starting_point = tools::random_vector(StateFunction::dim_in(), Params::bayes_opt_bobase::bounded()); - // new samples are from the acquisition optimizer - Eigen::VectorXd new_sample = acqui_optimizer(acqui_optimization, starting_point, Params::bayes_opt_bobase::bounded()); + // new samples are from the acquisition optimizer + Eigen::VectorXd new_sample = acqui_optimizer(acqui_optimization, starting_point, Params::bayes_opt_bobase::bounded()); - ///Evaluate a sample and add the result to the 'database'(sample/observations vectors)--it does not update the model - this->eval_and_add(sfun, new_sample); + ///Evaluate a sample and add the result to the 'database'(sample/observations vectors)--it does not update the model + this->eval_and_add(sfun, new_sample); //add new_sample to _sample and sfun to _observations in bo_base.hpp - this->_update_stats(*this, afun); + this->_update_stats(*this, afun); - _model.add_sample(this->_samples.back(), this->_observations.back()); + _model.add_sample(this->_samples.back(), this->_observations.back()); - if (Params::bayes_opt_boptimizer::hp_period() > 0 - && (this->_current_iteration + 1) % Params::bayes_opt_boptimizer::hp_period() == 0) - _model.optimize_hyperparams(); + if (Params::bayes_opt_boptimizer::hp_period() > 0 + && (this->_current_iteration + 1) % Params::bayes_opt_boptimizer::hp_period() == 0) + _model.optimize_hyperparams(); - this->_current_iteration++; - this->_total_iterations++; + this->_current_iteration++; + this->_total_iterations++; - gettimeofday(&timeEnd,NULL); + gettimeofday(&timeEnd,NULL); - timeDiff = 1000000 * (timeEnd.tv_sec - timeStart.tv_sec) - + timeEnd.tv_usec - timeStart.tv_usec; //tv_sec: value of second, tv_usec: value of microsecond - timeDiff/=1000; + timeDiff = 1000000 * (timeEnd.tv_sec - timeStart.tv_sec) + + timeEnd.tv_usec - timeStart.tv_usec; //tv_sec: value of second, tv_usec: value of microsecond + timeDiff/=1000; - std::ofstream ctime; - ctime.open("../ctime.txt", std::ios::app); - ctime << std::fixed << timeDiff << std::endl; - } +// std::ofstream ctime; +// ctime.open("../ctime.txt", std::ios::app); +// ctime << std::fixed << timeDiff << std::endl; + } } /// return the best observation so far (i.e. max(f(x))) @@ -165,7 +165,7 @@ namespace limbo { /// Return a reference to the last sample. Used for implementation with revolve const Eigen::VectorXd& last_sample(){ - return this->_samples.back(); + return this->_samples.back(); //back(): return the last elelment of _samples } const model_t& model() const { return _model; } diff --git a/cpprevolve/revolve/gazebo/brains/Evaluator.cpp b/cpprevolve/revolve/gazebo/brains/Evaluator.cpp index e082cd1596..a1369e0662 100644 --- a/cpprevolve/revolve/gazebo/brains/Evaluator.cpp +++ b/cpprevolve/revolve/gazebo/brains/Evaluator.cpp @@ -20,7 +20,7 @@ */ #include - +#include_next #include "Evaluator.h" using namespace revolve::gazebo; @@ -47,7 +47,7 @@ Evaluator::Evaluator(const double _evaluationRate, this->current_position_.Reset(); this->previous_position_.Reset(); this->start_position_.Reset(); - this->locomotion_type = "directed"; // {directed, gait} + this->locomotion_type = "gait"; // {directed, gait} this->path_length = 0.0; } @@ -69,18 +69,34 @@ double Evaluator::Fitness() double fitness_value = 0.0; if(this->locomotion_type == "gait") { - double dS; - dS = std::sqrt(std::pow(this->previous_position_.Pos().X() - - this->current_position_.Pos().X(), 2) + - std::pow(this->previous_position_.Pos().Y() - - this->current_position_.Pos().Y(), 2)); + double dS = 0.0; +// dS = std::sqrt(std::pow(this->previous_position_.Pos().X() - +// this->current_position_.Pos().X(), 2) + +// std::pow(this->previous_position_.Pos().Y() - +// this->current_position_.Pos().Y(), 2)); + for(int i = 1; i < this->step_poses.size(); i++) + { + const auto &pose_i_1 = this->step_poses[i-1]; + const auto &pose_i = this->step_poses[i]; + dS += Evaluator::measure_distance(pose_i_1, pose_i); + //save coordinations to coordinates.txt + std::ofstream coordinates; + coordinates.open(this->directory_name + "/coordinates.txt",std::ios::app); + if(i == 1) + { + start_position_ = pose_i_1; + coordinates << std::fixed << start_position_.Pos().X() << " " << start_position_.Pos().Y() << std::endl; + } + coordinates << std::fixed << pose_i.Pos().X() << " " << pose_i.Pos().Y() << std::endl; + } + fitness_value = dS / this->evaluation_rate_; } else if (this->locomotion_type == "directed") { - this->step_poses.push_back(this->current_position_); //step_poses: x y z roll pitch yaw +// std::cout << "step_poses.size(): " << step_poses.size() << " "; for (int i=1; i < this->step_poses.size(); i++) { const auto &pose_i_1 = this->step_poses[i-1]; @@ -92,20 +108,22 @@ double Evaluator::Fitness() if(i == 1) { - coordinates << std::fixed << start_position_.Pos().X() << " " << start_position_.Pos().Y() << std::endl; + start_position_ = pose_i_1; + coordinates << std::fixed << start_position_.Pos().X() << " " << start_position_.Pos().Y() << std::endl; } coordinates << std::fixed << pose_i.Pos().X() << " " << pose_i.Pos().Y() << std::endl; } - +// std::cout << "path_length " << path_length << " "; ////********** directed locomotion fitness function **********//// //directions(forward) of heads are the orientation(+x axis) - 1.570796 double beta0 = this->start_position_.Rot().Yaw()- M_PI/2.0; + if (beta0 < - M_PI) //always less than pi (beta0 + max(40degree) < pi) { beta0 = 2 * M_PI - std::abs(beta0); } - //save direction to coordinates.txt: This is used to make Figure 8 + //save direction to coordinates.txt std::ofstream coordinates; coordinates.open(this->directory_name + "/coordinates.txt",std::ios::app); coordinates << std::fixed << beta0 << std::endl; diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/body.pb.cc b/cpprevolve/revolve/gazebo/revolve/msgs/body.pb.cc new file mode 100644 index 0000000000..68e5b9a9fc --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/body.pb.cc @@ -0,0 +1,1262 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: body.proto + +#include "body.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include +extern PROTOBUF_INTERNAL_EXPORT_body_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_BodyConnection_body_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_parameter_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Parameter_parameter_2eproto; +namespace revolve { +namespace msgs { +class BodyPartDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _BodyPart_default_instance_; +class BodyConnectionDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _BodyConnection_default_instance_; +class BodyDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _Body_default_instance_; +} // namespace msgs +} // namespace revolve +static void InitDefaultsscc_info_Body_body_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_Body_default_instance_; + new (ptr) ::revolve::msgs::Body(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::Body::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Body_body_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_Body_body_2eproto}, { + &scc_info_BodyConnection_body_2eproto.base,}}; + +static void InitDefaultsscc_info_BodyConnection_body_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_BodyPart_default_instance_; + new (ptr) ::revolve::msgs::BodyPart(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + { + void* ptr = &::revolve::msgs::_BodyConnection_default_instance_; + new (ptr) ::revolve::msgs::BodyConnection(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::BodyPart::InitAsDefaultInstance(); + ::revolve::msgs::BodyConnection::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_BodyConnection_body_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_BodyConnection_body_2eproto}, { + &scc_info_Parameter_parameter_2eproto.base,}}; + +static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_body_2eproto[3]; +static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_body_2eproto = nullptr; +static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_body_2eproto = nullptr; + +const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_body_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyPart, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyPart, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyPart, id_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyPart, type_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyPart, x_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyPart, y_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyPart, orientation_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyPart, child_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyPart, param_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyPart, label_), + 0, + 1, + 3, + 4, + 5, + ~0u, + ~0u, + 2, + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyConnection, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyConnection, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyConnection, src_slot_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyConnection, dst_slot_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyConnection, part_), + 1, + 2, + 0, + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Body, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Body, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Body, root_), + 0, +}; +static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 13, sizeof(::revolve::msgs::BodyPart)}, + { 21, 29, sizeof(::revolve::msgs::BodyConnection)}, + { 32, 38, sizeof(::revolve::msgs::Body)}, +}; + +static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { + reinterpret_cast(&::revolve::msgs::_BodyPart_default_instance_), + reinterpret_cast(&::revolve::msgs::_BodyConnection_default_instance_), + reinterpret_cast(&::revolve::msgs::_Body_default_instance_), +}; + +const char descriptor_table_protodef_body_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\nbody.proto\022\014revolve.msgs\032\017parameter.pr" + "oto\"\263\001\n\010BodyPart\022\n\n\002id\030\001 \002(\t\022\014\n\004type\030\002 \002" + "(\t\022\t\n\001x\030\003 \002(\005\022\t\n\001y\030\004 \002(\005\022\023\n\013orientation\030" + "\005 \002(\001\022+\n\005child\030\006 \003(\0132\034.revolve.msgs.Body" + "Connection\022&\n\005param\030\007 \003(\0132\027.revolve.msgs" + ".Parameter\022\r\n\005label\030\010 \001(\t\"Z\n\016BodyConnect" + "ion\022\020\n\010src_slot\030\001 \002(\005\022\020\n\010dst_slot\030\002 \002(\005\022" + "$\n\004part\030\003 \002(\0132\026.revolve.msgs.BodyPart\",\n" + "\004Body\022$\n\004root\030\001 \002(\0132\026.revolve.msgs.BodyP" + "art" + ; +static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_body_2eproto_deps[1] = { + &::descriptor_table_parameter_2eproto, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_body_2eproto_sccs[2] = { + &scc_info_Body_body_2eproto.base, + &scc_info_BodyConnection_body_2eproto.base, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_body_2eproto_once; +const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_body_2eproto = { + false, false, descriptor_table_protodef_body_2eproto, "body.proto", 363, + &descriptor_table_body_2eproto_once, descriptor_table_body_2eproto_sccs, descriptor_table_body_2eproto_deps, 2, 1, + schemas, file_default_instances, TableStruct_body_2eproto::offsets, + file_level_metadata_body_2eproto, 3, file_level_enum_descriptors_body_2eproto, file_level_service_descriptors_body_2eproto, +}; + +// Force running AddDescriptors() at dynamic initialization time. +static bool dynamic_init_dummy_body_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_body_2eproto)), true); +namespace revolve { +namespace msgs { + +// =================================================================== + +void BodyPart::InitAsDefaultInstance() { +} +class BodyPart::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_id(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_x(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static void set_has_y(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static void set_has_orientation(HasBits* has_bits) { + (*has_bits)[0] |= 32u; + } + static void set_has_label(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x0000003b) ^ 0x0000003b) != 0; + } +}; + +void BodyPart::clear_param() { + param_.Clear(); +} +BodyPart::BodyPart(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + child_(arena), + param_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.BodyPart) +} +BodyPart::BodyPart(const BodyPart& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + child_(from.child_), + param_(from.param_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_id()) { + id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_id(), + GetArena()); + } + type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_type()) { + type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_type(), + GetArena()); + } + label_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_label()) { + label_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_label(), + GetArena()); + } + ::memcpy(&x_, &from.x_, + static_cast(reinterpret_cast(&orientation_) - + reinterpret_cast(&x_)) + sizeof(orientation_)); + // @@protoc_insertion_point(copy_constructor:revolve.msgs.BodyPart) +} + +void BodyPart::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_BodyConnection_body_2eproto.base); + id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + label_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + ::memset(&x_, 0, static_cast( + reinterpret_cast(&orientation_) - + reinterpret_cast(&x_)) + sizeof(orientation_)); +} + +BodyPart::~BodyPart() { + // @@protoc_insertion_point(destructor:revolve.msgs.BodyPart) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void BodyPart::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + id_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + label_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void BodyPart::ArenaDtor(void* object) { + BodyPart* _this = reinterpret_cast< BodyPart* >(object); + (void)_this; +} +void BodyPart::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void BodyPart::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const BodyPart& BodyPart::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_BodyConnection_body_2eproto.base); + return *internal_default_instance(); +} + + +void BodyPart::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.BodyPart) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + child_.Clear(); + param_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000001u) { + id_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + type_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000004u) { + label_.ClearNonDefaultToEmpty(); + } + } + if (cached_has_bits & 0x00000038u) { + ::memset(&x_, 0, static_cast( + reinterpret_cast(&orientation_) - + reinterpret_cast(&x_)) + sizeof(orientation_)); + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* BodyPart::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required string id = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_id(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.BodyPart.id"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required string type = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + auto str = _internal_mutable_type(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.BodyPart.type"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required int32 x = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { + _Internal::set_has_x(&has_bits); + x_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // required int32 y = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { + _Internal::set_has_y(&has_bits); + y_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // required double orientation = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 41)) { + _Internal::set_has_orientation(&has_bits); + orientation_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); + ptr += sizeof(double); + } else goto handle_unusual; + continue; + // repeated .revolve.msgs.BodyConnection child = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 50)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_child(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); + } else goto handle_unusual; + continue; + // repeated .revolve.msgs.Parameter param = 7; + case 7: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_param(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<58>(ptr)); + } else goto handle_unusual; + continue; + // optional string label = 8; + case 8: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 66)) { + auto str = _internal_mutable_label(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.BodyPart.label"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* BodyPart::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.BodyPart) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required string id = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_id().data(), static_cast(this->_internal_id().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.BodyPart.id"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_id(), target); + } + + // required string type = 2; + if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_type().data(), static_cast(this->_internal_type().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.BodyPart.type"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_type(), target); + } + + // required int32 x = 3; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_x(), target); + } + + // required int32 y = 4; + if (cached_has_bits & 0x00000010u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_y(), target); + } + + // required double orientation = 5; + if (cached_has_bits & 0x00000020u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(5, this->_internal_orientation(), target); + } + + // repeated .revolve.msgs.BodyConnection child = 6; + for (unsigned int i = 0, + n = static_cast(this->_internal_child_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(6, this->_internal_child(i), target, stream); + } + + // repeated .revolve.msgs.Parameter param = 7; + for (unsigned int i = 0, + n = static_cast(this->_internal_param_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(7, this->_internal_param(i), target, stream); + } + + // optional string label = 8; + if (cached_has_bits & 0x00000004u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_label().data(), static_cast(this->_internal_label().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.BodyPart.label"); + target = stream->WriteStringMaybeAliased( + 8, this->_internal_label(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.BodyPart) + return target; +} + +size_t BodyPart::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:revolve.msgs.BodyPart) + size_t total_size = 0; + + if (_internal_has_id()) { + // required string id = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_id()); + } + + if (_internal_has_type()) { + // required string type = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_type()); + } + + if (_internal_has_x()) { + // required int32 x = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_x()); + } + + if (_internal_has_y()) { + // required int32 y = 4; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_y()); + } + + if (_internal_has_orientation()) { + // required double orientation = 5; + total_size += 1 + 8; + } + + return total_size; +} +size_t BodyPart::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.BodyPart) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x0000003b) ^ 0x0000003b) == 0) { // All required fields are present. + // required string id = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_id()); + + // required string type = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_type()); + + // required int32 x = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_x()); + + // required int32 y = 4; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_y()); + + // required double orientation = 5; + total_size += 1 + 8; + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .revolve.msgs.BodyConnection child = 6; + total_size += 1UL * this->_internal_child_size(); + for (const auto& msg : this->child_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // repeated .revolve.msgs.Parameter param = 7; + total_size += 1UL * this->_internal_param_size(); + for (const auto& msg : this->param_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // optional string label = 8; + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_label()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void BodyPart::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.BodyPart) + GOOGLE_DCHECK_NE(&from, this); + const BodyPart* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.BodyPart) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.BodyPart) + MergeFrom(*source); + } +} + +void BodyPart::MergeFrom(const BodyPart& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.BodyPart) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + child_.MergeFrom(from.child_); + param_.MergeFrom(from.param_); + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x0000003fu) { + if (cached_has_bits & 0x00000001u) { + _internal_set_id(from._internal_id()); + } + if (cached_has_bits & 0x00000002u) { + _internal_set_type(from._internal_type()); + } + if (cached_has_bits & 0x00000004u) { + _internal_set_label(from._internal_label()); + } + if (cached_has_bits & 0x00000008u) { + x_ = from.x_; + } + if (cached_has_bits & 0x00000010u) { + y_ = from.y_; + } + if (cached_has_bits & 0x00000020u) { + orientation_ = from.orientation_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void BodyPart::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.BodyPart) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void BodyPart::CopyFrom(const BodyPart& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.BodyPart) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool BodyPart::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(child_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(param_)) return false; + return true; +} + +void BodyPart::InternalSwap(BodyPart* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + child_.InternalSwap(&other->child_); + param_.InternalSwap(&other->param_); + id_.Swap(&other->id_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + type_.Swap(&other->type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + label_.Swap(&other->label_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(BodyPart, orientation_) + + sizeof(BodyPart::orientation_) + - PROTOBUF_FIELD_OFFSET(BodyPart, x_)>( + reinterpret_cast(&x_), + reinterpret_cast(&other->x_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata BodyPart::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void BodyConnection::InitAsDefaultInstance() { + ::revolve::msgs::_BodyConnection_default_instance_._instance.get_mutable()->part_ = const_cast< ::revolve::msgs::BodyPart*>( + ::revolve::msgs::BodyPart::internal_default_instance()); +} +class BodyConnection::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_src_slot(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_dst_slot(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static const ::revolve::msgs::BodyPart& part(const BodyConnection* msg); + static void set_has_part(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000007) ^ 0x00000007) != 0; + } +}; + +const ::revolve::msgs::BodyPart& +BodyConnection::_Internal::part(const BodyConnection* msg) { + return *msg->part_; +} +BodyConnection::BodyConnection(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.BodyConnection) +} +BodyConnection::BodyConnection(const BodyConnection& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_part()) { + part_ = new ::revolve::msgs::BodyPart(*from.part_); + } else { + part_ = nullptr; + } + ::memcpy(&src_slot_, &from.src_slot_, + static_cast(reinterpret_cast(&dst_slot_) - + reinterpret_cast(&src_slot_)) + sizeof(dst_slot_)); + // @@protoc_insertion_point(copy_constructor:revolve.msgs.BodyConnection) +} + +void BodyConnection::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_BodyConnection_body_2eproto.base); + ::memset(&part_, 0, static_cast( + reinterpret_cast(&dst_slot_) - + reinterpret_cast(&part_)) + sizeof(dst_slot_)); +} + +BodyConnection::~BodyConnection() { + // @@protoc_insertion_point(destructor:revolve.msgs.BodyConnection) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void BodyConnection::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + if (this != internal_default_instance()) delete part_; +} + +void BodyConnection::ArenaDtor(void* object) { + BodyConnection* _this = reinterpret_cast< BodyConnection* >(object); + (void)_this; +} +void BodyConnection::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void BodyConnection::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const BodyConnection& BodyConnection::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_BodyConnection_body_2eproto.base); + return *internal_default_instance(); +} + + +void BodyConnection::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.BodyConnection) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(part_ != nullptr); + part_->Clear(); + } + if (cached_has_bits & 0x00000006u) { + ::memset(&src_slot_, 0, static_cast( + reinterpret_cast(&dst_slot_) - + reinterpret_cast(&src_slot_)) + sizeof(dst_slot_)); + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* BodyConnection::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required int32 src_slot = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + _Internal::set_has_src_slot(&has_bits); + src_slot_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // required int32 dst_slot = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + _Internal::set_has_dst_slot(&has_bits); + dst_slot_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // required .revolve.msgs.BodyPart part = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { + ptr = ctx->ParseMessage(_internal_mutable_part(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* BodyConnection::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.BodyConnection) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required int32 src_slot = 1; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_src_slot(), target); + } + + // required int32 dst_slot = 2; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_dst_slot(), target); + } + + // required .revolve.msgs.BodyPart part = 3; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 3, _Internal::part(this), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.BodyConnection) + return target; +} + +size_t BodyConnection::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:revolve.msgs.BodyConnection) + size_t total_size = 0; + + if (_internal_has_part()) { + // required .revolve.msgs.BodyPart part = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *part_); + } + + if (_internal_has_src_slot()) { + // required int32 src_slot = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_src_slot()); + } + + if (_internal_has_dst_slot()) { + // required int32 dst_slot = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_dst_slot()); + } + + return total_size; +} +size_t BodyConnection::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.BodyConnection) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) { // All required fields are present. + // required .revolve.msgs.BodyPart part = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *part_); + + // required int32 src_slot = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_src_slot()); + + // required int32 dst_slot = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_dst_slot()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void BodyConnection::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.BodyConnection) + GOOGLE_DCHECK_NE(&from, this); + const BodyConnection* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.BodyConnection) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.BodyConnection) + MergeFrom(*source); + } +} + +void BodyConnection::MergeFrom(const BodyConnection& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.BodyConnection) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000001u) { + _internal_mutable_part()->::revolve::msgs::BodyPart::MergeFrom(from._internal_part()); + } + if (cached_has_bits & 0x00000002u) { + src_slot_ = from.src_slot_; + } + if (cached_has_bits & 0x00000004u) { + dst_slot_ = from.dst_slot_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void BodyConnection::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.BodyConnection) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void BodyConnection::CopyFrom(const BodyConnection& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.BodyConnection) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool BodyConnection::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_internal_has_part()) { + if (!part_->IsInitialized()) return false; + } + return true; +} + +void BodyConnection::InternalSwap(BodyConnection* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(BodyConnection, dst_slot_) + + sizeof(BodyConnection::dst_slot_) + - PROTOBUF_FIELD_OFFSET(BodyConnection, part_)>( + reinterpret_cast(&part_), + reinterpret_cast(&other->part_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata BodyConnection::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void Body::InitAsDefaultInstance() { + ::revolve::msgs::_Body_default_instance_._instance.get_mutable()->root_ = const_cast< ::revolve::msgs::BodyPart*>( + ::revolve::msgs::BodyPart::internal_default_instance()); +} +class Body::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static const ::revolve::msgs::BodyPart& root(const Body* msg); + static void set_has_root(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; + } +}; + +const ::revolve::msgs::BodyPart& +Body::_Internal::root(const Body* msg) { + return *msg->root_; +} +Body::Body(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.Body) +} +Body::Body(const Body& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_root()) { + root_ = new ::revolve::msgs::BodyPart(*from.root_); + } else { + root_ = nullptr; + } + // @@protoc_insertion_point(copy_constructor:revolve.msgs.Body) +} + +void Body::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Body_body_2eproto.base); + root_ = nullptr; +} + +Body::~Body() { + // @@protoc_insertion_point(destructor:revolve.msgs.Body) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void Body::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + if (this != internal_default_instance()) delete root_; +} + +void Body::ArenaDtor(void* object) { + Body* _this = reinterpret_cast< Body* >(object); + (void)_this; +} +void Body::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void Body::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const Body& Body::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Body_body_2eproto.base); + return *internal_default_instance(); +} + + +void Body::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.Body) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(root_ != nullptr); + root_->Clear(); + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Body::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required .revolve.msgs.BodyPart root = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_root(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* Body::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.Body) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required .revolve.msgs.BodyPart root = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 1, _Internal::root(this), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.Body) + return target; +} + +size_t Body::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.Body) + size_t total_size = 0; + + // required .revolve.msgs.BodyPart root = 1; + if (_internal_has_root()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *root_); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void Body::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.Body) + GOOGLE_DCHECK_NE(&from, this); + const Body* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.Body) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.Body) + MergeFrom(*source); + } +} + +void Body::MergeFrom(const Body& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.Body) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_has_root()) { + _internal_mutable_root()->::revolve::msgs::BodyPart::MergeFrom(from._internal_root()); + } +} + +void Body::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.Body) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Body::CopyFrom(const Body& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.Body) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Body::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_internal_has_root()) { + if (!root_->IsInitialized()) return false; + } + return true; +} + +void Body::InternalSwap(Body* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + swap(root_, other->root_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Body::GetMetadata() const { + return GetMetadataStatic(); +} + + +// @@protoc_insertion_point(namespace_scope) +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::revolve::msgs::BodyPart* Arena::CreateMaybeMessage< ::revolve::msgs::BodyPart >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::BodyPart >(arena); +} +template<> PROTOBUF_NOINLINE ::revolve::msgs::BodyConnection* Arena::CreateMaybeMessage< ::revolve::msgs::BodyConnection >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::BodyConnection >(arena); +} +template<> PROTOBUF_NOINLINE ::revolve::msgs::Body* Arena::CreateMaybeMessage< ::revolve::msgs::Body >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::Body >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/body.pb.h b/cpprevolve/revolve/gazebo/revolve/msgs/body.pb.h new file mode 100644 index 0000000000..0a723305a4 --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/body.pb.h @@ -0,0 +1,1346 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: body.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_body_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_body_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3013000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3013000 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include "parameter.pb.h" +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_body_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_body_2eproto { + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[3] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; + static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; + static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_body_2eproto; +namespace revolve { +namespace msgs { +class Body; +class BodyDefaultTypeInternal; +extern BodyDefaultTypeInternal _Body_default_instance_; +class BodyConnection; +class BodyConnectionDefaultTypeInternal; +extern BodyConnectionDefaultTypeInternal _BodyConnection_default_instance_; +class BodyPart; +class BodyPartDefaultTypeInternal; +extern BodyPartDefaultTypeInternal _BodyPart_default_instance_; +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> ::revolve::msgs::Body* Arena::CreateMaybeMessage<::revolve::msgs::Body>(Arena*); +template<> ::revolve::msgs::BodyConnection* Arena::CreateMaybeMessage<::revolve::msgs::BodyConnection>(Arena*); +template<> ::revolve::msgs::BodyPart* Arena::CreateMaybeMessage<::revolve::msgs::BodyPart>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace revolve { +namespace msgs { + +// =================================================================== + +class BodyPart PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.BodyPart) */ { + public: + inline BodyPart() : BodyPart(nullptr) {} + virtual ~BodyPart(); + + BodyPart(const BodyPart& from); + BodyPart(BodyPart&& from) noexcept + : BodyPart() { + *this = ::std::move(from); + } + + inline BodyPart& operator=(const BodyPart& from) { + CopyFrom(from); + return *this; + } + inline BodyPart& operator=(BodyPart&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const BodyPart& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const BodyPart* internal_default_instance() { + return reinterpret_cast( + &_BodyPart_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(BodyPart& a, BodyPart& b) { + a.Swap(&b); + } + inline void Swap(BodyPart* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(BodyPart* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline BodyPart* New() const final { + return CreateMaybeMessage(nullptr); + } + + BodyPart* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const BodyPart& from); + void MergeFrom(const BodyPart& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(BodyPart* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.BodyPart"; + } + protected: + explicit BodyPart(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_body_2eproto); + return ::descriptor_table_body_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kChildFieldNumber = 6, + kParamFieldNumber = 7, + kIdFieldNumber = 1, + kTypeFieldNumber = 2, + kLabelFieldNumber = 8, + kXFieldNumber = 3, + kYFieldNumber = 4, + kOrientationFieldNumber = 5, + }; + // repeated .revolve.msgs.BodyConnection child = 6; + int child_size() const; + private: + int _internal_child_size() const; + public: + void clear_child(); + ::revolve::msgs::BodyConnection* mutable_child(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::BodyConnection >* + mutable_child(); + private: + const ::revolve::msgs::BodyConnection& _internal_child(int index) const; + ::revolve::msgs::BodyConnection* _internal_add_child(); + public: + const ::revolve::msgs::BodyConnection& child(int index) const; + ::revolve::msgs::BodyConnection* add_child(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::BodyConnection >& + child() const; + + // repeated .revolve.msgs.Parameter param = 7; + int param_size() const; + private: + int _internal_param_size() const; + public: + void clear_param(); + ::revolve::msgs::Parameter* mutable_param(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >* + mutable_param(); + private: + const ::revolve::msgs::Parameter& _internal_param(int index) const; + ::revolve::msgs::Parameter* _internal_add_param(); + public: + const ::revolve::msgs::Parameter& param(int index) const; + ::revolve::msgs::Parameter* add_param(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >& + param() const; + + // required string id = 1; + bool has_id() const; + private: + bool _internal_has_id() const; + public: + void clear_id(); + const std::string& id() const; + void set_id(const std::string& value); + void set_id(std::string&& value); + void set_id(const char* value); + void set_id(const char* value, size_t size); + std::string* mutable_id(); + std::string* release_id(); + void set_allocated_id(std::string* id); + private: + const std::string& _internal_id() const; + void _internal_set_id(const std::string& value); + std::string* _internal_mutable_id(); + public: + + // required string type = 2; + bool has_type() const; + private: + bool _internal_has_type() const; + public: + void clear_type(); + const std::string& type() const; + void set_type(const std::string& value); + void set_type(std::string&& value); + void set_type(const char* value); + void set_type(const char* value, size_t size); + std::string* mutable_type(); + std::string* release_type(); + void set_allocated_type(std::string* type); + private: + const std::string& _internal_type() const; + void _internal_set_type(const std::string& value); + std::string* _internal_mutable_type(); + public: + + // optional string label = 8; + bool has_label() const; + private: + bool _internal_has_label() const; + public: + void clear_label(); + const std::string& label() const; + void set_label(const std::string& value); + void set_label(std::string&& value); + void set_label(const char* value); + void set_label(const char* value, size_t size); + std::string* mutable_label(); + std::string* release_label(); + void set_allocated_label(std::string* label); + private: + const std::string& _internal_label() const; + void _internal_set_label(const std::string& value); + std::string* _internal_mutable_label(); + public: + + // required int32 x = 3; + bool has_x() const; + private: + bool _internal_has_x() const; + public: + void clear_x(); + ::PROTOBUF_NAMESPACE_ID::int32 x() const; + void set_x(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_x() const; + void _internal_set_x(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // required int32 y = 4; + bool has_y() const; + private: + bool _internal_has_y() const; + public: + void clear_y(); + ::PROTOBUF_NAMESPACE_ID::int32 y() const; + void set_y(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_y() const; + void _internal_set_y(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // required double orientation = 5; + bool has_orientation() const; + private: + bool _internal_has_orientation() const; + public: + void clear_orientation(); + double orientation() const; + void set_orientation(double value); + private: + double _internal_orientation() const; + void _internal_set_orientation(double value); + public: + + // @@protoc_insertion_point(class_scope:revolve.msgs.BodyPart) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::BodyConnection > child_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter > param_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr id_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr label_; + ::PROTOBUF_NAMESPACE_ID::int32 x_; + ::PROTOBUF_NAMESPACE_ID::int32 y_; + double orientation_; + friend struct ::TableStruct_body_2eproto; +}; +// ------------------------------------------------------------------- + +class BodyConnection PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.BodyConnection) */ { + public: + inline BodyConnection() : BodyConnection(nullptr) {} + virtual ~BodyConnection(); + + BodyConnection(const BodyConnection& from); + BodyConnection(BodyConnection&& from) noexcept + : BodyConnection() { + *this = ::std::move(from); + } + + inline BodyConnection& operator=(const BodyConnection& from) { + CopyFrom(from); + return *this; + } + inline BodyConnection& operator=(BodyConnection&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const BodyConnection& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const BodyConnection* internal_default_instance() { + return reinterpret_cast( + &_BodyConnection_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(BodyConnection& a, BodyConnection& b) { + a.Swap(&b); + } + inline void Swap(BodyConnection* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(BodyConnection* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline BodyConnection* New() const final { + return CreateMaybeMessage(nullptr); + } + + BodyConnection* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const BodyConnection& from); + void MergeFrom(const BodyConnection& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(BodyConnection* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.BodyConnection"; + } + protected: + explicit BodyConnection(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_body_2eproto); + return ::descriptor_table_body_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kPartFieldNumber = 3, + kSrcSlotFieldNumber = 1, + kDstSlotFieldNumber = 2, + }; + // required .revolve.msgs.BodyPart part = 3; + bool has_part() const; + private: + bool _internal_has_part() const; + public: + void clear_part(); + const ::revolve::msgs::BodyPart& part() const; + ::revolve::msgs::BodyPart* release_part(); + ::revolve::msgs::BodyPart* mutable_part(); + void set_allocated_part(::revolve::msgs::BodyPart* part); + private: + const ::revolve::msgs::BodyPart& _internal_part() const; + ::revolve::msgs::BodyPart* _internal_mutable_part(); + public: + void unsafe_arena_set_allocated_part( + ::revolve::msgs::BodyPart* part); + ::revolve::msgs::BodyPart* unsafe_arena_release_part(); + + // required int32 src_slot = 1; + bool has_src_slot() const; + private: + bool _internal_has_src_slot() const; + public: + void clear_src_slot(); + ::PROTOBUF_NAMESPACE_ID::int32 src_slot() const; + void set_src_slot(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_src_slot() const; + void _internal_set_src_slot(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // required int32 dst_slot = 2; + bool has_dst_slot() const; + private: + bool _internal_has_dst_slot() const; + public: + void clear_dst_slot(); + ::PROTOBUF_NAMESPACE_ID::int32 dst_slot() const; + void set_dst_slot(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_dst_slot() const; + void _internal_set_dst_slot(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:revolve.msgs.BodyConnection) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::revolve::msgs::BodyPart* part_; + ::PROTOBUF_NAMESPACE_ID::int32 src_slot_; + ::PROTOBUF_NAMESPACE_ID::int32 dst_slot_; + friend struct ::TableStruct_body_2eproto; +}; +// ------------------------------------------------------------------- + +class Body PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.Body) */ { + public: + inline Body() : Body(nullptr) {} + virtual ~Body(); + + Body(const Body& from); + Body(Body&& from) noexcept + : Body() { + *this = ::std::move(from); + } + + inline Body& operator=(const Body& from) { + CopyFrom(from); + return *this; + } + inline Body& operator=(Body&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const Body& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const Body* internal_default_instance() { + return reinterpret_cast( + &_Body_default_instance_); + } + static constexpr int kIndexInFileMessages = + 2; + + friend void swap(Body& a, Body& b) { + a.Swap(&b); + } + inline void Swap(Body* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Body* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline Body* New() const final { + return CreateMaybeMessage(nullptr); + } + + Body* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const Body& from); + void MergeFrom(const Body& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Body* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.Body"; + } + protected: + explicit Body(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_body_2eproto); + return ::descriptor_table_body_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kRootFieldNumber = 1, + }; + // required .revolve.msgs.BodyPart root = 1; + bool has_root() const; + private: + bool _internal_has_root() const; + public: + void clear_root(); + const ::revolve::msgs::BodyPart& root() const; + ::revolve::msgs::BodyPart* release_root(); + ::revolve::msgs::BodyPart* mutable_root(); + void set_allocated_root(::revolve::msgs::BodyPart* root); + private: + const ::revolve::msgs::BodyPart& _internal_root() const; + ::revolve::msgs::BodyPart* _internal_mutable_root(); + public: + void unsafe_arena_set_allocated_root( + ::revolve::msgs::BodyPart* root); + ::revolve::msgs::BodyPart* unsafe_arena_release_root(); + + // @@protoc_insertion_point(class_scope:revolve.msgs.Body) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::revolve::msgs::BodyPart* root_; + friend struct ::TableStruct_body_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// BodyPart + +// required string id = 1; +inline bool BodyPart::_internal_has_id() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool BodyPart::has_id() const { + return _internal_has_id(); +} +inline void BodyPart::clear_id() { + id_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& BodyPart::id() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyPart.id) + return _internal_id(); +} +inline void BodyPart::set_id(const std::string& value) { + _internal_set_id(value); + // @@protoc_insertion_point(field_set:revolve.msgs.BodyPart.id) +} +inline std::string* BodyPart::mutable_id() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.BodyPart.id) + return _internal_mutable_id(); +} +inline const std::string& BodyPart::_internal_id() const { + return id_.Get(); +} +inline void BodyPart::_internal_set_id(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void BodyPart::set_id(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + id_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.BodyPart.id) +} +inline void BodyPart::set_id(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.BodyPart.id) +} +inline void BodyPart::set_id(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.BodyPart.id) +} +inline std::string* BodyPart::_internal_mutable_id() { + _has_bits_[0] |= 0x00000001u; + return id_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* BodyPart::release_id() { + // @@protoc_insertion_point(field_release:revolve.msgs.BodyPart.id) + if (!_internal_has_id()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return id_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void BodyPart::set_allocated_id(std::string* id) { + if (id != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + id_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), id, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.BodyPart.id) +} + +// required string type = 2; +inline bool BodyPart::_internal_has_type() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool BodyPart::has_type() const { + return _internal_has_type(); +} +inline void BodyPart::clear_type() { + type_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000002u; +} +inline const std::string& BodyPart::type() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyPart.type) + return _internal_type(); +} +inline void BodyPart::set_type(const std::string& value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:revolve.msgs.BodyPart.type) +} +inline std::string* BodyPart::mutable_type() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.BodyPart.type) + return _internal_mutable_type(); +} +inline const std::string& BodyPart::_internal_type() const { + return type_.Get(); +} +inline void BodyPart::_internal_set_type(const std::string& value) { + _has_bits_[0] |= 0x00000002u; + type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void BodyPart::set_type(std::string&& value) { + _has_bits_[0] |= 0x00000002u; + type_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.BodyPart.type) +} +inline void BodyPart::set_type(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000002u; + type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.BodyPart.type) +} +inline void BodyPart::set_type(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000002u; + type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.BodyPart.type) +} +inline std::string* BodyPart::_internal_mutable_type() { + _has_bits_[0] |= 0x00000002u; + return type_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* BodyPart::release_type() { + // @@protoc_insertion_point(field_release:revolve.msgs.BodyPart.type) + if (!_internal_has_type()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000002u; + return type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void BodyPart::set_allocated_type(std::string* type) { + if (type != nullptr) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.BodyPart.type) +} + +// required int32 x = 3; +inline bool BodyPart::_internal_has_x() const { + bool value = (_has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool BodyPart::has_x() const { + return _internal_has_x(); +} +inline void BodyPart::clear_x() { + x_ = 0; + _has_bits_[0] &= ~0x00000008u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BodyPart::_internal_x() const { + return x_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BodyPart::x() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyPart.x) + return _internal_x(); +} +inline void BodyPart::_internal_set_x(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000008u; + x_ = value; +} +inline void BodyPart::set_x(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_x(value); + // @@protoc_insertion_point(field_set:revolve.msgs.BodyPart.x) +} + +// required int32 y = 4; +inline bool BodyPart::_internal_has_y() const { + bool value = (_has_bits_[0] & 0x00000010u) != 0; + return value; +} +inline bool BodyPart::has_y() const { + return _internal_has_y(); +} +inline void BodyPart::clear_y() { + y_ = 0; + _has_bits_[0] &= ~0x00000010u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BodyPart::_internal_y() const { + return y_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BodyPart::y() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyPart.y) + return _internal_y(); +} +inline void BodyPart::_internal_set_y(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000010u; + y_ = value; +} +inline void BodyPart::set_y(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_y(value); + // @@protoc_insertion_point(field_set:revolve.msgs.BodyPart.y) +} + +// required double orientation = 5; +inline bool BodyPart::_internal_has_orientation() const { + bool value = (_has_bits_[0] & 0x00000020u) != 0; + return value; +} +inline bool BodyPart::has_orientation() const { + return _internal_has_orientation(); +} +inline void BodyPart::clear_orientation() { + orientation_ = 0; + _has_bits_[0] &= ~0x00000020u; +} +inline double BodyPart::_internal_orientation() const { + return orientation_; +} +inline double BodyPart::orientation() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyPart.orientation) + return _internal_orientation(); +} +inline void BodyPart::_internal_set_orientation(double value) { + _has_bits_[0] |= 0x00000020u; + orientation_ = value; +} +inline void BodyPart::set_orientation(double value) { + _internal_set_orientation(value); + // @@protoc_insertion_point(field_set:revolve.msgs.BodyPart.orientation) +} + +// repeated .revolve.msgs.BodyConnection child = 6; +inline int BodyPart::_internal_child_size() const { + return child_.size(); +} +inline int BodyPart::child_size() const { + return _internal_child_size(); +} +inline void BodyPart::clear_child() { + child_.Clear(); +} +inline ::revolve::msgs::BodyConnection* BodyPart::mutable_child(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.BodyPart.child) + return child_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::BodyConnection >* +BodyPart::mutable_child() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.BodyPart.child) + return &child_; +} +inline const ::revolve::msgs::BodyConnection& BodyPart::_internal_child(int index) const { + return child_.Get(index); +} +inline const ::revolve::msgs::BodyConnection& BodyPart::child(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyPart.child) + return _internal_child(index); +} +inline ::revolve::msgs::BodyConnection* BodyPart::_internal_add_child() { + return child_.Add(); +} +inline ::revolve::msgs::BodyConnection* BodyPart::add_child() { + // @@protoc_insertion_point(field_add:revolve.msgs.BodyPart.child) + return _internal_add_child(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::BodyConnection >& +BodyPart::child() const { + // @@protoc_insertion_point(field_list:revolve.msgs.BodyPart.child) + return child_; +} + +// repeated .revolve.msgs.Parameter param = 7; +inline int BodyPart::_internal_param_size() const { + return param_.size(); +} +inline int BodyPart::param_size() const { + return _internal_param_size(); +} +inline ::revolve::msgs::Parameter* BodyPart::mutable_param(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.BodyPart.param) + return param_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >* +BodyPart::mutable_param() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.BodyPart.param) + return ¶m_; +} +inline const ::revolve::msgs::Parameter& BodyPart::_internal_param(int index) const { + return param_.Get(index); +} +inline const ::revolve::msgs::Parameter& BodyPart::param(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyPart.param) + return _internal_param(index); +} +inline ::revolve::msgs::Parameter* BodyPart::_internal_add_param() { + return param_.Add(); +} +inline ::revolve::msgs::Parameter* BodyPart::add_param() { + // @@protoc_insertion_point(field_add:revolve.msgs.BodyPart.param) + return _internal_add_param(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >& +BodyPart::param() const { + // @@protoc_insertion_point(field_list:revolve.msgs.BodyPart.param) + return param_; +} + +// optional string label = 8; +inline bool BodyPart::_internal_has_label() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool BodyPart::has_label() const { + return _internal_has_label(); +} +inline void BodyPart::clear_label() { + label_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000004u; +} +inline const std::string& BodyPart::label() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyPart.label) + return _internal_label(); +} +inline void BodyPart::set_label(const std::string& value) { + _internal_set_label(value); + // @@protoc_insertion_point(field_set:revolve.msgs.BodyPart.label) +} +inline std::string* BodyPart::mutable_label() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.BodyPart.label) + return _internal_mutable_label(); +} +inline const std::string& BodyPart::_internal_label() const { + return label_.Get(); +} +inline void BodyPart::_internal_set_label(const std::string& value) { + _has_bits_[0] |= 0x00000004u; + label_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void BodyPart::set_label(std::string&& value) { + _has_bits_[0] |= 0x00000004u; + label_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.BodyPart.label) +} +inline void BodyPart::set_label(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000004u; + label_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.BodyPart.label) +} +inline void BodyPart::set_label(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000004u; + label_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.BodyPart.label) +} +inline std::string* BodyPart::_internal_mutable_label() { + _has_bits_[0] |= 0x00000004u; + return label_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* BodyPart::release_label() { + // @@protoc_insertion_point(field_release:revolve.msgs.BodyPart.label) + if (!_internal_has_label()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000004u; + return label_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void BodyPart::set_allocated_label(std::string* label) { + if (label != nullptr) { + _has_bits_[0] |= 0x00000004u; + } else { + _has_bits_[0] &= ~0x00000004u; + } + label_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), label, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.BodyPart.label) +} + +// ------------------------------------------------------------------- + +// BodyConnection + +// required int32 src_slot = 1; +inline bool BodyConnection::_internal_has_src_slot() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool BodyConnection::has_src_slot() const { + return _internal_has_src_slot(); +} +inline void BodyConnection::clear_src_slot() { + src_slot_ = 0; + _has_bits_[0] &= ~0x00000002u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BodyConnection::_internal_src_slot() const { + return src_slot_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BodyConnection::src_slot() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyConnection.src_slot) + return _internal_src_slot(); +} +inline void BodyConnection::_internal_set_src_slot(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000002u; + src_slot_ = value; +} +inline void BodyConnection::set_src_slot(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_src_slot(value); + // @@protoc_insertion_point(field_set:revolve.msgs.BodyConnection.src_slot) +} + +// required int32 dst_slot = 2; +inline bool BodyConnection::_internal_has_dst_slot() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool BodyConnection::has_dst_slot() const { + return _internal_has_dst_slot(); +} +inline void BodyConnection::clear_dst_slot() { + dst_slot_ = 0; + _has_bits_[0] &= ~0x00000004u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BodyConnection::_internal_dst_slot() const { + return dst_slot_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BodyConnection::dst_slot() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyConnection.dst_slot) + return _internal_dst_slot(); +} +inline void BodyConnection::_internal_set_dst_slot(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000004u; + dst_slot_ = value; +} +inline void BodyConnection::set_dst_slot(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_dst_slot(value); + // @@protoc_insertion_point(field_set:revolve.msgs.BodyConnection.dst_slot) +} + +// required .revolve.msgs.BodyPart part = 3; +inline bool BodyConnection::_internal_has_part() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || part_ != nullptr); + return value; +} +inline bool BodyConnection::has_part() const { + return _internal_has_part(); +} +inline void BodyConnection::clear_part() { + if (part_ != nullptr) part_->Clear(); + _has_bits_[0] &= ~0x00000001u; +} +inline const ::revolve::msgs::BodyPart& BodyConnection::_internal_part() const { + const ::revolve::msgs::BodyPart* p = part_; + return p != nullptr ? *p : *reinterpret_cast( + &::revolve::msgs::_BodyPart_default_instance_); +} +inline const ::revolve::msgs::BodyPart& BodyConnection::part() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyConnection.part) + return _internal_part(); +} +inline void BodyConnection::unsafe_arena_set_allocated_part( + ::revolve::msgs::BodyPart* part) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(part_); + } + part_ = part; + if (part) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:revolve.msgs.BodyConnection.part) +} +inline ::revolve::msgs::BodyPart* BodyConnection::release_part() { + _has_bits_[0] &= ~0x00000001u; + ::revolve::msgs::BodyPart* temp = part_; + part_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::revolve::msgs::BodyPart* BodyConnection::unsafe_arena_release_part() { + // @@protoc_insertion_point(field_release:revolve.msgs.BodyConnection.part) + _has_bits_[0] &= ~0x00000001u; + ::revolve::msgs::BodyPart* temp = part_; + part_ = nullptr; + return temp; +} +inline ::revolve::msgs::BodyPart* BodyConnection::_internal_mutable_part() { + _has_bits_[0] |= 0x00000001u; + if (part_ == nullptr) { + auto* p = CreateMaybeMessage<::revolve::msgs::BodyPart>(GetArena()); + part_ = p; + } + return part_; +} +inline ::revolve::msgs::BodyPart* BodyConnection::mutable_part() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.BodyConnection.part) + return _internal_mutable_part(); +} +inline void BodyConnection::set_allocated_part(::revolve::msgs::BodyPart* part) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete part_; + } + if (part) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(part); + if (message_arena != submessage_arena) { + part = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, part, submessage_arena); + } + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + part_ = part; + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.BodyConnection.part) +} + +// ------------------------------------------------------------------- + +// Body + +// required .revolve.msgs.BodyPart root = 1; +inline bool Body::_internal_has_root() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || root_ != nullptr); + return value; +} +inline bool Body::has_root() const { + return _internal_has_root(); +} +inline void Body::clear_root() { + if (root_ != nullptr) root_->Clear(); + _has_bits_[0] &= ~0x00000001u; +} +inline const ::revolve::msgs::BodyPart& Body::_internal_root() const { + const ::revolve::msgs::BodyPart* p = root_; + return p != nullptr ? *p : *reinterpret_cast( + &::revolve::msgs::_BodyPart_default_instance_); +} +inline const ::revolve::msgs::BodyPart& Body::root() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Body.root) + return _internal_root(); +} +inline void Body::unsafe_arena_set_allocated_root( + ::revolve::msgs::BodyPart* root) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(root_); + } + root_ = root; + if (root) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:revolve.msgs.Body.root) +} +inline ::revolve::msgs::BodyPart* Body::release_root() { + _has_bits_[0] &= ~0x00000001u; + ::revolve::msgs::BodyPart* temp = root_; + root_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::revolve::msgs::BodyPart* Body::unsafe_arena_release_root() { + // @@protoc_insertion_point(field_release:revolve.msgs.Body.root) + _has_bits_[0] &= ~0x00000001u; + ::revolve::msgs::BodyPart* temp = root_; + root_ = nullptr; + return temp; +} +inline ::revolve::msgs::BodyPart* Body::_internal_mutable_root() { + _has_bits_[0] |= 0x00000001u; + if (root_ == nullptr) { + auto* p = CreateMaybeMessage<::revolve::msgs::BodyPart>(GetArena()); + root_ = p; + } + return root_; +} +inline ::revolve::msgs::BodyPart* Body::mutable_root() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.Body.root) + return _internal_mutable_root(); +} +inline void Body::set_allocated_root(::revolve::msgs::BodyPart* root) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete root_; + } + if (root) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(root); + if (message_arena != submessage_arena) { + root = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, root, submessage_arena); + } + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + root_ = root; + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.Body.root) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace msgs +} // namespace revolve + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_body_2eproto diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/model_inserted.pb.cc b/cpprevolve/revolve/gazebo/revolve/msgs/model_inserted.pb.cc new file mode 100644 index 0000000000..7e03365606 --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/model_inserted.pb.cc @@ -0,0 +1,423 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: model_inserted.proto + +#include "model_inserted.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include +extern PROTOBUF_INTERNAL_EXPORT_model_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_Model_model_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_time_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Time_time_2eproto; +namespace revolve { +namespace msgs { +class ModelInsertedDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _ModelInserted_default_instance_; +} // namespace msgs +} // namespace revolve +static void InitDefaultsscc_info_ModelInserted_model_5finserted_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_ModelInserted_default_instance_; + new (ptr) ::revolve::msgs::ModelInserted(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::ModelInserted::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ModelInserted_model_5finserted_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_ModelInserted_model_5finserted_2eproto}, { + &scc_info_Time_time_2eproto.base, + &scc_info_Model_model_2eproto.base,}}; + +static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_model_5finserted_2eproto[1]; +static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_model_5finserted_2eproto = nullptr; +static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_model_5finserted_2eproto = nullptr; + +const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_model_5finserted_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModelInserted, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModelInserted, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModelInserted, time_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModelInserted, model_), + 0, + 1, +}; +static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 7, sizeof(::revolve::msgs::ModelInserted)}, +}; + +static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { + reinterpret_cast(&::revolve::msgs::_ModelInserted_default_instance_), +}; + +const char descriptor_table_protodef_model_5finserted_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\024model_inserted.proto\022\014revolve.msgs\032\013mo" + "del.proto\032\ntime.proto\"S\n\rModelInserted\022\037" + "\n\004time\030\001 \002(\0132\021.gazebo.msgs.Time\022!\n\005model" + "\030\002 \002(\0132\022.gazebo.msgs.Model" + ; +static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_model_5finserted_2eproto_deps[2] = { + &::descriptor_table_model_2eproto, + &::descriptor_table_time_2eproto, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_model_5finserted_2eproto_sccs[1] = { + &scc_info_ModelInserted_model_5finserted_2eproto.base, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_model_5finserted_2eproto_once; +const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_model_5finserted_2eproto = { + false, false, descriptor_table_protodef_model_5finserted_2eproto, "model_inserted.proto", 146, + &descriptor_table_model_5finserted_2eproto_once, descriptor_table_model_5finserted_2eproto_sccs, descriptor_table_model_5finserted_2eproto_deps, 1, 2, + schemas, file_default_instances, TableStruct_model_5finserted_2eproto::offsets, + file_level_metadata_model_5finserted_2eproto, 1, file_level_enum_descriptors_model_5finserted_2eproto, file_level_service_descriptors_model_5finserted_2eproto, +}; + +// Force running AddDescriptors() at dynamic initialization time. +static bool dynamic_init_dummy_model_5finserted_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_model_5finserted_2eproto)), true); +namespace revolve { +namespace msgs { + +// =================================================================== + +void ModelInserted::InitAsDefaultInstance() { + ::revolve::msgs::_ModelInserted_default_instance_._instance.get_mutable()->time_ = const_cast< ::gazebo::msgs::Time*>( + ::gazebo::msgs::Time::internal_default_instance()); + ::revolve::msgs::_ModelInserted_default_instance_._instance.get_mutable()->model_ = const_cast< ::gazebo::msgs::Model*>( + ::gazebo::msgs::Model::internal_default_instance()); +} +class ModelInserted::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static const ::gazebo::msgs::Time& time(const ModelInserted* msg); + static void set_has_time(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::gazebo::msgs::Model& model(const ModelInserted* msg); + static void set_has_model(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +const ::gazebo::msgs::Time& +ModelInserted::_Internal::time(const ModelInserted* msg) { + return *msg->time_; +} +const ::gazebo::msgs::Model& +ModelInserted::_Internal::model(const ModelInserted* msg) { + return *msg->model_; +} +void ModelInserted::clear_time() { + if (time_ != nullptr) time_->Clear(); + _has_bits_[0] &= ~0x00000001u; +} +void ModelInserted::clear_model() { + if (model_ != nullptr) model_->Clear(); + _has_bits_[0] &= ~0x00000002u; +} +ModelInserted::ModelInserted(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.ModelInserted) +} +ModelInserted::ModelInserted(const ModelInserted& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_time()) { + time_ = new ::gazebo::msgs::Time(*from.time_); + } else { + time_ = nullptr; + } + if (from._internal_has_model()) { + model_ = new ::gazebo::msgs::Model(*from.model_); + } else { + model_ = nullptr; + } + // @@protoc_insertion_point(copy_constructor:revolve.msgs.ModelInserted) +} + +void ModelInserted::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ModelInserted_model_5finserted_2eproto.base); + ::memset(&time_, 0, static_cast( + reinterpret_cast(&model_) - + reinterpret_cast(&time_)) + sizeof(model_)); +} + +ModelInserted::~ModelInserted() { + // @@protoc_insertion_point(destructor:revolve.msgs.ModelInserted) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void ModelInserted::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + if (this != internal_default_instance()) delete time_; + if (this != internal_default_instance()) delete model_; +} + +void ModelInserted::ArenaDtor(void* object) { + ModelInserted* _this = reinterpret_cast< ModelInserted* >(object); + (void)_this; +} +void ModelInserted::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void ModelInserted::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const ModelInserted& ModelInserted::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ModelInserted_model_5finserted_2eproto.base); + return *internal_default_instance(); +} + + +void ModelInserted::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.ModelInserted) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(time_ != nullptr); + time_->Clear(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(model_ != nullptr); + model_->Clear(); + } + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* ModelInserted::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required .gazebo.msgs.Time time = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_time(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // required .gazebo.msgs.Model model = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr = ctx->ParseMessage(_internal_mutable_model(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* ModelInserted::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.ModelInserted) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required .gazebo.msgs.Time time = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 1, _Internal::time(this), target, stream); + } + + // required .gazebo.msgs.Model model = 2; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 2, _Internal::model(this), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.ModelInserted) + return target; +} + +size_t ModelInserted::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:revolve.msgs.ModelInserted) + size_t total_size = 0; + + if (_internal_has_time()) { + // required .gazebo.msgs.Time time = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *time_); + } + + if (_internal_has_model()) { + // required .gazebo.msgs.Model model = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *model_); + } + + return total_size; +} +size_t ModelInserted::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.ModelInserted) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required .gazebo.msgs.Time time = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *time_); + + // required .gazebo.msgs.Model model = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *model_); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void ModelInserted::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.ModelInserted) + GOOGLE_DCHECK_NE(&from, this); + const ModelInserted* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.ModelInserted) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.ModelInserted) + MergeFrom(*source); + } +} + +void ModelInserted::MergeFrom(const ModelInserted& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.ModelInserted) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _internal_mutable_time()->::gazebo::msgs::Time::MergeFrom(from._internal_time()); + } + if (cached_has_bits & 0x00000002u) { + _internal_mutable_model()->::gazebo::msgs::Model::MergeFrom(from._internal_model()); + } + } +} + +void ModelInserted::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.ModelInserted) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ModelInserted::CopyFrom(const ModelInserted& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.ModelInserted) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ModelInserted::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_internal_has_time()) { + if (!time_->IsInitialized()) return false; + } + if (_internal_has_model()) { + if (!model_->IsInitialized()) return false; + } + return true; +} + +void ModelInserted::InternalSwap(ModelInserted* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(ModelInserted, model_) + + sizeof(ModelInserted::model_) + - PROTOBUF_FIELD_OFFSET(ModelInserted, time_)>( + reinterpret_cast(&time_), + reinterpret_cast(&other->time_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata ModelInserted::GetMetadata() const { + return GetMetadataStatic(); +} + + +// @@protoc_insertion_point(namespace_scope) +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::revolve::msgs::ModelInserted* Arena::CreateMaybeMessage< ::revolve::msgs::ModelInserted >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::ModelInserted >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/model_inserted.pb.h b/cpprevolve/revolve/gazebo/revolve/msgs/model_inserted.pb.h new file mode 100644 index 0000000000..5c8e31e35e --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/model_inserted.pb.h @@ -0,0 +1,430 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: model_inserted.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_model_5finserted_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_model_5finserted_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3013000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3013000 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include "model.pb.h" +#include "time.pb.h" +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_model_5finserted_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_model_5finserted_2eproto { + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; + static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; + static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_model_5finserted_2eproto; +namespace revolve { +namespace msgs { +class ModelInserted; +class ModelInsertedDefaultTypeInternal; +extern ModelInsertedDefaultTypeInternal _ModelInserted_default_instance_; +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> ::revolve::msgs::ModelInserted* Arena::CreateMaybeMessage<::revolve::msgs::ModelInserted>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace revolve { +namespace msgs { + +// =================================================================== + +class ModelInserted PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.ModelInserted) */ { + public: + inline ModelInserted() : ModelInserted(nullptr) {} + virtual ~ModelInserted(); + + ModelInserted(const ModelInserted& from); + ModelInserted(ModelInserted&& from) noexcept + : ModelInserted() { + *this = ::std::move(from); + } + + inline ModelInserted& operator=(const ModelInserted& from) { + CopyFrom(from); + return *this; + } + inline ModelInserted& operator=(ModelInserted&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const ModelInserted& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const ModelInserted* internal_default_instance() { + return reinterpret_cast( + &_ModelInserted_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(ModelInserted& a, ModelInserted& b) { + a.Swap(&b); + } + inline void Swap(ModelInserted* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ModelInserted* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline ModelInserted* New() const final { + return CreateMaybeMessage(nullptr); + } + + ModelInserted* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const ModelInserted& from); + void MergeFrom(const ModelInserted& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(ModelInserted* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.ModelInserted"; + } + protected: + explicit ModelInserted(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_model_5finserted_2eproto); + return ::descriptor_table_model_5finserted_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTimeFieldNumber = 1, + kModelFieldNumber = 2, + }; + // required .gazebo.msgs.Time time = 1; + bool has_time() const; + private: + bool _internal_has_time() const; + public: + void clear_time(); + const ::gazebo::msgs::Time& time() const; + ::gazebo::msgs::Time* release_time(); + ::gazebo::msgs::Time* mutable_time(); + void set_allocated_time(::gazebo::msgs::Time* time); + private: + const ::gazebo::msgs::Time& _internal_time() const; + ::gazebo::msgs::Time* _internal_mutable_time(); + public: + void unsafe_arena_set_allocated_time( + ::gazebo::msgs::Time* time); + ::gazebo::msgs::Time* unsafe_arena_release_time(); + + // required .gazebo.msgs.Model model = 2; + bool has_model() const; + private: + bool _internal_has_model() const; + public: + void clear_model(); + const ::gazebo::msgs::Model& model() const; + ::gazebo::msgs::Model* release_model(); + ::gazebo::msgs::Model* mutable_model(); + void set_allocated_model(::gazebo::msgs::Model* model); + private: + const ::gazebo::msgs::Model& _internal_model() const; + ::gazebo::msgs::Model* _internal_mutable_model(); + public: + void unsafe_arena_set_allocated_model( + ::gazebo::msgs::Model* model); + ::gazebo::msgs::Model* unsafe_arena_release_model(); + + // @@protoc_insertion_point(class_scope:revolve.msgs.ModelInserted) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::gazebo::msgs::Time* time_; + ::gazebo::msgs::Model* model_; + friend struct ::TableStruct_model_5finserted_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ModelInserted + +// required .gazebo.msgs.Time time = 1; +inline bool ModelInserted::_internal_has_time() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || time_ != nullptr); + return value; +} +inline bool ModelInserted::has_time() const { + return _internal_has_time(); +} +inline const ::gazebo::msgs::Time& ModelInserted::_internal_time() const { + const ::gazebo::msgs::Time* p = time_; + return p != nullptr ? *p : *reinterpret_cast( + &::gazebo::msgs::_Time_default_instance_); +} +inline const ::gazebo::msgs::Time& ModelInserted::time() const { + // @@protoc_insertion_point(field_get:revolve.msgs.ModelInserted.time) + return _internal_time(); +} +inline void ModelInserted::unsafe_arena_set_allocated_time( + ::gazebo::msgs::Time* time) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(time_); + } + time_ = time; + if (time) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:revolve.msgs.ModelInserted.time) +} +inline ::gazebo::msgs::Time* ModelInserted::release_time() { + _has_bits_[0] &= ~0x00000001u; + ::gazebo::msgs::Time* temp = time_; + time_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::gazebo::msgs::Time* ModelInserted::unsafe_arena_release_time() { + // @@protoc_insertion_point(field_release:revolve.msgs.ModelInserted.time) + _has_bits_[0] &= ~0x00000001u; + ::gazebo::msgs::Time* temp = time_; + time_ = nullptr; + return temp; +} +inline ::gazebo::msgs::Time* ModelInserted::_internal_mutable_time() { + _has_bits_[0] |= 0x00000001u; + if (time_ == nullptr) { + auto* p = CreateMaybeMessage<::gazebo::msgs::Time>(GetArena()); + time_ = p; + } + return time_; +} +inline ::gazebo::msgs::Time* ModelInserted::mutable_time() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.ModelInserted.time) + return _internal_mutable_time(); +} +inline void ModelInserted::set_allocated_time(::gazebo::msgs::Time* time) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(time_); + } + if (time) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(time)->GetArena(); + if (message_arena != submessage_arena) { + time = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, time, submessage_arena); + } + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + time_ = time; + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.ModelInserted.time) +} + +// required .gazebo.msgs.Model model = 2; +inline bool ModelInserted::_internal_has_model() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || model_ != nullptr); + return value; +} +inline bool ModelInserted::has_model() const { + return _internal_has_model(); +} +inline const ::gazebo::msgs::Model& ModelInserted::_internal_model() const { + const ::gazebo::msgs::Model* p = model_; + return p != nullptr ? *p : *reinterpret_cast( + &::gazebo::msgs::_Model_default_instance_); +} +inline const ::gazebo::msgs::Model& ModelInserted::model() const { + // @@protoc_insertion_point(field_get:revolve.msgs.ModelInserted.model) + return _internal_model(); +} +inline void ModelInserted::unsafe_arena_set_allocated_model( + ::gazebo::msgs::Model* model) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(model_); + } + model_ = model; + if (model) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:revolve.msgs.ModelInserted.model) +} +inline ::gazebo::msgs::Model* ModelInserted::release_model() { + _has_bits_[0] &= ~0x00000002u; + ::gazebo::msgs::Model* temp = model_; + model_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::gazebo::msgs::Model* ModelInserted::unsafe_arena_release_model() { + // @@protoc_insertion_point(field_release:revolve.msgs.ModelInserted.model) + _has_bits_[0] &= ~0x00000002u; + ::gazebo::msgs::Model* temp = model_; + model_ = nullptr; + return temp; +} +inline ::gazebo::msgs::Model* ModelInserted::_internal_mutable_model() { + _has_bits_[0] |= 0x00000002u; + if (model_ == nullptr) { + auto* p = CreateMaybeMessage<::gazebo::msgs::Model>(GetArena()); + model_ = p; + } + return model_; +} +inline ::gazebo::msgs::Model* ModelInserted::mutable_model() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.ModelInserted.model) + return _internal_mutable_model(); +} +inline void ModelInserted::set_allocated_model(::gazebo::msgs::Model* model) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(model_); + } + if (model) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(model)->GetArena(); + if (message_arena != submessage_arena) { + model = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, model, submessage_arena); + } + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + model_ = model; + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.ModelInserted.model) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + +} // namespace msgs +} // namespace revolve + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_model_5finserted_2eproto diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/neural_net.pb.cc b/cpprevolve/revolve/gazebo/revolve/msgs/neural_net.pb.cc new file mode 100644 index 0000000000..b0fb20d78f --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/neural_net.pb.cc @@ -0,0 +1,1526 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: neural_net.proto + +#include "neural_net.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include +extern PROTOBUF_INTERNAL_EXPORT_neural_5fnet_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_NeuralConnection_neural_5fnet_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_neural_5fnet_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Neuron_neural_5fnet_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_parameter_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Parameter_parameter_2eproto; +namespace revolve { +namespace msgs { +class NeuralConnectionDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _NeuralConnection_default_instance_; +class NeuronDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _Neuron_default_instance_; +class NeuralNetworkDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _NeuralNetwork_default_instance_; +class ModifyNeuralNetworkDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _ModifyNeuralNetwork_default_instance_; +} // namespace msgs +} // namespace revolve +static void InitDefaultsscc_info_ModifyNeuralNetwork_neural_5fnet_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_ModifyNeuralNetwork_default_instance_; + new (ptr) ::revolve::msgs::ModifyNeuralNetwork(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::ModifyNeuralNetwork::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ModifyNeuralNetwork_neural_5fnet_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_ModifyNeuralNetwork_neural_5fnet_2eproto}, { + &scc_info_Neuron_neural_5fnet_2eproto.base, + &scc_info_NeuralConnection_neural_5fnet_2eproto.base,}}; + +static void InitDefaultsscc_info_NeuralConnection_neural_5fnet_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_NeuralConnection_default_instance_; + new (ptr) ::revolve::msgs::NeuralConnection(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::NeuralConnection::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_NeuralConnection_neural_5fnet_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_NeuralConnection_neural_5fnet_2eproto}, {}}; + +static void InitDefaultsscc_info_NeuralNetwork_neural_5fnet_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_NeuralNetwork_default_instance_; + new (ptr) ::revolve::msgs::NeuralNetwork(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::NeuralNetwork::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_NeuralNetwork_neural_5fnet_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_NeuralNetwork_neural_5fnet_2eproto}, { + &scc_info_Neuron_neural_5fnet_2eproto.base, + &scc_info_NeuralConnection_neural_5fnet_2eproto.base,}}; + +static void InitDefaultsscc_info_Neuron_neural_5fnet_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_Neuron_default_instance_; + new (ptr) ::revolve::msgs::Neuron(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::Neuron::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Neuron_neural_5fnet_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_Neuron_neural_5fnet_2eproto}, { + &scc_info_Parameter_parameter_2eproto.base,}}; + +static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_neural_5fnet_2eproto[4]; +static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_neural_5fnet_2eproto = nullptr; +static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_neural_5fnet_2eproto = nullptr; + +const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_neural_5fnet_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::revolve::msgs::NeuralConnection, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::NeuralConnection, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::NeuralConnection, src_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::NeuralConnection, dst_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::NeuralConnection, weight_), + 0, + 1, + 2, + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Neuron, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Neuron, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Neuron, id_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Neuron, layer_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Neuron, type_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Neuron, partid_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Neuron, param_), + 0, + 1, + 2, + 3, + ~0u, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::NeuralNetwork, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::NeuralNetwork, neuron_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::NeuralNetwork, connection_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModifyNeuralNetwork, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModifyNeuralNetwork, remove_hidden_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModifyNeuralNetwork, add_hidden_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModifyNeuralNetwork, set_parameters_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModifyNeuralNetwork, set_weights_), +}; +static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 8, sizeof(::revolve::msgs::NeuralConnection)}, + { 11, 21, sizeof(::revolve::msgs::Neuron)}, + { 26, -1, sizeof(::revolve::msgs::NeuralNetwork)}, + { 33, -1, sizeof(::revolve::msgs::ModifyNeuralNetwork)}, +}; + +static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { + reinterpret_cast(&::revolve::msgs::_NeuralConnection_default_instance_), + reinterpret_cast(&::revolve::msgs::_Neuron_default_instance_), + reinterpret_cast(&::revolve::msgs::_NeuralNetwork_default_instance_), + reinterpret_cast(&::revolve::msgs::_ModifyNeuralNetwork_default_instance_), +}; + +const char descriptor_table_protodef_neural_5fnet_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\020neural_net.proto\022\014revolve.msgs\032\017parame" + "ter.proto\"<\n\020NeuralConnection\022\013\n\003src\030\001 \002" + "(\t\022\013\n\003dst\030\002 \002(\t\022\016\n\006weight\030\003 \002(\001\"i\n\006Neuro" + "n\022\n\n\002id\030\001 \002(\t\022\r\n\005layer\030\002 \002(\t\022\014\n\004type\030\003 \002" + "(\t\022\016\n\006partId\030\004 \001(\t\022&\n\005param\030\005 \003(\0132\027.revo" + "lve.msgs.Parameter\"i\n\rNeuralNetwork\022$\n\006n" + "euron\030\001 \003(\0132\024.revolve.msgs.Neuron\0222\n\ncon" + "nection\030\002 \003(\0132\036.revolve.msgs.NeuralConne" + "ction\"\271\001\n\023ModifyNeuralNetwork\022\025\n\rremove_" + "hidden\030\001 \003(\t\022(\n\nadd_hidden\030\002 \003(\0132\024.revol" + "ve.msgs.Neuron\022,\n\016set_parameters\030\004 \003(\0132\024" + ".revolve.msgs.Neuron\0223\n\013set_weights\030\003 \003(" + "\0132\036.revolve.msgs.NeuralConnection" + ; +static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_neural_5fnet_2eproto_deps[1] = { + &::descriptor_table_parameter_2eproto, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_neural_5fnet_2eproto_sccs[4] = { + &scc_info_ModifyNeuralNetwork_neural_5fnet_2eproto.base, + &scc_info_NeuralConnection_neural_5fnet_2eproto.base, + &scc_info_NeuralNetwork_neural_5fnet_2eproto.base, + &scc_info_Neuron_neural_5fnet_2eproto.base, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_neural_5fnet_2eproto_once; +const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_neural_5fnet_2eproto = { + false, false, descriptor_table_protodef_neural_5fnet_2eproto, "neural_net.proto", 513, + &descriptor_table_neural_5fnet_2eproto_once, descriptor_table_neural_5fnet_2eproto_sccs, descriptor_table_neural_5fnet_2eproto_deps, 4, 1, + schemas, file_default_instances, TableStruct_neural_5fnet_2eproto::offsets, + file_level_metadata_neural_5fnet_2eproto, 4, file_level_enum_descriptors_neural_5fnet_2eproto, file_level_service_descriptors_neural_5fnet_2eproto, +}; + +// Force running AddDescriptors() at dynamic initialization time. +static bool dynamic_init_dummy_neural_5fnet_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_neural_5fnet_2eproto)), true); +namespace revolve { +namespace msgs { + +// =================================================================== + +void NeuralConnection::InitAsDefaultInstance() { +} +class NeuralConnection::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_src(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_dst(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_weight(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000007) ^ 0x00000007) != 0; + } +}; + +NeuralConnection::NeuralConnection(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.NeuralConnection) +} +NeuralConnection::NeuralConnection(const NeuralConnection& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + src_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_src()) { + src_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_src(), + GetArena()); + } + dst_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_dst()) { + dst_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_dst(), + GetArena()); + } + weight_ = from.weight_; + // @@protoc_insertion_point(copy_constructor:revolve.msgs.NeuralConnection) +} + +void NeuralConnection::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_NeuralConnection_neural_5fnet_2eproto.base); + src_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + dst_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + weight_ = 0; +} + +NeuralConnection::~NeuralConnection() { + // @@protoc_insertion_point(destructor:revolve.msgs.NeuralConnection) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void NeuralConnection::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + src_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + dst_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void NeuralConnection::ArenaDtor(void* object) { + NeuralConnection* _this = reinterpret_cast< NeuralConnection* >(object); + (void)_this; +} +void NeuralConnection::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void NeuralConnection::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const NeuralConnection& NeuralConnection::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_NeuralConnection_neural_5fnet_2eproto.base); + return *internal_default_instance(); +} + + +void NeuralConnection::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.NeuralConnection) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + src_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + dst_.ClearNonDefaultToEmpty(); + } + } + weight_ = 0; + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* NeuralConnection::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required string src = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_src(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.NeuralConnection.src"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required string dst = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + auto str = _internal_mutable_dst(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.NeuralConnection.dst"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required double weight = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 25)) { + _Internal::set_has_weight(&has_bits); + weight_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); + ptr += sizeof(double); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* NeuralConnection::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.NeuralConnection) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required string src = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_src().data(), static_cast(this->_internal_src().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.NeuralConnection.src"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_src(), target); + } + + // required string dst = 2; + if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_dst().data(), static_cast(this->_internal_dst().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.NeuralConnection.dst"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_dst(), target); + } + + // required double weight = 3; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(3, this->_internal_weight(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.NeuralConnection) + return target; +} + +size_t NeuralConnection::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:revolve.msgs.NeuralConnection) + size_t total_size = 0; + + if (_internal_has_src()) { + // required string src = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_src()); + } + + if (_internal_has_dst()) { + // required string dst = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_dst()); + } + + if (_internal_has_weight()) { + // required double weight = 3; + total_size += 1 + 8; + } + + return total_size; +} +size_t NeuralConnection::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.NeuralConnection) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) { // All required fields are present. + // required string src = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_src()); + + // required string dst = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_dst()); + + // required double weight = 3; + total_size += 1 + 8; + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void NeuralConnection::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.NeuralConnection) + GOOGLE_DCHECK_NE(&from, this); + const NeuralConnection* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.NeuralConnection) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.NeuralConnection) + MergeFrom(*source); + } +} + +void NeuralConnection::MergeFrom(const NeuralConnection& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.NeuralConnection) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000001u) { + _internal_set_src(from._internal_src()); + } + if (cached_has_bits & 0x00000002u) { + _internal_set_dst(from._internal_dst()); + } + if (cached_has_bits & 0x00000004u) { + weight_ = from.weight_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void NeuralConnection::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.NeuralConnection) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void NeuralConnection::CopyFrom(const NeuralConnection& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.NeuralConnection) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool NeuralConnection::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + return true; +} + +void NeuralConnection::InternalSwap(NeuralConnection* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + src_.Swap(&other->src_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + dst_.Swap(&other->dst_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + swap(weight_, other->weight_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata NeuralConnection::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void Neuron::InitAsDefaultInstance() { +} +class Neuron::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_id(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_layer(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_partid(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000007) ^ 0x00000007) != 0; + } +}; + +void Neuron::clear_param() { + param_.Clear(); +} +Neuron::Neuron(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + param_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.Neuron) +} +Neuron::Neuron(const Neuron& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + param_(from.param_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_id()) { + id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_id(), + GetArena()); + } + layer_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_layer()) { + layer_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_layer(), + GetArena()); + } + type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_type()) { + type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_type(), + GetArena()); + } + partid_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_partid()) { + partid_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_partid(), + GetArena()); + } + // @@protoc_insertion_point(copy_constructor:revolve.msgs.Neuron) +} + +void Neuron::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Neuron_neural_5fnet_2eproto.base); + id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + layer_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + partid_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +Neuron::~Neuron() { + // @@protoc_insertion_point(destructor:revolve.msgs.Neuron) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void Neuron::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + id_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + layer_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + partid_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void Neuron::ArenaDtor(void* object) { + Neuron* _this = reinterpret_cast< Neuron* >(object); + (void)_this; +} +void Neuron::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void Neuron::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const Neuron& Neuron::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Neuron_neural_5fnet_2eproto.base); + return *internal_default_instance(); +} + + +void Neuron::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.Neuron) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + param_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000001u) { + id_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + layer_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000004u) { + type_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000008u) { + partid_.ClearNonDefaultToEmpty(); + } + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Neuron::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required string id = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_id(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.Neuron.id"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required string layer = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + auto str = _internal_mutable_layer(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.Neuron.layer"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required string type = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { + auto str = _internal_mutable_type(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.Neuron.type"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional string partId = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { + auto str = _internal_mutable_partid(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.Neuron.partId"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated .revolve.msgs.Parameter param = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_param(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* Neuron::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.Neuron) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required string id = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_id().data(), static_cast(this->_internal_id().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.Neuron.id"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_id(), target); + } + + // required string layer = 2; + if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_layer().data(), static_cast(this->_internal_layer().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.Neuron.layer"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_layer(), target); + } + + // required string type = 3; + if (cached_has_bits & 0x00000004u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_type().data(), static_cast(this->_internal_type().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.Neuron.type"); + target = stream->WriteStringMaybeAliased( + 3, this->_internal_type(), target); + } + + // optional string partId = 4; + if (cached_has_bits & 0x00000008u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_partid().data(), static_cast(this->_internal_partid().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.Neuron.partId"); + target = stream->WriteStringMaybeAliased( + 4, this->_internal_partid(), target); + } + + // repeated .revolve.msgs.Parameter param = 5; + for (unsigned int i = 0, + n = static_cast(this->_internal_param_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(5, this->_internal_param(i), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.Neuron) + return target; +} + +size_t Neuron::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:revolve.msgs.Neuron) + size_t total_size = 0; + + if (_internal_has_id()) { + // required string id = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_id()); + } + + if (_internal_has_layer()) { + // required string layer = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_layer()); + } + + if (_internal_has_type()) { + // required string type = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_type()); + } + + return total_size; +} +size_t Neuron::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.Neuron) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) { // All required fields are present. + // required string id = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_id()); + + // required string layer = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_layer()); + + // required string type = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_type()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .revolve.msgs.Parameter param = 5; + total_size += 1UL * this->_internal_param_size(); + for (const auto& msg : this->param_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // optional string partId = 4; + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_partid()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void Neuron::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.Neuron) + GOOGLE_DCHECK_NE(&from, this); + const Neuron* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.Neuron) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.Neuron) + MergeFrom(*source); + } +} + +void Neuron::MergeFrom(const Neuron& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.Neuron) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + param_.MergeFrom(from.param_); + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000001u) { + _internal_set_id(from._internal_id()); + } + if (cached_has_bits & 0x00000002u) { + _internal_set_layer(from._internal_layer()); + } + if (cached_has_bits & 0x00000004u) { + _internal_set_type(from._internal_type()); + } + if (cached_has_bits & 0x00000008u) { + _internal_set_partid(from._internal_partid()); + } + } +} + +void Neuron::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.Neuron) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Neuron::CopyFrom(const Neuron& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.Neuron) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Neuron::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(param_)) return false; + return true; +} + +void Neuron::InternalSwap(Neuron* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + param_.InternalSwap(&other->param_); + id_.Swap(&other->id_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + layer_.Swap(&other->layer_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + type_.Swap(&other->type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + partid_.Swap(&other->partid_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Neuron::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void NeuralNetwork::InitAsDefaultInstance() { +} +class NeuralNetwork::_Internal { + public: +}; + +NeuralNetwork::NeuralNetwork(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + neuron_(arena), + connection_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.NeuralNetwork) +} +NeuralNetwork::NeuralNetwork(const NeuralNetwork& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + neuron_(from.neuron_), + connection_(from.connection_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:revolve.msgs.NeuralNetwork) +} + +void NeuralNetwork::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_NeuralNetwork_neural_5fnet_2eproto.base); +} + +NeuralNetwork::~NeuralNetwork() { + // @@protoc_insertion_point(destructor:revolve.msgs.NeuralNetwork) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void NeuralNetwork::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void NeuralNetwork::ArenaDtor(void* object) { + NeuralNetwork* _this = reinterpret_cast< NeuralNetwork* >(object); + (void)_this; +} +void NeuralNetwork::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void NeuralNetwork::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const NeuralNetwork& NeuralNetwork::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_NeuralNetwork_neural_5fnet_2eproto.base); + return *internal_default_instance(); +} + + +void NeuralNetwork::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.NeuralNetwork) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + neuron_.Clear(); + connection_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* NeuralNetwork::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // repeated .revolve.msgs.Neuron neuron = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_neuron(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + } else goto handle_unusual; + continue; + // repeated .revolve.msgs.NeuralConnection connection = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_connection(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* NeuralNetwork::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.NeuralNetwork) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // repeated .revolve.msgs.Neuron neuron = 1; + for (unsigned int i = 0, + n = static_cast(this->_internal_neuron_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, this->_internal_neuron(i), target, stream); + } + + // repeated .revolve.msgs.NeuralConnection connection = 2; + for (unsigned int i = 0, + n = static_cast(this->_internal_connection_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, this->_internal_connection(i), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.NeuralNetwork) + return target; +} + +size_t NeuralNetwork::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.NeuralNetwork) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .revolve.msgs.Neuron neuron = 1; + total_size += 1UL * this->_internal_neuron_size(); + for (const auto& msg : this->neuron_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // repeated .revolve.msgs.NeuralConnection connection = 2; + total_size += 1UL * this->_internal_connection_size(); + for (const auto& msg : this->connection_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void NeuralNetwork::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.NeuralNetwork) + GOOGLE_DCHECK_NE(&from, this); + const NeuralNetwork* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.NeuralNetwork) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.NeuralNetwork) + MergeFrom(*source); + } +} + +void NeuralNetwork::MergeFrom(const NeuralNetwork& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.NeuralNetwork) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + neuron_.MergeFrom(from.neuron_); + connection_.MergeFrom(from.connection_); +} + +void NeuralNetwork::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.NeuralNetwork) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void NeuralNetwork::CopyFrom(const NeuralNetwork& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.NeuralNetwork) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool NeuralNetwork::IsInitialized() const { + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(neuron_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(connection_)) return false; + return true; +} + +void NeuralNetwork::InternalSwap(NeuralNetwork* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + neuron_.InternalSwap(&other->neuron_); + connection_.InternalSwap(&other->connection_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata NeuralNetwork::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void ModifyNeuralNetwork::InitAsDefaultInstance() { +} +class ModifyNeuralNetwork::_Internal { + public: +}; + +ModifyNeuralNetwork::ModifyNeuralNetwork(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + remove_hidden_(arena), + add_hidden_(arena), + set_weights_(arena), + set_parameters_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.ModifyNeuralNetwork) +} +ModifyNeuralNetwork::ModifyNeuralNetwork(const ModifyNeuralNetwork& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + remove_hidden_(from.remove_hidden_), + add_hidden_(from.add_hidden_), + set_weights_(from.set_weights_), + set_parameters_(from.set_parameters_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:revolve.msgs.ModifyNeuralNetwork) +} + +void ModifyNeuralNetwork::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ModifyNeuralNetwork_neural_5fnet_2eproto.base); +} + +ModifyNeuralNetwork::~ModifyNeuralNetwork() { + // @@protoc_insertion_point(destructor:revolve.msgs.ModifyNeuralNetwork) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void ModifyNeuralNetwork::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void ModifyNeuralNetwork::ArenaDtor(void* object) { + ModifyNeuralNetwork* _this = reinterpret_cast< ModifyNeuralNetwork* >(object); + (void)_this; +} +void ModifyNeuralNetwork::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void ModifyNeuralNetwork::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const ModifyNeuralNetwork& ModifyNeuralNetwork::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ModifyNeuralNetwork_neural_5fnet_2eproto.base); + return *internal_default_instance(); +} + + +void ModifyNeuralNetwork::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.ModifyNeuralNetwork) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + remove_hidden_.Clear(); + add_hidden_.Clear(); + set_weights_.Clear(); + set_parameters_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* ModifyNeuralNetwork::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // repeated string remove_hidden = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_remove_hidden(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.ModifyNeuralNetwork.remove_hidden"); + #endif // !NDEBUG + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + } else goto handle_unusual; + continue; + // repeated .revolve.msgs.Neuron add_hidden = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_add_hidden(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else goto handle_unusual; + continue; + // repeated .revolve.msgs.NeuralConnection set_weights = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_set_weights(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); + } else goto handle_unusual; + continue; + // repeated .revolve.msgs.Neuron set_parameters = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_set_parameters(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* ModifyNeuralNetwork::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.ModifyNeuralNetwork) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // repeated string remove_hidden = 1; + for (int i = 0, n = this->_internal_remove_hidden_size(); i < n; i++) { + const auto& s = this->_internal_remove_hidden(i); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + s.data(), static_cast(s.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.ModifyNeuralNetwork.remove_hidden"); + target = stream->WriteString(1, s, target); + } + + // repeated .revolve.msgs.Neuron add_hidden = 2; + for (unsigned int i = 0, + n = static_cast(this->_internal_add_hidden_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, this->_internal_add_hidden(i), target, stream); + } + + // repeated .revolve.msgs.NeuralConnection set_weights = 3; + for (unsigned int i = 0, + n = static_cast(this->_internal_set_weights_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, this->_internal_set_weights(i), target, stream); + } + + // repeated .revolve.msgs.Neuron set_parameters = 4; + for (unsigned int i = 0, + n = static_cast(this->_internal_set_parameters_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(4, this->_internal_set_parameters(i), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.ModifyNeuralNetwork) + return target; +} + +size_t ModifyNeuralNetwork::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.ModifyNeuralNetwork) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated string remove_hidden = 1; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(remove_hidden_.size()); + for (int i = 0, n = remove_hidden_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + remove_hidden_.Get(i)); + } + + // repeated .revolve.msgs.Neuron add_hidden = 2; + total_size += 1UL * this->_internal_add_hidden_size(); + for (const auto& msg : this->add_hidden_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // repeated .revolve.msgs.NeuralConnection set_weights = 3; + total_size += 1UL * this->_internal_set_weights_size(); + for (const auto& msg : this->set_weights_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // repeated .revolve.msgs.Neuron set_parameters = 4; + total_size += 1UL * this->_internal_set_parameters_size(); + for (const auto& msg : this->set_parameters_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void ModifyNeuralNetwork::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.ModifyNeuralNetwork) + GOOGLE_DCHECK_NE(&from, this); + const ModifyNeuralNetwork* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.ModifyNeuralNetwork) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.ModifyNeuralNetwork) + MergeFrom(*source); + } +} + +void ModifyNeuralNetwork::MergeFrom(const ModifyNeuralNetwork& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.ModifyNeuralNetwork) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + remove_hidden_.MergeFrom(from.remove_hidden_); + add_hidden_.MergeFrom(from.add_hidden_); + set_weights_.MergeFrom(from.set_weights_); + set_parameters_.MergeFrom(from.set_parameters_); +} + +void ModifyNeuralNetwork::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.ModifyNeuralNetwork) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ModifyNeuralNetwork::CopyFrom(const ModifyNeuralNetwork& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.ModifyNeuralNetwork) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ModifyNeuralNetwork::IsInitialized() const { + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(add_hidden_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(set_weights_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(set_parameters_)) return false; + return true; +} + +void ModifyNeuralNetwork::InternalSwap(ModifyNeuralNetwork* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + remove_hidden_.InternalSwap(&other->remove_hidden_); + add_hidden_.InternalSwap(&other->add_hidden_); + set_weights_.InternalSwap(&other->set_weights_); + set_parameters_.InternalSwap(&other->set_parameters_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata ModifyNeuralNetwork::GetMetadata() const { + return GetMetadataStatic(); +} + + +// @@protoc_insertion_point(namespace_scope) +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::revolve::msgs::NeuralConnection* Arena::CreateMaybeMessage< ::revolve::msgs::NeuralConnection >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::NeuralConnection >(arena); +} +template<> PROTOBUF_NOINLINE ::revolve::msgs::Neuron* Arena::CreateMaybeMessage< ::revolve::msgs::Neuron >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::Neuron >(arena); +} +template<> PROTOBUF_NOINLINE ::revolve::msgs::NeuralNetwork* Arena::CreateMaybeMessage< ::revolve::msgs::NeuralNetwork >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::NeuralNetwork >(arena); +} +template<> PROTOBUF_NOINLINE ::revolve::msgs::ModifyNeuralNetwork* Arena::CreateMaybeMessage< ::revolve::msgs::ModifyNeuralNetwork >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::ModifyNeuralNetwork >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/neural_net.pb.h b/cpprevolve/revolve/gazebo/revolve/msgs/neural_net.pb.h new file mode 100644 index 0000000000..d6f1d328be --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/neural_net.pb.h @@ -0,0 +1,1734 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: neural_net.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_neural_5fnet_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_neural_5fnet_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3013000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3013000 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include "parameter.pb.h" +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_neural_5fnet_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_neural_5fnet_2eproto { + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[4] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; + static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; + static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_neural_5fnet_2eproto; +namespace revolve { +namespace msgs { +class ModifyNeuralNetwork; +class ModifyNeuralNetworkDefaultTypeInternal; +extern ModifyNeuralNetworkDefaultTypeInternal _ModifyNeuralNetwork_default_instance_; +class NeuralConnection; +class NeuralConnectionDefaultTypeInternal; +extern NeuralConnectionDefaultTypeInternal _NeuralConnection_default_instance_; +class NeuralNetwork; +class NeuralNetworkDefaultTypeInternal; +extern NeuralNetworkDefaultTypeInternal _NeuralNetwork_default_instance_; +class Neuron; +class NeuronDefaultTypeInternal; +extern NeuronDefaultTypeInternal _Neuron_default_instance_; +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> ::revolve::msgs::ModifyNeuralNetwork* Arena::CreateMaybeMessage<::revolve::msgs::ModifyNeuralNetwork>(Arena*); +template<> ::revolve::msgs::NeuralConnection* Arena::CreateMaybeMessage<::revolve::msgs::NeuralConnection>(Arena*); +template<> ::revolve::msgs::NeuralNetwork* Arena::CreateMaybeMessage<::revolve::msgs::NeuralNetwork>(Arena*); +template<> ::revolve::msgs::Neuron* Arena::CreateMaybeMessage<::revolve::msgs::Neuron>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace revolve { +namespace msgs { + +// =================================================================== + +class NeuralConnection PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.NeuralConnection) */ { + public: + inline NeuralConnection() : NeuralConnection(nullptr) {} + virtual ~NeuralConnection(); + + NeuralConnection(const NeuralConnection& from); + NeuralConnection(NeuralConnection&& from) noexcept + : NeuralConnection() { + *this = ::std::move(from); + } + + inline NeuralConnection& operator=(const NeuralConnection& from) { + CopyFrom(from); + return *this; + } + inline NeuralConnection& operator=(NeuralConnection&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const NeuralConnection& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const NeuralConnection* internal_default_instance() { + return reinterpret_cast( + &_NeuralConnection_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(NeuralConnection& a, NeuralConnection& b) { + a.Swap(&b); + } + inline void Swap(NeuralConnection* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(NeuralConnection* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline NeuralConnection* New() const final { + return CreateMaybeMessage(nullptr); + } + + NeuralConnection* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const NeuralConnection& from); + void MergeFrom(const NeuralConnection& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(NeuralConnection* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.NeuralConnection"; + } + protected: + explicit NeuralConnection(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_neural_5fnet_2eproto); + return ::descriptor_table_neural_5fnet_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kSrcFieldNumber = 1, + kDstFieldNumber = 2, + kWeightFieldNumber = 3, + }; + // required string src = 1; + bool has_src() const; + private: + bool _internal_has_src() const; + public: + void clear_src(); + const std::string& src() const; + void set_src(const std::string& value); + void set_src(std::string&& value); + void set_src(const char* value); + void set_src(const char* value, size_t size); + std::string* mutable_src(); + std::string* release_src(); + void set_allocated_src(std::string* src); + private: + const std::string& _internal_src() const; + void _internal_set_src(const std::string& value); + std::string* _internal_mutable_src(); + public: + + // required string dst = 2; + bool has_dst() const; + private: + bool _internal_has_dst() const; + public: + void clear_dst(); + const std::string& dst() const; + void set_dst(const std::string& value); + void set_dst(std::string&& value); + void set_dst(const char* value); + void set_dst(const char* value, size_t size); + std::string* mutable_dst(); + std::string* release_dst(); + void set_allocated_dst(std::string* dst); + private: + const std::string& _internal_dst() const; + void _internal_set_dst(const std::string& value); + std::string* _internal_mutable_dst(); + public: + + // required double weight = 3; + bool has_weight() const; + private: + bool _internal_has_weight() const; + public: + void clear_weight(); + double weight() const; + void set_weight(double value); + private: + double _internal_weight() const; + void _internal_set_weight(double value); + public: + + // @@protoc_insertion_point(class_scope:revolve.msgs.NeuralConnection) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr src_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr dst_; + double weight_; + friend struct ::TableStruct_neural_5fnet_2eproto; +}; +// ------------------------------------------------------------------- + +class Neuron PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.Neuron) */ { + public: + inline Neuron() : Neuron(nullptr) {} + virtual ~Neuron(); + + Neuron(const Neuron& from); + Neuron(Neuron&& from) noexcept + : Neuron() { + *this = ::std::move(from); + } + + inline Neuron& operator=(const Neuron& from) { + CopyFrom(from); + return *this; + } + inline Neuron& operator=(Neuron&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const Neuron& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const Neuron* internal_default_instance() { + return reinterpret_cast( + &_Neuron_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(Neuron& a, Neuron& b) { + a.Swap(&b); + } + inline void Swap(Neuron* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Neuron* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline Neuron* New() const final { + return CreateMaybeMessage(nullptr); + } + + Neuron* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const Neuron& from); + void MergeFrom(const Neuron& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Neuron* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.Neuron"; + } + protected: + explicit Neuron(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_neural_5fnet_2eproto); + return ::descriptor_table_neural_5fnet_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kParamFieldNumber = 5, + kIdFieldNumber = 1, + kLayerFieldNumber = 2, + kTypeFieldNumber = 3, + kPartIdFieldNumber = 4, + }; + // repeated .revolve.msgs.Parameter param = 5; + int param_size() const; + private: + int _internal_param_size() const; + public: + void clear_param(); + ::revolve::msgs::Parameter* mutable_param(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >* + mutable_param(); + private: + const ::revolve::msgs::Parameter& _internal_param(int index) const; + ::revolve::msgs::Parameter* _internal_add_param(); + public: + const ::revolve::msgs::Parameter& param(int index) const; + ::revolve::msgs::Parameter* add_param(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >& + param() const; + + // required string id = 1; + bool has_id() const; + private: + bool _internal_has_id() const; + public: + void clear_id(); + const std::string& id() const; + void set_id(const std::string& value); + void set_id(std::string&& value); + void set_id(const char* value); + void set_id(const char* value, size_t size); + std::string* mutable_id(); + std::string* release_id(); + void set_allocated_id(std::string* id); + private: + const std::string& _internal_id() const; + void _internal_set_id(const std::string& value); + std::string* _internal_mutable_id(); + public: + + // required string layer = 2; + bool has_layer() const; + private: + bool _internal_has_layer() const; + public: + void clear_layer(); + const std::string& layer() const; + void set_layer(const std::string& value); + void set_layer(std::string&& value); + void set_layer(const char* value); + void set_layer(const char* value, size_t size); + std::string* mutable_layer(); + std::string* release_layer(); + void set_allocated_layer(std::string* layer); + private: + const std::string& _internal_layer() const; + void _internal_set_layer(const std::string& value); + std::string* _internal_mutable_layer(); + public: + + // required string type = 3; + bool has_type() const; + private: + bool _internal_has_type() const; + public: + void clear_type(); + const std::string& type() const; + void set_type(const std::string& value); + void set_type(std::string&& value); + void set_type(const char* value); + void set_type(const char* value, size_t size); + std::string* mutable_type(); + std::string* release_type(); + void set_allocated_type(std::string* type); + private: + const std::string& _internal_type() const; + void _internal_set_type(const std::string& value); + std::string* _internal_mutable_type(); + public: + + // optional string partId = 4; + bool has_partid() const; + private: + bool _internal_has_partid() const; + public: + void clear_partid(); + const std::string& partid() const; + void set_partid(const std::string& value); + void set_partid(std::string&& value); + void set_partid(const char* value); + void set_partid(const char* value, size_t size); + std::string* mutable_partid(); + std::string* release_partid(); + void set_allocated_partid(std::string* partid); + private: + const std::string& _internal_partid() const; + void _internal_set_partid(const std::string& value); + std::string* _internal_mutable_partid(); + public: + + // @@protoc_insertion_point(class_scope:revolve.msgs.Neuron) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter > param_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr id_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr layer_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr partid_; + friend struct ::TableStruct_neural_5fnet_2eproto; +}; +// ------------------------------------------------------------------- + +class NeuralNetwork PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.NeuralNetwork) */ { + public: + inline NeuralNetwork() : NeuralNetwork(nullptr) {} + virtual ~NeuralNetwork(); + + NeuralNetwork(const NeuralNetwork& from); + NeuralNetwork(NeuralNetwork&& from) noexcept + : NeuralNetwork() { + *this = ::std::move(from); + } + + inline NeuralNetwork& operator=(const NeuralNetwork& from) { + CopyFrom(from); + return *this; + } + inline NeuralNetwork& operator=(NeuralNetwork&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const NeuralNetwork& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const NeuralNetwork* internal_default_instance() { + return reinterpret_cast( + &_NeuralNetwork_default_instance_); + } + static constexpr int kIndexInFileMessages = + 2; + + friend void swap(NeuralNetwork& a, NeuralNetwork& b) { + a.Swap(&b); + } + inline void Swap(NeuralNetwork* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(NeuralNetwork* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline NeuralNetwork* New() const final { + return CreateMaybeMessage(nullptr); + } + + NeuralNetwork* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const NeuralNetwork& from); + void MergeFrom(const NeuralNetwork& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(NeuralNetwork* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.NeuralNetwork"; + } + protected: + explicit NeuralNetwork(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_neural_5fnet_2eproto); + return ::descriptor_table_neural_5fnet_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kNeuronFieldNumber = 1, + kConnectionFieldNumber = 2, + }; + // repeated .revolve.msgs.Neuron neuron = 1; + int neuron_size() const; + private: + int _internal_neuron_size() const; + public: + void clear_neuron(); + ::revolve::msgs::Neuron* mutable_neuron(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >* + mutable_neuron(); + private: + const ::revolve::msgs::Neuron& _internal_neuron(int index) const; + ::revolve::msgs::Neuron* _internal_add_neuron(); + public: + const ::revolve::msgs::Neuron& neuron(int index) const; + ::revolve::msgs::Neuron* add_neuron(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >& + neuron() const; + + // repeated .revolve.msgs.NeuralConnection connection = 2; + int connection_size() const; + private: + int _internal_connection_size() const; + public: + void clear_connection(); + ::revolve::msgs::NeuralConnection* mutable_connection(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::NeuralConnection >* + mutable_connection(); + private: + const ::revolve::msgs::NeuralConnection& _internal_connection(int index) const; + ::revolve::msgs::NeuralConnection* _internal_add_connection(); + public: + const ::revolve::msgs::NeuralConnection& connection(int index) const; + ::revolve::msgs::NeuralConnection* add_connection(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::NeuralConnection >& + connection() const; + + // @@protoc_insertion_point(class_scope:revolve.msgs.NeuralNetwork) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron > neuron_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::NeuralConnection > connection_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_neural_5fnet_2eproto; +}; +// ------------------------------------------------------------------- + +class ModifyNeuralNetwork PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.ModifyNeuralNetwork) */ { + public: + inline ModifyNeuralNetwork() : ModifyNeuralNetwork(nullptr) {} + virtual ~ModifyNeuralNetwork(); + + ModifyNeuralNetwork(const ModifyNeuralNetwork& from); + ModifyNeuralNetwork(ModifyNeuralNetwork&& from) noexcept + : ModifyNeuralNetwork() { + *this = ::std::move(from); + } + + inline ModifyNeuralNetwork& operator=(const ModifyNeuralNetwork& from) { + CopyFrom(from); + return *this; + } + inline ModifyNeuralNetwork& operator=(ModifyNeuralNetwork&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const ModifyNeuralNetwork& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const ModifyNeuralNetwork* internal_default_instance() { + return reinterpret_cast( + &_ModifyNeuralNetwork_default_instance_); + } + static constexpr int kIndexInFileMessages = + 3; + + friend void swap(ModifyNeuralNetwork& a, ModifyNeuralNetwork& b) { + a.Swap(&b); + } + inline void Swap(ModifyNeuralNetwork* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ModifyNeuralNetwork* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline ModifyNeuralNetwork* New() const final { + return CreateMaybeMessage(nullptr); + } + + ModifyNeuralNetwork* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const ModifyNeuralNetwork& from); + void MergeFrom(const ModifyNeuralNetwork& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(ModifyNeuralNetwork* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.ModifyNeuralNetwork"; + } + protected: + explicit ModifyNeuralNetwork(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_neural_5fnet_2eproto); + return ::descriptor_table_neural_5fnet_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kRemoveHiddenFieldNumber = 1, + kAddHiddenFieldNumber = 2, + kSetWeightsFieldNumber = 3, + kSetParametersFieldNumber = 4, + }; + // repeated string remove_hidden = 1; + int remove_hidden_size() const; + private: + int _internal_remove_hidden_size() const; + public: + void clear_remove_hidden(); + const std::string& remove_hidden(int index) const; + std::string* mutable_remove_hidden(int index); + void set_remove_hidden(int index, const std::string& value); + void set_remove_hidden(int index, std::string&& value); + void set_remove_hidden(int index, const char* value); + void set_remove_hidden(int index, const char* value, size_t size); + std::string* add_remove_hidden(); + void add_remove_hidden(const std::string& value); + void add_remove_hidden(std::string&& value); + void add_remove_hidden(const char* value); + void add_remove_hidden(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& remove_hidden() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_remove_hidden(); + private: + const std::string& _internal_remove_hidden(int index) const; + std::string* _internal_add_remove_hidden(); + public: + + // repeated .revolve.msgs.Neuron add_hidden = 2; + int add_hidden_size() const; + private: + int _internal_add_hidden_size() const; + public: + void clear_add_hidden(); + ::revolve::msgs::Neuron* mutable_add_hidden(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >* + mutable_add_hidden(); + private: + const ::revolve::msgs::Neuron& _internal_add_hidden(int index) const; + ::revolve::msgs::Neuron* _internal_add_add_hidden(); + public: + const ::revolve::msgs::Neuron& add_hidden(int index) const; + ::revolve::msgs::Neuron* add_add_hidden(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >& + add_hidden() const; + + // repeated .revolve.msgs.NeuralConnection set_weights = 3; + int set_weights_size() const; + private: + int _internal_set_weights_size() const; + public: + void clear_set_weights(); + ::revolve::msgs::NeuralConnection* mutable_set_weights(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::NeuralConnection >* + mutable_set_weights(); + private: + const ::revolve::msgs::NeuralConnection& _internal_set_weights(int index) const; + ::revolve::msgs::NeuralConnection* _internal_add_set_weights(); + public: + const ::revolve::msgs::NeuralConnection& set_weights(int index) const; + ::revolve::msgs::NeuralConnection* add_set_weights(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::NeuralConnection >& + set_weights() const; + + // repeated .revolve.msgs.Neuron set_parameters = 4; + int set_parameters_size() const; + private: + int _internal_set_parameters_size() const; + public: + void clear_set_parameters(); + ::revolve::msgs::Neuron* mutable_set_parameters(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >* + mutable_set_parameters(); + private: + const ::revolve::msgs::Neuron& _internal_set_parameters(int index) const; + ::revolve::msgs::Neuron* _internal_add_set_parameters(); + public: + const ::revolve::msgs::Neuron& set_parameters(int index) const; + ::revolve::msgs::Neuron* add_set_parameters(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >& + set_parameters() const; + + // @@protoc_insertion_point(class_scope:revolve.msgs.ModifyNeuralNetwork) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField remove_hidden_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron > add_hidden_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::NeuralConnection > set_weights_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron > set_parameters_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_neural_5fnet_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// NeuralConnection + +// required string src = 1; +inline bool NeuralConnection::_internal_has_src() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool NeuralConnection::has_src() const { + return _internal_has_src(); +} +inline void NeuralConnection::clear_src() { + src_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& NeuralConnection::src() const { + // @@protoc_insertion_point(field_get:revolve.msgs.NeuralConnection.src) + return _internal_src(); +} +inline void NeuralConnection::set_src(const std::string& value) { + _internal_set_src(value); + // @@protoc_insertion_point(field_set:revolve.msgs.NeuralConnection.src) +} +inline std::string* NeuralConnection::mutable_src() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.NeuralConnection.src) + return _internal_mutable_src(); +} +inline const std::string& NeuralConnection::_internal_src() const { + return src_.Get(); +} +inline void NeuralConnection::_internal_set_src(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + src_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void NeuralConnection::set_src(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + src_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.NeuralConnection.src) +} +inline void NeuralConnection::set_src(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + src_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.NeuralConnection.src) +} +inline void NeuralConnection::set_src(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + src_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.NeuralConnection.src) +} +inline std::string* NeuralConnection::_internal_mutable_src() { + _has_bits_[0] |= 0x00000001u; + return src_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* NeuralConnection::release_src() { + // @@protoc_insertion_point(field_release:revolve.msgs.NeuralConnection.src) + if (!_internal_has_src()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return src_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void NeuralConnection::set_allocated_src(std::string* src) { + if (src != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + src_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), src, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.NeuralConnection.src) +} + +// required string dst = 2; +inline bool NeuralConnection::_internal_has_dst() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool NeuralConnection::has_dst() const { + return _internal_has_dst(); +} +inline void NeuralConnection::clear_dst() { + dst_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000002u; +} +inline const std::string& NeuralConnection::dst() const { + // @@protoc_insertion_point(field_get:revolve.msgs.NeuralConnection.dst) + return _internal_dst(); +} +inline void NeuralConnection::set_dst(const std::string& value) { + _internal_set_dst(value); + // @@protoc_insertion_point(field_set:revolve.msgs.NeuralConnection.dst) +} +inline std::string* NeuralConnection::mutable_dst() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.NeuralConnection.dst) + return _internal_mutable_dst(); +} +inline const std::string& NeuralConnection::_internal_dst() const { + return dst_.Get(); +} +inline void NeuralConnection::_internal_set_dst(const std::string& value) { + _has_bits_[0] |= 0x00000002u; + dst_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void NeuralConnection::set_dst(std::string&& value) { + _has_bits_[0] |= 0x00000002u; + dst_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.NeuralConnection.dst) +} +inline void NeuralConnection::set_dst(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000002u; + dst_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.NeuralConnection.dst) +} +inline void NeuralConnection::set_dst(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000002u; + dst_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.NeuralConnection.dst) +} +inline std::string* NeuralConnection::_internal_mutable_dst() { + _has_bits_[0] |= 0x00000002u; + return dst_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* NeuralConnection::release_dst() { + // @@protoc_insertion_point(field_release:revolve.msgs.NeuralConnection.dst) + if (!_internal_has_dst()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000002u; + return dst_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void NeuralConnection::set_allocated_dst(std::string* dst) { + if (dst != nullptr) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + dst_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), dst, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.NeuralConnection.dst) +} + +// required double weight = 3; +inline bool NeuralConnection::_internal_has_weight() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool NeuralConnection::has_weight() const { + return _internal_has_weight(); +} +inline void NeuralConnection::clear_weight() { + weight_ = 0; + _has_bits_[0] &= ~0x00000004u; +} +inline double NeuralConnection::_internal_weight() const { + return weight_; +} +inline double NeuralConnection::weight() const { + // @@protoc_insertion_point(field_get:revolve.msgs.NeuralConnection.weight) + return _internal_weight(); +} +inline void NeuralConnection::_internal_set_weight(double value) { + _has_bits_[0] |= 0x00000004u; + weight_ = value; +} +inline void NeuralConnection::set_weight(double value) { + _internal_set_weight(value); + // @@protoc_insertion_point(field_set:revolve.msgs.NeuralConnection.weight) +} + +// ------------------------------------------------------------------- + +// Neuron + +// required string id = 1; +inline bool Neuron::_internal_has_id() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool Neuron::has_id() const { + return _internal_has_id(); +} +inline void Neuron::clear_id() { + id_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& Neuron::id() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Neuron.id) + return _internal_id(); +} +inline void Neuron::set_id(const std::string& value) { + _internal_set_id(value); + // @@protoc_insertion_point(field_set:revolve.msgs.Neuron.id) +} +inline std::string* Neuron::mutable_id() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.Neuron.id) + return _internal_mutable_id(); +} +inline const std::string& Neuron::_internal_id() const { + return id_.Get(); +} +inline void Neuron::_internal_set_id(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void Neuron::set_id(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + id_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.Neuron.id) +} +inline void Neuron::set_id(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.Neuron.id) +} +inline void Neuron::set_id(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.Neuron.id) +} +inline std::string* Neuron::_internal_mutable_id() { + _has_bits_[0] |= 0x00000001u; + return id_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* Neuron::release_id() { + // @@protoc_insertion_point(field_release:revolve.msgs.Neuron.id) + if (!_internal_has_id()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return id_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void Neuron::set_allocated_id(std::string* id) { + if (id != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + id_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), id, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.Neuron.id) +} + +// required string layer = 2; +inline bool Neuron::_internal_has_layer() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool Neuron::has_layer() const { + return _internal_has_layer(); +} +inline void Neuron::clear_layer() { + layer_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000002u; +} +inline const std::string& Neuron::layer() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Neuron.layer) + return _internal_layer(); +} +inline void Neuron::set_layer(const std::string& value) { + _internal_set_layer(value); + // @@protoc_insertion_point(field_set:revolve.msgs.Neuron.layer) +} +inline std::string* Neuron::mutable_layer() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.Neuron.layer) + return _internal_mutable_layer(); +} +inline const std::string& Neuron::_internal_layer() const { + return layer_.Get(); +} +inline void Neuron::_internal_set_layer(const std::string& value) { + _has_bits_[0] |= 0x00000002u; + layer_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void Neuron::set_layer(std::string&& value) { + _has_bits_[0] |= 0x00000002u; + layer_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.Neuron.layer) +} +inline void Neuron::set_layer(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000002u; + layer_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.Neuron.layer) +} +inline void Neuron::set_layer(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000002u; + layer_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.Neuron.layer) +} +inline std::string* Neuron::_internal_mutable_layer() { + _has_bits_[0] |= 0x00000002u; + return layer_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* Neuron::release_layer() { + // @@protoc_insertion_point(field_release:revolve.msgs.Neuron.layer) + if (!_internal_has_layer()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000002u; + return layer_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void Neuron::set_allocated_layer(std::string* layer) { + if (layer != nullptr) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + layer_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), layer, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.Neuron.layer) +} + +// required string type = 3; +inline bool Neuron::_internal_has_type() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool Neuron::has_type() const { + return _internal_has_type(); +} +inline void Neuron::clear_type() { + type_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000004u; +} +inline const std::string& Neuron::type() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Neuron.type) + return _internal_type(); +} +inline void Neuron::set_type(const std::string& value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:revolve.msgs.Neuron.type) +} +inline std::string* Neuron::mutable_type() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.Neuron.type) + return _internal_mutable_type(); +} +inline const std::string& Neuron::_internal_type() const { + return type_.Get(); +} +inline void Neuron::_internal_set_type(const std::string& value) { + _has_bits_[0] |= 0x00000004u; + type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void Neuron::set_type(std::string&& value) { + _has_bits_[0] |= 0x00000004u; + type_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.Neuron.type) +} +inline void Neuron::set_type(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000004u; + type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.Neuron.type) +} +inline void Neuron::set_type(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000004u; + type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.Neuron.type) +} +inline std::string* Neuron::_internal_mutable_type() { + _has_bits_[0] |= 0x00000004u; + return type_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* Neuron::release_type() { + // @@protoc_insertion_point(field_release:revolve.msgs.Neuron.type) + if (!_internal_has_type()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000004u; + return type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void Neuron::set_allocated_type(std::string* type) { + if (type != nullptr) { + _has_bits_[0] |= 0x00000004u; + } else { + _has_bits_[0] &= ~0x00000004u; + } + type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.Neuron.type) +} + +// optional string partId = 4; +inline bool Neuron::_internal_has_partid() const { + bool value = (_has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool Neuron::has_partid() const { + return _internal_has_partid(); +} +inline void Neuron::clear_partid() { + partid_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000008u; +} +inline const std::string& Neuron::partid() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Neuron.partId) + return _internal_partid(); +} +inline void Neuron::set_partid(const std::string& value) { + _internal_set_partid(value); + // @@protoc_insertion_point(field_set:revolve.msgs.Neuron.partId) +} +inline std::string* Neuron::mutable_partid() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.Neuron.partId) + return _internal_mutable_partid(); +} +inline const std::string& Neuron::_internal_partid() const { + return partid_.Get(); +} +inline void Neuron::_internal_set_partid(const std::string& value) { + _has_bits_[0] |= 0x00000008u; + partid_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void Neuron::set_partid(std::string&& value) { + _has_bits_[0] |= 0x00000008u; + partid_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.Neuron.partId) +} +inline void Neuron::set_partid(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000008u; + partid_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.Neuron.partId) +} +inline void Neuron::set_partid(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000008u; + partid_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.Neuron.partId) +} +inline std::string* Neuron::_internal_mutable_partid() { + _has_bits_[0] |= 0x00000008u; + return partid_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* Neuron::release_partid() { + // @@protoc_insertion_point(field_release:revolve.msgs.Neuron.partId) + if (!_internal_has_partid()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000008u; + return partid_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void Neuron::set_allocated_partid(std::string* partid) { + if (partid != nullptr) { + _has_bits_[0] |= 0x00000008u; + } else { + _has_bits_[0] &= ~0x00000008u; + } + partid_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), partid, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.Neuron.partId) +} + +// repeated .revolve.msgs.Parameter param = 5; +inline int Neuron::_internal_param_size() const { + return param_.size(); +} +inline int Neuron::param_size() const { + return _internal_param_size(); +} +inline ::revolve::msgs::Parameter* Neuron::mutable_param(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.Neuron.param) + return param_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >* +Neuron::mutable_param() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.Neuron.param) + return ¶m_; +} +inline const ::revolve::msgs::Parameter& Neuron::_internal_param(int index) const { + return param_.Get(index); +} +inline const ::revolve::msgs::Parameter& Neuron::param(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.Neuron.param) + return _internal_param(index); +} +inline ::revolve::msgs::Parameter* Neuron::_internal_add_param() { + return param_.Add(); +} +inline ::revolve::msgs::Parameter* Neuron::add_param() { + // @@protoc_insertion_point(field_add:revolve.msgs.Neuron.param) + return _internal_add_param(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >& +Neuron::param() const { + // @@protoc_insertion_point(field_list:revolve.msgs.Neuron.param) + return param_; +} + +// ------------------------------------------------------------------- + +// NeuralNetwork + +// repeated .revolve.msgs.Neuron neuron = 1; +inline int NeuralNetwork::_internal_neuron_size() const { + return neuron_.size(); +} +inline int NeuralNetwork::neuron_size() const { + return _internal_neuron_size(); +} +inline void NeuralNetwork::clear_neuron() { + neuron_.Clear(); +} +inline ::revolve::msgs::Neuron* NeuralNetwork::mutable_neuron(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.NeuralNetwork.neuron) + return neuron_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >* +NeuralNetwork::mutable_neuron() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.NeuralNetwork.neuron) + return &neuron_; +} +inline const ::revolve::msgs::Neuron& NeuralNetwork::_internal_neuron(int index) const { + return neuron_.Get(index); +} +inline const ::revolve::msgs::Neuron& NeuralNetwork::neuron(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.NeuralNetwork.neuron) + return _internal_neuron(index); +} +inline ::revolve::msgs::Neuron* NeuralNetwork::_internal_add_neuron() { + return neuron_.Add(); +} +inline ::revolve::msgs::Neuron* NeuralNetwork::add_neuron() { + // @@protoc_insertion_point(field_add:revolve.msgs.NeuralNetwork.neuron) + return _internal_add_neuron(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >& +NeuralNetwork::neuron() const { + // @@protoc_insertion_point(field_list:revolve.msgs.NeuralNetwork.neuron) + return neuron_; +} + +// repeated .revolve.msgs.NeuralConnection connection = 2; +inline int NeuralNetwork::_internal_connection_size() const { + return connection_.size(); +} +inline int NeuralNetwork::connection_size() const { + return _internal_connection_size(); +} +inline void NeuralNetwork::clear_connection() { + connection_.Clear(); +} +inline ::revolve::msgs::NeuralConnection* NeuralNetwork::mutable_connection(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.NeuralNetwork.connection) + return connection_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::NeuralConnection >* +NeuralNetwork::mutable_connection() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.NeuralNetwork.connection) + return &connection_; +} +inline const ::revolve::msgs::NeuralConnection& NeuralNetwork::_internal_connection(int index) const { + return connection_.Get(index); +} +inline const ::revolve::msgs::NeuralConnection& NeuralNetwork::connection(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.NeuralNetwork.connection) + return _internal_connection(index); +} +inline ::revolve::msgs::NeuralConnection* NeuralNetwork::_internal_add_connection() { + return connection_.Add(); +} +inline ::revolve::msgs::NeuralConnection* NeuralNetwork::add_connection() { + // @@protoc_insertion_point(field_add:revolve.msgs.NeuralNetwork.connection) + return _internal_add_connection(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::NeuralConnection >& +NeuralNetwork::connection() const { + // @@protoc_insertion_point(field_list:revolve.msgs.NeuralNetwork.connection) + return connection_; +} + +// ------------------------------------------------------------------- + +// ModifyNeuralNetwork + +// repeated string remove_hidden = 1; +inline int ModifyNeuralNetwork::_internal_remove_hidden_size() const { + return remove_hidden_.size(); +} +inline int ModifyNeuralNetwork::remove_hidden_size() const { + return _internal_remove_hidden_size(); +} +inline void ModifyNeuralNetwork::clear_remove_hidden() { + remove_hidden_.Clear(); +} +inline std::string* ModifyNeuralNetwork::add_remove_hidden() { + // @@protoc_insertion_point(field_add_mutable:revolve.msgs.ModifyNeuralNetwork.remove_hidden) + return _internal_add_remove_hidden(); +} +inline const std::string& ModifyNeuralNetwork::_internal_remove_hidden(int index) const { + return remove_hidden_.Get(index); +} +inline const std::string& ModifyNeuralNetwork::remove_hidden(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.ModifyNeuralNetwork.remove_hidden) + return _internal_remove_hidden(index); +} +inline std::string* ModifyNeuralNetwork::mutable_remove_hidden(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.ModifyNeuralNetwork.remove_hidden) + return remove_hidden_.Mutable(index); +} +inline void ModifyNeuralNetwork::set_remove_hidden(int index, const std::string& value) { + // @@protoc_insertion_point(field_set:revolve.msgs.ModifyNeuralNetwork.remove_hidden) + remove_hidden_.Mutable(index)->assign(value); +} +inline void ModifyNeuralNetwork::set_remove_hidden(int index, std::string&& value) { + // @@protoc_insertion_point(field_set:revolve.msgs.ModifyNeuralNetwork.remove_hidden) + remove_hidden_.Mutable(index)->assign(std::move(value)); +} +inline void ModifyNeuralNetwork::set_remove_hidden(int index, const char* value) { + GOOGLE_DCHECK(value != nullptr); + remove_hidden_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:revolve.msgs.ModifyNeuralNetwork.remove_hidden) +} +inline void ModifyNeuralNetwork::set_remove_hidden(int index, const char* value, size_t size) { + remove_hidden_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.ModifyNeuralNetwork.remove_hidden) +} +inline std::string* ModifyNeuralNetwork::_internal_add_remove_hidden() { + return remove_hidden_.Add(); +} +inline void ModifyNeuralNetwork::add_remove_hidden(const std::string& value) { + remove_hidden_.Add()->assign(value); + // @@protoc_insertion_point(field_add:revolve.msgs.ModifyNeuralNetwork.remove_hidden) +} +inline void ModifyNeuralNetwork::add_remove_hidden(std::string&& value) { + remove_hidden_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:revolve.msgs.ModifyNeuralNetwork.remove_hidden) +} +inline void ModifyNeuralNetwork::add_remove_hidden(const char* value) { + GOOGLE_DCHECK(value != nullptr); + remove_hidden_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:revolve.msgs.ModifyNeuralNetwork.remove_hidden) +} +inline void ModifyNeuralNetwork::add_remove_hidden(const char* value, size_t size) { + remove_hidden_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:revolve.msgs.ModifyNeuralNetwork.remove_hidden) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& +ModifyNeuralNetwork::remove_hidden() const { + // @@protoc_insertion_point(field_list:revolve.msgs.ModifyNeuralNetwork.remove_hidden) + return remove_hidden_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +ModifyNeuralNetwork::mutable_remove_hidden() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.ModifyNeuralNetwork.remove_hidden) + return &remove_hidden_; +} + +// repeated .revolve.msgs.Neuron add_hidden = 2; +inline int ModifyNeuralNetwork::_internal_add_hidden_size() const { + return add_hidden_.size(); +} +inline int ModifyNeuralNetwork::add_hidden_size() const { + return _internal_add_hidden_size(); +} +inline void ModifyNeuralNetwork::clear_add_hidden() { + add_hidden_.Clear(); +} +inline ::revolve::msgs::Neuron* ModifyNeuralNetwork::mutable_add_hidden(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.ModifyNeuralNetwork.add_hidden) + return add_hidden_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >* +ModifyNeuralNetwork::mutable_add_hidden() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.ModifyNeuralNetwork.add_hidden) + return &add_hidden_; +} +inline const ::revolve::msgs::Neuron& ModifyNeuralNetwork::_internal_add_hidden(int index) const { + return add_hidden_.Get(index); +} +inline const ::revolve::msgs::Neuron& ModifyNeuralNetwork::add_hidden(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.ModifyNeuralNetwork.add_hidden) + return _internal_add_hidden(index); +} +inline ::revolve::msgs::Neuron* ModifyNeuralNetwork::_internal_add_add_hidden() { + return add_hidden_.Add(); +} +inline ::revolve::msgs::Neuron* ModifyNeuralNetwork::add_add_hidden() { + // @@protoc_insertion_point(field_add:revolve.msgs.ModifyNeuralNetwork.add_hidden) + return _internal_add_add_hidden(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >& +ModifyNeuralNetwork::add_hidden() const { + // @@protoc_insertion_point(field_list:revolve.msgs.ModifyNeuralNetwork.add_hidden) + return add_hidden_; +} + +// repeated .revolve.msgs.Neuron set_parameters = 4; +inline int ModifyNeuralNetwork::_internal_set_parameters_size() const { + return set_parameters_.size(); +} +inline int ModifyNeuralNetwork::set_parameters_size() const { + return _internal_set_parameters_size(); +} +inline void ModifyNeuralNetwork::clear_set_parameters() { + set_parameters_.Clear(); +} +inline ::revolve::msgs::Neuron* ModifyNeuralNetwork::mutable_set_parameters(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.ModifyNeuralNetwork.set_parameters) + return set_parameters_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >* +ModifyNeuralNetwork::mutable_set_parameters() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.ModifyNeuralNetwork.set_parameters) + return &set_parameters_; +} +inline const ::revolve::msgs::Neuron& ModifyNeuralNetwork::_internal_set_parameters(int index) const { + return set_parameters_.Get(index); +} +inline const ::revolve::msgs::Neuron& ModifyNeuralNetwork::set_parameters(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.ModifyNeuralNetwork.set_parameters) + return _internal_set_parameters(index); +} +inline ::revolve::msgs::Neuron* ModifyNeuralNetwork::_internal_add_set_parameters() { + return set_parameters_.Add(); +} +inline ::revolve::msgs::Neuron* ModifyNeuralNetwork::add_set_parameters() { + // @@protoc_insertion_point(field_add:revolve.msgs.ModifyNeuralNetwork.set_parameters) + return _internal_add_set_parameters(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Neuron >& +ModifyNeuralNetwork::set_parameters() const { + // @@protoc_insertion_point(field_list:revolve.msgs.ModifyNeuralNetwork.set_parameters) + return set_parameters_; +} + +// repeated .revolve.msgs.NeuralConnection set_weights = 3; +inline int ModifyNeuralNetwork::_internal_set_weights_size() const { + return set_weights_.size(); +} +inline int ModifyNeuralNetwork::set_weights_size() const { + return _internal_set_weights_size(); +} +inline void ModifyNeuralNetwork::clear_set_weights() { + set_weights_.Clear(); +} +inline ::revolve::msgs::NeuralConnection* ModifyNeuralNetwork::mutable_set_weights(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.ModifyNeuralNetwork.set_weights) + return set_weights_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::NeuralConnection >* +ModifyNeuralNetwork::mutable_set_weights() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.ModifyNeuralNetwork.set_weights) + return &set_weights_; +} +inline const ::revolve::msgs::NeuralConnection& ModifyNeuralNetwork::_internal_set_weights(int index) const { + return set_weights_.Get(index); +} +inline const ::revolve::msgs::NeuralConnection& ModifyNeuralNetwork::set_weights(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.ModifyNeuralNetwork.set_weights) + return _internal_set_weights(index); +} +inline ::revolve::msgs::NeuralConnection* ModifyNeuralNetwork::_internal_add_set_weights() { + return set_weights_.Add(); +} +inline ::revolve::msgs::NeuralConnection* ModifyNeuralNetwork::add_set_weights() { + // @@protoc_insertion_point(field_add:revolve.msgs.ModifyNeuralNetwork.set_weights) + return _internal_add_set_weights(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::NeuralConnection >& +ModifyNeuralNetwork::set_weights() const { + // @@protoc_insertion_point(field_list:revolve.msgs.ModifyNeuralNetwork.set_weights) + return set_weights_; +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace msgs +} // namespace revolve + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_neural_5fnet_2eproto diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/parameter.pb.cc b/cpprevolve/revolve/gazebo/revolve/msgs/parameter.pb.cc new file mode 100644 index 0000000000..48a64d5c85 --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/parameter.pb.cc @@ -0,0 +1,301 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: parameter.proto + +#include "parameter.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include +namespace revolve { +namespace msgs { +class ParameterDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _Parameter_default_instance_; +} // namespace msgs +} // namespace revolve +static void InitDefaultsscc_info_Parameter_parameter_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_Parameter_default_instance_; + new (ptr) ::revolve::msgs::Parameter(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::Parameter::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Parameter_parameter_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Parameter_parameter_2eproto}, {}}; + +static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_parameter_2eproto[1]; +static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_parameter_2eproto = nullptr; +static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_parameter_2eproto = nullptr; + +const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_parameter_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Parameter, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Parameter, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Parameter, value_), + 0, +}; +static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 6, sizeof(::revolve::msgs::Parameter)}, +}; + +static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { + reinterpret_cast(&::revolve::msgs::_Parameter_default_instance_), +}; + +const char descriptor_table_protodef_parameter_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\017parameter.proto\022\014revolve.msgs\"\032\n\tParam" + "eter\022\r\n\005value\030\001 \002(\001" + ; +static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_parameter_2eproto_deps[1] = { +}; +static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_parameter_2eproto_sccs[1] = { + &scc_info_Parameter_parameter_2eproto.base, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_parameter_2eproto_once; +const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_parameter_2eproto = { + false, false, descriptor_table_protodef_parameter_2eproto, "parameter.proto", 59, + &descriptor_table_parameter_2eproto_once, descriptor_table_parameter_2eproto_sccs, descriptor_table_parameter_2eproto_deps, 1, 0, + schemas, file_default_instances, TableStruct_parameter_2eproto::offsets, + file_level_metadata_parameter_2eproto, 1, file_level_enum_descriptors_parameter_2eproto, file_level_service_descriptors_parameter_2eproto, +}; + +// Force running AddDescriptors() at dynamic initialization time. +static bool dynamic_init_dummy_parameter_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_parameter_2eproto)), true); +namespace revolve { +namespace msgs { + +// =================================================================== + +void Parameter::InitAsDefaultInstance() { +} +class Parameter::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_value(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; + } +}; + +Parameter::Parameter(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.Parameter) +} +Parameter::Parameter(const Parameter& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + value_ = from.value_; + // @@protoc_insertion_point(copy_constructor:revolve.msgs.Parameter) +} + +void Parameter::SharedCtor() { + value_ = 0; +} + +Parameter::~Parameter() { + // @@protoc_insertion_point(destructor:revolve.msgs.Parameter) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void Parameter::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void Parameter::ArenaDtor(void* object) { + Parameter* _this = reinterpret_cast< Parameter* >(object); + (void)_this; +} +void Parameter::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void Parameter::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const Parameter& Parameter::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Parameter_parameter_2eproto.base); + return *internal_default_instance(); +} + + +void Parameter::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.Parameter) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + value_ = 0; + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Parameter::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required double value = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 9)) { + _Internal::set_has_value(&has_bits); + value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); + ptr += sizeof(double); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* Parameter::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.Parameter) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required double value = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(1, this->_internal_value(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.Parameter) + return target; +} + +size_t Parameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.Parameter) + size_t total_size = 0; + + // required double value = 1; + if (_internal_has_value()) { + total_size += 1 + 8; + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void Parameter::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.Parameter) + GOOGLE_DCHECK_NE(&from, this); + const Parameter* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.Parameter) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.Parameter) + MergeFrom(*source); + } +} + +void Parameter::MergeFrom(const Parameter& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.Parameter) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_has_value()) { + _internal_set_value(from._internal_value()); + } +} + +void Parameter::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.Parameter) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Parameter::CopyFrom(const Parameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.Parameter) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Parameter::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + return true; +} + +void Parameter::InternalSwap(Parameter* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + swap(value_, other->value_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Parameter::GetMetadata() const { + return GetMetadataStatic(); +} + + +// @@protoc_insertion_point(namespace_scope) +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::revolve::msgs::Parameter* Arena::CreateMaybeMessage< ::revolve::msgs::Parameter >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::Parameter >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/parameter.pb.h b/cpprevolve/revolve/gazebo/revolve/msgs/parameter.pb.h new file mode 100644 index 0000000000..81a70b5449 --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/parameter.pb.h @@ -0,0 +1,270 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: parameter.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_parameter_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_parameter_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3013000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3013000 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_parameter_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_parameter_2eproto { + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; + static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; + static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_parameter_2eproto; +namespace revolve { +namespace msgs { +class Parameter; +class ParameterDefaultTypeInternal; +extern ParameterDefaultTypeInternal _Parameter_default_instance_; +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> ::revolve::msgs::Parameter* Arena::CreateMaybeMessage<::revolve::msgs::Parameter>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace revolve { +namespace msgs { + +// =================================================================== + +class Parameter PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.Parameter) */ { + public: + inline Parameter() : Parameter(nullptr) {} + virtual ~Parameter(); + + Parameter(const Parameter& from); + Parameter(Parameter&& from) noexcept + : Parameter() { + *this = ::std::move(from); + } + + inline Parameter& operator=(const Parameter& from) { + CopyFrom(from); + return *this; + } + inline Parameter& operator=(Parameter&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const Parameter& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const Parameter* internal_default_instance() { + return reinterpret_cast( + &_Parameter_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Parameter& a, Parameter& b) { + a.Swap(&b); + } + inline void Swap(Parameter* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Parameter* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline Parameter* New() const final { + return CreateMaybeMessage(nullptr); + } + + Parameter* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const Parameter& from); + void MergeFrom(const Parameter& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Parameter* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.Parameter"; + } + protected: + explicit Parameter(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_parameter_2eproto); + return ::descriptor_table_parameter_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kValueFieldNumber = 1, + }; + // required double value = 1; + bool has_value() const; + private: + bool _internal_has_value() const; + public: + void clear_value(); + double value() const; + void set_value(double value); + private: + double _internal_value() const; + void _internal_set_value(double value); + public: + + // @@protoc_insertion_point(class_scope:revolve.msgs.Parameter) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + double value_; + friend struct ::TableStruct_parameter_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// Parameter + +// required double value = 1; +inline bool Parameter::_internal_has_value() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool Parameter::has_value() const { + return _internal_has_value(); +} +inline void Parameter::clear_value() { + value_ = 0; + _has_bits_[0] &= ~0x00000001u; +} +inline double Parameter::_internal_value() const { + return value_; +} +inline double Parameter::value() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Parameter.value) + return _internal_value(); +} +inline void Parameter::_internal_set_value(double value) { + _has_bits_[0] |= 0x00000001u; + value_ = value; +} +inline void Parameter::set_value(double value) { + _internal_set_value(value); + // @@protoc_insertion_point(field_set:revolve.msgs.Parameter.value) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + +} // namespace msgs +} // namespace revolve + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_parameter_2eproto diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/robot.pb.cc b/cpprevolve/revolve/gazebo/revolve/msgs/robot.pb.cc new file mode 100644 index 0000000000..a66ecaa9a1 --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/robot.pb.cc @@ -0,0 +1,460 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: robot.proto + +#include "robot.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include +extern PROTOBUF_INTERNAL_EXPORT_body_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Body_body_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_neural_5fnet_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_NeuralNetwork_neural_5fnet_2eproto; +namespace revolve { +namespace msgs { +class RobotDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _Robot_default_instance_; +} // namespace msgs +} // namespace revolve +static void InitDefaultsscc_info_Robot_robot_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_Robot_default_instance_; + new (ptr) ::revolve::msgs::Robot(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::Robot::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_Robot_robot_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_Robot_robot_2eproto}, { + &scc_info_Body_body_2eproto.base, + &scc_info_NeuralNetwork_neural_5fnet_2eproto.base,}}; + +static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_robot_2eproto[1]; +static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_robot_2eproto = nullptr; +static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_robot_2eproto = nullptr; + +const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_robot_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Robot, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Robot, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Robot, id_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Robot, body_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Robot, brain_), + 2, + 0, + 1, +}; +static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 8, sizeof(::revolve::msgs::Robot)}, +}; + +static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { + reinterpret_cast(&::revolve::msgs::_Robot_default_instance_), +}; + +const char descriptor_table_protodef_robot_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\013robot.proto\022\014revolve.msgs\032\nbody.proto\032" + "\020neural_net.proto\"a\n\005Robot\022\n\n\002id\030\001 \002(\005\022 " + "\n\004body\030\002 \002(\0132\022.revolve.msgs.Body\022*\n\005brai" + "n\030\003 \002(\0132\033.revolve.msgs.NeuralNetwork" + ; +static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_robot_2eproto_deps[2] = { + &::descriptor_table_body_2eproto, + &::descriptor_table_neural_5fnet_2eproto, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_robot_2eproto_sccs[1] = { + &scc_info_Robot_robot_2eproto.base, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_robot_2eproto_once; +const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_robot_2eproto = { + false, false, descriptor_table_protodef_robot_2eproto, "robot.proto", 156, + &descriptor_table_robot_2eproto_once, descriptor_table_robot_2eproto_sccs, descriptor_table_robot_2eproto_deps, 1, 2, + schemas, file_default_instances, TableStruct_robot_2eproto::offsets, + file_level_metadata_robot_2eproto, 1, file_level_enum_descriptors_robot_2eproto, file_level_service_descriptors_robot_2eproto, +}; + +// Force running AddDescriptors() at dynamic initialization time. +static bool dynamic_init_dummy_robot_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_robot_2eproto)), true); +namespace revolve { +namespace msgs { + +// =================================================================== + +void Robot::InitAsDefaultInstance() { + ::revolve::msgs::_Robot_default_instance_._instance.get_mutable()->body_ = const_cast< ::revolve::msgs::Body*>( + ::revolve::msgs::Body::internal_default_instance()); + ::revolve::msgs::_Robot_default_instance_._instance.get_mutable()->brain_ = const_cast< ::revolve::msgs::NeuralNetwork*>( + ::revolve::msgs::NeuralNetwork::internal_default_instance()); +} +class Robot::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_id(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static const ::revolve::msgs::Body& body(const Robot* msg); + static void set_has_body(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::revolve::msgs::NeuralNetwork& brain(const Robot* msg); + static void set_has_brain(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000007) ^ 0x00000007) != 0; + } +}; + +const ::revolve::msgs::Body& +Robot::_Internal::body(const Robot* msg) { + return *msg->body_; +} +const ::revolve::msgs::NeuralNetwork& +Robot::_Internal::brain(const Robot* msg) { + return *msg->brain_; +} +void Robot::clear_body() { + if (body_ != nullptr) body_->Clear(); + _has_bits_[0] &= ~0x00000001u; +} +void Robot::clear_brain() { + if (brain_ != nullptr) brain_->Clear(); + _has_bits_[0] &= ~0x00000002u; +} +Robot::Robot(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.Robot) +} +Robot::Robot(const Robot& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_body()) { + body_ = new ::revolve::msgs::Body(*from.body_); + } else { + body_ = nullptr; + } + if (from._internal_has_brain()) { + brain_ = new ::revolve::msgs::NeuralNetwork(*from.brain_); + } else { + brain_ = nullptr; + } + id_ = from.id_; + // @@protoc_insertion_point(copy_constructor:revolve.msgs.Robot) +} + +void Robot::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Robot_robot_2eproto.base); + ::memset(&body_, 0, static_cast( + reinterpret_cast(&id_) - + reinterpret_cast(&body_)) + sizeof(id_)); +} + +Robot::~Robot() { + // @@protoc_insertion_point(destructor:revolve.msgs.Robot) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void Robot::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + if (this != internal_default_instance()) delete body_; + if (this != internal_default_instance()) delete brain_; +} + +void Robot::ArenaDtor(void* object) { + Robot* _this = reinterpret_cast< Robot* >(object); + (void)_this; +} +void Robot::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void Robot::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const Robot& Robot::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Robot_robot_2eproto.base); + return *internal_default_instance(); +} + + +void Robot::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.Robot) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(body_ != nullptr); + body_->Clear(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(brain_ != nullptr); + brain_->Clear(); + } + } + id_ = 0; + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Robot::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required int32 id = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + _Internal::set_has_id(&has_bits); + id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // required .revolve.msgs.Body body = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr = ctx->ParseMessage(_internal_mutable_body(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // required .revolve.msgs.NeuralNetwork brain = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { + ptr = ctx->ParseMessage(_internal_mutable_brain(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* Robot::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.Robot) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required int32 id = 1; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_id(), target); + } + + // required .revolve.msgs.Body body = 2; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 2, _Internal::body(this), target, stream); + } + + // required .revolve.msgs.NeuralNetwork brain = 3; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 3, _Internal::brain(this), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.Robot) + return target; +} + +size_t Robot::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:revolve.msgs.Robot) + size_t total_size = 0; + + if (_internal_has_body()) { + // required .revolve.msgs.Body body = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *body_); + } + + if (_internal_has_brain()) { + // required .revolve.msgs.NeuralNetwork brain = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *brain_); + } + + if (_internal_has_id()) { + // required int32 id = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_id()); + } + + return total_size; +} +size_t Robot::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.Robot) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) { // All required fields are present. + // required .revolve.msgs.Body body = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *body_); + + // required .revolve.msgs.NeuralNetwork brain = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *brain_); + + // required int32 id = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_id()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void Robot::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.Robot) + GOOGLE_DCHECK_NE(&from, this); + const Robot* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.Robot) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.Robot) + MergeFrom(*source); + } +} + +void Robot::MergeFrom(const Robot& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.Robot) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000001u) { + _internal_mutable_body()->::revolve::msgs::Body::MergeFrom(from._internal_body()); + } + if (cached_has_bits & 0x00000002u) { + _internal_mutable_brain()->::revolve::msgs::NeuralNetwork::MergeFrom(from._internal_brain()); + } + if (cached_has_bits & 0x00000004u) { + id_ = from.id_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void Robot::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.Robot) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Robot::CopyFrom(const Robot& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.Robot) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Robot::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_internal_has_body()) { + if (!body_->IsInitialized()) return false; + } + if (_internal_has_brain()) { + if (!brain_->IsInitialized()) return false; + } + return true; +} + +void Robot::InternalSwap(Robot* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Robot, id_) + + sizeof(Robot::id_) + - PROTOBUF_FIELD_OFFSET(Robot, body_)>( + reinterpret_cast(&body_), + reinterpret_cast(&other->body_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Robot::GetMetadata() const { + return GetMetadataStatic(); +} + + +// @@protoc_insertion_point(namespace_scope) +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::revolve::msgs::Robot* Arena::CreateMaybeMessage< ::revolve::msgs::Robot >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::Robot >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/robot.pb.h b/cpprevolve/revolve/gazebo/revolve/msgs/robot.pb.h new file mode 100644 index 0000000000..d4d3bb8932 --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/robot.pb.h @@ -0,0 +1,473 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: robot.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_robot_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_robot_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3013000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3013000 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include "body.pb.h" +#include "neural_net.pb.h" +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_robot_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_robot_2eproto { + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; + static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; + static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_robot_2eproto; +namespace revolve { +namespace msgs { +class Robot; +class RobotDefaultTypeInternal; +extern RobotDefaultTypeInternal _Robot_default_instance_; +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> ::revolve::msgs::Robot* Arena::CreateMaybeMessage<::revolve::msgs::Robot>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace revolve { +namespace msgs { + +// =================================================================== + +class Robot PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.Robot) */ { + public: + inline Robot() : Robot(nullptr) {} + virtual ~Robot(); + + Robot(const Robot& from); + Robot(Robot&& from) noexcept + : Robot() { + *this = ::std::move(from); + } + + inline Robot& operator=(const Robot& from) { + CopyFrom(from); + return *this; + } + inline Robot& operator=(Robot&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const Robot& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const Robot* internal_default_instance() { + return reinterpret_cast( + &_Robot_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Robot& a, Robot& b) { + a.Swap(&b); + } + inline void Swap(Robot* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Robot* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline Robot* New() const final { + return CreateMaybeMessage(nullptr); + } + + Robot* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const Robot& from); + void MergeFrom(const Robot& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Robot* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.Robot"; + } + protected: + explicit Robot(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_robot_2eproto); + return ::descriptor_table_robot_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kBodyFieldNumber = 2, + kBrainFieldNumber = 3, + kIdFieldNumber = 1, + }; + // required .revolve.msgs.Body body = 2; + bool has_body() const; + private: + bool _internal_has_body() const; + public: + void clear_body(); + const ::revolve::msgs::Body& body() const; + ::revolve::msgs::Body* release_body(); + ::revolve::msgs::Body* mutable_body(); + void set_allocated_body(::revolve::msgs::Body* body); + private: + const ::revolve::msgs::Body& _internal_body() const; + ::revolve::msgs::Body* _internal_mutable_body(); + public: + void unsafe_arena_set_allocated_body( + ::revolve::msgs::Body* body); + ::revolve::msgs::Body* unsafe_arena_release_body(); + + // required .revolve.msgs.NeuralNetwork brain = 3; + bool has_brain() const; + private: + bool _internal_has_brain() const; + public: + void clear_brain(); + const ::revolve::msgs::NeuralNetwork& brain() const; + ::revolve::msgs::NeuralNetwork* release_brain(); + ::revolve::msgs::NeuralNetwork* mutable_brain(); + void set_allocated_brain(::revolve::msgs::NeuralNetwork* brain); + private: + const ::revolve::msgs::NeuralNetwork& _internal_brain() const; + ::revolve::msgs::NeuralNetwork* _internal_mutable_brain(); + public: + void unsafe_arena_set_allocated_brain( + ::revolve::msgs::NeuralNetwork* brain); + ::revolve::msgs::NeuralNetwork* unsafe_arena_release_brain(); + + // required int32 id = 1; + bool has_id() const; + private: + bool _internal_has_id() const; + public: + void clear_id(); + ::PROTOBUF_NAMESPACE_ID::int32 id() const; + void set_id(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_id() const; + void _internal_set_id(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:revolve.msgs.Robot) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::revolve::msgs::Body* body_; + ::revolve::msgs::NeuralNetwork* brain_; + ::PROTOBUF_NAMESPACE_ID::int32 id_; + friend struct ::TableStruct_robot_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// Robot + +// required int32 id = 1; +inline bool Robot::_internal_has_id() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool Robot::has_id() const { + return _internal_has_id(); +} +inline void Robot::clear_id() { + id_ = 0; + _has_bits_[0] &= ~0x00000004u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 Robot::_internal_id() const { + return id_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 Robot::id() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Robot.id) + return _internal_id(); +} +inline void Robot::_internal_set_id(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000004u; + id_ = value; +} +inline void Robot::set_id(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_id(value); + // @@protoc_insertion_point(field_set:revolve.msgs.Robot.id) +} + +// required .revolve.msgs.Body body = 2; +inline bool Robot::_internal_has_body() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || body_ != nullptr); + return value; +} +inline bool Robot::has_body() const { + return _internal_has_body(); +} +inline const ::revolve::msgs::Body& Robot::_internal_body() const { + const ::revolve::msgs::Body* p = body_; + return p != nullptr ? *p : *reinterpret_cast( + &::revolve::msgs::_Body_default_instance_); +} +inline const ::revolve::msgs::Body& Robot::body() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Robot.body) + return _internal_body(); +} +inline void Robot::unsafe_arena_set_allocated_body( + ::revolve::msgs::Body* body) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(body_); + } + body_ = body; + if (body) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:revolve.msgs.Robot.body) +} +inline ::revolve::msgs::Body* Robot::release_body() { + _has_bits_[0] &= ~0x00000001u; + ::revolve::msgs::Body* temp = body_; + body_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::revolve::msgs::Body* Robot::unsafe_arena_release_body() { + // @@protoc_insertion_point(field_release:revolve.msgs.Robot.body) + _has_bits_[0] &= ~0x00000001u; + ::revolve::msgs::Body* temp = body_; + body_ = nullptr; + return temp; +} +inline ::revolve::msgs::Body* Robot::_internal_mutable_body() { + _has_bits_[0] |= 0x00000001u; + if (body_ == nullptr) { + auto* p = CreateMaybeMessage<::revolve::msgs::Body>(GetArena()); + body_ = p; + } + return body_; +} +inline ::revolve::msgs::Body* Robot::mutable_body() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.Robot.body) + return _internal_mutable_body(); +} +inline void Robot::set_allocated_body(::revolve::msgs::Body* body) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(body_); + } + if (body) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(body)->GetArena(); + if (message_arena != submessage_arena) { + body = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, body, submessage_arena); + } + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + body_ = body; + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.Robot.body) +} + +// required .revolve.msgs.NeuralNetwork brain = 3; +inline bool Robot::_internal_has_brain() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || brain_ != nullptr); + return value; +} +inline bool Robot::has_brain() const { + return _internal_has_brain(); +} +inline const ::revolve::msgs::NeuralNetwork& Robot::_internal_brain() const { + const ::revolve::msgs::NeuralNetwork* p = brain_; + return p != nullptr ? *p : *reinterpret_cast( + &::revolve::msgs::_NeuralNetwork_default_instance_); +} +inline const ::revolve::msgs::NeuralNetwork& Robot::brain() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Robot.brain) + return _internal_brain(); +} +inline void Robot::unsafe_arena_set_allocated_brain( + ::revolve::msgs::NeuralNetwork* brain) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(brain_); + } + brain_ = brain; + if (brain) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:revolve.msgs.Robot.brain) +} +inline ::revolve::msgs::NeuralNetwork* Robot::release_brain() { + _has_bits_[0] &= ~0x00000002u; + ::revolve::msgs::NeuralNetwork* temp = brain_; + brain_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::revolve::msgs::NeuralNetwork* Robot::unsafe_arena_release_brain() { + // @@protoc_insertion_point(field_release:revolve.msgs.Robot.brain) + _has_bits_[0] &= ~0x00000002u; + ::revolve::msgs::NeuralNetwork* temp = brain_; + brain_ = nullptr; + return temp; +} +inline ::revolve::msgs::NeuralNetwork* Robot::_internal_mutable_brain() { + _has_bits_[0] |= 0x00000002u; + if (brain_ == nullptr) { + auto* p = CreateMaybeMessage<::revolve::msgs::NeuralNetwork>(GetArena()); + brain_ = p; + } + return brain_; +} +inline ::revolve::msgs::NeuralNetwork* Robot::mutable_brain() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.Robot.brain) + return _internal_mutable_brain(); +} +inline void Robot::set_allocated_brain(::revolve::msgs::NeuralNetwork* brain) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(brain_); + } + if (brain) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(brain)->GetArena(); + if (message_arena != submessage_arena) { + brain = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, brain, submessage_arena); + } + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + brain_ = brain; + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.Robot.brain) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + +} // namespace msgs +} // namespace revolve + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_robot_2eproto diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/robot_states.pb.cc b/cpprevolve/revolve/gazebo/revolve/msgs/robot_states.pb.cc new file mode 100644 index 0000000000..6dca058b4e --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/robot_states.pb.cc @@ -0,0 +1,793 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: robot_states.proto + +#include "robot_states.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include +extern PROTOBUF_INTERNAL_EXPORT_pose_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_Pose_pose_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_time_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Time_time_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_robot_5fstates_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_RobotState_robot_5fstates_2eproto; +namespace revolve { +namespace msgs { +class RobotStateDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _RobotState_default_instance_; +class RobotStatesDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _RobotStates_default_instance_; +} // namespace msgs +} // namespace revolve +static void InitDefaultsscc_info_RobotState_robot_5fstates_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_RobotState_default_instance_; + new (ptr) ::revolve::msgs::RobotState(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::RobotState::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_RobotState_robot_5fstates_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_RobotState_robot_5fstates_2eproto}, { + &scc_info_Pose_pose_2eproto.base,}}; + +static void InitDefaultsscc_info_RobotStates_robot_5fstates_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_RobotStates_default_instance_; + new (ptr) ::revolve::msgs::RobotStates(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::RobotStates::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_RobotStates_robot_5fstates_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_RobotStates_robot_5fstates_2eproto}, { + &scc_info_Time_time_2eproto.base, + &scc_info_RobotState_robot_5fstates_2eproto.base,}}; + +static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_robot_5fstates_2eproto[2]; +static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_robot_5fstates_2eproto = nullptr; +static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_robot_5fstates_2eproto = nullptr; + +const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_robot_5fstates_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::revolve::msgs::RobotState, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::RobotState, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::RobotState, id_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::RobotState, name_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::RobotState, pose_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::RobotState, dead_), + 2, + 0, + 1, + 3, + PROTOBUF_FIELD_OFFSET(::revolve::msgs::RobotStates, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::RobotStates, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::RobotStates, time_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::RobotStates, robot_state_), + 0, + ~0u, +}; +static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 9, sizeof(::revolve::msgs::RobotState)}, + { 13, 20, sizeof(::revolve::msgs::RobotStates)}, +}; + +static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { + reinterpret_cast(&::revolve::msgs::_RobotState_default_instance_), + reinterpret_cast(&::revolve::msgs::_RobotStates_default_instance_), +}; + +const char descriptor_table_protodef_robot_5fstates_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\022robot_states.proto\022\014revolve.msgs\032\ntime" + ".proto\032\npose.proto\"U\n\nRobotState\022\n\n\002id\030\001" + " \002(\r\022\014\n\004name\030\002 \002(\t\022\037\n\004pose\030\003 \002(\0132\021.gazeb" + "o.msgs.Pose\022\014\n\004dead\030\004 \001(\010\"]\n\013RobotStates" + "\022\037\n\004time\030\001 \002(\0132\021.gazebo.msgs.Time\022-\n\013rob" + "ot_state\030\002 \003(\0132\030.revolve.msgs.RobotState" + ; +static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_robot_5fstates_2eproto_deps[2] = { + &::descriptor_table_pose_2eproto, + &::descriptor_table_time_2eproto, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_robot_5fstates_2eproto_sccs[2] = { + &scc_info_RobotState_robot_5fstates_2eproto.base, + &scc_info_RobotStates_robot_5fstates_2eproto.base, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_robot_5fstates_2eproto_once; +const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_robot_5fstates_2eproto = { + false, false, descriptor_table_protodef_robot_5fstates_2eproto, "robot_states.proto", 240, + &descriptor_table_robot_5fstates_2eproto_once, descriptor_table_robot_5fstates_2eproto_sccs, descriptor_table_robot_5fstates_2eproto_deps, 2, 2, + schemas, file_default_instances, TableStruct_robot_5fstates_2eproto::offsets, + file_level_metadata_robot_5fstates_2eproto, 2, file_level_enum_descriptors_robot_5fstates_2eproto, file_level_service_descriptors_robot_5fstates_2eproto, +}; + +// Force running AddDescriptors() at dynamic initialization time. +static bool dynamic_init_dummy_robot_5fstates_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_robot_5fstates_2eproto)), true); +namespace revolve { +namespace msgs { + +// =================================================================== + +void RobotState::InitAsDefaultInstance() { + ::revolve::msgs::_RobotState_default_instance_._instance.get_mutable()->pose_ = const_cast< ::gazebo::msgs::Pose*>( + ::gazebo::msgs::Pose::internal_default_instance()); +} +class RobotState::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_id(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_name(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::gazebo::msgs::Pose& pose(const RobotState* msg); + static void set_has_pose(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_dead(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000007) ^ 0x00000007) != 0; + } +}; + +const ::gazebo::msgs::Pose& +RobotState::_Internal::pose(const RobotState* msg) { + return *msg->pose_; +} +void RobotState::clear_pose() { + if (pose_ != nullptr) pose_->Clear(); + _has_bits_[0] &= ~0x00000002u; +} +RobotState::RobotState(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.RobotState) +} +RobotState::RobotState(const RobotState& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_name()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), + GetArena()); + } + if (from._internal_has_pose()) { + pose_ = new ::gazebo::msgs::Pose(*from.pose_); + } else { + pose_ = nullptr; + } + ::memcpy(&id_, &from.id_, + static_cast(reinterpret_cast(&dead_) - + reinterpret_cast(&id_)) + sizeof(dead_)); + // @@protoc_insertion_point(copy_constructor:revolve.msgs.RobotState) +} + +void RobotState::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_RobotState_robot_5fstates_2eproto.base); + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + ::memset(&pose_, 0, static_cast( + reinterpret_cast(&dead_) - + reinterpret_cast(&pose_)) + sizeof(dead_)); +} + +RobotState::~RobotState() { + // @@protoc_insertion_point(destructor:revolve.msgs.RobotState) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void RobotState::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (this != internal_default_instance()) delete pose_; +} + +void RobotState::ArenaDtor(void* object) { + RobotState* _this = reinterpret_cast< RobotState* >(object); + (void)_this; +} +void RobotState::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void RobotState::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const RobotState& RobotState::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_RobotState_robot_5fstates_2eproto.base); + return *internal_default_instance(); +} + + +void RobotState::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.RobotState) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + name_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(pose_ != nullptr); + pose_->Clear(); + } + } + if (cached_has_bits & 0x0000000cu) { + ::memset(&id_, 0, static_cast( + reinterpret_cast(&dead_) - + reinterpret_cast(&id_)) + sizeof(dead_)); + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* RobotState::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required uint32 id = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + _Internal::set_has_id(&has_bits); + id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // required string name = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + auto str = _internal_mutable_name(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.RobotState.name"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required .gazebo.msgs.Pose pose = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { + ptr = ctx->ParseMessage(_internal_mutable_pose(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional bool dead = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { + _Internal::set_has_dead(&has_bits); + dead_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* RobotState::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.RobotState) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required uint32 id = 1; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt32ToArray(1, this->_internal_id(), target); + } + + // required string name = 2; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_name().data(), static_cast(this->_internal_name().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.RobotState.name"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_name(), target); + } + + // required .gazebo.msgs.Pose pose = 3; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 3, _Internal::pose(this), target, stream); + } + + // optional bool dead = 4; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(4, this->_internal_dead(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.RobotState) + return target; +} + +size_t RobotState::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:revolve.msgs.RobotState) + size_t total_size = 0; + + if (_internal_has_name()) { + // required string name = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + } + + if (_internal_has_pose()) { + // required .gazebo.msgs.Pose pose = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *pose_); + } + + if (_internal_has_id()) { + // required uint32 id = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt32Size( + this->_internal_id()); + } + + return total_size; +} +size_t RobotState::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.RobotState) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) { // All required fields are present. + // required string name = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + + // required .gazebo.msgs.Pose pose = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *pose_); + + // required uint32 id = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt32Size( + this->_internal_id()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // optional bool dead = 4; + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + 1; + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void RobotState::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.RobotState) + GOOGLE_DCHECK_NE(&from, this); + const RobotState* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.RobotState) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.RobotState) + MergeFrom(*source); + } +} + +void RobotState::MergeFrom(const RobotState& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.RobotState) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000001u) { + _internal_set_name(from._internal_name()); + } + if (cached_has_bits & 0x00000002u) { + _internal_mutable_pose()->::gazebo::msgs::Pose::MergeFrom(from._internal_pose()); + } + if (cached_has_bits & 0x00000004u) { + id_ = from.id_; + } + if (cached_has_bits & 0x00000008u) { + dead_ = from.dead_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void RobotState::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.RobotState) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void RobotState::CopyFrom(const RobotState& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.RobotState) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool RobotState::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_internal_has_pose()) { + if (!pose_->IsInitialized()) return false; + } + return true; +} + +void RobotState::InternalSwap(RobotState* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(RobotState, dead_) + + sizeof(RobotState::dead_) + - PROTOBUF_FIELD_OFFSET(RobotState, pose_)>( + reinterpret_cast(&pose_), + reinterpret_cast(&other->pose_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata RobotState::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void RobotStates::InitAsDefaultInstance() { + ::revolve::msgs::_RobotStates_default_instance_._instance.get_mutable()->time_ = const_cast< ::gazebo::msgs::Time*>( + ::gazebo::msgs::Time::internal_default_instance()); +} +class RobotStates::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static const ::gazebo::msgs::Time& time(const RobotStates* msg); + static void set_has_time(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; + } +}; + +const ::gazebo::msgs::Time& +RobotStates::_Internal::time(const RobotStates* msg) { + return *msg->time_; +} +void RobotStates::clear_time() { + if (time_ != nullptr) time_->Clear(); + _has_bits_[0] &= ~0x00000001u; +} +RobotStates::RobotStates(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + robot_state_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.RobotStates) +} +RobotStates::RobotStates(const RobotStates& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + robot_state_(from.robot_state_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_time()) { + time_ = new ::gazebo::msgs::Time(*from.time_); + } else { + time_ = nullptr; + } + // @@protoc_insertion_point(copy_constructor:revolve.msgs.RobotStates) +} + +void RobotStates::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_RobotStates_robot_5fstates_2eproto.base); + time_ = nullptr; +} + +RobotStates::~RobotStates() { + // @@protoc_insertion_point(destructor:revolve.msgs.RobotStates) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void RobotStates::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + if (this != internal_default_instance()) delete time_; +} + +void RobotStates::ArenaDtor(void* object) { + RobotStates* _this = reinterpret_cast< RobotStates* >(object); + (void)_this; +} +void RobotStates::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void RobotStates::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const RobotStates& RobotStates::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_RobotStates_robot_5fstates_2eproto.base); + return *internal_default_instance(); +} + + +void RobotStates::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.RobotStates) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + robot_state_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(time_ != nullptr); + time_->Clear(); + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* RobotStates::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required .gazebo.msgs.Time time = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_time(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated .revolve.msgs.RobotState robot_state = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_robot_state(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* RobotStates::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.RobotStates) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required .gazebo.msgs.Time time = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 1, _Internal::time(this), target, stream); + } + + // repeated .revolve.msgs.RobotState robot_state = 2; + for (unsigned int i = 0, + n = static_cast(this->_internal_robot_state_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, this->_internal_robot_state(i), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.RobotStates) + return target; +} + +size_t RobotStates::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.RobotStates) + size_t total_size = 0; + + // required .gazebo.msgs.Time time = 1; + if (_internal_has_time()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *time_); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .revolve.msgs.RobotState robot_state = 2; + total_size += 1UL * this->_internal_robot_state_size(); + for (const auto& msg : this->robot_state_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void RobotStates::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.RobotStates) + GOOGLE_DCHECK_NE(&from, this); + const RobotStates* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.RobotStates) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.RobotStates) + MergeFrom(*source); + } +} + +void RobotStates::MergeFrom(const RobotStates& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.RobotStates) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + robot_state_.MergeFrom(from.robot_state_); + if (from._internal_has_time()) { + _internal_mutable_time()->::gazebo::msgs::Time::MergeFrom(from._internal_time()); + } +} + +void RobotStates::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.RobotStates) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void RobotStates::CopyFrom(const RobotStates& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.RobotStates) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool RobotStates::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(robot_state_)) return false; + if (_internal_has_time()) { + if (!time_->IsInitialized()) return false; + } + return true; +} + +void RobotStates::InternalSwap(RobotStates* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + robot_state_.InternalSwap(&other->robot_state_); + swap(time_, other->time_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata RobotStates::GetMetadata() const { + return GetMetadataStatic(); +} + + +// @@protoc_insertion_point(namespace_scope) +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::revolve::msgs::RobotState* Arena::CreateMaybeMessage< ::revolve::msgs::RobotState >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::RobotState >(arena); +} +template<> PROTOBUF_NOINLINE ::revolve::msgs::RobotStates* Arena::CreateMaybeMessage< ::revolve::msgs::RobotStates >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::RobotStates >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/robot_states.pb.h b/cpprevolve/revolve/gazebo/revolve/msgs/robot_states.pb.h new file mode 100644 index 0000000000..6090cfc836 --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/robot_states.pb.h @@ -0,0 +1,815 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: robot_states.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_robot_5fstates_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_robot_5fstates_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3013000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3013000 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include "time.pb.h" +#include "pose.pb.h" +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_robot_5fstates_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_robot_5fstates_2eproto { + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[2] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; + static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; + static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_robot_5fstates_2eproto; +namespace revolve { +namespace msgs { +class RobotState; +class RobotStateDefaultTypeInternal; +extern RobotStateDefaultTypeInternal _RobotState_default_instance_; +class RobotStates; +class RobotStatesDefaultTypeInternal; +extern RobotStatesDefaultTypeInternal _RobotStates_default_instance_; +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> ::revolve::msgs::RobotState* Arena::CreateMaybeMessage<::revolve::msgs::RobotState>(Arena*); +template<> ::revolve::msgs::RobotStates* Arena::CreateMaybeMessage<::revolve::msgs::RobotStates>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace revolve { +namespace msgs { + +// =================================================================== + +class RobotState PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.RobotState) */ { + public: + inline RobotState() : RobotState(nullptr) {} + virtual ~RobotState(); + + RobotState(const RobotState& from); + RobotState(RobotState&& from) noexcept + : RobotState() { + *this = ::std::move(from); + } + + inline RobotState& operator=(const RobotState& from) { + CopyFrom(from); + return *this; + } + inline RobotState& operator=(RobotState&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const RobotState& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const RobotState* internal_default_instance() { + return reinterpret_cast( + &_RobotState_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(RobotState& a, RobotState& b) { + a.Swap(&b); + } + inline void Swap(RobotState* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(RobotState* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline RobotState* New() const final { + return CreateMaybeMessage(nullptr); + } + + RobotState* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const RobotState& from); + void MergeFrom(const RobotState& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(RobotState* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.RobotState"; + } + protected: + explicit RobotState(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_robot_5fstates_2eproto); + return ::descriptor_table_robot_5fstates_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kNameFieldNumber = 2, + kPoseFieldNumber = 3, + kIdFieldNumber = 1, + kDeadFieldNumber = 4, + }; + // required string name = 2; + bool has_name() const; + private: + bool _internal_has_name() const; + public: + void clear_name(); + const std::string& name() const; + void set_name(const std::string& value); + void set_name(std::string&& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + std::string* mutable_name(); + std::string* release_name(); + void set_allocated_name(std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: + + // required .gazebo.msgs.Pose pose = 3; + bool has_pose() const; + private: + bool _internal_has_pose() const; + public: + void clear_pose(); + const ::gazebo::msgs::Pose& pose() const; + ::gazebo::msgs::Pose* release_pose(); + ::gazebo::msgs::Pose* mutable_pose(); + void set_allocated_pose(::gazebo::msgs::Pose* pose); + private: + const ::gazebo::msgs::Pose& _internal_pose() const; + ::gazebo::msgs::Pose* _internal_mutable_pose(); + public: + void unsafe_arena_set_allocated_pose( + ::gazebo::msgs::Pose* pose); + ::gazebo::msgs::Pose* unsafe_arena_release_pose(); + + // required uint32 id = 1; + bool has_id() const; + private: + bool _internal_has_id() const; + public: + void clear_id(); + ::PROTOBUF_NAMESPACE_ID::uint32 id() const; + void set_id(::PROTOBUF_NAMESPACE_ID::uint32 value); + private: + ::PROTOBUF_NAMESPACE_ID::uint32 _internal_id() const; + void _internal_set_id(::PROTOBUF_NAMESPACE_ID::uint32 value); + public: + + // optional bool dead = 4; + bool has_dead() const; + private: + bool _internal_has_dead() const; + public: + void clear_dead(); + bool dead() const; + void set_dead(bool value); + private: + bool _internal_dead() const; + void _internal_set_dead(bool value); + public: + + // @@protoc_insertion_point(class_scope:revolve.msgs.RobotState) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::gazebo::msgs::Pose* pose_; + ::PROTOBUF_NAMESPACE_ID::uint32 id_; + bool dead_; + friend struct ::TableStruct_robot_5fstates_2eproto; +}; +// ------------------------------------------------------------------- + +class RobotStates PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.RobotStates) */ { + public: + inline RobotStates() : RobotStates(nullptr) {} + virtual ~RobotStates(); + + RobotStates(const RobotStates& from); + RobotStates(RobotStates&& from) noexcept + : RobotStates() { + *this = ::std::move(from); + } + + inline RobotStates& operator=(const RobotStates& from) { + CopyFrom(from); + return *this; + } + inline RobotStates& operator=(RobotStates&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const RobotStates& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const RobotStates* internal_default_instance() { + return reinterpret_cast( + &_RobotStates_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(RobotStates& a, RobotStates& b) { + a.Swap(&b); + } + inline void Swap(RobotStates* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(RobotStates* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline RobotStates* New() const final { + return CreateMaybeMessage(nullptr); + } + + RobotStates* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const RobotStates& from); + void MergeFrom(const RobotStates& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(RobotStates* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.RobotStates"; + } + protected: + explicit RobotStates(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_robot_5fstates_2eproto); + return ::descriptor_table_robot_5fstates_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kRobotStateFieldNumber = 2, + kTimeFieldNumber = 1, + }; + // repeated .revolve.msgs.RobotState robot_state = 2; + int robot_state_size() const; + private: + int _internal_robot_state_size() const; + public: + void clear_robot_state(); + ::revolve::msgs::RobotState* mutable_robot_state(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::RobotState >* + mutable_robot_state(); + private: + const ::revolve::msgs::RobotState& _internal_robot_state(int index) const; + ::revolve::msgs::RobotState* _internal_add_robot_state(); + public: + const ::revolve::msgs::RobotState& robot_state(int index) const; + ::revolve::msgs::RobotState* add_robot_state(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::RobotState >& + robot_state() const; + + // required .gazebo.msgs.Time time = 1; + bool has_time() const; + private: + bool _internal_has_time() const; + public: + void clear_time(); + const ::gazebo::msgs::Time& time() const; + ::gazebo::msgs::Time* release_time(); + ::gazebo::msgs::Time* mutable_time(); + void set_allocated_time(::gazebo::msgs::Time* time); + private: + const ::gazebo::msgs::Time& _internal_time() const; + ::gazebo::msgs::Time* _internal_mutable_time(); + public: + void unsafe_arena_set_allocated_time( + ::gazebo::msgs::Time* time); + ::gazebo::msgs::Time* unsafe_arena_release_time(); + + // @@protoc_insertion_point(class_scope:revolve.msgs.RobotStates) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::RobotState > robot_state_; + ::gazebo::msgs::Time* time_; + friend struct ::TableStruct_robot_5fstates_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// RobotState + +// required uint32 id = 1; +inline bool RobotState::_internal_has_id() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool RobotState::has_id() const { + return _internal_has_id(); +} +inline void RobotState::clear_id() { + id_ = 0u; + _has_bits_[0] &= ~0x00000004u; +} +inline ::PROTOBUF_NAMESPACE_ID::uint32 RobotState::_internal_id() const { + return id_; +} +inline ::PROTOBUF_NAMESPACE_ID::uint32 RobotState::id() const { + // @@protoc_insertion_point(field_get:revolve.msgs.RobotState.id) + return _internal_id(); +} +inline void RobotState::_internal_set_id(::PROTOBUF_NAMESPACE_ID::uint32 value) { + _has_bits_[0] |= 0x00000004u; + id_ = value; +} +inline void RobotState::set_id(::PROTOBUF_NAMESPACE_ID::uint32 value) { + _internal_set_id(value); + // @@protoc_insertion_point(field_set:revolve.msgs.RobotState.id) +} + +// required string name = 2; +inline bool RobotState::_internal_has_name() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool RobotState::has_name() const { + return _internal_has_name(); +} +inline void RobotState::clear_name() { + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& RobotState::name() const { + // @@protoc_insertion_point(field_get:revolve.msgs.RobotState.name) + return _internal_name(); +} +inline void RobotState::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:revolve.msgs.RobotState.name) +} +inline std::string* RobotState::mutable_name() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.RobotState.name) + return _internal_mutable_name(); +} +inline const std::string& RobotState::_internal_name() const { + return name_.Get(); +} +inline void RobotState::_internal_set_name(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void RobotState::set_name(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.RobotState.name) +} +inline void RobotState::set_name(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.RobotState.name) +} +inline void RobotState::set_name(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.RobotState.name) +} +inline std::string* RobotState::_internal_mutable_name() { + _has_bits_[0] |= 0x00000001u; + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* RobotState::release_name() { + // @@protoc_insertion_point(field_release:revolve.msgs.RobotState.name) + if (!_internal_has_name()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void RobotState::set_allocated_name(std::string* name) { + if (name != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.RobotState.name) +} + +// required .gazebo.msgs.Pose pose = 3; +inline bool RobotState::_internal_has_pose() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || pose_ != nullptr); + return value; +} +inline bool RobotState::has_pose() const { + return _internal_has_pose(); +} +inline const ::gazebo::msgs::Pose& RobotState::_internal_pose() const { + const ::gazebo::msgs::Pose* p = pose_; + return p != nullptr ? *p : *reinterpret_cast( + &::gazebo::msgs::_Pose_default_instance_); +} +inline const ::gazebo::msgs::Pose& RobotState::pose() const { + // @@protoc_insertion_point(field_get:revolve.msgs.RobotState.pose) + return _internal_pose(); +} +inline void RobotState::unsafe_arena_set_allocated_pose( + ::gazebo::msgs::Pose* pose) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(pose_); + } + pose_ = pose; + if (pose) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:revolve.msgs.RobotState.pose) +} +inline ::gazebo::msgs::Pose* RobotState::release_pose() { + _has_bits_[0] &= ~0x00000002u; + ::gazebo::msgs::Pose* temp = pose_; + pose_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::gazebo::msgs::Pose* RobotState::unsafe_arena_release_pose() { + // @@protoc_insertion_point(field_release:revolve.msgs.RobotState.pose) + _has_bits_[0] &= ~0x00000002u; + ::gazebo::msgs::Pose* temp = pose_; + pose_ = nullptr; + return temp; +} +inline ::gazebo::msgs::Pose* RobotState::_internal_mutable_pose() { + _has_bits_[0] |= 0x00000002u; + if (pose_ == nullptr) { + auto* p = CreateMaybeMessage<::gazebo::msgs::Pose>(GetArena()); + pose_ = p; + } + return pose_; +} +inline ::gazebo::msgs::Pose* RobotState::mutable_pose() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.RobotState.pose) + return _internal_mutable_pose(); +} +inline void RobotState::set_allocated_pose(::gazebo::msgs::Pose* pose) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(pose_); + } + if (pose) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(pose)->GetArena(); + if (message_arena != submessage_arena) { + pose = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, pose, submessage_arena); + } + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + pose_ = pose; + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.RobotState.pose) +} + +// optional bool dead = 4; +inline bool RobotState::_internal_has_dead() const { + bool value = (_has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool RobotState::has_dead() const { + return _internal_has_dead(); +} +inline void RobotState::clear_dead() { + dead_ = false; + _has_bits_[0] &= ~0x00000008u; +} +inline bool RobotState::_internal_dead() const { + return dead_; +} +inline bool RobotState::dead() const { + // @@protoc_insertion_point(field_get:revolve.msgs.RobotState.dead) + return _internal_dead(); +} +inline void RobotState::_internal_set_dead(bool value) { + _has_bits_[0] |= 0x00000008u; + dead_ = value; +} +inline void RobotState::set_dead(bool value) { + _internal_set_dead(value); + // @@protoc_insertion_point(field_set:revolve.msgs.RobotState.dead) +} + +// ------------------------------------------------------------------- + +// RobotStates + +// required .gazebo.msgs.Time time = 1; +inline bool RobotStates::_internal_has_time() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || time_ != nullptr); + return value; +} +inline bool RobotStates::has_time() const { + return _internal_has_time(); +} +inline const ::gazebo::msgs::Time& RobotStates::_internal_time() const { + const ::gazebo::msgs::Time* p = time_; + return p != nullptr ? *p : *reinterpret_cast( + &::gazebo::msgs::_Time_default_instance_); +} +inline const ::gazebo::msgs::Time& RobotStates::time() const { + // @@protoc_insertion_point(field_get:revolve.msgs.RobotStates.time) + return _internal_time(); +} +inline void RobotStates::unsafe_arena_set_allocated_time( + ::gazebo::msgs::Time* time) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(time_); + } + time_ = time; + if (time) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:revolve.msgs.RobotStates.time) +} +inline ::gazebo::msgs::Time* RobotStates::release_time() { + _has_bits_[0] &= ~0x00000001u; + ::gazebo::msgs::Time* temp = time_; + time_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::gazebo::msgs::Time* RobotStates::unsafe_arena_release_time() { + // @@protoc_insertion_point(field_release:revolve.msgs.RobotStates.time) + _has_bits_[0] &= ~0x00000001u; + ::gazebo::msgs::Time* temp = time_; + time_ = nullptr; + return temp; +} +inline ::gazebo::msgs::Time* RobotStates::_internal_mutable_time() { + _has_bits_[0] |= 0x00000001u; + if (time_ == nullptr) { + auto* p = CreateMaybeMessage<::gazebo::msgs::Time>(GetArena()); + time_ = p; + } + return time_; +} +inline ::gazebo::msgs::Time* RobotStates::mutable_time() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.RobotStates.time) + return _internal_mutable_time(); +} +inline void RobotStates::set_allocated_time(::gazebo::msgs::Time* time) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(time_); + } + if (time) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(time)->GetArena(); + if (message_arena != submessage_arena) { + time = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, time, submessage_arena); + } + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + time_ = time; + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.RobotStates.time) +} + +// repeated .revolve.msgs.RobotState robot_state = 2; +inline int RobotStates::_internal_robot_state_size() const { + return robot_state_.size(); +} +inline int RobotStates::robot_state_size() const { + return _internal_robot_state_size(); +} +inline void RobotStates::clear_robot_state() { + robot_state_.Clear(); +} +inline ::revolve::msgs::RobotState* RobotStates::mutable_robot_state(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.RobotStates.robot_state) + return robot_state_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::RobotState >* +RobotStates::mutable_robot_state() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.RobotStates.robot_state) + return &robot_state_; +} +inline const ::revolve::msgs::RobotState& RobotStates::_internal_robot_state(int index) const { + return robot_state_.Get(index); +} +inline const ::revolve::msgs::RobotState& RobotStates::robot_state(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.RobotStates.robot_state) + return _internal_robot_state(index); +} +inline ::revolve::msgs::RobotState* RobotStates::_internal_add_robot_state() { + return robot_state_.Add(); +} +inline ::revolve::msgs::RobotState* RobotStates::add_robot_state() { + // @@protoc_insertion_point(field_add:revolve.msgs.RobotStates.robot_state) + return _internal_add_robot_state(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::RobotState >& +RobotStates::robot_state() const { + // @@protoc_insertion_point(field_list:revolve.msgs.RobotStates.robot_state) + return robot_state_; +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace msgs +} // namespace revolve + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_robot_5fstates_2eproto diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/sdf_body_analyze.pb.cc b/cpprevolve/revolve/gazebo/revolve/msgs/sdf_body_analyze.pb.cc new file mode 100644 index 0000000000..19536131f3 --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/sdf_body_analyze.pb.cc @@ -0,0 +1,1055 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: sdf_body_analyze.proto + +#include "sdf_body_analyze.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include +extern PROTOBUF_INTERNAL_EXPORT_vector3d_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Vector3d_vector3d_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_sdf_5fbody_5fanalyze_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_BoundingBox_sdf_5fbody_5fanalyze_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_sdf_5fbody_5fanalyze_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Contact_sdf_5fbody_5fanalyze_2eproto; +namespace revolve { +namespace msgs { +class ContactDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _Contact_default_instance_; +class BoundingBoxDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _BoundingBox_default_instance_; +class BodyAnalysisResponseDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _BodyAnalysisResponse_default_instance_; +} // namespace msgs +} // namespace revolve +static void InitDefaultsscc_info_BodyAnalysisResponse_sdf_5fbody_5fanalyze_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_BodyAnalysisResponse_default_instance_; + new (ptr) ::revolve::msgs::BodyAnalysisResponse(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::BodyAnalysisResponse::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_BodyAnalysisResponse_sdf_5fbody_5fanalyze_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_BodyAnalysisResponse_sdf_5fbody_5fanalyze_2eproto}, { + &scc_info_BoundingBox_sdf_5fbody_5fanalyze_2eproto.base, + &scc_info_Contact_sdf_5fbody_5fanalyze_2eproto.base,}}; + +static void InitDefaultsscc_info_BoundingBox_sdf_5fbody_5fanalyze_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_BoundingBox_default_instance_; + new (ptr) ::revolve::msgs::BoundingBox(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::BoundingBox::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_BoundingBox_sdf_5fbody_5fanalyze_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_BoundingBox_sdf_5fbody_5fanalyze_2eproto}, { + &scc_info_Vector3d_vector3d_2eproto.base,}}; + +static void InitDefaultsscc_info_Contact_sdf_5fbody_5fanalyze_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_Contact_default_instance_; + new (ptr) ::revolve::msgs::Contact(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::Contact::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Contact_sdf_5fbody_5fanalyze_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Contact_sdf_5fbody_5fanalyze_2eproto}, {}}; + +static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_sdf_5fbody_5fanalyze_2eproto[3]; +static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_sdf_5fbody_5fanalyze_2eproto = nullptr; +static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_sdf_5fbody_5fanalyze_2eproto = nullptr; + +const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_sdf_5fbody_5fanalyze_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Contact, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Contact, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Contact, collision1_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Contact, collision2_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BoundingBox, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BoundingBox, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BoundingBox, min_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BoundingBox, max_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyAnalysisResponse, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyAnalysisResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyAnalysisResponse, boundingbox_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::BodyAnalysisResponse, contact_), + 0, + ~0u, +}; +static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 7, sizeof(::revolve::msgs::Contact)}, + { 9, 16, sizeof(::revolve::msgs::BoundingBox)}, + { 18, 25, sizeof(::revolve::msgs::BodyAnalysisResponse)}, +}; + +static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { + reinterpret_cast(&::revolve::msgs::_Contact_default_instance_), + reinterpret_cast(&::revolve::msgs::_BoundingBox_default_instance_), + reinterpret_cast(&::revolve::msgs::_BodyAnalysisResponse_default_instance_), +}; + +const char descriptor_table_protodef_sdf_5fbody_5fanalyze_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\026sdf_body_analyze.proto\022\014revolve.msgs\032\016" + "vector3d.proto\"1\n\007Contact\022\022\n\ncollision1\030" + "\001 \002(\t\022\022\n\ncollision2\030\002 \002(\t\"U\n\013BoundingBox" + "\022\"\n\003min\030\001 \002(\0132\025.gazebo.msgs.Vector3d\022\"\n\003" + "max\030\002 \002(\0132\025.gazebo.msgs.Vector3d\"n\n\024Body" + "AnalysisResponse\022.\n\013boundingBox\030\001 \001(\0132\031." + "revolve.msgs.BoundingBox\022&\n\007contact\030\002 \003(" + "\0132\025.revolve.msgs.Contact" + ; +static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_sdf_5fbody_5fanalyze_2eproto_deps[1] = { + &::descriptor_table_vector3d_2eproto, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_sdf_5fbody_5fanalyze_2eproto_sccs[3] = { + &scc_info_BodyAnalysisResponse_sdf_5fbody_5fanalyze_2eproto.base, + &scc_info_BoundingBox_sdf_5fbody_5fanalyze_2eproto.base, + &scc_info_Contact_sdf_5fbody_5fanalyze_2eproto.base, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_sdf_5fbody_5fanalyze_2eproto_once; +const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_sdf_5fbody_5fanalyze_2eproto = { + false, false, descriptor_table_protodef_sdf_5fbody_5fanalyze_2eproto, "sdf_body_analyze.proto", 304, + &descriptor_table_sdf_5fbody_5fanalyze_2eproto_once, descriptor_table_sdf_5fbody_5fanalyze_2eproto_sccs, descriptor_table_sdf_5fbody_5fanalyze_2eproto_deps, 3, 1, + schemas, file_default_instances, TableStruct_sdf_5fbody_5fanalyze_2eproto::offsets, + file_level_metadata_sdf_5fbody_5fanalyze_2eproto, 3, file_level_enum_descriptors_sdf_5fbody_5fanalyze_2eproto, file_level_service_descriptors_sdf_5fbody_5fanalyze_2eproto, +}; + +// Force running AddDescriptors() at dynamic initialization time. +static bool dynamic_init_dummy_sdf_5fbody_5fanalyze_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_sdf_5fbody_5fanalyze_2eproto)), true); +namespace revolve { +namespace msgs { + +// =================================================================== + +void Contact::InitAsDefaultInstance() { +} +class Contact::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_collision1(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_collision2(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +Contact::Contact(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.Contact) +} +Contact::Contact(const Contact& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + collision1_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_collision1()) { + collision1_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_collision1(), + GetArena()); + } + collision2_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_collision2()) { + collision2_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_collision2(), + GetArena()); + } + // @@protoc_insertion_point(copy_constructor:revolve.msgs.Contact) +} + +void Contact::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Contact_sdf_5fbody_5fanalyze_2eproto.base); + collision1_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + collision2_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +Contact::~Contact() { + // @@protoc_insertion_point(destructor:revolve.msgs.Contact) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void Contact::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + collision1_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + collision2_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void Contact::ArenaDtor(void* object) { + Contact* _this = reinterpret_cast< Contact* >(object); + (void)_this; +} +void Contact::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void Contact::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const Contact& Contact::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Contact_sdf_5fbody_5fanalyze_2eproto.base); + return *internal_default_instance(); +} + + +void Contact::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.Contact) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + collision1_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + collision2_.ClearNonDefaultToEmpty(); + } + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Contact::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required string collision1 = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_collision1(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.Contact.collision1"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required string collision2 = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + auto str = _internal_mutable_collision2(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.Contact.collision2"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* Contact::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.Contact) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required string collision1 = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_collision1().data(), static_cast(this->_internal_collision1().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.Contact.collision1"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_collision1(), target); + } + + // required string collision2 = 2; + if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_collision2().data(), static_cast(this->_internal_collision2().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.Contact.collision2"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_collision2(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.Contact) + return target; +} + +size_t Contact::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:revolve.msgs.Contact) + size_t total_size = 0; + + if (_internal_has_collision1()) { + // required string collision1 = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_collision1()); + } + + if (_internal_has_collision2()) { + // required string collision2 = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_collision2()); + } + + return total_size; +} +size_t Contact::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.Contact) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required string collision1 = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_collision1()); + + // required string collision2 = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_collision2()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void Contact::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.Contact) + GOOGLE_DCHECK_NE(&from, this); + const Contact* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.Contact) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.Contact) + MergeFrom(*source); + } +} + +void Contact::MergeFrom(const Contact& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.Contact) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _internal_set_collision1(from._internal_collision1()); + } + if (cached_has_bits & 0x00000002u) { + _internal_set_collision2(from._internal_collision2()); + } + } +} + +void Contact::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.Contact) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Contact::CopyFrom(const Contact& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.Contact) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Contact::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + return true; +} + +void Contact::InternalSwap(Contact* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + collision1_.Swap(&other->collision1_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + collision2_.Swap(&other->collision2_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Contact::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void BoundingBox::InitAsDefaultInstance() { + ::revolve::msgs::_BoundingBox_default_instance_._instance.get_mutable()->min_ = const_cast< ::gazebo::msgs::Vector3d*>( + ::gazebo::msgs::Vector3d::internal_default_instance()); + ::revolve::msgs::_BoundingBox_default_instance_._instance.get_mutable()->max_ = const_cast< ::gazebo::msgs::Vector3d*>( + ::gazebo::msgs::Vector3d::internal_default_instance()); +} +class BoundingBox::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static const ::gazebo::msgs::Vector3d& min(const BoundingBox* msg); + static void set_has_min(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::gazebo::msgs::Vector3d& max(const BoundingBox* msg); + static void set_has_max(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +const ::gazebo::msgs::Vector3d& +BoundingBox::_Internal::min(const BoundingBox* msg) { + return *msg->min_; +} +const ::gazebo::msgs::Vector3d& +BoundingBox::_Internal::max(const BoundingBox* msg) { + return *msg->max_; +} +void BoundingBox::clear_min() { + if (min_ != nullptr) min_->Clear(); + _has_bits_[0] &= ~0x00000001u; +} +void BoundingBox::clear_max() { + if (max_ != nullptr) max_->Clear(); + _has_bits_[0] &= ~0x00000002u; +} +BoundingBox::BoundingBox(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.BoundingBox) +} +BoundingBox::BoundingBox(const BoundingBox& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_min()) { + min_ = new ::gazebo::msgs::Vector3d(*from.min_); + } else { + min_ = nullptr; + } + if (from._internal_has_max()) { + max_ = new ::gazebo::msgs::Vector3d(*from.max_); + } else { + max_ = nullptr; + } + // @@protoc_insertion_point(copy_constructor:revolve.msgs.BoundingBox) +} + +void BoundingBox::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_BoundingBox_sdf_5fbody_5fanalyze_2eproto.base); + ::memset(&min_, 0, static_cast( + reinterpret_cast(&max_) - + reinterpret_cast(&min_)) + sizeof(max_)); +} + +BoundingBox::~BoundingBox() { + // @@protoc_insertion_point(destructor:revolve.msgs.BoundingBox) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void BoundingBox::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + if (this != internal_default_instance()) delete min_; + if (this != internal_default_instance()) delete max_; +} + +void BoundingBox::ArenaDtor(void* object) { + BoundingBox* _this = reinterpret_cast< BoundingBox* >(object); + (void)_this; +} +void BoundingBox::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void BoundingBox::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const BoundingBox& BoundingBox::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_BoundingBox_sdf_5fbody_5fanalyze_2eproto.base); + return *internal_default_instance(); +} + + +void BoundingBox::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.BoundingBox) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(min_ != nullptr); + min_->Clear(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(max_ != nullptr); + max_->Clear(); + } + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* BoundingBox::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required .gazebo.msgs.Vector3d min = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_min(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // required .gazebo.msgs.Vector3d max = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr = ctx->ParseMessage(_internal_mutable_max(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* BoundingBox::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.BoundingBox) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required .gazebo.msgs.Vector3d min = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 1, _Internal::min(this), target, stream); + } + + // required .gazebo.msgs.Vector3d max = 2; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 2, _Internal::max(this), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.BoundingBox) + return target; +} + +size_t BoundingBox::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:revolve.msgs.BoundingBox) + size_t total_size = 0; + + if (_internal_has_min()) { + // required .gazebo.msgs.Vector3d min = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *min_); + } + + if (_internal_has_max()) { + // required .gazebo.msgs.Vector3d max = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *max_); + } + + return total_size; +} +size_t BoundingBox::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.BoundingBox) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required .gazebo.msgs.Vector3d min = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *min_); + + // required .gazebo.msgs.Vector3d max = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *max_); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void BoundingBox::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.BoundingBox) + GOOGLE_DCHECK_NE(&from, this); + const BoundingBox* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.BoundingBox) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.BoundingBox) + MergeFrom(*source); + } +} + +void BoundingBox::MergeFrom(const BoundingBox& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.BoundingBox) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _internal_mutable_min()->::gazebo::msgs::Vector3d::MergeFrom(from._internal_min()); + } + if (cached_has_bits & 0x00000002u) { + _internal_mutable_max()->::gazebo::msgs::Vector3d::MergeFrom(from._internal_max()); + } + } +} + +void BoundingBox::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.BoundingBox) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void BoundingBox::CopyFrom(const BoundingBox& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.BoundingBox) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool BoundingBox::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_internal_has_min()) { + if (!min_->IsInitialized()) return false; + } + if (_internal_has_max()) { + if (!max_->IsInitialized()) return false; + } + return true; +} + +void BoundingBox::InternalSwap(BoundingBox* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(BoundingBox, max_) + + sizeof(BoundingBox::max_) + - PROTOBUF_FIELD_OFFSET(BoundingBox, min_)>( + reinterpret_cast(&min_), + reinterpret_cast(&other->min_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata BoundingBox::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void BodyAnalysisResponse::InitAsDefaultInstance() { + ::revolve::msgs::_BodyAnalysisResponse_default_instance_._instance.get_mutable()->boundingbox_ = const_cast< ::revolve::msgs::BoundingBox*>( + ::revolve::msgs::BoundingBox::internal_default_instance()); +} +class BodyAnalysisResponse::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static const ::revolve::msgs::BoundingBox& boundingbox(const BodyAnalysisResponse* msg); + static void set_has_boundingbox(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } +}; + +const ::revolve::msgs::BoundingBox& +BodyAnalysisResponse::_Internal::boundingbox(const BodyAnalysisResponse* msg) { + return *msg->boundingbox_; +} +BodyAnalysisResponse::BodyAnalysisResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + contact_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.BodyAnalysisResponse) +} +BodyAnalysisResponse::BodyAnalysisResponse(const BodyAnalysisResponse& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + contact_(from.contact_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_boundingbox()) { + boundingbox_ = new ::revolve::msgs::BoundingBox(*from.boundingbox_); + } else { + boundingbox_ = nullptr; + } + // @@protoc_insertion_point(copy_constructor:revolve.msgs.BodyAnalysisResponse) +} + +void BodyAnalysisResponse::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_BodyAnalysisResponse_sdf_5fbody_5fanalyze_2eproto.base); + boundingbox_ = nullptr; +} + +BodyAnalysisResponse::~BodyAnalysisResponse() { + // @@protoc_insertion_point(destructor:revolve.msgs.BodyAnalysisResponse) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void BodyAnalysisResponse::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + if (this != internal_default_instance()) delete boundingbox_; +} + +void BodyAnalysisResponse::ArenaDtor(void* object) { + BodyAnalysisResponse* _this = reinterpret_cast< BodyAnalysisResponse* >(object); + (void)_this; +} +void BodyAnalysisResponse::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void BodyAnalysisResponse::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const BodyAnalysisResponse& BodyAnalysisResponse::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_BodyAnalysisResponse_sdf_5fbody_5fanalyze_2eproto.base); + return *internal_default_instance(); +} + + +void BodyAnalysisResponse::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.BodyAnalysisResponse) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + contact_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(boundingbox_ != nullptr); + boundingbox_->Clear(); + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* BodyAnalysisResponse::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // optional .revolve.msgs.BoundingBox boundingBox = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_boundingbox(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated .revolve.msgs.Contact contact = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_contact(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* BodyAnalysisResponse::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.BodyAnalysisResponse) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // optional .revolve.msgs.BoundingBox boundingBox = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 1, _Internal::boundingbox(this), target, stream); + } + + // repeated .revolve.msgs.Contact contact = 2; + for (unsigned int i = 0, + n = static_cast(this->_internal_contact_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, this->_internal_contact(i), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.BodyAnalysisResponse) + return target; +} + +size_t BodyAnalysisResponse::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.BodyAnalysisResponse) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .revolve.msgs.Contact contact = 2; + total_size += 1UL * this->_internal_contact_size(); + for (const auto& msg : this->contact_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // optional .revolve.msgs.BoundingBox boundingBox = 1; + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *boundingbox_); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void BodyAnalysisResponse::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.BodyAnalysisResponse) + GOOGLE_DCHECK_NE(&from, this); + const BodyAnalysisResponse* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.BodyAnalysisResponse) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.BodyAnalysisResponse) + MergeFrom(*source); + } +} + +void BodyAnalysisResponse::MergeFrom(const BodyAnalysisResponse& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.BodyAnalysisResponse) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + contact_.MergeFrom(from.contact_); + if (from._internal_has_boundingbox()) { + _internal_mutable_boundingbox()->::revolve::msgs::BoundingBox::MergeFrom(from._internal_boundingbox()); + } +} + +void BodyAnalysisResponse::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.BodyAnalysisResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void BodyAnalysisResponse::CopyFrom(const BodyAnalysisResponse& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.BodyAnalysisResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool BodyAnalysisResponse::IsInitialized() const { + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(contact_)) return false; + if (_internal_has_boundingbox()) { + if (!boundingbox_->IsInitialized()) return false; + } + return true; +} + +void BodyAnalysisResponse::InternalSwap(BodyAnalysisResponse* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + contact_.InternalSwap(&other->contact_); + swap(boundingbox_, other->boundingbox_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata BodyAnalysisResponse::GetMetadata() const { + return GetMetadataStatic(); +} + + +// @@protoc_insertion_point(namespace_scope) +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::revolve::msgs::Contact* Arena::CreateMaybeMessage< ::revolve::msgs::Contact >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::Contact >(arena); +} +template<> PROTOBUF_NOINLINE ::revolve::msgs::BoundingBox* Arena::CreateMaybeMessage< ::revolve::msgs::BoundingBox >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::BoundingBox >(arena); +} +template<> PROTOBUF_NOINLINE ::revolve::msgs::BodyAnalysisResponse* Arena::CreateMaybeMessage< ::revolve::msgs::BodyAnalysisResponse >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::BodyAnalysisResponse >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/sdf_body_analyze.pb.h b/cpprevolve/revolve/gazebo/revolve/msgs/sdf_body_analyze.pb.h new file mode 100644 index 0000000000..35a3bfb00d --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/sdf_body_analyze.pb.h @@ -0,0 +1,1074 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: sdf_body_analyze.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_sdf_5fbody_5fanalyze_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_sdf_5fbody_5fanalyze_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3013000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3013000 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include "vector3d.pb.h" +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_sdf_5fbody_5fanalyze_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_sdf_5fbody_5fanalyze_2eproto { + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[3] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; + static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; + static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_sdf_5fbody_5fanalyze_2eproto; +namespace revolve { +namespace msgs { +class BodyAnalysisResponse; +class BodyAnalysisResponseDefaultTypeInternal; +extern BodyAnalysisResponseDefaultTypeInternal _BodyAnalysisResponse_default_instance_; +class BoundingBox; +class BoundingBoxDefaultTypeInternal; +extern BoundingBoxDefaultTypeInternal _BoundingBox_default_instance_; +class Contact; +class ContactDefaultTypeInternal; +extern ContactDefaultTypeInternal _Contact_default_instance_; +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> ::revolve::msgs::BodyAnalysisResponse* Arena::CreateMaybeMessage<::revolve::msgs::BodyAnalysisResponse>(Arena*); +template<> ::revolve::msgs::BoundingBox* Arena::CreateMaybeMessage<::revolve::msgs::BoundingBox>(Arena*); +template<> ::revolve::msgs::Contact* Arena::CreateMaybeMessage<::revolve::msgs::Contact>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace revolve { +namespace msgs { + +// =================================================================== + +class Contact PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.Contact) */ { + public: + inline Contact() : Contact(nullptr) {} + virtual ~Contact(); + + Contact(const Contact& from); + Contact(Contact&& from) noexcept + : Contact() { + *this = ::std::move(from); + } + + inline Contact& operator=(const Contact& from) { + CopyFrom(from); + return *this; + } + inline Contact& operator=(Contact&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const Contact& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const Contact* internal_default_instance() { + return reinterpret_cast( + &_Contact_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Contact& a, Contact& b) { + a.Swap(&b); + } + inline void Swap(Contact* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Contact* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline Contact* New() const final { + return CreateMaybeMessage(nullptr); + } + + Contact* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const Contact& from); + void MergeFrom(const Contact& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Contact* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.Contact"; + } + protected: + explicit Contact(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_sdf_5fbody_5fanalyze_2eproto); + return ::descriptor_table_sdf_5fbody_5fanalyze_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kCollision1FieldNumber = 1, + kCollision2FieldNumber = 2, + }; + // required string collision1 = 1; + bool has_collision1() const; + private: + bool _internal_has_collision1() const; + public: + void clear_collision1(); + const std::string& collision1() const; + void set_collision1(const std::string& value); + void set_collision1(std::string&& value); + void set_collision1(const char* value); + void set_collision1(const char* value, size_t size); + std::string* mutable_collision1(); + std::string* release_collision1(); + void set_allocated_collision1(std::string* collision1); + private: + const std::string& _internal_collision1() const; + void _internal_set_collision1(const std::string& value); + std::string* _internal_mutable_collision1(); + public: + + // required string collision2 = 2; + bool has_collision2() const; + private: + bool _internal_has_collision2() const; + public: + void clear_collision2(); + const std::string& collision2() const; + void set_collision2(const std::string& value); + void set_collision2(std::string&& value); + void set_collision2(const char* value); + void set_collision2(const char* value, size_t size); + std::string* mutable_collision2(); + std::string* release_collision2(); + void set_allocated_collision2(std::string* collision2); + private: + const std::string& _internal_collision2() const; + void _internal_set_collision2(const std::string& value); + std::string* _internal_mutable_collision2(); + public: + + // @@protoc_insertion_point(class_scope:revolve.msgs.Contact) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr collision1_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr collision2_; + friend struct ::TableStruct_sdf_5fbody_5fanalyze_2eproto; +}; +// ------------------------------------------------------------------- + +class BoundingBox PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.BoundingBox) */ { + public: + inline BoundingBox() : BoundingBox(nullptr) {} + virtual ~BoundingBox(); + + BoundingBox(const BoundingBox& from); + BoundingBox(BoundingBox&& from) noexcept + : BoundingBox() { + *this = ::std::move(from); + } + + inline BoundingBox& operator=(const BoundingBox& from) { + CopyFrom(from); + return *this; + } + inline BoundingBox& operator=(BoundingBox&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const BoundingBox& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const BoundingBox* internal_default_instance() { + return reinterpret_cast( + &_BoundingBox_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(BoundingBox& a, BoundingBox& b) { + a.Swap(&b); + } + inline void Swap(BoundingBox* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(BoundingBox* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline BoundingBox* New() const final { + return CreateMaybeMessage(nullptr); + } + + BoundingBox* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const BoundingBox& from); + void MergeFrom(const BoundingBox& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(BoundingBox* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.BoundingBox"; + } + protected: + explicit BoundingBox(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_sdf_5fbody_5fanalyze_2eproto); + return ::descriptor_table_sdf_5fbody_5fanalyze_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kMinFieldNumber = 1, + kMaxFieldNumber = 2, + }; + // required .gazebo.msgs.Vector3d min = 1; + bool has_min() const; + private: + bool _internal_has_min() const; + public: + void clear_min(); + const ::gazebo::msgs::Vector3d& min() const; + ::gazebo::msgs::Vector3d* release_min(); + ::gazebo::msgs::Vector3d* mutable_min(); + void set_allocated_min(::gazebo::msgs::Vector3d* min); + private: + const ::gazebo::msgs::Vector3d& _internal_min() const; + ::gazebo::msgs::Vector3d* _internal_mutable_min(); + public: + void unsafe_arena_set_allocated_min( + ::gazebo::msgs::Vector3d* min); + ::gazebo::msgs::Vector3d* unsafe_arena_release_min(); + + // required .gazebo.msgs.Vector3d max = 2; + bool has_max() const; + private: + bool _internal_has_max() const; + public: + void clear_max(); + const ::gazebo::msgs::Vector3d& max() const; + ::gazebo::msgs::Vector3d* release_max(); + ::gazebo::msgs::Vector3d* mutable_max(); + void set_allocated_max(::gazebo::msgs::Vector3d* max); + private: + const ::gazebo::msgs::Vector3d& _internal_max() const; + ::gazebo::msgs::Vector3d* _internal_mutable_max(); + public: + void unsafe_arena_set_allocated_max( + ::gazebo::msgs::Vector3d* max); + ::gazebo::msgs::Vector3d* unsafe_arena_release_max(); + + // @@protoc_insertion_point(class_scope:revolve.msgs.BoundingBox) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::gazebo::msgs::Vector3d* min_; + ::gazebo::msgs::Vector3d* max_; + friend struct ::TableStruct_sdf_5fbody_5fanalyze_2eproto; +}; +// ------------------------------------------------------------------- + +class BodyAnalysisResponse PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.BodyAnalysisResponse) */ { + public: + inline BodyAnalysisResponse() : BodyAnalysisResponse(nullptr) {} + virtual ~BodyAnalysisResponse(); + + BodyAnalysisResponse(const BodyAnalysisResponse& from); + BodyAnalysisResponse(BodyAnalysisResponse&& from) noexcept + : BodyAnalysisResponse() { + *this = ::std::move(from); + } + + inline BodyAnalysisResponse& operator=(const BodyAnalysisResponse& from) { + CopyFrom(from); + return *this; + } + inline BodyAnalysisResponse& operator=(BodyAnalysisResponse&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const BodyAnalysisResponse& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const BodyAnalysisResponse* internal_default_instance() { + return reinterpret_cast( + &_BodyAnalysisResponse_default_instance_); + } + static constexpr int kIndexInFileMessages = + 2; + + friend void swap(BodyAnalysisResponse& a, BodyAnalysisResponse& b) { + a.Swap(&b); + } + inline void Swap(BodyAnalysisResponse* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(BodyAnalysisResponse* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline BodyAnalysisResponse* New() const final { + return CreateMaybeMessage(nullptr); + } + + BodyAnalysisResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const BodyAnalysisResponse& from); + void MergeFrom(const BodyAnalysisResponse& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(BodyAnalysisResponse* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.BodyAnalysisResponse"; + } + protected: + explicit BodyAnalysisResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_sdf_5fbody_5fanalyze_2eproto); + return ::descriptor_table_sdf_5fbody_5fanalyze_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kContactFieldNumber = 2, + kBoundingBoxFieldNumber = 1, + }; + // repeated .revolve.msgs.Contact contact = 2; + int contact_size() const; + private: + int _internal_contact_size() const; + public: + void clear_contact(); + ::revolve::msgs::Contact* mutable_contact(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Contact >* + mutable_contact(); + private: + const ::revolve::msgs::Contact& _internal_contact(int index) const; + ::revolve::msgs::Contact* _internal_add_contact(); + public: + const ::revolve::msgs::Contact& contact(int index) const; + ::revolve::msgs::Contact* add_contact(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Contact >& + contact() const; + + // optional .revolve.msgs.BoundingBox boundingBox = 1; + bool has_boundingbox() const; + private: + bool _internal_has_boundingbox() const; + public: + void clear_boundingbox(); + const ::revolve::msgs::BoundingBox& boundingbox() const; + ::revolve::msgs::BoundingBox* release_boundingbox(); + ::revolve::msgs::BoundingBox* mutable_boundingbox(); + void set_allocated_boundingbox(::revolve::msgs::BoundingBox* boundingbox); + private: + const ::revolve::msgs::BoundingBox& _internal_boundingbox() const; + ::revolve::msgs::BoundingBox* _internal_mutable_boundingbox(); + public: + void unsafe_arena_set_allocated_boundingbox( + ::revolve::msgs::BoundingBox* boundingbox); + ::revolve::msgs::BoundingBox* unsafe_arena_release_boundingbox(); + + // @@protoc_insertion_point(class_scope:revolve.msgs.BodyAnalysisResponse) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Contact > contact_; + ::revolve::msgs::BoundingBox* boundingbox_; + friend struct ::TableStruct_sdf_5fbody_5fanalyze_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// Contact + +// required string collision1 = 1; +inline bool Contact::_internal_has_collision1() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool Contact::has_collision1() const { + return _internal_has_collision1(); +} +inline void Contact::clear_collision1() { + collision1_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& Contact::collision1() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Contact.collision1) + return _internal_collision1(); +} +inline void Contact::set_collision1(const std::string& value) { + _internal_set_collision1(value); + // @@protoc_insertion_point(field_set:revolve.msgs.Contact.collision1) +} +inline std::string* Contact::mutable_collision1() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.Contact.collision1) + return _internal_mutable_collision1(); +} +inline const std::string& Contact::_internal_collision1() const { + return collision1_.Get(); +} +inline void Contact::_internal_set_collision1(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + collision1_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void Contact::set_collision1(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + collision1_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.Contact.collision1) +} +inline void Contact::set_collision1(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + collision1_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.Contact.collision1) +} +inline void Contact::set_collision1(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + collision1_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.Contact.collision1) +} +inline std::string* Contact::_internal_mutable_collision1() { + _has_bits_[0] |= 0x00000001u; + return collision1_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* Contact::release_collision1() { + // @@protoc_insertion_point(field_release:revolve.msgs.Contact.collision1) + if (!_internal_has_collision1()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return collision1_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void Contact::set_allocated_collision1(std::string* collision1) { + if (collision1 != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + collision1_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), collision1, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.Contact.collision1) +} + +// required string collision2 = 2; +inline bool Contact::_internal_has_collision2() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool Contact::has_collision2() const { + return _internal_has_collision2(); +} +inline void Contact::clear_collision2() { + collision2_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _has_bits_[0] &= ~0x00000002u; +} +inline const std::string& Contact::collision2() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Contact.collision2) + return _internal_collision2(); +} +inline void Contact::set_collision2(const std::string& value) { + _internal_set_collision2(value); + // @@protoc_insertion_point(field_set:revolve.msgs.Contact.collision2) +} +inline std::string* Contact::mutable_collision2() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.Contact.collision2) + return _internal_mutable_collision2(); +} +inline const std::string& Contact::_internal_collision2() const { + return collision2_.Get(); +} +inline void Contact::_internal_set_collision2(const std::string& value) { + _has_bits_[0] |= 0x00000002u; + collision2_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void Contact::set_collision2(std::string&& value) { + _has_bits_[0] |= 0x00000002u; + collision2_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:revolve.msgs.Contact.collision2) +} +inline void Contact::set_collision2(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000002u; + collision2_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:revolve.msgs.Contact.collision2) +} +inline void Contact::set_collision2(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000002u; + collision2_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.Contact.collision2) +} +inline std::string* Contact::_internal_mutable_collision2() { + _has_bits_[0] |= 0x00000002u; + return collision2_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* Contact::release_collision2() { + // @@protoc_insertion_point(field_release:revolve.msgs.Contact.collision2) + if (!_internal_has_collision2()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000002u; + return collision2_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void Contact::set_allocated_collision2(std::string* collision2) { + if (collision2 != nullptr) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + collision2_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), collision2, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.Contact.collision2) +} + +// ------------------------------------------------------------------- + +// BoundingBox + +// required .gazebo.msgs.Vector3d min = 1; +inline bool BoundingBox::_internal_has_min() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || min_ != nullptr); + return value; +} +inline bool BoundingBox::has_min() const { + return _internal_has_min(); +} +inline const ::gazebo::msgs::Vector3d& BoundingBox::_internal_min() const { + const ::gazebo::msgs::Vector3d* p = min_; + return p != nullptr ? *p : *reinterpret_cast( + &::gazebo::msgs::_Vector3d_default_instance_); +} +inline const ::gazebo::msgs::Vector3d& BoundingBox::min() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BoundingBox.min) + return _internal_min(); +} +inline void BoundingBox::unsafe_arena_set_allocated_min( + ::gazebo::msgs::Vector3d* min) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(min_); + } + min_ = min; + if (min) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:revolve.msgs.BoundingBox.min) +} +inline ::gazebo::msgs::Vector3d* BoundingBox::release_min() { + _has_bits_[0] &= ~0x00000001u; + ::gazebo::msgs::Vector3d* temp = min_; + min_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::gazebo::msgs::Vector3d* BoundingBox::unsafe_arena_release_min() { + // @@protoc_insertion_point(field_release:revolve.msgs.BoundingBox.min) + _has_bits_[0] &= ~0x00000001u; + ::gazebo::msgs::Vector3d* temp = min_; + min_ = nullptr; + return temp; +} +inline ::gazebo::msgs::Vector3d* BoundingBox::_internal_mutable_min() { + _has_bits_[0] |= 0x00000001u; + if (min_ == nullptr) { + auto* p = CreateMaybeMessage<::gazebo::msgs::Vector3d>(GetArena()); + min_ = p; + } + return min_; +} +inline ::gazebo::msgs::Vector3d* BoundingBox::mutable_min() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.BoundingBox.min) + return _internal_mutable_min(); +} +inline void BoundingBox::set_allocated_min(::gazebo::msgs::Vector3d* min) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(min_); + } + if (min) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(min)->GetArena(); + if (message_arena != submessage_arena) { + min = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, min, submessage_arena); + } + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + min_ = min; + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.BoundingBox.min) +} + +// required .gazebo.msgs.Vector3d max = 2; +inline bool BoundingBox::_internal_has_max() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || max_ != nullptr); + return value; +} +inline bool BoundingBox::has_max() const { + return _internal_has_max(); +} +inline const ::gazebo::msgs::Vector3d& BoundingBox::_internal_max() const { + const ::gazebo::msgs::Vector3d* p = max_; + return p != nullptr ? *p : *reinterpret_cast( + &::gazebo::msgs::_Vector3d_default_instance_); +} +inline const ::gazebo::msgs::Vector3d& BoundingBox::max() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BoundingBox.max) + return _internal_max(); +} +inline void BoundingBox::unsafe_arena_set_allocated_max( + ::gazebo::msgs::Vector3d* max) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(max_); + } + max_ = max; + if (max) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:revolve.msgs.BoundingBox.max) +} +inline ::gazebo::msgs::Vector3d* BoundingBox::release_max() { + _has_bits_[0] &= ~0x00000002u; + ::gazebo::msgs::Vector3d* temp = max_; + max_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::gazebo::msgs::Vector3d* BoundingBox::unsafe_arena_release_max() { + // @@protoc_insertion_point(field_release:revolve.msgs.BoundingBox.max) + _has_bits_[0] &= ~0x00000002u; + ::gazebo::msgs::Vector3d* temp = max_; + max_ = nullptr; + return temp; +} +inline ::gazebo::msgs::Vector3d* BoundingBox::_internal_mutable_max() { + _has_bits_[0] |= 0x00000002u; + if (max_ == nullptr) { + auto* p = CreateMaybeMessage<::gazebo::msgs::Vector3d>(GetArena()); + max_ = p; + } + return max_; +} +inline ::gazebo::msgs::Vector3d* BoundingBox::mutable_max() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.BoundingBox.max) + return _internal_mutable_max(); +} +inline void BoundingBox::set_allocated_max(::gazebo::msgs::Vector3d* max) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(max_); + } + if (max) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(max)->GetArena(); + if (message_arena != submessage_arena) { + max = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, max, submessage_arena); + } + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + max_ = max; + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.BoundingBox.max) +} + +// ------------------------------------------------------------------- + +// BodyAnalysisResponse + +// optional .revolve.msgs.BoundingBox boundingBox = 1; +inline bool BodyAnalysisResponse::_internal_has_boundingbox() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || boundingbox_ != nullptr); + return value; +} +inline bool BodyAnalysisResponse::has_boundingbox() const { + return _internal_has_boundingbox(); +} +inline void BodyAnalysisResponse::clear_boundingbox() { + if (boundingbox_ != nullptr) boundingbox_->Clear(); + _has_bits_[0] &= ~0x00000001u; +} +inline const ::revolve::msgs::BoundingBox& BodyAnalysisResponse::_internal_boundingbox() const { + const ::revolve::msgs::BoundingBox* p = boundingbox_; + return p != nullptr ? *p : *reinterpret_cast( + &::revolve::msgs::_BoundingBox_default_instance_); +} +inline const ::revolve::msgs::BoundingBox& BodyAnalysisResponse::boundingbox() const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyAnalysisResponse.boundingBox) + return _internal_boundingbox(); +} +inline void BodyAnalysisResponse::unsafe_arena_set_allocated_boundingbox( + ::revolve::msgs::BoundingBox* boundingbox) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(boundingbox_); + } + boundingbox_ = boundingbox; + if (boundingbox) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:revolve.msgs.BodyAnalysisResponse.boundingBox) +} +inline ::revolve::msgs::BoundingBox* BodyAnalysisResponse::release_boundingbox() { + _has_bits_[0] &= ~0x00000001u; + ::revolve::msgs::BoundingBox* temp = boundingbox_; + boundingbox_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::revolve::msgs::BoundingBox* BodyAnalysisResponse::unsafe_arena_release_boundingbox() { + // @@protoc_insertion_point(field_release:revolve.msgs.BodyAnalysisResponse.boundingBox) + _has_bits_[0] &= ~0x00000001u; + ::revolve::msgs::BoundingBox* temp = boundingbox_; + boundingbox_ = nullptr; + return temp; +} +inline ::revolve::msgs::BoundingBox* BodyAnalysisResponse::_internal_mutable_boundingbox() { + _has_bits_[0] |= 0x00000001u; + if (boundingbox_ == nullptr) { + auto* p = CreateMaybeMessage<::revolve::msgs::BoundingBox>(GetArena()); + boundingbox_ = p; + } + return boundingbox_; +} +inline ::revolve::msgs::BoundingBox* BodyAnalysisResponse::mutable_boundingbox() { + // @@protoc_insertion_point(field_mutable:revolve.msgs.BodyAnalysisResponse.boundingBox) + return _internal_mutable_boundingbox(); +} +inline void BodyAnalysisResponse::set_allocated_boundingbox(::revolve::msgs::BoundingBox* boundingbox) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete boundingbox_; + } + if (boundingbox) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(boundingbox); + if (message_arena != submessage_arena) { + boundingbox = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, boundingbox, submessage_arena); + } + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + boundingbox_ = boundingbox; + // @@protoc_insertion_point(field_set_allocated:revolve.msgs.BodyAnalysisResponse.boundingBox) +} + +// repeated .revolve.msgs.Contact contact = 2; +inline int BodyAnalysisResponse::_internal_contact_size() const { + return contact_.size(); +} +inline int BodyAnalysisResponse::contact_size() const { + return _internal_contact_size(); +} +inline void BodyAnalysisResponse::clear_contact() { + contact_.Clear(); +} +inline ::revolve::msgs::Contact* BodyAnalysisResponse::mutable_contact(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.BodyAnalysisResponse.contact) + return contact_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Contact >* +BodyAnalysisResponse::mutable_contact() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.BodyAnalysisResponse.contact) + return &contact_; +} +inline const ::revolve::msgs::Contact& BodyAnalysisResponse::_internal_contact(int index) const { + return contact_.Get(index); +} +inline const ::revolve::msgs::Contact& BodyAnalysisResponse::contact(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.BodyAnalysisResponse.contact) + return _internal_contact(index); +} +inline ::revolve::msgs::Contact* BodyAnalysisResponse::_internal_add_contact() { + return contact_.Add(); +} +inline ::revolve::msgs::Contact* BodyAnalysisResponse::add_contact() { + // @@protoc_insertion_point(field_add:revolve.msgs.BodyAnalysisResponse.contact) + return _internal_add_contact(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Contact >& +BodyAnalysisResponse::contact() const { + // @@protoc_insertion_point(field_list:revolve.msgs.BodyAnalysisResponse.contact) + return contact_; +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace msgs +} // namespace revolve + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_sdf_5fbody_5fanalyze_2eproto diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/spline_policy.pb.cc b/cpprevolve/revolve/gazebo/revolve/msgs/spline_policy.pb.cc new file mode 100644 index 0000000000..a1fecf79ec --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/spline_policy.pb.cc @@ -0,0 +1,928 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: spline_policy.proto + +#include "spline_policy.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include +extern PROTOBUF_INTERNAL_EXPORT_parameter_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Parameter_parameter_2eproto; +namespace revolve { +namespace msgs { +class SplineDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _Spline_default_instance_; +class PolicyDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _Policy_default_instance_; +class ModifyPolicyDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _ModifyPolicy_default_instance_; +} // namespace msgs +} // namespace revolve +static void InitDefaultsscc_info_ModifyPolicy_spline_5fpolicy_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_ModifyPolicy_default_instance_; + new (ptr) ::revolve::msgs::ModifyPolicy(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::ModifyPolicy::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ModifyPolicy_spline_5fpolicy_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_ModifyPolicy_spline_5fpolicy_2eproto}, {}}; + +static void InitDefaultsscc_info_Policy_spline_5fpolicy_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_Policy_default_instance_; + new (ptr) ::revolve::msgs::Policy(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::Policy::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Policy_spline_5fpolicy_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Policy_spline_5fpolicy_2eproto}, {}}; + +static void InitDefaultsscc_info_Spline_spline_5fpolicy_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::revolve::msgs::_Spline_default_instance_; + new (ptr) ::revolve::msgs::Spline(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::revolve::msgs::Spline::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Spline_spline_5fpolicy_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_Spline_spline_5fpolicy_2eproto}, { + &scc_info_Parameter_parameter_2eproto.base,}}; + +static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_spline_5fpolicy_2eproto[3]; +static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_spline_5fpolicy_2eproto = nullptr; +static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_spline_5fpolicy_2eproto = nullptr; + +const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_spline_5fpolicy_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Spline, _has_bits_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Spline, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Spline, index_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Spline, size_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Spline, param_), + 0, + 1, + ~0u, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Policy, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::Policy, index_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModifyPolicy, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModifyPolicy, add_point_), + PROTOBUF_FIELD_OFFSET(::revolve::msgs::ModifyPolicy, interpolate_), +}; +static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 8, sizeof(::revolve::msgs::Spline)}, + { 11, -1, sizeof(::revolve::msgs::Policy)}, + { 17, -1, sizeof(::revolve::msgs::ModifyPolicy)}, +}; + +static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { + reinterpret_cast(&::revolve::msgs::_Spline_default_instance_), + reinterpret_cast(&::revolve::msgs::_Policy_default_instance_), + reinterpret_cast(&::revolve::msgs::_ModifyPolicy_default_instance_), +}; + +const char descriptor_table_protodef_spline_5fpolicy_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\023spline_policy.proto\022\014revolve.msgs\032\017par" + "ameter.proto\"M\n\006Spline\022\r\n\005index\030\001 \002(\005\022\014\n" + "\004size\030\002 \002(\005\022&\n\005param\030\005 \003(\0132\027.revolve.msg" + "s.Parameter\"\027\n\006Policy\022\r\n\005index\030\001 \003(\005\"6\n\014" + "ModifyPolicy\022\021\n\tadd_point\030\001 \003(\001\022\023\n\013inter" + "polate\030\002 \003(\t" + ; +static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_spline_5fpolicy_2eproto_deps[1] = { + &::descriptor_table_parameter_2eproto, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_spline_5fpolicy_2eproto_sccs[3] = { + &scc_info_ModifyPolicy_spline_5fpolicy_2eproto.base, + &scc_info_Policy_spline_5fpolicy_2eproto.base, + &scc_info_Spline_spline_5fpolicy_2eproto.base, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_spline_5fpolicy_2eproto_once; +const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_spline_5fpolicy_2eproto = { + false, false, descriptor_table_protodef_spline_5fpolicy_2eproto, "spline_policy.proto", 212, + &descriptor_table_spline_5fpolicy_2eproto_once, descriptor_table_spline_5fpolicy_2eproto_sccs, descriptor_table_spline_5fpolicy_2eproto_deps, 3, 1, + schemas, file_default_instances, TableStruct_spline_5fpolicy_2eproto::offsets, + file_level_metadata_spline_5fpolicy_2eproto, 3, file_level_enum_descriptors_spline_5fpolicy_2eproto, file_level_service_descriptors_spline_5fpolicy_2eproto, +}; + +// Force running AddDescriptors() at dynamic initialization time. +static bool dynamic_init_dummy_spline_5fpolicy_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_spline_5fpolicy_2eproto)), true); +namespace revolve { +namespace msgs { + +// =================================================================== + +void Spline::InitAsDefaultInstance() { +} +class Spline::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_index(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_size(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +void Spline::clear_param() { + param_.Clear(); +} +Spline::Spline(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + param_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.Spline) +} +Spline::Spline(const Spline& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + param_(from.param_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::memcpy(&index_, &from.index_, + static_cast(reinterpret_cast(&size_) - + reinterpret_cast(&index_)) + sizeof(size_)); + // @@protoc_insertion_point(copy_constructor:revolve.msgs.Spline) +} + +void Spline::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Spline_spline_5fpolicy_2eproto.base); + ::memset(&index_, 0, static_cast( + reinterpret_cast(&size_) - + reinterpret_cast(&index_)) + sizeof(size_)); +} + +Spline::~Spline() { + // @@protoc_insertion_point(destructor:revolve.msgs.Spline) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void Spline::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void Spline::ArenaDtor(void* object) { + Spline* _this = reinterpret_cast< Spline* >(object); + (void)_this; +} +void Spline::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void Spline::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const Spline& Spline::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Spline_spline_5fpolicy_2eproto.base); + return *internal_default_instance(); +} + + +void Spline::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.Spline) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + param_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + ::memset(&index_, 0, static_cast( + reinterpret_cast(&size_) - + reinterpret_cast(&index_)) + sizeof(size_)); + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Spline::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required int32 index = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + _Internal::set_has_index(&has_bits); + index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // required int32 size = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + _Internal::set_has_size(&has_bits); + size_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated .revolve.msgs.Parameter param = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_param(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* Spline::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.Spline) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required int32 index = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_index(), target); + } + + // required int32 size = 2; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_size(), target); + } + + // repeated .revolve.msgs.Parameter param = 5; + for (unsigned int i = 0, + n = static_cast(this->_internal_param_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(5, this->_internal_param(i), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.Spline) + return target; +} + +size_t Spline::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:revolve.msgs.Spline) + size_t total_size = 0; + + if (_internal_has_index()) { + // required int32 index = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_index()); + } + + if (_internal_has_size()) { + // required int32 size = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_size()); + } + + return total_size; +} +size_t Spline::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.Spline) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required int32 index = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_index()); + + // required int32 size = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_size()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .revolve.msgs.Parameter param = 5; + total_size += 1UL * this->_internal_param_size(); + for (const auto& msg : this->param_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void Spline::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.Spline) + GOOGLE_DCHECK_NE(&from, this); + const Spline* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.Spline) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.Spline) + MergeFrom(*source); + } +} + +void Spline::MergeFrom(const Spline& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.Spline) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + param_.MergeFrom(from.param_); + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + index_ = from.index_; + } + if (cached_has_bits & 0x00000002u) { + size_ = from.size_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void Spline::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.Spline) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Spline::CopyFrom(const Spline& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.Spline) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Spline::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(param_)) return false; + return true; +} + +void Spline::InternalSwap(Spline* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + param_.InternalSwap(&other->param_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Spline, size_) + + sizeof(Spline::size_) + - PROTOBUF_FIELD_OFFSET(Spline, index_)>( + reinterpret_cast(&index_), + reinterpret_cast(&other->index_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Spline::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void Policy::InitAsDefaultInstance() { +} +class Policy::_Internal { + public: +}; + +Policy::Policy(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + index_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.Policy) +} +Policy::Policy(const Policy& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + index_(from.index_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:revolve.msgs.Policy) +} + +void Policy::SharedCtor() { +} + +Policy::~Policy() { + // @@protoc_insertion_point(destructor:revolve.msgs.Policy) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void Policy::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void Policy::ArenaDtor(void* object) { + Policy* _this = reinterpret_cast< Policy* >(object); + (void)_this; +} +void Policy::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void Policy::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const Policy& Policy::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Policy_spline_5fpolicy_2eproto.base); + return *internal_default_instance(); +} + + +void Policy::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.Policy) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + index_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Policy::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // repeated int32 index = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + ptr -= 1; + do { + ptr += 1; + _internal_add_index(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<8>(ptr)); + } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_index(), ptr, ctx); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* Policy::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.Policy) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // repeated int32 index = 1; + for (int i = 0, n = this->_internal_index_size(); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_index(i), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.Policy) + return target; +} + +size_t Policy::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.Policy) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated int32 index = 1; + { + size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + Int32Size(this->index_); + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_index_size()); + total_size += data_size; + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void Policy::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.Policy) + GOOGLE_DCHECK_NE(&from, this); + const Policy* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.Policy) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.Policy) + MergeFrom(*source); + } +} + +void Policy::MergeFrom(const Policy& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.Policy) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + index_.MergeFrom(from.index_); +} + +void Policy::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.Policy) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Policy::CopyFrom(const Policy& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.Policy) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Policy::IsInitialized() const { + return true; +} + +void Policy::InternalSwap(Policy* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + index_.InternalSwap(&other->index_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Policy::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void ModifyPolicy::InitAsDefaultInstance() { +} +class ModifyPolicy::_Internal { + public: +}; + +ModifyPolicy::ModifyPolicy(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + add_point_(arena), + interpolate_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:revolve.msgs.ModifyPolicy) +} +ModifyPolicy::ModifyPolicy(const ModifyPolicy& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + add_point_(from.add_point_), + interpolate_(from.interpolate_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:revolve.msgs.ModifyPolicy) +} + +void ModifyPolicy::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ModifyPolicy_spline_5fpolicy_2eproto.base); +} + +ModifyPolicy::~ModifyPolicy() { + // @@protoc_insertion_point(destructor:revolve.msgs.ModifyPolicy) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void ModifyPolicy::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void ModifyPolicy::ArenaDtor(void* object) { + ModifyPolicy* _this = reinterpret_cast< ModifyPolicy* >(object); + (void)_this; +} +void ModifyPolicy::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void ModifyPolicy::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const ModifyPolicy& ModifyPolicy::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ModifyPolicy_spline_5fpolicy_2eproto.base); + return *internal_default_instance(); +} + + +void ModifyPolicy::Clear() { +// @@protoc_insertion_point(message_clear_start:revolve.msgs.ModifyPolicy) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + add_point_.Clear(); + interpolate_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* ModifyPolicy::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // repeated double add_point = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 9)) { + ptr -= 1; + do { + ptr += 1; + _internal_add_add_point(::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr)); + ptr += sizeof(double); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<9>(ptr)); + } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedDoubleParser(_internal_mutable_add_point(), ptr, ctx); + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated string interpolate = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_interpolate(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "revolve.msgs.ModifyPolicy.interpolate"); + #endif // !NDEBUG + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* ModifyPolicy::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:revolve.msgs.ModifyPolicy) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // repeated double add_point = 1; + for (int i = 0, n = this->_internal_add_point_size(); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(1, this->_internal_add_point(i), target); + } + + // repeated string interpolate = 2; + for (int i = 0, n = this->_internal_interpolate_size(); i < n; i++) { + const auto& s = this->_internal_interpolate(i); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + s.data(), static_cast(s.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "revolve.msgs.ModifyPolicy.interpolate"); + target = stream->WriteString(2, s, target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:revolve.msgs.ModifyPolicy) + return target; +} + +size_t ModifyPolicy::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:revolve.msgs.ModifyPolicy) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated double add_point = 1; + { + unsigned int count = static_cast(this->_internal_add_point_size()); + size_t data_size = 8UL * count; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_add_point_size()); + total_size += data_size; + } + + // repeated string interpolate = 2; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(interpolate_.size()); + for (int i = 0, n = interpolate_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + interpolate_.Get(i)); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void ModifyPolicy::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:revolve.msgs.ModifyPolicy) + GOOGLE_DCHECK_NE(&from, this); + const ModifyPolicy* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:revolve.msgs.ModifyPolicy) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:revolve.msgs.ModifyPolicy) + MergeFrom(*source); + } +} + +void ModifyPolicy::MergeFrom(const ModifyPolicy& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:revolve.msgs.ModifyPolicy) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + add_point_.MergeFrom(from.add_point_); + interpolate_.MergeFrom(from.interpolate_); +} + +void ModifyPolicy::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:revolve.msgs.ModifyPolicy) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ModifyPolicy::CopyFrom(const ModifyPolicy& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:revolve.msgs.ModifyPolicy) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ModifyPolicy::IsInitialized() const { + return true; +} + +void ModifyPolicy::InternalSwap(ModifyPolicy* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + add_point_.InternalSwap(&other->add_point_); + interpolate_.InternalSwap(&other->interpolate_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata ModifyPolicy::GetMetadata() const { + return GetMetadataStatic(); +} + + +// @@protoc_insertion_point(namespace_scope) +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::revolve::msgs::Spline* Arena::CreateMaybeMessage< ::revolve::msgs::Spline >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::Spline >(arena); +} +template<> PROTOBUF_NOINLINE ::revolve::msgs::Policy* Arena::CreateMaybeMessage< ::revolve::msgs::Policy >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::Policy >(arena); +} +template<> PROTOBUF_NOINLINE ::revolve::msgs::ModifyPolicy* Arena::CreateMaybeMessage< ::revolve::msgs::ModifyPolicy >(Arena* arena) { + return Arena::CreateMessageInternal< ::revolve::msgs::ModifyPolicy >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/cpprevolve/revolve/gazebo/revolve/msgs/spline_policy.pb.h b/cpprevolve/revolve/gazebo/revolve/msgs/spline_policy.pb.h new file mode 100644 index 0000000000..5e89bc1869 --- /dev/null +++ b/cpprevolve/revolve/gazebo/revolve/msgs/spline_policy.pb.h @@ -0,0 +1,901 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: spline_policy.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_spline_5fpolicy_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_spline_5fpolicy_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3013000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3013000 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include "parameter.pb.h" +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_spline_5fpolicy_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_spline_5fpolicy_2eproto { + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[3] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; + static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; + static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_spline_5fpolicy_2eproto; +namespace revolve { +namespace msgs { +class ModifyPolicy; +class ModifyPolicyDefaultTypeInternal; +extern ModifyPolicyDefaultTypeInternal _ModifyPolicy_default_instance_; +class Policy; +class PolicyDefaultTypeInternal; +extern PolicyDefaultTypeInternal _Policy_default_instance_; +class Spline; +class SplineDefaultTypeInternal; +extern SplineDefaultTypeInternal _Spline_default_instance_; +} // namespace msgs +} // namespace revolve +PROTOBUF_NAMESPACE_OPEN +template<> ::revolve::msgs::ModifyPolicy* Arena::CreateMaybeMessage<::revolve::msgs::ModifyPolicy>(Arena*); +template<> ::revolve::msgs::Policy* Arena::CreateMaybeMessage<::revolve::msgs::Policy>(Arena*); +template<> ::revolve::msgs::Spline* Arena::CreateMaybeMessage<::revolve::msgs::Spline>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace revolve { +namespace msgs { + +// =================================================================== + +class Spline PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.Spline) */ { + public: + inline Spline() : Spline(nullptr) {} + virtual ~Spline(); + + Spline(const Spline& from); + Spline(Spline&& from) noexcept + : Spline() { + *this = ::std::move(from); + } + + inline Spline& operator=(const Spline& from) { + CopyFrom(from); + return *this; + } + inline Spline& operator=(Spline&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const Spline& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const Spline* internal_default_instance() { + return reinterpret_cast( + &_Spline_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Spline& a, Spline& b) { + a.Swap(&b); + } + inline void Swap(Spline* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Spline* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline Spline* New() const final { + return CreateMaybeMessage(nullptr); + } + + Spline* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const Spline& from); + void MergeFrom(const Spline& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Spline* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.Spline"; + } + protected: + explicit Spline(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_spline_5fpolicy_2eproto); + return ::descriptor_table_spline_5fpolicy_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kParamFieldNumber = 5, + kIndexFieldNumber = 1, + kSizeFieldNumber = 2, + }; + // repeated .revolve.msgs.Parameter param = 5; + int param_size() const; + private: + int _internal_param_size() const; + public: + void clear_param(); + ::revolve::msgs::Parameter* mutable_param(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >* + mutable_param(); + private: + const ::revolve::msgs::Parameter& _internal_param(int index) const; + ::revolve::msgs::Parameter* _internal_add_param(); + public: + const ::revolve::msgs::Parameter& param(int index) const; + ::revolve::msgs::Parameter* add_param(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >& + param() const; + + // required int32 index = 1; + bool has_index() const; + private: + bool _internal_has_index() const; + public: + void clear_index(); + ::PROTOBUF_NAMESPACE_ID::int32 index() const; + void set_index(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_index() const; + void _internal_set_index(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // required int32 size = 2; + bool has_size() const; + private: + bool _internal_has_size() const; + public: + void clear_size(); + ::PROTOBUF_NAMESPACE_ID::int32 size() const; + void set_size(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_size() const; + void _internal_set_size(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:revolve.msgs.Spline) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter > param_; + ::PROTOBUF_NAMESPACE_ID::int32 index_; + ::PROTOBUF_NAMESPACE_ID::int32 size_; + friend struct ::TableStruct_spline_5fpolicy_2eproto; +}; +// ------------------------------------------------------------------- + +class Policy PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.Policy) */ { + public: + inline Policy() : Policy(nullptr) {} + virtual ~Policy(); + + Policy(const Policy& from); + Policy(Policy&& from) noexcept + : Policy() { + *this = ::std::move(from); + } + + inline Policy& operator=(const Policy& from) { + CopyFrom(from); + return *this; + } + inline Policy& operator=(Policy&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const Policy& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const Policy* internal_default_instance() { + return reinterpret_cast( + &_Policy_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(Policy& a, Policy& b) { + a.Swap(&b); + } + inline void Swap(Policy* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Policy* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline Policy* New() const final { + return CreateMaybeMessage(nullptr); + } + + Policy* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const Policy& from); + void MergeFrom(const Policy& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Policy* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.Policy"; + } + protected: + explicit Policy(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_spline_5fpolicy_2eproto); + return ::descriptor_table_spline_5fpolicy_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kIndexFieldNumber = 1, + }; + // repeated int32 index = 1; + int index_size() const; + private: + int _internal_index_size() const; + public: + void clear_index(); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_index(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& + _internal_index() const; + void _internal_add_index(::PROTOBUF_NAMESPACE_ID::int32 value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* + _internal_mutable_index(); + public: + ::PROTOBUF_NAMESPACE_ID::int32 index(int index) const; + void set_index(int index, ::PROTOBUF_NAMESPACE_ID::int32 value); + void add_index(::PROTOBUF_NAMESPACE_ID::int32 value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& + index() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* + mutable_index(); + + // @@protoc_insertion_point(class_scope:revolve.msgs.Policy) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 > index_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_spline_5fpolicy_2eproto; +}; +// ------------------------------------------------------------------- + +class ModifyPolicy PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:revolve.msgs.ModifyPolicy) */ { + public: + inline ModifyPolicy() : ModifyPolicy(nullptr) {} + virtual ~ModifyPolicy(); + + ModifyPolicy(const ModifyPolicy& from); + ModifyPolicy(ModifyPolicy&& from) noexcept + : ModifyPolicy() { + *this = ::std::move(from); + } + + inline ModifyPolicy& operator=(const ModifyPolicy& from) { + CopyFrom(from); + return *this; + } + inline ModifyPolicy& operator=(ModifyPolicy&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const ModifyPolicy& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const ModifyPolicy* internal_default_instance() { + return reinterpret_cast( + &_ModifyPolicy_default_instance_); + } + static constexpr int kIndexInFileMessages = + 2; + + friend void swap(ModifyPolicy& a, ModifyPolicy& b) { + a.Swap(&b); + } + inline void Swap(ModifyPolicy* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ModifyPolicy* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline ModifyPolicy* New() const final { + return CreateMaybeMessage(nullptr); + } + + ModifyPolicy* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const ModifyPolicy& from); + void MergeFrom(const ModifyPolicy& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(ModifyPolicy* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "revolve.msgs.ModifyPolicy"; + } + protected: + explicit ModifyPolicy(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_spline_5fpolicy_2eproto); + return ::descriptor_table_spline_5fpolicy_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kAddPointFieldNumber = 1, + kInterpolateFieldNumber = 2, + }; + // repeated double add_point = 1; + int add_point_size() const; + private: + int _internal_add_point_size() const; + public: + void clear_add_point(); + private: + double _internal_add_point(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< double >& + _internal_add_point() const; + void _internal_add_add_point(double value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< double >* + _internal_mutable_add_point(); + public: + double add_point(int index) const; + void set_add_point(int index, double value); + void add_add_point(double value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< double >& + add_point() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< double >* + mutable_add_point(); + + // repeated string interpolate = 2; + int interpolate_size() const; + private: + int _internal_interpolate_size() const; + public: + void clear_interpolate(); + const std::string& interpolate(int index) const; + std::string* mutable_interpolate(int index); + void set_interpolate(int index, const std::string& value); + void set_interpolate(int index, std::string&& value); + void set_interpolate(int index, const char* value); + void set_interpolate(int index, const char* value, size_t size); + std::string* add_interpolate(); + void add_interpolate(const std::string& value); + void add_interpolate(std::string&& value); + void add_interpolate(const char* value); + void add_interpolate(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& interpolate() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_interpolate(); + private: + const std::string& _internal_interpolate(int index) const; + std::string* _internal_add_interpolate(); + public: + + // @@protoc_insertion_point(class_scope:revolve.msgs.ModifyPolicy) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< double > add_point_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField interpolate_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_spline_5fpolicy_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// Spline + +// required int32 index = 1; +inline bool Spline::_internal_has_index() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool Spline::has_index() const { + return _internal_has_index(); +} +inline void Spline::clear_index() { + index_ = 0; + _has_bits_[0] &= ~0x00000001u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 Spline::_internal_index() const { + return index_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 Spline::index() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Spline.index) + return _internal_index(); +} +inline void Spline::_internal_set_index(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000001u; + index_ = value; +} +inline void Spline::set_index(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_index(value); + // @@protoc_insertion_point(field_set:revolve.msgs.Spline.index) +} + +// required int32 size = 2; +inline bool Spline::_internal_has_size() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool Spline::has_size() const { + return _internal_has_size(); +} +inline void Spline::clear_size() { + size_ = 0; + _has_bits_[0] &= ~0x00000002u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 Spline::_internal_size() const { + return size_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 Spline::size() const { + // @@protoc_insertion_point(field_get:revolve.msgs.Spline.size) + return _internal_size(); +} +inline void Spline::_internal_set_size(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000002u; + size_ = value; +} +inline void Spline::set_size(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_size(value); + // @@protoc_insertion_point(field_set:revolve.msgs.Spline.size) +} + +// repeated .revolve.msgs.Parameter param = 5; +inline int Spline::_internal_param_size() const { + return param_.size(); +} +inline int Spline::param_size() const { + return _internal_param_size(); +} +inline ::revolve::msgs::Parameter* Spline::mutable_param(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.Spline.param) + return param_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >* +Spline::mutable_param() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.Spline.param) + return ¶m_; +} +inline const ::revolve::msgs::Parameter& Spline::_internal_param(int index) const { + return param_.Get(index); +} +inline const ::revolve::msgs::Parameter& Spline::param(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.Spline.param) + return _internal_param(index); +} +inline ::revolve::msgs::Parameter* Spline::_internal_add_param() { + return param_.Add(); +} +inline ::revolve::msgs::Parameter* Spline::add_param() { + // @@protoc_insertion_point(field_add:revolve.msgs.Spline.param) + return _internal_add_param(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::revolve::msgs::Parameter >& +Spline::param() const { + // @@protoc_insertion_point(field_list:revolve.msgs.Spline.param) + return param_; +} + +// ------------------------------------------------------------------- + +// Policy + +// repeated int32 index = 1; +inline int Policy::_internal_index_size() const { + return index_.size(); +} +inline int Policy::index_size() const { + return _internal_index_size(); +} +inline void Policy::clear_index() { + index_.Clear(); +} +inline ::PROTOBUF_NAMESPACE_ID::int32 Policy::_internal_index(int index) const { + return index_.Get(index); +} +inline ::PROTOBUF_NAMESPACE_ID::int32 Policy::index(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.Policy.index) + return _internal_index(index); +} +inline void Policy::set_index(int index, ::PROTOBUF_NAMESPACE_ID::int32 value) { + index_.Set(index, value); + // @@protoc_insertion_point(field_set:revolve.msgs.Policy.index) +} +inline void Policy::_internal_add_index(::PROTOBUF_NAMESPACE_ID::int32 value) { + index_.Add(value); +} +inline void Policy::add_index(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_add_index(value); + // @@protoc_insertion_point(field_add:revolve.msgs.Policy.index) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& +Policy::_internal_index() const { + return index_; +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& +Policy::index() const { + // @@protoc_insertion_point(field_list:revolve.msgs.Policy.index) + return _internal_index(); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* +Policy::_internal_mutable_index() { + return &index_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* +Policy::mutable_index() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.Policy.index) + return _internal_mutable_index(); +} + +// ------------------------------------------------------------------- + +// ModifyPolicy + +// repeated double add_point = 1; +inline int ModifyPolicy::_internal_add_point_size() const { + return add_point_.size(); +} +inline int ModifyPolicy::add_point_size() const { + return _internal_add_point_size(); +} +inline void ModifyPolicy::clear_add_point() { + add_point_.Clear(); +} +inline double ModifyPolicy::_internal_add_point(int index) const { + return add_point_.Get(index); +} +inline double ModifyPolicy::add_point(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.ModifyPolicy.add_point) + return _internal_add_point(index); +} +inline void ModifyPolicy::set_add_point(int index, double value) { + add_point_.Set(index, value); + // @@protoc_insertion_point(field_set:revolve.msgs.ModifyPolicy.add_point) +} +inline void ModifyPolicy::_internal_add_add_point(double value) { + add_point_.Add(value); +} +inline void ModifyPolicy::add_add_point(double value) { + _internal_add_add_point(value); + // @@protoc_insertion_point(field_add:revolve.msgs.ModifyPolicy.add_point) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< double >& +ModifyPolicy::_internal_add_point() const { + return add_point_; +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< double >& +ModifyPolicy::add_point() const { + // @@protoc_insertion_point(field_list:revolve.msgs.ModifyPolicy.add_point) + return _internal_add_point(); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< double >* +ModifyPolicy::_internal_mutable_add_point() { + return &add_point_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< double >* +ModifyPolicy::mutable_add_point() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.ModifyPolicy.add_point) + return _internal_mutable_add_point(); +} + +// repeated string interpolate = 2; +inline int ModifyPolicy::_internal_interpolate_size() const { + return interpolate_.size(); +} +inline int ModifyPolicy::interpolate_size() const { + return _internal_interpolate_size(); +} +inline void ModifyPolicy::clear_interpolate() { + interpolate_.Clear(); +} +inline std::string* ModifyPolicy::add_interpolate() { + // @@protoc_insertion_point(field_add_mutable:revolve.msgs.ModifyPolicy.interpolate) + return _internal_add_interpolate(); +} +inline const std::string& ModifyPolicy::_internal_interpolate(int index) const { + return interpolate_.Get(index); +} +inline const std::string& ModifyPolicy::interpolate(int index) const { + // @@protoc_insertion_point(field_get:revolve.msgs.ModifyPolicy.interpolate) + return _internal_interpolate(index); +} +inline std::string* ModifyPolicy::mutable_interpolate(int index) { + // @@protoc_insertion_point(field_mutable:revolve.msgs.ModifyPolicy.interpolate) + return interpolate_.Mutable(index); +} +inline void ModifyPolicy::set_interpolate(int index, const std::string& value) { + // @@protoc_insertion_point(field_set:revolve.msgs.ModifyPolicy.interpolate) + interpolate_.Mutable(index)->assign(value); +} +inline void ModifyPolicy::set_interpolate(int index, std::string&& value) { + // @@protoc_insertion_point(field_set:revolve.msgs.ModifyPolicy.interpolate) + interpolate_.Mutable(index)->assign(std::move(value)); +} +inline void ModifyPolicy::set_interpolate(int index, const char* value) { + GOOGLE_DCHECK(value != nullptr); + interpolate_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:revolve.msgs.ModifyPolicy.interpolate) +} +inline void ModifyPolicy::set_interpolate(int index, const char* value, size_t size) { + interpolate_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:revolve.msgs.ModifyPolicy.interpolate) +} +inline std::string* ModifyPolicy::_internal_add_interpolate() { + return interpolate_.Add(); +} +inline void ModifyPolicy::add_interpolate(const std::string& value) { + interpolate_.Add()->assign(value); + // @@protoc_insertion_point(field_add:revolve.msgs.ModifyPolicy.interpolate) +} +inline void ModifyPolicy::add_interpolate(std::string&& value) { + interpolate_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:revolve.msgs.ModifyPolicy.interpolate) +} +inline void ModifyPolicy::add_interpolate(const char* value) { + GOOGLE_DCHECK(value != nullptr); + interpolate_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:revolve.msgs.ModifyPolicy.interpolate) +} +inline void ModifyPolicy::add_interpolate(const char* value, size_t size) { + interpolate_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:revolve.msgs.ModifyPolicy.interpolate) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& +ModifyPolicy::interpolate() const { + // @@protoc_insertion_point(field_list:revolve.msgs.ModifyPolicy.interpolate) + return interpolate_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +ModifyPolicy::mutable_interpolate() { + // @@protoc_insertion_point(field_mutable_list:revolve.msgs.ModifyPolicy.interpolate) + return &interpolate_; +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace msgs +} // namespace revolve + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_spline_5fpolicy_2eproto diff --git a/experiments/bo_learner/BOTuningAnalysis.py b/experiments/bo_learner/BOTuningAnalysis.py index 0136decf65..802dc50a5d 100644 --- a/experiments/bo_learner/BOTuningAnalysis.py +++ b/experiments/bo_learner/BOTuningAnalysis.py @@ -5,7 +5,7 @@ import matplotlib as mpl -path = "/home/gongjinlan/BO_tuning_results/main_1560002003-BO-spider9-finished/" +path = "/Users/lan/projects/revolve/BO_tuning_results/main_1560002003-BO-spider9-finished/" dirs = glob(path + "*/") # Base settings for alph, sigma_sq, l diff --git a/experiments/bo_learner/GridSearch.py b/experiments/bo_learner/GridSearch.py old mode 100644 new mode 100755 index 71f8c0f2c9..8f3edb3a21 --- a/experiments/bo_learner/GridSearch.py +++ b/experiments/bo_learner/GridSearch.py @@ -19,36 +19,29 @@ # Parameters -min_lines = 1480 +min_lines = 1500 run_gazebo = False -n_runs = 15 # Naar 20 -n_jobs = 30 +n_runs = 20 # Naar 20 +n_jobs = 4 my_yaml_path = "experiments/bo_learner/yaml/" -yaml_model = "babyC.yaml" +yaml_model = "nihedssnake6.yaml" manager = "experiments/bo_learner/manager.py" python_interpreter = ".venv/bin/python3" search_space = { - 'n_learning_iterations': [1500], - 'n_init_samples': [20], - 'evaluation_rate': [60], - 'verbose': [0], - 'kernel_sigma_sq': [1], - 'kernel_l': [0.02, 0.05, 0.1, 0.2], - 'acqui_ucb_alpha': [0.1, 0.3, 0.5, 1.0], - 'range_ub': [1.5], - 'signal_factor_all': [4.0], + # 'load_brain': ["/Users/lan/projects/revolve/output/cpg_bo/one/main_1560413639/0/0/best_brain.txt"], + 'init_method': ["LHS"], } print(search_space) # You don't have to change this my_sub_directory = "yaml_temp/" -output_path = "output/cpg_bo/main_" + str(round(time.time())) + "/" +output_path = "output/cpg_boea/main_" + str(round(time.time())) + "/" start_port = 11000 finished = False # Make in revolve/build to allow runs from terminal -os.system('cmake /home/gongjinlan/projects/revolve/ -DCMAKE_BUILD_TYPE="Release"') -os.system("make -j60") +os.system('cmake . -DCMAKE_BUILD_TYPE="Release"') +os.system("make -j4") def change_parameters(original_file, parameters): # Iterate over dictionary elements @@ -152,29 +145,29 @@ def run(i, sub_directory, model, params): # PASTE THE EXPERIMENTS HERE, IN THE FORMAT SHOWN BELOW experiments = [ - {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, # BASE RUN - - # BASE RUN - {'init_method': "LHS", 'kernel_l': 0.2, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, - {'init_method': "LHS", 'kernel_l': 0.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, - {'init_method': "LHS", 'kernel_l': 1.0, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, - {'init_method': "LHS", 'kernel_l': 1.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, - - {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.1, 'acqui_ucb_alpha': 0.5}, - {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.2, 'acqui_ucb_alpha': 0.5}, - {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.5, 'acqui_ucb_alpha': 0.5}, - # BASE RUN - - {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.1}, - {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.2}, - # BASE RUN - {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.0}, - {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.5}, - {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 2.0}, - {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 3.0}, - {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 4.0}, - - {'init_method': "RS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + {'init_method': "LHS"}, + + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.2, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.0, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.1, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.2, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.5, 'acqui_ucb_alpha': 0.5}, + # # BASE RUN + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.1}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.2}, + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 2.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 3.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 4.0}, + # + # {'init_method': "RS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, # BASE RUN ] # 'kernel_l': [0.02, 0.05, 0.1, 0.2], @@ -185,6 +178,7 @@ def run(i, sub_directory, model, params): # Get id's on the permutations for ix, my_dict in enumerate(experiments): my_dict["id"] = ix + experiments *=n_runs # Save to yaml files create_yamls(yaml_path=my_yaml_path, @@ -196,8 +190,8 @@ def run(i, sub_directory, model, params): # Create dirs if not os.path.isdir("output"): os.mkdir("output") - if not os.path.isdir("output/cpg_bo"): - os.mkdir("output/cpg_bo") + if not os.path.isdir("output/cpg_boea"): + os.mkdir("output/cpg_boea") os.mkdir(output_path) # Create experiment group directories diff --git a/experiments/bo_learner/GridSearchBaby.py b/experiments/bo_learner/GridSearchBaby.py new file mode 100755 index 0000000000..2d2cbad6d4 --- /dev/null +++ b/experiments/bo_learner/GridSearchBaby.py @@ -0,0 +1,330 @@ +""" + experiments = [ + {'range_ub': 1.0, 'signal_factor_all': 1.0}, + {'range_ub': 1.0, 'signal_factor_all': 3.0}, + {'range_ub': 4.5, 'signal_factor_all': 3.0} + ] +""" +from sys import platform +import matplotlib +if platform == "darwin": + matplotlib.use("TkAgg") +import numpy as np +import itertools +import os +import time +import matplotlib.pyplot as plt +from glob import glob +from joblib import Parallel, delayed + + +# Parameters +min_lines = 1500 +run_gazebo = False +n_runs = 20 # Naar 20 +n_jobs = 4 +my_yaml_path = "experiments/bo_learner/yaml/" +yaml_model = "babyA.yaml" +manager = "experiments/bo_learner/manager.py" +python_interpreter = "~/snake_workspace/revolve/.venv/bin/python3" +search_space = { + # 'load_brain': ["/Users/lan/projects/revolve/output/cpg_bo/one/main_1560413639/0/0/best_brain.txt"], + 'init_method': ["LHS"], +} + +print(search_space) +# You don't have to change this +my_sub_directory = "yaml_temp/" +output_path = "output/cpg_boea/main_" + str(round(time.time())) + "/" +start_port = 19000 +finished = False + +# Make in revolve/build to allow runs from terminal +os.system('cmake ~/snake_workspace/revolve/ -DCMAKE_BUILD_TYPE="Release"') +os.system("make -j4") + +def change_parameters(original_file, parameters): + # Iterate over dictionary elements + for key, value in iter(parameters.items()): + # Find first occurrence of parameter + ix = [row for row in range(len(original_file)) if key in original_file[row]][0] + + # Change values. Note the Python indentation + original_file[ix] = " " + key + " = " + str(value) + + # Return adapted file: + return original_file + + +def write_file(filename, contents): + # Write back to file + with open(filename, 'w') as file: + # Write updated contents + for line in contents: + file.write((line + "\n")) + file.close() + + +def create_yamls(yaml_path, model, sub_directory, experiments): + # Read original yaml file + yaml_file = [(line.rstrip('\n')) for line in open(yaml_path + model)] + + # Change yaml file + for my_dict in experiments: + # Loop over the entries in this dict + for key, value in my_dict.items(): + if not key == "id": + # Check on what line this parameter is + index = [ix for ix, x in enumerate(yaml_file) if key in x][0] + + yaml_file[index] = " " + key + ": " + str(value) + + # Write yaml file to desired location + write_file(yaml_path + sub_directory + "/" + yaml_model.split(".")[0] + "-" + str(my_dict["id"]) + ".yaml", yaml_file) + + +def run(i, sub_directory, model, params): + # Sleepy time when starting up to save gazebo from misery + if i < n_jobs: + time.sleep(5*i) + else: + print("Todo: Make sure you are leaving 2 seconds in between firing " + "gazebos") + + # Get yaml file id + k = params["id"] + + my_time = str(round(time.time(), 2)) + my_run_path = output_path + str(k) + "/" + my_time + "/" + os.mkdir(my_run_path) + + # Select relevant yaml file + yaml_model = my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + ".yaml" + print(yaml_model) + # Get relevant yaml file + yaml_file = [(line.rstrip('\n')) for line in open(yaml_model)] + + # Change output_directory + index = [ix for ix, x in enumerate(yaml_file) if "output_directory" in x][0] + yaml_file[index] = f' output_directory: "{my_run_path}"' + + # Write temporarily with identifier + write_file(my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + "-" + str(i) + ".yaml", yaml_file) + yaml_model = my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + "-" + str(i) + ".yaml" + + # Change port: We need to do this via the manager + world_address = "127.0.0.1:" + str(start_port + i) + os.environ["GAZEBO_MASTER_URI"] = "http://localhost:" + str(start_port + i) + os.environ["LIBGL_ALWAYS_INDIRECT"] = "0" + py_command = "" + + # Call the experiment + if not run_gazebo: + py_command = python_interpreter + \ + " ./revolve.py" + \ + " --manager " + manager + \ + " --world-address " + world_address + \ + " --robot-yaml " + yaml_model + else: + py_command = python_interpreter + \ + " ./revolve.py" + \ + " --manager " + manager + \ + " --world-address " + world_address + \ + " --robot-yaml " + yaml_model + \ + " --simulator-cmd gazebo" \ + + return_code = os.system(py_command) + if return_code == 32512: + print("Specify a valid python interpreter in the parameters") + + +if __name__ == "__main__": + # Get permutations + keys, values = zip(*search_space.items()) + experiments = [dict(zip(keys, v)) for v in itertools.product(*values)] + + # PASTE THE EXPERIMENTS HERE, IN THE FORMAT SHOWN BELOW + experiments = [ + {'init_method': "LHS"}, + + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.2, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.0, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.1, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.2, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.5, 'acqui_ucb_alpha': 0.5}, + # # BASE RUN + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.1}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.2}, + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 2.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 3.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 4.0}, + # + # {'init_method': "RS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # BASE RUN + ] + # 'kernel_l': [0.02, 0.05, 0.1, 0.2], + # 'acqui_ucb_alpha': [0.1, 0.3, 0.5, 1.0], + unique_experiments = experiments + n_unique_experiments = len(experiments) + + # Get id's on the permutations + for ix, my_dict in enumerate(experiments): + my_dict["id"] = ix + experiments *=n_runs + + # Save to yaml files + create_yamls(yaml_path=my_yaml_path, + model=yaml_model, + sub_directory=my_sub_directory, + experiments=experiments + ) + + # Create dirs + if not os.path.isdir("output"): + os.mkdir("output") + if not os.path.isdir("output/cpg_boea"): + os.mkdir("output/cpg_boea") + os.mkdir(output_path) + + # Create experiment group directories + for i in range(n_unique_experiments): + os.mkdir(output_path + str(i) + "/") + + while not finished: + with Parallel(n_jobs=n_jobs) as parallel: + # Run experiments in parallel + try: + parallel(delayed(run)(i, + my_sub_directory, + yaml_model, + experiment) for i, experiment in enumerate(experiments)) + except: + print("Some runs are killed by timeout") + + # Count number of finished runs for all experiments. Read this from the parameters file + runs_succesful = {} + experiment_list = glob(output_path + "*/") + + for ix,e in enumerate(experiment_list): + runs = glob(e + "*/") + runs_succesful[str(e.split("/")[-2])] = 0 + + for my_run in runs: + if os.path.isfile(my_run + "fitnesses.txt"): + n_lines = len([(line.rstrip('\n')) for line in open(my_run + "fitnesses.txt")]) + + # In case we had a succesful run + if n_lines > min_lines: + runs_succesful[str(e.split("/")[-2])] += 1 + + to_run = {} + for key, val in runs_succesful.items(): + to_run[key] = n_runs - val + to_run = {k: v for k, v in to_run.items() if v > 0} + + # If the experiment list is empty + if not bool(to_run): + finished = True + else: + print(f"To finish {sum(to_run.values())} runs") + + # Empty experiments list + experiments = [] + + # Use spare computing capacity + while sum(to_run.values()) < n_jobs - len(to_run): + print(to_run) + + for key, value in to_run.items(): + to_run[key] += 1 + + # Construct new experiment list + for key, val in to_run.items(): + for i in range(val): + entry = unique_experiments[int(key)] + experiments.append(entry) + + # START ANALYSIS HERE + print("I will now perform analysis") + + # Do analysis + fitness_list = [] + for i in range(n_unique_experiments): + path = output_path + str(i) + "/*/" + path_list = glob(path) + path_list = [my_path for my_path in path_list if os.path.exists(my_path + "fitnesses.txt")] + n_rows = len([(line.rstrip('\n')) for line in open(path_list[0] + "fitnesses.txt")]) + n_subruns = len(path_list) + + # Working variables + fitnesses = np.empty((n_rows,n_subruns)) + fitnesses_mon = np.empty((n_rows,n_subruns)) + + # Create plot + plt.figure() + plt.title("Monotonic - Param setting " + str(i)) + plt.xlabel("Iteration") + plt.ylabel("Fitness") + plt.grid() + + # Get sub-runs for this setup + for ix, e in enumerate(path_list): + # Read fitness + my_fitness = [float((line.rstrip('\n'))) for line in open(e + "fitnesses.txt")] + + # Transfer fitness to monotonic sequence and save + my_fitness_mon = [e if e >= max(my_fitness[:ix+1]) else max(my_fitness[:ix+1]) for ix, e in enumerate(my_fitness)] + + # Save fitness + fitnesses_mon[:,ix] = np.array(my_fitness_mon) + fitnesses[:,ix] = np.array(my_fitness) + + # Plot the avg fitness + plt.plot(fitnesses_mon[:, ix], linewidth = 1, color = "blue") + + # Take average value over the n_runs + avg_fitness = np.mean(fitnesses, axis=1) + avg_fitness_mon = np.mean(fitnesses_mon, axis=1) + + # Save plot + plt.plot(avg_fitness_mon, linestyle="dashed", linewidth=2.5, color="black") + plt.tight_layout() + plt.savefig(output_path + str(i) + "/" + str(round(avg_fitness_mon[-1], 7)) + ".png") + + # Save fitness + fitness_list += [[round(avg_fitness_mon[-1], 5), i]] + + # Get fitness stats + fitness_list.sort(key=lambda x: x[0]) + fitness_list.reverse() + fitness_list + + print("Fitnesses are:") + for e in fitness_list: + print(e) + e = [str(e_) for e_ in e] + # Write to file in main directory + with open(output_path + '/results.txt', 'a') as avg_fitness_file: + avg_fitness_file.write(",".join(e) + "\n") + + print("Contents written to ", output_path) + + # Delete the yaml's + yaml_temp = my_yaml_path + my_sub_directory + yaml_files = glob(yaml_temp + "*") + for f in yaml_files: + os.remove(f) + + # Write the parameters + params_string =[] + for key, value in iter(search_space.items()): + params_string += [str(key) + ": " + str(value)] + write_file(output_path + "search_space.txt", params_string) diff --git a/experiments/bo_learner/GridSearchBabyA.py b/experiments/bo_learner/GridSearchBabyA.py new file mode 100755 index 0000000000..eb40c26fd7 --- /dev/null +++ b/experiments/bo_learner/GridSearchBabyA.py @@ -0,0 +1,330 @@ +""" + experiments = [ + {'range_ub': 1.0, 'signal_factor_all': 1.0}, + {'range_ub': 1.0, 'signal_factor_all': 3.0}, + {'range_ub': 4.5, 'signal_factor_all': 3.0} + ] +""" +from sys import platform +import matplotlib +if platform == "darwin": + matplotlib.use("TkAgg") +import numpy as np +import itertools +import os +import time +import matplotlib.pyplot as plt +from glob import glob +from joblib import Parallel, delayed + + +# Parameters +min_lines = 1500 +run_gazebo = False +n_runs = 20 # Naar 20 +n_jobs = 4 +my_yaml_path = "experiments/bo_learner/yaml/" +yaml_model = "BabyA.yaml" +manager = "experiments/bo_learner/manager.py" +python_interpreter = "~/snake_workspace/revolve/.venv/bin/python3" +search_space = { + # 'load_brain': ["/Users/lan/projects/revolve/output/cpg_bo/one/main_1560413639/0/0/best_brain.txt"], + 'init_method': ["LHS"], +} + +print(search_space) +# You don't have to change this +my_sub_directory = "yaml_temp/" +output_path = "output/cpg_boea/main_" + str(round(time.time())) + "/" +start_port = 11000 +finished = False + +# Make in revolve/build to allow runs from terminal +os.system('cmake ~/snake_workspace/revolve/ -DCMAKE_BUILD_TYPE="Release"') +os.system("make -j12") + +def change_parameters(original_file, parameters): + # Iterate over dictionary elements + for key, value in iter(parameters.items()): + # Find first occurrence of parameter + ix = [row for row in range(len(original_file)) if key in original_file[row]][0] + + # Change values. Note the Python indentation + original_file[ix] = " " + key + " = " + str(value) + + # Return adapted file: + return original_file + + +def write_file(filename, contents): + # Write back to file + with open(filename, 'w') as file: + # Write updated contents + for line in contents: + file.write((line + "\n")) + file.close() + + +def create_yamls(yaml_path, model, sub_directory, experiments): + # Read original yaml file + yaml_file = [(line.rstrip('\n')) for line in open(yaml_path + model)] + + # Change yaml file + for my_dict in experiments: + # Loop over the entries in this dict + for key, value in my_dict.items(): + if not key == "id": + # Check on what line this parameter is + index = [ix for ix, x in enumerate(yaml_file) if key in x][0] + + yaml_file[index] = " " + key + ": " + str(value) + + # Write yaml file to desired location + write_file(yaml_path + sub_directory + "/" + yaml_model.split(".")[0] + "-" + str(my_dict["id"]) + ".yaml", yaml_file) + + +def run(i, sub_directory, model, params): + # Sleepy time when starting up to save gazebo from misery + if i < n_jobs: + time.sleep(5*i) + else: + print("Todo: Make sure you are leaving 2 seconds in between firing " + "gazebos") + + # Get yaml file id + k = params["id"] + + my_time = str(round(time.time(), 2)) + my_run_path = output_path + str(k) + "/" + my_time + "/" + os.mkdir(my_run_path) + + # Select relevant yaml file + yaml_model = my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + ".yaml" + print(yaml_model) + # Get relevant yaml file + yaml_file = [(line.rstrip('\n')) for line in open(yaml_model)] + + # Change output_directory + index = [ix for ix, x in enumerate(yaml_file) if "output_directory" in x][0] + yaml_file[index] = f' output_directory: "{my_run_path}"' + + # Write temporarily with identifier + write_file(my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + "-" + str(i) + ".yaml", yaml_file) + yaml_model = my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + "-" + str(i) + ".yaml" + + # Change port: We need to do this via the manager + world_address = "127.0.0.1:" + str(start_port + i) + os.environ["GAZEBO_MASTER_URI"] = "http://localhost:" + str(start_port + i) + os.environ["LIBGL_ALWAYS_INDIRECT"] = "0" + py_command = "" + + # Call the experiment + if not run_gazebo: + py_command = python_interpreter + \ + " ./revolve.py" + \ + " --manager " + manager + \ + " --world-address " + world_address + \ + " --robot-yaml " + yaml_model + else: + py_command = python_interpreter + \ + " ./revolve.py" + \ + " --manager " + manager + \ + " --world-address " + world_address + \ + " --robot-yaml " + yaml_model + \ + " --simulator-cmd gazebo" \ + + return_code = os.system(py_command) + if return_code == 32512: + print("Specify a valid python interpreter in the parameters") + + +if __name__ == "__main__": + # Get permutations + keys, values = zip(*search_space.items()) + experiments = [dict(zip(keys, v)) for v in itertools.product(*values)] + + # PASTE THE EXPERIMENTS HERE, IN THE FORMAT SHOWN BELOW + experiments = [ + {'init_method': "LHS"}, + + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.2, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.0, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.1, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.2, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.5, 'acqui_ucb_alpha': 0.5}, + # # BASE RUN + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.1}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.2}, + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 2.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 3.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 4.0}, + # + # {'init_method': "RS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # BASE RUN + ] + # 'kernel_l': [0.02, 0.05, 0.1, 0.2], + # 'acqui_ucb_alpha': [0.1, 0.3, 0.5, 1.0], + unique_experiments = experiments + n_unique_experiments = len(experiments) + + # Get id's on the permutations + for ix, my_dict in enumerate(experiments): + my_dict["id"] = ix + experiments *=n_runs + + # Save to yaml files + create_yamls(yaml_path=my_yaml_path, + model=yaml_model, + sub_directory=my_sub_directory, + experiments=experiments + ) + + # Create dirs + if not os.path.isdir("output"): + os.mkdir("output") + if not os.path.isdir("output/cpg_boea"): + os.mkdir("output/cpg_boea") + os.mkdir(output_path) + + # Create experiment group directories + for i in range(n_unique_experiments): + os.mkdir(output_path + str(i) + "/") + + while not finished: + with Parallel(n_jobs=n_jobs) as parallel: + # Run experiments in parallel + try: + parallel(delayed(run)(i, + my_sub_directory, + yaml_model, + experiment) for i, experiment in enumerate(experiments)) + except: + print("Some runs are killed by timeout") + + # Count number of finished runs for all experiments. Read this from the parameters file + runs_succesful = {} + experiment_list = glob(output_path + "*/") + + for ix,e in enumerate(experiment_list): + runs = glob(e + "*/") + runs_succesful[str(e.split("/")[-2])] = 0 + + for my_run in runs: + if os.path.isfile(my_run + "fitnesses.txt"): + n_lines = len([(line.rstrip('\n')) for line in open(my_run + "fitnesses.txt")]) + + # In case we had a succesful run + if n_lines > min_lines: + runs_succesful[str(e.split("/")[-2])] += 1 + + to_run = {} + for key, val in runs_succesful.items(): + to_run[key] = n_runs - val + to_run = {k: v for k, v in to_run.items() if v > 0} + + # If the experiment list is empty + if not bool(to_run): + finished = True + else: + print(f"To finish {sum(to_run.values())} runs") + + # Empty experiments list + experiments = [] + + # Use spare computing capacity + while sum(to_run.values()) < n_jobs - len(to_run): + print(to_run) + + for key, value in to_run.items(): + to_run[key] += 1 + + # Construct new experiment list + for key, val in to_run.items(): + for i in range(val): + entry = unique_experiments[int(key)] + experiments.append(entry) + + # START ANALYSIS HERE + print("I will now perform analysis") + + # Do analysis + fitness_list = [] + for i in range(n_unique_experiments): + path = output_path + str(i) + "/*/" + path_list = glob(path) + path_list = [my_path for my_path in path_list if os.path.exists(my_path + "fitnesses.txt")] + n_rows = len([(line.rstrip('\n')) for line in open(path_list[0] + "fitnesses.txt")]) + n_subruns = len(path_list) + + # Working variables + fitnesses = np.empty((n_rows,n_subruns)) + fitnesses_mon = np.empty((n_rows,n_subruns)) + + # Create plot + plt.figure() + plt.title("Monotonic - Param setting " + str(i)) + plt.xlabel("Iteration") + plt.ylabel("Fitness") + plt.grid() + + # Get sub-runs for this setup + for ix, e in enumerate(path_list): + # Read fitness + my_fitness = [float((line.rstrip('\n'))) for line in open(e + "fitnesses.txt")] + + # Transfer fitness to monotonic sequence and save + my_fitness_mon = [e if e >= max(my_fitness[:ix+1]) else max(my_fitness[:ix+1]) for ix, e in enumerate(my_fitness)] + + # Save fitness + fitnesses_mon[:,ix] = np.array(my_fitness_mon) + fitnesses[:,ix] = np.array(my_fitness) + + # Plot the avg fitness + plt.plot(fitnesses_mon[:, ix], linewidth = 1, color = "blue") + + # Take average value over the n_runs + avg_fitness = np.mean(fitnesses, axis=1) + avg_fitness_mon = np.mean(fitnesses_mon, axis=1) + + # Save plot + plt.plot(avg_fitness_mon, linestyle="dashed", linewidth=2.5, color="black") + plt.tight_layout() + plt.savefig(output_path + str(i) + "/" + str(round(avg_fitness_mon[-1], 7)) + ".png") + + # Save fitness + fitness_list += [[round(avg_fitness_mon[-1], 5), i]] + + # Get fitness stats + fitness_list.sort(key=lambda x: x[0]) + fitness_list.reverse() + fitness_list + + print("Fitnesses are:") + for e in fitness_list: + print(e) + e = [str(e_) for e_ in e] + # Write to file in main directory + with open(output_path + '/results.txt', 'a') as avg_fitness_file: + avg_fitness_file.write(",".join(e) + "\n") + + print("Contents written to ", output_path) + + # Delete the yaml's + yaml_temp = my_yaml_path + my_sub_directory + yaml_files = glob(yaml_temp + "*") + for f in yaml_files: + os.remove(f) + + # Write the parameters + params_string =[] + for key, value in iter(search_space.items()): + params_string += [str(key) + ": " + str(value)] + write_file(output_path + "search_space.txt", params_string) diff --git a/experiments/bo_learner/GridSearchBabySnake.py b/experiments/bo_learner/GridSearchBabySnake.py new file mode 100755 index 0000000000..5a9dc2e5b3 --- /dev/null +++ b/experiments/bo_learner/GridSearchBabySnake.py @@ -0,0 +1,330 @@ +""" + experiments = [ + {'range_ub': 1.0, 'signal_factor_all': 1.0}, + {'range_ub': 1.0, 'signal_factor_all': 3.0}, + {'range_ub': 4.5, 'signal_factor_all': 3.0} + ] +""" +from sys import platform +import matplotlib +if platform == "darwin": + matplotlib.use("TkAgg") +import numpy as np +import itertools +import os +import time +import matplotlib.pyplot as plt +from glob import glob +from joblib import Parallel, delayed + + +# Parameters +min_lines = 1500 +run_gazebo = False +n_runs = 10 # Naar 20 +n_jobs = 4 +my_yaml_path = "experiments/bo_learner/yaml/" +yaml_model = "babysnake6.yaml" +manager = "experiments/bo_learner/manager.py" +python_interpreter = "~/snake_workspace/revolve/.venv/bin/python3" +search_space = { + # 'load_brain': ["/Users/lan/projects/revolve/output/cpg_bo/one/main_1560413639/0/0/best_brain.txt"], + 'init_method': ["LHS"], +} + +print(search_space) +# You don't have to change this +my_sub_directory = "yaml_temp/" +output_path = "output/cpg_boea/main_" + str(round(time.time())) + "/" +start_port = 17000 +finished = False + +# Make in revolve/build to allow runs from terminal +os.system('cmake ~/snake_workspace/revolve/ -DCMAKE_BUILD_TYPE="Release"') +os.system("make -j4") + +def change_parameters(original_file, parameters): + # Iterate over dictionary elements + for key, value in iter(parameters.items()): + # Find first occurrence of parameter + ix = [row for row in range(len(original_file)) if key in original_file[row]][0] + + # Change values. Note the Python indentation + original_file[ix] = " " + key + " = " + str(value) + + # Return adapted file: + return original_file + + +def write_file(filename, contents): + # Write back to file + with open(filename, 'w') as file: + # Write updated contents + for line in contents: + file.write((line + "\n")) + file.close() + + +def create_yamls(yaml_path, model, sub_directory, experiments): + # Read original yaml file + yaml_file = [(line.rstrip('\n')) for line in open(yaml_path + model)] + + # Change yaml file + for my_dict in experiments: + # Loop over the entries in this dict + for key, value in my_dict.items(): + if not key == "id": + # Check on what line this parameter is + index = [ix for ix, x in enumerate(yaml_file) if key in x][0] + + yaml_file[index] = " " + key + ": " + str(value) + + # Write yaml file to desired location + write_file(yaml_path + sub_directory + "/" + yaml_model.split(".")[0] + "-" + str(my_dict["id"]) + ".yaml", yaml_file) + + +def run(i, sub_directory, model, params): + # Sleepy time when starting up to save gazebo from misery + if i < n_jobs: + time.sleep(5*i) + else: + print("Todo: Make sure you are leaving 2 seconds in between firing " + "gazebos") + + # Get yaml file id + k = params["id"] + + my_time = str(round(time.time(), 2)) + my_run_path = output_path + str(k) + "/" + my_time + "/" + os.mkdir(my_run_path) + + # Select relevant yaml file + yaml_model = my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + ".yaml" + print(yaml_model) + # Get relevant yaml file + yaml_file = [(line.rstrip('\n')) for line in open(yaml_model)] + + # Change output_directory + index = [ix for ix, x in enumerate(yaml_file) if "output_directory" in x][0] + yaml_file[index] = f' output_directory: "{my_run_path}"' + + # Write temporarily with identifier + write_file(my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + "-" + str(i) + ".yaml", yaml_file) + yaml_model = my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + "-" + str(i) + ".yaml" + + # Change port: We need to do this via the manager + world_address = "127.0.0.1:" + str(start_port + i) + os.environ["GAZEBO_MASTER_URI"] = "http://localhost:" + str(start_port + i) + os.environ["LIBGL_ALWAYS_INDIRECT"] = "0" + py_command = "" + + # Call the experiment + if not run_gazebo: + py_command = python_interpreter + \ + " ./revolve.py" + \ + " --manager " + manager + \ + " --world-address " + world_address + \ + " --robot-yaml " + yaml_model + else: + py_command = python_interpreter + \ + " ./revolve.py" + \ + " --manager " + manager + \ + " --world-address " + world_address + \ + " --robot-yaml " + yaml_model + \ + " --simulator-cmd gazebo" \ + + return_code = os.system(py_command) + if return_code == 32512: + print("Specify a valid python interpreter in the parameters") + + +if __name__ == "__main__": + # Get permutations + keys, values = zip(*search_space.items()) + experiments = [dict(zip(keys, v)) for v in itertools.product(*values)] + + # PASTE THE EXPERIMENTS HERE, IN THE FORMAT SHOWN BELOW + experiments = [ + {'init_method': "LHS"}, + + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.2, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.0, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.1, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.2, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.5, 'acqui_ucb_alpha': 0.5}, + # # BASE RUN + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.1}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.2}, + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 2.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 3.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 4.0}, + # + # {'init_method': "RS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # BASE RUN + ] + # 'kernel_l': [0.02, 0.05, 0.1, 0.2], + # 'acqui_ucb_alpha': [0.1, 0.3, 0.5, 1.0], + unique_experiments = experiments + n_unique_experiments = len(experiments) + + # Get id's on the permutations + for ix, my_dict in enumerate(experiments): + my_dict["id"] = ix + experiments *=n_runs + + # Save to yaml files + create_yamls(yaml_path=my_yaml_path, + model=yaml_model, + sub_directory=my_sub_directory, + experiments=experiments + ) + + # Create dirs + if not os.path.isdir("output"): + os.mkdir("output") + if not os.path.isdir("output/cpg_boea"): + os.mkdir("output/cpg_boea") + os.mkdir(output_path) + + # Create experiment group directories + for i in range(n_unique_experiments): + os.mkdir(output_path + str(i) + "/") + + while not finished: + with Parallel(n_jobs=n_jobs) as parallel: + # Run experiments in parallel + try: + parallel(delayed(run)(i, + my_sub_directory, + yaml_model, + experiment) for i, experiment in enumerate(experiments)) + except: + print("Some runs are killed by timeout") + + # Count number of finished runs for all experiments. Read this from the parameters file + runs_succesful = {} + experiment_list = glob(output_path + "*/") + + for ix,e in enumerate(experiment_list): + runs = glob(e + "*/") + runs_succesful[str(e.split("/")[-2])] = 0 + + for my_run in runs: + if os.path.isfile(my_run + "fitnesses.txt"): + n_lines = len([(line.rstrip('\n')) for line in open(my_run + "fitnesses.txt")]) + + # In case we had a succesful run + if n_lines > min_lines: + runs_succesful[str(e.split("/")[-2])] += 1 + + to_run = {} + for key, val in runs_succesful.items(): + to_run[key] = n_runs - val + to_run = {k: v for k, v in to_run.items() if v > 0} + + # If the experiment list is empty + if not bool(to_run): + finished = True + else: + print(f"To finish {sum(to_run.values())} runs") + + # Empty experiments list + experiments = [] + + # Use spare computing capacity + while sum(to_run.values()) < n_jobs - len(to_run): + print(to_run) + + for key, value in to_run.items(): + to_run[key] += 1 + + # Construct new experiment list + for key, val in to_run.items(): + for i in range(val): + entry = unique_experiments[int(key)] + experiments.append(entry) + + # START ANALYSIS HERE + print("I will now perform analysis") + + # Do analysis + fitness_list = [] + for i in range(n_unique_experiments): + path = output_path + str(i) + "/*/" + path_list = glob(path) + path_list = [my_path for my_path in path_list if os.path.exists(my_path + "fitnesses.txt")] + n_rows = len([(line.rstrip('\n')) for line in open(path_list[0] + "fitnesses.txt")]) + n_subruns = len(path_list) + + # Working variables + fitnesses = np.empty((n_rows,n_subruns)) + fitnesses_mon = np.empty((n_rows,n_subruns)) + + # Create plot + plt.figure() + plt.title("Monotonic - Param setting " + str(i)) + plt.xlabel("Iteration") + plt.ylabel("Fitness") + plt.grid() + + # Get sub-runs for this setup + for ix, e in enumerate(path_list): + # Read fitness + my_fitness = [float((line.rstrip('\n'))) for line in open(e + "fitnesses.txt")] + + # Transfer fitness to monotonic sequence and save + my_fitness_mon = [e if e >= max(my_fitness[:ix+1]) else max(my_fitness[:ix+1]) for ix, e in enumerate(my_fitness)] + + # Save fitness + fitnesses_mon[:,ix] = np.array(my_fitness_mon) + fitnesses[:,ix] = np.array(my_fitness) + + # Plot the avg fitness + plt.plot(fitnesses_mon[:, ix], linewidth = 1, color = "blue") + + # Take average value over the n_runs + avg_fitness = np.mean(fitnesses, axis=1) + avg_fitness_mon = np.mean(fitnesses_mon, axis=1) + + # Save plot + plt.plot(avg_fitness_mon, linestyle="dashed", linewidth=2.5, color="black") + plt.tight_layout() + plt.savefig(output_path + str(i) + "/" + str(round(avg_fitness_mon[-1], 7)) + ".png") + + # Save fitness + fitness_list += [[round(avg_fitness_mon[-1], 5), i]] + + # Get fitness stats + fitness_list.sort(key=lambda x: x[0]) + fitness_list.reverse() + fitness_list + + print("Fitnesses are:") + for e in fitness_list: + print(e) + e = [str(e_) for e_ in e] + # Write to file in main directory + with open(output_path + '/results.txt', 'a') as avg_fitness_file: + avg_fitness_file.write(",".join(e) + "\n") + + print("Contents written to ", output_path) + + # Delete the yaml's + yaml_temp = my_yaml_path + my_sub_directory + yaml_files = glob(yaml_temp + "*") + for f in yaml_files: + os.remove(f) + + # Write the parameters + params_string =[] + for key, value in iter(search_space.items()): + params_string += [str(key) + ": " + str(value)] + write_file(output_path + "search_space.txt", params_string) diff --git a/experiments/bo_learner/GridSearchGecko.py b/experiments/bo_learner/GridSearchGecko.py new file mode 100755 index 0000000000..c80444d3ec --- /dev/null +++ b/experiments/bo_learner/GridSearchGecko.py @@ -0,0 +1,330 @@ +""" + experiments = [ + {'range_ub': 1.0, 'signal_factor_all': 1.0}, + {'range_ub': 1.0, 'signal_factor_all': 3.0}, + {'range_ub': 4.5, 'signal_factor_all': 3.0} + ] +""" +from sys import platform +import matplotlib +if platform == "darwin": + matplotlib.use("TkAgg") +import numpy as np +import itertools +import os +import time +import matplotlib.pyplot as plt +from glob import glob +from joblib import Parallel, delayed + + +# Parameters +min_lines = 1500 +run_gazebo = False +n_runs = 20 # Naar 20 +n_jobs = 4 +my_yaml_path = "experiments/bo_learner/yaml/" +yaml_model = "gecko7.yaml" +manager = "experiments/bo_learner/manager.py" +python_interpreter = "~/snake_workspace/revolve/.venv/bin/python3" +search_space = { + # 'load_brain': ["/Users/lan/projects/revolve/output/cpg_bo/one/main_1560413639/0/0/best_brain.txt"], + 'init_method': ["LHS"], +} + +print(search_space) +# You don't have to change this +my_sub_directory = "yaml_temp/" +output_path = "output/cpg_boea/main_" + str(round(time.time())) + "/" +start_port = 12000 +finished = False + +# Make in revolve/build to allow runs from terminal +os.system('cmake ~/snake_workspace/revolve/ -DCMAKE_BUILD_TYPE="Release"') +os.system("make -j12") + +def change_parameters(original_file, parameters): + # Iterate over dictionary elements + for key, value in iter(parameters.items()): + # Find first occurrence of parameter + ix = [row for row in range(len(original_file)) if key in original_file[row]][0] + + # Change values. Note the Python indentation + original_file[ix] = " " + key + " = " + str(value) + + # Return adapted file: + return original_file + + +def write_file(filename, contents): + # Write back to file + with open(filename, 'w') as file: + # Write updated contents + for line in contents: + file.write((line + "\n")) + file.close() + + +def create_yamls(yaml_path, model, sub_directory, experiments): + # Read original yaml file + yaml_file = [(line.rstrip('\n')) for line in open(yaml_path + model)] + + # Change yaml file + for my_dict in experiments: + # Loop over the entries in this dict + for key, value in my_dict.items(): + if not key == "id": + # Check on what line this parameter is + index = [ix for ix, x in enumerate(yaml_file) if key in x][0] + + yaml_file[index] = " " + key + ": " + str(value) + + # Write yaml file to desired location + write_file(yaml_path + sub_directory + "/" + yaml_model.split(".")[0] + "-" + str(my_dict["id"]) + ".yaml", yaml_file) + + +def run(i, sub_directory, model, params): + # Sleepy time when starting up to save gazebo from misery + if i < n_jobs: + time.sleep(5*i) + else: + print("Todo: Make sure you are leaving 2 seconds in between firing " + "gazebos") + + # Get yaml file id + k = params["id"] + + my_time = str(round(time.time(), 2)) + my_run_path = output_path + str(k) + "/" + my_time + "/" + os.mkdir(my_run_path) + + # Select relevant yaml file + yaml_model = my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + ".yaml" + print(yaml_model) + # Get relevant yaml file + yaml_file = [(line.rstrip('\n')) for line in open(yaml_model)] + + # Change output_directory + index = [ix for ix, x in enumerate(yaml_file) if "output_directory" in x][0] + yaml_file[index] = f' output_directory: "{my_run_path}"' + + # Write temporarily with identifier + write_file(my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + "-" + str(i) + ".yaml", yaml_file) + yaml_model = my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + "-" + str(i) + ".yaml" + + # Change port: We need to do this via the manager + world_address = "127.0.0.1:" + str(start_port + i) + os.environ["GAZEBO_MASTER_URI"] = "http://localhost:" + str(start_port + i) + os.environ["LIBGL_ALWAYS_INDIRECT"] = "0" + py_command = "" + + # Call the experiment + if not run_gazebo: + py_command = python_interpreter + \ + " ./revolve.py" + \ + " --manager " + manager + \ + " --world-address " + world_address + \ + " --robot-yaml " + yaml_model + else: + py_command = python_interpreter + \ + " ./revolve.py" + \ + " --manager " + manager + \ + " --world-address " + world_address + \ + " --robot-yaml " + yaml_model + \ + " --simulator-cmd gazebo" \ + + return_code = os.system(py_command) + if return_code == 32512: + print("Specify a valid python interpreter in the parameters") + + +if __name__ == "__main__": + # Get permutations + keys, values = zip(*search_space.items()) + experiments = [dict(zip(keys, v)) for v in itertools.product(*values)] + + # PASTE THE EXPERIMENTS HERE, IN THE FORMAT SHOWN BELOW + experiments = [ + {'init_method': "LHS"}, + + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.2, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.0, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.1, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.2, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.5, 'acqui_ucb_alpha': 0.5}, + # # BASE RUN + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.1}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.2}, + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 2.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 3.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 4.0}, + # + # {'init_method': "RS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # BASE RUN + ] + # 'kernel_l': [0.02, 0.05, 0.1, 0.2], + # 'acqui_ucb_alpha': [0.1, 0.3, 0.5, 1.0], + unique_experiments = experiments + n_unique_experiments = len(experiments) + + # Get id's on the permutations + for ix, my_dict in enumerate(experiments): + my_dict["id"] = ix + experiments *=n_runs + + # Save to yaml files + create_yamls(yaml_path=my_yaml_path, + model=yaml_model, + sub_directory=my_sub_directory, + experiments=experiments + ) + + # Create dirs + if not os.path.isdir("output"): + os.mkdir("output") + if not os.path.isdir("output/cpg_boea"): + os.mkdir("output/cpg_boea") + os.mkdir(output_path) + + # Create experiment group directories + for i in range(n_unique_experiments): + os.mkdir(output_path + str(i) + "/") + + while not finished: + with Parallel(n_jobs=n_jobs) as parallel: + # Run experiments in parallel + try: + parallel(delayed(run)(i, + my_sub_directory, + yaml_model, + experiment) for i, experiment in enumerate(experiments)) + except: + print("Some runs are killed by timeout") + + # Count number of finished runs for all experiments. Read this from the parameters file + runs_succesful = {} + experiment_list = glob(output_path + "*/") + + for ix,e in enumerate(experiment_list): + runs = glob(e + "*/") + runs_succesful[str(e.split("/")[-2])] = 0 + + for my_run in runs: + if os.path.isfile(my_run + "fitnesses.txt"): + n_lines = len([(line.rstrip('\n')) for line in open(my_run + "fitnesses.txt")]) + + # In case we had a succesful run + if n_lines > min_lines: + runs_succesful[str(e.split("/")[-2])] += 1 + + to_run = {} + for key, val in runs_succesful.items(): + to_run[key] = n_runs - val + to_run = {k: v for k, v in to_run.items() if v > 0} + + # If the experiment list is empty + if not bool(to_run): + finished = True + else: + print(f"To finish {sum(to_run.values())} runs") + + # Empty experiments list + experiments = [] + + # Use spare computing capacity + while sum(to_run.values()) < n_jobs - len(to_run): + print(to_run) + + for key, value in to_run.items(): + to_run[key] += 1 + + # Construct new experiment list + for key, val in to_run.items(): + for i in range(val): + entry = unique_experiments[int(key)] + experiments.append(entry) + + # START ANALYSIS HERE + print("I will now perform analysis") + + # Do analysis + fitness_list = [] + for i in range(n_unique_experiments): + path = output_path + str(i) + "/*/" + path_list = glob(path) + path_list = [my_path for my_path in path_list if os.path.exists(my_path + "fitnesses.txt")] + n_rows = len([(line.rstrip('\n')) for line in open(path_list[0] + "fitnesses.txt")]) + n_subruns = len(path_list) + + # Working variables + fitnesses = np.empty((n_rows,n_subruns)) + fitnesses_mon = np.empty((n_rows,n_subruns)) + + # Create plot + plt.figure() + plt.title("Monotonic - Param setting " + str(i)) + plt.xlabel("Iteration") + plt.ylabel("Fitness") + plt.grid() + + # Get sub-runs for this setup + for ix, e in enumerate(path_list): + # Read fitness + my_fitness = [float((line.rstrip('\n'))) for line in open(e + "fitnesses.txt")] + + # Transfer fitness to monotonic sequence and save + my_fitness_mon = [e if e >= max(my_fitness[:ix+1]) else max(my_fitness[:ix+1]) for ix, e in enumerate(my_fitness)] + + # Save fitness + fitnesses_mon[:,ix] = np.array(my_fitness_mon) + fitnesses[:,ix] = np.array(my_fitness) + + # Plot the avg fitness + plt.plot(fitnesses_mon[:, ix], linewidth = 1, color = "blue") + + # Take average value over the n_runs + avg_fitness = np.mean(fitnesses, axis=1) + avg_fitness_mon = np.mean(fitnesses_mon, axis=1) + + # Save plot + plt.plot(avg_fitness_mon, linestyle="dashed", linewidth=2.5, color="black") + plt.tight_layout() + plt.savefig(output_path + str(i) + "/" + str(round(avg_fitness_mon[-1], 7)) + ".png") + + # Save fitness + fitness_list += [[round(avg_fitness_mon[-1], 5), i]] + + # Get fitness stats + fitness_list.sort(key=lambda x: x[0]) + fitness_list.reverse() + fitness_list + + print("Fitnesses are:") + for e in fitness_list: + print(e) + e = [str(e_) for e_ in e] + # Write to file in main directory + with open(output_path + '/results.txt', 'a') as avg_fitness_file: + avg_fitness_file.write(",".join(e) + "\n") + + print("Contents written to ", output_path) + + # Delete the yaml's + yaml_temp = my_yaml_path + my_sub_directory + yaml_files = glob(yaml_temp + "*") + for f in yaml_files: + os.remove(f) + + # Write the parameters + params_string =[] + for key, value in iter(search_space.items()): + params_string += [str(key) + ": " + str(value)] + write_file(output_path + "search_space.txt", params_string) diff --git a/experiments/bo_learner/GridSearchSpider.py b/experiments/bo_learner/GridSearchSpider.py new file mode 100755 index 0000000000..5f5ceb4255 --- /dev/null +++ b/experiments/bo_learner/GridSearchSpider.py @@ -0,0 +1,330 @@ +""" + experiments = [ + {'range_ub': 1.0, 'signal_factor_all': 1.0}, + {'range_ub': 1.0, 'signal_factor_all': 3.0}, + {'range_ub': 4.5, 'signal_factor_all': 3.0} + ] +""" +from sys import platform +import matplotlib +if platform == "darwin": + matplotlib.use("TkAgg") +import numpy as np +import itertools +import os +import time +import matplotlib.pyplot as plt +from glob import glob +from joblib import Parallel, delayed + + +# Parameters +min_lines = 1500 +run_gazebo = False +n_runs = 20 # Naar 20 +n_jobs = 4 +my_yaml_path = "experiments/bo_learner/yaml/" +yaml_model = "spider9.yaml" +manager = "experiments/bo_learner/manager.py" +python_interpreter = "~/snake_workspace/revolve/.venv/bin/python3" +search_space = { + # 'load_brain': ["/Users/lan/projects/revolve/output/cpg_bo/one/main_1560413639/0/0/best_brain.txt"], + 'init_method': ["LHS"], +} + +print(search_space) +# You don't have to change this +my_sub_directory = "yaml_temp/" +output_path = "output/cpg_boea/main_" + str(round(time.time())) + "/" +start_port = 13000 +finished = False + +# Make in revolve/build to allow runs from terminal +os.system('cmake ~/snake_workspace/revolve/ -DCMAKE_BUILD_TYPE="Release"') +os.system("make -j12") + +def change_parameters(original_file, parameters): + # Iterate over dictionary elements + for key, value in iter(parameters.items()): + # Find first occurrence of parameter + ix = [row for row in range(len(original_file)) if key in original_file[row]][0] + + # Change values. Note the Python indentation + original_file[ix] = " " + key + " = " + str(value) + + # Return adapted file: + return original_file + + +def write_file(filename, contents): + # Write back to file + with open(filename, 'w') as file: + # Write updated contents + for line in contents: + file.write((line + "\n")) + file.close() + + +def create_yamls(yaml_path, model, sub_directory, experiments): + # Read original yaml file + yaml_file = [(line.rstrip('\n')) for line in open(yaml_path + model)] + + # Change yaml file + for my_dict in experiments: + # Loop over the entries in this dict + for key, value in my_dict.items(): + if not key == "id": + # Check on what line this parameter is + index = [ix for ix, x in enumerate(yaml_file) if key in x][0] + + yaml_file[index] = " " + key + ": " + str(value) + + # Write yaml file to desired location + write_file(yaml_path + sub_directory + "/" + yaml_model.split(".")[0] + "-" + str(my_dict["id"]) + ".yaml", yaml_file) + + +def run(i, sub_directory, model, params): + # Sleepy time when starting up to save gazebo from misery + if i < n_jobs: + time.sleep(5*i) + else: + print("Todo: Make sure you are leaving 2 seconds in between firing " + "gazebos") + + # Get yaml file id + k = params["id"] + + my_time = str(round(time.time(), 2)) + my_run_path = output_path + str(k) + "/" + my_time + "/" + os.mkdir(my_run_path) + + # Select relevant yaml file + yaml_model = my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + ".yaml" + print(yaml_model) + # Get relevant yaml file + yaml_file = [(line.rstrip('\n')) for line in open(yaml_model)] + + # Change output_directory + index = [ix for ix, x in enumerate(yaml_file) if "output_directory" in x][0] + yaml_file[index] = f' output_directory: "{my_run_path}"' + + # Write temporarily with identifier + write_file(my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + "-" + str(i) + ".yaml", yaml_file) + yaml_model = my_yaml_path + sub_directory + model.split(".yaml")[0] + "-" + str(k) + "-" + str(i) + ".yaml" + + # Change port: We need to do this via the manager + world_address = "127.0.0.1:" + str(start_port + i) + os.environ["GAZEBO_MASTER_URI"] = "http://localhost:" + str(start_port + i) + os.environ["LIBGL_ALWAYS_INDIRECT"] = "0" + py_command = "" + + # Call the experiment + if not run_gazebo: + py_command = python_interpreter + \ + " ./revolve.py" + \ + " --manager " + manager + \ + " --world-address " + world_address + \ + " --robot-yaml " + yaml_model + else: + py_command = python_interpreter + \ + " ./revolve.py" + \ + " --manager " + manager + \ + " --world-address " + world_address + \ + " --robot-yaml " + yaml_model + \ + " --simulator-cmd gazebo" \ + + return_code = os.system(py_command) + if return_code == 32512: + print("Specify a valid python interpreter in the parameters") + + +if __name__ == "__main__": + # Get permutations + keys, values = zip(*search_space.items()) + experiments = [dict(zip(keys, v)) for v in itertools.product(*values)] + + # PASTE THE EXPERIMENTS HERE, IN THE FORMAT SHOWN BELOW + experiments = [ + {'init_method': "LHS"}, + + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.2, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.0, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 1.5, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.1, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.2, 'acqui_ucb_alpha': 0.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 0.5, 'acqui_ucb_alpha': 0.5}, + # # BASE RUN + # + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.1}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.2}, + # # BASE RUN + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 1.5}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 2.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 3.0}, + # {'init_method': "LHS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 4.0}, + # + # {'init_method': "RS", 'kernel_l': 0.1, 'kernel_sigma_sq': 1.0, 'acqui_ucb_alpha': 0.5}, + # BASE RUN + ] + # 'kernel_l': [0.02, 0.05, 0.1, 0.2], + # 'acqui_ucb_alpha': [0.1, 0.3, 0.5, 1.0], + unique_experiments = experiments + n_unique_experiments = len(experiments) + + # Get id's on the permutations + for ix, my_dict in enumerate(experiments): + my_dict["id"] = ix + experiments *=n_runs + + # Save to yaml files + create_yamls(yaml_path=my_yaml_path, + model=yaml_model, + sub_directory=my_sub_directory, + experiments=experiments + ) + + # Create dirs + if not os.path.isdir("output"): + os.mkdir("output") + if not os.path.isdir("output/cpg_boea"): + os.mkdir("output/cpg_boea") + os.mkdir(output_path) + + # Create experiment group directories + for i in range(n_unique_experiments): + os.mkdir(output_path + str(i) + "/") + + while not finished: + with Parallel(n_jobs=n_jobs) as parallel: + # Run experiments in parallel + try: + parallel(delayed(run)(i, + my_sub_directory, + yaml_model, + experiment) for i, experiment in enumerate(experiments)) + except: + print("Some runs are killed by timeout") + + # Count number of finished runs for all experiments. Read this from the parameters file + runs_succesful = {} + experiment_list = glob(output_path + "*/") + + for ix,e in enumerate(experiment_list): + runs = glob(e + "*/") + runs_succesful[str(e.split("/")[-2])] = 0 + + for my_run in runs: + if os.path.isfile(my_run + "fitnesses.txt"): + n_lines = len([(line.rstrip('\n')) for line in open(my_run + "fitnesses.txt")]) + + # In case we had a succesful run + if n_lines > min_lines: + runs_succesful[str(e.split("/")[-2])] += 1 + + to_run = {} + for key, val in runs_succesful.items(): + to_run[key] = n_runs - val + to_run = {k: v for k, v in to_run.items() if v > 0} + + # If the experiment list is empty + if not bool(to_run): + finished = True + else: + print(f"To finish {sum(to_run.values())} runs") + + # Empty experiments list + experiments = [] + + # Use spare computing capacity + while sum(to_run.values()) < n_jobs - len(to_run): + print(to_run) + + for key, value in to_run.items(): + to_run[key] += 1 + + # Construct new experiment list + for key, val in to_run.items(): + for i in range(val): + entry = unique_experiments[int(key)] + experiments.append(entry) + + # START ANALYSIS HERE + print("I will now perform analysis") + + # Do analysis + fitness_list = [] + for i in range(n_unique_experiments): + path = output_path + str(i) + "/*/" + path_list = glob(path) + path_list = [my_path for my_path in path_list if os.path.exists(my_path + "fitnesses.txt")] + n_rows = len([(line.rstrip('\n')) for line in open(path_list[0] + "fitnesses.txt")]) + n_subruns = len(path_list) + + # Working variables + fitnesses = np.empty((n_rows,n_subruns)) + fitnesses_mon = np.empty((n_rows,n_subruns)) + + # Create plot + plt.figure() + plt.title("Monotonic - Param setting " + str(i)) + plt.xlabel("Iteration") + plt.ylabel("Fitness") + plt.grid() + + # Get sub-runs for this setup + for ix, e in enumerate(path_list): + # Read fitness + my_fitness = [float((line.rstrip('\n'))) for line in open(e + "fitnesses.txt")] + + # Transfer fitness to monotonic sequence and save + my_fitness_mon = [e if e >= max(my_fitness[:ix+1]) else max(my_fitness[:ix+1]) for ix, e in enumerate(my_fitness)] + + # Save fitness + fitnesses_mon[:,ix] = np.array(my_fitness_mon) + fitnesses[:,ix] = np.array(my_fitness) + + # Plot the avg fitness + plt.plot(fitnesses_mon[:, ix], linewidth = 1, color = "blue") + + # Take average value over the n_runs + avg_fitness = np.mean(fitnesses, axis=1) + avg_fitness_mon = np.mean(fitnesses_mon, axis=1) + + # Save plot + plt.plot(avg_fitness_mon, linestyle="dashed", linewidth=2.5, color="black") + plt.tight_layout() + plt.savefig(output_path + str(i) + "/" + str(round(avg_fitness_mon[-1], 7)) + ".png") + + # Save fitness + fitness_list += [[round(avg_fitness_mon[-1], 5), i]] + + # Get fitness stats + fitness_list.sort(key=lambda x: x[0]) + fitness_list.reverse() + fitness_list + + print("Fitnesses are:") + for e in fitness_list: + print(e) + e = [str(e_) for e_ in e] + # Write to file in main directory + with open(output_path + '/results.txt', 'a') as avg_fitness_file: + avg_fitness_file.write(",".join(e) + "\n") + + print("Contents written to ", output_path) + + # Delete the yaml's + yaml_temp = my_yaml_path + my_sub_directory + yaml_files = glob(yaml_temp + "*") + for f in yaml_files: + os.remove(f) + + # Write the parameters + params_string =[] + for key, value in iter(search_space.items()): + params_string += [str(key) + ": " + str(value)] + write_file(output_path + "search_space.txt", params_string) diff --git a/experiments/bo_learner/manager.py b/experiments/bo_learner/manager.py index f37fe45584..43f644b6ac 100755 --- a/experiments/bo_learner/manager.py +++ b/experiments/bo_learner/manager.py @@ -26,7 +26,7 @@ async def run(): # Load a robot from yaml robot = revolve_bot.RevolveBot() if settings.robot_yaml is None: - robot.load_file("experiments/bo_learner/yaml/spider.yaml") + robot.load_file("nihedssnake6.yaml") else: robot.load_file(settings.robot_yaml) robot.update_substrate() diff --git a/experiments/bo_learner/run_get_analytics.py b/experiments/bo_learner/run_get_analytics.py index c48c90fa6e..f411c272cb 100644 --- a/experiments/bo_learner/run_get_analytics.py +++ b/experiments/bo_learner/run_get_analytics.py @@ -1,8 +1,8 @@ from glob import glob import os -python_interpreter = "/home/maarten/CLionProjects/revolve/venv/bin/python" -path = "/home/maarten/CLionProjects/revolve/output/cpg_bo/main_1557477606/47/" +python_interpreter = "/Users/lan/projects/revolve/venv/bin/python" +path = "/Users/lan/projects/revolve/output/cpg_bo/main_1557477606/47/" paths = glob(path + "*/") diff --git a/experiments/bo_learner/yaml/babyA.yaml b/experiments/bo_learner/yaml/babyA.yaml index 6ee67bdc64..aee5e44ca8 100644 --- a/experiments/bo_learner/yaml/babyA.yaml +++ b/experiments/bo_learner/yaml/babyA.yaml @@ -4,9 +4,9 @@ body: id : Core type : Core params: - red: 0.04 - green: 0.26 - blue: 0.72 + red: 0.98 + green: 0.98 + blue: 0.98 children : 1: slot : 0 @@ -24,8 +24,8 @@ body: type : FixedBrick params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 orientation : -90 children : 1: @@ -44,8 +44,8 @@ body: type : FixedBrick params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 orientation : -90 children: 2: @@ -64,8 +64,8 @@ body: type : FixedBrick params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 orientation : 0 3: slot : 0 @@ -83,8 +83,8 @@ body: type : FixedBrick params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 orientation : 0 2: slot : 0 @@ -102,8 +102,8 @@ body: type : FixedBrick params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 orientation : 0 3: slot : 0 @@ -163,28 +163,31 @@ brain: signal_factor_all: 4.0 signal_factor_mid: 2.5 signal_factor_left_right: 2.5 - range_lb: -1.0 + range_lb: -1.5 range_ub: 1.5 init_neuron_state: 0.707 learner: - n_init_samples: 50 + n_init_samples: 10 init_method: "LHS" kernel_noise: 0.00000001 kernel_optimize_noise: "false" - kernel_sigma_sq: 0.222 - kernel_l: 0.55 + kernel_sigma_sq: 1.0 + kernel_l: 0.2 kernel_squared_exp_ard_k: 4 acqui_gpucb_delta: 0.5 - acqui_ucb_alpha: 0.44 + acqui_ucb_alpha: 3.0 acqui_ei_jitter: 0 acquisition_function: "UCB" + gaussian_step_size: 0.3 + covrate: 0.4 + mutrate: 0.6 meta: - robot_size: 26 - run_analytics: "true" - n_learning_iterations: 1450 - n_cooldown_iterations: 1 + robot_size: 16 + run_analytics: "false" + n_learning_iterations: 1500 + n_cooldown_iterations: 0 reset_robot_position: "false" - evaluation_rate: 60 + evaluation_rate: 30 output_directory: "" - verbose: 0 + verbose: 1 startup_time: 0 diff --git a/experiments/bo_learner/yaml/babyB.yaml b/experiments/bo_learner/yaml/babyB.yaml index 1144e9f64f..e4e7104f4d 100644 --- a/experiments/bo_learner/yaml/babyB.yaml +++ b/experiments/bo_learner/yaml/babyB.yaml @@ -203,20 +203,20 @@ brain: init_method: "LHS" kernel_noise: 0.00000001 kernel_optimize_noise: "false" - kernel_sigma_sq: 0.222 - kernel_l: 0.55 + kernel_sigma_sq: 1.0 + kernel_l: 0.2 kernel_squared_exp_ard_k: 4 acqui_gpucb_delta: 0.5 - acqui_ucb_alpha: 0.44 + acqui_ucb_alpha: 3.0 acqui_ei_jitter: 0 acquisition_function: "UCB" meta: - robot_size: 26 - run_analytics: "true" + robot_size: 22 + run_analytics: "false" n_learning_iterations: 1450 - n_cooldown_iterations: 1 + n_cooldown_iterations: 0 reset_robot_position: "false" - evaluation_rate: 60 + evaluation_rate: 30 output_directory: "" - verbose: 0 + verbose: 1 startup_time: 0 diff --git a/experiments/bo_learner/yaml/babyC.yaml b/experiments/bo_learner/yaml/babyC.yaml index 07b15884af..f98c7112f0 100644 --- a/experiments/bo_learner/yaml/babyC.yaml +++ b/experiments/bo_learner/yaml/babyC.yaml @@ -309,7 +309,7 @@ brain: signal_factor_all: 4.0 signal_factor_mid: 2.5 signal_factor_left_right: 2.5 - range_lb: -1.0 + range_lb: -1.5 range_ub: 1.5 init_neuron_state: 0.707 learner: @@ -317,20 +317,20 @@ brain: init_method: "LHS" kernel_noise: 0.00000001 kernel_optimize_noise: "false" - kernel_sigma_sq: 0.222 - kernel_l: 0.55 + kernel_sigma_sq: 1.0 + kernel_l: 0.2 kernel_squared_exp_ard_k: 4 acqui_gpucb_delta: 0.5 - acqui_ucb_alpha: 0.44 + acqui_ucb_alpha: 3.0 acqui_ei_jitter: 0 acquisition_function: "UCB" meta: - robot_size: 26 - run_analytics: "true" + robot_size: 32 + run_analytics: "false" n_learning_iterations: 1450 n_cooldown_iterations: 1 reset_robot_position: "false" - evaluation_rate: 60 + evaluation_rate: 30 output_directory: "" - verbose: 0 + verbose: 1 startup_time: 0 diff --git a/experiments/bo_learner/yaml/babysnake6.yaml b/experiments/bo_learner/yaml/babysnake6.yaml new file mode 100644 index 0000000000..f92d269fcd --- /dev/null +++ b/experiments/bo_learner/yaml/babysnake6.yaml @@ -0,0 +1,158 @@ +--- +id: nihedsnake6 +body: + id : Core + type : Core + params: + red: 0.94 + green: 0.98 + blue: 0.05 + children : + 0: + id : Leg00Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg00 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children : + 1: + id : Leg02Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg02 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + children : + 1: + id : Leg03Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg03 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children: + 1: + id : Leg04Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg04 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + children : + 1: + id : Leg05Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg05 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children: + 1: + id : Leg06Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg06 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + + + + + +brain: + type: bo-cpg + controller: + use_frame_of_reference: 0 + load_brain: "" + reset_neuron_state_bool: "true" + reset_neuron_random: "false" + abs_output_bound: 1.0 + signal_factor_all: 4.0 + signal_factor_mid: 2.5 + signal_factor_left_right: 2.5 + range_lb: -1.5 + range_ub: 1.5 + init_neuron_state: 0.707 + learner: + n_init_samples: 10 + init_method: "LHS" + kernel_noise: 0.00000001 + kernel_optimize_noise: "false" + kernel_sigma_sq: 1.0 + kernel_l: 0.2 + kernel_squared_exp_ard_k: 4 + acqui_gpucb_delta: 0.5 + acqui_ucb_alpha: 3.0 + acqui_ei_jitter: 0 + acquisition_function: "UCB" + covrate: 0.7 + mutrate: 0.8 + gaussian_step_size: 0.3 + meta: + robot_size: 13 + run_analytics: "false" + n_learning_iterations: 30 + n_cooldown_iterations: 0 + reset_robot_position: "false" + evaluation_rate: 30 + output_directory: "" + verbose: 1 + startup_time: 0 diff --git a/experiments/bo_learner/yaml/gecko12.yaml b/experiments/bo_learner/yaml/gecko12.yaml index bb6dfaaeab..f6209fd37a 100644 --- a/experiments/bo_learner/yaml/gecko12.yaml +++ b/experiments/bo_learner/yaml/gecko12.yaml @@ -226,7 +226,7 @@ brain: signal_factor_all: 4.0 signal_factor_mid: 2.5 signal_factor_left_right: 2.5 - range_lb: -1.0 + range_lb: -1.5 range_ub: 1.5 init_neuron_state: 0.707 learner: @@ -234,20 +234,20 @@ brain: init_method: "LHS" kernel_noise: 0.00000001 kernel_optimize_noise: "false" - kernel_sigma_sq: 0.222 - kernel_l: 0.55 + kernel_sigma_sq: 2.0 + kernel_l: 0.2 kernel_squared_exp_ard_k: 4 acqui_gpucb_delta: 0.5 - acqui_ucb_alpha: 0.44 + acqui_ucb_alpha: 3.0 acqui_ei_jitter: 0 acquisition_function: "UCB" meta: - robot_size: 26 - run_analytics: "true" + robot_size: 23 + run_analytics: "false" n_learning_iterations: 1450 - n_cooldown_iterations: 1 + n_cooldown_iterations: 0 reset_robot_position: "false" - evaluation_rate: 60 + evaluation_rate: 30 output_directory: "" - verbose: 0 + verbose: 1 startup_time: 0 diff --git a/experiments/bo_learner/yaml/gecko17.yaml b/experiments/bo_learner/yaml/gecko17.yaml index 1c32cf0ede..092a7b77d5 100644 --- a/experiments/bo_learner/yaml/gecko17.yaml +++ b/experiments/bo_learner/yaml/gecko17.yaml @@ -318,7 +318,7 @@ brain: signal_factor_all: 4.0 signal_factor_mid: 2.5 signal_factor_left_right: 2.5 - range_lb: -1.0 + range_lb: -1.5 range_ub: 1.5 init_neuron_state: 0.707 learner: @@ -334,12 +334,12 @@ brain: acqui_ei_jitter: 0 acquisition_function: "UCB" meta: - robot_size: 26 - run_analytics: "true" + robot_size: 33 + run_analytics: "false" n_learning_iterations: 1450 - n_cooldown_iterations: 1 + n_cooldown_iterations: 0 reset_robot_position: "false" - evaluation_rate: 60 + evaluation_rate: 30 output_directory: "" - verbose: 0 + verbose: 1 startup_time: 0 diff --git a/experiments/bo_learner/yaml/gecko7.yaml b/experiments/bo_learner/yaml/gecko7.yaml index 00b3eee25e..969f40d013 100644 --- a/experiments/bo_learner/yaml/gecko7.yaml +++ b/experiments/bo_learner/yaml/gecko7.yaml @@ -5,8 +5,8 @@ body: type : Core params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 children : 2: slot : 0 @@ -24,8 +24,8 @@ body: type : FixedBrick params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 orientation : 0 3: slot : 0 @@ -43,8 +43,8 @@ body: type : FixedBrick params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 orientation : 0 1: slot : 0 @@ -62,8 +62,8 @@ body: type : FixedBrick params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 orientation : -90 children : 1: @@ -82,8 +82,8 @@ body: type : FixedBrick params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 orientation : -90 children: 2: @@ -102,8 +102,8 @@ body: type : FixedBrick params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 orientation : 0 3: slot : 0 @@ -121,8 +121,8 @@ body: type : FixedBrick params: red: 0.04 - green: 0.26 - blue: 0.72 + green: 0.98 + blue: 0.04 orientation : 0 brain: type: bo-cpg @@ -135,7 +135,7 @@ brain: signal_factor_all: 4.0 signal_factor_mid: 2.5 signal_factor_left_right: 2.5 - range_lb: -1.0 + range_lb: -1.5 range_ub: 1.5 init_neuron_state: 0.707 learner: @@ -143,20 +143,20 @@ brain: init_method: "LHS" kernel_noise: 0.00000001 kernel_optimize_noise: "false" - kernel_sigma_sq: 0.222 - kernel_l: 0.55 + kernel_sigma_sq: 1.0 + kernel_l: 0.2 kernel_squared_exp_ard_k: 4 acqui_gpucb_delta: 0.5 - acqui_ucb_alpha: 0.44 + acqui_ucb_alpha: 3.0 acqui_ei_jitter: 0 acquisition_function: "UCB" meta: - robot_size: 26 - run_analytics: "true" + robot_size: 13 + run_analytics: "false" n_learning_iterations: 1450 - n_cooldown_iterations: 1 + n_cooldown_iterations: 0 reset_robot_position: "false" - evaluation_rate: 60 + evaluation_rate: 30 output_directory: "" - verbose: 0 + verbose: 1 startup_time: 0 diff --git a/experiments/bo_learner/yaml/nihedssnake10.yaml b/experiments/bo_learner/yaml/nihedssnake10.yaml new file mode 100644 index 0000000000..e13aa8af20 --- /dev/null +++ b/experiments/bo_learner/yaml/nihedssnake10.yaml @@ -0,0 +1,228 @@ +--- +id: nihed_snake10 +body: + id : Core + type : Core + params: + red: 0.94 + green: 0.98 + blue: 0.05 + children : + 0: + id : Leg00Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg00 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children : + 1: + id : Leg02Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg02 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + children : + 1: + id : Leg03Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg03 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children: + 1: + id : Leg04Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg04 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + children : + 1: + id : Leg05Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg05 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children: + 1: + id : Leg06Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg06 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + children : + 1: + id : Leg07Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg07 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children: + 1: + id : Leg08Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg08 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + children : + 1: + id : Leg09Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg09 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children: + 1: + id : Leg10Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg10 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + + + + +brain: + type: bo-cpg + controller: + use_frame_of_reference: 0 + load_brain: "" + reset_neuron_state_bool: "true" + reset_neuron_random: "false" + abs_output_bound: 1.0 + signal_factor_all: 4.0 + signal_factor_mid: 2.5 + signal_factor_left_right: 2.5 + range_lb: -1.5 + range_ub: 1.5 + init_neuron_state: 0.707 + learner: + n_init_samples: 10 + init_method: "LHS" + kernel_noise: 0.00000001 + kernel_optimize_noise: "false" + kernel_sigma_sq: 1.0 + kernel_l: 0.2 + kernel_squared_exp_ard_k: 4 + acqui_gpucb_delta: 0.5 + acqui_ucb_alpha: 3.0 + acqui_ei_jitter: 0 + acquisition_function: "UCB" + covrate: 0.7 + mutrate: 0.8 + gaussian_step_size: 0.3 + meta: + robot_size: 21 + run_analytics: "false" + n_learning_iterations: 1500 + n_cooldown_iterations: 0 + reset_robot_position: "false" + evaluation_rate: 30 + output_directory: "" + verbose: 1 + startup_time: 0 + diff --git a/experiments/bo_learner/yaml/nihedssnake6.yaml b/experiments/bo_learner/yaml/nihedssnake6.yaml new file mode 100644 index 0000000000..0758a9c875 --- /dev/null +++ b/experiments/bo_learner/yaml/nihedssnake6.yaml @@ -0,0 +1,158 @@ +--- +id: nihedsnake6 +body: + id : Core + type : Core + params: + red: 0.94 + green: 0.98 + blue: 0.05 + children : + 0: + id : Leg00Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg00 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children : + 1: + id : Leg02Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg02 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + children : + 1: + id : Leg03Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg03 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children: + 1: + id : Leg04Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg04 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + children : + 1: + id : Leg05Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg05 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children: + 1: + id : Leg06Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg06 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + + + + + +brain: + type: bo-cpg + controller: + use_frame_of_reference: 0 + load_brain: "" + reset_neuron_state_bool: "true" + reset_neuron_random: "false" + abs_output_bound: 1.0 + signal_factor_all: 4.0 + signal_factor_mid: 2.5 + signal_factor_left_right: 2.5 + range_lb: -1.5 + range_ub: 1.5 + init_neuron_state: 0.707 + learner: + n_init_samples: 10 + init_method: "LHS" + kernel_noise: 0.00000001 + kernel_optimize_noise: "false" + kernel_sigma_sq: 1.0 + kernel_l: 0.2 + kernel_squared_exp_ard_k: 4 + acqui_gpucb_delta: 0.5 + acqui_ucb_alpha: 3.0 + acqui_ei_jitter: 0 + acquisition_function: "UCB" + covrate: 0.7 + mutrate: 0.8 + gaussian_step_size: 0.3 + meta: + robot_size: 13 + run_analytics: "false" + n_learning_iterations: 1500 + n_cooldown_iterations: 0 + reset_robot_position: "false" + evaluation_rate: 30 + output_directory: "" + verbose: 1 + startup_time: 0 diff --git a/experiments/bo_learner/yaml/nihedssnake8.yaml b/experiments/bo_learner/yaml/nihedssnake8.yaml new file mode 100644 index 0000000000..ee63800f04 --- /dev/null +++ b/experiments/bo_learner/yaml/nihedssnake8.yaml @@ -0,0 +1,193 @@ +--- +id: nihed_snake8 +body: + id : Core + type : Core + params: + red: 0.94 + green: 0.98 + blue: 0.05 + children : + 0: + id : Leg00Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg00 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children : + 1: + id : Leg02Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg02 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + children : + 1: + id : Leg03Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg03 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children: + 1: + id : Leg04Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg04 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + children : + 1: + id : Leg05Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg05 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children: + 1: + id : Leg06Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg06 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + children : + 1: + id : Leg07Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg07 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : -90 + children: + 1: + id : Leg08Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg08 + type : FixedBrick + params: + red: 0.94 + green: 0.98 + blue: 0.05 + orientation : 0 + + + + +brain: + type: bo-cpg + controller: + use_frame_of_reference: 0 + load_brain: "" + reset_neuron_state_bool: "true" + reset_neuron_random: "false" + abs_output_bound: 1.0 + signal_factor_all: 4.0 + signal_factor_mid: 2.5 + signal_factor_left_right: 2.5 + range_lb: -1.5 + range_ub: 1.5 + init_neuron_state: 0.707 + learner: + n_init_samples: 10 + init_method: "LHS" + kernel_noise: 0.00000001 + kernel_optimize_noise: "false" + kernel_sigma_sq: 1.0 + kernel_l: 0.2 + kernel_squared_exp_ard_k: 4 + acqui_gpucb_delta: 0.5 + acqui_ucb_alpha: 3.0 + acqui_ei_jitter: 0 + acquisition_function: "UCB" + covrate: 0.7 + mutrate: 0.8 + gaussian_step_size: 0.3 + meta: + robot_size: 17 + run_analytics: "false" + n_learning_iterations: 1500 + n_cooldown_iterations: 0 + reset_robot_position: "false" + evaluation_rate: 30 + output_directory: "" + verbose: 1 + startup_time: 0 + diff --git a/experiments/bo_learner/yaml/one.yaml b/experiments/bo_learner/yaml/one.yaml new file mode 100644 index 0000000000..7c786f658e --- /dev/null +++ b/experiments/bo_learner/yaml/one.yaml @@ -0,0 +1,158 @@ +--- +id: example_one+ +body: + id : Core + type : Core + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 2: + slot : 0 + id : BodyJoint0 + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + slot : 0 + id : Body0 + type : FixedBrick + params: + red: 0.04 + green: 0.98 + blue: 0.04 + orientation : -90 + children : + 1: + slot : 0 + id : BodyJoint1 + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + slot : 0 + id : Body1 + type : FixedBrick + params: + red: 0.04 + green: 0.98 + blue: 0.04 + orientation : -90 + children: + 2: + slot : 0 + id : Leg10Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 0 + children : + 1: + slot : 0 + id : Leg10 + type : FixedBrick + params: + red: 0.04 + green: 0.98 + blue: 0.04 + orientation : 0 + 3: + slot : 0 + id : Leg11Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 0 + children : + 1: + slot : 0 + id : Leg11 + type : FixedBrick + params: + red: 0.04 + green: 0.98 + blue: 0.04 + orientation : 0 + 3: + slot : 0 + id : Leg30Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + orientation : 90 + children : + 1: + id : Leg30 + type : FixedBrick + params: + red: 0.04 + green: 0.04 + blue: 0.98 + orientation : -90 + children : + 1: + id : Leg31Joint + type : ActiveHinge + params: + red: 0.98 + green: 0.98 + blue: 0.98 + children : + 1: + id : Leg31 + type : FixedBrick + params: + red: 0.04 + green: 0.04 + blue: 0.98 + orientation : 0 +brain: + type: bo-cpg + controller: + use_frame_of_reference: 0 + load_brain: "" + reset_neuron_state_bool: "true" + reset_neuron_random: "false" + abs_output_bound: 1.0 + signal_factor_all: 4.0 + signal_factor_mid: 2.5 + signal_factor_left_right: 2.5 + range_lb: -1.5 + range_ub: 1.5 + init_neuron_state: 0.707 + learner: + n_init_samples: 20 + init_method: "LHS" + kernel_noise: 0.00000001 + kernel_optimize_noise: "false" + kernel_sigma_sq: 0.001 + kernel_l: 0.1 + kernel_squared_exp_ard_k: 4 + acqui_gpucb_delta: 0.1 + acqui_ucb_alpha: 2.0 + acqui_ei_jitter: 0 + acquisition_function: "UCB" + meta: + run_analytics: "true" + n_learning_iterations: 980 + n_cooldown_iterations: 0 + reset_robot_position: "true" + evaluation_rate: 60 + output_directory: "" + verbose: 1 + startup_time: 0 diff --git a/experiments/bo_learner/yaml/spider13.yaml b/experiments/bo_learner/yaml/spider13.yaml index 5fed980f4e..a535323cd2 100644 --- a/experiments/bo_learner/yaml/spider13.yaml +++ b/experiments/bo_learner/yaml/spider13.yaml @@ -231,7 +231,7 @@ brain: signal_factor_all: 4.0 signal_factor_mid: 2.5 signal_factor_left_right: 2.5 - range_lb: -1.0 + range_lb: -1.5 range_ub: 1.5 init_neuron_state: 0.707 learner: @@ -239,20 +239,20 @@ brain: init_method: "LHS" kernel_noise: 0.00000001 kernel_optimize_noise: "false" - kernel_sigma_sq: 0.222 - kernel_l: 0.55 + kernel_sigma_sq: 1.0 + kernel_l: 0.2 kernel_squared_exp_ard_k: 4 acqui_gpucb_delta: 0.5 - acqui_ucb_alpha: 0.44 + acqui_ucb_alpha: 2.0 acqui_ei_jitter: 0 acquisition_function: "UCB" meta: robot_size: 26 - run_analytics: "true" + run_analytics: "false" n_learning_iterations: 1450 - n_cooldown_iterations: 1 + n_cooldown_iterations: 0 reset_robot_position: "false" - evaluation_rate: 60 + evaluation_rate: 30 output_directory: "" - verbose: 0 + verbose: 1 startup_time: 0 diff --git a/experiments/bo_learner/yaml/spider17.yaml b/experiments/bo_learner/yaml/spider17.yaml index 2cdae21c26..81848303dd 100644 --- a/experiments/bo_learner/yaml/spider17.yaml +++ b/experiments/bo_learner/yaml/spider17.yaml @@ -303,7 +303,7 @@ brain: signal_factor_all: 4.0 signal_factor_mid: 2.5 signal_factor_left_right: 2.5 - range_lb: -1.0 + range_lb: -1.5 range_ub: 1.5 init_neuron_state: 0.707 learner: @@ -311,20 +311,20 @@ brain: init_method: "LHS" kernel_noise: 0.00000001 kernel_optimize_noise: "false" - kernel_sigma_sq: 0.222 - kernel_l: 0.55 + kernel_sigma_sq: 1.0 + kernel_l: 0.2 kernel_squared_exp_ard_k: 4 acqui_gpucb_delta: 0.5 - acqui_ucb_alpha: 0.44 + acqui_ucb_alpha: 3.0 acqui_ei_jitter: 0 acquisition_function: "UCB" meta: robot_size: 34 - run_analytics: "true" + run_analytics: "false" n_learning_iterations: 1450 - n_cooldown_iterations: 1 + n_cooldown_iterations: 0 reset_robot_position: "false" - evaluation_rate: 60 + evaluation_rate: 30 output_directory: "" - verbose: 0 + verbose: 1 startup_time: 0 diff --git a/experiments/bo_learner/yaml/spider9.yaml b/experiments/bo_learner/yaml/spider9.yaml index 7e153dceef..b31b6ab97c 100644 --- a/experiments/bo_learner/yaml/spider9.yaml +++ b/experiments/bo_learner/yaml/spider9.yaml @@ -155,7 +155,7 @@ brain: signal_factor_all: 4.0 signal_factor_mid: 2.5 signal_factor_left_right: 2.5 - range_lb: -1.0 + range_lb: -1.5 range_ub: 1.5 init_neuron_state: 0.707 learner: @@ -163,20 +163,20 @@ brain: init_method: "LHS" kernel_noise: 0.00000001 kernel_optimize_noise: "false" - kernel_sigma_sq: 0.222 - kernel_l: 0.55 + kernel_sigma_sq: 1.0 + kernel_l: 0.2 kernel_squared_exp_ard_k: 4 acqui_gpucb_delta: 0.5 - acqui_ucb_alpha: 0.44 + acqui_ucb_alpha: 3.0 acqui_ei_jitter: 0 acquisition_function: "UCB" meta: robot_size: 18 run_analytics: "true" n_learning_iterations: 1450 - n_cooldown_iterations: 1 + n_cooldown_iterations: 0 reset_robot_position: "false" - evaluation_rate: 60 + evaluation_rate: 30 output_directory: "" - verbose: 0 + verbose: 1 startup_time: 0 diff --git a/experiments/examples/manager.py b/experiments/examples/manager.py index 3dacc321c2..b7434726d5 100755 --- a/experiments/examples/manager.py +++ b/experiments/examples/manager.py @@ -27,6 +27,7 @@ async def run(): robot = revolve_bot.RevolveBot() robot.load_file("experiments/examples/yaml/spider.yaml") robot.update_substrate() + # robot.save_file("./spider.sdf", conf_type='sdf') # Connect to the simulator and pause world = await World.create(settings) diff --git a/pyrevolve/revolve_bot/brain/bo_cpg.py b/pyrevolve/revolve_bot/brain/bo_cpg.py index 7f8a28c140..915d62cef0 100644 --- a/pyrevolve/revolve_bot/brain/bo_cpg.py +++ b/pyrevolve/revolve_bot/brain/bo_cpg.py @@ -35,6 +35,9 @@ def __init__(self): self.acqui_ucb_alpha = None self.acqui_ei_jitter = None self.n_init_samples = None + self.gaussian_step_size = None + self.covrate = None + self.mutrate = None # Various self.robot_size = None @@ -91,6 +94,9 @@ def learner_sdf(self): 'acqui_gpucb_delta': str(self.acqui_gpucb_delta), 'acqui_ucb_alpha': str(self.acqui_ucb_alpha), 'acqui_ei_jitter': str(self.acqui_ei_jitter), + 'gaussian_step_size': str(self.gaussian_step_size), + 'covrate': str(self.covrate), + 'mutrate': str(self.mutrate), }) def controller_sdf(self): diff --git a/run_baby.sh b/run_baby.sh new file mode 100755 index 0000000000..76de74e8ad --- /dev/null +++ b/run_baby.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +set -x + +screen -d -m -S "BabyA" -L -Logfile "babyA.log" nice -n19 python3 ./experiments/bo_learner/GridSearchBaby.py diff --git a/run_babysnake.sh b/run_babysnake.sh new file mode 100755 index 0000000000..f9bbe0c613 --- /dev/null +++ b/run_babysnake.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +set -x + +screen -d -m -S "BabySnake" -L -Logfile "babySnakeA.log" nice -n19 python3 ./experiments/bo_learner/GridSearchBaby.py diff --git a/run_snakes.sh b/run_snakes.sh new file mode 100755 index 0000000000..1cf6e36400 --- /dev/null +++ b/run_snakes.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +set -x + +screen -d -m -S "Snakes" -L -Logfile "snakes6.log" nice -n19 python3 ./experiments/bo_learner/GridSearch.py diff --git a/thirdparty/galgo/galgo/Chromosome.hpp b/thirdparty/galgo/galgo/Chromosome.hpp new file mode 100755 index 0000000000..d2296ba1b6 --- /dev/null +++ b/thirdparty/galgo/galgo/Chromosome.hpp @@ -0,0 +1,599 @@ +//================================================================================================= +// Copyright (C) 2018 Alain Lanthier - All Rights Reserved +// License: MIT License See LICENSE.md for the full license. +// Original code 2017 Olivier Mallet (MIT License) +//================================================================================================= + +#ifndef CHROMOSOME_HPP +#define CHROMOSOME_HPP + +namespace galgo +{ + + //================================================================================================= + + template class Chromosome + { + public: + // constructor + Chromosome(const GeneticAlgorithm &ga); + + // copy constructor + Chromosome(const Chromosome< T > &rhs); + + // create new chromosome + void create(int num_in_pop, Eigen::VectorXd indiv); + + // create new chromosome +// void create(); + + // initialize chromosome + void initialize(); + + // evaluate chromosome + void evaluate(); + + // evaluate 0 generations chromosome + void evaluate0gen(Eigen::VectorXd observations); + + //get the number of generations + int get_ga_nogen() const; + + // reset chromosome + void reset(); + + // set or replace kth gene by a new one + void setGene(int k); + + // initialize or replace kth gene by a know value + void initGene(int k, T value); + + // add bit to chromosome + void addBit(char bit); + + // initialize or replace an existing chromosome bit + void setBit(char bit, int pos); + + // flip an existing chromosome bit + void flipBit(int pos); + + // get chromosome bit + char getBit(int pos) const; + + // initialize or replace a portion of bits with a portion of another chromosome + void setPortion( + const Chromosome< T > &x, + int start, + int end); + + // initialize or replace a portion of bits with a portion of another chromosome + void setPortion( + const Chromosome< T > &x, + int start); + + // get parameter value(s) from chromosome + const std::vector< T > &getParam() const; + + // get objective function result + const std::vector< double > &getResult() const; + + // get the total sum of all objective function(s) result + double getTotal() const; + + // get constraint value(s) + const std::vector< double > getConstraint() const; + + // return chromosome size in number of bits + int size() const; + + // return number of chromosome bits to mutate + double mutrate() const; + + const MutationInfo &mutinfo() const; + + double recombination_ratio() const; + + // return number of genes in chromosome + int nbgene() const; + + // return numero of generation this chromosome belongs to + int nogen() const; + + // return lower bound(s) + const std::vector< T > &lowerBound() const; + + // return upper bound(s) + const std::vector< T > &upperBound() const; + + T get_value(int k) const; + + double get_sigma(int k) const; + + long get_sigma_iteration(int k) const; + + void sigma_update( + int k, + double new_sigma) + { + _sigma_iteration[k]++; + _sigma[k] = new_sigma; + } + + private: + std::vector< T > param; // estimated parameter(s) + std::vector< double > result; // chromosome objective function(s) result + std::string chr; // string of bits representing chromosome + const GeneticAlgorithm *ptr = nullptr; //pointer to genetic algorithm + ///******* new **********/// + std::ifstream infile; + std::ifstream numgens; +// std::vector< double > indiv; + std::vector< double > _sigma; // stddev per parameter + std::vector< long > _sigma_iteration; //number of time _sigma was updated + + int clusterCount = 10; //pop_size + int dimens = 20; //dimensions + + public: + double fitness; // chromosome fitness, objective function(s) result that can be modified (adapted to constraint(s), set to positive values, etc...) + + private: + double total; // total sum of objective function(s) result + int chrsize; // chromosome size (in number of bits) + int numgen; // numero of generation + }; + + /*-------------------------------------------------------------------------------------------------*/ + + // constructor + template + Chromosome< T >::Chromosome(const GeneticAlgorithm &ga) + { + param.resize(ga.nbparam); + _sigma.resize(ga.nbparam); + _sigma_iteration.resize(ga.nbparam); + + ptr = &ga; + chrsize = ga.nbbit; + numgen = ga.nogen; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // copy constructor + template Chromosome< T >::Chromosome(const Chromosome< T > &rhs) + { + param = rhs.param; + _sigma = rhs._sigma; + _sigma_iteration = rhs._sigma_iteration; + + result = rhs.result; + chr = rhs.chr; + ptr = rhs.ptr; + + // re-initializing fitness to its original value + fitness = rhs.total; + total = rhs.total; + chrsize = rhs.chrsize; + numgen = rhs.numgen; + } + + /*-------------------------------------------------------------------------------------------------*/ + // create new chromosome //called in row 171 population.hpp + template inline void Chromosome< T >::create(int num_in_pop, Eigen::VectorXd indiv) + { + chr.clear(); + // pass MaxIndivPerCluster to param + int j(0); + for (const auto &x : ptr->param) // for(0 : dimensions) + { + param[j] = indiv[j]; +// std::cout << param[j] << ", "; + + T newvalue = (T) indiv[j]; + initGene(j, newvalue); + + _sigma[j] = 0.0; + _sigma_iteration[j] = 0; + j++; + } + } + + // create new chromosome +// template +// inline void Chromosome::create() +// { +// chr.clear(); +// +// int i(0); +// for (const auto& x : ptr->param) +// { +// // encoding parameter random value +// std::string str = x->encode(); +// chr.append(str); +// +// _sigma[i] = 0.0; +// _sigma_iteration[i] = 0; +// +// i++; +// } +// } + /*-------------------------------------------------------------------------------------------------*/ + + // initialize chromosome (from known parameter values) + template inline void Chromosome< T >::initialize() + { + chr.clear(); + + int i(0); + for (const auto &x : ptr->param) + { + // encoding parameter initial value + std::string str = x->encode(ptr->initialSet[i++]); + chr.append(str); + + //_sigma[i] = 0.0; + //_sigma_iteration[i] = 0; + } + } + + /*-------------------------------------------------------------------------------------------------*/ + + // evaluate chromosome fitness + template inline void Chromosome< T >::evaluate() + { + int i(0); + for (const auto &x : ptr->param) + { + // decoding chromosome: converting chromosome string into a real value + param[i] = x->decode(chr.substr(ptr->idx[i], x->size())); + std::cout << " param[" << i << "]: " << param[i]; + i++; + } + + // computing objective result(s) + result = ptr->Objective(param); + + // computing sum of all results (in case there is not only one objective functions) + total = std::accumulate(result.begin(), result.end(), 0.0); + + // initializing fitness to this total + fitness = total; + std::cout << " fitness: " << fitness << std::endl; + + std::ofstream outvalue; + outvalue.open("../value.txt", std::ios::app); + outvalue << std::fixed << fitness << std::endl; + } + + /*-------------------------------------------------------------------------------------------------*/ + // evaluate chromosome fitness for 0 generations + template + inline void Chromosome::evaluate0gen(Eigen::VectorXd observation) + { + /// removed passing the value to param, with clustering pop as instead + // computing objective result(s) std::vector< double > result; + //result = ptr->Objective(param); //std::vector Objective + std::vector vec(observation.data(), observation.data() + observation.size()); + result.push_back(vec[0]); + // computing sum of all results (in case there is not only one objective functions) + total = result[0]; //std::accumulate(result.begin(), result.end(), 0.0); double total + + // initializing fitness to this total + fitness = total; //double fitness +// std::cout << "result[0]: " << result[0] +// << " total: " << total +// << " fitness: " << fitness << std::endl; +// +// std::ofstream outvalue; +// outvalue.open("../value.txt", std::ios::app); +// outvalue << std::fixed << fitness << std::endl; + } + /*-------------------------------------------------------------------------------------------------*/ + // get the number of generations + template + inline int Chromosome::get_ga_nogen() const + { + return ptr->nogen; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // reset chromosome + template inline void Chromosome< T >::reset() + { + chr.clear(); + result = 0.0; + total = 0.0; + fitness = 0.0; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // set or replace kth gene by a new one + template inline void Chromosome< T >::setGene(int k) + { +#ifndef NDEBUG + if (k < 0 || k >= ptr->nbparam) + { + throw std::invalid_argument( + "Error: in galgo::Chromosome::setGene(int), argument cannot be outside interval [0,nbparam-1], please amend."); + } +#endif + + // generating a new gene + std::string s = ptr->param[k]->encode(); + + // adding or replacing gene in chromosome + chr.replace(ptr->idx[k], s.size(), s, 0, s.size()); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // initialize or replace kth gene by a know value + template + inline void Chromosome< T >::initGene( + int k, + T x) + { +#ifndef NDEBUG + if (k < 0 || k >= ptr->nbparam) + { + throw std::invalid_argument( + "Error: in galgo::Chromosome::initGene(int), first argument cannot be outside interval [0,nbparam-1], please amend."); + } +#endif + + // encoding gene + std::string s = ptr->param[k]->encode(x); + + // adding or replacing gene in chromosome + chr.replace(ptr->idx[k], s.size(), s, 0, s.size()); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // add chromosome bit to chromosome (when constructing a new one) + template inline void Chromosome< T >::addBit(char bit) + { + chr.push_back(bit); + +#ifndef NDEBUG + if (chr.size() > chrsize) + { + throw std::out_of_range( + "Error: in galgo::Chromosome::setBit(char), exceeding chromosome size."); + } +#endif + } + + /*-------------------------------------------------------------------------------------------------*/ + + // initialize or replace an existing chromosome bit + template + inline void Chromosome< T >::setBit( + char bit, + int pos) + { +#ifndef NDEBUG + if (pos >= chrsize) + { + throw std::out_of_range( + "Error: in galgo::Chromosome::replaceBit(char, int), second argument cannot be equal or greater than chromosome size."); + } +#endif + + std::stringstream ss; + std::string str; + ss << bit; + ss >> str; + chr.replace(pos, 1, str); + std::cout << chr << "\n"; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // flip an existing chromosome bit + template inline void Chromosome< T >::flipBit(int pos) + { +#ifndef NDEBUG + if (pos >= chrsize) + { + throw std::out_of_range( + "Error: in galgo::Chromosome::flipBit(int), argument cannot be equal or greater than chromosome size."); + } +#endif + + if (chr[pos] == '0') + { + chr.replace(pos, 1, "1"); + } + else + { + chr.replace(pos, 1, "0"); + } + } + + /*-------------------------------------------------------------------------------------------------*/ + + // get a chromosome bit + template inline char Chromosome< T >::getBit(int pos) const + { +#ifndef NDEBUG + if (pos >= chrsize) + { + throw std::out_of_range( + "Error: in galgo::Chromosome::getBit(int), argument cannot be equal or greater than chromosome size."); + } +#endif + + return chr[pos]; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // initialize or replace a portion of bits with a portion of another chromosome (from position start to position end included) + template + inline void Chromosome< T >::setPortion( + const Chromosome< T > &x, + int start, + int end) + { +#ifndef NDEBUG + if (start > chrsize) + { + throw std::out_of_range( + "Error: in galgo::Chromosome::setPortion(const Chromosome&, int, int), second argument cannot be greater than chromosome size."); + } +#endif + ///replace chr(strat, end-start+1) with x.chr(start, end-start+1) + chr.replace(start, end - start + 1, x.chr, start, end - start + 1); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // initialize or replace a portion of bits with a portion of another chromosome (from position start to the end of he chromosome) + template + inline void Chromosome< T >::setPortion( + const Chromosome< T > &x, + int start) + { +#ifndef NDEBUG + if (start > chrsize) + { + throw std::out_of_range( + "Error: in galgo::Chromosome::setPortion(const Chromosome&, int), second argument cannot be greater than chromosome size."); + } +#endif + ///replace chr(strat, chrsize) with x.chr(start, x.chrsize) + chr.replace(start, chrsize, x.chr, start, x.chrsize); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // get parameter value(s) from chromosome + template + inline const std::vector< T > &Chromosome< T >::getParam() const + { + return param; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // get objective function result + template + inline const std::vector< double > &Chromosome< T >::getResult() const + { + return result; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // get the total sum of all objective function(s) result + template inline double Chromosome< T >::getTotal() const + { + return total; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // get constraint value(s) for this chromosome + template + inline const std::vector< double > Chromosome< T >::getConstraint() const + { + return ptr->Constraint(param); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return chromosome size in number of bits + template inline int Chromosome< T >::size() const + { + return chrsize; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return mutation rate + template inline double Chromosome< T >::mutrate() const + { + return ptr->mutrate; + } + + template + inline double Chromosome< T >::recombination_ratio() const + { + return ptr->recombination_ratio; + } + + template + inline const MutationInfo &Chromosome< T >::mutinfo() const + { + return ptr->mutinfo; + } + + + /*-------------------------------------------------------------------------------------------------*/ + + // return number of genes in chromosome + template inline int Chromosome< T >::nbgene() const + { + return ptr->nbparam; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return numero of generation this chromosome belongs to + template inline int Chromosome< T >::nogen() const + { + return numgen; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return lower bound(s) + template + inline const std::vector< T > &Chromosome< T >::lowerBound() const + { + return ptr->lowerBound; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return upper bound(s) + template + inline const std::vector< T > &Chromosome< T >::upperBound() const + { + return ptr->upperBound; + } + + + template T Chromosome< T >::get_value(int k) const + { +#ifndef NDEBUG + if (k < 0 || k >= ptr->nbparam) + { + throw std::invalid_argument( + "Error: in galgo::Chromosome::get_value(int), first argument cannot be outside interval [0,nbparam-1], please amend."); + } +#endif + + auto &x = ptr->param[k]; + return x->decode(chr.substr(ptr->idx[k], x->size())); + } + + + template double Chromosome< T >::get_sigma(int k) const + { + return _sigma[k]; + } + + template long Chromosome< T >::get_sigma_iteration(int k) const + { + return _sigma_iteration[k]; + } + //================================================================================================= + +} + +#endif diff --git a/thirdparty/galgo/galgo/Converter.hpp b/thirdparty/galgo/galgo/Converter.hpp new file mode 100755 index 0000000000..b6ad0e86bd --- /dev/null +++ b/thirdparty/galgo/galgo/Converter.hpp @@ -0,0 +1,40 @@ +//================================================================================================= +// Copyright (C) 2018 Alain Lanthier - All Rights Reserved +// License: MIT License See LICENSE.md for the full license. +// Original code 2017 Olivier Mallet (MIT License) +//================================================================================================= + +#ifndef CONVERTER_HPP +#define CONVERTER_HPP + +namespace galgo { + +//================================================================================================= + +// convert unsigned long long integer to binary string +std::string GetBinary(uint64_t value) +{ + std::bitset bits(value); + // NB: CHAR_BIT = number of bits in char usually 8 but not always on older machines + return bits.to_string(); +} + +/*-------------------------------------------------------------------------------------------------*/ + +// convert binary string to unsigned long long integer +uint64_t GetValue(const std::string& s) +{ + uint64_t value, x = 0; + for (std::string::const_iterator it = s.begin(), end = s.end(); it != end; ++it) { + x = (x << 1) + (*it - '0'); + } + memcpy(&value, &x, sizeof(uint64_t)); + + return value; +} + +//================================================================================================= + +} + +#endif diff --git a/thirdparty/galgo/galgo/Evolution.hpp b/thirdparty/galgo/galgo/Evolution.hpp new file mode 100755 index 0000000000..09dff34015 --- /dev/null +++ b/thirdparty/galgo/galgo/Evolution.hpp @@ -0,0 +1,1075 @@ +//================================================================================================= +// Copyright (C) 2018 Alain Lanthier - All Rights Reserved +// License: MIT License See LICENSE.md for the full license. +// Original code 2017 Olivier Mallet (MIT License) +//================================================================================================= + +#ifndef EVOLUTION_HPP +#define EVOLUTION_HPP + +// In this header, the user can define his own selection, cross-over, mutation and adaptation to +// constraint(s) methods by respecting the function declaration template + +//================================================================================================= + +// SELECTION METHODS + +/*-------------------------------------------------------------------------------------------------*/ + +// proportional roulette wheel selection +template void RWS(galgo::Population< T > &x) +{ + // adjusting all fitness to positive values + x.adjustFitness(); + + // computing fitness sum + double fitsum = x.getSumFitness(); + + // selecting mating population + for (int i = 0, end = x.matsize(); i < end; ++i) + { + int j = 0; + if (fitsum > 0.0) + { + // generating a random fitness sum in [0,fitsum) + double fsum = galgo::uniform< double >(0.0, fitsum); + + while (fsum >= 0.0) + { +#ifndef NDEBUG + if (j == x.popsize()) + { + throw std::invalid_argument( + "Error: in RWS(galgo::Population&) index j cannot be equal to population size."); + } +#endif + fsum -= x(j)->fitness; + j++; + } + } + else + { + j = 1; + } + + // selecting element + x.select(j - 1); + } +} + +/*-------------------------------------------------------------------------------------------------*/ + +// stochastic universal sampling selection +template void SUS(galgo::Population< T > &x) +{ + // adjusting all fitness to positive values + x.adjustFitness(); + + // computing fitness sum + double fitsum = x.getSumFitness(); + + int matsize = x.matsize(); + + // computing interval size + double dist = fitsum / matsize; + + if (fitsum == 0.0) + { + dist = 1.0; // BUG to fix + } + + // initializing pointer + double ptr = galgo::uniform< double >(0.0, dist); + + // selecting mating population + for (int i = 0; i < matsize; ++i) + { + + int j = 0; + double fsum = 0; + + while (fsum <= ptr) + { + //#ifndef NDEBUG + if (j == x.popsize()) + { + //throw std::invalid_argument("Error: in SUS(galgo::Population&) index j cannot be equal to population size."); + j = 1; + break; + } + //#endif + if (j < matsize) + { + fsum += x(j)->fitness; + if (j < matsize - 1) + { + j++; + } + else + { + // BUG to fix + j = 1; + break; + } + } + else + { + // BUG to fix + j = 1; + break; + } + } + + // selecting element + x.select(j - 1); + + // incrementing pointer + ptr += dist; + } +} + +/*-------------------------------------------------------------------------------------------------*/ + +// classic linear rank-based selection +template void RNK(galgo::Population< T > &x) +{ + int popsize = x.popsize(); + static std::vector< int > rank(popsize); + static int ranksum; + + // this will only be run at the first generation + if (x.nogen() == 1) + { + int n = popsize + 1; + // generating ranks from highest to lowest + std::generate_n(rank.begin(), popsize, [&n]() -> int + { return --n; }); + // computing sum of ranks + ranksum = int(.5 * popsize * (popsize + 1)); + } + + // selecting mating population + for (int i = 0, end = x.matsize(); i < end; ++i) + { + // generating a random rank sum in [1,ranksum) + int rsum = galgo::uniform< int >(1, ranksum); + + int j = 0; + while (rsum > 0) + { +#ifndef NDEBUG + if (j == popsize) + { + throw std::invalid_argument( + "Error: in RNK(galgo::Population&) index j cannot be equal to population size."); + } +#endif + rsum -= rank[j]; + j++; + } + // selecting element + x.select(j - 1); + } +} + +/*-------------------------------------------------------------------------------------------------*/ + +// linear rank-based selection with selective pressure +template void RSP(galgo::Population< T > &x) +{ + int popsize = x.popsize(); + static std::vector< double > rank(popsize); + static double ranksum; + + // this will only be run at the first generation + if (x.nogen() == 1) + { + // initializing ranksum + ranksum = 0.0; + // generating ranks from highest to lowest + for (int i = 0; i < popsize; ++i) + { + rank[i] = 2 - x.SP() + 2 * (x.SP() - 1) * (popsize - i) / popsize; + ranksum += rank[i]; + } + } + + // selecting mating population + for (int i = 0, end = x.matsize(); i < end; ++i) + { + // generating a random rank sum in [0,ranksum) + double rsum = galgo::uniform< double >(0.0, ranksum); + + int j = 0; + while (rsum >= 0.0) + { +#ifndef NDEBUG + if (j == popsize) + { + throw std::invalid_argument( + "Error: in RSP(galgo::Population&) index j cannot be equal to population size."); + } +#endif + rsum -= rank[j]; + j++; + } + // selecting element + x.select(j - 1); + } +} + +/*-------------------------------------------------------------------------------------------------*/ + +// tournament selection +template void TNT(galgo::Population< T > &x) +{ + int popsize = x.popsize(); + int tntsize = x.tntsize(); + + // selecting mating population + for (int i = 0, end = x.matsize(); i < end; ++i) //matsize() = popsize + { + // selecting randomly a first element + int bestIdx = galgo::uniform< int >(0, popsize); + // the operator() access element in current population at position pos + double bestFit = x(bestIdx)->fitness; + + // starting k-tournament,tntsize = k = 2/4 + for (int j = 1; j < tntsize; ++j) + { + int idx = galgo::uniform< int >(0, popsize); + //the operator() access element in current population at position pos + double fit = x(idx)->fitness; + if (fit > bestFit) + { + bestFit = fit; + bestIdx = idx; + } + } + // selecting element at position bestIdx in current population and copy it into mating population + x.select(bestIdx); //matpop[matidx] = curpop[pos]; + } +} + +/*-------------------------------------------------------------------------------------------------*/ + +// transform ranking selection +template void TRS(galgo::Population< T > &x) +{ + static double c; + // (re)initializing when running new GA + if (x.nogen() == 1) + { + c = 0.2; + } + int popsize = x.popsize(); + + // generating a random set of popsize values on [0,1) + std::vector< double > r(popsize); + std::for_each(r.begin(), r.end(), [](double &z) -> double + { return galgo::proba(galgo::rng); }); + + // sorting them from highest to lowest + std::sort(r.begin(), r.end(), []( + double z1, + double z2) -> bool + { return z1 > z2; }); + // transforming population fitness + auto it = x.begin(); + std::for_each(r.begin(), r.end(), [&it, popsize](double z) -> void + { + (*it)->fitness = ceil((popsize - popsize * exp(-c * z)) / (1 - exp(-c))); + it++; + }); + + // updating c for next generation + c = c + 0.1; // arithmetic transition + //c = c * 1.1; // geometric transition + // computing fitness sum + double fitsum = x.getSumFitness(); + + // selecting mating population + for (int i = 0, end = x.matsize(); i < end; ++i) + { + int j = 0; + if (fitsum > 0.0) + { + // generating a random fitness sum in [0,fitsum) + double fsum = galgo::uniform< double >(0, fitsum); + while (fsum >= 0) + { +#ifndef NDEBUG + if (j == popsize) + { + throw std::invalid_argument( + "Error: in TRS(galgo::Population&) index j cannot be equal to population size."); + } +#endif + fsum -= x(j)->fitness; + j++; + } + } + else + { + j = 1; + } + + // selecting element + x.select(j - 1); + } +} + +/*-------------------------------------------------------------------------------------------------*/ + +// CROSS-OVER METHODS + +template void transmit_sigma( + double r, + const galgo::Chromosome< T > &chrmat1, + const galgo::Chromosome< T > &chrmat2, + galgo::CHR< T > &chr1, + galgo::CHR< T > &chr2) +{ + for (int i = 0; i < chr1->nbgene(); i++) + { + chr1->sigma_update(i, + (r * chrmat1.get_sigma(i)) + ((1.0 - r) * chrmat2 + .get_sigma(i))); + } + for (int i = 0; i < chr2->nbgene(); i++) + { + chr2->sigma_update(i, + (r * chrmat2.get_sigma(i)) + ((1.0 - r) * chrmat1 + .get_sigma(i))); + } +} + +template void transmit_sigma( + const galgo::Chromosome< T > &chrmat1, + galgo::Chromosome< T > &chr1) +{ + for (int i = 0; i < chr1.nbgene(); i++) + { + chr1.sigma_update(i, chrmat1.get_sigma(i)); + } +} + +/*-------------------------------------------------------------------------------------------------*/ +template void RealValuedSimpleArithmeticRecombination( + const galgo::Population< T > &x, + galgo::CHR< T > &chr1, + galgo::CHR< T > &chr2) +{ + // choosing randomly 2 chromosomes from mating population + int idx1 = galgo::uniform< int >(0, x.matsize()); + int idx2 = galgo::uniform< int >(0, x.matsize()); + if (x.matsize() >= 2) + { + while (idx1 == idx2) + { + idx2 = galgo::uniform< int >(0, x.matsize()); + }// find not same parents + } + + // choosing randomly a position for cross-over + int pos = galgo::uniform< int >(0, chr1->nbgene()); + double r = chr1->recombination_ratio(); + // std::cout << "pos: " << pos << " r: " << r << " "; + + // *x[idx1] is operator[](int pos) is access element in mating population at position pos + //operator [] is a element function of class population in row 267 population.hpp + const galgo::Chromosome< T > &chrmat1 = *x[idx1]; + const galgo::Chromosome< T > &chrmat2 = *x[idx2]; + + for (int i = 0; i < pos; i++) + { + chr1->initGene(i, chrmat1.get_value(i)); + } + for (int i = pos; i < chr1->nbgene(); i++) + { + // std::cout << "chr1value: " << chrmat1.get_value(i) + // << " chr2value: " << chrmat2.get_value(i) + // << " chr1newXover: " + // << (r * chrmat2.get_value(i)) + ((1.0 - r) * chrmat1.get_value(i)) << " "; + chr1->initGene(i, (T)((r * chrmat2.get_value(i)) + ((1.0 - r) * chrmat1.get_value(i)))); + } + // std::cout << std::endl; + for (int i = 0; i < pos; i++) + { + chr2->initGene(i, chrmat2.get_value(i)); + } + for (int i = pos; i < chr2->nbgene(); i++) + { + chr2->initGene(i, (T)((r * chrmat1.get_value(i)) + ((1.0 - r) * chrmat2.get_value(i)))); + } + + // Transmit sigma + transmit_sigma< T >(r, chrmat1, chrmat2, chr1, chr2); +} + +template void RealValuedSingleArithmeticRecombination( + const galgo::Population< T > &x, + galgo::CHR< T > &chr1, + galgo::CHR< T > &chr2) +{ + // choosing randomly 2 chromosomes from mating population + int idx1 = galgo::uniform< int >(0, x.matsize()); + int idx2 = galgo::uniform< int >(0, x.matsize()); + if (x.matsize() >= 2) + { + while (idx1 == idx2) + { + idx2 = galgo::uniform< int >(0, x.matsize()); + } // find not unique parents + } + + // choosing randomly a position for cross-over + int pos = galgo::uniform< int >(0, chr1->nbgene()); + + double r = chr1->recombination_ratio(); + const galgo::Chromosome< T > &chrmat1 = *x[idx1]; + const galgo::Chromosome< T > &chrmat2 = *x[idx2]; + + for (int i = 0; i < chr1->nbgene(); i++) + { + chr1->initGene(i, chrmat1.get_value(i)); + } + chr1->initGene(pos, + (T)(r * chrmat2.get_value(pos) + (1.0 - r) * chrmat1 + .get_value(pos))); + + for (int i = 0; i < chr2->nbgene(); i++) + { + chr2->initGene(i, chrmat2.get_value(i)); + } + chr2->initGene(pos, + (T)(r * chrmat1.get_value(pos) + (1.0 - r) * chrmat2 + .get_value(pos))); + + // Transmit sigma + transmit_sigma< T >(r, chrmat1, chrmat2, chr1, chr2); +} + +template void RealValuedWholeArithmeticRecombination( + const galgo::Population< T > &x, + galgo::CHR< T > &chr1, + galgo::CHR< T > &chr2) +{ + // choosing randomly 2 chromosomes from mating population + int idx1 = galgo::uniform< int >(0, x.matsize()); + int idx2 = galgo::uniform< int >(0, x.matsize()); + if (x.matsize() >= 2) + { + while (idx1 == idx2) + { + idx2 = galgo::uniform< int >(0, x.matsize()); + } // find not unique parents + } + + double r = chr1->recombination_ratio(); + const galgo::Chromosome< T > &chrmat1 = *x[idx1]; + const galgo::Chromosome< T > &chrmat2 = *x[idx2]; + + for (int i = 0; i < chr1->nbgene(); i++) + { + chr1->initGene(i, + (T)(r * chrmat2.get_value(i) + (1.0 - r) * chrmat1 + .get_value(i))); + } + for (int i = 0; i < chr2->nbgene(); i++) + { + chr2->initGene(i, + (T)(r * chrmat1.get_value(i) + (1.0 - r) * chrmat2 + .get_value(i))); + } + + // Transmit sigma + transmit_sigma< T >(r, chrmat1, chrmat2, chr1, chr2); +} + + +// one-point random cross-over of 2 chromosomes +template void P1XO( + const galgo::Population< T > &x, + galgo::CHR< T > &chr1, + galgo::CHR< T > &chr2) +{ + // choosing randomly 2 chromosomes from mating population + int idx1 = galgo::uniform< int >(0, x.matsize()); + int idx2 = galgo::uniform< int >(0, x.matsize()); + if (x.matsize() >= 2) + { + while (idx1 == idx2) + { + idx2 = galgo::uniform< int >(0, x.matsize()); + } // find not unique parents + } + + // choosing randomly a position for cross-over + int pos = galgo::uniform< int >(0, chr1->size()); + + // transmitting portion of bits to new chromosomes + chr1->setPortion(*x[idx1], 0, pos); + chr2->setPortion(*x[idx2], 0, pos); + chr1->setPortion(*x[idx2], pos + 1); + chr2->setPortion(*x[idx1], pos + 1); + + double r = chr1->recombination_ratio(); + const galgo::Chromosome< T > &chrmat1 = *x[idx1]; + const galgo::Chromosome< T > &chrmat2 = *x[idx2]; + + // Transmit sigma + transmit_sigma< T >(r, chrmat1, chrmat2, chr1, chr2); +} + +/*-------------------------------------------------------------------------------------------------*/ + +// two-point random cross-over of 2 chromosomes +template void P2XO( + const galgo::Population< T > &x, + galgo::CHR< T > &chr1, + galgo::CHR< T > &chr2) +{ + // choosing randomly 2 chromosomes from mating population + int idx1 = galgo::uniform< int >(0, x.matsize()); + int idx2 = galgo::uniform< int >(0, x.matsize()); + if (x.matsize() >= 2) + { + while (idx1 == idx2) + { + idx2 = galgo::uniform< int >(0, x.matsize()); + } // find not unique parents + } + + // choosing randomly 2 positions for cross-over + int pos1 = galgo::uniform< int >(0, chr1->size()); + int pos2 = galgo::uniform< int >(0, chr1->size()); + + // ordering these 2 random positions + int m = std::min(pos1, pos2); + int M = std::max(pos1, pos2); + + // transmitting portion of bits new chromosomes + chr1->setPortion(*x[idx1], 0, m); + chr2->setPortion(*x[idx2], 0, m); + chr1->setPortion(*x[idx2], m + 1, M); + chr2->setPortion(*x[idx1], m + 1, M); + chr1->setPortion(*x[idx1], M + 1); + chr2->setPortion(*x[idx2], M + 1); + + double r = chr1->recombination_ratio(); + const galgo::Chromosome< T > &chrmat1 = *x[idx1]; + const galgo::Chromosome< T > &chrmat2 = *x[idx2]; + + // Transmit sigma + transmit_sigma< T >(r, chrmat1, chrmat2, chr1, chr2); +} + +/*-------------------------------------------------------------------------------------------------*/ + +// uniform random cross-over of 2 chromosomes +template void UXO( + const galgo::Population< T > &x, + galgo::CHR< T > &chr1, + galgo::CHR< T > &chr2) +{ + // choosing randomly 2 chromosomes from mating population + int idx1 = galgo::uniform< int >(0, x.matsize()); + int idx2 = galgo::uniform< int >(0, x.matsize()); + if (x.matsize() >= 2) + { + while (idx1 == idx2) + { + idx2 = galgo::uniform< int >(0, x.matsize()); + } // find not unique parents + } + + for (int j = 0; j < chr1->size(); ++j) + { + // choosing 1 of the 2 chromosomes randomly + if (galgo::proba(galgo::rng) < 0.50) + { + // adding its jth bit to new chromosome + chr1->addBit(x[idx1]->getBit(j)); + chr2->addBit(x[idx2]->getBit(j)); + } + else + { + // adding its jth bit to new chromosomes + chr1->addBit(x[idx2]->getBit(j)); + chr2->addBit(x[idx1]->getBit(j)); + } + } + + double r = chr1->recombination_ratio(); + const galgo::Chromosome< T > &chrmat1 = *x[idx1]; + const galgo::Chromosome< T > &chrmat2 = *x[idx2]; + + // Transmit sigma + transmit_sigma< T >(r, chrmat1, chrmat2, chr1, chr2); +} + +/*-------------------------------------------------------------------------------------------------*/ + +// MUTATION METHODS + +/*-------------------------------------------------------------------------------------------------*/ + +// boundary mutation: replacing a chromosome gene by its lower or upper bound +template void BDM(galgo::CHR< T > &chr) +{ + double mutrate = chr->mutrate(); + if (mutrate == 0.0) + { + return; + } + + // getting chromosome lower bound(s) + const std::vector< T > &lowerBound = chr->lowerBound(); + // getting chromosome upper bound(s) + const std::vector< T > &upperBound = chr->upperBound(); + + // looping on number of genes + for (int i = 0; i < chr->nbgene(); ++i) + { + // generating a random probability + if (galgo::proba(galgo::rng) <= mutrate) + { + // generating a random probability + if (galgo::proba(galgo::rng) < .5) + { + // replacing ith gene by lower bound + chr->initGene(i, lowerBound[i]); + } + else + { + // replacing ith gene by upper bound + chr->initGene(i, upperBound[i]); + } + } + } +} + +/*-------------------------------------------------------------------------------------------------*/ +// single point mutation: flipping a chromosome bit +template void SPM(galgo::CHR< T > &chr) +{ + double mutrate = chr->mutrate(); + if (mutrate == 0.0) + { + return; + } + + // looping on chromosome bits + for (int i = 0; i < chr->size(); ++i) + { + // generating a random probability + if (galgo::proba(galgo::rng) <= mutrate) + { + // flipping ith bit + chr->flipBit(i); + } + } +} + + +template +void GAM_UncorrelatedOneStepSizeFixed(galgo::CHR< T > &chr) +{ + double mutrate = chr->mutrate(); + if (mutrate == 0.0) + { + return; + } + + const std::vector< T > &lowerBound = chr->lowerBound(); + const std::vector< T > &upperBound = chr->upperBound(); + + double n = chr->nbgene(); + double tau = 1.0 / pow(n, 0.50); + + std::normal_distribution< double > distribution01(0.0, 1.0); + + // looping on number of genes (parameters) + for (int i = 0; i < chr->nbgene(); ++i) + { + // generating a random probability + if (galgo::proba(galgo::rng) <= mutrate) + { + T value = chr->get_value(i); + double sigma = chr->get_sigma(i); + + if (sigma < 0.001) // first time + { + sigma = chr->mutinfo()._sigma; + if (sigma < chr->mutinfo()._sigma_lowest) + { + sigma = chr->mutinfo()._sigma_lowest; + } + chr->sigma_update(i, sigma); + } + + double newsigma = sigma * std::exp(tau * distribution01(galgo::rng)); + if (newsigma < chr->mutinfo()._sigma_lowest) + { + newsigma = chr->mutinfo()._sigma_lowest; + } + chr->sigma_update(i, newsigma); + + double norm01 = distribution01(galgo::rng); + T step = (T)(newsigma * norm01); + + T newvalue = (T)(std::min< T >(std::max< T >(value + step, lowerBound[i]), + upperBound[i])); + chr->initGene(i, newvalue); + } + } +} + +template +void GAM_UncorrelatedOneStepSizeBoundary(galgo::CHR< T > &chr) +{ + double mutrate = chr->mutrate(); + if (mutrate == 0.0) + { + return; + } + + const std::vector< T > &lowerBound = chr->lowerBound(); + const std::vector< T > &upperBound = chr->upperBound(); + + double n = (double)chr->nbgene(); + double tau = 1.0 / pow(n, 0.50); + + std::normal_distribution< double > distribution01(0.0, 1.0); + + // looping on number of genes + for (int i = 0; i < chr->nbgene(); ++i) + { + // generating a random probability + if (galgo::proba(galgo::rng) <= mutrate) + { + T value = chr->get_value(i); + double sigma = chr->get_sigma(i); + + if (sigma < 0.001) // first time + { + sigma = + (upperBound[i] - lowerBound[i]) * chr->mutinfo()._ratio_boundary; + if (sigma < chr->mutinfo()._sigma_lowest) + { + sigma = chr->mutinfo()._sigma_lowest; + } + chr->sigma_update(i, sigma); + } + + double newsigma = sigma * std::exp(tau * distribution01(galgo::rng)); + if (newsigma < chr->mutinfo()._sigma_lowest) + { + newsigma = chr->mutinfo()._sigma_lowest; + } + chr->sigma_update(i, newsigma); + + double norm01 = distribution01(galgo::rng); + T step = (T)(newsigma * norm01); + + T newvalue = (T)(std::min< T >(std::max< T >(value + step, lowerBound[i]), upperBound[i])); + chr->initGene(i, newvalue); + } + } +} + +template +void GAM_UncorrelatedNStepSize(galgo::CHR< T > &chr) +{ + double mutrate = chr->mutrate(); + if (mutrate == 0.0) + { + return; + } + + const std::vector< T > &lowerBound = chr->lowerBound(); + const std::vector< T > &upperBound = chr->upperBound(); + + std::normal_distribution< double > distribution01(0.0, 1.0); + + double n = (double)chr->nbgene(); + double tau1 = 1.0 / pow(2.0 * n, 0.50); + double tau2 = 1.0 / pow(2.0 * pow(n, 0.50), 0.50); + + // looping on number of genes + for (int i = 0; i < chr->nbgene(); ++i) + { + // generating a random probability + if (galgo::proba(galgo::rng) <= mutrate) + { + T value = chr->get_value(i); + double sigma = chr->get_sigma(i); + + if (sigma < 0.001) // never copied from parent + { + sigma = chr->mutinfo()._sigma; + if (sigma < chr->mutinfo()._sigma_lowest) + { + sigma = chr->mutinfo()._sigma_lowest; + } + chr->sigma_update(i, sigma); + } + else + { + double factor1 = std::exp(tau1 * distribution01(galgo::rng)); + double factor2 = std::exp(tau2 * distribution01(galgo::rng)); + + double newsigma = sigma * factor1 * factor2; + if (newsigma < chr->mutinfo()._sigma_lowest) + { + newsigma = chr->mutinfo()._sigma_lowest; + } + + chr->sigma_update(i, newsigma); + sigma = newsigma; + } + + double norm01 = distribution01(galgo::rng); + T newvalue = (T)(std::min< T >(std::max< T >(value + (T)(sigma * norm01), + lowerBound[i]), + upperBound[i])); + chr->initGene(i, newvalue); + } + } +} + +template +void GAM_UncorrelatedNStepSizeBoundary(galgo::CHR< T > &chr, size_t current_iteration, double gaussian_step_size) +{ + double mutrate = chr->mutrate(); //mutrate = 1.0; + if (mutrate == 0.0) + { + return; + } + + const std::vector< T > &lowerBound = chr->lowerBound(); + const std::vector< T > &upperBound = chr->upperBound(); + ////todo the adaptive sigma over iterations for higher accurate + ////sigma from small to very small and jump to big if no gain for long iters +// auto nogens = galgo::GeneticAlgorithm::nogen; +// double std_dev = 0.5 - std::sqrt(current_iteration)/100; +// double gaussian_step_size = 0.3; +// if(current_iteration > 400) +// { +// std_dev = 0.4 - 0.01 * std::sqrt(current_iteration - 400); +// int random_big_mutation = galgo::uniform(0,10); +// std::cout << "random_big_mutation: " << random_big_mutation << " "; +// if(random_big_mutation > 8) +// { +// //keep exploration each generation +// std_dev = 0.8; +// } +// } + std::normal_distribution< double > distribution01(0.0, gaussian_step_size); //ea:0.4, boea:0.2 + std::normal_distribution< double > distribution11(1.0, 0.5); + + double n = (double)chr->nbgene(); + double tau1 = 1.0 / pow(2.0 * n, 0.50); //5d (n=5): 0.3162277660 + double tau2 = 1.0 / pow(2.0 * pow(n, 0.50), 0.50); //5d: 0.4728708045 + + // looping on number of genes, nbgene(): dimensions + for (int i = 0; i < chr->nbgene(); ++i) + { + // generating a random probability + if (galgo::proba(galgo::rng) <= mutrate) //mutrate = 1.0, 0.8; + { + T value = chr->get_value(i); + double sigma = chr->get_sigma(i); //stddev per parameter + + if (sigma < 0.001) // never copied from parent + { + sigma = (upperBound[i] - lowerBound[i]) * chr->mutinfo()._ratio_boundary; + if (sigma < chr->mutinfo()._sigma_lowest) + { + sigma = chr->mutinfo()._sigma_lowest; + } + chr->sigma_update(i, sigma); + } + else + { + double factor1 = std::exp(tau1 * distribution01(galgo::rng)); + double factor2 = std::exp(tau2 * distribution01(galgo::rng)); +// std::cout << "sigma-" << i << " "<< sigma << " factor1: " << factor1 +// << " factor2: " << factor2 << " "; + double newsigma = sigma * factor1 * factor2; + if (newsigma < chr->mutinfo()._sigma_lowest) + { + newsigma = chr->mutinfo()._sigma_lowest; + } + + chr->sigma_update(i, newsigma); + sigma = newsigma; + } + + double norm01 = distribution01(galgo::rng); +// T newvalue = (T)(std::min< T >(std::max< T >(value + (T)(sigma * norm01), lowerBound[i]), upperBound[i])); + + //// random when value lower/bigger than lowerBound/upperBound + T newvalue = (T) (value + (T)(sigma * norm01)); + + while (newvalue < lowerBound[i]) + { + newvalue = distribution01(galgo::rng); //random when value lower than lowerBound + } + while (newvalue > upperBound[i]) + { + newvalue = distribution11(galgo::rng); + } + + chr->initGene(i, newvalue); + } + } +} + +/*-------------------------------------------------------------------------------------------------*/ +// Gaussian mutation: replacing a chromosome gene by near guassian value +template +void GAM_sigma_adapting_per_generation(galgo::CHR< T > &chr) +{ + double mutrate = chr->mutrate(); + if (mutrate == 0.0) + { + return; + } + + const std::vector< T > &lowerBound = chr->lowerBound(); + const std::vector< T > &upperBound = chr->upperBound(); + + std::normal_distribution< double > distribution01(0.0, 1.0); + + // looping on number of genes + for (int i = 0; i < chr->nbgene(); ++i) + { + // generating a random probability + if (galgo::proba(galgo::rng) <= mutrate) + { + T value = chr->get_value(i); + double sigma = ((double)(upperBound[i] - lowerBound[i])) * chr->mutinfo()._ratio_boundary; + if (sigma < chr->mutinfo()._sigma_lowest) + { + sigma = chr->mutinfo()._sigma_lowest; + } + + double norm01; + + // sigma decreasing blindly with number generation produced + std::cout << "chr->nogen(): " << chr->nogen() << std::endl; + for (int z = 1; z < chr->nogen() / 2; z++) + { + norm01 = distribution01(galgo::rng); + sigma = std::max(double(0), sigma * exp(norm01)); + } + + std::normal_distribution< double > distribution((double)value, sigma); + double norm = distribution(galgo::rng); + T newvalue = (T)(std::min(std::max((T)norm, lowerBound[i]), upperBound[i])); + chr->initGene(i, newvalue); + } + } +} +/*-------------------------------------------------------------------------------------------------*/ + + +/*-------------------------------------------------------------------------------------------------*/ +// Gaussian mutation: replacing a chromosome gene by near gaussian value +template void GAM_sigma_adapting_per_mutation(galgo::CHR< T > &chr) +{ + double mutrate = chr->mutrate(); + if (mutrate == 0.0) + { + return; + } + + const std::vector< T > &lowerBound = chr->lowerBound(); + const std::vector< T > &upperBound = chr->upperBound(); + + std::normal_distribution< double > distribution01(0.0, 1.0); + + // looping on number of genes + for (int i = 0; i < chr->nbgene(); ++i) + { + // generating a random probability + if (galgo::proba(galgo::rng) <= mutrate) + { + T value = chr->get_value(i); + double sigma = chr->get_sigma(i); + + if (sigma < 0.001) // never copied from parent + { + sigma = ((double)(upperBound[i] - lowerBound[i])) * chr->mutinfo() + ._ratio_boundary; + if (sigma < chr->mutinfo()._sigma_lowest) + { + sigma = chr->mutinfo()._sigma_lowest; + } + chr->sigma_update(i, sigma); + } + + std::normal_distribution< double > distribution((double)value, sigma); + double norm = distribution(galgo::rng); + T new_value = + (T)(std::min(std::max((T)norm, lowerBound[i]), upperBound[i])); + chr->initGene(i, new_value); + } + } +} +/*-------------------------------------------------------------------------------------------------*/ + + +// uniform mutation: replacing a chromosome gene by a new one +template void UNM(galgo::CHR< T > &chr) +{ + double mutrate = chr->mutrate(); + if (mutrate == 0.0) + { + return; + } + + // looping on number of genes + for (int i = 0; i < chr->nbgene(); ++i) + { + // generating a random probability + if (galgo::proba(galgo::rng) <= mutrate) + { + // replacing ith gene by a new one + chr->setGene(i); + } + } +} + +/*-------------------------------------------------------------------------------------------------*/ + +// ADAPTATION TO CONSTRAINT(S) METHODS + +/*-------------------------------------------------------------------------------------------------*/ + +// adapt population to genetic algorithm constraint(s) +template void DAC(galgo::Population< T > &x) +{ + // getting worst population objective function total result + double worstTotal = x.getWorstTotal(); + + for (auto it = x.begin(), end = x.end(); it != end; ++it) + { + // computing element constraint value(s) + const std::vector< double > &cst = (*it)->getConstraint(); + + // adapting fitness if any constraint violated + if (std::any_of(cst.cbegin(), cst.cend(), [](double x) -> bool + { return x >= 0.0; })) + { + (*it)->fitness = + worstTotal - std::accumulate(cst.cbegin(), cst.cend(), 0.0); + } + } +} + +//================================================================================================= + +#endif diff --git a/thirdparty/galgo/galgo/Galgo.hpp b/thirdparty/galgo/galgo/Galgo.hpp new file mode 100755 index 0000000000..553cf21055 --- /dev/null +++ b/thirdparty/galgo/galgo/Galgo.hpp @@ -0,0 +1,90 @@ +//================================================================================================= +// Copyright (C) 2018 Alain Lanthier - All Rights Reserved +// License: MIT License See LICENSE.md for the full license. +// Original code 2017 Olivier Mallet (MIT License) +//================================================================================================= + +#ifndef GALGO_H +#define GALGO_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/*-------------------------------------------------------------------------------------------------*/ + +namespace galgo { + +// forward declarations +template +struct ConfigInfo; + +template +struct MutationInfo; + +template +class BaseParameter; + +template +class Parameter; + +template +class GeneticAlgorithm; + +template +class Population; + +template +class Chromosome; + +// convenient typedefs +template +using CHR = std::shared_ptr>; + +template +using PAR = std::unique_ptr>; + +template +using TUP = std::tuple&...>; + +} + +/*-------------------------------------------------------------------------------------------------*/ + +#ifdef _OPENMP + #include + // getting maximum number of threads available + static const int MAX_THREADS = omp_get_max_threads(); +#endif + +/*-------------------------------------------------------------------------------------------------*/ + +#include "Randomize.hpp" +#include "Converter.hpp" +#include "Parameter.hpp" +#include "Evolution.hpp" +#include "Chromosome.hpp" +#include "Population.hpp" +#include "GeneticAlgorithm.hpp" + +//================================================================================================= + +#endif + diff --git a/thirdparty/galgo/galgo/GeneticAlgorithm.hpp b/thirdparty/galgo/galgo/GeneticAlgorithm.hpp new file mode 100755 index 0000000000..1150921fc9 --- /dev/null +++ b/thirdparty/galgo/galgo/GeneticAlgorithm.hpp @@ -0,0 +1,540 @@ +//================================================================================================= +// Copyright (C) 2018 Alain Lanthier - All Rights Reserved +// License: MIT License See LICENSE.md for the full license. +// Original code 2017 Olivier Mallet (MIT License) +//================================================================================================= + +#ifndef GENETICALGORITHM_HPP +#define GENETICALGORITHM_HPP + +namespace galgo { + +enum class MutationType { + MutationSPM, + MutationBDM, + MutationUNM, + MutationGAM_UncorrelatedOneStepSizeFixed, + MutationGAM_UncorrelatedOneStepSizeBoundary, + MutationGAM_UncorrelatedNStepSize, + MutationGAM_UncorrelatedNStepSizeBoundary, + MutationGAM_sigma_adapting_per_generation, + MutationGAM_sigma_adapting_per_mutation, +}; + +template +struct MutationInfo +{ + MutationInfo() : + _type(MutationType::MutationSPM), + _sigma(1.0), + _ratio_boundary(1.0 / 10.0), //default: 1.0/6.0 + _sigma_lowest(0.001) // default: 0.0001 + { + } + + MutationType _type; + double _sigma; + double _ratio_boundary; + double _sigma_lowest; +}; + +template +struct ConfigInfo +{ + ConfigInfo() : mutinfo() + { + // DEFAULTS + covrate = 0.4; // cross-over rate + mutrate = 0.6; // mutation rate usually is 1.0 for real-valued + SP = 1.5; + tolerance = 0.0; + recombination_ratio = 0.60; //Real Valued crossover ratio, can't be 0.5 because 0.5 will generate two same offsprings after Xover + + elitpop = 1; + tntsize = 2; // k-tournament size k=2/4, higher value higher pressure + precision = 10; + + Objective = nullptr; + Selection = TNT; // RWS, TNT, RNK, RSP, TRS + CrossOver = RealValuedSimpleArithmeticRecombination; // + //Mutation = SPM; // derived from by mutinfo._type + Adaptation = nullptr; + Constraint = nullptr; + FixedValue = nullptr; + StopCondition = nullptr; + + nbgen = 125; //The num of gens for EA, 131+19, 125+25, 122+28 + popsize = 10; + output = false; + } + + MutationInfo mutinfo; + + double covrate; + double mutrate; + double SP; + double tolerance; + double recombination_ratio; + + int elitpop; + //int matsize; // set to popsize when ga is constructed, maybe change by ga.matsize = ... after constructor and before ga.run() + int tntsize; + int precision; + + std::vector (*Objective)(const std::vector&); + void (*Selection)(Population&); + void (*CrossOver)(const Population&, CHR&, CHR&); + void (*Mutation)(CHR&); + void (*Adaptation)(Population&) = nullptr; + std::vector (*Constraint)(const std::vector&); + void (*FixedValue)(Population&, int k); + bool (*StopCondition)(galgo::GeneticAlgorithm&); + + std::vector force_value_flag; + std::vector force_value; + + int nbgen; + int popsize; + bool output; +}; + + +/*-------------------------------------------------------------------------------------------------*/ + +template +class GeneticAlgorithm +{ + template friend class Population; + template friend class Chromosome; + template using FuncKT = std::vector(*)(const std::vector&); + +protected: + Population pop; // population of chromosomes + std::vector> param; // parameter(s) + std::vector lowerBound; // parameter(s) lower bound + std::vector upperBound; // parameter(s) upper bound + std::vector initialSet; // initial set of parameter(s) + std::vector idx; // indexes for chromosome breakdown + +public: + // objective function pointer + FuncKT Objective; + + // selection method initialized to roulette wheel selection + void (*Selection)(Population&) = TNT; + + // cross-over method initialized to 1-point cross-over + void(*CrossOver)(const Population&, CHR&, CHR&) = RealValuedSimpleArithmeticRecombination; + + // mutation method initialized to single-point mutation + void (*Mutation)(CHR&, size_t current_iteration, double gaussian_step_size) = GAM_UncorrelatedNStepSizeBoundary; + + // adaptation to constraint(s) method + void (*Adaptation)(Population&) = nullptr; + + // constraint(s) + std::vector (*Constraint)(const std::vector&) = nullptr; + + MutationInfo mutinfo; + + double covrate = 0.4; // cross-over rate + double mutrate = 0.6; // mutation rate + double SP = 1.5; // selective pressure for RSP selection method + double tolerance = 0.0; // terminal condition (inactive if equal to zero) + double recombination_ratio = 0.60; // Real Valued crossover ratio number = popsize * recombination_ratio + + int elitpop = 1; // elit population size + int matsize; // mating pool size, set to popsize by default + int tntsize = 2; // k-tournament size k=2/4, higher value higher pressure + int precision = 10; // precision for outputting results + bool output; // control if results must be outputted + + // Prototype to set fixed value of parameters while evolving + void (*FixedValue)(Population&, int k) = nullptr; + std::vector force_value_flag; + std::vector force_value; + + bool (*StopCondition)(GeneticAlgorithm&) = nullptr; + + // constructor + template GeneticAlgorithm(FuncKT objective, int popsize, int nbgen, bool output, MutationInfo mutinfo, const Parameter&...args); + template GeneticAlgorithm(const ConfigInfo& config, const Parameter&...args); + + // initialize populations to genetic algorithm, and return populations +// void init_run(std::vector< Eigen::VectorXd > samples); + + // run genetic algorithm + void run(std::string learner_algorithm, + size_t current_iteration, + double gaussian_step_size, + size_t switch_num, + std::vector samples, + std::vector observations); + + // return the last sample + Eigen::VectorXd get_sample(int i); + + // return best chromosome + const CHR& result() const; + + // print results for each new generation + void print(bool force = false) const; + + Population& get_pop() { return pop; } + +protected: + void setMutation(const MutationInfo& mt) + { + mutinfo = mt; +// if (mt._type == MutationType::MutationSPM) { Mutation = SPM; } +// else if (mt._type == MutationType::MutationBDM) { Mutation = BDM; } +// else if (mt._type == MutationType::MutationUNM) { Mutation = UNM; } +// else if (mt._type == MutationType::MutationGAM_UncorrelatedOneStepSizeFixed) { Mutation = GAM_UncorrelatedOneStepSizeFixed; } +// else if (mt._type == MutationType::MutationGAM_UncorrelatedOneStepSizeBoundary) { Mutation = GAM_UncorrelatedOneStepSizeBoundary; } +// else if (mt._type == MutationType::MutationGAM_UncorrelatedNStepSize) { Mutation = GAM_UncorrelatedNStepSize; } +// else if (mt._type == MutationType::MutationGAM_UncorrelatedNStepSizeBoundary) { Mutation = GAM_UncorrelatedNStepSizeBoundary; } +// else if (mt._type == MutationType::MutationGAM_sigma_adapting_per_generation) { Mutation = GAM_sigma_adapting_per_generation; } +// else if (mt._type == MutationType::MutationGAM_sigma_adapting_per_mutation) { Mutation = GAM_sigma_adapting_per_mutation; } +// else Mutation = SPM; + if (mt._type == MutationType::MutationGAM_UncorrelatedNStepSizeBoundary) { Mutation = GAM_UncorrelatedNStepSizeBoundary; } + + } + + GeneticAlgorithm(const ConfigInfo& config); // No parameters set + + int nbbit; // total number of bits per chromosome + int nbgen; // number of generations + int nogen = 0; // numero of generation + int nbparam; // number of parameters to be estimated + int popsize; // population size + + // end of recursion for initializing parameter(s) data + template + typename std::enable_if::type init(const TUP&); + + // recursion for initializing parameter(s) data + template + typename std::enable_if::type init(const TUP&); + + // check inputs validity + void check() const ; + + void init_from_config(const ConfigInfo& config); +}; + +/*-------------------------------------------------------------------------------------------------*/ +//template +//class GeneticAlgorithmN : public GeneticAlgorithm +//{ +//public: +// // constructor +// GeneticAlgorithmN(const ConfigInfo& config, +// std::vector& _lowerBound, +// std::vector& _upperBound, +// std::vector& _initialSet); +//}; + +/*-------------------------------------------------------------------------------------------------*/ +template +void GeneticAlgorithm::init_from_config(const ConfigInfo& config) +{ + setMutation(config.mutinfo); // Mutation is set here + + Objective = config.Objective; + Selection = config.Selection; + CrossOver = config.CrossOver; + Adaptation = config.Adaptation; + Constraint = config.Constraint; + FixedValue = config.FixedValue; + StopCondition = config.StopCondition; + + covrate = config.covrate; + mutrate = config.mutrate; + SP = config.SP; + tolerance = config.tolerance; + recombination_ratio = config.recombination_ratio; + + elitpop = config.elitpop; + tntsize = config.tntsize; + precision = config.precision; + + force_value_flag = config.force_value_flag; + force_value = config.force_value; + + nbgen = config.nbgen; + popsize = config.popsize; + matsize = popsize; // matsize default to popsize + output = config.output; + + nogen = 0; +} + +template template +GeneticAlgorithm::GeneticAlgorithm(const ConfigInfo& config, const Parameter&...args) +{ + init_from_config(config); + + nbbit = sum(N...); + nbparam = sizeof...(N); + TUP tp(args...); + init(tp); +} + +template +GeneticAlgorithm::GeneticAlgorithm(const ConfigInfo& config) +{ + init_from_config(config); +} + +// constructor +template template +GeneticAlgorithm::GeneticAlgorithm(FuncKT objective, int popsize, int nbgen, bool output, MutationInfo mutinfo, const Parameter&...args) +{ + setMutation(mutinfo); + Objective = objective; + + // getting total number of bits per chromosome + nbbit = sum(N...); + nbgen = nbgen; + + // getting number of parameters in the pack + nbparam = sizeof...(N); + + popsize = popsize; + matsize = popsize; + output = output; + + // unpacking parameter pack in tuple + TUP tp(args...); + + // initializing parameter(s) data + init(tp); +} + +//// constructor +//template +//GeneticAlgorithmN::GeneticAlgorithmN(const ConfigInfo& _config, std::vector& _lowerBound, std::vector& _upperBound, std::vector& _initialSet) +// : GeneticAlgorithm(_config) +//{ +// for (int i = 0; i<_lowerBound.size(); i++) +// { +// std::vector w; +// w.push_back(_lowerBound[i]); w.push_back(_upperBound[i]); w.push_back(_initialSet[i]); +// Parameter p(w); +// param.emplace_back(new decltype(p)(p)); +// +// if (i == 0) idx.push_back(0); +// else idx.push_back(idx[i - 1] + PARAM_NBIT); +// } +// lowerBound = _lowerBound; +// upperBound = _upperBound; +// initialSet = _initialSet; +// +// nbbit = (int)_lowerBound.size()*PARAM_NBIT; +// nbparam = (int)_lowerBound.size(); +//}; + +/*-------------------------------------------------------------------------------------------------*/ + +// end of recursion for initializing parameter(s) data +template template +inline typename std::enable_if::type +GeneticAlgorithm::init(const TUP& tp) {} + +// recursion for initializing parameter(s) data +template template +inline typename std::enable_if::type +GeneticAlgorithm::init(const TUP& tp) +{ + // getting Ith parameter in tuple + auto par = std::get(tp); + + // getting Ith parameter initial data + const std::vector& data = par.getData(); + + // copying parameter data + param.emplace_back(new decltype(par)(par)); + + lowerBound.push_back(data[0]); + upperBound.push_back(data[1]); + + // if parameter has initial value + if (data.size() > 2) { + initialSet.push_back(data[2]); + } + // setting indexes for chromosome breakdown + if (I == 0) { + idx.push_back(0); + } else { + idx.push_back(idx[I - 1] + par.size()); + } + // recursing + init(tp); +} + +/*-------------------------------------------------------------------------------------------------*/ + +// check inputs validity +template +void GeneticAlgorithm::check() const +{ + if (!initialSet.empty()) { + for (int i = 0; i < nbparam; ++i) { + if (initialSet[i] < lowerBound[i] || initialSet[i] > upperBound[i]) { + throw std::invalid_argument("Error: in class galgo::Parameter, initial parameter value cannot be outside the parameter boundaries, please choose a value between its lower and upper bounds."); + } + } + if (initialSet.size() != (unsigned)nbparam) { + throw std::invalid_argument("Error: in class galgo::GeneticAlgorithm, initial set of parameters does not have the same dimension than the number of parameters, please adjust."); + } + } + if (SP < 1.0 || SP > 2.0) { + throw std::invalid_argument("Error: in class galgo::GeneticAlgorithm, selective pressure (SP) cannot be outside [1.0,2.0], please choose a real value within this interval."); + } + if (elitpop > popsize || elitpop < 0) { + throw std::invalid_argument("Error: in class galgo::GeneticAlgorithm, elit population (elitpop) cannot outside [0,popsize], please choose an integral value within this interval."); + } + if (covrate < 0.0 || covrate > 1.0) { + throw std::invalid_argument("Error: in class galgo::GeneticAlgorithm, cross-over rate (covrate) cannot outside [0.0,1.0], please choose a real value within this interval."); + } +} + +/*-------------------------------------------------------------------------------------------------*/ +// initialize populations to genetic algorithm +//template +//void GeneticAlgorithm::init_run(std::vector< Eigen::VectorXd > samples) +//{ +// std::cout << "Running init_run() for initial random sampling in EA ...\n"; +// double bestResult; +// double prevBestResult; +// // checking inputs validity +// check(); +// +// // setting adaptation method to default if needed +// if (Constraint != nullptr && Adaptation == nullptr) { +// Adaptation = DAC; +// } +// +// // initializing population +// pop = Population(*this); +// +// // creating population +// pop.creation(samples); +// +// // initializing best result and previous best result +// ////TODO different bestResult for Revolve +// bestResult = pop(0)->getTotal(); +// prevBestResult = bestResult; +// +// // outputting results +// if (output) print(); +//} + +template +Eigen::VectorXd GeneticAlgorithm::get_sample(int i) +{ + // return the i_th individual + std::vector individual = pop.get_individual(i); + // transfer std::vector to Eigen::VectorXd + Eigen::VectorXd sample = Eigen::Map(individual.data(), individual.size()); + return sample; // return Eigen::VectorXd +} + +/*-------------------------------------------------------------------------------------------------*/ +// run genetic algorithm +template +void GeneticAlgorithm::run(std::string learner_algorithm, + size_t current_iteration, + double gaussian_step_size, + size_t switch_num, + std::vector samples, + std::vector observations) +{ +// std::cout << "Running run() ....\n"; + // checking inputs validity + check(); + + // setting adaptation method to default if needed + if (Constraint != nullptr && Adaptation == nullptr) { + Adaptation = DAC; + } + + // initializing population + pop = Population(*this); + + // creating population + pop.creation(learner_algorithm, current_iteration, switch_num, samples, observations); + + // outputting results + if (output) print(); + + // starting population evolution + pop.evolution(current_iteration, gaussian_step_size); +} + +/*-------------------------------------------------------------------------------------------------*/ + +// return best chromosome +template +inline const CHR& GeneticAlgorithm::result() const +{ + return pop(0); +} + +/*-------------------------------------------------------------------------------------------------*/ + +// print results for each new generation +template +void GeneticAlgorithm::print(bool force) const +{ + // getting best parameter(s) from best chromosome + std::vector< T > bestParam = pop(0)->getParam(); + std::vector< double > bestResult = pop(0)->getResult(); + + std::cout << " Generation = " << std::setw(std::to_string(nbgen).size()) + << nogen << " |"; + for (int i = 0; i < nbparam; ++i) + { + std::cout << " X"; + if (nbparam > 1) + { + std::cout << std::to_string(i + 1); + } + std::cout << " = " << std::setw(2 + precision) << std::fixed + << std::setprecision(precision) << bestParam[i] << " |"; + } + for (unsigned i = 0; i < bestResult.size(); ++i) + { + std::cout << " F"; + if (bestResult.size() > 1) + { + std::cout << std::to_string(i + 1); + } + std::cout << "(x) = " << std::setw(12) << std::fixed + << std::setprecision(precision) << bestResult[i]; + + if(nogen not_eq 0) + { + //save the best value + std::ofstream value; + value.open("../value.txt", std::ios::app); + value << std::fixed << bestResult[i] << std::endl; + } + + if (i < bestResult.size() - 1) + { + std::cout << " |"; + } + else + { + std::cout << "\n"; + } + } + std::cout << std::endl; +} + +//================================================================================================= + +} + +#endif diff --git a/thirdparty/galgo/galgo/Parameter.hpp b/thirdparty/galgo/galgo/Parameter.hpp new file mode 100755 index 0000000000..41b2a9070d --- /dev/null +++ b/thirdparty/galgo/galgo/Parameter.hpp @@ -0,0 +1,126 @@ +//================================================================================================= +// Copyright (C) 2018 Alain Lanthier - All Rights Reserved +// License: MIT License See LICENSE.md for the full license. +// Original code 2017 Olivier Mallet (MIT License) +//================================================================================================= + +#ifndef PARAMETER_H +#define PARAMETER_H + +namespace galgo { + +// end of recursion for computing the sum of a parameter pack of integral numbers +int sum(int first) +{ + return first; +} + +// recursion for computing the sum of a parameter pack of integral numbers +template +int sum(int first, Args...args) +{ + return first + sum(args...); +} + +/*-------------------------------------------------------------------------------------------------*/ + +// abstract base class for Parameter objects +template +class BaseParameter +{ +public: + virtual ~BaseParameter() {} + virtual std::string encode() const = 0; + virtual std::string encode(T z) const = 0; + virtual T decode(const std::string& y) const = 0; + virtual int size() const = 0; + virtual const std::vector& getData() const = 0; +}; + +/*-------------------------------------------------------------------------------------------------*/ + +template +class Parameter : public BaseParameter +{ + template + friend class Chromosome; + +private: + std::vector data; // contains lower bound, upper bound and initial value (optional) + +public: + // default constructor + Parameter() + { + } + + // constructor + Parameter(const std::vector& data) + { + if (data.size() < 2) { + throw std::invalid_argument("Error: in class galgo::Parameter, argument must contain at least 2 elements of type T, the lower bound and the upper bound, please adjust."); + } + if (data[0] >= data[1]) { + throw std::invalid_argument("Error: in class galgo::Parameter, first argument (lower bound) cannot be equal or greater than second argument (upper bound), please amend."); + } + this->data = data; + } + // return encoded parameter size in number of bits + int size() const override { + return N; + } + // return parameter initial data + const std::vector& getData() const override { + return data; + } + + +private: + // encoding random unsigned integer + std::string encode() const override + { + std::string str = GetBinary(galgo::Randomize::generate()); + return str.substr(str.size() - N, N); + } + + // encoding known unsigned integer + std::string encode(T z) const override + { + if (std::is_integral::value) + { + uint64_t value = (uint64_t)(z - data[0]); + std::string str = GetBinary(value); + return str.substr(str.size() - N, N); + } + else + { + uint64_t value = (uint64_t)(Randomize::MAXVAL * (z - data[0]) / (data[1] - data[0])); + std::string str = GetBinary(value); + return str.substr(str.size() - N, N); + } + } + + // decoding string + T decode(const std::string& str) const override + { + if (std::is_integral::value) + { + int64_t d0 = (int64_t)data[0]; + int64_t r = d0 + GetValue(str); + int64_t v = std::min(std::max(r, static_cast(data[0])), static_cast(data[1])); + return (T)v; + } + else + { + // decoding string to real value + // Randomize::MAXVAL=> 0,1,3,7,15,31,... + return (T)(data[0] + (GetValue(str) / static_cast(Randomize::MAXVAL)) * (data[1] - data[0])); + } + } +}; + +//================================================================================================= + +} + +#endif diff --git a/thirdparty/galgo/galgo/Population.hpp b/thirdparty/galgo/galgo/Population.hpp new file mode 100755 index 0000000000..40b6067764 --- /dev/null +++ b/thirdparty/galgo/galgo/Population.hpp @@ -0,0 +1,604 @@ +//================================================================================================= +// Copyright (C) 2018 Alain Lanthier - All Rights Reserved +// License: MIT License See LICENSE.md for the full license. +// Original code 2017 Olivier Mallet (MIT License) +//================================================================================================= + +#ifndef POPULATION_HPP +#define POPULATION_HPP + +#include +#include +#include "opencv2/highgui/highgui.hpp" +#include "opencv2/core/core.hpp" +#include +#include + +namespace galgo +{ + + template class Population + { + public: + // nullary constructor + Population() + { + } + + // constructor + Population(const GeneticAlgorithm &ga); + + // create a population of chromosomes + void creation(std::string learner_algorithm, + size_t current_iteration, + size_t switch_num, + std::vector< Eigen::VectorXd> samples, + std::vector observations); + + // evolve population, get next generation + void evolution(size_t current_iteration, double gaussian_step_size); + + //get individuals + std::vector get_individual(int i); + + // access element in current population at position pos + const CHR &operator()(int pos) const; + + // access element in mating population at position pos + const CHR &operator[](int pos) const; + + // return iterator to current population beginning + typename std::vector< CHR < T>>:: + + iterator begin(); + + // return const iterator to current population beginning + typename std::vector< CHR < T>>:: + + const_iterator cbegin() const; + + // return iterator to current population ending + typename std::vector< CHR < T>>:: + + iterator end(); + + // return const iterator to current population ending + typename std::vector< CHR < T>>:: + + const_iterator cend() const; + + // select element at position pos in current population and copy it into mating population + void select(int pos); + + // set all fitness to positive values + void adjustFitness(); + + // compute fitness sum of current population + double getSumFitness() const; + + // get worst objective function total result from current population + double getWorstTotal() const; + + // return population size + int popsize() const; + + // return mating population size + int matsize() const; + + // return tournament size + int tntsize() const; + + // return numero of generation + int nogen() const; + + // return number of generations + int nbgen() const; + + // return selection pressure + double SP() const; + + const GeneticAlgorithm *ga_algo() { return ptr;} + + std::vector>& get_newpop() { return newpop;} + + std::vector>& get_curpop() { return curpop;} + + private: + std::vector< CHR < T>> curpop; // current population + std::vector< CHR < T>> matpop; // mating population + std::vector< CHR < T>> newpop; // new population + + const GeneticAlgorithm *ptr = nullptr; // pointer to genetic algorithm + int nbrcrov; // number of cross-over + int matidx; // mating population index + + // elitism => saving best chromosomes in new population + void elitism(); + + // create new population from recombination of the old one + void recombination(size_t current_iteration, double gaussian_step_size); + + // complete new population randomly + void completion(size_t current_iteration, double gaussian_step_size); + + // update population (adapting, sorting) + void updating(); + + bool compare_Xd(const Eigen::VectorXd& lhs, const Eigen::VectorXd& rhs) + { + return lhs(0) < rhs(0); + } + }; + + /*-------------------------------------------------------------------------------------------------*/ + + // constructor + template + Population< T >::Population(const GeneticAlgorithm &ga) + { + ptr = &ga; + nbrcrov = (int)ceil(ga.covrate * (ga.popsize - ga.elitpop)); + + // adjusting nbrcrov (must be an even number) + if (nbrcrov % 2 != 0) + { + nbrcrov += 1; + } + + // for convenience, we add elitpop to nbrcrov + nbrcrov += ga.elitpop; + + // allocating memory + curpop.resize(ga.popsize); + matpop.resize(ga.matsize); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // create a population of chromosomes + template void Population< T >::creation(std::string learner_algorithm, + size_t current_iteration, + size_t switch_num, + std::vector< Eigen::VectorXd> samples, + std::vector< Eigen::VectorXd> observations) + { + int start = 0; + + // initializing first chromosome + if (!ptr->initialSet.empty()) + { + curpop[0] = std::make_shared< Chromosome< T>>(*ptr); + curpop[0]->initialize(); //create new chromosome by encoding value to binary + curpop[0]->evaluate(); //encoding binary to value and calculating fitness + start++; + } + // getting the rest + #ifdef _OPENMP + #pragma omp parallel for num_threads(MAX_THREADS) + #endif + + if(learner_algorithm == "EA") + { + for (int i = start; i < ptr->popsize; ++i) + { + curpop[i] = std::make_shared< Chromosome< T>>(*ptr); + curpop[i]->create(i, samples[i]); + curpop[i]->evaluate0gen(observations[i]); //row 316 in Chromosome.hpp + } + } + +/////**** the interface to bayesian optimization ****/// + if(learner_algorithm == "BOEA") + { + std::cout << "switch_num: " << switch_num << std::endl; + // load the individuals from BO + if(current_iteration == switch_num) + { + int dimens = samples[0].size(); // curpop[i]->nbgene() + std::cout << "dimens: " << dimens << std::endl; + std::vector< Eigen::VectorXd > boea_observations = observations; + std::cout << " boea_observations.size(): " << boea_observations.size() << std::endl; + std::sort(boea_observations.begin(), boea_observations.end(), [](const Eigen::VectorXd& lhs, const Eigen::VectorXd& rhs) {return lhs(0) > rhs(0);}); + std::cout << "boea_observations: " << std::endl; + for (int i = 0; i < boea_observations.size(); i++) + { + std::cout << boea_observations[i] << " "; + } + std::cout << std::endl; + + std::vector< Eigen::VectorXd > boea_samples(ptr->popsize); + for (int i = 0; i < ptr->popsize; i++) + { + for (int j = 0; j < boea_observations.size(); j++) + { + if (boea_observations[i] == observations[j]) + { + std::cout << "i: " << i << " " << boea_observations[i] << " " + << observations[j] << std::endl; + std::cout << "samples[" << j << "] " << samples[j] << std::endl; + boea_samples[i] = samples[j]; + std::cout << "boea_samples[" << i << "]: " << boea_samples[i] << std::endl; + } + } + } + + for (int i = start; i < ptr->popsize; ++i) + { + curpop[i] = std::make_shared< Chromosome< T>>(*ptr); + curpop[i]->create(i, boea_samples[i]); + curpop[i]->evaluate0gen(boea_observations[i]); //row 316 in Chromosome.hpp + } + } + else + { + for (int i = start; i < ptr->popsize; ++i) + { + curpop[i] = std::make_shared< Chromosome< T>>(*ptr); + curpop[i]->create(i, samples[i]); + curpop[i]->evaluate0gen(observations[i]); //row 316 in Chromosome.hpp + } + } + } + + // updating population: sorting chromosomes from best to worst fitness + this->updating(); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // population evolution (selection, recombination, completion, mutation), get next generation + template void Population< T >::evolution(size_t current_iteration, double gaussian_step_size) + { + // initializing mating population index + matidx = 0; + + // selecting mating population + // curpop[] -> matpop[] + ptr->Selection(*this); + + // applying elitism if required + // curpop[] -> newpop[0...elitpop-1] + this->elitism(); + + // crossing-over mating population + // matpop[] -> newpop[elitpop...nbrcrov-1] // crossover + mutation + this->recombination(current_iteration, gaussian_step_size); + + // completing new population // only mutation + // matpop[] -> newpop[nbrcrov...popsize] + this->completion(current_iteration, gaussian_step_size); + + // moving new population into current population for next generation + curpop = std::move(newpop); +// // galgo::CHR< T > &chr +// std::cout << "nbgene: " << curpop[0]->nbgene() << std::endl; +// double individual = curpop[1]->get_value(0); +// std::cout << "curpop.begin(): " << individual << std::endl; + + // updating population, sorting chromosomes from best to worst fitnes +// this->updating(); + +// std::cout << "curpop.begin(): " << curpop[1]->get_value(0) << std::endl; + } + + template + std::vector Population< T >::get_individual(int i) + { + int nbparams = curpop[i]->nbgene(); + std::vector individual(nbparams); + //get the parameters of i_th individual + for(int j = 0; j < nbparams; j++) + { + individual[j] = curpop[i]->get_value(j); + std::cout << individual[j] << " "; + } + std::cout << std::endl; + return individual; + } + /*-------------------------------------------------------------------------------------------------*/ + + // elitism => saving best chromosomes in new population, making a copy of each elit chromosome + template void Population< T >::elitism() + { + // (re)allocating new population + newpop.resize(ptr->popsize); + + if (ptr->elitpop > 0) + { + // copying elit chromosomes into new population + std::transform(curpop.cbegin(), + curpop.cend(), + newpop.begin(), + [](const CHR< T > &chr) -> CHR< T > + { return std::make_shared< Chromosome< T>>(*chr); }); + + for (size_t i = 0; i < curpop.size(); i++) + { + transmit_sigma< T >(*curpop[i], *newpop[i]); + } + } + } + + /*-------------------------------------------------------------------------------------------------*/ + + // create new population from recombination of the old one + template void Population< T >::recombination(size_t current_iteration, double gaussian_step_size) + { + // creating a new population by cross-over +#ifdef _OPENMP +#pragma omp parallel for num_threads(MAX_THREADS) +#endif + + for (int i = ptr->elitpop; i < nbrcrov; i = i + 2) + { + // initializing 2 new chromosome + newpop[i] = std::make_shared< Chromosome< T>>(*ptr); + newpop[i + 1] = std::make_shared< Chromosome< T>>(*ptr); + + // crossing-over mating population to create 2 new chromosomes + ptr->CrossOver(*this, newpop[i], newpop[i + 1]); + + // mutating new chromosomes + ptr->Mutation(newpop[i], current_iteration, gaussian_step_size); + ptr->Mutation(newpop[i + 1], current_iteration, gaussian_step_size); + + if (ptr->FixedValue != nullptr) + { + ptr->FixedValue(*this, i); + ptr->FixedValue(*this, i + 1); + } + + // evaluating new chromosomes + //std::cout << "Nu_evaluation_re: " << i; +// newpop[i]->evaluate(); + //std::cout << "Nu_evaluation_re- " << (i + 1); +// newpop[i + 1]->evaluate(); + } + } + + /*-------------------------------------------------------------------------------------------------*/ + + // complete new population + template void Population< T >::completion(size_t current_iteration, double gaussian_step_size) + { +#ifdef _OPENMP +#pragma omp parallel for num_threads(MAX_THREADS) +#endif + for (int i = nbrcrov; i < ptr->popsize; ++i) + { + // selecting chromosome randomly from mating population + int pos = uniform< int >(0, ptr->matsize); + newpop[i] = std::make_shared< Chromosome< T>>(*matpop[pos]); + transmit_sigma< T >(*matpop[pos], *newpop[i]); + + // mutating chromosome + ptr->Mutation(newpop[i], current_iteration, gaussian_step_size); + + if (ptr->FixedValue != nullptr) + { + ptr->FixedValue(*this, i); + } + //std::cout << "Nu_evaluation_com: " << i; + // evaluating chromosome +// newpop[i]->evaluate(); + } + } + + /*-------------------------------------------------------------------------------------------------*/ + + // update population (adapting, sorting) + template void Population< T >::updating() + { +// std::cout << "update population: sorting chromosomes from best to worst fitness" << std::endl; + // adapting population to constraints + if (ptr->Constraint != nullptr) + { + ptr->Adaptation(*this); + } + // sorting chromosomes from best to worst fitness + std::sort(curpop.begin(), curpop.end(), [](const CHR& chr1, const CHR& chr2)->bool{return chr1->fitness > chr2->fitness;}); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // access element in current population at position pos + template + const CHR &Population< T >::operator()(int pos) const + { +#ifndef NDEBUG + if (pos > ptr->popsize - 1) + { + throw std::invalid_argument( + "Error: in galgo::Population::operator()(int), exceeding current population memory."); + } +#endif + + return curpop[pos]; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // access element in mating population at position pos + template + const CHR &Population< T >::operator[](int pos) const + { +#ifndef NDEBUG + if (pos > ptr->matsize - 1) + { + throw std::invalid_argument( + "Error: in galgo::Population::operator[](int), exceeding mating population memory."); + } +#endif + + return matpop[pos]; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return iterator to current population beginning + template inline typename std::vector< CHR < T>> + + ::iterator Population< T >::begin() + { + return curpop.begin(); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return const iterator to current population beginning + template inline typename std::vector< CHR < T>> + + ::const_iterator Population< T >::cbegin() const + { + return curpop.cbegin(); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return iterator to current population ending + template inline typename std::vector< CHR < T>> + + ::iterator Population< T >::end() + { + return curpop.end(); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return const iterator to current population ending + template inline typename std::vector< CHR < T>> + + ::const_iterator Population< T >::cend() const + { + return curpop.cend(); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // select element at position pos in current population and copy it into mating population + template inline void Population< T >::select(int pos) + { +#ifndef NDEBUG + if (pos > ptr->popsize - 1) + { + throw std::invalid_argument( + "Error: in galgo::Population::select(int), exceeding current population memory."); + } + if (matidx == ptr->matsize) + { + throw std::invalid_argument( + "Error: in galgo::Population::select(int), exceeding mating population memory."); + } +#endif + + matpop[matidx] = curpop[pos]; + matidx++; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // set all fitness to positive values (used in RWS and SUS selection methods) + template void Population< T >::adjustFitness() + { + // getting worst population fitness + double worstFitness = curpop.back()->fitness; + + if (worstFitness < 0) + { + // getting best fitness + double bestFitness = curpop.front()->fitness; + // case where all fitness are equal and negative + if (worstFitness == bestFitness) + { + std::for_each(curpop.begin(), curpop.end(), [](CHR< T > &chr) -> void + { chr->fitness *= -1; }); + } + else + { + std::for_each(curpop.begin(), + curpop.end(), + [worstFitness](CHR< T > &chr) -> void + { chr->fitness -= worstFitness; }); + } + } + } + + /*-------------------------------------------------------------------------------------------------*/ + + // compute population fitness sum (used in TRS, RWS and SUS selection methods) + template inline double Population< T >::getSumFitness() const + { + return std::accumulate(curpop.cbegin(), curpop.cend(), 0.0, []( + double sum, + const CHR< T > &chr) -> double + { return sum + chr->fitness; }); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // get worst objective function total result from current population (used in constraint(s) adaptation) + template inline double Population< T >::getWorstTotal() const + { + auto it = std::min_element(curpop.begin(), curpop.end(), []( + const CHR< T > &chr1, + const CHR< T > &chr2) -> bool + { return chr1->getTotal() < chr2->getTotal(); }); + return (*it)->getTotal(); + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return population size + template inline int Population< T >::popsize() const + { + return ptr->popsize; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return mating population size + template inline int Population< T >::matsize() const + { + return ptr->matsize; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return tournament size + template inline int Population< T >::tntsize() const + { + return ptr->tntsize; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return numero of generation + template inline int Population< T >::nogen() const + { + return ptr->nogen; + } + + + /*-------------------------------------------------------------------------------------------------*/ + + // return number of generations + template inline int Population< T >::nbgen() const + { + return ptr->nbgen; + } + + /*-------------------------------------------------------------------------------------------------*/ + + // return selection pressure + template inline double Population< T >::SP() const + { + return ptr->SP; + } + + //================================================================================================= + +} + +#endif + + diff --git a/thirdparty/galgo/galgo/Randomize.hpp b/thirdparty/galgo/galgo/Randomize.hpp new file mode 100755 index 0000000000..2a5e96bd91 --- /dev/null +++ b/thirdparty/galgo/galgo/Randomize.hpp @@ -0,0 +1,75 @@ +//================================================================================================= +// Copyright (C) 2018 Alain Lanthier - All Rights Reserved +// License: MIT License See LICENSE.md for the full license. +// Original code 2017 Olivier Mallet (MIT License) +//================================================================================================= + +#ifndef RANDOMIZE_H +#define RANDOMIZE_H + +namespace galgo { + +// template metaprogramming for getting maximum unsigned integral value from N bits +template +struct MAXVALUE +{ + enum : uint64_t{ value = 2 * MAXVALUE::value }; +}; + +// template specialization for initial case N = 0 +template <> +struct MAXVALUE<0> +{ + enum { value = 1 }; +}; + +/*-------------------------------------------------------------------------------------------------*/ + +// Mersenne Twister 19937 pseudo-random number generator +std::random_device rand_dev; +std::mt19937_64 rng(rand_dev()); + +// generate uniform random probability in range [0,1) +std::uniform_real_distribution<> proba(0, 1); + +/*-------------------------------------------------------------------------------------------------*/ + +// generate a uniform random number within the interval [min,max) +template +inline T uniform(T min, T max) +{ + #ifndef NDEBUG + if (min >= max) { + throw std::invalid_argument("Error: in galgo::uniform(T, T), first argument must be < to second argument."); + // std::cout << "Error: in galgo::uniform(T, T), first argument must be < to second argument." << std::endl; + } + #endif + + return (T) ( min + proba(rng) * (max - min)); +} + +/*-------------------------------------------------------------------------------------------------*/ + +// static class for generating random unsigned integral numbers +template +class Randomize +{ + static_assert(N > 0 && N <= 64, "in class galgo::Randomize, template parameter N cannot be ouside interval [1,64], please choose an integer within this interval."); + +public: + // computation only done once for each different N + static constexpr uint64_t MAXVAL = MAXVALUE::value - 1; + + // generating random unsigned long long integer on [0,MAXVAL] + static uint64_t generate() { + // class constructor only called once for each different N + static std::uniform_int_distribution udistrib(0,MAXVAL); + return udistrib(rng); + } +}; + +//================================================================================================= + +} + +#endif diff --git a/thirdparty/galgo/galgo/TestFunction.hpp b/thirdparty/galgo/galgo/TestFunction.hpp new file mode 100755 index 0000000000..3af6632b55 --- /dev/null +++ b/thirdparty/galgo/galgo/TestFunction.hpp @@ -0,0 +1,358 @@ +//================================================================================================= +// Copyright (C) 2018 Alain Lanthier - All Rights Reserved +// License: MIT License See LICENSE.md for the full license. +// Original code 2017 Olivier Mallet (MIT License) +//================================================================================================= + +#ifndef TESTFUNCTION_HPP +#define TESTFUNCTION_HPP + +/********** 1# ACKLEY function N Dimensions **************/ +template +class AckleyObjective +{ + public: + static std::vector Objective(const std::vector& x) + { + size_t dim_in = 5; + auto xx = x; + // transfer interval from [0, 1] to [-32.768, 32.768] + for (int i = 0; i < dim_in; i++) + { + xx[i] = 65.536 * x[i] - 32.768; + } + const double a = 20.; + const double b = 0.2; + const double c = 2 * M_PI; + double sum1 = 0.; + double sum2 = 0.; + for (size_t i = 0; i < dim_in; i++) + { + sum1 = sum1 + xx[i] * xx[i]; + sum2 = sum2 + std::cos(c * xx[i]); + } + double term1 = -a * std::exp(-b * std::sqrt(sum1 / dim_in)); + double term2 = -std::exp(sum2 / dim_in); + double obj = term1 + term2 + a + std::exp(1); + return {-obj}; //max = 0, at (0,...,0) + } +}; + +/********** 2# SCHWEFEL function N Dimensions **************/ +template +class SchwefelObjective //todo not accurate results +{ + public: + static std::vector Objective(const std::vector& x) + { + size_t dim_in = 20; + auto xx = x; + //transfer [0, 1] to [-500, 500] [250, 500] [100,500] [200,500] + for (int i = 0; i < dim_in; i++) + { + xx[i] = 300. * x[i] + 200.; + } + double sum = 0.; + for (size_t i = 0; i < dim_in; i++) + { + sum = sum + xx[i] * sin(sqrt(abs(xx[i]))); + } + double obj = 418.9829 * dim_in - sum;//X1 = 0.9209721088 | X2 = 0.9209100604 | F(x) = -0.0004374512 + return {-obj}; //maximum = 0 with (420.9687, ..., 420.9687) + } +}; + +/********** 3# Ellipsoid function N Dimensions **************/ +template +class EllipsoidObjective +{ + public: + static std::vector Objective(const std::vector& x) + { + size_t dim_in = 5; + double inner = 0., outer = 0.; + for (size_t i = 0; i < dim_in; ++i) + { + for(size_t j = 0; j < i; j++) + { + inner = inner + std::pow((131.072 * x[j] - 65.536), 2); //(-65.536, 65.536) + } + outer = outer + inner; + } + return {-outer}; //maximum = 0 at (0, ..., 0) + } +}; + +/********** 4# Sphere function N Dimensions **************/ +template +class SphereObjective +{ + public: + static std::vector Objective(const std::vector& x) + { + size_t dim_in = 5; + double inner = 0.; + for (size_t i = 0; i < dim_in; ++i) + { + inner = inner + std::pow((10. * x[i] - 5.), 2); + } + return {-inner}; //maximum = 0 with (0, 0) + } +}; + +/********** 5# Rosenbrock function N Dimensions **************/ +template +class RosenbrockObjective //todo not good results +{ + public: + static std::vector Objective(const std::vector& x) + { + size_t dim_in = 5; + auto xx = x; + // transfer interval from [0, 1] to [-5, 10] + for (int i = 0; i < dim_in; i++) + xx[i] = 15. * x[i] - 5.; + double sum = 0.; + double term = 0.; + double xnext = 0.; + for(size_t i = 0; i < (dim_in - 1); i++) + { + xnext = xx[i + 1]; + term = 100. * std::pow((xnext - xx[i] * xx[i]), 2.0) + std::pow((xx[i] - 1), 2.0); + sum = sum + term; + } + double obj = sum; + return {-obj}; //maximum = 0 with (1,...,1) + } +}; + +/********* 6# Michalewicz function N = 2/5/10 Dimensions **********/ +template +class MichalewiczObjective //todo not good results +{ + public: + static std::vector Objective(const std::vector& x) + { + size_t dim_in = 5; + auto xx = x; + // transfer interval from [0, 1] to [0, pi] + for (int i = 0; i < dim_in; i++) + xx[i] = M_PI * x[i]; + double sum = 0.; + double term = 0.; + double m = 10.; + for(size_t i = 0; i < dim_in; i++) + { + term = std::sin(xx[i]) * std::pow(std::sin(i * xx[i] * xx[i]/M_PI), 2 * m); + sum = sum + term; + } + double obj = sum; + return {obj}; //max= -1.8013(2D) at (2.20,1.57)/-4.687658(5D)/-9.66015(10D) + } +}; + +/********** 7# StyblinskiTang function N Dimensions ****************/ +template +class StyblinskiTangObjective +{ + public: + static std::vector Objective(const std::vector& x) + { + size_t dim_in = 20; + auto xx = x; + // transfer interval from [0, 1] to [-5, 5] [-4,4] + for (int i = 0; i < dim_in; i++) + xx[i] = 10. * x[i] - 5.; + double sum = 0.; + double term; + for(size_t i = 0; i < dim_in; i++) + { + term = std::pow(xx[i], 4.0) - 16 * xx[i] * xx[i] + 5 * xx[i]; + sum = sum + term; + } + double obj = sum/2.0; + return {-obj}; //max= 39.16599 * d, (5D:195.82995)at (-2.903534,...,-2.903534) + } +}; + +/********** Rastrigin function N Dimensions ****************/ +template +class RastriginObjective +{ + public: + static std::vector Objective(const std::vector& x) + { + size_t dim_in = 20; + auto xx = x; + //transfer interval from [0, 1] to [-3, 3] [-2, 2] [-5, 5] + for (int i = 0; i < dim_in; i++) + xx[i] = 4. * x[i] - 2.; + double f = 10. * dim_in; + for (size_t i = 0; i < dim_in; ++i) + f += xx[i] * xx[i] - 10. * std::cos(2 * M_PI * xx[i]); + return {-f}; //maximum = 0 with (0, 0, 0, 0); + } +}; + +/********** Griewank function N Dimensions ****************/ +template +class GriewankObjective +{ + public: + static std::vector Objective(const std::vector& x) + { + size_t dim_in = 20; + auto xx = x; + //transfer interval from [0, 1] to [-10, 10] or [-5, 5] [-6,6] + for (int i = 0; i < dim_in; i++) + xx[i] = 10. * x[i] - 5.; + double sum = 0.0, f = 1.0; + for (size_t i = 0; i < dim_in; ++i) + { + sum += xx[i] * xx[i]/4000; + f = f * std::cos(xx[i]/std::sqrt(i+1)); + } + double obj = sum - f + 1; + return {-obj}; //maximum = 0 with (0, 0, 0, 0); + } +}; + + +/********** 8# Powell function N >= 4 Dimensions *************/ +template +class PowellObjective //todo not good results +{ + public: + static std::vector Objective(const std::vector& x) + { + size_t dim_in = 5; + auto xx = x; + // transfer interval from [0, 1] to [-4, 5] + for (int i = 0; i < dim_in; i++) + xx[i] = 9 * x[i] - 4; + double sum = 0.; + double term1, term2, term3, term4; + for(size_t i = 0; i < dim_in/4; i++) + { + term1 = std::pow((xx[4 * i - 3] + 10 * xx[4 * i - 2]), 2.0); + term2 = 5 * std::pow((xx[4 * i - 1] - xx[4 * i]), 2.0); + term3 = std::pow(xx[4 * i - 2] - 2 * xx[4 * i - 1], 4.0); + term4 = 10 * std::pow(xx[4 * i - 3] - xx[4 * i], 4.0); + sum = sum + term1 + term2 + term3 + term4; + std::cout << std::endl << "i: " << i + << " sum: " << sum << " term1: " << term1 << " term2: " << term2 + << " term3: " << term3 << " term4: " << term4 << std::endl; + } + double obj = sum; + return {-obj}; //max= 0 at (0,...,0) + } +}; + +//// constraints example: +//template +//std::vector MyConstraint(const std::vector& x) +//{ +// double x0 = (double)x[0]; +// double x1 = (double)x[1]; +// return +// { +// //x[0]*x[1]+x[0]-x[1]+1.5, // 1) x * y + x - y + 1.5 <= 0 +// //10-x[0]*x[1] // 2) 10 - x * y <= 0 +// x0 - 2, // x0 <= 2 +// x1 - 2 // x1 <= 2 +// }; +//} + +/*Rastrigin Function*/ +template +double pso_rastrigin(std::vector< T > particle) +{ + double result(10. * static_cast (particle.size())), A(10.), PI(3.14159); + for (auto dim : particle) { + result += pow(dim, 2.) - (A * cos(2. * PI * dim)); + } + return (result); +} + +template +class rastriginObjective +{ +public: + static std::vector Objective(const std::vector& x) + { + std::vector xd(x.size()); + for (size_t i = 0; i < x.size(); i++) xd[i] = (double)x[i]; + + double obj = -pso_rastrigin(xd); + return { obj }; + } +}; + +/* +Griewank Function +*/ +template +double pso_griewank(std::vector< T > particle) +{ + double sum(0.), product(1.); + for (int i = 0; i < particle.size(); i++) { + sum += pow(particle[i], 2.); + product *= cos(particle[i] / sqrt(i + 1)); + } + return (1. + (sum / 4000.) - product); +} + +//template +//class GriewankObjective +//{ +//public: +// static std::vector Objective(const std::vector& x) +// { +// std::vector xd(x.size()); +// for (size_t i = 0; i < x.size(); i++) xd[i] = (double)x[i]; +// +// double obj = -pso_griewank(xd); +// return { obj }; +// } +//}; + +/* +Styblinski-Tang Function +Min = (-2.903534,...,--2.903534) +*/ +template +double pso_styb_tang(std::vector< T > particle) +{ + double result(0.); + for (auto dim : particle) { + result += pow(dim, 4.0) - (16. * pow(dim, 2.)) + (5. * dim); + } + return (result / 2.); +} + + +template +class SumSameAsPrdObjective +{ +public: + static std::vector Objective(const std::vector& x) + { + double x0 = (double)x[0]; + double x1 = (double)x[1]; + + int ix = (int)x0; + int iy = (int)x1; + double sum = ix + iy; + double prd = ix * iy; + double diff = std::fabs(sum - prd); + + double err = 1000 * diff * diff;; + err += (100 * std::fabs(x0 - ix)* std::fabs(x0 - ix) + 100 * std::fabs(x1 - iy)* std::fabs(x1 - iy)); + + double obj = -(diff + err); + return { obj }; + } +}; + + +#endif \ No newline at end of file diff --git a/thirdparty/galgo/galgo/example.cpp b/thirdparty/galgo/galgo/example.cpp new file mode 100755 index 0000000000..d372e547a3 --- /dev/null +++ b/thirdparty/galgo/galgo/example.cpp @@ -0,0 +1,143 @@ +//================================================================================================= +// Copyright (C) 2018 Alain Lanthier - All Rights Reserved +// License: MIT License See LICENSE.md for the full license. +// Original code 2017 Olivier Mallet (MIT License) +//================================================================================================= + +#include "Galgo.hpp" + +//------------------------------------------------------------------ +// Uncomment #define TEST_ALL_TYPE to test compiling of all types +// Uncomment #define TEST_BINAIRO to test GA for Binairos +//------------------------------------------------------------------ +//#define TEST_ALL_TYPE +//#define TEST_BINAIRO + +#include "TestFunction.hpp" + +#ifdef TEST_ALL_TYPE +#include "TestTypes.hpp" +#endif + + +template +void set_my_config(galgo::ConfigInfo<_TYPE>& config) +{ + // override some defaults + config.mutinfo._sigma = 1.0; + config.mutinfo._sigma_lowest = 0.01; + config.mutinfo._ratio_boundary = 0.10; + + config.covrate = 0.50; // 0.0 if no cros-over + config.mutrate = 0.05; + config.recombination_ratio = 0.50; + + config.elitpop = 5; + config.tntsize = 2; + config.Selection = TNT; + config.CrossOver = RealValuedSimpleArithmeticRecombination; + config.mutinfo._type = galgo::MutationType::MutationGAM_UncorrelatedNStepSizeBoundary; + + config.popsize = 100; + config.nbgen = 400; + config.output = true; +} + +int main() +{ +#ifdef TEST_ALL_TYPE + TEST_all_types(); + + system("pause"); + return 0; +#endif + +#ifdef TEST_BINAIRO + system("color F0"); + GA_Binairo::test_ga_binairo(4); // 0=resolve one free cell(hard), 1=resolve 4 free cells(very hard), 2=resolve 7 free cells(diabolical), 3 , 4==generate new grid + + system("pause"); + return 0; +#endif + + using _TYPE = float; // Suppport float, double, char, int, long, ... for parameters + const int NBIT = 32; // Has to remain between 1 and 64 + + // CONFIG + galgo::ConfigInfo<_TYPE> config; // A new instance of config get initial defaults + set_my_config<_TYPE>(config); // Override some defaults + + { + { + std::cout << std::endl; + std::cout << "SumSameAsPrd function 2x2 = 2+2"; + galgo::Parameter<_TYPE, NBIT> par1({ (_TYPE)1.5, (_TYPE)3, 3 }); // an initial value can be added inside the initializer list after the upper bound + galgo::Parameter<_TYPE, NBIT> par2({ (_TYPE)1.5, (_TYPE)3, 3 }); + + config.Objective = SumSameAsPrdObjective<_TYPE>::Objective; + galgo::GeneticAlgorithm<_TYPE> ga(config, par1, par2); + ga.run(); + } + + { + std::cout << std::endl; + std::cout << "Rosenbrock function"; + galgo::Parameter<_TYPE, NBIT > par1({ (_TYPE)-2.0,(_TYPE)2.0 }); + galgo::Parameter<_TYPE, NBIT > par2({ (_TYPE)-2.0,(_TYPE)2.0 }); + + config.Objective = RosenbrockObjective<_TYPE>::Objective; + galgo::GeneticAlgorithm<_TYPE> ga(config, par1, par2); + ga.run(); + } + + { + std::cout << std::endl; + std::cout << "Ackley function"; + galgo::Parameter<_TYPE, NBIT > par1({ (_TYPE)-4.0,(_TYPE)5.0 }); + galgo::Parameter<_TYPE, NBIT > par2({ (_TYPE)-4.0,(_TYPE)5.0 }); + + config.Objective = AckleyObjective<_TYPE>::Objective; + galgo::GeneticAlgorithm<_TYPE> ga(config, par1, par2); + ga.run(); + } + + { + std::cout << std::endl; + std::cout << "Rastrigin function"; + galgo::Parameter<_TYPE, NBIT > par1({ (_TYPE)-4.0,(_TYPE)5.0 }); + galgo::Parameter<_TYPE, NBIT > par2({ (_TYPE)-4.0,(_TYPE)5.0 }); + galgo::Parameter<_TYPE, NBIT > par3({ (_TYPE)-4.0,(_TYPE)5.0 }); + + config.Objective = rastriginObjective<_TYPE>::Objective; + galgo::GeneticAlgorithm<_TYPE> ga(config, par1, par2, par3); + ga.run(); + } + + { + std::cout << std::endl; + std::cout << "StyblinskiTang function Min = (-2.903534,...,--2.903534)"; + galgo::Parameter<_TYPE, NBIT > par1({ (_TYPE)-4.0,(_TYPE)4.0 }); + galgo::Parameter<_TYPE, NBIT > par2({ (_TYPE)-4.0,(_TYPE)4.0 }); + galgo::Parameter<_TYPE, NBIT > par3({ (_TYPE)-4.0,(_TYPE)4.0 }); + + config.Objective = StyblinskiTangObjective<_TYPE>::Objective; + galgo::GeneticAlgorithm<_TYPE> ga(config, par1, par2, par3); + ga.run(); + } + + { + std::cout << std::endl; + std::cout << "Griewank function"; + galgo::Parameter<_TYPE, NBIT > par1({ (_TYPE)-4.0,(_TYPE)5.0 }); + galgo::Parameter<_TYPE, NBIT > par2({ (_TYPE)-4.0,(_TYPE)5.0 }); + galgo::Parameter<_TYPE, NBIT > par3({ (_TYPE)-4.0,(_TYPE)5.0 }); + + config.Objective = GriewankObjective<_TYPE>::Objective; + galgo::GeneticAlgorithm<_TYPE> ga(config, par1, par2, par3); + ga.run(); + } + } + + system("pause"); +} + diff --git a/tutorial/nihedscode.py b/tutorial/nihedscode.py new file mode 100644 index 0000000000..0e8c929d96 --- /dev/null +++ b/tutorial/nihedscode.py @@ -0,0 +1,33 @@ +from __future__ import absolute_import + +import unittest + +from pyrevolve.revolve_bot import RevolveBot + +class TestRevolveBot(unittest.TestCase): + """ + Basic tests for RobolveBot body and brain generation + """ + + def test_load_save_yaml(self): + """ + We load a YAML file and save it + """ + + revolve_bot = RevolveBot() + revolve_bot.load_file( + path='/Users/nihed/Desktop/nihedssnakes/nihedssnake6.yaml', + conf_type='yaml' + ) + revolve_bot.save_file( + path='/revolve_bot.yaml', + conf_type='yaml' + ) + + revolve_bot2 = RevolveBot() + revolve_bot2.load_file( + path='/revolve_bot.yaml', + conf_type='yaml' + ) + + self.assertEqual(revolve_bot, revolve_bot2) diff --git a/tutorial/test_robots.py b/tutorial/test_robots.py new file mode 100755 index 0000000000..6df06dee27 --- /dev/null +++ b/tutorial/test_robots.py @@ -0,0 +1,45 @@ +import asyncio + +from pyrevolve import parser +from pyrevolve.revolve_bot import RevolveBot +from pyrevolve.tol.manage import World + + +async def run(): + + settings = parser.parse_args() + yaml_file = 'experiments/'+ settings.experiment_name sla+'/data_fullevolution/phenotypes/'+'phenotype_'+settings.test_robot+'.yaml' + + r = RevolveBot(_id=settings.test_robot) + r.load_file(yaml_file, conf_type='yaml') + #r.save_file('experiments/'+ settings +'/data_fullevolution/phenotype_35.sdf.xml', conf_type='sdf') + #r.render_body('experiments/'+ settings +'/data_fullevolution/phenotypes/phenotype_35.body.png') + + connection = await World.create(settings, world_address=("127.0.0.1", settings.port_start)) + await connection.insert_robot(r) + + +def main(): + import traceback + + def handler(_loop, context): + try: + exc = context['exception'] + except KeyError: + print(context['message']) + return + traceback.print_exc() + raise exc + + try: + loop = asyncio.get_event_loop() + loop.set_exception_handler(handler) + loop.run_until_complete(run()) + except KeyboardInterrupt: + print("Got CtrlC, shutting down.") + + +if __name__ == '__main__': + print("STARTING") + main() + print("FINISHED") diff --git a/tutorial/tutorial1.py b/tutorial/tutorial1.py new file mode 100644 index 0000000000..99366eac33 --- /dev/null +++ b/tutorial/tutorial1.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +import asyncio +import os +import sys +import time +from pyrevolve import parser +from pyrevolve.custom_logging.logger import logger +from pyrevolve.gazebo.manage import WorldManager as World +from pyrevolve.util.supervisor.supervisor_multi import DynamicSimSupervisor + + +# ./revolve.py --simulator-cmd=gazebo --manager tutorial/tutorial1.py +async def run(): + logger.info('Hello World!') + settings = parser.parse_args() + + # Start Simulator + if settings.simulator_cmd != 'debug': + simulator_supervisor = DynamicSimSupervisor( + world_file=settings.world, + simulator_cmd=settings.simulator_cmd, + simulator_args=["--verbose"], + plugins_dir_path=os.path.join('.', 'build', 'lib'), + models_dir_path=os.path.join('.', 'models'), + simulator_name='gazebo' + ) + await simulator_supervisor.launch_simulator(port=settings.port_start) + await asyncio.sleep(0.1) + + connection = await World.create() + if connection: + logger.info("Connected to the simulator world.") + + await connection.pause(True) + + while True: + await asyncio.sleep(10.0) \ No newline at end of file diff --git a/tutorial/tutorial1_helloworld.py b/tutorial/tutorial1_helloworld.py new file mode 100755 index 0000000000..12b43bf12c --- /dev/null +++ b/tutorial/tutorial1_helloworld.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 +import os +import sys +from pyrevolve.custom_logging.logger import logger + + +# ./revolve.py --simulator-cmd=gazebo --manager tutorial/tutorial1_helloworld.py +async def run(): + logger.info('Hello World!') \ No newline at end of file diff --git a/tutorial/tutorial1_world.py b/tutorial/tutorial1_world.py new file mode 100644 index 0000000000..3f637b639a --- /dev/null +++ b/tutorial/tutorial1_world.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +import asyncio +import os +import sys +import time +from pyrevolve import parser +from pyrevolve.custom_logging.logger import logger +from pyrevolve.gazebo.manage import WorldManager as World +from pyrevolve.util.supervisor.supervisor_multi import DynamicSimSupervisor + + +async def run(): + logger.info('Hello World!') + settings = parser.parse_args() + + # Start Simulator + if settings.simulator_cmd != 'debug': + simulator_supervisor = DynamicSimSupervisor( + world_file=settings.world, + simulator_cmd=settings.simulator_cmd, + simulator_args=["--verbose"], + plugins_dir_path=os.path.join('.', 'build', 'lib'), + models_dir_path=os.path.join('.', 'models'), + simulator_name='gazebo' + ) + await simulator_supervisor.launch_simulator(port=settings.port_start) + await asyncio.sleep(0.1) + + connection = await World.create() + if connection: + logger.info("Connected to the simulator world.") + + await connection.pause(True) + + while True: + await asyncio.sleep(10.0) \ No newline at end of file diff --git a/tutorial/tutorial2.py b/tutorial/tutorial2.py new file mode 100644 index 0000000000..9a23328a35 --- /dev/null +++ b/tutorial/tutorial2.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +import asyncio +import os +import sys +from pyrevolve.util.supervisor.supervisor_multi import DynamicSimSupervisor +from pyrevolve import parser + +here = os.path.dirname(os.path.abspath(__file__)) +rvpath = os.path.abspath(os.path.join(here, '..', 'revolve')) +sys.path.append(os.path.dirname(os.path.abspath(__file__))) + +from pyrevolve.gazebo.manage import WorldManager as World + + +async def run(): + # Start Simulator + settings = parser.parse_args() + if settings.simulator_cmd != 'debug': + simulator_supervisor = DynamicSimSupervisor( + world_file=settings.world, + simulator_cmd=settings.simulator_cmd, + simulator_args=["--verbose"], + plugins_dir_path=os.path.join('.', 'build', 'lib'), + models_dir_path=os.path.join('.', 'models'), + simulator_name='gazebo' + ) + await simulator_supervisor.launch_simulator(port=settings.port_start) + await asyncio.sleep(0.1) + + world = await World.create() + if world: + print("Connected to the simulator world.") + + sdf_model = """ + + + 1 0 0 0 0 0 + + 0 0 .5 0 0 0 + + + + 0.5 + + + + + + + 0.5 + + + + + + """ + + await world.insert_model(sdf_model) + await world.pause(True) + + while True: + await asyncio.sleep(10.0) + + +def main(): + loop = asyncio.get_event_loop() + loop.run_until_complete(run()) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/tutorial/tutorial3.py b/tutorial/tutorial3.py new file mode 100644 index 0000000000..36f64d563d --- /dev/null +++ b/tutorial/tutorial3.py @@ -0,0 +1,68 @@ +import asyncio +import logging +import sys +import os + +from pyrevolve import parser +from pyrevolve.custom_logging import logger + +from pyrevolve.tol.manage import World +from pyrevolve.util.supervisor.supervisor_multi import DynamicSimSupervisor + +from pyrevolve.revolve_bot import RevolveBot +from pyrevolve.evolution import fitness +from pyrevolve.SDF.math import Vector3 + + +# ./revolve.py --simulator-cmd=gazebo --manager=tutorial/tutorial3.py +async def run(): + """ + The main coroutine, which is started below + """ + log = logger.create_logger('experiment', handlers=[ + logging.StreamHandler(sys.stdout), + ]) + + # Set debug level to DEBUG + log.setLevel(logging.DEBUG) + + # Parse command line / file input arguments + settings = parser.parse_args() + + # Start Simulator + if settings.simulator_cmd != 'debug': + simulator_supervisor = DynamicSimSupervisor( + world_file=settings.world, + simulator_cmd=settings.simulator_cmd, + simulator_args=["--verbose"], + plugins_dir_path=os.path.join('.', 'build', 'lib'), + models_dir_path=os.path.join('.', 'models'), + simulator_name='gazebo' + ) + await simulator_supervisor.launch_simulator(port=settings.port_start) + await asyncio.sleep(0.1) + + # Connect to the simulator and pause + connection = await World.create(settings, world_address=('127.0.0.1', settings.port_start)) + await asyncio.sleep(1) + + # initialization finished + + # load robot file + robot = RevolveBot(_id=settings.test_robot) + robot.load_file("/Users/nihed/Desktop/nihedssnakes/nihedssnake6.yaml", conf_type='yaml') + robot.save_file(f'{"/Users/nihed/Desktop/nihedssnakes/nihedssnake6.yaml"}.sdf', conf_type='sdf') + + # insert robot into the simulator + robot_manager = await connection.insert_robot(robot, Vector3(0, 0, 0.25), life_timeout=None) + await asyncio.sleep(1.0) + + # Start the main life loop + while True: + # Print robot fitness every second + status = 'dead' if robot_manager.dead else 'alive' + print(f"Robot fitness ({status}) is \n" + f" OLD: {fitness.online_old_revolve(robot_manager)}\n" + f" DISPLAC: {fitness.displacement(robot_manager, robot)}\n" + f" DIS_VEL: {fitness.displacement_velocity(robot_manager, robot)}") + await asyncio.sleep(1.0) diff --git a/tutorial/tutorial4.py b/tutorial/tutorial4.py new file mode 100644 index 0000000000..0fc182d092 --- /dev/null +++ b/tutorial/tutorial4.py @@ -0,0 +1,127 @@ +#!/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.analyzer_queue import AnalyzerQueue +from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue +from pyrevolve.custom_logging.logger import logger + + +# ./revolve.py --simulator-cmd=gazebo --manager=tutorial/tutorial4.py +async def run(): + """ + The main coroutine, which is started below. + """ + + # experiment params # + num_generations = 10 + population_size = 10 + offspring_size = 10 + + 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, + ) + # experiment params # + + # Parse command line / file input arguments + settings = parser.parse_args() + experiment_management = ExperimentManagement(settings) + 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 + + population_conf = PopulationConfig( + population_size=population_size, + genotype_constructor=random_initialization, + genotype_conf=genotype_conf, + fitness_function=fitness.displacement_velocity, + 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=offspring_size, + experiment_name=settings.experiment_name, + experiment_management=experiment_management, + ) + + n_cores = settings.n_cores + + settings = parser.parse_args() + + # # load robot file + # robot = RevolveBot(_id=settings.test_robot) + #robot.load_file("/Users/nihed/Desktop/nihedssnakes/nihedssnake6.yaml", #conf_type='yaml') + #robot.save_file(f'{"/Users/nihed/Desktop/nihedssnakes/nihedssnake6.yaml"}.sdf', conf_type='sdf') + + + simulator_queue = SimulatorQueue(n_cores, settings, settings.port_start) + await simulator_queue.start() + + analyzer_queue = AnalyzerQueue(1, settings, settings.port_start+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: + 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...