Skip to content

Commit

Permalink
Merge commit 'ab4dc2cb0b2d165d439415271d01d798ae72afea' into new_gene…
Browse files Browse the repository at this point in the history
…tics
  • Loading branch information
TheoPannetier committed Feb 13, 2024
2 parents ab8a332 + ab4dc2c commit a6cc181
Show file tree
Hide file tree
Showing 41 changed files with 882 additions and 1,582 deletions.
26 changes: 26 additions & 0 deletions src/RScore/.github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: check
on: push

jobs:
check:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
include:
- os: windows-latest
path_to_exe: ./build/Debug/RScore.exe
- os: ubuntu-latest
path_to_exe: ./build/RScore
- os: macos-latest
path_to_exe: ./build/RScore
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- name: build
run: |
mkdir build && cd build
cmake ../ && cmake --build .
- name: run
run: ${{ matrix.path_to_exe }}
2 changes: 1 addition & 1 deletion src/RScore/Allele.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ class Allele {
~Allele() {}
float getAlleleValue() const { return value; };
float getDominanceCoef() const { return dominance; };
float getId() const { return id; }
int getId() const { return id; }
};
#endif
29 changes: 24 additions & 5 deletions src/RScore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
# Config file for compilation with CMake
# Only relevant for Batch mode, but this file needs to live in the RScore folder

add_library(RScore Species.cpp Cell.cpp Community.cpp FractalGenerator.cpp GeneticLoad.cpp Individual.cpp Landscape.cpp Model.cpp NeutralStatsManager.cpp Parameters.cpp Patch.cpp Population.cpp QTLTrait.cpp RSrandom.cpp SNPTrait.cpp SubCommunity.cpp)
if (NOT batchmode) # that is, RScore as a standalone
cmake_minimum_required(VERSION 3.10)
# set the project name and version
project(RScore VERSION 2.1.0)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_executable(RScore Main.cpp Species.cpp Cell.cpp Community.cpp FractalGenerator.cpp GeneticLoad.cpp Individual.cpp Landscape.cpp Model.cpp NeutralStatsManager.cpp Parameters.cpp Patch.cpp Population.cpp QTLTrait.cpp RSrandom.cpp SNPTrait.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 GeneticLoad.cpp Individual.cpp Landscape.cpp Model.cpp NeutralStatsManager.cpp Parameters.cpp Patch.cpp Population.cpp QTLTrait.cpp RSrandom.cpp SNPTrait.cpp SpeciesTrait.cpp SubCommunity.cpp Utils.cpp)
endif()

# pass config definitions to compiler
target_compile_definitions(RScore PRIVATE RSWIN64)

# enable LINUX_CLUSTER macro on Linux + macOS
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_compile_definitions(RScore PRIVATE "RSDEBUG" "RSWIN64" "LINUX_CLUSTER")
else() # Windows
target_compile_definitions(RScore PRIVATE "RSDEBUG" "RSWIN64")
add_compile_definitions("LINUX_CLUSTER")
endif()

# Debug Mode by default, unless "release" is passed
if(NOT DEFINED release)
add_compile_definitions(RSDEBUG)
endif()

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

## How to contribute

Thank you for your interest in contributing to the RangeShifter platform.
In this document we will give you guidance on how to contribute to the RangeShifter project regarding issues, bug fixing and adding new features.

## Repo structure

![Rangeshifter repo structure](RS_repos.png)

RangeShifter is distributed with three user interfaces, each living in their own repo:

- the RangeShifter GUI (clickable Windows interface)*
- RangeShifter Batch Mode (command line interface)
- the RangeShiftR package (R interface)

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).

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

## Roles

#### Maintainers

- [@JetteReeg](https://github.com/JetteReeg): RScore repo and lead in R package
- [@TheoPannetier](https://github.com/TheoPannetier): RScore repo and lead in batch mode

Maintainers are responsible for coordinating development efforts and ensuring that RangeShifter keeps building continuously.

#### Developers

Regular contributors and members of the [RangeShifter development team](https://github.com/orgs/RangeShifter/people), including maintainers.

#### Contributors

Anyone who whishes to make changes to RangeShifter's code, including regular developers.

## Branching policy

![](branches.png)

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

This policy applies to RScore and all three RangeShifter interfaces.
RangeShifter uses the following branching structure:

- `main` is the default branch, where stable releases live. Because it contains the version of RangeShifter that users normally interact with, it must be stable and build at all times.
Only maintainers should make significant changes to `main`, normally by merging `develop` into `main` to make newly developed features available to users, and marking a release while doing so.
- `develop` is the development branch containing new, in-development features. It is the reference branch for all developers. Contributors may make small changes directly to `develop` but should ensure that new changes do not break the build. If one happens to break `develop`, it should be their top priority to fix it as this will disrupt the work of all other contributors.
Larger changes should instead be developed on feature branches.
- Larger changes should be first developed on feature (e.g. `cmake`, `mutualism`, etc.) or contributor (e.g., `theo`) branches. Contributors are welcome to experiment and break such branches at any time, as this will not impact users or other contributors.

When progress is deemed satisfactory, changes can be brought to `develop`. Please open a pull request on GitHub, and assign at least one maintainer as a reviewer. As a pre-requisite, RangeShifter must build on the branch before merging. Please enter a descriptive title and use the description field to describe what you have changed.

In the meantime, we encourage contributors to work in small and frequent commits, and to merge `develop` into their branch often to update their branch with newest changes.

### Contributing to RangeShifter core code

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 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.

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

Do you have an idea of a new feature in the RangeShifter platform that should be integrated and is of use for other RangeShifter users?
Please get in touch with the RangeShifter development team ([email protected]) to discuss a collaboration.

⚠️ We advise to contact the developer team as early as possible if you plan on implementing a new feature. This could prevent simultaneous development of the same feature and coordinate potential joint development.

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.
12 changes: 0 additions & 12 deletions src/RScore/Cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,12 @@ Cell::Cell(int xx, int yy, intptr patch, float hab)
}

Cell::~Cell() {
#if RSDEBUG
//DEBUGLOG << "Cell::~Cell(): this = " << this << " smsData = " << smsData << endl;
#endif
habIxx.clear();
habitats.clear();
if (smsData != 0) {
if (smsData->effcosts != 0) delete smsData->effcosts;
delete smsData;
}
#if RSDEBUG
//DEBUGLOG << "Cell::~Cell(): deleted" << endl;
#endif
}

void Cell::setHabIndex(short hx) {
Expand Down Expand Up @@ -118,12 +112,6 @@ void Cell::setPatch(intptr p) {
}
intptr Cell::getPatch(void)
{
#if RSDEBUG
//DebugGUI(("Cell::getPatch(): this=" + Int2Str((int)this)
// + " x=" + Int2Str(x) + " y=" + Int2Str(y)
// + " habIxx[0]=" + Int2Str(habIxx[0]) + " pPatch=" + Int2Str(pPatch)
//).c_str());
#endif
return pPatch;
}

Expand Down
Loading

0 comments on commit a6cc181

Please sign in to comment.