Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats managers #63

Merged
merged 53 commits into from
Jun 1, 2016
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
2164781
Last commit before I completely overhaul OEE.h
emilydolson Apr 6, 2016
eba2749
Merge branch 'master' of github.com:devosoft/Empirical
emilydolson Apr 8, 2016
d70eea3
Merge branch 'master' of github.com:devosoft/Empirical
emilydolson Apr 19, 2016
4e615bc
Adding update signal
emilydolson Apr 22, 2016
24aa95f
Merge branch 'master' of github.com:devosoft/Empirical
emilydolson Apr 22, 2016
0ebbf5c
Complexity and Ecology work
emilydolson May 11, 2016
b787d67
Fixed merge conflict
emilydolson May 11, 2016
2c7be2f
Merge branch 'master' of github.com:devosoft/Empirical
emilydolson May 11, 2016
6ae3880
All metrics work
emilydolson May 11, 2016
2abc7e5
All metrics work
emilydolson May 12, 2016
fdd1819
All metrics work, skeletonization streamlined
emilydolson May 13, 2016
570aab4
Separate generations deduction works now
emilydolson May 13, 2016
e718cf2
Merge branch 'master' of github.com:devosoft/Empirical
emilydolson May 13, 2016
24e903a
Cleaned up OEE.h, added comments
emilydolson May 13, 2016
de8731e
Added example for OEE tracker
emilydolson May 14, 2016
7481633
Fixed bug in change deque length, added fitness tracking
emilydolson May 14, 2016
bcb6fa9
Merge branch 'master' of github.com:devosoft/Empirical
emilydolson May 14, 2016
86fe09b
Added print statement to verify settings
emilydolson May 14, 2016
88b491e
Added template specializations to appease std::vector
emilydolson May 15, 2016
8aac649
Made template specialization of ShannonDiversity to take a World
emilydolson May 18, 2016
1c525dc
Worlds are iterable
emilydolson May 18, 2016
7c51aeb
Fixing merge conflict
emilydolson May 18, 2016
779a6f4
Use world iterator in stats
emilydolson May 19, 2016
89150a8
Merge branch 'master' of github.com:devosoft/Empirical into nullorgs
emilydolson May 19, 2016
e6629c8
Fixed tournament selection to only choose from valid orgs
emilydolson May 19, 2016
229d7d9
NK_OEE now uses const landscapes
emilydolson May 19, 2016
39d792d
Lineage tracker does everything automatically with signals
emilydolson May 19, 2016
b119b08
Made ids actually propagate correctly
emilydolson May 19, 2016
295fd66
Elite selection is null org safe
emilydolson May 19, 2016
7795f83
GetValidOrgIndices actually works now
emilydolson May 19, 2016
0303f20
Merge in Jake and Stevens addition to Stats.h
emilydolson May 20, 2016
c41f784
Merge in null org handling
emilydolson May 20, 2016
a740eb6
Base stats manager functionality works
emilydolson May 20, 2016
f331839
StatsManagers handle output locations
emilydolson May 22, 2016
b718da7
Worlditerator uses pointers
emilydolson May 22, 2016
a848858
Added error message for invalid file
emilydolson May 22, 2016
b68dba6
Created default stats manager, made header
emilydolson May 23, 2016
14a5af0
Merge branch 'master' of github.com:devosoft/Empirical
emilydolson May 23, 2016
261a9f3
Added comments, cleaned up types
emilydolson May 23, 2016
49744de
OEE stats manager uses base output
emilydolson May 23, 2016
09fdf57
Stats managers have config files
emilydolson May 23, 2016
34198f6
Fixed possible null dereference in tournament fitness calculation
emilydolson May 23, 2016
db2c17d
Guard against null dereference in MutatePop
emilydolson May 23, 2016
39ae05f
StatsManagers can be passed as template arguments
emilydolson May 27, 2016
eb645f2
LineageTracker and OEEStats now follow general StatsManager format
emilydolson May 29, 2016
2149343
LineageTracker and OEEStats now follow general StatsManager format
emilydolson May 29, 2016
4fd1544
Merge branch 'master' of github.com:emilydolson/Empirical
emilydolson May 29, 2016
0a6b803
Lineage tracker automatically hooks up to OEE stats
emilydolson May 29, 2016
97f0ffb
Automatic lineage tracker construction works
emilydolson May 29, 2016
adadaac
Made stats generic and moved them to tools
emilydolson May 29, 2016
a92e954
Merge branch 'master' of github.com:devosoft/Empirical
emilydolson May 30, 2016
a80244f
Fixed g++ compilation bug
emilydolson May 31, 2016
a6897a1
Stats Manager headers + assorted cleanup
emilydolson Jun 1, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use world iterator in stats
  • Loading branch information
emilydolson committed May 19, 2016
commit 779a6f4a82d124cbe29514c1e34f95ab4661f192
111 changes: 111 additions & 0 deletions evo/Stats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// This file is part of Empirical, https://github.com/devosoft/Empirical/
// Copyright (C) Michigan State University, 2016.
// Released under the MIT Software license; see doc/LICENSE

// This file contains functions for calculating various statistics about
// a population.
//

#ifndef EMP_EVO_STATS_H
#define EMP_EVO_STATS_H

#include <type_traits>
#include <map>
#include <cmath>
#include <vector>
#include <set>
#include "../tools/vector.h"
#include "World.h"

namespace emp{
namespace evo{

//Calculates Shannon Entropy of the members of the container passed
template <typename C, class = typename C::value_type >
double ShannonDiversity(C elements) {

//Count number of each value present
std::map<typename C::value_type, int> counts;
for (auto element : elements) {
if (counts.find(element) != counts.end()) {
counts[element]++;
} else {
counts[element] = 1;
}
}

//Shannon entropy calculation
double result = 0;
for (auto element : counts) {
double p = double(element.second)/elements.size();
result += p * log2(p);
}

return -1 * result;
}

//Calculates Shannon Entropy of the members of a world
template <typename ORG, typename... MANAGERS>
double ShannonDiversity(emp::evo::World<ORG, MANAGERS...> & elements) {

//Count number of each value present
std::map<ORG, int> counts;
for (auto element : elements) {
if (counts.find(element) != counts.end()) {
counts[element]++;
} else {
counts[element] = 1;
}

}

//Shannon entropy calculation
double result = 0;
for (auto element : counts) {
double p = double(element.second)/elements.GetSize();
result += p * log2(p);
}

return -1 * result;
}

//Calculates number of unique elements in the container passed
template <typename C>
int Richness(C elements) {
//Converting to a set will remove duplicates leaving only unique values
std::set<typename C::value_type> unique_elements(elements.begin(),
elements.end());
return unique_elements.size();
}

template <typename ORG, typename C, class = typename C::value_type >
double MaxFitness(std::function<double(ORG * org)> fit_fun, C orgs){
double fittest = fit_fun(&orgs[0]);
for (auto org : orgs){
double fitness = fit_fun(&org);
if (fitness > fittest){
fittest = fitness;
}
}
return fittest;
}

template <typename ORG, typename... MANAGERS>
double MaxFitness(std::function<double(ORG * org)> fit_fun, World<ORG, MANAGERS...> & orgs){
double fittest = fit_fun(&(*(orgs.begin())));
for (auto org : orgs){
double fitness = fit_fun(&org);
if (fitness > fittest){
fittest = fitness;
}
}
return fittest;
}

}
}

#endif

//Base class outputs most recent
//Write derived class