Author: echatellier Date: 2012-09-25 16:51:25 +0200 (Tue, 25 Sep 2012) New Revision: 296 Url: http://forge.codelutin.com/repositories/revision/isis-fish-data/296 Log: Ajout des scripts utilisant groupMin/groupMax permettant de calculer la mortalit?\195?\169 totale par p?\195?\170che (ftot). Added: trunk/scripts/MinimisationUtil.java trunk/scripts/ObjectiveFunction.java trunk/scripts/ObjectiveFunctionBaranov.java Modified: trunk/pom.xml trunk/scripts/ResultName.java trunk/scripts/RuleUtil.java trunk/scripts/SiMatrix.java trunk/simulators/DefaultSimulator.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-09-14 14:12:39 UTC (rev 295) +++ trunk/pom.xml 2012-09-25 14:51:25 UTC (rev 296) @@ -14,7 +14,7 @@ <packaging>jar</packaging> <!--Version --> - <version>4.2.0</version> + <version>4.2.1</version> <!--Description --> <description>Data for Isis-fish</description> @@ -74,7 +74,7 @@ <dependency> <groupId>fr.ifremer</groupId> <artifactId>isis-fish</artifactId> - <version>4.2.0.0</version> + <version>4.2.1.0-SNAPSHOT</version> <scope>compile</scope> </dependency> </dependencies> Added: trunk/scripts/MinimisationUtil.java =================================================================== --- trunk/scripts/MinimisationUtil.java (rev 0) +++ trunk/scripts/MinimisationUtil.java 2012-09-25 14:51:25 UTC (rev 296) @@ -0,0 +1,176 @@ +/* + * #%L + * IsisFish data + * %% + * Copyright (C) 2012 Ifremer, CodeLutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package scripts; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.isisfish.util.Nocache; + +public class MinimisationUtil { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory.getLog(RuleUtil.class); + + /** + * Algo de minimisation de fmin(step, x,C,M,N) sur x. + * + * en prenant une valeur initiale de x dans [a,b] et une tolerance = tol + * Reference de l'algo : http://www1.fpl.fs.fed.us/optimization.html + * Algorithme de Brent qui approxime la fonction a minimiser par une + * parabole si possible et fait du "golden step" sinon + * + * @param a + * @param b + * @param tol tolérance + * @param f fonction d'objectif + * @return + */ + @Nocache + public static double fmin(double a, double b, double tol, ObjectiveFunction f) { + + double c, d, e, eps, xm, p, q, r, tol1, t2, u, v, w, fu, fv, fw, fx, x, tol3; + + c = .5 * (3.0 - Math.sqrt(5.0)); + d = 0.0; + eps = 1.2e-16; // 1.1102e-16 is machine precision + tol1 = eps + 1.0; + eps = Math.sqrt(eps); + v = a + c * (b - a); + // log.info("Finit=" + v); + w = v; + x = v; + e = 0.0; + fx = 0.0; + fu = 0.0; + + fx = f.compute(x); + // log.info("fx= " + fx); + + fv = fx; + fw = fx; + tol3 = tol / 3.0; + xm = .5 * (a + b); + tol1 = eps * Math.abs(x) + tol3; + t2 = 2.0 * tol1; + + while (Math.abs(x - xm) > (t2 - .5 * (b - a))) { // main loop; + // ///// De là... + p = q = r = 0.0; + if (Math.abs(e) > tol1) { // fit the parabola; + r = (x - w) * (fx - fv); + q = (x - v) * (fx - fw); + p = (x - v) * q - (x - w) * r; + q = 2.0 * (q - r); + if (q > 0.0) { + p = -p; + } else { + q = -q; + } + r = e; + e = d; + } + if ((Math.abs(p) < Math.abs(.5 * q * r)) && (p > q * (a - x)) + && (p < q * (b - x))) { // parabolic interpolation step; + d = p / q; + u = x + d; + if (((u - a) < t2) || ((b - u) < t2)) { // f must not be + // evaluated too close + // to a or b; + d = tol1; + if (x >= xm) + d = -d; + } + } else { // a golden-section step; + if (x < xm) { + e = b - x; + } else { + e = a - x; + } + d = c * e; + } + if (Math.abs(d) >= tol1) { // f must not be evaluated too close to x; + u = x + d; + } else { + if (d > 0.0) { + u = x + tol1; + } else { + u = x - tol1; + } + } + // ... à ici : ne sert qu'à calculer un u (selon 2 manières + // différentes) afin de comparer fx a fu + // --> On peut très bien prendre u à partir d'une autre simu a + // la place (?) + + fu = f.compute(u); + //log.info("fu= " + fu); + + // Update a, b, v, w, and x + if (fx <= fu) { + if (u < x) { + a = u; + } else { + b = u; + } + } + if (fu <= fx) { + if (u < x) { + b = x; + } else { + a = x; + } + v = w; + fv = fw; + w = x; + fw = fx; + x = u; + fx = fu; + xm = .5 * (a + b); + tol1 = eps * Math.abs(x) + tol3; + t2 = 2.0 * tol1; + } else { + if ((fu <= fw) || (w == x)) { + v = w; + fv = fw; + w = u; + fw = fu; + xm = .5 * (a + b); + tol1 = eps * Math.abs(x) + tol3; + t2 = 2.0 * tol1; + } else if ((fu > fv) && (v != x) && (v != w)) { + xm = .5 * (a + b); + tol1 = eps * Math.abs(x) + tol3; + t2 = 2.0 * tol1; + } else { + v = u; + fv = fu; + xm = .5 * (a + b); + tol1 = eps * Math.abs(x) + tol3; + t2 = 2.0 * tol1; + } + } + } + return x; + } +} Property changes on: trunk/scripts/MinimisationUtil.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/scripts/ObjectiveFunction.java =================================================================== --- trunk/scripts/ObjectiveFunction.java (rev 0) +++ trunk/scripts/ObjectiveFunction.java 2012-09-25 14:51:25 UTC (rev 296) @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2012 lgasche + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package scripts; + +/** + * ObjectiveFunction.java + * + * Created: 10 aout 2012 + * + * @author lgasche + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + */ +public abstract class ObjectiveFunction { + + /** + * Compute value depending on objective function implementation + * @param x + * @return + */ + public abstract double compute(double x); +} \ No newline at end of file Property changes on: trunk/scripts/ObjectiveFunction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/scripts/ObjectiveFunctionBaranov.java =================================================================== --- trunk/scripts/ObjectiveFunctionBaranov.java (rev 0) +++ trunk/scripts/ObjectiveFunctionBaranov.java 2012-09-25 14:51:25 UTC (rev 296) @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012 lgasche + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package scripts; + +import fr.ifremer.isisfish.util.Nocache; + +/** + * FonctionObjectif_Baranov.java + * + * Created: 10 aout 2012 + * + * @author lgasche <user.name@vcs.hostName> + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + */ +@Nocache +public class ObjectiveFunctionBaranov extends ObjectiveFunction { + + protected double C, M, N; + + public ObjectiveFunctionBaranov(double C, double M, double N) { // step ?? + this.C = C; + this.M = M; + this.N = N; + } + + public double compute(double xx) { + double ff = Math.pow((C - (xx/(xx+M))*(1-Math.exp(-(xx+M)))*N),2); + return ff; + } +} \ No newline at end of file Property changes on: trunk/scripts/ObjectiveFunctionBaranov.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/scripts/ResultName.java =================================================================== --- trunk/scripts/ResultName.java 2012-09-14 14:12:39 UTC (rev 295) +++ trunk/scripts/ResultName.java 2012-09-25 14:51:25 UTC (rev 296) @@ -159,6 +159,21 @@ @Doc(value = "Disponible uniquement avec les simulations par Zone. do the doc of Result matrixFishingMortality") static final public String MATRIX_FISHING_MORTALITY = n_("matrixFishingMortality"); + /** + * Matrix with 1 dimension + * Dimension 1 : TimeStep + */ + @Doc(value = "do the doc of Result matrixTotalFishingMortality") + static final public String MATRIX_TOTAL_FISHING_MORTALITY = n_("matrixTotalFishingMortality"); + + /** + * Matrix with 2 dimensions + * Dimension 1 : TimeStep + * Dimension 2 : Group + */ + @Doc(value = "do the doc of Result matrixFishingMortalityPerGroup") + static final public String MATRIX_FISHING_MORTALITY_PER_GROUP = n_("matrixFishingMortalityPerGroup"); + /** * Matrix with three dimensions * Dimension 1 : TimeStep Modified: trunk/scripts/RuleUtil.java =================================================================== --- trunk/scripts/RuleUtil.java 2012-09-14 14:12:39 UTC (rev 295) +++ trunk/scripts/RuleUtil.java 2012-09-25 14:51:25 UTC (rev 296) @@ -2,7 +2,7 @@ * #%L * IsisFish data * %% - * Copyright (C) 2006 - 2011 Ifremer, CodeLutin + * Copyright (C) 2006 - 2012 Ifremer, CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -25,9 +25,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.math.matrix.MatrixND; -import org.nuiton.math.matrix.*; - import fr.ifremer.isisfish.entities.Population; import fr.ifremer.isisfish.entities.PopulationGroup; import fr.ifremer.isisfish.entities.Species; @@ -78,4 +77,24 @@ } return result; } + + public static double getTotalCatchTonsPop(SimulationContext context, Population pop, TimeStep step) { + double result = 0; + MatrixND mat = context.getPopulationMonitor().getHoldCatch(pop); + if (mat != null) { + mat = mat.copy(); + mat = mat.sumOverDim(0); // sum over Strategies + mat = mat.sumOverDim(1); // sum over metiers + mat = mat.sumOverDim(3); // sum over zones + + List<PopulationGroup> groups = pop.getPopulationGroup(); + + for (int c = 0; c < groups.size(); c++) { + PopulationGroup group = groups.get(c); + double weight = group.getMeanWeight(); + result += mat.getValue(0, 0, c, 0) * weight / 1000.0; + } + } + return result; + } } Modified: trunk/scripts/SiMatrix.java =================================================================== --- trunk/scripts/SiMatrix.java 2012-09-14 14:12:39 UTC (rev 295) +++ trunk/scripts/SiMatrix.java 2012-09-25 14:51:25 UTC (rev 296) @@ -2,7 +2,7 @@ * #%L * IsisFish data * %% - * Copyright (C) 2006 - 2012 Ifremer, Code Lutin, Benjamin Poussin, Chatellier Eric + * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Benjamin Poussin * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -26,9 +26,11 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.Arrays; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -57,12 +59,19 @@ import fr.ifremer.isisfish.simulator.SimulationContext; import fr.ifremer.isisfish.types.TimeStep; import fr.ifremer.isisfish.types.Month; +import fr.ifremer.isisfish.datastore.ResultStorage; +import scripts.RuleUtil; /** - * SiMatrix calcul simplement des résultats ne dependant que des parametres - * de simulation et des données du modèle. + * SiMatrix.java * + * Created: 21 aout 2006 15:53:01 + * * @author poussin + * @version $Revision: 1.18 $ + * + * Last update: $Date: 2007-11-02 17:53:20 $ + * by : $Author: bpoussin $ */ public class SiMatrix { @@ -1381,8 +1390,8 @@ Zone zone, MatrixND matrixFishingMortality) throws TopiaException, IsisFishException { double F = totalFishingMortality(step, matrixFishingMortality) - .getValue(group, zone); //totalFishingMortality(step, group, zone); // rem perf: totalFishingMortality a deja ete calcul� - double M = group.getNaturalDeathRate(zone) + .getValue(group, zone); //totalFishingMortality(step, group, zone); // rem perf: totalFishingMortality a deja ete calcule + double M = group.getNaturalDeathRate(zone) / (double) Month.NUMBER_OF_MONTH; double result = Math.exp(-(F + M)); @@ -1402,9 +1411,9 @@ throws TopiaException, IsisFishException { double F = totalFishingMortalityPerCell(step, - matrixFishingMortalityPerCell).getValue(group, zone, cell); //totalFishingMortality(step, group, zone); // rem perf: totalFishingMortality a deja ete calcul� + matrixFishingMortalityPerCell).getValue(group, zone, cell); //totalFishingMortality(step, group, zone); // rem perf: totalFishingMortality a deja ete calcule double M = group.getNaturalDeathRate(zone) - / (double) Month.NUMBER_OF_MONTH; + / (double) Month.NUMBER_OF_MONTH; double result = (double) Math.exp(-(F + M)); return result; @@ -1554,9 +1563,9 @@ // // /////////////////////////////////////////////////////////////////////////// - public MatrixND matrixEffortNominalPerStrategyMet(TimeStep step) throws TopiaException { + public MatrixND matrixEffortNominalPerStrategyMet(TimeStep step) throws TopiaException { - List<Strategy> strategies = getStrategies(step); + List<Strategy> strategies = getStrategies(step); List<Metier> metiers = getMetiers(step); MatrixND result = MatrixFactory.getInstance().create( @@ -1576,4 +1585,127 @@ return result; } + + /** + * Ce morceau de script sert a calculer la mortalite par peche par espece et + * par groupe d'age sur l'ensemble de la zone d'etude, + * en minimisant la difference entre les captures d'ISIS et celles calculees + * a partir de l'equation de Baranov. + * + * @param step pas de temps + * @param pop population + * @return Fishing mortality per group per year (computed in December) + */ + public MatrixND fishingMortalityPerGroup(TimeStep step, Population pop, ResultStorage resManager) throws TopiaException { + double Fgroup=0; + double Cgroup=0; + double Mgroup=0; + double NgroupJan=0; + + List<Population> populations = Collections.singletonList(pop); + List<PopulationGroup> groups = pop.getPopulationGroup(); + + MatrixND tfgMatrix = MatrixFactory.getInstance().create( + ResultName.MATRIX_FISHING_MORTALITY_PER_GROUP, + new List[]{populations, groups}, // On travaille sur les pops ET les groupes + new String[]{n_("Population"), n_("Group")}); + + for (PopulationGroup group : groups) { + + if (step.getMonth() == Month.DECEMBER) { + + MatrixND catchPerStrategy = null; + + for (TimeStep loopstep = new TimeStep(step.getYear() * 12); loopstep.beforeOrEquals(step); loopstep=loopstep.next()){ + // On fait cette boucle pour contourner les aspects de cache qui font que les resultats ne sont pas recuperes + //s'ils ont deja ete calcules une fois (meme s'ils ont change depuis) + // beforeOrEquals sert a bien prendre Decembre aussi + + MatrixND catchPerStrategyTemp = resManager.getMatrix(loopstep, pop, ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP); + if (catchPerStrategy == null){ + catchPerStrategy = catchPerStrategyTemp.clone(); + // On clone la matrice car si on fait les operations sur celle contenue dans le cache on la modifie et donc on recupere des resultats faux. + } else { + catchPerStrategy = catchPerStrategy.add(catchPerStrategyTemp); // Pour avoir la somme des captures sur les 12 mois + } + } + + //log.info("catchPerStrategy = " + catchPerStrategy); + catchPerStrategy = catchPerStrategy.sumOverDim(0); // Strategy + catchPerStrategy = catchPerStrategy.sumOverDim(1); // Metier + catchPerStrategy = catchPerStrategy.sumOverDim(3); // Zone : une pop peut avoir plusieurs zonespop dans ISIS + List semgroup = catchPerStrategy.getSemantic(2); + catchPerStrategy = catchPerStrategy.reduce(); // Enleve les dimensions de taille 1 + catchPerStrategy.setSemantic(0, semgroup); // Ne plait pas a Eric + Cgroup = catchPerStrategy.getValue(group); + //log.info("Cgroup = " + Cgroup + "Year=" + step.getYear()); + //log.info("catchPerStrategy = " + catchPerStrategy + "Year=" + step.getYear()); + + MatrixND naturalDeathRatePop = pop.getNaturalDeathRateMatrix(); + naturalDeathRatePop = naturalDeathRatePop.meanOverDim(1); // moyenne sur Zone + naturalDeathRatePop = naturalDeathRatePop.reduce(); // Enleve les dimensions de taille 1 + Mgroup = naturalDeathRatePop.getValue(group); + //log.info("Mgroup= " + Mgroup + "Year=" + step.getYear()); + + MatrixND abundancePopJan = resManager.getMatrix(new TimeStep(12*step.getYear()), pop, ResultName.MATRIX_ABUNDANCE); // Le timestep 0 correspond a janvier de la premiere annee et les annees sont numerotees a partir de zero abundancePopJan = abundancePopJan.sumOverDim(1); // somme sur Zone + abundancePopJan = abundancePopJan.reduce(); + NgroupJan = abundancePopJan.getValue(group); + //log.info("NgroupJan = " + NgroupJan + "Year=" + step.getYear()); + + ObjectiveFunction f = new ObjectiveFunctionBaranov(Cgroup, Mgroup, NgroupJan); + Fgroup = MinimisationUtil.fmin(0.0,2.0,1.0e-10, f); // step ?? + + //log.info("Fgroup = " + Fgroup); + + tfgMatrix.setValue(pop, group, Fgroup); // Bien faire attention a l'endroit ou on met cette etape (quelle boucle) ? + + } else { + //Fgroup = 0; // Ce n'est plus une valeur unique mais une matrice, est-ce que cette notation peut fonctionner ? + tfgMatrix.setValue(pop, group, 0); // Bien faire attention a l'endroit ou on met cette etape (quelle boucle) ? + } + } + + //log.info("tfgMatrix = " + tfgMatrix); + //log.info("tfg.DimensionNames = " + Arrays.toString(tfgMatrix.getDimensionNames())); + //log.info("tfg.Semantics = " + Arrays.toString(tfgMatrix.getSemantics())); + + return tfgMatrix; + } + + /** + * Ce morceau de script sert a calculer la mortalite par peche par espece et + * par groupe representatif a partir de la mortalite par peche par groupe + * calculee precedemment. + */ + public MatrixND totalFishingMortality (TimeStep step, Population pop, MatrixND FishingMortalityPerGroup) throws TopiaException { + MatrixND tfmMatrix = FishingMortalityPerGroup.copy(); + tfmMatrix.setName(ResultName.MATRIX_TOTAL_FISHING_MORTALITY); + //log.info("tfmMatrix = " + tfmMatrix); + + List<PopulationGroup> groups = pop.getPopulationGroup(); + + int groupMin = pop.getGroupMin(); + int groupMax = pop.getGroupMax(); + int Nbre = (int)groupMax - (int)groupMin + 1; + //log.info("Nbre = " + Nbre); + + if (groupMin != groupMax){ + for (PopulationGroup group : groups) { + if (group.getId() == groupMin) { + // MatrixND getSubMatrix(int dim, Object, int nb) + tfmMatrix = tfmMatrix.getSubMatrix(1, group, Nbre); + tfmMatrix = tfmMatrix.meanOverDim(1); + tfmMatrix = tfmMatrix.reduce(); + //log.info("tfm.DimensionNames = " + Arrays.toString(tfmMatrix.getDimensionNames())); + //log.info("tfm.Semantics = " + Arrays.toString(tfmMatrix.getSemantics())); + } + } + } else { + tfmMatrix = tfmMatrix.reduce(); + //log.info("tfm.DimensionNames = " + Arrays.toString(tfmMatrix.getDimensionNames())); + //log.info("tfm.Semantics = " + Arrays.toString(tfmMatrix.getSemantics())); + } + + return tfmMatrix; + } } Modified: trunk/simulators/DefaultSimulator.java =================================================================== --- trunk/simulators/DefaultSimulator.java 2012-09-14 14:12:39 UTC (rev 295) +++ trunk/simulators/DefaultSimulator.java 2012-09-25 14:51:25 UTC (rev 296) @@ -2,7 +2,7 @@ * #%L * IsisFish data * %% - * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin + * Copyright (C) 2006 - 2012 Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -19,7 +19,6 @@ * <http://www.gnu.org/licenses/gpl-2.0.html>. * #L% */ - package simulators; import fr.ifremer.isisfish.IsisFishException; @@ -56,7 +55,7 @@ /** * DefaultSimulator.java * - * Created: 21 août 2006 10:57:46 + * Created: 21 aout 2006 10:57:46 * * @author poussin * @version $Revision: 1.19 $ @@ -216,11 +215,12 @@ for (Population pop : siMatrix.getPopulations(step)) { computeMonth(context, siMatrix, step, pop); } - + // // Add some result not population dependante // + // only if there are one or more strategy if (siMatrix.getStrategies(step).size() > 0) { @@ -326,10 +326,11 @@ db.rollbackTransaction(); // - // clear cache + // commit result // - control.setText("Clear cache"); - context.clearCache(step); + control.setText("Commit results"); + TopiaContext tx = context.getDbResult(); + tx.commitTransaction(); // // Go next step @@ -479,7 +480,7 @@ .matrixCatchWeightPerStrategyMetPerZonePop(step, pop, catchPerStrategyMetPerZonePop); resManager.addResult(step, pop, catchWeightPerStrategyMet); - } + } if (isEffortByCell(context)) { MatrixND catchPerStrategyMetPerZoneMet = siMatrix @@ -495,6 +496,21 @@ } } + if (resManager.isEnabled(ResultName.MATRIX_FISHING_MORTALITY_PER_GROUP) || + resManager.isEnabled(ResultName.MATRIX_TOTAL_FISHING_MORTALITY)) { + MatrixND fishingMortalityPerGroup = siMatrix.fishingMortalityPerGroup(step, + pop, context.getSimulationStorage().getResultStorage()); + + if (resManager.isEnabled(ResultName.MATRIX_FISHING_MORTALITY_PER_GROUP)) { + resManager.addResult(step, pop, fishingMortalityPerGroup); + } + + if (resManager.isEnabled(ResultName.MATRIX_TOTAL_FISHING_MORTALITY)) { + MatrixND totalFishingMortality = siMatrix.totalFishingMortality(step, pop, fishingMortalityPerGroup); + resManager.addResult(step, pop, totalFishingMortality); + } + } + } else { // no strategies // compute only if fishing mortality =0 to apply Natural Mortality abundance = siMatrix.matrixAbundanceSsF(N, pop, step); @@ -553,10 +569,6 @@ .matrixSharedNotFixedCostsPerVessel(step); resManager.addResult(step, mat); } - // if (resManager.isEnabled(ResultName.MATRIX_SHARED_FIXED_COSTS_PER_VESSEL_PER_MET)) { - // MatrixND mat = gravityModel.matrixSharedFixedCostsPerVesselPerMet(date); - // resManager.addResult(date, mat); - // } if (resManager .isEnabled(ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET)) { MatrixND mat = gravityModel