Ejemplo n.º 1
0
  public void updateBiomass(
      Ecosystem ecosystem, Map<Integer, SpeciesZoneType> nextSpeciesNodeList) {
    for (Entry<Integer, SpeciesZoneType> entry : nextSpeciesNodeList.entrySet()) {
      int species_id = entry.getKey();
      SpeciesZoneType szt = entry.getValue();
      int biomassValue = (int) entry.getValue().getCurrentBiomass();
      Species species = ecosystem.getSpecies(szt.getSpeciesType().getID());
      for (SpeciesGroup group : species.getGroups().values()) {
        group.setBiomass(biomassValue);

        EcoSpeciesDAO.updateBiomass(group.getID(), group.getBiomass());
      }
    }
  }
Ejemplo n.º 2
0
  /* Set all system parameters for a node (SpeciesZoneType) for a simulation run.
  HJR, original version of this, getSystemParameter() has some problems
  with how it submits link parameters.  (1) orig uses call to SZT.getlPreyIndex(),
  which is not active (set by prior call to SpeciesType.getPreyIndex, which returns
  empty list) i.e. never actually submits any link params, default or otherwise! */
  @SuppressWarnings("unused")
  private String setSystemParameters(
      SpeciesZoneType species, HashMap<Integer, SpeciesZoneType> fullSpeciesMap, int timestepIdx) {

    SpeciesTypeEnum type = species.getType();
    int nodeIdx = species.getNodeIndex();

    List<String> sParams = new ArrayList<String>();
    StringBuilder builder = new StringBuilder();
    if (type == SpeciesTypeEnum.PLANT) {
      // Carrying capacity(k) and GrowthRate(r) are only effective when species is plant
      // Higher Carrying capacity means higher biomass
      // for example, if carrying capacity is 10, maximum biomass of species is 10.
      // Higher growth rate means that species with higher growth rate will gain biomass faster.
      // Metabolic rate (x) are effective for both animals and plants
      // higher metabolic rate means that biomass of species will decrease compared to other species

      // YES, need to divide by Constants.BIOMASS_SCALE.
      setSystemParametersNode(
          sParams,
          timestepIdx,
          nodeIdx,
          species.getParamK(),
          ManipulatingParameterName.k,
          "carryingCapacityDefault");
      if (false) { // HJR Currently I have turned off R and X
        setSystemParametersNode(
            sParams,
            timestepIdx,
            nodeIdx,
            species.getParamR(),
            ManipulatingParameterName.r,
            "growthRateDefault");
        setSystemParametersNode(
            sParams,
            timestepIdx,
            nodeIdx,
            species.getParamX(),
            ManipulatingParameterName.x,
            "metabolicRateDefault");
      }
      // Pack everything
      // [5],2000,1.000,1,K=9431.818,0,
      // [K=10.0, R=1.0, X=0.5]
      builder.append(sParams.size()).append(",");
      for (int i = 0; i < sParams.size(); i++) {
        builder.append(sParams.get(i)).append(",");
      }
      builder.append("0").append(",");
    } else if (type == SpeciesTypeEnum.ANIMAL) {
      // Metabolic rate (x) are effective for both animals and plants
      // higher metabolic rate means that biomass of species will decrease compared to other species
      // Assimilation efficiency (e) is only available for animals.
      // higher assimilation efficiency means that biomass of species will increase.
      setSystemParametersNode(
          sParams,
          timestepIdx,
          nodeIdx,
          species.getParamX(),
          ManipulatingParameterName.x,
          "metabolicRateDefault");
      builder.append(sParams.size()).append(",");
      for (int i = 0; i < sParams.size(); i++) {
        builder.append(sParams.get(i));
        builder.append(",");
      }
      sParams.clear();
      // loop through prey, adding link parameters
      if (Integer.valueOf(propertiesConfig.getProperty("submitLinkParameterSettings")) == 1) {
        int preyCnt = species.getSpeciesType().getPreyNodeIDs().size();
        for (int preyIdx : species.getSpeciesType().getPreyNodeIDs()) {
          if (fullSpeciesMap == null || !fullSpeciesMap.containsKey(preyIdx)) {
            continue;
          }
          /* separate note: there appear to be a limited number of link params
          that can be submitted, over which an "axis fault" error will occur.  Varies
          with number of species in the ecosystem; on a test of a 15 species ecosystem,
          only 3 link params could be used.  Have disabled all, as I am not using them
          at this time.  Not fully evaluated, obviously, but these were not implemented
          at all previously.
          */

          /* default values that mimic web-services internal defaults are:
          predatorInterferenceDefault = 0
          assimilationEfficiencyAnimalDefault=1
          assimilationEfficiencyPlantDefault=1
          functionalResponseControlParameterDefault=0
          halfSaturationDensityDefault=0.5
          maximumIngestionRateDefault=6

          >consistent default values were not found for the following and there is some
          confusion about their role - based on prior code, parameter "a" matches
          relativeHalfSaturationDensityDefault.
          parameter "a" does not appear in any of the equations that I've seen, (possibly
          omega - consumption rate?),
          but DOES impact the simulation results.  No single value (0-1.0) gives result consistent
          to omitting the value, suggesting that species are distinguished somehow.
          Animal/Plant division was tested, but did not yield consistent results.
          relativeHalfSaturationDensityDefault=1.0
          relativeHalfSaturationDensity = 0.01
          */
          //// sequence is
          // linkParamCnt,[prey_Id0],paramID0=value0,[prey_Id1],paramID1=value1,...[prey_IdN],paramIDN=valueN
          // setSystemParametersLink(sParams, timestepIdx, nodeIdx, preyIdx,
          // species.getParamA(preyIdx),
          //        ManipulatingParameterName.a, "relativeHalfSaturationDensityDefault", preyCnt);
          if (false) {
            setSystemParametersLink(
                sParams,
                timestepIdx,
                nodeIdx,
                preyIdx,
                species.getParamB0(preyIdx),
                ManipulatingParameterName.b0,
                "halfSaturationDensityDefault",
                preyCnt);
            setSystemParametersLink(
                sParams,
                timestepIdx,
                nodeIdx,
                preyIdx,
                species.getParamD(preyIdx),
                ManipulatingParameterName.d,
                "predatorInterferenceDefault",
                preyCnt);
            setSystemParametersLink(
                sParams,
                timestepIdx,
                nodeIdx,
                preyIdx,
                species.getParamE(preyIdx),
                ManipulatingParameterName.e,
                "assimilationEfficiencyPlantDefault",
                preyCnt);
            setSystemParametersLink(
                sParams,
                timestepIdx,
                nodeIdx,
                preyIdx,
                species.getParamQ(preyIdx),
                ManipulatingParameterName.q,
                "functionalResponseControlParameterDefault",
                preyCnt);
            setSystemParametersLink(
                sParams,
                timestepIdx,
                nodeIdx,
                preyIdx,
                species.getParamY(preyIdx),
                ManipulatingParameterName.y,
                "maximumIngestionRateDefault",
                preyCnt);
          }
        }
        builder.append(sParams.size()).append(",");
        for (int i = 0; i < sParams.size(); i++) {
          builder.append(sParams.get(i));
          builder.append(",");
        }
        System.out.println(builder);
      }
    }
    return builder.toString();
  }