Skip to content

Commit

Permalink
Make the test - test passes
Browse files Browse the repository at this point in the history
  • Loading branch information
brianreedpowers committed Oct 6, 2023
1 parent 7d109a3 commit 8396718
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class RecruitmentBySpawningBiomass extends YearlyRecruitmentProcess {
/**
* the number of recruits you'd get in a "virgin" state.
*/
private final int virginRecruits;
private final long virginRecruits;

/**
* logistic growth parameter
Expand Down Expand Up @@ -67,7 +67,7 @@ public class RecruitmentBySpawningBiomass extends YearlyRecruitmentProcess {


public RecruitmentBySpawningBiomass(
final int virginRecruits,
final long virginRecruits,
final double steepness,
final double cumulativePhi, final boolean addRelativeFecundityToSpawningBiomass, final double[] maturity,
final double[] relativeFecundity, final int femaleSubdivision, final boolean recruitEveryDay
Expand Down Expand Up @@ -95,7 +95,7 @@ public RecruitmentBySpawningBiomass(


public RecruitmentBySpawningBiomass(
final int virginRecruits,
final long virginRecruits,
final double steepness,
final double cumulativePhi, final boolean addRelativeFecundityToSpawningBiomass,
final Function<Species, double[]> maturity,
Expand Down Expand Up @@ -131,6 +131,7 @@ public double computeYearlyRecruitment(
final Species species, final Meristics meristics, final StructuredAbundance abundance
) {


//you need to sum up the spawning biomass of the fish:
final int cohorts = meristics.getNumberOfBins();

Expand Down Expand Up @@ -193,7 +194,7 @@ public void addNoise(final NoiseMaker noiseMaker) {
*
* @return Value for property 'virginRecruits'.
*/
public int getVirginRecruits() {
public long getVirginRecruits() {
return virginRecruits;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public class RecruitmentProcessesFactory
);
final float r0 = record.getFloat("R0");
return entry(species, new RecruitmentBySpawningBiomass(
Math.round(r0),
(long)(r0),


record.getDouble("h_steepness"),
record.getDouble("virgin_ssb") / r0,
false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package uk.ac.ox.oxfish.biology.tuna;

import org.apache.commons.lang3.ArrayUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import uk.ac.ox.oxfish.biology.Species;
import uk.ac.ox.oxfish.geography.currents.CurrentPatternMapSupplier;
import uk.ac.ox.oxfish.model.FishState;
import uk.ac.ox.oxfish.model.scenario.EpoAbundanceScenario;

import java.util.Arrays;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class EpoRecruitment2022Test {

@Test
public void testRunBiologyOnlyScenario() {
final EpoAbundanceScenario scenario = new EpoAbundanceScenario();
/* ((AbundanceMortalityProcessFromFileFactory)
((ScheduledAbundanceProcessesFactory) scenario.getBiologicalProcesses()
.getScheduledProcesses())
.getAbundanceMortalityProcess())
.setMortalityFile(scenario.testFolder().path("mortality_BP.csv"));*/
final FishState fishState = new FishState();
fishState.setScenario(scenario);
scenario.getFadMap().setCurrentPatternMapSupplier(CurrentPatternMapSupplier.EMPTY);

fishState.start();

System.out.println("SeaTiles: " + fishState.getMap().getAllSeaTiles().size());
final List<Species> specieses = fishState.getSpecies();

final Species BET = fishState.getSpecies("Bigeye tuna");
final Species SKJ = fishState.getSpecies("Skipjack tuna");
final Species YFT = fishState.getSpecies("Yellowfin tuna");
final double[][] initialAbundanceBET = fishState.getTotalAbundance(BET);
final double[][] initialAbundanceSKJ = fishState.getTotalAbundance(SKJ);
final double[][] initialAbundanceYFT = fishState.getTotalAbundance(YFT);


// System.out.println("breakpoint");


final int[] checkDays = {90, 181, 273};

do {

if (ArrayUtils.contains(checkDays, fishState.getStep())) {
// System.out.println(fishState.getStep() + " " + fishState.getTotalBiomass(fishState.getSpecies(
// "Bigeye tuna")) / 1000);
final double[][] totalAbundanceBET = fishState.getTotalAbundance(BET);
final double[][] totalAbundanceSKJ = fishState.getTotalAbundance(SKJ);
final double[][] totalAbundanceYFT = fishState.getTotalAbundance(YFT);
// System.out.println(fishState.getStep() + "BET[0]= " + (totalAbundanceBET[0][0]+totalAbundanceBET[1][0]));
// System.out.println(fishState.getStep() + "SKJ[0]= " + (totalAbundanceSKJ[0][0]+totalAbundanceSKJ[1][0]));
// System.out.println(fishState.getStep() + "YFT[0]= " + (totalAbundanceYFT[0][0]+totalAbundanceYFT[1][0]));


assertEquals(totalAbundanceBET[0][0]+totalAbundanceBET[1][0], 7653070,10);
assertEquals((totalAbundanceSKJ[0][0]+totalAbundanceSKJ[1][0])/100000, 154464,10);
assertEquals(totalAbundanceYFT[0][0]+totalAbundanceYFT[1][0], 299183000,10);



// System.out.println("breakpoint");

}
fishState.schedule.step(fishState);
} while (fishState.getYear() < 1);
}
}

0 comments on commit 8396718

Please sign in to comment.