Author: echatellier Date: 2018-04-05 10:54:08 +0200 (Thu, 05 Apr 2018) New Revision: 400 Url: http://forge.codelutin.com/projects/isis-fish-data/repository/revisions/400 Log: Simplification du code Modified: trunk/pom.xml trunk/rules/Cantonnement.java trunk/rules/CantonnementPreSimu.java trunk/rules/ChangementParamControlablePresimu.java trunk/rules/InterdictionEngin.java trunk/rules/InterdictionEnginPreSimu.java trunk/rules/TACpoids.java trunk/scripts/GravityModel.java trunk/scripts/SiMatrix.java trunk/scripts/SiMatrixEffortByCell.java trunk/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java trunk/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java trunk/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/pom.xml 2018-04-05 08:54:08 UTC (rev 400) @@ -24,6 +24,9 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputDirectory>UTF-8</project.reporting.outputDirectory> <maven.test.skip>true</maven.test.skip> + <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> </properties> <organization> @@ -35,18 +38,6 @@ <sourceDirectory>${project.basedir}</sourceDirectory> <plugins> <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.7.0</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - <excludes> - <exclude>**/simulations/**</exclude> - <exclude>**/formules/**</exclude> - </excludes> - </configuration> - </plugin> - <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.6.0</version> Modified: trunk/rules/Cantonnement.java =================================================================== --- trunk/rules/Cantonnement.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/rules/Cantonnement.java 2018-04-05 08:54:08 UTC (rev 400) @@ -193,7 +193,7 @@ for (Iterator<Zone> i = zoneMetiers.iterator(); i.hasNext();) { Zone zone = i.next(); // copy list cell to not modify original zone - List<Cell> tmpCells = new ArrayList<Cell>(zone.getCell()); + List<Cell> tmpCells = new ArrayList<>(zone.getCell()); tmpCells.removeAll(param_zone.getCell()); zoneCantonnement.addAllCell(tmpCells); Modified: trunk/rules/CantonnementPreSimu.java =================================================================== --- trunk/rules/CantonnementPreSimu.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/rules/CantonnementPreSimu.java 2018-04-05 08:54:08 UTC (rev 400) @@ -219,7 +219,7 @@ //si tout est fermé on met les proportions à 0 pour les mois fermes if (ToutFerme){ log.info ("toute la zone métier est fermée"); - List<Month> chomageMonth = new ArrayList<Month>(SaisonFermee); + List<Month> chomageMonth = new ArrayList<>(SaisonFermee); chomageMonth.retainAll(saison); log.info ("de "+chomageMonth.get(0)+" a "+ chomageMonth.get(chomageMonth.size()-1)+ ", le metier est donc mis au chomage"); @@ -246,7 +246,7 @@ //si tout est fermé on met les proportions à 0 pour les mois fermes if (ToutFerme){ log.info ("toute la zone est fermee"); - List<Month> chomageMonth = new ArrayList<Month>(SaisonFermee); + List<Month> chomageMonth = new ArrayList<>(SaisonFermee); chomageMonth.retainAll(saison); reportNonActivite(context, listestrategies, metiers, metier, chomageMonth); } Modified: trunk/rules/ChangementParamControlablePresimu.java =================================================================== --- trunk/rules/ChangementParamControlablePresimu.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/rules/ChangementParamControlablePresimu.java 2018-04-05 08:54:08 UTC (rev 400) @@ -140,7 +140,7 @@ if (ZoneFermee == null || taille!=0){ if (saison.containsAll(SaisonFermee)){ log.info ("il y a intersection de la zone metier au cours de la saison" + saison); - List<Month> moisconcerne = new ArrayList<Month>(saison); + List<Month> moisconcerne = new ArrayList<>(saison); moisconcerne.retainAll(SaisonFermee); MetierDAO metierDao = context.getMetierDAO(); @@ -159,7 +159,7 @@ NouveauInfoSaison.setMetier(NouveauMetier); NouveauInfoSaison.setMonths(sais); // EC : new ArrayList<Zone>() fix error "Found shared references to a collection" - NouveauInfoSaison.setZone(new ArrayList<Zone>(infsais.getZone())); + NouveauInfoSaison.setZone(new ArrayList<>(infsais.getZone())); NouveauInfoSaison.setComment("créé durant la simulation"); NouveauMetier.addMetierSeasonInfo(NouveauInfoSaison); } Modified: trunk/rules/InterdictionEngin.java =================================================================== --- trunk/rules/InterdictionEngin.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/rules/InterdictionEngin.java 2018-04-05 08:54:08 UTC (rev 400) @@ -151,7 +151,7 @@ // récupère toutes les stratégies pratiquant le métier et pour lesquelles la proportion !=0 SiMatrix siMatrix = SiMatrix.getSiMatrix(context); List<Strategy> strs = siMatrix.getStrategies(step); - List<Strategy> ListeStrat = new ArrayList<Strategy>(); + List<Strategy> ListeStrat = new ArrayList<>(); for (Strategy str : strs) { double prop = str.getStrategyMonthInfo(step.getMonth()).getProportionMetier(metier); Modified: trunk/rules/InterdictionEnginPreSimu.java =================================================================== --- trunk/rules/InterdictionEnginPreSimu.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/rules/InterdictionEnginPreSimu.java 2018-04-05 08:54:08 UTC (rev 400) @@ -119,8 +119,8 @@ metierMon.addforbiddenMetier(metier, mois); //1er cas:l'effort est reporte sur un metier de la meme strategie, n'ayant pas l'espece comme capture principale et pechant avec le meme engin - List<EffortDescription> MetiersPossibles = - new ArrayList<EffortDescription>(Strat.getSetOfVessels().getPossibleMetiers()); + List<EffortDescription> MetiersPossibles = + new ArrayList<>(Strat.getSetOfVessels().getPossibleMetiers()); // on verifie que les metiers sont bien pratiques au mois courant, // qu'ils n'ont pas le meme ont le meme engin et qu'ils ne sont Modified: trunk/rules/TACpoids.java =================================================================== --- trunk/rules/TACpoids.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/rules/TACpoids.java 2018-04-05 08:54:08 UTC (rev 400) @@ -194,7 +194,7 @@ //recupere toutes les strategies pratiquant le metier et pour lesquelles la proportion !=0 SiMatrix siMatrix = SiMatrix.getSiMatrix(context); - Set<Strategy> strs = new HashSet<Strategy>(); + Set<Strategy> strs = new HashSet<>(); for (Strategy str : siMatrix.getStrategies(step)) { double prop = str.getStrategyMonthInfo(step.getMonth()) .getProportionMetier(metier); @@ -210,14 +210,14 @@ // 1er cas de figure: l'effort est reporte sur un metier de la // meme strategie, n'ayant pas l'espece comme capture principale // et pechant avec le meme engin - Set<Metier> possibleMetierCase1 = new HashSet<Metier>(); + Set<Metier> possibleMetierCase1 = new HashSet<>(); // second cas de figure: on cherche un metier de substitution // sans condition sur les engins, mais qui soit pratique - Set<Metier> possibleMetierCase2 = new HashSet<Metier>(); + Set<Metier> possibleMetierCase2 = new HashSet<>(); // 3 eme cas de figure: on cherche des metiers non vises, // sans consideration sur les engins, et pour lesquels la // proportion peut etre nulle - Set<Metier> possibleMetierCase3 = new HashSet<Metier>(); + Set<Metier> possibleMetierCase3 = new HashSet<>(); for (EffortDescription effort : str.getSetOfVessels() .getPossibleMetiers()) { Modified: trunk/scripts/GravityModel.java =================================================================== --- trunk/scripts/GravityModel.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/scripts/GravityModel.java 2018-04-05 08:54:08 UTC (rev 400) @@ -138,11 +138,9 @@ new List[] { strategies, metiers }, new String[] { n("Strategies"), n("Metiers") }); - for (int s = 0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); + for (Strategy str : strategies) { metiers = siMatrix.getMetiers(str, step); - for (int m = 0; m < metiers.size(); m++) { - Metier metier = metiers.get(m); + for (Metier metier : metiers) { double value = fishingTimePerMonthPerVessel(str, metier, step); result.setValue(str, metier, value); } @@ -183,11 +181,9 @@ new List[] { strategies, metiers }, new String[] { n("Strategies"), n("Metiers") }); - for (int s = 0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); + for (Strategy str : strategies) { metiers = siMatrix.getMetiers(str, step); - for (int m = 0; m < metiers.size(); m++) { - Metier metier = metiers.get(m); + for (Metier metier : metiers) { double value = fuelCostsOfTravelPerVessel(str, metier, step); result.setValue(str, metier, value); } @@ -235,11 +231,9 @@ new List[] { strategies, metiers }, new String[] { n("Strategies"), n("Metiers") }); - for (int s = 0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); + for (Strategy str : strategies) { metiers = siMatrix.getMetiers(str, step); - for (int m = 0; m < metiers.size(); m++) { - Metier metier = metiers.get(m); + for (Metier metier : metiers) { double value = costsOfFishingPerVessel(str, metier, step); result.setValue(str, metier, value); } @@ -289,11 +283,9 @@ new List[] { strategies, metiers }, new String[] { n("Strategies"), n("Metiers") }); - for (int s = 0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); + for (Strategy str : strategies) { metiers = siMatrix.getMetiers(str, step); - for (int m = 0; m < metiers.size(); m++) { - Metier metier = metiers.get(m); + for (Metier metier : metiers) { double value = fuelCostsPerVessel(str, metier, step); result.setValue(str, metier, value); } @@ -333,13 +325,10 @@ new List[] { strategies, metiers }, new String[] { n("Strategies"), n("Metiers") }); - for (int s = 0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); + for (Strategy str : strategies) { SetOfVessels sov = str.getSetOfVessels(); metiers = siMatrix.getMetiers(str, step); - for (int m = 0; m < metiers.size(); m++) { - Metier metier = metiers.get(m); - + for (Metier metier : metiers) { double fishingTime = 0; double repair = 0; @@ -347,10 +336,10 @@ if (effort != null) { repair = effort.getRepairAndMaintenanceGearCost(); } - if (repair != 0 ) { + if (repair != 0) { fishingTimePerMonthPerVessel(str, metier, step); } - + // FIXME verifier qu'il faut bien retourner 0, si pas d'effort double value = fishingTime * repair / TimeUnit.HOUR_PER_DAY; @@ -408,11 +397,9 @@ new List[] { strategies, metiers }, new String[] { n("Strategies"), n("Metiers") }); - for (int s = 0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); + for (Strategy str : strategies) { metiers = siMatrix.getMetiers(str, step); - for (int m = 0; m < metiers.size(); m++) { - Metier metier = metiers.get(m); + for (Metier metier : metiers) { double value = otherRunningCostsPerVessel(str, metier, step); result.setValue(str, metier, value); } @@ -461,11 +448,9 @@ new List[] { strategies, metiers }, new String[] { n("Strategies"), n("Metiers") }); - for (int s = 0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); + for (Strategy str : strategies) { metiers = siMatrix.getMetiers(str, step); - for (int m = 0; m < metiers.size(); m++) { - Metier metier = metiers.get(m); + for (Metier metier : metiers) { double value = sharedNotFixedCostsPerVessel(str, metier, step); result.setValue(str, metier, value); } Modified: trunk/scripts/SiMatrix.java =================================================================== --- trunk/scripts/SiMatrix.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/scripts/SiMatrix.java 2018-04-05 08:54:08 UTC (rev 400) @@ -126,7 +126,7 @@ * @throws TopiaException */ public List<Population> getPopulations(TimeStep step) throws TopiaException { - List<Population> populations = new ArrayList<Population>(); + List<Population> populations = new ArrayList<>(); for (Population pop : context.getSimulationStorage().getParameter() .getPopulations()) { Population tmp = (Population) db.findByTopiaId(pop.getTopiaId()); @@ -141,7 +141,7 @@ */ public List<Strategy> getStrategies(TimeStep step) throws TopiaException { // if (strategies == null) { - List<Strategy> strategies = new ArrayList<Strategy>(); + List<Strategy> strategies = new ArrayList<>(); for (Strategy str : context.getSimulationStorage().getParameter() .getStrategies()) { Strategy tmp = (Strategy) db.findByTopiaId(str.getTopiaId()); @@ -153,8 +153,8 @@ public List<Metier> getMetiers(TimeStep step) throws TopiaException { // if (metiers == null) { - List<Metier> metiers = new ArrayList<Metier>(); - HashSet<Metier> tmp = new HashSet<Metier>(); + List<Metier> metiers = new ArrayList<>(); + HashSet<Metier> tmp = new HashSet<>(); for (Strategy str : getStrategies(step)) { SetOfVessels sov = str.getSetOfVessels(); for (EffortDescription effort : sov.getPossibleMetiers()) { @@ -328,18 +328,14 @@ Month month = step.getMonth(); // Optimisation Hilaire - for (int s = 0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); + for (Strategy str : strategies) { metiers = getMetiers(str, step); - for (int m = 0; m < metiers.size(); m++) { - Metier metier = metiers.get(m); + for (Metier metier : metiers) { MetierSeasonInfo msi = metier.getMetierSeasonInfo(month); - for (int z = 0; z < zones.size(); z++) { - Zone zone = zones.get(z); + for (Zone zone : zones) { double effort = effortPerZonePop(str, metier, msi, step, zone); if (effort > 0) { - for (int g = 0; g < groups.size(); g++) { - PopulationGroup group = groups.get(g); + for (PopulationGroup group : groups) { double value = catchRatePerStrategyMet(str, metier, step, group, zone, matrixFishingMortality); result.setValue(str, metier, group, zone, value); @@ -861,7 +857,7 @@ * @return */ public List<Cell> getCells(Collection<Zone> zones) { - List<Cell> result = new ArrayList<Cell>(); + List<Cell> result = new ArrayList<>(); for (Zone zone : zones) { result.addAll(zone.getCell()); } @@ -877,7 +873,7 @@ */ public int nbCellInter(Collection<Zone> zoneMet, Zone zonePop) { List<Cell> cells = getCells(zoneMet); - List<Cell> tmp = new ArrayList<Cell>(cells); + List<Cell> tmp = new ArrayList<>(cells); tmp.retainAll(zonePop.getCell()); return tmp.size(); } @@ -951,7 +947,7 @@ Zone zone = zones.get(z); double M = getTotalDeathRate(step, group, zone) / (double) Month.NUMBER_OF_MONTH; - double value = (double) Math.exp(-M); + double value = Math.exp(-M); double n = N.getValue(g, z); value *= n; @@ -1052,10 +1048,8 @@ MatrixAbundanceBeginMonth.NAME, new List[] { groups, zones }, new String[] { n("Groups"), n("Zones") }); - for (int g = 0; g < groups.size(); g++) { - PopulationGroup group = groups.get(g); - for (int z = 0; z < zones.size(); z++) { - Zone zone = zones.get(z); + for (PopulationGroup group : groups) { + for (Zone zone : zones) { double value = N.getValue(group, zone); result.setValue(group, zone, value); } @@ -1077,11 +1071,9 @@ new List[] { strategies, metiers }, new String[] { n("Strategies"), n("Metiers") }); - for (int s = 0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); + for (Strategy str : strategies) { metiers = getMetiers(str, step); - for (int m = 0; m < metiers.size(); m++) { - Metier metier = metiers.get(m); + for (Metier metier : metiers) { double value = effortPerStrategyMet(str, metier, step); result.setValue(str, metier, value); } @@ -1128,11 +1120,9 @@ new List[]{strategies, metiers}, new String[]{n("Strategies"), n("Metiers")}); - for (int s=0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); + for (Strategy str : strategies) { metiers = getMetiers(str, step); - for (int m=0; m < metiers.size(); m++) { - Metier metier = metiers.get(m); + for (Metier metier : metiers) { double value = effortNominalPerStrategyMet(str, metier, step); result.setValue(str, metier, value); } @@ -1245,7 +1235,7 @@ int groupMin = pop.getFbarGroupMin(); int groupMax = pop.getFbarGroupMax(); - int groupCount = (int)groupMax - (int)groupMin + 1; + int groupCount = groupMax - groupMin + 1; for (PopulationGroup group : groups) { if (group.getId() == groupMin) { Modified: trunk/scripts/SiMatrixEffortByCell.java =================================================================== --- trunk/scripts/SiMatrixEffortByCell.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/scripts/SiMatrixEffortByCell.java 2018-04-05 08:54:08 UTC (rev 400) @@ -123,15 +123,12 @@ MatrixND tmp = matrixCatchPerStrategyMetPerCell.sumOverDim(3); tmp = tmp.reduceDims(3); - for (int s = 0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); - for (int g = 0; g < groups.size(); g++) { - PopulationGroup group = groups.get(g); + for (Strategy str : strategies) { + for (PopulationGroup group : groups) { // on iter que sur les metiers qui ont une proportion non 0 // car la matrice pour les autres metiers, contient 0. List<Metier> metiersNot0 = getMetiers(str, step); - for (int m = 0; m < metiersNot0.size(); m++) { - Metier metier = metiersNot0.get(m); + for (Metier metier : metiersNot0) { MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(step .getMonth()); Collection<Zone> zoneMet = infoMet.getZone(); @@ -138,8 +135,7 @@ for (Zone z : zoneMet) { double value = 0; List<Cell> cells = z.getCell(); - for (int c = 0; c < cells.size(); c++) { - Cell cell = cells.get(c); + for (Cell cell : cells) { if (cellPops.contains(cell)) { // les cells de la matrice sont les cells des // zones pops, donc seul les intersections avec @@ -258,7 +254,7 @@ matrixFishingMortalityPerCell).getValue(group, zone, cell); //totalFishingMortality(step, group, zone); // rem perf: totalFishingMortality a deja ete calcule double M = getTotalDeathRate(step, group, zone) / (double) Month.NUMBER_OF_MONTH; - double result = (double) Math.exp(-(F + M)); + double result = Math.exp(-(F + M)); return result; } @@ -335,7 +331,7 @@ str, metier, infoMet, step); if (effort > 0) { // put value only if <> 0 for (Zone zone : zones) { - Set<Cell> cellPops = new HashSet<Cell>(zone.getCell()); + Set<Cell> cellPops = new HashSet<>(zone.getCell()); for (Cell cellMet : infoMet.getCells()) { if (cellPops.contains(cellMet)) { // Reduction d'effort (generic): Modified: trunk/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java =================================================================== --- trunk/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java 2018-04-05 08:54:08 UTC (rev 400) @@ -75,7 +75,7 @@ List<PopulationGroup> groups = tempPop.getPopulationGroup(); - Map<Integer, Double> map =new HashMap<Integer,Double>(); + Map<Integer, Double> map = new HashMap<>(); for (PopulationGroup group:groups) { map.put(group.getId(),group.getMaturityOgive()); Modified: trunk/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java =================================================================== --- trunk/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java 2018-04-05 08:54:08 UTC (rev 400) @@ -80,7 +80,7 @@ List<PopulationGroup> groups = tempPop.getPopulationGroup(); - Map<Integer, Double> map =new HashMap<Integer,Double>(); + Map<Integer, Double> map = new HashMap<>(); for (PopulationGroup group:groups) { map.put(group.getId(),group.getMaturityOgive()); Modified: trunk/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java =================================================================== --- trunk/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java 2018-04-03 13:17:32 UTC (rev 399) +++ trunk/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java 2018-04-05 08:54:08 UTC (rev 400) @@ -76,7 +76,7 @@ enum State { STATE_INIT, STATE_0, STATE_1, STATE_2, STATE_3, STATE_4 - }; + } /////***here must appear the path to export the historic file ("Historic.csv") //in which q1, q2 and objective function computed at each simulation are stored @@ -431,10 +431,10 @@ // cree la liste experiences ou sont stoqués q1,q2 et critere pour chaque simulation /** contains last simplex and potentialy 2 more simulation */ - public List<Experience> current = new ArrayList<Experience>(); + public List<Experience> current = new ArrayList<>(); /** contains all experience done */ - public List<Experience> history = new ArrayList<Experience>(); + public List<Experience> history = new ArrayList<>(); /** * return experience requested, if this experience doesn't exist