Skip to content

Commit

Permalink
merge in master branch, fix merge conflicts in string_utils.h
Browse files Browse the repository at this point in the history
  • Loading branch information
amlalejini committed Feb 29, 2020
2 parents 02a7354 + f5e28dd commit a0b0b00
Show file tree
Hide file tree
Showing 24 changed files with 652 additions and 109 deletions.
2 changes: 1 addition & 1 deletion examples/config/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CFLAGS_web_debug := $(CFLAGS_all) $(OFLAGS_web_debug) --js-library ../../web/lib
CFLAGS_web_opt := $(CFLAGS_all) $(OFLAGS_web_opt) --js-library ../../web/library_emp.js -s EXPORTED_FUNCTIONS="['_main', '_empCppCallback']" -s NO_EXIT_RUNTIME=1
#CFLAGS_web := $(CFLAGS_all) $(OFLAGS_web) --js-library ../../web/library_emp.js -s EXPORTED_FUNCTIONS="['_main', '_empCppCallback']" -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=1

TARGETS := config namespaces
TARGETS := config namespaces SettingCombos

default: native

Expand Down
25 changes: 25 additions & 0 deletions examples/config/SettingCombos.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// This file is part of Empirical, https://github.com/devosoft/Empirical
// Copyright (C) Michigan State University, 2020.
// Released under the MIT Software license; see doc/LICENSE
//
//
// Some examples code for using emp::SettingCombos

#include <iostream>
#include "config/SettingCombos.h"

#define PRINT(X) std::cout << #X " = " << X << std::endl

int main()
{
emp::SettingCombos config_set;

config_set.AddSetting<int>("int1") = { 1, 2, 3, 4 };
config_set.AddSetting<std::string>("string") = { "a", "b", "cde" };
config_set.AddSetting<int>("int2") = { 5 };
config_set.AddSetting<double>("double") = { 1.1, 2.2 };

do {
std::cout << config_set.CurString() << std::endl;
} while (config_set.Next());
}
4 changes: 4 additions & 0 deletions examples/hardware/SignalGP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ int main() {
hardware_t hw16_1(&inst_lib, &event_lib, &random);
hardware_t hw16_2(&inst_lib, &event_lib, &random);

// Spin up main cores (used to be handled in constructor)
hw16_1.SpawnCore(0);
hw16_2.SpawnCore(0);

// Configure the hardware.
hw16_1.SetMinBindThresh(HW_MIN_SIM_THRESH);
hw16_1.SetMaxCores(HW_MAX_THREADS);
Expand Down
30 changes: 0 additions & 30 deletions examples/tools/Binomial.cc

This file was deleted.

56 changes: 56 additions & 0 deletions examples/tools/Distribution.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// This file is part of Empirical, https://github.com/devosoft/Empirical
// Copyright (C) Michigan State University, 2018-2020.
// Released under the MIT Software license; see doc/LICENSE
//
//
// Some examples code for using emp::Distribution are derived classes.

#include <iostream>
#include "tools/Random.h"
#include "tools/Distribution.h"

int main()
{
emp::Random random;

emp::Binomial bi1000(0.003, 1000);

// Print out the first values in the distribution.
for (size_t i = 0; i < 20; i++) {
std::cout << "bi1000[" << i << "] = " << bi1000[i] << "\n";
}
std::cout << "Total = " << bi1000.GetTotalProb() << std::endl;

// Pick some random values...
std::cout << "\nSome random values:";
for (size_t i = 0; i < 100; i++) {
std::cout << " " << bi1000.PickRandom(random);
}
std::cout << std::endl;

// And total some more random picks (to take a bit of time).
size_t total = 0;
const size_t test_count = 10000000;

for (size_t i = 0; i < test_count; i++) {
total += bi1000.PickRandom(random);
}

std::cout << "Average of " << test_count << " = "
<< (((double) total) / (double) test_count)
<< std::endl;


//emp::NegativeBinomial nbi10(0.5, 2);
emp::NegativeBinomial nbi10(0.3, 10);

std::cout << "\n-- Negative Binomial--\n";

std::cout << "size = " << nbi10.GetSize() << std::endl
<< "total_prob = " << nbi10.GetTotalProb() << std::endl;

// for (size_t i = 0; i < 10; i++) {
for (size_t i = 9; i < 40; i++) {
std::cout << "nbi10[" << i << "] = " << nbi10[i] << "\n";
}
}
2 changes: 1 addition & 1 deletion examples/tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CFLAGS_web_debug := $(CFLAGS_all) $(OFLAGS_web_debug) --js-library ../../source/
CFLAGS_web_opt := $(CFLAGS_all) $(OFLAGS_web_opt) --js-library ../../source/web/library_emp.js -s EXPORTED_FUNCTIONS="['_main', '_empCppCallback']" -s NO_EXIT_RUNTIME=1
#CFLAGS_web := $(CFLAGS_all) $(OFLAGS_web) --js-library ../../source/web/library_emp.js -s EXPORTED_FUNCTIONS="['_main', '_empCppCallback']" -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=1

TARGETS := AnyFunction attrs Binomial BitSet BitVector Cache combos const ContiguousStream DFA File flex_function GenericFunction IndexMap info_theory Lexer lexer_utils math memo_function NFA ra_set Random Range RegEx StringMap tuple_utils TypeMap TypeTracker valsort_map vector_utils
TARGETS := AnyFunction attrs BitSet BitVector Cache combos const ContiguousStream Distribution DFA File flex_function GenericFunction IndexMap info_theory Lexer lexer_utils math memo_function NFA ra_set Random Range RegEx StringMap tuple_utils TypeMap TypeTracker valsort_map vector_utils

TOOLS := ../../source/tools
TOOL_DEPEND := ../../source/base/assert.h
Expand Down
14 changes: 13 additions & 1 deletion examples/tools/vector_utils.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file is part of Empirical, https://github.com/devosoft/Empirical
// Copyright (C) Michigan State University, 2017.
// Copyright (C) Michigan State University, 2017-2020.
// Released under the MIT Software license; see doc/LICENSE
//
//
Expand All @@ -11,6 +11,18 @@

int main()
{
emp::vector<std::string> v1 = { "a", "b", "cde" };
emp::vector<std::string> v2 = { "f", "g", "hij" };
emp::vector<std::string> v3 = { "klm", "n", "op" };
emp::vector<std::string> v4 = { "qrstuv", "wxy", "z" };

auto all = emp::Concat(v1, v2, v3, v4);

std::cout << "Words: ";
for (const auto & w : all) {
std::cout << w << " ";
}
std::cout << std::endl;

emp::vector<int> v = { 14, 13, 1, 2, 3, 4, 22, 5, 6, 7, 8, 9, 10, 12 };

Expand Down
2 changes: 1 addition & 1 deletion source/Evolve/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ namespace emp {

// 2. If synchronous generations (i.e, pops[1] is not empty), move next population into
// place as the current popoulation.
if (pops[1].size()) {
if (IsSynchronous()) {
// Trigger signals for orgs in next pop before they are moved into the active pop.
for (size_t i = 0; i < pops[1].size(); i++) {
if (!pops[1][i]) continue;
Expand Down
Loading

0 comments on commit a0b0b00

Please sign in to comment.