Author: echatellier Date: 2012-09-26 10:37:04 +0200 (Wed, 26 Sep 2012) New Revision: 298 Url: http://forge.codelutin.com/repositories/revision/isis-fish-data/298 Log: Remove useless if/else code Modified: trunk/scripts/MinimisationUtil.java trunk/scripts/SiMatrix.java Modified: trunk/scripts/MinimisationUtil.java =================================================================== --- trunk/scripts/MinimisationUtil.java 2012-09-26 08:35:52 UTC (rev 297) +++ trunk/scripts/MinimisationUtil.java 2012-09-26 08:37:04 UTC (rev 298) @@ -30,7 +30,7 @@ public class MinimisationUtil { /** to use log facility, just put in your code: log.info("..."); */ - static private Log log = LogFactory.getLog(RuleUtil.class); + static private Log log = LogFactory.getLog(MinimisationUtil.class); /** * Algo de minimisation de fmin(step, x,C,M,N) sur x. Modified: trunk/scripts/SiMatrix.java =================================================================== --- trunk/scripts/SiMatrix.java 2012-09-26 08:35:52 UTC (rev 297) +++ trunk/scripts/SiMatrix.java 2012-09-26 08:37:04 UTC (rev 298) @@ -30,7 +30,6 @@ 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; @@ -60,7 +59,6 @@ import fr.ifremer.isisfish.types.TimeStep; import fr.ifremer.isisfish.types.Month; import fr.ifremer.isisfish.datastore.ResultStorage; -import scripts.RuleUtil; /** * SiMatrix.java @@ -1597,19 +1595,19 @@ * @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; + 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) { @@ -1620,7 +1618,7 @@ // 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(); @@ -1629,7 +1627,7 @@ 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 @@ -1640,13 +1638,13 @@ 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); @@ -1656,7 +1654,7 @@ 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 { @@ -1668,17 +1666,17 @@ //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(); + 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); @@ -1689,21 +1687,15 @@ 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())); + 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())); + } } return tfmMatrix;