This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "/home/tollie/Development/Maximilian/maximilian.h" | |
#include <vector> | |
#include <algorithm> | |
#include <chrono> | |
size_t amount = 1; | |
std::vector<maxiOsc> maxiObjects; | |
void process() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i, p in enumerate(self.population): | |
if elitism > 0 and i in n_fittest: | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.disturbance_threshold *= decay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
envs = [gym.make(self.env_name) for _ in range(multiprocessing.cpu_count())] | |
amount_per_thread = int(np.floor(self.population_size / multiprocessing.cpu_count())) | |
left_over = self.population_size - amount_per_thread * multiprocessing.cpu_count() | |
fitnesses = np.zeros(len(self.population)) | |
def get_weights_reward(begin, size, env): | |
for i in range(begin, begin + size): | |
fitnesses[i] = -self.get_reward(self.population[i], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swarms_best_index = np.argmin(fitnesses) | |
self.swarms_best_score = np.amin(fitnesses) | |
self.swarms_best = self.population[swarms_best_index] | |
if self.swarms_best_score <= self.all_time_best_score: | |
self.all_time_best_score = self.swarms_best_score | |
self.all_time_best = self.swarms_best |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if self.mode == 'original': | |
if r[i][x] < self.disturbance_threshold: | |
p[x] = np.random.normal(dev, mean) | |
else: | |
leader_rate = np.random.uniform(0.0, 1.0) | |
update = self.swarms_best[x] - best_neighbour[x] | |
p[x] = best_neighbour[x] + leader_rate * update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elif self.mode == 'hybrid': | |
if r[i][x] < self.disturbance_threshold: | |
p[x] = np.random.normal(dev, mean) | |
else: | |
leader_rate = np.random.uniform(0.0, 1.0) | |
update = (best_neighbour[x] + self.swarms_best[x]) / 2.0 - p[x] | |
p[x] = p[x] + leader_rate * update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elif self.mode == 'n_fittest': | |
if r[i][x] < self.disturbance_threshold: | |
p[x] = np.random.normal(dev, mean) | |
else: | |
leader_rate = np.random.uniform(0.0, 1.0) | |
update = np.average(self.population[n_fittest]) - best_neighbour[x] | |
p[x] = best_neighbour[x] + leader_rate * update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elif self.mode == 'random_gauss': | |
p[x] = np.random.normal(dev, mean) | |
elif self.mode == 'random_uniform': | |
p[x] = np.random.sample() |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer