Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/new_genetics' into trans…
Browse files Browse the repository at this point in the history
…loc_new_genetics_merge

Resolved multiple conflicts, which still need to be tested:

CMakeLists.txt
Cell.cpp
Community.cpp
Community.h
Genome.h
Individual.cpp
Landscape.cpp
Landscape.h
Model.cpp
Model.h
Parameters.h
Population.cpp
Population.h
  • Loading branch information
JetteReeg committed Jul 31, 2024
2 parents f6c2a5b + ebb1546 commit c08db1f
Show file tree
Hide file tree
Showing 46 changed files with 5,989 additions and 4,620 deletions.
16 changes: 16 additions & 0 deletions Allele.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef ALLELEH
#define ALLELEH

class Allele {
const int id;
const float value;
const float dominance;
inline static int counter = 0; // track nb alleles to set unique ID for each allele
public:
Allele(float alleleValue, float alleleDominance) : value(alleleValue), dominance(alleleDominance), id(counter) { ++counter; }
~Allele() {}
float getAlleleValue() const { return value; };
float getDominanceCoef() const { return dominance; };
int getId() const { return id; }
};
#endif
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ if (NOT batchmode) # that is, RScore as a standalone
# set the project name and version
project(RScore VERSION 2.1.0)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_executable(RScore Main.cpp Species.cpp Cell.cpp Community.cpp FractalGenerator.cpp Genome.cpp Individual.cpp Landscape.cpp Management.cpp Model.cpp Parameters.cpp Patch.cpp Population.cpp RandomCheck.cpp RSrandom.cpp SubCommunity.cpp Utils.cpp)

add_executable(RScore Main.cpp Species.cpp Cell.cpp Community.cpp FractalGenerator.cpp GeneticFitnessTrait.cpp Individual.cpp Landscape.cpp Management.cpp Model.cpp NeutralStatsManager.cpp Parameters.cpp Patch.cpp Population.cpp DispersalTrait.cpp RSrandom.cpp NeutralTrait.cpp SpeciesTrait.cpp SubCommunity.cpp Utils.cpp)
else() # that is, RScore compiled as library within RangeShifter_batch
add_library(RScore Species.cpp Cell.cpp Community.cpp FractalGenerator.cpp Genome.cpp Individual.cpp Landscape.cpp Management.cpp Model.cpp Parameters.cpp Patch.cpp Population.cpp RandomCheck.cpp RSrandom.cpp SubCommunity.cpp Utils.cpp)

add_library(RScore Species.cpp Cell.cpp Community.cpp FractalGenerator.cpp GeneticFitnessTrait.cpp Individual.cpp Landscape.cpp Management.cpp Model.cpp NeutralStatsManager.cpp Parameters.cpp Patch.cpp Population.cpp DispersalTrait.cpp RSrandom.cpp NeutralTrait.cpp SpeciesTrait.cpp SubCommunity.cpp Utils.cpp)
endif()

# pass config definitions to compiler
Expand All @@ -27,4 +30,4 @@ endif()

if(NOT batchmode)
target_include_directories(RScore PUBLIC "${PROJECT_BINARY_DIR}")
endif()
endif()
18 changes: 14 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The RangeShifter platform - An eco-evolutionary modelling framework
# The RangeShifter platform - An eco-evolutionary modelling framework

## How to contribute

Expand All @@ -17,7 +17,7 @@ RangeShifter is distributed with three user interfaces, each living in their own

All three share the same source code for the core simulation (i.e., the actual model), which lives in this repo (RScore). Each of the interfaces keeps a copy of this core code in a subfolder called RScore, kept in sync with the RScore repo via a git subtree (see Git subtree usage section).

If you wish to propose a change to one of the interfaces, please do so in the corresponding repo: [RangeShifter batch mode](https://github.com/RangeShifter/RangeShifter_batch_dev), [RangeShiftR package](https://github.com/RangeShifter/RangeShiftR-package-dev).
⚠ If you wish to propose a change to one of the interfaces, please do so in the corresponding repo: [RangeShifter batch mode](https://github.com/RangeShifter/RangeShifter_batch_dev), [RangeShiftR package](https://github.com/RangeShifter/RangeShiftR-package-dev).

*The RangeShifter GUI is currently being rewritten, and is not open source yet.

Expand All @@ -40,10 +40,13 @@ Anyone who whishes to make changes to RangeShifter's code, including regular dev

## Branching policy

<<<<<<<< HEAD:src/RScore/CONTRIBUTING.md
![](branches.png)

*Check out the [Git cheatsheet](https://github.com/RangeShifter/RScore/blob/main/git_cheatsheet.md) for a reminder on the main git commands*

========
>>>>>>>> develop:CONTRIBUTING.md
This policy applies to RScore and all three RangeShifter interfaces.
RangeShifter uses the following branching structure:

Expand All @@ -61,12 +64,17 @@ In the meantime, we encourage contributors to work in small and frequent commits

Any changes regarding the RangeShifter core code should be done in this repository and can afterwards be synced with all interfaces using the git subtree feature (see [Git subtree](https://github.com/RangeShifter/RScore/tree/main?tab=readme-ov-file#usage-git-subtree) section in the README).


#### Bugs

To report a bug, please [open an issue](https://github.com/RangeShifter/RangeShiftR-package-dev/issues/new), using the Bug Report template.
Please do check if a related issue has already open on one of the other interfaces ([here](https://github.com/RangeShifter/RangeShifter_batch-dev/issues) for the batch interface or [here](https://github.com/RangeShifter/RangeShiftR-package-dev) for the R package interface).
To report a bug, please [open an issue](https://github.com/RangeShifter/RangeShiftR-package/issues/new), using the Bug Report template.
Please do check if a related issue has already open on one of the other interfaces ([here](https://github.com/RangeShifter/RangeShifter_batch/issues) for the batch interface or [here](https://github.com/RangeShifter/RangeShiftR-package) for the R package interface).

To propose a bug fix (thank you!!), please create and work on your own branch or fork, from either `main` or `develop` (preferred), and open a pull request when your fix is ready to be merged into the original branch.

As a prerequisite for merging, please ensure that your version passes status check (that is, RangeShifter batch mode can still build and run as intended).
This can be seen in the Actions panel for every commit and at the bottom of the pull request.

Maintainers will review the pull request, possibly request changes, and eventually integrate the bug fix into RScore, and update the subtrees to bring the fix to all interfaces.

#### New features
Expand All @@ -79,3 +87,5 @@ Please get in touch with the RangeShifter development team (rangeshiftr@uni-pots
Alternatively, proceed as with the bug fix above: create your own branch or fork _from `develop`_ and work from there, and submit a pull request when your new features are ready to join the core code.
We recommend that you update your branch regularly to new changes on `develop` (using `git merge develop`) to reduce the risk of merge conflicts or your version getting out-of-touch in the late stages of development.
We also recommend that you work in small commits, as this makes the code easier to debug, and makes it easier for maintainers to understand your contributions when reviewing a pull request.

*Do we welcome independent contributions?
150 changes: 75 additions & 75 deletions Cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,75 +32,75 @@

Cell::Cell(int xx,int yy,intptr patch,int hab)
{
x = xx; y = yy;
pPatch = patch;
envVal = 1.0; // default - no effect of any gradient
envDev = eps = 0.0;
habIxx.push_back(hab);
visits = 0;
smsData = 0;
x = xx; y = yy;
pPatch = patch;
envVal = 1.0; // default - no effect of any gradient
envDev = eps = 0.0;
habIxx.push_back(hab);
visits = 0;
smsData = 0;
}

Cell::Cell(int xx,int yy,intptr patch,float hab)
{
x = xx; y = yy;
pPatch = patch;
envVal = 1.0; // default - no effect of any gradient
envDev = eps = 0.0;
habitats.push_back(hab);
visits = 0;
smsData = 0;
x = xx; y = yy;
pPatch = patch;
envVal = 1.0; // default - no effect of any gradient
envDev = eps = 0.0;
habitats.push_back(hab);
visits = 0;
smsData = 0;
}

Cell::~Cell() {
habIxx.clear();
habitats.clear();
if (smsData != 0) {
if (smsData->effcosts != 0) delete smsData->effcosts;
delete smsData;
}
habIxx.clear();
habitats.clear();
if (smsData != 0) {
if (smsData->effcosts != 0) delete smsData->effcosts;
delete smsData;
}
}

void Cell::setHabIndex(short hx) {
if (hx < 0) habIxx.push_back(0);
else habIxx.push_back(hx);
if (hx < 0) habIxx.push_back(0);
else habIxx.push_back(hx);
}

void Cell::changeHabIndex(short ix,short hx) {
if (ix >= 0 && ix < (short)habIxx.size() && hx >= 0) habIxx[ix] = hx;
else habIxx[ix] = 0;
if (ix >= 0 && ix < (short)habIxx.size() && hx >= 0) habIxx[ix] = hx;
else habIxx[ix] = 0;
}

int Cell::getHabIndex(int ix) {
if (ix < 0 || ix >= (int)habIxx.size())
// nodata cell OR should not occur, but treat as such
return -1;
else return habIxx[ix];
if (ix < 0 || ix >= (int)habIxx.size())
// nodata cell OR should not occur, but treat as such
return -1;
else return habIxx[ix];
}
int Cell::nHabitats(void) {
int nh = (int)habIxx.size();
if ((int)habitats.size() > nh) nh = (int)habitats.size();
return nh;
int nh = (int)habIxx.size();
if ((int)habitats.size() > nh) nh = (int)habitats.size();
return nh;
}

void Cell::setHabitat(float q) {
if (q >= 0.0 && q <= 100.0) habitats.push_back(q);
else habitats.push_back(0.0);
if (q >= 0.0 && q <= 100.0) habitats.push_back(q);
else habitats.push_back(0.0);
}

float Cell::getHabitat(int ix) {
if (ix < 0 || ix >= (int)habitats.size())
// nodata cell OR should not occur, but treat as such
return -1.0;
else return habitats[ix];
if (ix < 0 || ix >= (int)habitats.size())
// nodata cell OR should not occur, but treat as such
return -1.0;
else return habitats[ix];
}

void Cell::setPatch(intptr p) {
pPatch = p;
pPatch = p;
}
intptr Cell::getPatch(void)
{
return pPatch;
return pPatch;
}

locn Cell::getLocn(void) { locn q; q.x = x; q.y = y; return q; }
Expand All @@ -110,67 +110,67 @@ void Cell::setEnvDev(float d) { envDev = d; }
float Cell::getEnvDev(void) { return envDev; }

void Cell::setEnvVal(float e) {
if (e >= 0.0) envVal = e;
if (e >= 0.0) envVal = e;
}

float Cell::getEnvVal(void) { return envVal; }

void Cell::updateEps(float ac,float randpart) {
eps = eps*ac + randpart;
eps = eps * ac + randpart;
}

float Cell::getEps(void) { return eps; }

// Functions to handle costs for SMS

int Cell::getCost(void) {
int c;
if (smsData == 0) c = 0; // costs not yet set up
else c = smsData->cost;
return c;
int c;
if (smsData == 0) c = 0; // costs not yet set up
else c = smsData->cost;
return c;
}

void Cell::setCost(int c) {
if (smsData == 0) {
smsData = new smscosts;
smsData->effcosts = 0;
}
smsData->cost = c;
if (smsData == 0) {
smsData = new smscosts;
smsData->effcosts = 0;
}
smsData->cost = c;
}

// Reset the cost and the effective cost of the cell
void Cell::resetCost(void) {
if (smsData != 0) { resetEffCosts(); delete smsData; }
smsData = 0;
if (smsData != 0) { resetEffCosts(); delete smsData; }
smsData = 0;
}

array3x3f Cell::getEffCosts(void) {
array3x3f a;
if (smsData == 0 || smsData->effcosts == 0) { // effective costs have not been calculated
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
a.cell[i][j] = -1.0;
}
}
}
else
a = *smsData->effcosts;
return a;
array3x3f a;
if (smsData == 0 || smsData->effcosts == 0) { // effective costs have not been calculated
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
a.cell[i][j] = -1.0;
}
}
}
else
a = *smsData->effcosts;
return a;
}

void Cell::setEffCosts(array3x3f a) {
if (smsData->effcosts == 0) smsData->effcosts = new array3x3f;
*smsData->effcosts = a;
if (smsData->effcosts == 0) smsData->effcosts = new array3x3f;
*smsData->effcosts = a;
}

// Reset the effective cost, but not the cost, of the cell
void Cell::resetEffCosts(void) {
if (smsData != 0) {
if (smsData->effcosts != 0) {
delete smsData->effcosts;
smsData->effcosts = 0;
}
}
if (smsData != 0) {
if (smsData->effcosts != 0) {
delete smsData->effcosts;
smsData->effcosts = 0;
}
}
}

void Cell::resetVisits(void) { visits = 0; }
Expand All @@ -182,20 +182,20 @@ unsigned long int Cell::getVisits(void) { return visits; }
// Initial species distribution cell functions

DistCell::DistCell(int xx,int yy) {
x = xx; y = yy; initialise = false;
x = xx; y = yy; initialise = false;
}

DistCell::~DistCell() {

}

void DistCell::setCell(bool init) {
initialise = init;
initialise = init;
}

bool DistCell::toInitialise(locn loc) {
if (loc.x == x && loc.y == y) return initialise;
else return false;
if (loc.x == x && loc.y == y) return initialise;
else return false;
}

bool DistCell::selected(void) { return initialise; }
Expand Down
Loading

0 comments on commit c08db1f

Please sign in to comment.