Skip to content

Commit

Permalink
Merge pull request #168 from anyaevostinar/remove-resource-set-code
Browse files Browse the repository at this point in the history
removing dead resource types code, rip
  • Loading branch information
anyaevostinar committed Jul 15, 2022
2 parents a8a8b35 + c182ade commit 47c137b
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 85 deletions.
6 changes: 0 additions & 6 deletions source/Organism.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ class Organism {
virtual emp::vector<emp::Ptr<Organism>>& GetReproSymbionts() {
std::cout << "GetReproSymbionts called from Organism" << std::endl;
throw "Organism method called!";}
virtual std::set<int> GetResTypes() const {
std::cout << "GetResTypes called from Organism" << std::endl;
throw "Organism method called!";}
virtual void SetResInProcess(double _in){
std::cout << "SetResInProcess called from Organism" << std::endl;
throw "Organism method called!";}
Expand All @@ -151,9 +148,6 @@ class Organism {
virtual void SetSymbionts(emp::vector<emp::Ptr<Organism>> _in) {
std::cout << "SetSymbionts called from Organism" << std::endl;
throw "Organism method called!";}
virtual void SetResTypes(std::set<int> _in) {
std::cout << "SetResTypes called from Organism" << std::endl;
throw "Organism method called!";}
virtual void AddSymbiont(emp::Ptr<Organism> _in)
{std::cout << "AddSymbiont called from Organism" << std::endl;
throw "Organism method called!";}
Expand Down
35 changes: 2 additions & 33 deletions source/default_mode/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "../../Empirical/include/emp/math/Random.hpp"
#include "../../Empirical/include/emp/tools/string_utils.hpp"
#include <set>
#include <iomanip> // setprecision
#include <sstream> // stringstream
#include "../Organism.h"
Expand Down Expand Up @@ -43,20 +42,12 @@ class Host: public Organism {

/**
*
* Purpose: Represents the set of repro symbionts belonging to a host.
* Purpose: Represents the set of in-progress "reproductive" symbionts belonging to a host. These are symbionts that aren't yet active.
* Symbionts can be added with AddReproSymb(). This can be cleared with ClearSyms()
*
*/
emp::vector<emp::Ptr<Organism>> repro_syms = {};

/**
*
* Purpose: Represents the resource type available to hosts.
* This is currently not implemented fully.
*
*/
std::set<int> res_types = {};

/**
*
* Purpose: Represents the resource points possessed by a host.
Expand Down Expand Up @@ -109,9 +100,7 @@ class Host: public Organism {
Host(emp::Ptr<emp::Random> _random, emp::Ptr<SymWorld> _world, emp::Ptr<SymConfigBase> _config,
double _intval =0.0, emp::vector<emp::Ptr<Organism>> _syms = {},
emp::vector<emp::Ptr<Organism>> _repro_syms = {},
std::set<int> _set = std::set<int>(),
double _points = 0.0) : interaction_val(_intval), syms(_syms), repro_syms(_repro_syms),
res_types(_set), points(_points), random(_random), my_world(_world), my_config(_config) {
double _points = 0.0) : interaction_val(_intval), syms(_syms), repro_syms(_repro_syms), points(_points), random(_random), my_world(_world), my_config(_config) {
if ( _intval > 1 || _intval < -1) {
throw "Invalid interaction value. Must be between -1 and 1"; // Exception for invalid interaction value
};
Expand Down Expand Up @@ -235,16 +224,6 @@ class Host: public Organism {
emp::vector<emp::Ptr<Organism>>& GetReproSymbionts() {return repro_syms;}


/**
* Input: None
*
* Output: The set of ints representing a host's res type.
*
* Purpose: To get the set of ints representing the host's res type.
*/
std::set<int> GetResTypes() const { return res_types;}


/**
* Input: None
*
Expand Down Expand Up @@ -306,16 +285,6 @@ class Host: public Organism {
}


/**
* Input: A set of ints representing a host's resource type.
*
* Output: None
*
* Purpose: To set a host's resource types to the input.
*/
void SetResTypes(std::set<int> _in) {res_types = _in;}


/**
* Input: A double representing a host's new point value.
*
Expand Down
3 changes: 1 addition & 2 deletions source/efficient_mode/EfficientHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ class EfficientHost: public Host {
EfficientHost(emp::Ptr<emp::Random> _random, emp::Ptr<EfficientWorld> _world, emp::Ptr<SymConfigBase> _config,
double _intval =0.0, emp::vector<emp::Ptr<Organism>> _syms = {},
emp::vector<emp::Ptr<Organism>> _repro_syms = {},
std::set<int> _set = std::set<int>(),
double _points = 0.0, double _efficient = 0.1) :
Host(_random, _world, _config, _intval, _syms, _repro_syms, _set, _points) {
Host(_random, _world, _config, _intval, _syms, _repro_syms, _points) {
efficiency = _efficient;
my_world = _world;
}
Expand Down
3 changes: 1 addition & 2 deletions source/lysis_mode/Bacterium.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class Bacterium : public Host {
Bacterium(emp::Ptr<emp::Random> _random, emp::Ptr<LysisWorld> _world, emp::Ptr<SymConfigBase> _config,
double _intval =0.0, emp::vector<emp::Ptr<Organism>> _syms = {},
emp::vector<emp::Ptr<Organism>> _repro_syms = {},
std::set<int> _set = std::set<int>(),
double _points = 0.0) : Host(_random, _world, _config, _intval,_syms, _repro_syms, _set, _points) {
double _points = 0.0) : Host(_random, _world, _config, _intval,_syms, _repro_syms, _points) {
host_incorporation_val = my_config->HOST_INC_VAL();
if(host_incorporation_val == -1){
host_incorporation_val = random->GetDouble(0.0, 1.0);
Expand Down
3 changes: 1 addition & 2 deletions source/pgg_mode/PGGHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ class PGGHost: public Host {
PGGHost(emp::Ptr<emp::Random> _random, emp::Ptr<PGGWorld> _world, emp::Ptr<SymConfigBase> _config,
double _intval =0.0, emp::vector<emp::Ptr<Organism>> _syms = {},
emp::vector<emp::Ptr<Organism>> _repro_syms = {},
std::set<int> _set = std::set<int>(),
double _points = 0.0) : Host(_random, _world, _config, _intval,_syms, _repro_syms, _set, _points) {my_world = _world;}
double _points = 0.0) : Host(_random, _world, _config, _intval,_syms, _repro_syms, _points) {my_world = _world;}


/**
Expand Down
34 changes: 3 additions & 31 deletions source/test/default_mode_test/Host.test.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "../../default_mode/Host.h"
#include "../../default_mode/Symbiont.h"
#include <iostream>
#include <ostream>
#include <set>

TEST_CASE("Host Constructor", "[default]") {
Expand All @@ -23,7 +25,7 @@ TEST_CASE("Host Constructor", "[default]") {
emp::vector<emp::Ptr<Organism>> repro_syms = {};
std::set<int> set = std::set<int>();
double points = 10;
emp::Ptr<Host> host2 = emp::NewPtr<Host>(random, world, &config, int_val, syms, repro_syms, set, points);
emp::Ptr<Host> host2 = emp::NewPtr<Host>(random, world, &config, int_val, syms, repro_syms, points);
CHECK(host2->GetIntVal() == int_val);
CHECK(host2->GetAge() == 0);
CHECK(host2->GetPoints() == points);
Expand Down Expand Up @@ -93,36 +95,6 @@ TEST_CASE("SetPoints, AddPoints, GetPoints", "[default]") {
host.Delete();
}

TEST_CASE("SetResTypes, GetResTypes", "[default]") {
emp::Ptr<emp::Random> random = new emp::Random(-1);
SymConfigBase config;
SymWorld world(*random, &config);
double int_val = 1;
emp::vector<emp::Ptr<Organism>> syms = {};
emp::vector<emp::Ptr<Organism>> repro_syms = {};
std::set<int> res_types {1,3,5,9,2};

emp::Ptr<Host> host = emp::NewPtr<Host>(random, &world, &config, int_val, syms, repro_syms, res_types);

std::set<int> expected_res_types = host->GetResTypes();
for (int number : res_types)
{
// Tests if each integer from res_types is in expected_res_types
REQUIRE(expected_res_types.find(number) != expected_res_types.end());
}

res_types = {0,1};
host->SetResTypes(res_types);
expected_res_types = host->GetResTypes();
for (int number : res_types)
{
// Tests if each integer from res_types is in expected_res_types
REQUIRE(expected_res_types.find(number) != expected_res_types.end());
}

host.Delete();
}

TEST_CASE("HasSym", "[default]") {
emp::Ptr<emp::Random> random = new emp::Random(-1);
SymConfigBase config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "../../default_mode/Host.h"
#include "../../default_mode/Symbiont.h"
#include <set>

TEST_CASE( "Host-Symbiont interactions", "[default]") {
SymConfigBase config;
Expand All @@ -12,12 +11,11 @@ TEST_CASE( "Host-Symbiont interactions", "[default]") {
double host_interaction_val = 0.5;
double host_points = 17;
double host_resource = 100;
Host host(&random, &world, &config, host_interaction_val, {}, {}, std::set<int>(), host_points);
Host host(&random, &world, &config, host_interaction_val, {}, {}, host_points);

REQUIRE( host.GetIntVal() == .5 );
REQUIRE( host.GetSymbionts().size() == 0 );
REQUIRE( host.GetReproSymbionts().size() == 0 );
REQUIRE( host.GetResTypes().size() == 0 );
REQUIRE( host.GetPoints() == host_points );

WHEN( "resources are distributed" ) {
Expand Down Expand Up @@ -144,7 +142,6 @@ TEST_CASE( "Host-Symbiont interactions", "[default]") {
REQUIRE( host.GetIntVal() == -.2 );
REQUIRE( host.GetSymbionts().size() == 0 );
REQUIRE( host.GetReproSymbionts().size() == 0 );
REQUIRE( host.GetResTypes().size() == 0 );
REQUIRE( host.GetPoints() == 0 );

WHEN( "resources are distributed" ) {
Expand Down
3 changes: 1 addition & 2 deletions source/test/efficient_mode_test/EfficientHost.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ TEST_CASE("EfficientHost Constructor", "[efficient]"){
int_val = -1;
emp::vector<emp::Ptr<Organism>> syms = {};
emp::vector<emp::Ptr<Organism>> repro_syms = {};
std::set<int> set = std::set<int>();
double points = 10;
double efficiency = 0.5;
emp::Ptr<EfficientHost> host2 = emp::NewPtr<EfficientHost>(random, world, &config, int_val, syms, repro_syms, set, points, efficiency);
emp::Ptr<EfficientHost> host2 = emp::NewPtr<EfficientHost>(random, world, &config, int_val, syms, repro_syms, points, efficiency);
CHECK(host2->GetIntVal() == int_val);
CHECK(host2->GetEfficiency() == efficiency);
CHECK(host2->GetAge() == 0);
Expand Down
4 changes: 1 addition & 3 deletions source/test/pgg_mode_test/PGGHost.test.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "../../pgg_mode/PGGHost.h"
#include "../../pgg_mode/PGGSymbiont.h"
#include <set>

TEST_CASE("PGGHost constructor", "[pgg]"){
emp::Ptr<emp::Random> random = new emp::Random(-1);
Expand All @@ -20,9 +19,8 @@ TEST_CASE("PGGHost constructor", "[pgg]"){
int_val = -1;
emp::vector<emp::Ptr<Organism>> syms = {};
emp::vector<emp::Ptr<Organism>> repro_syms = {};
std::set<int> set = std::set<int>();
double points = 10;
emp::Ptr<PGGHost> host2 = emp::NewPtr<PGGHost>(random, world, &config, int_val, syms, repro_syms, set, points);
emp::Ptr<PGGHost> host2 = emp::NewPtr<PGGHost>(random, world, &config, int_val, syms, repro_syms, points);
CHECK(host2->GetIntVal() == int_val);
CHECK(host2->GetAge() == 0);
CHECK(host2->GetPoints() == points);
Expand Down

0 comments on commit 47c137b

Please sign in to comment.