Program Listing for File SimulatedSpeciesAbundancesHandler.h

Return to documentation for file (necsim/SimulatedSpeciesAbundancesHandler.h)

// This file is part of necsim project which is released under MIT license.
// See file **LICENSE.txt** or visit for full license details.


#include <string>
#include <memory>
#include <map>
#include <vector>
#include <cmath>
#include <numeric>

#include "neutral_analytical.h"
#include "RNGController.h"
#include "custom_exceptions.h"
#include "double_comparison.h"
#include "SpeciesAbundancesHandler.h"

namespace na = neutral_analytical;

using namespace std;
namespace necsim
    class SimulatedSpeciesAbundancesHandler : public virtual SpeciesAbundancesHandler
        // Maps abundance values to a vector containing species ids
        map<unsigned long, vector<unsigned long>> species_abundances;
        // Maps abundance values to the maximum number of species expected to be contained.
        map<unsigned long, unsigned long> species_richness_per_abundance;
        // Maps cumulative probabilities of choosing each abundance to abundance values
        shared_ptr<map<unsigned long, unsigned long>> cumulative_abundance_map;
        // Total species number
        double total_species_number;
        unsigned long number_of_individuals;


        ~SimulatedSpeciesAbundancesHandler() override = default;

        unsigned long getRandomSpeciesID() override;

        void setAbundanceList(const shared_ptr<map<unsigned long, unsigned long>> &abundance_list_in) override;

        void setAbundanceList(shared_ptr<vector<unsigned long>> abundance_list_in) override;

        void generateAbundanceTable(shared_ptr<vector<unsigned long>> abundance_list);

        void generateCumulativeAbundances(shared_ptr<vector<unsigned long>> abundance_list);

        unsigned long getRandomAbundanceOfIndividual();