Isis-fish-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
July 2014
- 4 participants
- 67 discussions
r4074 - in trunk/src/test/resources/test-database: . exports rules scripts sensitivityexports simulationplans simulators
by echatellier@users.forge.codelutin.com 29 Jul '14
by echatellier@users.forge.codelutin.com 29 Jul '14
29 Jul '14
Author: echatellier
Date: 2014-07-29 16:44:48 +0200 (Tue, 29 Jul 2014)
New Revision: 4074
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4074
Log:
Update test scripts
Added:
trunk/src/test/resources/test-database/exports/CapturesNombreStrategies.java
trunk/src/test/resources/test-database/exports/CapturesPoidsStrategies.java
trunk/src/test/resources/test-database/objectives/
trunk/src/test/resources/test-database/optimizations/
trunk/src/test/resources/test-database/scripts/MinimisationUtil.java
trunk/src/test/resources/test-database/scripts/ObjectiveFunction.java
trunk/src/test/resources/test-database/scripts/ObjectiveFunctionBaranov.java
trunk/src/test/resources/test-database/simulationplans/RecuitSimuleSimulateur.java
trunk/src/test/resources/test-database/simulators/SimulatorEffortByCell.java
Modified:
trunk/src/test/resources/test-database/exports/Abundances.java
trunk/src/test/resources/test-database/exports/Biomasses.java
trunk/src/test/resources/test-database/exports/CapturesNombre.java
trunk/src/test/resources/test-database/exports/CapturesPoids.java
trunk/src/test/resources/test-database/exports/CellsDefinition.java
trunk/src/test/resources/test-database/exports/EffortsMetier.java
trunk/src/test/resources/test-database/exports/MetierZone.java
trunk/src/test/resources/test-database/exports/NonActivite.java
trunk/src/test/resources/test-database/exports/OwnerMargin.java
trunk/src/test/resources/test-database/exports/RegionDefinition.java
trunk/src/test/resources/test-database/exports/RejetsNombre.java
trunk/src/test/resources/test-database/exports/RejetsPoids.java
trunk/src/test/resources/test-database/exports/VesselMargin.java
trunk/src/test/resources/test-database/exports/ZonesDefinition.java
trunk/src/test/resources/test-database/rules/Cantonnement.java
trunk/src/test/resources/test-database/rules/CantonnementPreSimu.java
trunk/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java
trunk/src/test/resources/test-database/rules/EffortReduction.java
trunk/src/test/resources/test-database/rules/GraviteVPUE1.java
trunk/src/test/resources/test-database/rules/InterdictionEngin.java
trunk/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java
trunk/src/test/resources/test-database/rules/TACpoids.java
trunk/src/test/resources/test-database/rules/TailleMin.java
trunk/src/test/resources/test-database/rules/TotalClosure.java
trunk/src/test/resources/test-database/scripts/GravityModel.java
trunk/src/test/resources/test-database/scripts/ResultName.java
trunk/src/test/resources/test-database/scripts/RuleUtil.java
trunk/src/test/resources/test-database/scripts/SiMatrix.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java
trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java
trunk/src/test/resources/test-database/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java
trunk/src/test/resources/test-database/simulationplans/SimulationNumberRestriction.java
trunk/src/test/resources/test-database/simulators/DefaultSimulator.java
Modified: trunk/src/test/resources/test-database/exports/Abundances.java
===================================================================
--- trunk/src/test/resources/test-database/exports/Abundances.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/Abundances.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 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
@@ -26,7 +26,6 @@
import java.io.Writer;
-import static org.nuiton.i18n.I18n._;
import org.nuiton.math.matrix.*;
import scripts.ResultName;
@@ -37,7 +36,7 @@
import fr.ifremer.isisfish.datastore.SimulationStorage;
/**
- * Abundance.java
+ * Abundances.java
*
* Created: 1 septembre 2006
*
@@ -52,8 +51,8 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(Abundances.class);
- protected String [] necessaryResult = {
- ResultName.MATRIX_ABUNDANCE
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_ABUNDANCE
};
@Override
@@ -73,22 +72,22 @@
@Override
public String getDescription() {
- return _("Exporte les abondances en nombre tableau avec des lignes pop;id;zone;date;nombre.");
+ return "Exporte les abondances en nombre tableau avec des lignes pop;id;zone;date;nombre.";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
for (Population pop : simulation.getParameter().getPopulations()) {
MatrixND mat = simulation.getResultStorage().getMatrix(pop, ResultName.MATRIX_ABUNDANCE);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
- Object [] sems = i.getSemanticsCoordinates();
- TimeStep step = (TimeStep)sems[0];
- PopulationGroup group = (PopulationGroup)sems[1];
- Zone zone = (Zone)sems[2];
+ Object[] sems = i.getSemanticsCoordinates();
+ TimeStep step = (TimeStep) sems[0];
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Zone zone = (Zone) sems[2];
double val = i.getValue();
- out.write(pop.getName() +";"+ group.getId() +";"+ zone.getName() +";"+ step.getStep() +";"+ val +"\n");
+ out.write(pop.getName() + ";" + group.getId() + ";" + zone.getName() + ";" + step.getStep() + ";" + val + "\n");
}
}
}
Modified: trunk/src/test/resources/test-database/exports/Biomasses.java
===================================================================
--- trunk/src/test/resources/test-database/exports/Biomasses.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/Biomasses.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -53,8 +51,8 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(Biomasses.class);
- protected String [] necessaryResult = {
- ResultName.MATRIX_BIOMASS
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_BIOMASS
};
@Override
@@ -74,22 +72,22 @@
@Override
public String getDescription() {
- return _("Exporte les biomasses tableau avec des lignes pop;id;zone;date;nombre");
+ return "Exporte les biomasses tableau avec des lignes pop;id;zone;date;nombre";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
for (Population pop : simulation.getParameter().getPopulations()) {
MatrixND mat = simulation.getResultStorage().getMatrix(pop, ResultName.MATRIX_BIOMASS);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
- Object [] sems = i.getSemanticsCoordinates();
- TimeStep step = (TimeStep)sems[0];
- PopulationGroup group = (PopulationGroup)sems[1];
- Zone zone = (Zone)sems[2];
-
+ Object[] sems = i.getSemanticsCoordinates();
+ TimeStep step = (TimeStep) sems[0];
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Zone zone = (Zone) sems[2];
+
double val = i.getValue();
- out.write(pop.getName() +";"+ group.getId() +";"+ zone.getName() +";"+ step.getStep() +";"+ val +"\n");
+ out.write(pop.getName() + ";" + group.getId() + ";" + zone.getName() + ";" + step.getStep() + ";" + val + "\n");
}
}
}
Modified: trunk/src/test/resources/test-database/exports/CapturesNombre.java
===================================================================
--- trunk/src/test/resources/test-database/exports/CapturesNombre.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/CapturesNombre.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,16 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixIterator;
-import org.nuiton.math.matrix.MatrixND;
-
-import scripts.ResultName;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Metier;
import fr.ifremer.isisfish.entities.Population;
@@ -38,12 +28,20 @@
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.export.Export;
import fr.ifremer.isisfish.types.TimeStep;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+import java.io.Writer;
+
/**
* CapturesNombre.java
*
- * Created: 23 novembre 2006
- *
+ * Export des captures en nombre de la forme :
+ * Population ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur
+ *
* @author anonymous <anonymous(a)labs.libre-entreprise.org>
* @version $Revision: 1.4 $
*
@@ -54,7 +52,9 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(CapturesNombre.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP
+ };
@Override
public String[] getNecessaryResult() {
@@ -73,7 +73,7 @@
@Override
public String getDescription() {
- return _("Export les captures en nombre de la simulation. tableau pop;metier;id;zone;nombre");
+ return "Export les captures en nombre de la simulation. tableau pop;metier;id;zone;nombre";
}
@Override
@@ -82,8 +82,7 @@
TimeStep lastStep = simulation.getResultStorage().getLastStep();
for (Population pop : simulation.getParameter().getPopulations()) {
- for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step
- .next()) {
+ for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step.next()) {
MatrixND mat = simulation.getResultStorage().getMatrix(step,
pop, ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP);
if (mat != null) { // can be null if simulation is stopped before last year simulation
Added: trunk/src/test/resources/test-database/exports/CapturesNombreStrategies.java
===================================================================
--- trunk/src/test/resources/test-database/exports/CapturesNombreStrategies.java (rev 0)
+++ trunk/src/test/resources/test-database/exports/CapturesNombreStrategies.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -0,0 +1,109 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
+ * %%
+ * 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 3 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-3.0.html>.
+ * #L%
+ */
+package exports;
+
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.export.Export;
+import fr.ifremer.isisfish.types.TimeStep;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+
+import java.io.Writer;
+
+/**
+ * CapturesNombreStrategies.java
+ *
+ * Export des captures en nombre de la forme :
+ * Population ; Stratégie ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur
+ *
+ * @author anonymous <anonymous(a)labs.libre-entreprise.org>
+ * @version $Revision$
+ *
+ * Last update: $Date$ by : $Author$
+ */
+public class CapturesNombreStrategies implements Export {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(CapturesNombreStrategies.class);
+
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP
+ };
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "CapturesNombreStrategies";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Export les captures en nombre de la simulation. tableau pop;strategie;metier;id;zone;nombre";
+ }
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out) throws Exception {
+ TimeStep lastStep = simulation.getResultStorage().getLastStep();
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step
+ .next()) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(step,
+ pop, ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP);
+ if (mat != null) { // can be null if simulation is stopped before last year simulation
+ //mat = mat.sumOverDim(0); //sum on strategy
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Metier metier = (Metier) sems[1];
+ PopulationGroup group = (PopulationGroup) sems[2];
+ Zone zone = (Zone) sems[3];
+ Strategy strategy = (Strategy) sems[0];
+
+ double val = i.getValue();
+ out.write(pop.getName() + ";" + strategy.getName() + ";"
+ + metier.getName() + ";" + group.getId() + ";"
+ + zone.getName() + ";" + step.getStep() + ";"
+ + val + "\n");
+ }
+ }
+ }
+ }
+ }
+}
Property changes on: trunk/src/test/resources/test-database/exports/CapturesNombreStrategies.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/test/resources/test-database/exports/CapturesPoids.java
===================================================================
--- trunk/src/test/resources/test-database/exports/CapturesPoids.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/CapturesPoids.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,16 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixIterator;
-import org.nuiton.math.matrix.MatrixND;
-
-import scripts.ResultName;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Metier;
import fr.ifremer.isisfish.entities.Population;
@@ -38,11 +28,19 @@
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.export.Export;
import fr.ifremer.isisfish.types.TimeStep;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+import java.io.Writer;
+
/**
* CapturesPoids.java
*
- * Created: 23 novembre 2006
+ * Export des captures en poids de la forme :
+ * Population ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur
*
* @author anonymous <anonymous(a)labs.libre-entreprise.org>
* @version $Revision: 1.4 $
@@ -54,7 +52,9 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(CapturesPoids.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
@Override
public String[] getNecessaryResult() {
@@ -73,7 +73,7 @@
@Override
public String getDescription() {
- return _("Export les captures en poids de la simulation. tableau pop;metier;id;zone;nombre");
+ return "Export les captures en poids de la simulation. tableau pop;metier;id;zone;nombre";
}
@Override
Added: trunk/src/test/resources/test-database/exports/CapturesPoidsStrategies.java
===================================================================
--- trunk/src/test/resources/test-database/exports/CapturesPoidsStrategies.java (rev 0)
+++ trunk/src/test/resources/test-database/exports/CapturesPoidsStrategies.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -0,0 +1,110 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
+ * %%
+ * 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 3 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-3.0.html>.
+ * #L%
+ */
+package exports;
+
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.export.Export;
+import fr.ifremer.isisfish.types.TimeStep;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+
+import java.io.Writer;
+
+/**
+ * CapturesPoidsStrategies.java
+ *
+ * Export des captures en poids de la forme :
+ * Population ; Stratégie ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur
+ *
+ * @author anonymous <anonymous(a)labs.libre-entreprise.org>
+ * @version $Revision$
+ *
+ * Last update: $Date$ by : $Author$
+ */
+public class CapturesPoidsStrategies implements Export {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(CapturesPoidsStrategies.class);
+
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "CapturesPoidsStrategies";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Export les captures en poids de la simulation. tableau pop;strategie;metier;id;zone;nombre";
+ }
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ TimeStep lastStep = simulation.getResultStorage().getLastStep();
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step
+ .next()) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(step,
+ pop, ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ if (mat != null) { // can be null if simulation is stopped before last year simulation
+ //mat = mat.sumOverDim(0); //sum on strategy
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Metier metier = (Metier) sems[1];
+ PopulationGroup group = (PopulationGroup) sems[2];
+ Zone zone = (Zone) sems[3];
+ Strategy strategy = (Strategy) sems[0];
+
+ double val = i.getValue();
+ out.write(pop.getName() + ";" + strategy.getName() + ";"
+ + metier.getName() + ";" + group.getId() + ";"
+ + zone.getName() + ";" + step.getStep() + ";"
+ + val + "\n");
+ }
+ }
+ }
+ }
+ }
+}
Property changes on: trunk/src/test/resources/test-database/exports/CapturesPoidsStrategies.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/test/resources/test-database/exports/CellsDefinition.java
===================================================================
--- trunk/src/test/resources/test-database/exports/CellsDefinition.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/CellsDefinition.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import java.util.List;
@@ -50,11 +48,11 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(CellsDefinition.class);
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -74,7 +72,7 @@
@Override
public String getDescription() {
- return _("Export cell's position(longitute/latitute)");
+ return "Export cell's position(longitute/latitute)";
}
@Override
Modified: trunk/src/test/resources/test-database/exports/EffortsMetier.java
===================================================================
--- trunk/src/test/resources/test-database/exports/EffortsMetier.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/EffortsMetier.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,7 +52,7 @@
static private Log log = LogFactory.getLog(EffortsMetier.class);
protected String [] necessaryResult = {
- ResultName.MATRIX_EFFORT_PER_STRATEGY_MET
+ ResultName.MATRIX_EFFORT_PER_STRATEGY_MET
};
@Override
@@ -74,13 +72,13 @@
@Override
public String getDescription() {
- return _("retourne un tableau strategie;metier;date;effort");
+ return "retourne un tableau strategie;metier;date;effort";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
MatrixND mat = simulation.getResultStorage().getMatrix(ResultName.MATRIX_EFFORT_PER_STRATEGY_MET);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
Object [] sems = i.getSemanticsCoordinates();
TimeStep step = (TimeStep)sems[0];
Modified: trunk/src/test/resources/test-database/exports/MetierZone.java
===================================================================
--- trunk/src/test/resources/test-database/exports/MetierZone.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/MetierZone.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -26,7 +26,6 @@
import java.io.Writer;
-import static org.nuiton.i18n.I18n._;
import org.nuiton.math.matrix.*;
import scripts.ResultName;
@@ -51,8 +50,8 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(MetierZone.class);
- public String [] necessaryResult = {
- ResultName.MATRIX_METIER_ZONE,
+ protected String [] necessaryResult = {
+ ResultName.MATRIX_METIER_ZONE,
};
@Override
@@ -72,7 +71,7 @@
@Override
public String getDescription() {
- return _("Export zone used by metier during simulation");
+ return "Export zone used by metier during simulation";
}
@Override
@@ -82,7 +81,7 @@
for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step.next() ) {
MatrixND mat = simulation.getResultStorage().getMatrix(step, ResultName.MATRIX_METIER_ZONE);
if (mat != null) { // can be null if simulation is stopped before last year simulation
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
if (i.getValue() == 1) {
Object metier = i.getSemanticsCoordinates()[0];
Modified: trunk/src/test/resources/test-database/exports/NonActivite.java
===================================================================
--- trunk/src/test/resources/test-database/exports/NonActivite.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/NonActivite.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,7 +52,7 @@
static private Log log = LogFactory.getLog(NonActivite.class);
protected String [] necessaryResult = {
- ResultName.MATRIX_NO_ACTIVITY
+ ResultName.MATRIX_NO_ACTIVITY
};
@Override
@@ -74,13 +72,13 @@
@Override
public String getDescription() {
- return _("retourne un tableau strategie;metier;date;proportion");
+ return "retourne un tableau strategie;metier;date;proportion";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
MatrixND mat = simulation.getResultStorage().getMatrix(ResultName.MATRIX_NO_ACTIVITY);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
Object [] sems = i.getSemanticsCoordinates();
TimeStep step = (TimeStep)sems[0];
Modified: trunk/src/test/resources/test-database/exports/OwnerMargin.java
===================================================================
--- trunk/src/test/resources/test-database/exports/OwnerMargin.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/OwnerMargin.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,7 +52,7 @@
static private Log log = LogFactory.getLog(OwnerMargin.class);
protected String [] necessaryResult = {
- ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL
+ ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL
};
@Override
@@ -74,15 +72,15 @@
@Override
public String getDescription() {
- return _("Exporte les profits du patrons, retourne un tableau strategy;date;value");
+ return "Exporte les profits du patrons, retourne un tableau strategy;date;value";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
MatrixND mat = simulation.getResultStorage().getMatrix(ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
- Object [] sems = i.getSemanticsCoordinates();
+ Object[] sems = i.getSemanticsCoordinates();
TimeStep step = (TimeStep)sems[0];
Strategy str = (Strategy)sems[1];
Modified: trunk/src/test/resources/test-database/exports/RegionDefinition.java
===================================================================
--- trunk/src/test/resources/test-database/exports/RegionDefinition.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/RegionDefinition.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -26,7 +26,6 @@
import java.io.Writer;
-import static org.nuiton.i18n.I18n._;
import org.nuiton.topia.TopiaContext;
import fr.ifremer.isisfish.entities.*;
@@ -49,11 +48,11 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(RegionDefinition.class);
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -73,7 +72,7 @@
@Override
public String getDescription() {
- return _("Export region description");
+ return "Export region description";
}
@Override
Modified: trunk/src/test/resources/test-database/exports/RejetsNombre.java
===================================================================
--- trunk/src/test/resources/test-database/exports/RejetsNombre.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/RejetsNombre.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -54,7 +52,9 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(RejetsNombre.class);
- protected String[] necessaryResult = { ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP
+ };
@Override
public String[] getNecessaryResult() {
@@ -73,7 +73,7 @@
@Override
public String getDescription() {
- return _("Export les rejets en nombre de la simulation. tableau pop;metier;id;zone;date;nombre");
+ return "Export les rejets en nombre de la simulation. tableau pop;metier;id;zone;date;nombre";
}
@Override
Modified: trunk/src/test/resources/test-database/exports/RejetsPoids.java
===================================================================
--- trunk/src/test/resources/test-database/exports/RejetsPoids.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/RejetsPoids.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -54,8 +52,8 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(RejetsPoids.class);
- protected String[] necessaryResult = { ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP
-
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP
};
@Override
@@ -75,7 +73,7 @@
@Override
public String getDescription() {
- return _("Export les rejets en poids de la simulation. tableau pop;metier;id;zone;date;nombre");
+ return "Export les rejets en poids de la simulation. tableau pop;metier;id;zone;date;nombre";
}
@Override
Modified: trunk/src/test/resources/test-database/exports/VesselMargin.java
===================================================================
--- trunk/src/test/resources/test-database/exports/VesselMargin.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/VesselMargin.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,7 +52,7 @@
static private Log log = LogFactory.getLog(VesselMargin.class);
protected String [] necessaryResult = {
- ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL
+ ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL
};
@Override
@@ -74,13 +72,13 @@
@Override
public String getDescription() {
- return _("cvs out strategy;date;value");
+ return "cvs out strategy;date;value";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
MatrixND mat = simulation.getResultStorage().getMatrix(ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
Object [] sems = i.getSemanticsCoordinates();
TimeStep step = (TimeStep)sems[0];
Modified: trunk/src/test/resources/test-database/exports/ZonesDefinition.java
===================================================================
--- trunk/src/test/resources/test-database/exports/ZonesDefinition.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/exports/ZonesDefinition.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -27,7 +27,6 @@
import java.io.Writer;
import java.util.List;
-import static org.nuiton.i18n.I18n._;
import org.nuiton.topia.TopiaContext;
import fr.ifremer.isisfish.entities.*;
@@ -51,11 +50,11 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(ZonesDefinition.class);
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -75,7 +74,7 @@
@Override
public String getDescription() {
- return _("Export cell's zone constitution");
+ return "Export cell's zone constitution";
}
@Override
Modified: trunk/src/test/resources/test-database/rules/Cantonnement.java
===================================================================
--- trunk/src/test/resources/test-database/rules/Cantonnement.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/rules/Cantonnement.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -50,6 +48,8 @@
/**
* Cantonnement.java
*
+ * Remplace aussi Cantonnement Engin
+ *
* Created: 30 novembre 2006
*
* @author anonymous <anonymous(a)labs.libre-entreprise.org>
@@ -58,10 +58,6 @@
* Last update: $Date: 2007-11-02 17:41:41 $
* by : $Author: bpoussin $
*/
-
-/**
- * Remplace aussi Cantonnement Engin
- */
public class Cantonnement extends AbstractRule {
/** to use log facility, just put in your code: log.info("..."); */
@@ -80,12 +76,12 @@
@Doc(value="End month")
public Month param_endMonth = Month.DECEMBER;
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- ResultName.MATRIX_NO_ACTIVITY,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ ResultName.MATRIX_NO_ACTIVITY,
};
@Override
@@ -101,7 +97,7 @@
public String getDescription() throws Exception {
// fermeture saisiniere de zone qui peut être réduite à un engin
// et a certaines années de la simulation
- return _("Cantonnement: can be used to Cantonnement with gear if you put gear in parameter");
+ return "Cantonnement: can be used to Cantonnement with gear if you put gear in parameter";
}
/**
@@ -126,7 +122,7 @@
public boolean condition(SimulationContext context, TimeStep step, Metier metier) throws Exception {
if (step.before(param_beginStep)) {
return false;
- } else if(step.after(param_endStep)) {
+ } else if (step.after(param_endStep)) {
return false;
}
@@ -204,7 +200,7 @@
zoneCantonnement.addAllCell(tmpCells);
i.remove();
}
- List<Zone> newZone = new ArrayList<Zone>();
+ List<Zone> newZone = new ArrayList<>();
newZone.add(zoneCantonnement);
infoMetier.setZone(newZone);
} else {
@@ -219,10 +215,10 @@
metierMon.addforbiddenMetier(metier);
List<Strategy> strategies = siMatrix.getStrategies(step);
- for(Strategy str : strategies){
+ for (Strategy str : strategies) {
StrategyMonthInfo info = str.getStrategyMonthInfo(step.getMonth());
double prop = info.getProportionMetier(metier);
- if (prop != 0){
+ if (prop != 0) {
noActivity.setValue(str , metier, prop);
info.setProportionMetier(metier, 0);
}
Modified: trunk/src/test/resources/test-database/rules/CantonnementPreSimu.java
===================================================================
--- trunk/src/test/resources/test-database/rules/CantonnementPreSimu.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/rules/CantonnementPreSimu.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,9 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n.n_;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -73,15 +70,15 @@
@Doc(value="End month")
public Month param_endMonth = Month.DECEMBER;
- protected Map<Month, MatrixND> tableNonActivite = new HashMap<Month, MatrixND>();
+ protected Map<Month, MatrixND> tableNonActivite = new HashMap<>();
protected boolean affectNonActivite = false;
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- ResultName.MATRIX_NO_ACTIVITY,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ ResultName.MATRIX_NO_ACTIVITY,
};
@Override
@@ -95,7 +92,7 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Cantonnement: can be used to Cantonnement with gear if you put gear in parameter");
+ return "Cantonnement: can be used to Cantonnement with gear if you put gear in parameter";
}
private void reportNonActivite(SimulationContext context,
@@ -107,7 +104,8 @@
if (effort != null){
for (Month month : chomageMonth) {
StrategyMonthInfo InfoMois = strategy.getStrategyMonthInfo(month);
-//this.p.tableNonActivite=Regle_action_lib.reportNonActivite(this.p.tableNonActivite, listestrategies.get(i), metier, mois, InfoMois.getProportionMetier(metier));
+ // this.p.tableNonActivite=Regle_action_lib.reportNonActivite(this.p.tableNonActivite,
+ // listestrategies.get(i), metier, mois, InfoMois.getProportionMetier(metier));
log.info("debut reportNonActivite");
// on regarde si on a déjà une entrée pour le mois courant
@@ -116,7 +114,7 @@
matNonActiviteMois = MatrixFactory.getInstance().create(
ResultName.MATRIX_NO_ACTIVITY,
new List[]{listestrategies, metiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ new String[]{"Strategies", "Metiers"});
tableNonActivite.put(month, matNonActiviteMois);
}
@@ -160,20 +158,20 @@
else {
log.info("l engin du métier est bien concerné");
List<MetierSeasonInfo> saisons = metier.getMetierSeasonInfo();
- for (MetierSeasonInfo saisonmetier: saisons){
+ for (MetierSeasonInfo saisonmetier : saisons){
int inter = siMatrix.nbCellInter(saisonmetier.getZone(), param_zone);
- if (inter != 0){
+ if (inter != 0) {
List<Cell> MailleMetier = siMatrix.getCells(saisonmetier.getZone());
// les mailles qui reste dans la zone metier
- List<Cell> newCellMetier = new ArrayList<Cell>(MailleMetier);
+ List<Cell> newCellMetier = new ArrayList<>(MailleMetier);
newCellMetier.removeAll(maillefermee);
- List<Month> saison=saisonmetier.getMonths();
+ List<Month> saison = saisonmetier.getMonths();
if (saison.containsAll(SaisonFermee)){
log.info("il y a bien intersection entre la zone métier et le cantonnement pour la saison "+saison.toString());
// calcule de la zone restante:
- boolean ToutFerme=false;
+ boolean ToutFerme;
boolean DebInclus=saison.contains(param_beginMonth);
boolean FinInclus=saison.contains(param_endMonth);
@@ -202,7 +200,7 @@
log.info("toute la saison metier est incluse dans la saison de fermeture");
//si tout est fermé, on met le metier au chômage
- if (ToutFerme==true) {
+ if (ToutFerme) {
log.info ("toute la zone est fermée, le metier passe donc à chômage pour cette saison");
reportNonActivite(context, listestrategies, metiers, metier, saison);
@@ -219,7 +217,7 @@
else if (DebInclus && ((!FinInclus) || param_endMonth.equals(saison.get(saison.size()-1)))) {
log.info ("il y a intersection de la saison de fermeture avec la saison métier de " + param_beginMonth + " à " + saison.get(saison.size()-1));
//si tout est fermé on met les proportions à 0 pour les mois fermes
- if (ToutFerme==true){
+ if (ToutFerme){
log.info ("toute la zone métier est fermée");
List<Month> chomageMonth = new ArrayList<Month>(SaisonFermee);
chomageMonth.retainAll(saison);
@@ -246,7 +244,7 @@
else if (((!DebInclus) || param_beginMonth.equals(saison.get(0))) && FinInclus) {
log.info ("il y a intersection de la saison de fermeture avec la saison métier de "+param_beginMonth+" à "+saison.get(saison.size()-1));
//si tout est fermé on met les proportions à 0 pour les mois fermes
- if (ToutFerme==true){
+ if (ToutFerme){
log.info ("toute la zone est fermee");
List<Month> chomageMonth = new ArrayList<Month>(SaisonFermee);
chomageMonth.retainAll(saison);
@@ -272,7 +270,7 @@
// dernier cas de figure: les deux sont inclus et sont différents des bornes
else {
//si tout est fermé on met les proportions à 0 pour les mois fermes
- if (ToutFerme==true){
+ if (ToutFerme){
log.info("toute la zone métier est fermée");
reportNonActivite(context, listestrategies, metiers, metier, SaisonFermee);
}
@@ -325,7 +323,7 @@
public boolean condition(SimulationContext context, TimeStep step, Metier metier) throws Exception {
boolean result = false;
MatrixND mat = tableNonActivite.get(step.getMonth());
- if (mat != null && affectNonActivite == false) {
+ if (mat != null && !affectNonActivite) {
result = true;
}
return result;
@@ -353,7 +351,7 @@
metierMon.setNoActivity(step, mat.copy());
}
else{
- noActivity = noActivity.add(mat);
+ noActivity.add(mat);
}
}
Modified: trunk/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java
===================================================================
--- trunk/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import java.util.ArrayList;
import java.util.List;
@@ -77,11 +75,11 @@
@Doc(value="New param controlable value")
public String param_newParamValue = "80";
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -95,7 +93,7 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Change gear parameter value for all metier with this gear");
+ return "Change gear parameter value for all metier with this gear";
}
/**
Modified: trunk/src/test/resources/test-database/rules/EffortReduction.java
===================================================================
--- trunk/src/test/resources/test-database/rules/EffortReduction.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/rules/EffortReduction.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import java.util.List;
import org.apache.commons.logging.Log;
@@ -57,9 +55,13 @@
@Doc("Pourcentage de reduction d effort applique.")
public double param_PercentReduction = 0.5;
- boolean first = true;
+ protected boolean first = true;
- protected String[] necessaryResult = {};
+ protected String[] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ };
/**
* @return the necessaryResult
@@ -75,7 +77,7 @@
*/
@Override
public String getDescription() {
- return _("Reduce monthly effort of each strategy of the percent indicated");
+ return "Reduce monthly effort of each strategy of the percent indicated";
}
/**
Modified: trunk/src/test/resources/test-database/rules/GraviteVPUE1.java
===================================================================
--- trunk/src/test/resources/test-database/rules/GraviteVPUE1.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/rules/GraviteVPUE1.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -59,21 +57,20 @@
static private Log log = LogFactory.getLog(GraviteVPUE1.class);
/** stocke la somme des prop initiales [str x month] */
- private MatrixND SommePropInitial = null;
- /** stocke par strat*met, la dernière attractivite pour chaque mois [str x met x month] */
+ protected MatrixND SommePropInitial = null;
/** permet de stocker les CPUE nominales [str x met] */
- private MatrixND valuePerUnitOfEffort = null;
+ protected MatrixND valuePerUnitOfEffort = null;
- public String[] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- //ResultName.MATRIX_EFFORT_PER_STRATEGY_MET,
- ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET, // garder la ,
+ // Booleen permettant que ne boucler que sur un seul metier dans la preaction :
+ protected boolean first = true;
+ protected String[] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET
};
@Override
@@ -87,7 +84,7 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Calcule les proportion par métier chaque mois en fonction de la VPUE du métier l'année précédante");
+ return "Calcule les proportion par métier chaque mois en fonction de la VPUE du métier l'année précédante";
/*"HYPOTHESES GRAVITE"
" attention cette règle doit toujours être mise avant les mesures de gestion"+
" si pour un metier Effort (métier annee-1,mois) = 0 et propinitiale (métier, mois) !=0 (ie métier potentiellement pratiqué), alors "+
@@ -146,7 +143,6 @@
SommePropInitial.setValue(str, info.getMonth(), somme);
}
}
-
}
/**
@@ -164,8 +160,6 @@
return step.getYear() > 0;
}
- // Booleen permettant que ne boucler que sur un seul metier dans la preaction :
- boolean first = true;
/**
* Si la condition est vrai alors cette action est executee avant le pas
@@ -195,14 +189,14 @@
////////Initialisation des matrices qui resultent de la simulation////////////////////////////////////////////////////////////
//Calcul de l effort nominal par strategy met
- MatrixND EffortNominalPerStrMet = null;
+ MatrixND EffortNominalPerStrMet;
EffortNominalPerStrMet = resultmanager.getMatrix(step.previousYear(),
ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET);
//System.out.println("EffortNominalPerStrMet calculee "
// + EffortNominalPerStrMet);
//on commence par creer une matrice de valeurs (somme sur ttes les especes capturees) par strategie met
- MatrixND GrossValuePerStrMet = null;
+ MatrixND GrossValuePerStrMet;
GrossValuePerStrMet = resultmanager.getMatrix(step.previousYear(),
ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET);
@@ -246,7 +240,7 @@
//log.info("value/effort= " + vpue);
somme += value / effort;
} else if ((effort == 0)
- & (smi.getProportionMetier(strMetier) == 0)) {// n'a jamais pêche avec ce metier
+ && (smi.getProportionMetier(strMetier) == 0)) {// n'a jamais pêche avec ce metier
valuePerUnitOfEffort.setValue(str, strMetier, 0);
//log.info("n'a jamais pêche avec ce metier");
} else {// n'a pas peche au mois, annee -1, mais avait une prop d'effort non nul a l'annee=0
@@ -257,7 +251,7 @@
//log.info("testCondition pour str" + str.getName()
// + ":" + testCondition);
// A partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravité
- double newProp = 0;
+ double newProp;
//log.info("A partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravité");
if (!testCondition) {
double SommeVPUEstrat = somme;
Modified: trunk/src/test/resources/test-database/rules/InterdictionEngin.java
===================================================================
--- trunk/src/test/resources/test-database/rules/InterdictionEngin.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/rules/InterdictionEngin.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -71,11 +69,11 @@
@Doc(value="do the doc of param endMonth")
public Month param_endMonth = Month.DECEMBER;
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -90,7 +88,7 @@
@Override
public String getDescription() throws Exception {
// interdiction des metiers utilisant cet engin
- return _("Prohibited gear");
+ return "Prohibited gear";
}
/**
@@ -167,7 +165,7 @@
// 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 engin et qu'ils ne sont pas
@@ -184,7 +182,7 @@
// on repartit maintenant l'effort entre les differents metiers
// possibles dans la meme strategie si un metier possible existe bien
- if (MetiersPossibles.size() != 0){
+ if (MetiersPossibles.size() != 0) {
int NbMetier=MetiersPossibles.size();
for (EffortDescription effort : MetiersPossibles) {
Metier met = effort.getPossibleMetiers();
@@ -203,7 +201,7 @@
siMatrix.getMetiers(step));
matNonActivite.setValue(Strat, metier,
StratMonthInfo.getProportionMetier(metier));
- StratMonthInfo.setProportionMetier(metier,0);
+ StratMonthInfo.setProportionMetier(metier, 0);
}
}
Modified: trunk/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java
===================================================================
--- trunk/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,9 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.n_;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -70,14 +67,14 @@
@Doc(value="do the doc of param endMonth")
public Month param_endMonth = Month.DECEMBER;
- protected Map<Month, MatrixND> tableNonActivite = new HashMap<Month, MatrixND>();
+ protected Map<Month, MatrixND> tableNonActivite = new HashMap<>();
protected boolean affectNonActivite = false;
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -91,7 +88,7 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Prohibited gear");
+ return "Prohibited gear";
}
/**
@@ -159,7 +156,7 @@
matNonActiviteMois = MatrixFactory.getInstance().create(
ResultName.MATRIX_NO_ACTIVITY,
new List[]{ListeStrat, ListeMetiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ new String[]{"Strategies", "Metiers"});
tableNonActivite.put(mois, matNonActiviteMois);
}
@@ -189,7 +186,7 @@
public boolean condition(SimulationContext context, TimeStep step, Metier metier) throws Exception {
boolean result = false;
MatrixND mat = tableNonActivite.get(step.getMonth());
- if (mat != null && affectNonActivite == false) {
+ if (mat != null && !affectNonActivite) {
result = true;
}
return result;
@@ -207,7 +204,7 @@
@Override
public void preAction(SimulationContext context, TimeStep step, Metier metier) throws Exception {
// on ne doit le faire qu'une seul fois quelque soit le nombre de metier
- affectNonActivite=true;
+ affectNonActivite = true;
MatrixND mat = tableNonActivite.get(step.getMonth());
MetierMonitor metierMon = context.getMetierMonitor();
@@ -215,10 +212,9 @@
if (noActivity == null) {
metierMon.setNoActivity(step, mat.copy());
+ } else {
+ noActivity.add(mat);
}
- else {
- noActivity = noActivity.add(mat);
- }
// fin
}
Modified: trunk/src/test/resources/test-database/rules/TACpoids.java
===================================================================
--- trunk/src/test/resources/test-database/rules/TACpoids.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/rules/TACpoids.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import java.util.HashSet;
import java.util.Set;
@@ -87,13 +85,13 @@
@Doc("TAC in tons")
public double param_tacInTons = 900;
- boolean affectation = false;
+ protected boolean affectation = false;
protected String[] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
/**
@@ -111,7 +109,7 @@
*/
@Override
public String getDescription() {
- return _("TAC weight in tons.\nIf you want survival discard use propSurvie other than 0.\nIf you wish TAC computed as a proportion of the biomass use propTac other than 0.");
+ return "TAC weight in tons.\nIf you want survival discard use propSurvie other than 0.\nIf you wish TAC computed as a proportion of the biomass use propTac other than 0.";
}
/**
Modified: trunk/src/test/resources/test-database/rules/TailleMin.java
===================================================================
--- trunk/src/test/resources/test-database/rules/TailleMin.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/rules/TailleMin.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin, Stéphanie Mahevas, 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
@@ -21,39 +21,41 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixIterator;
import org.nuiton.math.matrix.MatrixND;
import scripts.ResultName;
-import scripts.SiMatrix;
import fr.ifremer.isisfish.entities.Metier;
import fr.ifremer.isisfish.entities.MetierSeasonInfo;
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationGroup;
import fr.ifremer.isisfish.entities.Species;
import fr.ifremer.isisfish.entities.TargetSpecies;
+import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.rule.AbstractRule;
import fr.ifremer.isisfish.simulator.PopulationMonitor;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.Doc;
+import java.util.List;
/**
- * Cette methode remplace aussi TailleMinSurvieRejet si propSurvie est > 0
+ * Cette regles tient compte de la taille minimum des poissons capturable.
*
+ * Les captures ne sont pas impactées, mais des rejets sont générés si la
+ * taille des poissons est inférieures à TailleMin.
+ *
+ * En cas de propSurvie positif, la matrice d'effectif est modifié
+ * pour tenir compte de la partie de poisson rejeté qui survi.
+ *
* Created: 30 novembre 2006
- *
- * @author anonymous <anonymous(a)labs.libre-entreprise.org>
+ *
+ * @author smahevas
* @version $Revision: 1.1 $
- *
- * Last update: $Date: 2007-01-24 18:25:34 $
- * by : $Author: bpoussin $
+ *
+ * Last update: $Date: 2007-01-24 18:25:34 $ by : $Author: bpoussin $
*/
public class TailleMin extends AbstractRule {
@@ -74,12 +76,14 @@
@Doc(value = "Proportion de survie")
public double param_propSurvie = 0;
-
- public String[] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+
+ protected boolean affectation = true;
+
+ protected String[] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -94,19 +98,20 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Tous les poissons dont la taille est inférieure à TailleMin" +
- " ne seront pas capturés. Ils sont placés en rejets et rejetés" +
- " suivant la proportion de survie.");
+ return "Tous les poissons dont la taille est inférieure à TailleMin"
+ + " ne seront pas capturés. Ils sont placés en rejets et rejetés"
+ + " suivant la proportion de survie.";
}
/**
- * Appelé au démarrage de la simulation, cette méthode permet d'initialiser
- * des valeurs
+ * Appele au demarrage de la simulation, cette methode permet
+ * d'initialiser des valeurs de la règle.
*
- * @param context La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour laquelle on utilise cette regle
*/
@Override
public void init(SimulationContext context) throws Exception {
+
}
/**
@@ -135,12 +140,12 @@
*
* @param context la simulation pour lequel on utilise cette regle
* @param step le pas de temps courant
- * @param metier le metier concerné
+ * @param metier le metier concerne
* @return vrai si on souhaite que les actions soit faites
*/
@Override
- public boolean condition(SimulationContext context, TimeStep step, Metier metier)
- throws Exception {
+ public boolean condition(SimulationContext context, TimeStep step,
+ Metier metier) throws Exception {
log.info("Recherche si la taille Minimale s'applique");
boolean result = true;
if (step.before(param_beginStep)) {
@@ -156,79 +161,92 @@
}
/**
- * Si la condition est vrai alors cette action est executee avant le pas
- * de temps de la simulation.
+ * Si la condition est vrai alors cette action est executee avant le pas de
+ * temps de la simulation.
*
* @param context la simulation pour lequel on utilise cette regle
* @param step le pas de temps courant
- * @param metier le metier concerné
+ * @param metier le metier concerne
*/
@Override
- public void preAction(SimulationContext context, TimeStep step, Metier metier)
- throws Exception {
- // nothing
+ public void preAction(SimulationContext context, TimeStep step,
+ Metier metier) throws Exception {
+
+ affectation = true; // pour que affectation soit vraie au debut de
+ // chaque pas de temps pour rentrer au moins une
+ // fois dans postaction
}
/**
- * Si la condition est vrai alors cette action est executée apres le pas
+ * Si la condition est vrai alors cette action est executee apres le pas
* de temps de la simulation.
*
* @param context La simulation pour lequel on utilise cette regle
* @param step le pas de temps courant
- * @param metier le metier concerné
+ * @param metier le metier concerne
*/
@Override
- public void postAction(SimulationContext context, TimeStep step, Metier metier)
- throws Exception {
- log.info("*$*$*$* TailleMin.actionApres:" + step + " metapop:" +
- param_species + " metier:" + metier);
+ public void postAction(SimulationContext context, TimeStep step,
+ Metier metier) throws Exception {
+ //log.info("*$*$*$* TailleMin.actionApres:" + step + " metapop:"
+ // + param_species + " metier:" + metier);
- if (isCaptureDate(step, param_species, metier)) {
- log.info(
- "*$*$*$* ok affecte capture infÃ?rieure Ã? TailleMin au rejet");
- // ATTENTION
- // les captures pour cette metapop ne sont plus du qu'au metier pour qui
- // l'espece est secondaire: elles sont affectees aux rejets
+ if (affectation) {
+ log.info("*$*$*$* ok affecte capture inferieure a TailleMin au rejet");
+ // ATTENTION
+ // les captures pour cette metapop ne sont plus du qu'au metier pour
+ // qui l'espece est secondaire: elles sont affectees aux rejets
- //pb : ne se fait pas par metier
- //il faut une matrice pour chaques pas de temps qui stocke les rejets
- //par metier, par metapop et par classes d'age (comme pour les captures)
- //////
- log.info("deb de affecterCaptureREJETTailleMin");
+ // pb : ne se fait pas par metier
+ // il faut une matrice pour chaques pas de temps qui stocke les
+ // rejets par metier, par metapop et par classes d'age (comme pour
+ // les captures)
+ //log.info("deb de affecterCaptureREJETTailleMin");
PopulationMonitor popMon = context.getPopulationMonitor();
- SiMatrix siMatrix = SiMatrix.getSiMatrix(context);
- List<Population> pops = siMatrix.getPopulations(step);
- for (Population pop : pops) {
- if (pop.getSpecies().equals(param_species)) {
- if (popMon.getDiscard(step, pop) == null) {
- MatrixND discard = popMon.getCatch(pop).copy();
- MatrixND eff = popMon.getN(pop);
+ int groupDim = 2;
+ int zoneDim = 3;
- for (MatrixIterator i = discard.iterator(); i.next();) {
- Object[] coordonnees = i.getSemanticsCoordinates();
- PopulationGroup group =
- (PopulationGroup) coordonnees[2];
- if (group.getLength() >= param_TailleMin) {
- i.setValue(0);
- } else if (param_propSurvie > 0) {
- eff.setValue(coordonnees[2], coordonnees[3],
- eff.getValue(coordonnees[2],
- coordonnees[3]) + i.getValue() *
- param_propSurvie);
- }
- }
- discard.setName(
- ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP);
- popMon.addDiscard(step, pop, discard);
+ for (Population pop : param_species.getPopulation()) {
+ MatrixND discard = popMon.getCatch(pop).copy();
+ discard.setName(ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP);
+
+ MatrixND eff = popMon.getN(pop);
+
+ // collect les tailles des groupes pour eviter de multiples appels a la methode
+ // getLength dans la boucle
+ List<PopulationGroup> groups = (List<PopulationGroup>)discard.getSemantic(2);
+ double[] length = new double[groups.size()];
+ int cpt = 0;
+ for (PopulationGroup group : groups) {
+ length[cpt++] = group.getLength();
+ }
+
+ // on iter que sur les valeurs != 0, car si deja zero, ca ne
+ // sert a rien de le mettre a 0
+ for (MatrixIterator i = discard.iteratorNotZero(); i.next();) {
+ int[] pos = i.getCoordinates();
+ int groupIndex = pos[groupDim];
+ if (length[groupIndex] >= param_TailleMin) {
+ i.setValue(0);
+ } else if (param_propSurvie > 0) {
+ Object[] coordonnees = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) coordonnees[groupDim];
+ Zone zone = (Zone)coordonnees[zoneDim];
+ eff.setValue(group, zone,
+ eff.getValue(group, zone)
+ + i.getValue() * param_propSurvie);
}
}
+ popMon.addDiscard(step, pop, discard);
}
- log.info("fin de affecterCaptureRejetTailleMin");
+ //log.info("fin de affecterCaptureRejetTailleMin");
- //on a affecte une fois cette meta pop au rejet il ne faut pas le refaire
+ // on a affecte une fois cette meta pop au rejet il ne faut pas le
+ // refaire pour ce pas de temps
+ affectation = false;
}
}
}
Modified: trunk/src/test/resources/test-database/rules/TotalClosure.java
===================================================================
--- trunk/src/test/resources/test-database/rules/TotalClosure.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/rules/TotalClosure.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import java.util.List;
import org.apache.commons.logging.Log;
@@ -57,8 +55,8 @@
public Month param_beginMonth = Month.JANUARY;
public Month param_endMonth = Month.JANUARY;
- public String[] necessaryResult = {
- ResultName.MATRIX_NO_ACTIVITY
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_NO_ACTIVITY
};
@Override
@@ -68,7 +66,7 @@
@Override
public String getDescription() throws Exception {
- return _("Total closure of the fishery");
+ return "Total closure of the fishery";
}
/**
@@ -77,6 +75,7 @@
*/
@Override
public void init(SimulationContext context) throws Exception {
+
}
/**
Modified: trunk/src/test/resources/test-database/scripts/GravityModel.java
===================================================================
--- trunk/src/test/resources/test-database/scripts/GravityModel.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/scripts/GravityModel.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
+ * Copyright (C) 2006 - 2014 Ifremer, Code Lutin, Cédric 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
@@ -22,7 +22,7 @@
package scripts;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.n;
import java.util.Collection;
import java.util.List;
@@ -47,22 +47,22 @@
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.types.Month;
import fr.ifremer.isisfish.types.TimeUnit;
+import org.nuiton.math.matrix.MatrixIterator;
/**
- * GravityModel.java
- *
- * Created: 4 sept. 06 15:49:08
- *
+ * Gravity model calcul des resultats à basés sur des resultats provenant
+ * de SiMatrix ou des resultat précédement calculé disponible via le
+ * result manager.
+ *
+ * Cette classe sert a calculer des résultats economique (prix, resultat
+ * servant a optimiser des cout pour les pécheurs...).
+ *
* @author poussin
- * @version $Revision: 1.9 $
- *
- * Last update: $Date: 2007-03-01 17:16:12 $
- * by : $Author: bpoussin $
*/
public class GravityModel {
/** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(GravityModel.class);
+ final static private Log log = LogFactory.getLog(GravityModel.class);
protected SimulationContext context = null;
protected TopiaContext db = null;
@@ -112,7 +112,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_FISHING_TIME_PER_MONTH_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -157,7 +157,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_FUEL_COSTS_OF_TRAVEL_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -209,7 +209,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_COSTS_OF_FISHING_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -263,7 +263,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_FUEL_COSTS_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -307,15 +307,29 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_REPAIR_AND_MAINTENANCE_GEAR_COSTS_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
+ SetOfVessels sov = str.getSetOfVessels();
metiers = siMatrix.getMetiers(str, step);
for (int m = 0; m < metiers.size(); m++) {
Metier metier = metiers.get(m);
- double value = repairAndMaintenanceGearCostsPerVessel(str,
- metier, step);
+
+ double fishingTime = 0;
+ double repair = 0;
+
+ EffortDescription effort = sov.getPossibleMetiers(metier);
+ if (effort != null) {
+ repair = effort.getRepairAndMaintenanceGearCost();
+ }
+ 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;
+
result.setValue(str, metier, value);
}
}
@@ -341,21 +355,21 @@
* @param step
* @return
*/
- private double repairAndMaintenanceGearCostsPerVessel(Strategy str,
- Metier metier, TimeStep step) {
- double fishingTime = fishingTimePerMonthPerVessel(str, metier, step);
+// private double repairAndMaintenanceGearCostsPerVessel(Strategy str,
+// Metier metier, TimeStep step) {
+// double fishingTime = fishingTimePerMonthPerVessel(str, metier, step);
+//
+// EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+// metier);
+//
+// double repair = 0;
+// if (effort != null) {
+// repair = effort.getRepairAndMaintenanceGearCost();
+// }
+// // FIXME verifier qu'il faut bien retourner 0, si pas d'effort
+// return fishingTime * repair / TimeUnit.HOUR_PER_DAY;
+// }
- EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
- metier);
-
- double repair = 0;
- if (effort != null) {
- repair = effort.getRepairAndMaintenanceGearCost();
- }
- // FIXME verifier qu'il faut bien retourner 0, si pas d'effort
- return fishingTime * repair / TimeUnit.HOUR_PER_DAY;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixOtherRunningCostsPerVessel
//////////////////////////////////////////////////////////////////////
@@ -368,7 +382,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_OTHER_RUNNING_COSTS_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -421,7 +435,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_SHARED_NOT_FIXED_COSTS_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -470,61 +484,117 @@
.create(
ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET,
new List[] { strategies, metiers, pops },
- new String[] { n_("Strategies"), n_("Metiers"),
- n_("Populations") });
+ new String[] { n("Strategies"), n("Metiers"),
+ n("Populations") });
+ // indice dans les matrices catch et discards
+ int strDim = 0;
+ int metierDim = 1;
+ int groupDim = 2;
+ int zoneDim = 3;
+
for (int p = 0; p < pops.size(); p++) {
Population pop = pops.get(p);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = grossValueOfLandingsPerSpeciesPerStrategyMet(
- str, metier, pop, step);
- result.setValue(str, metier, pop, value);
+ List<PopulationGroup> groups = pop.getPopulationGroup();
+ double[] prices = new double[groups.size()];
+ int cpt=0;
+ for (PopulationGroup group : groups) {
+ prices[cpt++] = group.getPrice();
+ }
+
+ MatrixND matCatch = getResult_MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP(step, pop);
+ MatrixND matDiscards = getResult_MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP(step, pop);
+
+ if (matCatch != null) {
+ for (MatrixIterator i=matCatch.iteratorNotZero(); i.next();){
+ int[] pos = i.getCoordinates();
+ double price = prices[pos[groupDim]];
+ if (price != 0) {
+ double value = result.getValue(pos[strDim], pos[metierDim], p) + price * i.getValue();
+ result.setValue(pos[strDim], pos[metierDim], p, value);
+ }
}
}
+ if (matDiscards != null) {
+ for (MatrixIterator i=matDiscards.iteratorNotZero(); i.next();){
+ int[] pos = i.getCoordinates();
+ double price = prices[pos[groupDim]];
+ if (price != 0) {
+ double value = result.getValue(pos[strDim], pos[metierDim], p) - price * i.getValue();
+ result.setValue(pos[strDim], pos[metierDim], p, value);
+ }
+ }
+ }
}
return result;
- }
- /**
- * implante suivant document ModifTable3PourBP25-07-2006.doc
- * GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month]=sum over
- * classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet
- * [str,met,pop,cl,month] ?DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
- * nth] GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month] =
- * sum over classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet
- * [str,met,pop,cl,month] -DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
- * nth])]
- *
- * @param str
- * @param metier
- * @param pop
- * @param step
- * @return
- */
- private double grossValueOfLandingsPerSpeciesPerStrategyMet(Strategy str,
- Metier metier, Population pop, TimeStep step) {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- double result = 0;
- for (PopulationGroup group : groups) {
- double price = group.getPrice();
- Collection<Zone> zones = pop.getPopulationZone();
- for (Zone zone : zones) {
- double catchWeight = getCatchWeightPerStrMetPerZonePop(str,
- metier, group, zone, step);
- double discardsWeight = getDiscardsWeightPerStrMet(str, metier,
- group, zone, step);
- // FIXME demander/verifier que ce le bon calcule
- result += price * (catchWeight - discardsWeight);
- }
- }
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+// List<Population> pops = siMatrix.getPopulations(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET,
+// new List[] { strategies, metiers, pops },
+// new String[] { n("Strategies"), n("Metiers"),
+// n("Populations") });
+//
+// for (int p = 0; p < pops.size(); p++) {
+// Population pop = pops.get(p);
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = grossValueOfLandingsPerSpeciesPerStrategyMet(
+// str, metier, pop, step);
+// result.setValue(str, metier, pop, value);
+// }
+// }
+// }
+//
+// return result;
}
+// /**
+// * implante suivant document ModifTable3PourBP25-07-2006.doc
+// * GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month]=sum over
+// * classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet
+// * [str,met,pop,cl,month] ?DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
+// * nth] GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month] =
+// * sum over classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet
+// * [str,met,pop,cl,month] -DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
+// * nth])]
+// *
+// * @param str
+// * @param metier
+// * @param pop
+// * @param step
+// * @return
+// */
+// private double grossValueOfLandingsPerSpeciesPerStrategyMet(Strategy str,
+// Metier metier, Population pop, TimeStep step) {
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// double result = 0;
+// for (PopulationGroup group : groups) {
+// double price = group.getPrice();
+// if (price != 0) {
+// Collection<Zone> zones = pop.getPopulationZone();
+// for (Zone zone : zones) {
+// double catchWeight = getCatchWeightPerStrMetPerZonePop(str,
+// metier, group, zone, step);
+// double discardsWeight = getDiscardsWeightPerStrMet(str, metier,
+// group, zone, step);
+// // FIXME demander/verifier que ce le bon calcule
+// result += price * (catchWeight - discardsWeight);
+// }
+// }
+// }
+// return result;
+// }
+
/**
* @param str
* @param metier
@@ -535,8 +605,7 @@
*/
private double getCatchWeightPerStrMetPerZonePop(Strategy str,
Metier metier, PopulationGroup group, Zone zone, TimeStep step) {
- MatrixND mat = resultManager.getMatrix(step, group.getPopulation(),
- ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ MatrixND mat = getResult_MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP(step, group.getPopulation());
double result = 0;
if (mat != null) {
result = mat.getValue(str, metier, group, zone);
@@ -544,6 +613,12 @@
return result;
}
+ private MatrixND getResult_MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP(TimeStep step, Population pop) {
+ MatrixND mat = resultManager.getMatrix(step, pop,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ return mat;
+ }
+
/**
* @param str
* @param metier
@@ -554,8 +629,7 @@
*/
private double getDiscardsWeightPerStrMet(Strategy str, Metier metier,
PopulationGroup group, Zone zone, TimeStep step) {
- MatrixND mat = resultManager.getMatrix(step, group.getPopulation(),
- ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
+ MatrixND mat = getResult_MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP(step, group.getPopulation());
double result = 0;
if (mat != null) {
result = mat.getValue(str, metier, group, zone);
@@ -563,81 +637,117 @@
return result;
}
+ private MatrixND getResult_MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP(TimeStep step, Population pop) {
+ MatrixND mat = resultManager.getMatrix(step, pop,
+ ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
+ return mat;
+ }
+
//////////////////////////////////////////////////////////////////////
// matrixGrossValueOfLandingsPerStrategyMet
//////////////////////////////////////////////////////////////////////
public MatrixND matrixGrossValueOfLandingsPerStrategyMet(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
-
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = grossValueOfLandingsPerStrategyMet(str, metier,
- step);
- result.setValue(str, metier, value);
- }
- }
-
+ MatrixND matPerSpecies = matrixGrossValueOfLandingsPerSpeciesPerStrategyMet(step);
+ // sum over pop
+ MatrixND result = matPerSpecies.sumOverDim(2).reduceDims(2);
+ result.setName(ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET);
return result;
- }
- /**
- * @param str
- * @param metier
- * @param step
- * @return
- * @throws TopiaException
- */
- private double grossValueOfLandingsPerStrategyMet(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- List<Population> pops = siMatrix.getPopulations(step);
- double result = 0;
- for (int i = 0; i < pops.size(); i++) {
- Population pop = (Population) pops.get(i);
- result += grossValueOfLandingsPerSpeciesPerStrategyMet(str, metier,
- pop, step);
- }
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = grossValueOfLandingsPerStrategyMet(str, metier,
+// step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
+// /**
+// * @param str
+// * @param metier
+// * @param step
+// * @return
+// * @throws TopiaException
+// */
+// private double grossValueOfLandingsPerStrategyMet(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// List<Population> pops = siMatrix.getPopulations(step);
+// double result = 0;
+// for (int i = 0; i < pops.size(); i++) {
+// Population pop = (Population) pops.get(i);
+// result += grossValueOfLandingsPerSpeciesPerStrategyMet(str, metier,
+// pop, step);
+// }
+// return result;
+// }
+
//////////////////////////////////////////////////////////////////////
// matrixGrossValueOfLandingsPerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixGrossValueOfLandingsPerStrategyMetPerVessel(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
+ MatrixND matGrossValue = matrixGrossValueOfLandingsPerStrategyMet(step);
+ MatrixND result = matGrossValue.copy();
+ result.setName(ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ for (MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = grossValueOfLandingsPerStrategyMetPerVessel(str,
- metier, step);
- result.setValue(str, metier, value);
- }
+ // FIXME verifier que c bien cette donn�e qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
+ double proportionSetOfVessels = str.getProportionSetOfVessels();
+ double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+
+ double grossValueOfLandingsOtherSpeciesPerStrategyMet =
+ grossValueOfLandingsOtherSpeciesPerStrategyMet(str, metier, step);
+
+ double value = (i.getValue() + grossValueOfLandingsOtherSpeciesPerStrategyMet)
+ / (proportionSetOfVessels * numberOfVessels);
+
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = grossValueOfLandingsPerStrategyMetPerVessel(str,
+// metier, step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -651,47 +761,74 @@
* @return
* @throws TopiaException
*/
- private double grossValueOfLandingsPerStrategyMetPerVessel(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- double grossValueOfLandingsPerStrategyMet = grossValueOfLandingsPerStrategyMet(
- str, metier, step);
- // FIXME verifier que c bien cette donn�e qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
- double proportionSetOfVessels = str.getProportionSetOfVessels();
- double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+// private double grossValueOfLandingsPerStrategyMetPerVessel(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// double grossValueOfLandingsPerStrategyMet = grossValueOfLandingsPerStrategyMet(
+// str, metier, step);
+// // FIXME verifier que c bien cette donn�e qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
+// double proportionSetOfVessels = str.getProportionSetOfVessels();
+// double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+//
+// double grossValueOfLandingsOtherSpeciesPerStrategyMet = grossValueOfLandingsOtherSpeciesPerStrategyMet(
+// str, metier, step);
+//
+// return (grossValueOfLandingsPerStrategyMet + grossValueOfLandingsOtherSpeciesPerStrategyMet)
+// / (proportionSetOfVessels * numberOfVessels);
+// }
- double grossValueOfLandingsOtherSpeciesPerStrategyMet = grossValueOfLandingsOtherSpeciesPerStrategyMet(
- str, metier, step);
-
- return (grossValueOfLandingsPerStrategyMet + grossValueOfLandingsOtherSpeciesPerStrategyMet)
- / (proportionSetOfVessels * numberOfVessels);
- }
-
//////////////////////////////////////////////////////////////////////
// matrixNetValueOfLandingsPerStrategyMet
//////////////////////////////////////////////////////////////////////
public MatrixND matrixNetValueOfLandingsPerStrategyMet(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ MatrixND result = matrixGrossValueOfLandingsPerStrategyMet(step).copy();
+ result.setName(ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET);
+
+ for (MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = netValueOfLandingsPerStrategyMet(str, metier,
- step);
- result.setValue(str, metier, value);
+ EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+ metier);
+ double landingCost = 1;
+ // FIXME demander si le metier n'a pas d'effort s'il faut que landingCost soit bien a 1
+ if (effort != null) {
+ landingCost -= effort.getLandingCosts();
}
+
+ double grossValueOfLandingsOtherSpeciesPerStrategyMet =
+ grossValueOfLandingsOtherSpeciesPerStrategyMet(str, metier, step);
+
+ double value = (i.getValue() + grossValueOfLandingsOtherSpeciesPerStrategyMet)
+ * landingCost;
+ i.setValue(value);
}
+ return result;
- return result;
+
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = netValueOfLandingsPerStrategyMet(str, metier,
+// step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -699,33 +836,33 @@
* NetValueOfLandingsPerStrategyMet[str,met,month] =
* GrossValueOfLandingsPerStrategyMet[str,met,month]
* (1-LandingCostRate[str,met])
- *
+ *
* @param str
* @param metier
* @param step
* @return
* @throws TopiaException
*/
- private double netValueOfLandingsPerStrategyMet(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- double grossValue = grossValueOfLandingsPerStrategyMet(str, metier,
- step);
- EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
- metier);
- double landingCost = 1;
- // FIXME demander si le metier n'a pas d'effort s'il faut que landingCost soit bien a 1
- if (effort != null) {
- landingCost -= effort.getLandingCosts();
- }
+// private double netValueOfLandingsPerStrategyMet(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// double grossValue = grossValueOfLandingsPerStrategyMet(str, metier,
+// step);
+// EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+// metier);
+// double landingCost = 1;
+// // FIXME demander si le metier n'a pas d'effort s'il faut que landingCost soit bien a 1
+// if (effort != null) {
+// landingCost -= effort.getLandingCosts();
+// }
+//
+// double grossValueOfLandingsOtherSpeciesPerStrategyMet =
+// grossValueOfLandingsOtherSpeciesPerStrategyMet(str, metier, step);
+//
+// double result = (grossValue + grossValueOfLandingsOtherSpeciesPerStrategyMet)
+// * landingCost;
+// return result;
+// }
- double grossValueOfLandingsOtherSpeciesPerStrategyMet = grossValueOfLandingsOtherSpeciesPerStrategyMet(
- str, metier, step);
-
- double result = (grossValue + grossValueOfLandingsOtherSpeciesPerStrategyMet)
- * landingCost;
- return result;
- }
-
private double grossValueOfLandingsOtherSpeciesPerStrategyMet(Strategy str,
Metier metier, TimeStep step) throws TopiaException {
// FIXME evaluer l'equation dans suivant le doc des equations
@@ -738,28 +875,51 @@
public MatrixND matrixNetValueOfLandingsPerStrategyMetPerVessel(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
+ MatrixND result = matrixNetValueOfLandingsPerStrategyMet(step).copy();
+ result.setName(ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ for(MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = netValueOfLandingsPerStrategyMetPerVessel(str,
- metier, step);
- result.setValue(str, metier, value);
+ // FIXME verifier que c bien cette donnée qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
+ double proportionSetOfVessels = str.getProportionSetOfVessels();
+ double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+
+ double div = proportionSetOfVessels * numberOfVessels;
+
+ if (div != 0) {
+ double value = i.getValue() / div;
+
+ i.setValue(value);
}
}
return result;
+
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = netValueOfLandingsPerStrategyMetPerVessel(str,
+// metier, step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -774,46 +934,65 @@
* @return
* @throws TopiaException
*/
- private double netValueOfLandingsPerStrategyMetPerVessel(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- double netValueOfLandingsPerStrategyMet = netValueOfLandingsPerStrategyMet(
- str, metier, step);
- // FIXME verifier que c bien cette donnée qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
- double proportionSetOfVessels = str.getProportionSetOfVessels();
- double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+// private double netValueOfLandingsPerStrategyMetPerVessel(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// double netValueOfLandingsPerStrategyMet = netValueOfLandingsPerStrategyMet(
+// str, metier, step);
+// // FIXME verifier que c bien cette donnée qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
+// double proportionSetOfVessels = str.getProportionSetOfVessels();
+// double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+//
+// return netValueOfLandingsPerStrategyMet
+// / (proportionSetOfVessels * numberOfVessels);
+// }
- return netValueOfLandingsPerStrategyMet
- / (proportionSetOfVessels * numberOfVessels);
- }
-
//////////////////////////////////////////////////////////////////////
// matrixNetRenevueToSharePerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixNetRenevueToSharePerStrategyMetPerVessel(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ MatrixND result = matrixNetValueOfLandingsPerStrategyMetPerVessel(step).copy();
+ result.setName(ResultName.MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = netRenevueToSharePerStrategyMetPerVessel(str,
- metier, step);
- result.setValue(str, metier, value);
- }
+ for(MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
+
+ double sharedNotFixedCostsPerVessel = sharedNotFixedCostsPerVessel(str,
+ metier, step);
+ double propStr = str.getStrategyMonthInfo(step.getMonth())
+ .getProportionMetier(metier);
+
+ double value = i.getValue() - sharedNotFixedCostsPerVessel * propStr;
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = netRenevueToSharePerStrategyMetPerVessel(str,
+// metier, step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -829,46 +1008,68 @@
* @return
* @throws TopiaException
*/
- private double netRenevueToSharePerStrategyMetPerVessel(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- double netRenevueToSharePerStrategyMetPerVessel = netValueOfLandingsPerStrategyMetPerVessel(
- str, metier, step);
- double sharedNotFixedCostsPerVessel = sharedNotFixedCostsPerVessel(str,
- metier, step);
- double propStr = str.getStrategyMonthInfo(step.getMonth())
- .getProportionMetier(metier);
+// private double netRenevueToSharePerStrategyMetPerVessel(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// double netRenevueToSharePerStrategyMetPerVessel = netValueOfLandingsPerStrategyMetPerVessel(
+// str, metier, step);
+// double sharedNotFixedCostsPerVessel = sharedNotFixedCostsPerVessel(str,
+// metier, step);
+// double propStr = str.getStrategyMonthInfo(step.getMonth())
+// .getProportionMetier(metier);
+//
+// double result = netRenevueToSharePerStrategyMetPerVessel
+// - sharedNotFixedCostsPerVessel * propStr;
+// return result;
+// }
- double result = netRenevueToSharePerStrategyMetPerVessel
- - sharedNotFixedCostsPerVessel * propStr;
- return result;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixCrewSharePerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixCrewSharePerStrategyMetPerVessel(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ MatrixND result = matrixNetValueOfLandingsPerStrategyMetPerVessel(step).copy();
+ result.setName(ResultName.MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = crewSharePerStrategyMetPerVessel(str, metier,
- step);
- result.setValue(str, metier, value);
+ for(MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
+
+ EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+ metier);
+
+ double crewShareRate = 0;
+ if (effort != null) {
+ crewShareRate = effort.getCrewShareRate();
}
+ // FIXME verifier qu'il faut bien retourner 0, si pas d'effort
+ double value = i.getValue() * crewShareRate;
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = crewSharePerStrategyMetPerVessel(str, metier,
+// step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -882,50 +1083,79 @@
* @return
* @throws TopiaException
*/
- private double crewSharePerStrategyMetPerVessel(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
- str, metier, step);
+// private double crewSharePerStrategyMetPerVessel(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
+// str, metier, step);
+//
+// EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+// metier);
+//
+// double crewShareRate = 0;
+// if (effort != null) {
+// crewShareRate = effort.getCrewShareRate();
+// }
+// // FIXME verifier qu'il faut bien retourner 0, si pas d'effort
+// return netRenevueToShare * crewShareRate;
+// }
- EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
- metier);
-
- double crewShareRate = 0;
- if (effort != null) {
- crewShareRate = effort.getCrewShareRate();
- }
- // FIXME verifier qu'il faut bien retourner 0, si pas d'effort
- return netRenevueToShare * crewShareRate;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel(
TimeStep step) throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ MatrixND matRepair = matrixRepairAndMaintenanceGearCostsPerVessel(step);
+ MatrixND matCrew = matrixCrewSharePerStrategyMetPerVessel(step);
+ MatrixND matRevenue = matrixNetRenevueToSharePerStrategyMetPerVessel(step);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = ownerMarginOverVariableCostsPerStrategyMetPerVessel(
- str, metier, step);
- result.setValue(str, metier, value);
+ MatrixND result = matRevenue.copy();
+ result.setName(ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL);
+
+ for(MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
+
+ double propStr = str.getStrategyMonthInfo(step.getMonth())
+ .getProportionMetier(metier);
+
+ double netRenevueToShare = i.getValue();
+ double crewShare = matCrew.getValue(str, metier);
+ double repair = 0;
+ if (propStr != 0) {
+ repair = matRepair.getValue(str, metier);
}
+
+ double value = netRenevueToShare - crewShare - repair * propStr;
+ i.setValue(value);
}
return result;
+
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = ownerMarginOverVariableCostsPerStrategyMetPerVessel(
+// str, metier, step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -942,47 +1172,71 @@
* @return
* @throws TopiaException
*/
- private double ownerMarginOverVariableCostsPerStrategyMetPerVessel(
- Strategy str, Metier metier, TimeStep step) throws TopiaException {
- double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
- str, metier, step);
- double crewShare = crewSharePerStrategyMetPerVessel(str, metier, step);
- double repair = repairAndMaintenanceGearCostsPerVessel(str, metier,
- step);
- double propStr = str.getStrategyMonthInfo(step.getMonth())
- .getProportionMetier(metier);
+// private double ownerMarginOverVariableCostsPerStrategyMetPerVessel(
+// Strategy str, Metier metier, TimeStep step) throws TopiaException {
+// double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
+// str, metier, step);
+// double crewShare = crewSharePerStrategyMetPerVessel(str, metier, step);
+// double repair = repairAndMaintenanceGearCostsPerVessel(str, metier,
+// step);
+// double propStr = str.getStrategyMonthInfo(step.getMonth())
+// .getProportionMetier(metier);
+//
+// return netRenevueToShare - crewShare - repair * propStr;
+// }
- return netRenevueToShare - crewShare - repair * propStr;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel(
TimeStep step) throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ MatrixND matRepair = matrixRepairAndMaintenanceGearCostsPerVessel(step);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = vesselMarginOverVariableCostsPerStrategyMetPerVessel(
- str, metier, step);
- result.setValue(str, metier, value);
+ MatrixND result = matrixNetValueOfLandingsPerStrategyMetPerVessel(step).copy();
+ result.setName(ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL);
+
+ for(MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
+
+ double repair = 0;
+ double propStr = str.getStrategyMonthInfo(step.getMonth())
+ .getProportionMetier(metier);
+ if (propStr != 0) {
+ // optimisation repair ne sert pas si propStr == 0, donc on va pas le chercher
+ repair = matRepair.getValue(str, metier);
}
+
+ double value = i.getValue() - repair * propStr;
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = vesselMarginOverVariableCostsPerStrategyMetPerVessel(
+// str, metier, step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -998,41 +1252,67 @@
* @return
* @throws TopiaException
*/
- private double vesselMarginOverVariableCostsPerStrategyMetPerVessel(
- Strategy str, Metier metier, TimeStep step) throws TopiaException {
- double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
- str, metier, step);
- double repair = repairAndMaintenanceGearCostsPerVessel(str, metier,
- step);
- double propStr = str.getStrategyMonthInfo(step.getMonth())
- .getProportionMetier(metier);
+// private double vesselMarginOverVariableCostsPerStrategyMetPerVessel(
+// Strategy str, Metier metier, TimeStep step) throws TopiaException {
+// double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
+// str, metier, step);
+// double repair = repairAndMaintenanceGearCostsPerVessel(str, metier,
+// step);
+// double propStr = str.getStrategyMonthInfo(step.getMonth())
+// .getProportionMetier(metier);
+//
+// return netRenevueToShare - repair * propStr;
+// }
- return netRenevueToShare - repair * propStr;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixOwnerMarginOverVariableCostsPerStrategyPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixOwnerMarginOverVariableCostsPerStrategyPerVessel(
TimeStep step) throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
+ MatrixND matOwner = matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel(step);
MatrixND result = MatrixFactory
.getInstance()
.create(
ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
- new List[] { strategies },
- new String[] { n_("Strategies") });
+ new List[] { matOwner.getSemantic(0) },
+ new String[] { n("Strategies") });
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- double value = ownerMarginOverVariableCostsPerStrategyPerVessel(
- str, step);
- result.setValue(s, value);
+ for(MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+
+ SetOfVessels sov = str.getSetOfVessels();
+ Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+
+ double value = 0;
+
+ for (EffortDescription effort : efforts) {
+ Metier metier = effort.getPossibleMetiers();
+ value += matOwner.getValue(str, metier);
+ }
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
+// new List[] { strategies },
+// new String[] { n("Strategies") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// double value = ownerMarginOverVariableCostsPerStrategyPerVessel(
+// str, step);
+// result.setValue(s, value);
+// }
+//
+// return result;
}
/**
@@ -1046,43 +1326,58 @@
* @return
* @throws TopiaException
*/
- private double ownerMarginOverVariableCostsPerStrategyPerVessel(
- Strategy str, TimeStep step) throws TopiaException {
- SetOfVessels sov = str.getSetOfVessels();
- Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+// private double ownerMarginOverVariableCostsPerStrategyPerVessel(
+// Strategy str, TimeStep step) throws TopiaException {
+// SetOfVessels sov = str.getSetOfVessels();
+// Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+//
+// float result = 0;
+//
+// for (EffortDescription effort : efforts) {
+// Metier metier = effort.getPossibleMetiers();
+// result += ownerMarginOverVariableCostsPerStrategyMetPerVessel(str,
+// metier, step);
+// }
+// return result;
+// }
- float result = 0;
-
- for (EffortDescription effort : efforts) {
- Metier metier = effort.getPossibleMetiers();
- result += ownerMarginOverVariableCostsPerStrategyMetPerVessel(str,
- metier, step);
- }
- return result;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixOwnerMarginOverVariableCostsPerStrategy
//////////////////////////////////////////////////////////////////////
public MatrixND matrixOwnerMarginOverVariableCostsPerStrategy(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
+ MatrixND result = matrixOwnerMarginOverVariableCostsPerStrategyPerVessel(step).copy();
+ result.setName(ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
- new List[] { strategies },
- new String[] { n_("Strategies") });
+ for(MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- double value = ownerMarginOverVariableCostsPerStrategy(str, step);
- result.setValue(s, value);
+ double proportionSetOfVessels = str.getProportionSetOfVessels();
+ double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+
+ double value = i.getValue() * (proportionSetOfVessels * numberOfVessels);
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
+// new List[] { strategies },
+// new String[] { n("Strategies") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// double value = ownerMarginOverVariableCostsPerStrategy(str, step);
+// result.setValue(s, value);
+// }
+//
+// return result;
}
/**
@@ -1096,40 +1391,69 @@
* @return
* @throws TopiaException
*/
- private double ownerMarginOverVariableCostsPerStrategy(Strategy str,
- TimeStep step) throws TopiaException {
- double ownerMarginOverVariableCostsPerStrategyPerVessel = ownerMarginOverVariableCostsPerStrategyPerVessel(
- str, step);
- double proportionSetOfVessels = str.getProportionSetOfVessels();
- double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+// private double ownerMarginOverVariableCostsPerStrategy(Strategy str,
+// TimeStep step) throws TopiaException {
+// double ownerMarginOverVariableCostsPerStrategyPerVessel = ownerMarginOverVariableCostsPerStrategyPerVessel(
+// str, step);
+// double proportionSetOfVessels = str.getProportionSetOfVessels();
+// double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+//
+// return ownerMarginOverVariableCostsPerStrategyPerVessel
+// * (proportionSetOfVessels * numberOfVessels);
+// }
- return ownerMarginOverVariableCostsPerStrategyPerVessel
- * (proportionSetOfVessels * numberOfVessels);
- }
-
//////////////////////////////////////////////////////////////////////
// matrixVesselMarginOverVariableCostsPerStrategyPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixVesselMarginOverVariableCostsPerStrategyPerVessel(
TimeStep step) throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
+ MatrixND matPerMet =
+ matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel(step);
MatrixND result = MatrixFactory
.getInstance()
.create(
ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
- new List[] { strategies },
- new String[] { n_("Strategies") });
+ new List[] { matPerMet.getSemantic(0) },
+ new String[] { n("Strategies") });
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- double value = vesselMarginOverVariableCostsPerStrategyPerVessel(
- str, step);
- result.setValue(s, value);
+ for(MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+
+ SetOfVessels sov = str.getSetOfVessels();
+ Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+
+ double value = 0;
+
+ for (EffortDescription effort : efforts) {
+ Metier metier = effort.getPossibleMetiers();
+ value += matPerMet.getValue(str, metier);
+ }
+
+ i.setValue(value);
}
+ return result;
- return result;
+
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
+// new List[] { strategies },
+// new String[] { n("Strategies") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// double value = vesselMarginOverVariableCostsPerStrategyPerVessel(
+// str, step);
+// result.setValue(s, value);
+// }
+//
+// return result;
}
/**
@@ -1143,43 +1467,59 @@
* @return
* @throws TopiaException
*/
- private double vesselMarginOverVariableCostsPerStrategyPerVessel(
- Strategy str, TimeStep step) throws TopiaException {
- SetOfVessels sov = str.getSetOfVessels();
- Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+// private double vesselMarginOverVariableCostsPerStrategyPerVessel(
+// Strategy str, TimeStep step) throws TopiaException {
+// SetOfVessels sov = str.getSetOfVessels();
+// Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+//
+// float result = 0;
+//
+// for (EffortDescription effort : efforts) {
+// Metier metier = effort.getPossibleMetiers();
+// result += vesselMarginOverVariableCostsPerStrategyMetPerVessel(str,
+// metier, step);
+// }
+// return result;
+// }
- float result = 0;
-
- for (EffortDescription effort : efforts) {
- Metier metier = effort.getPossibleMetiers();
- result += vesselMarginOverVariableCostsPerStrategyMetPerVessel(str,
- metier, step);
- }
- return result;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixVesselMarginOverVariableCostsPerStrategy
//////////////////////////////////////////////////////////////////////
public MatrixND matrixVesselMarginOverVariableCostsPerStrategy(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
- new List[] { strategies },
- new String[] { n_("Strategies") });
+ MatrixND result = matrixVesselMarginOverVariableCostsPerStrategyPerVessel(step).copy();
+ result.setName(ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- double value = vesselMarginOverVariableCostsPerStrategy(str, step);
- result.setValue(s, value);
+ for(MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+
+ double proportionSetOfVessels = str.getProportionSetOfVessels();
+ double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+
+ double value = i.getValue() * (proportionSetOfVessels * numberOfVessels);
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
+// new List[] { strategies },
+// new String[] { n("Strategies") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// double value = vesselMarginOverVariableCostsPerStrategy(str, step);
+// result.setValue(s, value);
+// }
+//
+// return result;
}
/**
@@ -1193,17 +1533,17 @@
* @return
* @throws TopiaException
*/
- private double vesselMarginOverVariableCostsPerStrategy(Strategy str,
- TimeStep step) throws TopiaException {
- double vesselMarginOverVariableCostsPerStrategyPerVessel = vesselMarginOverVariableCostsPerStrategyPerVessel(
- str, step);
- double proportionSetOfVessels = str.getProportionSetOfVessels();
- double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+// private double vesselMarginOverVariableCostsPerStrategy(Strategy str,
+// TimeStep step) throws TopiaException {
+// double vesselMarginOverVariableCostsPerStrategyPerVessel = vesselMarginOverVariableCostsPerStrategyPerVessel(
+// str, step);
+// double proportionSetOfVessels = str.getProportionSetOfVessels();
+// double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+//
+// return vesselMarginOverVariableCostsPerStrategyPerVessel
+// * (proportionSetOfVessels * numberOfVessels);
+// }
- return vesselMarginOverVariableCostsPerStrategyPerVessel
- * (proportionSetOfVessels * numberOfVessels);
- }
-
///////////////////////////////////////////////////////////////////////////
//
// Methode non utilisee directement dans GravityModel, mais dans les rules
@@ -1216,28 +1556,27 @@
double result = 0;
- for (Population pop : pops) {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- Collection<Zone> zones = pop.getPopulationZone();
- for (PopulationGroup group : groups) {
- double price = group.getPrice();
- for (Zone zone : zones) {
- double catchValue = getCatchWeightPerStrMetPerZonePop(str,
- metier, group, zone, step);
- double discards = getDiscardsWeightPerStrMet(str, metier,
- group, zone, step);
- result += price * (catchValue - discards);
+ double effort = getEffortPerStrategyMet(str, metier, step);
+ if (effort != 0) {
+ for (Population pop : pops) {
+ List<PopulationGroup> groups = pop.getPopulationGroup();
+ for (PopulationGroup group : groups) {
+ double price = group.getPrice();
+ if (price != 0) {
+ Collection<Zone> zones = pop.getPopulationZone();
+ for (Zone zone : zones) {
+ double catchValue = getCatchWeightPerStrMetPerZonePop(str,
+ metier, group, zone, step);
+ double discards = getDiscardsWeightPerStrMet(str, metier,
+ group, zone, step);
+ result += price * (catchValue - discards);
+ }
+ }
}
}
+ result = result / effort;
}
- double effort = getEffortPerStrategyMet(str, metier, step);
-
- if (effort == 0) {
- result = 0;
- } else {
- result = result / effort;
- }
// FIXME verifier qu'il faut bien retourner 0, si pas d'effort
return result;
}
Added: trunk/src/test/resources/test-database/scripts/MinimisationUtil.java
===================================================================
--- trunk/src/test/resources/test-database/scripts/MinimisationUtil.java (rev 0)
+++ trunk/src/test/resources/test-database/scripts/MinimisationUtil.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -0,0 +1,176 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2012, 2014 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 3 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-3.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(MinimisationUtil.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/src/test/resources/test-database/scripts/MinimisationUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/test/resources/test-database/scripts/ObjectiveFunction.java
===================================================================
--- trunk/src/test/resources/test-database/scripts/ObjectiveFunction.java (rev 0)
+++ trunk/src/test/resources/test-database/scripts/ObjectiveFunction.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -0,0 +1,44 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2012, 2014 Ifremer, CodeLutin, 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 3 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-3.0.html>.
+ * #L%
+ */
+
+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/src/test/resources/test-database/scripts/ObjectiveFunction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/test/resources/test-database/scripts/ObjectiveFunctionBaranov.java
===================================================================
--- trunk/src/test/resources/test-database/scripts/ObjectiveFunctionBaranov.java (rev 0)
+++ trunk/src/test/resources/test-database/scripts/ObjectiveFunctionBaranov.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -0,0 +1,53 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2012, 2014 Ifremer, CodeLutin, 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 3 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-3.0.html>.
+ * #L%
+ */
+
+package scripts;
+
+import fr.ifremer.isisfish.util.Nocache;
+
+/**
+ * FonctionObjectif_Baranov.java
+ *
+ * Created: 10 aout 2012
+ *
+ * @author lgasche <user.name(a)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/src/test/resources/test-database/scripts/ObjectiveFunctionBaranov.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/test/resources/test-database/scripts/ResultName.java
===================================================================
--- trunk/src/test/resources/test-database/scripts/ResultName.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/scripts/ResultName.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin
+ * Copyright (C) 2006 - 2014 Ifremer, Code Lutin, Cedric Pineau, 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
@@ -22,7 +22,7 @@
package scripts;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.n;
import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
@@ -51,7 +51,7 @@
* Dimension 4 : Zone
*/
@Doc(value = "do the doc of Result matrixDiscardsWeightPerStrMet")
- static final public String MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP = n_("matrixDiscardsWeightPerStrMetPerZonePop");
+ static final public String MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP = n("matrixDiscardsWeightPerStrMetPerZonePop");
/**
* Matrix with five dimensions
@@ -62,7 +62,7 @@
* Dimension 5 : Zone
*/
@Doc(value = "do the doc of Result matrixDiscardsPerStrMet")
- static final public String MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP = n_("matrixDiscardsPerStrMetPerZonePop");
+ static final public String MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP = n("matrixDiscardsPerStrMetPerZonePop");
/**
* Matrix with five dimensions
@@ -73,7 +73,7 @@
* Dimension 5 : Zone
*/
@Doc(value = "do the doc of Result matrixLandingPerMet")
- static final public String MATRIX_LANDING_PER_MET = n_("matrixLandingPerMet");
+ static final public String MATRIX_LANDING_PER_MET = n("matrixLandingPerMet");
/**
* Matrix with three dimensions
@@ -82,7 +82,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixEffortPerStrategyMet")
- static final public String MATRIX_EFFORT_PER_STRATEGY_MET = n_("matrixEffortPerStrategyMet");
+ static final public String MATRIX_EFFORT_PER_STRATEGY_MET = n("matrixEffortPerStrategyMet");
/**
* Matrix with three dimensions
@@ -91,7 +91,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixEffortNominalPerStrategyMet")
- static final public String MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET = n_("matrixEffortNominalPerStrategyMet");
+ static final public String MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET = n("matrixEffortNominalPerStrategyMet");
/**
* Matrix with five dimensions
@@ -102,7 +102,7 @@
* Dimension 5 : Zone
*/
@Doc(value = "Disponible uniquement avec les simulations par Zone. do the doc of Result matrixCatchRatePerStrategyMet")
- static final public String MATRIX_CATCH_RATE_PER_STRATEGY_MET_PER_ZONE_POP = n_("matrixCatchRatePerStrategyMet");
+ static final public String MATRIX_CATCH_RATE_PER_STRATEGY_MET_PER_ZONE_POP = n("matrixCatchRatePerStrategyMet");
/**
* Matrix with five dimensions
@@ -111,9 +111,12 @@
* Dimension 3 : Metier
* Dimension 4 : Group
* Dimension 5 : Zone
+ *
+ * N'est calculé que si l'effort est calculé par cellule et non par zone.
+ * @see simulators.SimulatorEffortByCell
*/
@Doc(value = "do the doc of Result matrixCatchPerStrategyMetPerZoneMet")
- static final public String MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_MET = n_("matrixCatchPerStrategyMetPerZoneMet");
+ static final public String MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_MET = n("matrixCatchPerStrategyMetPerZoneMet");
/**
* Matrix with five dimensions
@@ -124,7 +127,7 @@
* Dimension 5 : Zone
*/
@Doc(value = "do the doc of Result matrixCatchPerStrategyMetPerZonePop")
- static final public String MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP = n_("matrixCatchPerStrategyMetPerZonePop");
+ static final public String MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP = n("matrixCatchPerStrategyMetPerZonePop");
/**
* Matrix with five dimensions
@@ -133,9 +136,12 @@
* Dimension 3 : Metier
* Dimension 4 : Group
* Dimension 5 : Zone
+ *
+ * N'est calculé que si l'effort est calculé par cellule et non par zone.
+ * @see simulators.SimulatorEffortByCell
*/
@Doc(value = "do the doc of Result matrixCatchWeightPerStrategyMetPerZoneMet")
- static final public String MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_MET = n_("matrixCatchWeightPerStrategyMetPerZoneMet");
+ static final public String MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_MET = n("matrixCatchWeightPerStrategyMetPerZoneMet");
/**
* Matrix with five dimensions
@@ -146,7 +152,7 @@
* Dimension 5 : Zone
*/
@Doc(value = "do the doc of Result matrixCatchWeightPerStrategyMetPerZonePop")
- static final public String MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP = n_("matrixCatchWeightPerStrategyMetPerZonePop");
+ static final public String MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP = n("matrixCatchWeightPerStrategyMetPerZonePop");
/**
* Matrix with five dimensions
@@ -157,8 +163,23 @@
* Dimension 5 : Zone
*/
@Doc(value = "Disponible uniquement avec les simulations par Zone. do the doc of Result matrixFishingMortality")
- static final public String MATRIX_FISHING_MORTALITY = n_("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
@@ -166,7 +187,7 @@
* Dimension 3 : Zone (semantics : Dimension 2)
*/
@Doc(value = "do the doc of Result matrixAbundance")
- static final public String MATRIX_ABUNDANCE = n_("matrixAbundance");
+ static final public String MATRIX_ABUNDANCE = n("matrixAbundance");
/**
* Matrix with three dimensions
@@ -175,7 +196,7 @@
* Dimension 3 : Zone
*/
@Doc(value = "do the doc of Result matrixAbundanceBeginMonth")
- static final public String MATRIX_ABUNDANCE_BEGIN_MONTH = n_("matrixAbundanceBeginMonth");
+ static final public String MATRIX_ABUNDANCE_BEGIN_MONTH = n("matrixAbundanceBeginMonth");
/**
* Matrix with three dimensions
@@ -184,7 +205,7 @@
* Dimension 3 : Zone
*/
@Doc(value = "do the doc of Result matrixBiomass")
- static final public String MATRIX_BIOMASS = n_("matrixBiomass");
+ static final public String MATRIX_BIOMASS = n("matrixBiomass");
/**
* Matrix with three dimensions
@@ -193,7 +214,7 @@
* Dimension 3 : Zone
*/
@Doc(value = "do the doc of Result matrixBiomassBeginMonth")
- static final public String MATRIX_BIOMASS_BEGIN_MONTH = n_("matrixBiomassBeginMonth");
+ static final public String MATRIX_BIOMASS_BEGIN_MONTH = n("matrixBiomassBeginMonth");
/**
* Matrix with three dimensions
@@ -202,7 +223,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixFishingTimePerMonthPerVessel")
- static final public String MATRIX_FISHING_TIME_PER_MONTH_PER_VESSEL = n_("matrixFishingTimePerMonthPerVessel");
+ static final public String MATRIX_FISHING_TIME_PER_MONTH_PER_VESSEL = n("matrixFishingTimePerMonthPerVessel");
/**
* Matrix with three dimensions
@@ -211,7 +232,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixFuelCostsOfTravelPerVessel")
- static final public String MATRIX_FUEL_COSTS_OF_TRAVEL_PER_VESSEL = n_("matrixFuelCostsOfTravelPerVessel");
+ static final public String MATRIX_FUEL_COSTS_OF_TRAVEL_PER_VESSEL = n("matrixFuelCostsOfTravelPerVessel");
/**
* Matrix with three dimensions
@@ -220,7 +241,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixCostsOfFishingPerVessel")
- static final public String MATRIX_COSTS_OF_FISHING_PER_VESSEL = n_("matrixCostsOfFishingPerVessel");
+ static final public String MATRIX_COSTS_OF_FISHING_PER_VESSEL = n("matrixCostsOfFishingPerVessel");
/**
* Matrix with three dimensions
@@ -229,7 +250,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixFuelCostsPerVessel")
- static final public String MATRIX_FUEL_COSTS_PER_VESSEL = n_("matrixFuelCostsPerVessel");
+ static final public String MATRIX_FUEL_COSTS_PER_VESSEL = n("matrixFuelCostsPerVessel");
/**
* Matrix with three dimensions
@@ -238,7 +259,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixRepairAndMaintenanceGearCostsPerVessel")
- static final public String MATRIX_REPAIR_AND_MAINTENANCE_GEAR_COSTS_PER_VESSEL = n_("matrixRepairAndMaintenanceGearCostsPerVessel");
+ static final public String MATRIX_REPAIR_AND_MAINTENANCE_GEAR_COSTS_PER_VESSEL = n("matrixRepairAndMaintenanceGearCostsPerVessel");
/**
* Matrix with three dimensions
@@ -247,7 +268,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixOtherRunningCostsPerVessel")
- static final public String MATRIX_OTHER_RUNNING_COSTS_PER_VESSEL = n_("matrixOtherRunningCostsPerVessel");
+ static final public String MATRIX_OTHER_RUNNING_COSTS_PER_VESSEL = n("matrixOtherRunningCostsPerVessel");
/**
* Matrix with three dimensions
@@ -256,7 +277,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixSharedNotFixedCostsPerVessel")
- static final public String MATRIX_SHARED_NOT_FIXED_COSTS_PER_VESSEL = n_("matrixSharedNotFixedCostsPerVessel");
+ static final public String MATRIX_SHARED_NOT_FIXED_COSTS_PER_VESSEL = n("matrixSharedNotFixedCostsPerVessel");
/**
* Matrix with four dimensions
@@ -266,7 +287,7 @@
* Dimension 4 : Population
*/
@Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerSpeciesPerStrategyMet")
- static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET = n_("matrixGrossValueOfLandingsPerSpeciesPerStrategyMet");
+ static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET = n("matrixGrossValueOfLandingsPerSpeciesPerStrategyMet");
/**
* Matrix with three dimensions
@@ -275,7 +296,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerStrategyMet")
- static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET = n_("matrixGrossValueOfLandingsPerStrategyMet");
+ static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET = n("matrixGrossValueOfLandingsPerStrategyMet");
/**
* Matrix with three dimensions
@@ -286,7 +307,7 @@
* Matrix calculated in the non generic Rule : GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD
*/
@Doc(value = "do the doc of Result matrixGrossValueOfLandingsOtherSpeciesPerStrategyMet")
- static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_OTHER_SPECIES_PER_STRATEGY_MET = n_("matrixGrossValueOfLandingsOtherSpeciesPerStrategyMet");
+ static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_OTHER_SPECIES_PER_STRATEGY_MET = n("matrixGrossValueOfLandingsOtherSpeciesPerStrategyMet");
/**
* Matrix with three dimensions
@@ -295,7 +316,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerStrategyMetPerVessel")
- static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL = n_("matrixGrossValueOfLandingsPerStrategyMetPerVessel");
+ static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL = n("matrixGrossValueOfLandingsPerStrategyMetPerVessel");
/**
* Matrix with three dimensions
@@ -304,7 +325,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixNetValueOfLandingsPerStrategyMet")
- static final public String MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET = n_("matrixNetValueOfLandingsPerStrategyMet");
+ static final public String MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET = n("matrixNetValueOfLandingsPerStrategyMet");
/**
* Matrix with three dimensions
@@ -313,7 +334,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixNetValueOfLandingsPerStrategyMetPerVessel")
- static final public String MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL = n_("matrixNetValueOfLandingsPerStrategyMetPerVessel");
+ static final public String MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL = n("matrixNetValueOfLandingsPerStrategyMetPerVessel");
/**
* Matrix with three dimensions
@@ -322,7 +343,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixNetRenevueToSharePerStrategyMetPerVessel")
- static final public String MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL = n_("matrixNetRenevueToSharePerStrategyMetPerVessel");
+ static final public String MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL = n("matrixNetRenevueToSharePerStrategyMetPerVessel");
/**
* Matrix with three dimensions
@@ -331,7 +352,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixCrewSharePerStrategyPerVessel")
- static final public String MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL = n_("matrixCrewSharePerStrategyPerVessel");
+ static final public String MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL = n("matrixCrewSharePerStrategyPerVessel");
/**
* Matrix with three dimensions
@@ -340,7 +361,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel")
- static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL = n_("matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel");
+ static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL = n("matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel");
/**
* Matrix with three dimensions
@@ -349,7 +370,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel")
- static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL = n_("matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel");
+ static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL = n("matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel");
/**
* Matrix with three dimensions
@@ -358,7 +379,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixOwnerMarginOverVariableCostsPerStrategyPerVessel")
- static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL = n_("matrixOwnerMarginOverVariableCostsPerStrategyPerVessel");
+ static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL = n("matrixOwnerMarginOverVariableCostsPerStrategyPerVessel");
/**
* Matrix with two dimensions
@@ -366,7 +387,7 @@
* Dimension 2 : Strategy
*/
@Doc(value = "do the doc of Result matrixOwnerMarginOverVariableCostsPerStrategy")
- static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY = n_("matrixOwnerMarginOverVariableCostsPerStrategy");
+ static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY = n("matrixOwnerMarginOverVariableCostsPerStrategy");
/**
* Matrix with two dimensions
@@ -374,7 +395,7 @@
* Dimension 2 : Strategy
*/
@Doc(value = "do the doc of Result matrixVesselMarginOverVariableCostsPerStrategyPerVessel")
- static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL = n_("matrixVesselMarginOverVariableCostsPerStrategyPerVessel");
+ static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL = n("matrixVesselMarginOverVariableCostsPerStrategyPerVessel");
/**
* Matrix with two dimensions
@@ -382,7 +403,7 @@
* Dimension 2 : Strategy
*/
@Doc(value = "do the doc of Result matrixVesselMarginOverVariableCostsPerStrategy")
- static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY = n_("matrixVesselMarginOverVariableCostsPerStrategy");
+ static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY = n("matrixVesselMarginOverVariableCostsPerStrategy");
/**
* Matrix with three dimensions
@@ -391,7 +412,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixNoActivity")
- static final public String MATRIX_NO_ACTIVITY = n_("matrixNoActivity");
+ static final public String MATRIX_NO_ACTIVITY = n("matrixNoActivity");
/**
* Matrix with three dimensions
@@ -400,7 +421,7 @@
* Dimension 3 : Zone
*/
@Doc(value = "do the doc of Result matrixMetierZone")
- static final public String MATRIX_METIER_ZONE = n_("matrixMetierZone");
+ static final public String MATRIX_METIER_ZONE = n("matrixMetierZone");
/**
* Matrix with two dimensions
@@ -408,5 +429,5 @@
* Dimension 2 : Group
*/
@Doc(value = "do the doc of Result matrixPrice")
- static final public String MATRIX_PRICE = n_("matrixPrice");
+ static final public String MATRIX_PRICE = n("matrixPrice");
}
Modified: trunk/src/test/resources/test-database/scripts/RuleUtil.java
===================================================================
--- trunk/src/test/resources/test-database/scripts/RuleUtil.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/scripts/RuleUtil.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 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;
@@ -53,7 +52,7 @@
/**
* @param context le context de simulation
* @param species l'espece sur lequel on souhaite le total
- * @param date la date pour laquel on veut le calcul, cet argument est
+ * @param step le pas de temps pour lequel on veut le calcul, cet argument est
* passe seulement pour que le cache ne retourne pas toujours la meme valeur
* @return total catch in tons
*/
@@ -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/src/test/resources/test-database/scripts/SiMatrix.java
===================================================================
--- trunk/src/test/resources/test-database/scripts/SiMatrix.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/scripts/SiMatrix.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Benjamin Poussin
+ * Copyright (C) 2006 - 2014 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
@@ -22,10 +22,11 @@
package scripts;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.n;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -57,6 +58,8 @@
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 fr.ifremer.isisfish.util.Nocache;
/**
* SiMatrix.java
@@ -99,13 +102,9 @@
}
/**
- *
* @param context
- * Simulation context
- * @param db
- * TopiaContext with transaction opened. You must used this
- * TopiaContext and not used
- * SimulationContext.getSimulationStorage().getStorage()
+ * Simulation context transaction opened. You must used this
+ * TopiaContext and not used SimulationContext.getSimulationStorage().getStorage()
* @throws TopiaException
*/
public SiMatrix(SimulationContext context) throws TopiaException {
@@ -181,17 +180,19 @@
*/
public List<Metier> getMetiers(Strategy str, TimeStep step) {
StrategyMonthInfo info = str.getStrategyMonthInfo(step.getMonth());
- MatrixND props = info.getProportionMetier();
+ List<Metier> result = info.getMetierWithProportion();
- List<Metier> result = new ArrayList<Metier>();
-
- for (MatrixIterator i = props.iterator(); i.hasNext();) {
- i.next();
- if (i.getValue() != 0) {
- Metier metier = (Metier) i.getSemanticsCoordinates()[0];
- result.add(metier);
- }
- }
+// MatrixND props = info.getProportionMetier();
+//
+// List<Metier> result = new ArrayList<Metier>();
+//
+// for (MatrixIterator i = props.iterator(); i.hasNext();) {
+// i.next();
+// if (i.getValue() != 0) {
+// Metier metier = (Metier) i.getSemanticsCoordinates()[0];
+// result.add(metier);
+// }
+// }
return result;
}
@@ -211,7 +212,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_METIER_ZONE, new List[] { metiers, zones },
- new String[] { n_("Metiers"), n_("Zones") });
+ new String[] { n("Metiers"), n("Zones") });
for (Metier metier : metiers) {
Collection<Zone> zoneMetier = metier.getMetierSeasonInfo(
@@ -227,7 +228,7 @@
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_PRICE, new List[] { groups },
- new String[] { n_("PopulationGroup") });
+ new String[] { n("PopulationGroup") });
for (PopulationGroup group : groups) {
result.setValue(group, group.getPrice());
@@ -246,18 +247,23 @@
public MatrixND matrixCatchWeightPerStrategyMetPerZoneMet(TimeStep step,
Population pop, MatrixND matrixCatchPerStrategyMetPerZoneMet)
throws TopiaException, IsisFishException {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- MatrixND result = matrixCatchPerStrategyMetPerZoneMet.copy();
- result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_MET);
+ return matrixToWeightMatrix(step, 2,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_MET,
+ matrixCatchPerStrategyMetPerZoneMet);
- for (PopulationGroup group : groups) {
- MatrixND sub = result.getSubMatrix(2, group, 1);
- double meanWeight = group.getMeanWeight();
- sub.mults(meanWeight);
- }
-
- return result;
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+//
+// MatrixND result = matrixCatchPerStrategyMetPerZoneMet.copy();
+// result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_MET);
+//
+// for (PopulationGroup group : groups) {
+// MatrixND sub = result.getSubMatrix(2, group, 1);
+// double meanWeight = group.getMeanWeight();
+// sub.mults(meanWeight);
+// }
+//
+// return result;
}
public MatrixND matrixCatchPerStrategyMetPerZoneMet(MatrixND N,
@@ -282,8 +288,8 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_MET,
new List[] { strategies, metiers, groups, zones },
- new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
- n_("Zones") });
+ new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+ n("Zones") });
// matrice temporaire ou les zones pops sont sommees
MatrixND tmp = matrixCatchPerStrategyMetPerCell.sumOverDim(3);
@@ -293,8 +299,11 @@
Strategy str = strategies.get(s);
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
+ // 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);
MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(step
.getMonth());
Collection<Zone> zoneMet = infoMet.getZone();
@@ -339,18 +348,23 @@
public MatrixND matrixCatchWeightPerStrategyMetPerZonePop(TimeStep step,
Population pop, MatrixND matrixCatchPerStrategyMetPerZonePop)
throws TopiaException, IsisFishException {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- MatrixND result = matrixCatchPerStrategyMetPerZonePop.copy();
- result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ return matrixToWeightMatrix(step, 2,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP,
+ matrixCatchPerStrategyMetPerZonePop);
- for (PopulationGroup group : groups) {
- MatrixND sub = result.getSubMatrix(2, group, 1);
- double meanWeight = group.getMeanWeight();
- sub.mults(meanWeight);
- }
-
- return result;
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+//
+// MatrixND result = matrixCatchPerStrategyMetPerZonePop.copy();
+// result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+//
+// for (PopulationGroup group : groups) {
+// MatrixND sub = result.getSubMatrix(2, group, 1);
+// double meanWeight = group.getMeanWeight();
+// sub.mults(meanWeight);
+// }
+//
+// return result;
}
/**
@@ -369,23 +383,36 @@
public MatrixND matrixCatchPerStrategyMetPerZone(MatrixND N,
Population pop, TimeStep step, MatrixND matrixCatchRatePerStrategyMet)
throws TopiaException, IsisFishException {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- List<Zone> zones = pop.getPopulationZone();
- // on le passe en argument ce qui evite de le calculer 2 fois
- // MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, step);
+ int dimGroup = 2;
+ int dimZone = 3;
+
MatrixND result = matrixCatchRatePerStrategyMet.copy();
result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP);
- for (PopulationGroup group : groups) {
- MatrixND sub = result.getSubMatrix(2, group, 1);
- for (Zone zone : zones) {
- MatrixND subsub = sub.getSubMatrix(3, zone, 1);
- double val = N.getValue(group, zone);
- subsub.mults(val);
- }
+ for (MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] posSem = i.getSemanticsCoordinates();
+ double val = i.getValue();
+ double n = N.getValue(posSem[dimGroup], posSem[dimZone]);
+ i.setValue(val * n);
}
+
return result;
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// List<Zone> zones = pop.getPopulationZone();
+//
+// MatrixND result = matrixCatchRatePerStrategyMet.copy();
+// result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP);
+//
+// for (PopulationGroup group : groups) {
+// MatrixND sub = result.getSubMatrix(2, group, 1);
+// for (Zone zone : zones) {
+// MatrixND subsub = sub.getSubMatrix(3, zone, 1);
+// double val = N.getValue(group, zone);
+// subsub.mults(val);
+// }
+// }
+// return result;
}
/**
@@ -410,18 +437,20 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_CATCH_RATE_PER_STRATEGY_MET_PER_ZONE_POP,
new List[] { strategies, metiers, groups, zones },
- new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
- n_("Zones") });
+ new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+ n("Zones") });
+ Month month = step.getMonth();
// Optimisation Hilaire
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = getMetiers(str, step);
for (int m = 0; m < metiers.size(); m++) {
Metier metier = metiers.get(m);
+ MetierSeasonInfo msi = metier.getMetierSeasonInfo(month);
for (int z = 0; z < zones.size(); z++) {
Zone zone = zones.get(z);
- double effort = effortPerZonePop(str, metier, step, zone);
+ double effort = effortPerZonePop(str, metier, msi, step, zone);
if (effort > 0) {
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -443,14 +472,13 @@
* @param zone
* @return
*/
- private double effortPerZonePop(Strategy str, Metier metier, TimeStep step,
+ private double effortPerZonePop(Strategy str, Metier metier, MetierSeasonInfo infoMet, TimeStep step,
Zone zonePop) {
- Month month = step.getMonth();
- Collection<Zone> zoneMet = metier.getMetierSeasonInfo(month).getZone();
+ Collection<Zone> zoneMet = infoMet.getZone();
double inter = nbCellInter(zoneMet, zonePop);
double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier,
- step);
+ infoMet, step);
if (log.isDebugEnabled()) {
log.debug(" strategy=" + str + " metier=" + metier + " inter="
@@ -539,9 +567,86 @@
return result;
}
+// /**
+// * Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop ]
+// *
+// * @param pop
+// * @param step
+// * @return
+// * @throws TopiaException
+// * @throws IsisFishException
+// */
+// public MatrixND matrixFishingMortality(TimeStep step, Population pop)
+// throws TopiaException, IsisFishException {
+// List<Strategy> strategies = getStrategies(step);
+// List<Metier> metiers = getMetiers(step);
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// List<Zone> zones = pop.getPopulationZone();
+//
+// // default value in matrix is 0
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_FISHING_MORTALITY,
+// new List[] { strategies, metiers, groups, zones },
+// new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+// n("Zones") });
+//
+// Month month = step.getMonth();
+// PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
+//
+// for (int g = 0; g < groups.size(); g++) {
+// PopulationGroup group = groups.get(g);
+//
+// // getCapturability is check matrix validity and create matrix if needed and get one value in
+// double capturability = infoPop.getCapturability(group);
+// if (capturability != 0) { // check 0, this prevent next call, for default value
+//
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+//
+// MetierSeasonInfo infoMet = metier
+// .getMetierSeasonInfo(month);
+// // getTargetFactor seem to be simple
+// double ciblage = infoMet.getTargetFactor(group);
+//
+// if (ciblage != 0) { // check 0, this prevent next call, for default value
+//
+// Gear gear = metier.getGear();
+// Selectivity selectivity = gear
+// .getPopulationSelectivity(pop);
+// if (selectivity != null) {
+//
+// // getCoefficient is equation evaluation
+// double coeff = selectivity.getCoefficient(pop,
+// group, metier);
+// if (coeff != 0) { // check 0, this prevent next call, for default value
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// for (int z = 0; z < zones.size(); z++) {
+// Zone zone = zones.get(z);
+// double effort = effortPerZonePop(str,
+// metier, infoMet, step, zone);
+// if (effort > 0) { // put value only if <> 0
+// double value = coeff
+// * capturability * ciblage
+// * effort;
+// result.setValue(str, metier, group,
+// zone, value);
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// return result;
+// }
+
/**
* Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop ]
- *
+ *
* @param pop
* @param step
* @return
@@ -559,51 +664,63 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_FISHING_MORTALITY,
new List[] { strategies, metiers, groups, zones },
- new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
- n_("Zones") });
+ new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+ n("Zones") });
Month month = step.getMonth();
PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
+
+ for (Strategy str : strategies) {
+ StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
+ double nbTrip = smi.getNumberOfTrips();
+ double propSetOfVessels = str.getProportionSetOfVessels();
+ int nbOfVessels = str.getSetOfVessels().getNumberOfVessels();
- for (int g = 0; g < groups.size(); g++) {
- PopulationGroup group = groups.get(g);
+ // dans le calcul de l'effort si une de ces donnees est 0
+ // alors le result dans la matrice est 0
+ // donc autant ne pas faire tous les autres calculs couteux
+ if (nbTrip * propSetOfVessels * nbOfVessels != 0) {
+ for (PopulationGroup group : groups) {
- // getCapturability is check matrix validity and create matrix if needed and get one value in
- double capturability = infoPop.getCapturability(group);
- if (capturability != 0) { // check 0, this prevent next call, for default value
+ // getCapturability is check matrix validity and create matrix if needed and get one value in
+ double capturability = infoPop.getCapturability(group);
+ if (capturability != 0) { // check 0, this prevent next call, for default value
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
+ // et de la meme facon si la proportion est 0 alors
+ // le resultat dans la matrice sera 0, donc on boucle que
+ // sur ceux qui ont une proportion
+ for (Metier metier : getMetiers(str, step)) {
- MetierSeasonInfo infoMet = metier
- .getMetierSeasonInfo(month);
- // getTargetFactor seem to be simple
- double ciblage = infoMet.getTargetFactor(group);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
- if (ciblage != 0) { // check 0, this prevent next call, for default value
+ MetierSeasonInfo infoMet = metier
+ .getMetierSeasonInfo(month);
+ // getTargetFactor seem to be simple
+ double ciblage = infoMet.getTargetFactor(group);
- Gear gear = metier.getGear();
- Selectivity selectivity = gear
- .getPopulationSelectivity(pop);
- if (selectivity != null) {
+ if (ciblage != 0) { // check 0, this prevent next call, for default value
- // getCoefficient is equation evaluation
- double coeff = selectivity.getCoefficient(pop,
- group, metier);
- if (coeff != 0) { // check 0, this prevent next call, for default value
+ Gear gear = metier.getGear();
+ Selectivity selectivity = gear
+ .getPopulationSelectivity(pop);
+ if (selectivity != null) {
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- for (int z = 0; z < zones.size(); z++) {
- Zone zone = zones.get(z);
- double effort = effortPerZonePop(str,
- metier, step, zone);
- if (effort > 0) { // put value only if <> 0
- double value = coeff
- * capturability * ciblage
- * effort;
- result.setValue(str, metier, group,
- zone, value);
+ // getCoefficient is equation evaluation
+ double coeff = selectivity.getCoefficient(pop,
+ group, metier);
+ if (coeff != 0) { // check 0, this prevent next call, for default value
+
+ for (Zone zone : zones) {
+ double effort = effortPerZonePop(str,
+ metier, infoMet, step, zone);
+ if (effort > 0) { // put value only if <> 0
+ double value = coeff
+ * capturability * ciblage
+ * effort;
+ result.setValue(str, metier, group,
+ zone, value);
+ }
}
}
}
@@ -616,6 +733,7 @@
return result;
}
+
/**
* Matrice des captures en nombre dim [ Strategy x Metier x Classe x zonePop ]
*
@@ -631,23 +749,80 @@
Population pop, TimeStep step,
MatrixND matrixCatchRatePerStrategyMetPerCell)
throws TopiaException, IsisFishException {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- List<Zone> zones = pop.getPopulationZone();
+ int groupDim = 2;
+ int zoneDim = 3;
- // on le passe en argument ce qui evite de le calculer 2 fois
- // MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, step);
+ int NGroupDim = 0;
+ int NZoneDim = 1;
+
MatrixND result = matrixCatchRatePerStrategyMetPerCell.copy();
result.setName("matrixCatchPerStrategyMetPerCell");
- for (PopulationGroup group : groups) {
- MatrixND sub = result.getSubMatrix(2, group, 1);
- for (Zone zone : zones) {
- MatrixND subsub = sub.getSubMatrix(3, zone, 1);
- double val = N.getValue(group, zone) / (double) zone.sizeCell();
- subsub.mults(val);
+ List<PopulationGroup> groups = (List<PopulationGroup>)result.getSemantic(groupDim);
+ List<Zone> zones = (List<Zone>)result.getSemantic(zoneDim);
+
+ double[] sizeCell = new double[zones.size()];
+ int cpt = 0;
+ for (Zone z : zones) {
+ sizeCell[cpt++] = z.sizeCell();
+ }
+
+ // on suppose que les semantics de N et matrixCatchRatePerStrategyMetPerCell
+ // pour les PopulationGroup et Zone sont les memes
+ // mais on verifie tout de meme
+ if (groups.equals(N.getSemantic(NGroupDim)) &&
+ zones.equals(N.getSemantic(NZoneDim))) {
+
+ // on place les effectifs dans un tableau pour un acces rapide
+ // on divise directement par le nombre de cell de la zone pour eviter
+ // de le faire beaucoup plus souvent dans l'autre boucle
+ double[][] NArray = new double[groups.size()][zones.size()];
+ for (MatrixIterator i=N.iteratorNotZero(); i.next();) {
+ int[] pos = i.getCoordinates();
+ double val = i.getValue();
+
+ NArray[pos[NGroupDim]][pos[NZoneDim]] = val / sizeCell[pos[NZoneDim]];
}
+
+ // calcul de la matrice resultat
+ for (MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ int[] pos = i.getCoordinates();
+ double val = i.getValue();
+ val *= NArray[pos[groupDim]][pos[zoneDim]];
+ i.setValue(val);
+ }
+
+ } else {
+ // N et matrixCatchRatePerStrategyMetPerCell non pas les meme semantics
+ // on fait moins rapide
+ for (MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ int[] pos = i.getCoordinates();
+ Object[] sems = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup)sems[groupDim];
+ Zone zone = (Zone)sems[zoneDim];
+ double val = i.getValue();
+ val *= N.getValue(group, zone) / sizeCell[pos[zoneDim]];
+ i.setValue(val);
+ }
}
+
return result;
+
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// List<Zone> zones = pop.getPopulationZone();
+//
+// MatrixND result = matrixCatchRatePerStrategyMetPerCell.copy();
+// result.setName("matrixCatchPerStrategyMetPerCell");
+//
+// for (PopulationGroup group : groups) {
+// MatrixND sub = result.getSubMatrix(2, group, 1);
+// for (Zone zone : zones) {
+// MatrixND subsub = sub.getSubMatrix(3, zone, 1);
+// double val = N.getValue(group, zone) / (double) zone.sizeCell();
+// subsub.mults(val);
+// }
+// }
+// return result;
}
/**
@@ -662,103 +837,136 @@
private MatrixND matrixCatchRatePerStrategyMetPerCell(Population pop,
TimeStep step, MatrixND matrixFishingMortalityPerCell)
throws TopiaException, IsisFishException {
- List<Strategy> strategies = getStrategies(step);
- List<Metier> metiers = getMetiers(step);
- List<PopulationGroup> groups = pop.getPopulationGroup();
- List<Zone> zones = pop.getPopulationZone();
- List<Cell> cells = getCells(zones);
- MatrixND result = MatrixFactory.getInstance().create(
- "matrixCatchRatePerStrategyMetPerCell",
- new List[] { strategies, metiers, groups, zones, cells },
- new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
- n_("Zones"), n_("Cells") });
+ MatrixND totalFishingMortalityPerCell = totalFishingMortalityPerCell(
+ step, matrixFishingMortalityPerCell);
- // Optimisation Hilaire
- MatrixND matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCell
- .sumOverDim(2);
- matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCellSumOverGroup
- .reduceDims(2);
+ MatrixND result = matrixFishingMortalityPerCell.copy();
+ result.setName("matrixCatchRatePerStrategyMetPerCell");
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- for (int z = 0; z < zones.size(); z++) {
- Zone zone = zones.get(z);
- List<Cell> cellZones = zone.getCell();
- for (int c = 0; c < cellZones.size(); c++) {
- Cell cell = cellZones.get(c);
- double effort = matrixFishingMortalityPerCellSumOverGroup
- .getValue(str, metier, zone, cell);
- if (effort > 0) {
- for (int g = 0; g < groups.size(); g++) {
- PopulationGroup group = groups.get(g);
- double value = catchRatePerStrategyMetPerCell(
- str, metier, step, group, zone, cell,
- matrixFishingMortalityPerCell);
- result.setValue(new Object[] { str, metier,
- group, zone, cell }, value);
- }
- }
- }
- }
- }
- }
+ for (MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
- return result;
- }
+ PopulationGroup group = (PopulationGroup)sems[2];
+ Zone zone = (Zone)sems[3];
+ Cell cell = (Cell)sems[4];
- /**
- * catchRatePerStrategyMetPerCell.
- *
- * Optimisation Hilaire
- *
- * @param str
- * @param metier
- * @param step
- * @param group
- * @param zone
- * @param cell
- * @param matrixFishingMortalityPerCell
- * @return
- * @throws TopiaException
- * @throws IsisFishException
- */
- private double catchRatePerStrategyMetPerCell(Strategy str, Metier metier,
- TimeStep step, PopulationGroup group, Zone zone, Cell cell,
- MatrixND matrixFishingMortalityPerCell) throws TopiaException,
- IsisFishException {
+ double totalFishingMortality = totalFishingMortalityPerCell.getValue(
+ group, zone, cell);
- MatrixND totalFishingMortalityPerCell = totalFishingMortalityPerCell(
- step, matrixFishingMortalityPerCell);
- double totalFishingMortality = totalFishingMortalityPerCell.getValue(
- group, zone, cell);
+ if (totalFishingMortality != 0) {
- if (totalFishingMortality == 0) {
- if (log.isDebugEnabled()) {
- log.debug("pas de totalFishingMortality pour (" + group + ", "
- + zone + ")");
+ double fishingMortalityPerCell = i.getValue();
+ double totalCatchRatePerCell = totalCatchRatePerCell(step, group, zone,
+ totalFishingMortality);
+
+ double value = fishingMortalityPerCell / totalFishingMortality
+ * totalCatchRatePerCell;
+
+ i.setValue(value);
}
- return 0;
}
- double fishingMortalityPerCell = matrixFishingMortalityPerCell
- .getValue(new Object[] { str, metier, group, zone, cell });
- double totalCatchRatePerCell = totalCatchRatePerCell(step, group, zone,
- totalFishingMortality);
+ return result;
- if (log.isDebugEnabled()) {
- log.debug(" totalFishingMortality=" + totalFishingMortality
- + " fishingMortality=" + fishingMortalityPerCell
- + " totalCatchRate=" + totalCatchRatePerCell);
- }
- double result = fishingMortalityPerCell / totalFishingMortality
- * totalCatchRatePerCell;
- return result;
+// List<Strategy> strategies = getStrategies(step);
+// List<Metier> metiers = getMetiers(step);
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// List<Zone> zones = pop.getPopulationZone();
+// List<Cell> cells = getCells(zones);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// "matrixCatchRatePerStrategyMetPerCell",
+// new List[] { strategies, metiers, groups, zones, cells },
+// new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+// n("Zones"), n("Cells") });
+//
+// // Optimisation Hilaire
+// MatrixND matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCell
+// .sumOverDim(2);
+// matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCellSumOverGroup
+// .reduceDims(2);
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// for (int z = 0; z < zones.size(); z++) {
+// Zone zone = zones.get(z);
+// List<Cell> cellZones = zone.getCell();
+// for (int c = 0; c < cellZones.size(); c++) {
+// Cell cell = cellZones.get(c);
+// double effort = matrixFishingMortalityPerCellSumOverGroup
+// .getValue(str, metier, zone, cell);
+// if (effort > 0) {
+// for (int g = 0; g < groups.size(); g++) {
+// PopulationGroup group = groups.get(g);
+// double value = catchRatePerStrategyMetPerCell(
+// str, metier, step, group, zone, cell,
+// matrixFishingMortalityPerCell);
+// result.setValue(new Object[] { str, metier,
+// group, zone, cell }, value);
+// }
+// }
+// }
+// }
+// }
+// }
+//
+// return result;
}
+// directement dans matrixCatchRatePerStrategyMetPerCell pour pouvoir mieux optimiser
+// /**
+// * catchRatePerStrategyMetPerCell.
+// *
+// * Optimisation Hilaire
+// *
+// * @param str
+// * @param metier
+// * @param step
+// * @param group
+// * @param zone
+// * @param cell
+// * @param matrixFishingMortalityPerCell
+// * @return
+// * @throws TopiaException
+// * @throws IsisFishException
+// */
+// private double catchRatePerStrategyMetPerCell(Strategy str, Metier metier,
+// TimeStep step, PopulationGroup group, Zone zone, Cell cell,
+// MatrixND matrixFishingMortalityPerCell) throws TopiaException,
+// IsisFishException {
+//
+// MatrixND totalFishingMortalityPerCell = totalFishingMortalityPerCell(
+// step, matrixFishingMortalityPerCell);
+// double totalFishingMortality = totalFishingMortalityPerCell.getValue(
+// group, zone, cell);
+//
+// if (totalFishingMortality == 0) {
+// if (log.isDebugEnabled()) {
+// log.debug("pas de totalFishingMortality pour (" + group + ", "
+// + zone + ")");
+// }
+// return 0;
+// }
+//
+// double fishingMortalityPerCell = matrixFishingMortalityPerCell
+// .getValue(new Object[] { str, metier, group, zone, cell });
+// double totalCatchRatePerCell = totalCatchRatePerCell(step, group, zone,
+// totalFishingMortality);
+//
+// if (log.isDebugEnabled()) {
+// log.debug(" totalFishingMortality=" + totalFishingMortality
+// + " fishingMortality=" + fishingMortalityPerCell
+// + " totalCatchRate=" + totalCatchRatePerCell);
+// }
+// double result = fishingMortalityPerCell / totalFishingMortality
+// * totalCatchRatePerCell;
+//
+// return result;
+// }
/**
* @param step
@@ -791,7 +999,7 @@
/**
* Returne une matrice de mortalite group x zone, donc somme sur str et
* metier
- *
+ *
* @param step
* @param matrixFishingMortality
* @param group
@@ -806,12 +1014,101 @@
return result;
}
+// /**
+// * Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop x
+// * cellPop]
+// *
+// * Nouvelle implantation suite a demande Steph et Sigrid: 20080208 (NouvellesEquationsfev2008ParCelluleAvecAlgo.odt)
+// *
+// * @param pop
+// * @param step
+// * @return
+// * @throws TopiaException
+// * @throws IsisFishException
+// */
+// public MatrixND matrixFishingMortalityPerCell(TimeStep step, Population pop)
+// throws TopiaException, IsisFishException {
+// List<Strategy> strategies = getStrategies(step);
+// List<Metier> metiers = getMetiers(step);
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// List<Zone> zones = pop.getPopulationZone();
+// List<Cell> cells = getCells(zones);
+//
+// // default value in matrix is 0
+// MatrixND result = MatrixFactory.getInstance().create(
+// "matrixFishingMortalityPerCell",
+// new List[] { strategies, metiers, groups, zones, cells },
+// new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+// n("Zones"), n("Cells") });
+//
+// Month month = step.getMonth();
+// PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
+//
+// for (int g = 0; g < groups.size(); g++) {
+// PopulationGroup group = groups.get(g);
+//
+// // getCapturability is check matrix validity and create matrix
+// // if needed and get one value in
+// double capturability = infoPop.getCapturability(group);
+// if (capturability != 0) { // check 0, this prevent next call, for default value
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+//
+// MetierSeasonInfo infoMet = metier
+// .getMetierSeasonInfo(month);
+// // getTargetFactor seem to be simple
+// double ciblage = infoMet.getTargetFactor(group);
+//
+// if (ciblage != 0) { // check 0, this prevent next call, for default value
+//
+// Gear gear = metier.getGear();
+// Selectivity selectivity = gear.getPopulationSelectivity(pop);
+// if (selectivity != null) {
+//
+// // getCoefficient is equation evaluation
+// double coeff = selectivity.getCoefficient(pop,group, metier);
+// if (coeff != 0) { // check 0, this prevent next call, for default value
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// // l'effort d'une cellule du metier
+// double effort = effortPerStrategyPerCell(
+// str, metier, infoMet, step);
+// if (effort > 0) { // put value only if <> 0
+// for (int z = 0; z < zones.size(); z++) {
+// Zone zone = zones.get(z);
+// Set<Cell> cellPops = new HashSet<Cell>(zone.getCell());
+// for (Cell cellMet : infoMet.getCells()) {
+// if (cellPops.contains(cellMet)) {
+// double value = coeff * capturability * ciblage * effort;
+// result.setValue(
+// new Object[] { str,
+// metier,
+// group,
+// zone,
+// cellMet },
+// value);
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// return result;
+// }
+//
+
/**
* Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop x
* cellPop]
- *
+ *
* Nouvelle implantation suite a demande Steph et Sigrid: 20080208 (NouvellesEquationsfev2008ParCelluleAvecAlgo.odt)
- *
+ *
* @param pop
* @param step
* @return
@@ -825,61 +1122,71 @@
List<PopulationGroup> groups = pop.getPopulationGroup();
List<Zone> zones = pop.getPopulationZone();
List<Cell> cells = getCells(zones);
-
+
// default value in matrix is 0
MatrixND result = MatrixFactory.getInstance().create(
"matrixFishingMortalityPerCell",
new List[] { strategies, metiers, groups, zones, cells },
- new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
- n_("Zones"), n_("Cells") });
+ new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+ n("Zones"), n("Cells") });
Month month = step.getMonth();
PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
- for (int g = 0; g < groups.size(); g++) {
- PopulationGroup group = groups.get(g);
+ for (Strategy str : strategies) {
+ StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
+ double nbTrip = smi.getNumberOfTrips();
+ double propSetOfVessels = str.getProportionSetOfVessels();
+ int nbOfVessels = str.getSetOfVessels().getNumberOfVessels();
- // getCapturability is check matrix validity and create matrix
- // if needed and get one value in
- double capturability = infoPop.getCapturability(group);
- if (capturability != 0) { // check 0, this prevent next call, for default value
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
+ // dans le calcul de l'effort si une de ces donnees est 0
+ // alors le result dans la matrice est 0
+ // donc autant ne pas faire tous les autres calculs couteux
+ if (nbTrip * propSetOfVessels * nbOfVessels != 0) {
+ for (PopulationGroup group : groups) {
- MetierSeasonInfo infoMet = metier
- .getMetierSeasonInfo(month);
- // getTargetFactor seem to be simple
- double ciblage = infoMet.getTargetFactor(group);
+ // getCapturability is check matrix validity and create matrix if needed and get one value in
+ double capturability = infoPop.getCapturability(group);
+ if (capturability != 0) { // check 0, this prevent next call, for default value
- if (ciblage != 0) { // check 0, this prevent next call, for default value
+ // et de la meme facon si la proportion est 0 alors
+ // le resultat dans la matrice sera 0, donc on boucle que
+ // sur ceux qui ont une proportion
+ List<Metier> metiersNot0 = getMetiers(str, step);
+ for (Metier metier : metiersNot0) {
- Gear gear = metier.getGear();
- Selectivity selectivity = gear.getPopulationSelectivity(pop);
- if (selectivity != null) {
+ MetierSeasonInfo infoMet = metier
+ .getMetierSeasonInfo(month);
+ // getTargetFactor seem to be simple
+ double ciblage = infoMet.getTargetFactor(group);
- // getCoefficient is equation evaluation
- double coeff = selectivity.getCoefficient(pop,group, metier);
- if (coeff != 0) { // check 0, this prevent next call, for default value
+ if (ciblage != 0) { // check 0, this prevent next call, for default value
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- // l'effort d'une cellule du metier
- double effort = effortPerStrategyPerCell(
- str, metier, step);
- if (effort > 0) { // put value only if <> 0
- for (int z = 0; z < zones.size(); z++) {
- Zone zone = zones.get(z);
- Set<Cell> cellPops = new HashSet<Cell>(zone.getCell());
- for (Cell cellMet : infoMet.getCells()) {
- if (cellPops.contains(cellMet)) {
- double value = coeff * capturability * ciblage * effort;
- result.setValue(
- new Object[] { str,
+ Gear gear = metier.getGear();
+ Selectivity selectivity = gear.getPopulationSelectivity(pop);
+ if (selectivity != null) {
+
+ // getCoefficient is equation evaluation
+ double coeff = selectivity.getCoefficient(pop,group, metier);
+ if (coeff != 0) { // check 0, this prevent next call, for default value
+
+ // l'effort d'une cellule du metier
+ double effort = effortPerStrategyPerCell(
+ str, metier, infoMet, step);
+ if (effort > 0) { // put value only if <> 0
+ for (Zone zone : zones) {
+ Set<Cell> cellPops = new HashSet<Cell>(zone.getCell());
+ for (Cell cellMet : infoMet.getCells()) {
+ if (cellPops.contains(cellMet)) {
+ double value = coeff * capturability * ciblage * effort;
+ result.setValue(
+ new Object[] { str,
metier,
group,
zone,
cellMet },
- value);
+ value);
+ }
}
}
}
@@ -901,19 +1208,20 @@
* @return
*/
private double effortPerStrategyPerCell(Strategy str, Metier metier,
- TimeStep step) {
- Month month = step.getMonth();
+ MetierSeasonInfo infoMet, TimeStep step) {
//StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
- Collection<Zone> zones = metier.getMetierSeasonInfo(month).getZone();
+ Collection<Zone> zones = infoMet.getZone();
double nbCell = getCells(zones).size();
if (nbCell == 0) {
// normalement il devrait y avoir des mailles, mais pour les
// ancienne zone AuPort, il n'y en avait pas
- if (log.isWarnEnabled())
+ if (log.isWarnEnabled()) {
+ Month month = step.getMonth();
log.warn("Calcul d'une distance pour le metier " + metier
+ " pour le mois " + month
+ " avec une zone sans maille: " + zones);
+ }
return 0;
}
@@ -1078,8 +1386,8 @@
/**
*
- * @param setOfVessels
- * @param zone
+ * @param sov
+ * @param zoneMetier
* @return
*/
protected double travelTimePerTrip(SetOfVessels sov,
@@ -1255,7 +1563,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_ABUNDANCE + "_PER_CELL",
new List[] { groups, zones, allCells },
- new String[] { n_("Groups"), n_("Zones"), n_("Cells") });
+ new String[] { n("Groups"), n("Zones"), n("Cells") });
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -1320,7 +1628,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_ABUNDANCE, new List[] { groups, zones },
- new String[] { n_("Groups"), n_("Zones") });
+ new String[] { n("Groups"), n("Zones") });
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -1355,7 +1663,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_ABUNDANCE, new List[] { groups, zones },
- new String[] { n_("Groups"), n_("Zones") });
+ new String[] { n("Groups"), n("Zones") });
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -1386,8 +1694,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));
@@ -1407,9 +1715,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;
@@ -1428,47 +1736,51 @@
* @return
*/
public MatrixND matrixBiomass(MatrixND N, Population pop, TimeStep step) {
- List<PopulationGroup> groups = (List<PopulationGroup>)N.getSemantic(0);
- List<Zone> zones = (List<Zone>)N.getSemantic(1);
-
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_BIOMASS, new List[] { groups, zones },
- new String[] { n_("Groups"), n_("Zones") });
-
- for (int g = 0; g < groups.size(); g++) {
- PopulationGroup group = groups.get(g);
- double meanWeight = group.getMeanWeight();
- for (int z = 0; z < zones.size(); z++) {
- Zone zone = zones.get(z);
- double n = N.getValue(group, zone);
- double value = n * meanWeight;
- result.setValue(group, zone, value);
- }
- }
-
- return result;
+ return matrixToWeightMatrix(step, 0, ResultName.MATRIX_BIOMASS, N);
+//
+// List<PopulationGroup> groups = (List<PopulationGroup>)N.getSemantic(0);
+// List<Zone> zones = (List<Zone>)N.getSemantic(1);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_BIOMASS, new List[] { groups, zones },
+// new String[] { n("Groups"), n("Zones") });
+//
+// for (int g = 0; g < groups.size(); g++) {
+// PopulationGroup group = groups.get(g);
+// double meanWeight = group.getMeanWeight();
+// for (int z = 0; z < zones.size(); z++) {
+// Zone zone = zones.get(z);
+// double n = N.getValue(group, zone);
+// double value = n * meanWeight;
+// result.setValue(group, zone, value);
+// }
+// }
+//
+// return result;
}
public MatrixND matrixBiomassBeginMonth(MatrixND N, Population pop,
TimeStep step) {
- List<PopulationGroup> groups = (List<PopulationGroup>)N.getSemantic(0);
- List<Zone> zones = (List<Zone>)N.getSemantic(1);
+ return matrixToWeightMatrix(step, 0, ResultName.MATRIX_BIOMASS_BEGIN_MONTH, N);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_BIOMASS_BEGIN_MONTH, new List[] { groups, zones },
- new String[] { n_("Groups"), n_("Zones") });
-
- for (int g = 0; g < groups.size(); g++) {
- PopulationGroup group = groups.get(g);
- double meanWeight = group.getMeanWeight();
- for (int z = 0; z < zones.size(); z++) {
- Zone zone = zones.get(z);
- double n = N.getValue(group, zone);
- double value = n * meanWeight;
- result.setValue(group, zone, value);
- }
- }
- return result;
+// List<PopulationGroup> groups = (List<PopulationGroup>)N.getSemantic(0);
+// List<Zone> zones = (List<Zone>)N.getSemantic(1);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_BIOMASS_BEGIN_MONTH, new List[] { groups, zones },
+// new String[] { n("Groups"), n("Zones") });
+//
+// for (int g = 0; g < groups.size(); g++) {
+// PopulationGroup group = groups.get(g);
+// double meanWeight = group.getMeanWeight();
+// for (int z = 0; z < zones.size(); z++) {
+// Zone zone = zones.get(z);
+// double n = N.getValue(group, zone);
+// double value = n * meanWeight;
+// result.setValue(group, zone, value);
+// }
+// }
+// return result;
}
public MatrixND matrixAbondanceBeginMonth(MatrixND N, Population pop,
@@ -1478,7 +1790,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_ABUNDANCE_BEGIN_MONTH, new List[] { groups, zones },
- new String[] { n_("Groups"), n_("Zones") });
+ new String[] { n("Groups"), n("Zones") });
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -1491,12 +1803,6 @@
return result;
}
- ///////////////////////////////////////////////////////////////////////////
- //
- //
- //
- ///////////////////////////////////////////////////////////////////////////
-
/**
* @param step
* @return
@@ -1509,7 +1815,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_EFFORT_PER_STRATEGY_MET,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -1524,12 +1830,6 @@
return result;
}
- ///////////////////////////////////////////////////////////////////////////
- //
- //
- //
- ///////////////////////////////////////////////////////////////////////////
-
/**
*
*
@@ -1540,34 +1840,33 @@
*/
public MatrixND matrixDiscardWeightPerStrategyMetPerZonePop(Population pop,
TimeStep step, MatrixND matrixDiscardPerStrategyMetPerZonePop) {
- List<PopulationGroup> groups = pop.getPopulationGroup();
+ return matrixToWeightMatrix(step, 2,
+ ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP,
+ matrixDiscardPerStrategyMetPerZonePop);
- MatrixND result = matrixDiscardPerStrategyMetPerZonePop.copy();
- result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
-
- for (PopulationGroup group : groups) {
- MatrixND sub = result.getSubMatrix(2, group, 1);
- double meanWeight = group.getMeanWeight();
- sub.mults(meanWeight);
- }
-
- return result;
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+//
+// MatrixND result = matrixDiscardPerStrategyMetPerZonePop.copy();
+// result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
+//
+// for (PopulationGroup group : groups) {
+// MatrixND sub = result.getSubMatrix(2, group, 1);
+// double meanWeight = group.getMeanWeight();
+// sub.mults(meanWeight);
+// }
+//
+// return result;
}
- ///////////////////////////////////////////////////////////////////////////
- //
- //
- //
- ///////////////////////////////////////////////////////////////////////////
- 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(
ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET,
new List[]{strategies, metiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ new String[]{n("Strategies"), n("Metiers")});
for (int s=0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -1581,4 +1880,153 @@
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);
+
+ 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;
+ }
+
+ /**
+ * Converti une matrix contenant des effectifs en une matrice en poids
+ *
+ * @param step
+ * @param dimGroup
+ * @param resultName
+ * @return
+ */
+ @Nocache // no need to cache it, because caller method is cached
+ public MatrixND matrixToWeightMatrix(TimeStep step, int dimGroup, String resultName,
+ MatrixND matrix) {
+
+ MatrixND result = matrix.copy();
+ result.setName(resultName);
+
+ List<PopulationGroup> groups = (List<PopulationGroup>)result.getSemantic(dimGroup);
+ double[] meanWeight = new double[groups.size()];
+ int cpt = 0;
+ for (PopulationGroup group : groups) {
+ meanWeight[cpt++] = group.getMeanWeight();
+ }
+
+ for (MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ double val = i.getValue();
+ int[] pos = i.getCoordinates();
+ i.setValue(val * meanWeight[pos[dimGroup]]);
+ }
+
+ return result;
+ }
}
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.File;
import java.io.Writer;
@@ -67,10 +65,10 @@
ReverseFileReader reader = new ReverseFileReader(referenceFile);
//read the last line of the file (should be empty)
- String line = reader.readLine();
+ reader.readLine();
//read the next line (the last written line)
- line = reader.readLine();
+ String line = reader.readLine();
String lastMonth="";
@@ -113,12 +111,12 @@
@Override
public String getDescription() {
- return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityBiomassReferenceY9";
+ return "SensitivityBiomassReferenceY9_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.File;
import java.io.Writer;
@@ -71,10 +69,10 @@
ReverseFileReader reader = new ReverseFileReader(referenceFile);
//read the last line of the file (should be empty)
- String line = reader.readLine();
+ reader.readLine();
//read the next line (the last written line)
- line = reader.readLine();
+ String line = reader.readLine();
String lastMonth="";
@@ -121,12 +119,12 @@
@Override
public String getDescription() {
- return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityBiomassRelativeReferenceY12";
+ return "SensitivityBiomassRelativeReferenceY12_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -77,12 +75,12 @@
@Override
public String getDescription() {
- return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityBiomassRelativeY6";
+ return "SensitivityBiomassRelativeY6_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -67,12 +65,12 @@
@Override
public String getDescription() {
- return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityBiomassY3";
+ return "SensitivityBiomassY3_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.File;
import java.io.Writer;
@@ -114,14 +112,14 @@
@Override
public String getDescription() {
- return _("Captures in weight for the last year for the popage " +
+ return "Captures in weight for the last year for the popage " +
"population. Captures is the sum of zones, groups, metiers " +
- "and strategies");
+ "and strategies";
}
@Override
public String getExportFilename() {
- return "SensitivityCapturesWeightReferenceY7";
+ return "SensitivityCapturesWeightReferenceY7_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.File;
import java.io.Writer;
@@ -39,14 +37,15 @@
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.Doc;
-public class SensitivityCatchWeightRelativeReferenceY10 implements
- SensitivityExport {
+public class SensitivityCatchWeightRelativeReferenceY10 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory
.getLog(SensitivityCatchWeightRelativeReferenceY10.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
@Doc("Population")
public Population param_pop;
@@ -129,12 +128,12 @@
@Override
public String getDescription() {
- return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies");
+ return "Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies";
}
@Override
public String getExportFilename() {
- return "SensitivityCapturesWeightRelativeReferenceY10";
+ return "SensitivityCapturesWeightRelativeReferenceY10_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -43,7 +41,9 @@
static private Log log = LogFactory
.getLog(SensitivityCatchWeightRelativeY4.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
@Doc("Population")
public Population param_pop;
@@ -85,12 +85,12 @@
@Override
public String getDescription() {
- return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies");
+ return "Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies";
}
@Override
public String getExportFilename() {
- return "SensitivityCapturesWeightRelativeY4";
+ return "SensitivityCapturesWeightRelativeY4_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -43,7 +41,9 @@
static private Log log = LogFactory
.getLog(SensitivityCatchWeightY1.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
@Doc("Population")
public Population param_pop;
@@ -76,12 +76,12 @@
@Override
public String getDescription() {
- return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies");
+ return "Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies";
}
@Override
public String getExportFilename() {
- return "SensitivityCapturesWeightY1";
+ return "SensitivityCapturesWeightY1_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau, 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
@@ -21,43 +21,42 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.File;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.TimeStep;
+import fr.ifremer.isisfish.util.Doc;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixIterator;
import org.nuiton.math.matrix.MatrixND;
-
import org.nuiton.topia.TopiaContext;
import org.nuiton.util.ReverseFileReader;
import scripts.ResultName;
-import fr.ifremer.isisfish.datastore.ResultStorage;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.entities.PopulationGroup;
-import fr.ifremer.isisfish.export.SensitivityExport;
-import fr.ifremer.isisfish.types.TimeStep;
-import fr.ifremer.isisfish.util.Doc;
+import java.io.File;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
public class SensitivitySpawningBiomassReferenceY8 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory
.getLog(SensitivitySpawningBiomassReferenceY8.class);
- protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_BIOMASS
+ };
@Doc("Population")
public Population param_pop;
@Doc("URL of the Biomasses.csv reference export file")
- public String param_referenceBiomassCSV ="";
+ public String param_referenceBiomassCSV = "";
@Override
public void export(SimulationStorage simulation, Writer out)
@@ -78,7 +77,7 @@
Map<Integer, Double> map =new HashMap<Integer,Double>();
for (PopulationGroup group:groups) {
- map.put(group.getId(),group.getReproductionRate());
+ map.put(group.getId(),group.getMaturityOgive());
}
tx.closeContext();
@@ -110,6 +109,7 @@
}
line = reader.readLine();
}
+ reader.close();
for (Population pop : simulation.getParameter().getPopulations()) {
if (pop.getName().equals(param_pop.getName())) {
@@ -123,22 +123,23 @@
PopulationGroup group = (PopulationGroup) sems[1];
TimeStep step = (TimeStep) sems[0];
if (step.equals(lastStep)) {
- biomass += i.getValue() * group.getReproductionRate();
+ biomass += i.getValue() * group.getMaturityOgive();
}
}
}
}
+
out.write(Double.toString(biomass / referenceBiomass));
}
@Override
public String getDescription() {
- return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivitySpawningBiomassReferenceY8";
+ return "SensitivitySpawningBiomassReferenceY8_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau, 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
@@ -21,22 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.File;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixIterator;
-import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.topia.TopiaContext;
-
-import org.nuiton.util.ReverseFileReader;
-import scripts.ResultName;
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Population;
@@ -44,7 +28,20 @@
import fr.ifremer.isisfish.export.SensitivityExport;
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.Doc;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.util.ReverseFileReader;
+import scripts.ResultName;
+import java.io.File;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
public class SensitivitySpawningBiomassRelativeReferenceY11 implements
SensitivityExport {
@@ -58,7 +55,7 @@
public Population param_pop;
@Doc("URL of the Biomasses.csv reference export file")
- public String param_referenceBiomassCSV ="";
+ public String param_referenceBiomassCSV = "";
@Override
public void export(SimulationStorage simulation, Writer out)
@@ -83,7 +80,7 @@
Map<Integer, Double> map =new HashMap<Integer,Double>();
for (PopulationGroup group:groups) {
- map.put(group.getId(),group.getReproductionRate());
+ map.put(group.getId(),group.getMaturityOgive());
}
tx.closeContext();
@@ -120,6 +117,7 @@
line = reader.readLine();
}
+ reader.close();
for (Population pop : simulation.getParameter().getPopulations()) {
if (pop.getName().equals(param_pop.getName())) {
@@ -134,7 +132,7 @@
TimeStep step = (TimeStep) sems[0];
if (step.equals(firstStep)) {
firstbiomass += i.getValue()
- * group.getReproductionRate();
+ * group.getMaturityOgive();
}
}
@@ -148,23 +146,24 @@
TimeStep step = (TimeStep) sems[0];
if (step.equals(lastStep)) {
biomass = biomass + i.getValue()
- * group.getReproductionRate();
+ * group.getMaturityOgive();
}
}
}
}
+
out.write(Double.toString((biomass / firstbiomass)
/ (biomassReference / firstBiomassReference)));
}
@Override
public String getDescription() {
- return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivitySpawningBiomassRelativeReferenceY11";
+ return "SensitivitySpawningBiomassRelativeReferenceY11_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau, 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
@@ -21,16 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixIterator;
-import org.nuiton.math.matrix.MatrixND;
-
-import scripts.ResultName;
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Population;
@@ -38,14 +28,24 @@
import fr.ifremer.isisfish.export.SensitivityExport;
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.Doc;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+
+import java.io.Writer;
+
public class SensitivitySpawningBiomassRelativeY5 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory
.getLog(SensitivitySpawningBiomassRelativeY5.class);
- protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_BIOMASS
+ };
@Doc("Population")
public Population param_pop;
@@ -72,7 +72,7 @@
TimeStep step = (TimeStep) sems[0];
if (step.equals(firstStep)) {
firstbiomass += i.getValue()
- * group.getReproductionRate();
+ * group.getMaturityOgive();
}
}
@@ -85,7 +85,7 @@
PopulationGroup group = (PopulationGroup) sems[1];
TimeStep step = (TimeStep) sems[0];
if (step.equals(lastStep))
- biomass += i.getValue() * group.getReproductionRate();
+ biomass += i.getValue() * group.getMaturityOgive();
}
}
}
@@ -94,12 +94,12 @@
@Override
public String getDescription() {
- return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityGenitorBiomassRelativeY5";
+ return "SensitivityGenitorBiomassRelativeY5_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java
===================================================================
--- trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau, 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
@@ -21,16 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixIterator;
-import org.nuiton.math.matrix.MatrixND;
-
-import scripts.ResultName;
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Population;
@@ -38,14 +28,24 @@
import fr.ifremer.isisfish.export.SensitivityExport;
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.Doc;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+
+import java.io.Writer;
+
public class SensitivitySpawningBiomassY2 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory
.getLog(SensitivitySpawningBiomassY2.class);
- protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_BIOMASS
+ };
@Doc("Population")
public Population param_pop;
@@ -69,7 +69,7 @@
TimeStep step = (TimeStep) sems[0];
PopulationGroup group = (PopulationGroup) sems[1];
if (step.equals(lastStep)) {
- biomass += i.getValue() * group.getReproductionRate();
+ biomass += i.getValue() * group.getMaturityOgive();
}
}
}
@@ -79,12 +79,12 @@
@Override
public String getDescription() {
- return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityGenitorBiomassY2";
+ return "SensitivityGenitorBiomassY2_" + param_pop.getName();
}
@Override
Modified: trunk/src/test/resources/test-database/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java
===================================================================
--- trunk/src/test/resources/test-database/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2007 - 2011 Ifremer, CodeLutin, Sigrid Lehuta
+ * Copyright (C) 2007 - 2014 Ifremer, CodeLutin, Sigrid Lehuta
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,15 +21,12 @@
*/
package simulationplans;
-import static org.nuiton.i18n.I18n._;
-
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import fr.ifremer.isisfish.util.ScriptUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixIterator;
@@ -38,16 +35,16 @@
import org.nuiton.util.FileUtil;
import org.nuiton.util.StringUtil;
+import scripts.ResultName;
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationGroup;
-import fr.ifremer.isisfish.simulator.SimulationPlanContext;
import fr.ifremer.isisfish.simulator.SimulationPlan;
+import fr.ifremer.isisfish.simulator.SimulationPlanContext;
import fr.ifremer.isisfish.util.Doc;
+import fr.ifremer.isisfish.util.ScriptUtil;
-import scripts.ResultName;
-
/**
* CalibrationSimplexePasVariable2Capturabilite.
*
@@ -111,7 +108,7 @@
//*** write the name of the simulated matrix that contains the data corresponding
// to your observations (here MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP)
- public String[] necessaryResult = {
+ protected String[] necessaryResult = {
ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
};
@@ -124,9 +121,9 @@
* @return L'aide ou la description du plan
*/
public String getDescription() throws Exception {
- return _("Calibration using variable step Simplex method (Walters): user" +
+ return "Calibration using variable step Simplex method (Walters): user" +
"gives a file of observations (here catches)(.csv), simulated output" +
- "will try to approach oservations by changing the values of catchability");
+ "will try to approach oservations by changing the values of catchability";
}
/**
@@ -156,7 +153,8 @@
double worst2;
/**
- * Call before each simulation
+ * Call before each simulation.
+ *
* @param context plan context
* @param nextSimulation storage used for next simulation
* @return true if we must do next simulation, false to stop plan
@@ -483,4 +481,4 @@
}
}
-}
+}
\ No newline at end of file
Added: trunk/src/test/resources/test-database/simulationplans/RecuitSimuleSimulateur.java
===================================================================
--- trunk/src/test/resources/test-database/simulationplans/RecuitSimuleSimulateur.java (rev 0)
+++ trunk/src/test/resources/test-database/simulationplans/RecuitSimuleSimulateur.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -0,0 +1,638 @@
+package simulationplans;
+
+/*
+ * #%L
+ * IsisFish
+ * %%
+ * Copyright (C) 1999 - 2014 Ifremer, Codelutin
+ * %%
+ * 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 3 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-3.0.html>.
+ * #L%
+ */
+
+import static org.nuiton.i18n.I18n._;
+
+import java.io.File;
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.StringUtil;
+
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.simulator.SimulationException;
+import fr.ifremer.isisfish.simulator.SimulationPlanContext;
+import fr.ifremer.isisfish.simulator.SimulationPlan;
+import fr.ifremer.isisfish.util.Doc;
+
+import scripts.ResultName;
+
+/**
+ * RecuitSimule.
+ *
+ * Created:
+ *
+ * @author
+ * @version
+ *
+ * Last update:
+ * by :
+ */
+
+// ////////////////////////////////////////////////////////////////////////
+// USER GUIDE
+//-------------------------------------------------------------------------
+// Script must be adapted to the case study (calibration data, catchability assumptions)
+// Script won't compile as it stands
+// Comments preceeded by /////*** explain where and how to adapt the script
+// Access to the APIs is free
+// ////////////////////////////////////////////////////////////////////////
+
+// ***You can modify class name if you want
+// ***BUT attention : file name and class name must be the same (without the extention ".java"),
+// ie here : "RecuitSimule"
+
+public class RecuitSimuleSimulateur implements SimulationPlan {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(RecuitSimuleSimulateur.class);
+
+ /////***here must appear the path to export the historic file ("Historic.csv")
+ //in which all information about each simulation is stored
+ /////***Attention : before beginning a new calibration rename any potential
+ //old Historic.csv files or they will be lost
+ protected File exportHistoric = new File("Historic.csv");
+
+ protected String exportHisto = "";
+
+ @Doc("Population which parameters are calibrated")
+ public Population param_Population = null;
+ @Doc("Lower values of parameters, separated with semicolons: de la forme(\"xx1;xx2;xx3\")")
+ public String param_borneInf = "2.42e-5;2.11e-6";// devient un parametre du plan d analyse/// Rentrer ici les bornes inférieruers de chaque paramètre.
+ @Doc("Upper values of parameters, separated with semicolons: de la forme(\"xx1;xx2;xx3\"); Keep the order used to fill borneInf.")
+ public String param_borneSup = "2.42e-5;2.11e-6";// devient un parametre du plan d analyse/// Rentrer ici les bornes supérieruers de chaque paramètre.
+ @Doc("Cooling schedule : choose between \"Van Laarhoven\", \"Huang\", \"Triki\", \"Geometric\", \"Lundy\", \"Constant\" and \"Linear\".")
+ public String param_coolingSchedule = "Triki"; // Attention aux méthodes à valeurs à fixer par l'utilisateur.
+ //public long param_seed = 1;
+
+ String [] borneInf;
+ String [] borneSup;
+ int taille;
+
+ int current;
+ int compteurSimus;
+ int compteurTemperature;
+ int compteurAccept;
+ double deltaEnergy;
+ SecureRandom random;
+ double rhoValue;
+ boolean bool;
+ double obj;
+
+ /////***hasard1,2,3, etc => des méthodes de hasard à déterminer, à placer en début de script. Pour le moment, elles ne font que de l'uniforme, à nous de voir ce qui est le mieux et pourquoi
+ public int hasard1(){
+ int result = random.nextInt(taille);
+ return result;
+ }
+ public int hasard2(){
+ int result = random.nextInt();
+ return result;
+ }
+ public double hasard3(){
+ double result = random.nextDouble();
+ return result;
+ }
+ public double hasardUniforme(){
+ double result = random.nextDouble();
+ return result;
+ }
+
+ //int seuilTemperature=5;// Laissés au choix de l'utilisateur. Dans l'interface, proposer des méthodes pour faire évoluer les seuils?
+ //int seuilAcceptance=3;
+ double seuilArret=0.01; //Sera utilisé en fonction du critèe d'arrêt utilisé...son cas est encore à trancher.
+
+ // ***put here the path and name of the file containing the data used to calibrate
+ // your fishery ( here observed landings per season and age groups)
+ @Doc(value = "file name and path of observed landings")
+ public String param_nomfichier_debarquements = "Observedlandings2001-2003.csv";
+ protected File debarquementsObserves;
+ protected MatrixND matrixDebarquement;
+
+ ArrayList<Experience> historique = new ArrayList<Experience>(); //historique va contenir tout l'historique de l'algorithme, c'est un ArrayList d'Experience.
+ //*** double temperature=???; //Initialisation de la température. Pour le moment, à l'utilisateur de remplacer ??? par un double dans le script.
+
+ //*** write the name of the simulated matrix that contains the data corresponding
+ // to your observations (here MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP)
+ public String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
+
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+ /**
+ * Permet d'afficher a l'utilisateur une aide sur le plan.
+ * @return L'aide ou la description du plan
+ */
+ public String getDescription() throws Exception {
+ return _("Calibration using simulated annealing: user" +
+ "gives a file of observations (here catches)(.csv), simulated output" +
+ "will try to approach oservations by changing the values of catchability");
+ }
+
+
+ /**
+ * Appele au demarrage de la simulation, cette methode permet d'initialiser
+ * des valeurs
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void init(SimulationPlanContext context) throws Exception {
+ random = new SecureRandom();
+ //random.setSeed(param_seed);
+
+ if (param_nomfichier_debarquements == null
+ || "".equals(param_nomfichier_debarquements)) {
+ debarquementsObserves = FileUtil.getFile(".*.csv",
+ "fichier csv separateur ';'");
+ } else {
+ debarquementsObserves = new File(param_nomfichier_debarquements);
+ }
+
+ // ***Create the matrix named matrixDebarquement that will contain your observed landings
+ // method: MatrixFactory.getInstance().create()
+ // ***Then import your file in it
+ // method : matrixDebarquement.importCSV();
+ log.info("MatrixDebarquement : " + matrixDebarquement);
+
+ borneInf=param_borneInf.split(";");
+ borneSup=param_borneSup.split(";");
+ taille=borneInf.length;
+
+ }
+
+ /**
+ *Crée (*@see createExperience) une nouvelle expérience (le contructeur modifie la paramétrisation parente ou en initialise une si c'est la première), baisse la température si nécessaire(*@see baisse), modifie la base de données(*@see changeDB).
+ *@param context plan context
+ *@param nextSimulation storage for the next simulation
+ *@return true if we must do next simulation, false to stop plan
+ *@throws Exception
+ */
+
+ public boolean beforeSimulation(SimulationPlanContext context,
+ SimulationStorage nextSimulation) throws Exception {//Dans le before, on modifie la paramétrisation actuelle, on enregistre cette modification, on change la base de données.
+ compteurSimus=getIteration(nextSimulation); //numéro de la simulation à venir
+ Experience expCurrent;
+
+ if (compteurSimus==0){//En considérant que la numérotation des simulations commence à 0, on traite ici la premièe simulation.
+ expCurrent = createExperience(compteurSimus, null);
+ expCurrent.accepted = true;
+ }
+ else {
+ Experience expPrev = historique.get(compteurSimus - 1);
+ expCurrent = createExperience(compteurSimus, expPrev);
+ expCurrent.temperature = baisse(expCurrent);
+ }
+
+ changeDB(expCurrent, nextSimulation);
+ return true;
+ }
+
+ /**
+ *Récupère les résultats de la simulation, calcule la fonction d'objectif(*@see calculFonctionObjectif), accepte ou non la nouvelle paramétrisation et décide la paramétrisation parente(*@see acceptationSolution) et vérifie le critère d'arrêt(*@see isCritereArretAtteint).
+ *@param context plan context
+ *@param lastSimulation storage for the next simulation
+ *@return true if we must do next simulation, false to stop plan
+ *@throws Exception
+ *@see getIteration
+ */
+ public boolean afterSimulation(SimulationPlanContext context,
+ SimulationStorage lastSimulation) throws Exception{//Dans l'after, on évalue la nouvelle paramétrisation, on met en compétition cette paramétrisation
+ //avec celle de référence (celle de l'itération current), on modifie la température, on vérifie que le
+ //critèe d'arrêt de l'algorithme n'est pas atteint, on enregistre toutes les modifications dans la table historique.
+ ResultStorage result = lastSimulation.getResultStorage();
+ boolean bool=true;
+ compteurSimus=getIteration(lastSimulation); //numéro de la simulation qui vient de se terminer
+ Experience expCurrent = historique.get(compteurSimus);
+ double obj=calculFonctionObjectif(result);
+ expCurrent.objective = obj;
+
+ if (compteurSimus > 0){
+ if (obj < expCurrent.best.objective){//On compare la nouvelle paramétrisation à la meilleure paramétrisation
+ expCurrent.best = expCurrent;
+ }
+ acceptationSolution(expCurrent);//On compare la nouvelle paramétrisation à la paramétrisation courante et on décide qui sera la courante.
+ //if (isModifierTemperature()){//Pour le moment, les méthodes proposées modifient la température à chaque fois. On intégrera un système de phase et de vérification de critère de température plus tard, si besoin.
+ /*}
+ else{
+ historique.get(compteurSimus).temperature = getExperience(compteurSimus-1).temperature;
+ }*/
+ bool=isCritereArretAtteint(expCurrent);
+ }
+ return bool;
+ }
+
+////////////////////
+////////////////////
+/// ///
+///AUTRES CLASSES///
+/// ///
+////////////////////
+////////////////////
+
+ protected Parameter[] copyM1(Parameter[]M1){
+ Parameter[] result = new Parameter[M1.length];
+ for (int i=0,maxi=M1.length; i<maxi; i++) {
+ result[i] = M1[i].copy();
+ }
+ return result;
+ }
+
+ class Parameter {
+ double value;
+ double inf;
+ double sup;
+
+ public Parameter (double valeur, double borneinf, double bornesup){
+ /*if (borneinf >= bornesup) {
+ throws SimulationException(String.format("Error: inf(%s) >= sup(%s)", borneinf, bornesup));
+ }*/
+ value=valeur;
+ inf=borneinf;
+ sup=bornesup;
+ }
+
+ public Parameter copy() {
+ return new Parameter(value, inf, sup);
+ }
+ }
+
+ class Experience{// 1 objet Experience contient toutes les informations sur la passage de l'état current à l'état suivant.
+ public int id;
+ public Experience parent;
+ public Experience best;
+ public boolean accepted;
+
+ public double rho;
+ public double rand;
+ public Parameter[] parametrisation; //On enregistre la paramétrisation et les bornes, tout est nécessaire en cas de ré-utilisation.
+ public double objective;
+ public double temperature;
+
+ public Experience(int id, Experience parent) {
+ this.id = id;
+ this.parent = parent;
+
+ if (parent == null) {
+ best = this;
+ parametrisation = initM1();
+ } else {
+ best = parent.best;
+
+ Parameter[] M1=copyM1(parent.getParametrisation());
+ modif(M1);
+ parametrisation = M1;
+ }
+ }
+
+ /**
+ * recherche de la 1ere experience accepte et retourne parametrisation
+ */
+ public Parameter[] getParametrisation() {
+ Parameter[] result = parametrisation;
+ if (!accepted) {
+ result = parent.getParametrisation();
+ }
+ return result;
+ }
+
+ /*public String toCSV() {
+ String sep = ";";
+ String result = "";
+
+ result += id + sep;
+ result += accepted + sep;
+ result += rand + sep;
+ result += rho + sep;
+ result += objective + sep;
+ result += temperature + sep;
+ result += parametrisation.value + sep;
+ result += parent.id + sep;
+ result += best.id + sep;
+
+ return result;
+ }*/
+ }
+
+////////////////////
+////////////////////
+/// ///
+/// METHODES ///
+/// ///
+////////////////////
+////////////////////
+
+ /**
+ *Retourne l'experience à l'index i dans la table historique, crée l'experience si elle n'existe pas encore.
+ *@param i l'index de l'Experience demandée
+ *@return l'Experience i
+ */
+
+ public Experience createExperience(int id, Experience parent){
+ Experience result = new Experience(id, parent);
+ historique.add(result);
+ return result;
+ }
+
+ /**
+ *Baisse la température selon une certaine méthode. Appellé par @see modifierTemperature
+ *@param compteurSimus la simulation qui vient de s'achever
+ *@return la température baissée
+ */
+ //En faire une fonction de compteurSimus pour que toutes les méthdoes marchaent!
+ public double baisse(Experience expCurrent){
+ double temperature = expCurrent.temperature;
+ double result=0;
+ //Méthode pour faire baisser la température. Il peut y en avoir plusieurs, l'idée étant de pouvoir basculer d'une méthode à l'autre pendant l'algorithme;
+
+ //Van Laarhoven et al. (1987)
+ if (param_coolingSchedule.equals("Van Laarhoven")){
+ double delta=0.001;// Valeur à fixer par l'utilisateur
+ double obj = expCurrent.objective;
+ double sigmasquare=(obj*obj-obj)*(obj*obj-obj);
+ double sigma=Math.sqrt(sigmasquare);
+ result = temperature*(1/(1+(Math.log(1+delta))*temperature/(3*sigma)));
+ }
+ //Huang et al. (1986)
+ if (param_coolingSchedule.equals("Huang")){
+ double lambda =0.5;// 0<lambda<=1 à fixer par l'utilisateur
+ double obj = expCurrent.objective;
+ double sigmasquare=(obj*obj-obj)*(obj*obj-obj);
+ double sigma=Math.sqrt(sigmasquare);
+ result=temperature*Math.exp(-lambda*temperature/sigma);
+ }
+ // Triki et al. (2005)
+ if (param_coolingSchedule.equals("Triki")){
+ double obj = expCurrent.objective;
+ double objCurrent=historique.get(expCurrent.parent.id).objective;
+ double delta=obj-objCurrent;
+ double sigmasquare=(obj*obj-obj)*(obj*obj-obj);
+ result= temperature*(1-temperature*delta/sigmasquare);
+ }
+ // Géométrique (décrit dans Triki et al. (2005))
+ if (param_coolingSchedule.equals("Geometric")){
+ double alpha =0.5; // 0<alpha<1 à fixer par l'utilisateur
+ result=alpha*temperature;
+ }
+ // Lundy et al. (1986)
+ if (param_coolingSchedule.equals("Lundy")){
+ //double beta=???; // Voir à quoi ça correspond
+ //result= temperature*(1/(1+beta*temperature));
+ }
+ // Fixe
+ if (param_coolingSchedule.equals("Constant")){
+ result=temperature; //Il faut fixer une bonne température, voir Cohn et Connolly pour plus de renseignements.
+ }
+ //Linéaire
+ if (param_coolingSchedule.equals("Linear")){
+ //double baisse =???// A fixer par l'utilisateur
+ //result=temperature-baisse;
+ }
+ return result;
+ }
+
+ /**
+ *Initialise une paramétrisation avant la première simulation à partir des bornes de chaque paramètre selon une loi uniforme
+ *@return la paramétrisation initialisée.
+ */
+ public Parameter[] initM1(){
+ //Méthode 1 : initialisation selon une loi uniforme entre les bornes de chaque paramètre.
+ Parameter M1[] = new Parameter[taille];
+ for (int i=0; i<taille; i++){
+ double uni=hasardUniforme();
+ double inf = Double.parseDouble(borneInf[i]);
+ double sup = Double.parseDouble(borneSup[i]);
+ double val= inf+uni*(sup-inf);
+ Parameter param = new Parameter(val, inf, sup);
+ M1[i]=param;
+ }
+
+ //Méthode 2 => On peut proposer plusieurs méthodes d'initiation dans l'interface? Lois de Poisson, Gauss, etc.
+ //etc.
+ return M1;
+ }
+
+ /**
+ * Modify nextSimulation database with parameters in Experience exp.
+ * @param exp the Experience in process
+ * @param nextSimulation storage for the next simulation
+ * @throws Exception
+ */
+ protected void changeDB(Experience exp, SimulationStorage nextSimulation)
+ throws Exception {
+ // methode appelee dans before simualtion
+ TopiaContext db = nextSimulation.getStorage().beginTransaction();//ouvrir un context pour modifier les donnees
+ Population pop = (Population) db.findByTopiaId(param_Population.getTopiaId()); //reccupere la pop ciblee
+ MatrixND c = pop.getCapturability(); // reccupere la matrice de capturabilité
+
+ // *** that is where you explain how to fill the catchability matrix with q1 and q2
+ for (MatrixIterator i = c.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sem = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sem[0];
+
+ // *** exemple when q2 corresponds to the 12 first groups (groups 0 to 11)
+ if (group.getId() < 12) {
+ i.setValue(exp.parametrisation[1].value);
+ } else {
+ i.setValue(exp.parametrisation[0].value);
+ }
+
+ // *** exemple when it depends on seasons and groups
+ /*PopulationSeasonInfo season = (PopulationSeasonInfo) sem[1];
+ if (season.getFirstMonth().after(Month.JULY) && group.getId() >=18){ //month >= aout && groupID >= 18
+ i.setValue(exp.q2);
+ } else {
+ i.setValue(exp.q1);
+ } */
+ }//fin du for
+
+ db.commitTransaction(); // effectue la modification
+ db.closeContext(); // ferme le context
+ }
+
+ /**
+ *Modifie une paramétrisation, utilise une méthode pour modifier paramètre par paramètre
+ *@param M1 la paramétrisation à modifier
+ *@see modifParameter
+ */
+ public void modif(Parameter[] M1){
+ double nbModif=hasard1(); //Une méthode de tirage aléatoire à coder dans une autre méthode (type getPoisson), on la mettre au début du script,
+ while (nbModif >= 0){ //où plusieurs possibilités de tirages sont proposées. L'utilisateur peut y rajouter les siennes.
+ int num=M1.length*hasard2(); //On tire au hasard entre 0 et M1.length-1 une position sur M1.
+ modifParameter(num, M1); //Modification du paramètre
+ nbModif-=1;
+ }
+ }
+
+ /**
+ *Modifie un paramètre selon une certaine méthode, appellée par @see modif
+ *@param num la position dans la paramétrisation du paramètre à modifier
+ */
+ public void modifParameter(int num, Parameter[] M1){
+ //Méthode 1
+ double amplitude = hasard3();
+ double valeur=M1[num].value;
+ M1[num].value=amplitude*valeur;
+ int MAX = 10000;
+ while (MAX > 0 && (M1[num].value<M1[num].inf || M1[num].value>M1[num].sup)){ //Tant qu'on est en dehors du domaine de définiton du paramètre, on modifie la valeur
+ amplitude = hasard3();
+ M1[num].value=amplitude*valeur;
+ MAX--;
+ }
+ /*
+ if (MAX <= 0) {
+ throws SimulationException("Can't find new value");
+ }*/
+ //Méthode 2
+ //etc. L'idée est de faire varier la manièe de faire varier delta en fcontion de l'avancement de l'algorithme.
+ }
+
+ /**
+ *Met en compétition la nouvelle solution et la solution courante (calcul de la "probabilité" d'acceptation) et décide de qui sera la solution courante, le renseigne dans l'historique des simulations.
+ *@param compteurSimus le numéro de la simulation qui vient de s'achever.
+ *@see getProba
+ */
+ public void acceptationSolution(Experience expCurrent){// Mise en compétition de l'état current et du nouvel état
+
+ deltaEnergy= expCurrent.objective - expCurrent.parent.objective;//Valeur absolue
+ double rhoValue = getProba(expCurrent, deltaEnergy);
+ expCurrent.rho = rhoValue;
+ double randValue;
+ if (rhoValue>1){
+ expCurrent.rand = 0;// rand n'a pas été tiré à cette itération.
+ expCurrent.accepted = true;
+ }else{
+ randValue=hasardUniforme();
+ if (randValue<rhoValue){
+ expCurrent.rand = randValue;
+ expCurrent.accepted = true;
+ }
+ else{
+ expCurrent.accepted = false;
+ }
+ }
+ }
+
+ /**
+ *Calcule la valeur de la fonction d'objectif de la paramétrisation utilisée pour la simulation qui vient de s'achever.
+ *@param result le numéro de la simulation venant de s'achever
+ *@return la valeur de fonction d'objectif
+ */
+ public double calculFonctionObjectif(ResultStorage result){//Inclut l'import des données, des résultats de la simulation et le calcul de la fonction d'objectif;
+ /////***import the matrix of simulated data (here landings) from the simulation result
+ MatrixND L = result.getMatrix(param_Population,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ /////*** extract, sum, etc to obtain the same format/data as your observation matrix
+ // useful methods to work on matrix : sumOverDim(), getSubMatrix(), reduce()
+
+ ///////////////////Calcul du critere//////////////////
+ log.info("calcul de la fonction objectif");
+ log.info("dim de L" + " " + Arrays.toString(L.getDim()));
+ log.info("dim de obs" + " "
+ + Arrays.toString(matrixDebarquement.getDim()));
+
+ double obj = 0;
+ // *** using the matrixIterator assumes that the observation and simulated
+ // matrix are organised in the exact same way ( columns and rows corresponding in each of them)
+ for (MatrixIterator g = L.iterator(); g.hasNext();) {
+ g.next();
+ int[] dim = g.getCoordinates();
+ double obs = matrixDebarquement.getValue(dim);
+ double simules = g.getValue();
+ obj += Math.pow(obs - simules, 2);
+ }
+ return obj;
+ }
+
+ /**
+ *Vérifie si le critère d'arrêt de l'algorithme est atteint, les critères pouvant changer selon les préférences de l'utilisateur.
+ *@param compteurSimus le numéro de la simulation qui vient de s'achever
+ *@return true si le critère est atteint, false sinon.
+ */
+ public boolean isCritereArretAtteint(Experience expCurrent){// Critèe à choisir? A rendre variable au cours de l'algorithme? (autant sur le critèe d'une méthode que sur la méthode employée?)
+ //Méthode 1
+ double deltaEnergy = expCurrent.objective - expCurrent.parent.objective;
+ boolean bool = deltaEnergy < seuilArret; //seuil à déterminer
+
+ /*
+ if (temperature<seuilArret) //seuil à déterminer
+ double temperature = getExperience(compteurSimus).temperature
+ bool=true;
+
+ if (compteurSimus>seuilArret) //seuil à déterminer
+ bool=true;
+
+ //Méthode 4 numéro de phase...vraiment?
+ */
+ //etc.
+ return bool;
+ }
+
+ /**
+ *Calcule ce qu'on appelle (abusivement) la probabilité d'accepter la nouvelle paramétrisation, appelée par @see acceptationSolution
+ *@param deltaEnergy la différence de fonction d'objectif entre la nouvelle paramétrisation et la paramétrisation courante
+ *@return la "probabilité"
+ */
+ public double getProba(Experience expCurrent, double deltaEnergy){
+ double temp = expCurrent.temperature;
+ double proba = Math.exp(deltaEnergy/temp);
+ return proba;
+ }
+ /*
+ /**
+ *Vérifie si le critère de modification de la température est atteint, les critères pouvant varier selon les préférences de l'utilisateur.
+ *@return true s'il faut modifier la température (@see modifierTemperature), false sinon.
+ *:/
+ public boolean isModifierTemperature(){//Renvoie un booléen qui indique s'il faut changer ou non la température.
+ boolean bool=false;
+ if (compteurTemperature>seuilTemperature || compteurAccept>seuilAcceptance){//seuils à fixer/déterminer
+ bool=true;
+ }
+ return bool;
+ }
+ */
+
+ /**
+ *Récupère le numéro de la simulation renseignée
+ *@param simulation storage de la simulationr enseignée
+ *@return numéro de la simulation renseignée
+ */
+ public int getIteration(SimulationStorage simulation){ //Il n'y a pas de setIteration
+ return simulation.getParameter().getSimulationPlanNumber();
+ }
+}
\ No newline at end of file
Property changes on: trunk/src/test/resources/test-database/simulationplans/RecuitSimuleSimulateur.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/test/resources/test-database/simulationplans/SimulationNumberRestriction.java
===================================================================
--- trunk/src/test/resources/test-database/simulationplans/SimulationNumberRestriction.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/simulationplans/SimulationNumberRestriction.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package simulationplans;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,11 +47,11 @@
@Doc(value = "do the doc of param max")
public int param_max = 10;
- public String[] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String[] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -68,7 +66,7 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Permit to specify maximum simulation numbers");
+ return "Permit to specify maximum simulation numbers";
}
/**
@@ -85,10 +83,8 @@
/**
* Call before each simulation
*
- * @param context
- * plan context
- * @param nextSimulation
- * storage used for next simulation
+ * @param context plan context
+ * @param nextSimulation storage used for next simulation
* @return true if we must do next simulation, false to stop plan
* @throws Exception
*/
@@ -102,8 +98,7 @@
/**
* Call after each simulation
*
- * @param context
- * plan context
+ * @param context plan context
* @param lastSimulation storage used for last simulation
* @return true if we must do next simulation, false to stop plan
* @throws Exception
Modified: trunk/src/test/resources/test-database/simulators/DefaultSimulator.java
===================================================================
--- trunk/src/test/resources/test-database/simulators/DefaultSimulator.java 2014-07-29 11:59:25 UTC (rev 4073)
+++ trunk/src/test/resources/test-database/simulators/DefaultSimulator.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
+ * Copyright (C) 2006 - 2014 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,24 +19,8 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
-
package simulators;
-import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.n_;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixFactory;
-import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-
-import scripts.GravityModel;
-import scripts.ResultName;
-import scripts.SiMatrix;
import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.entities.Metier;
@@ -51,13 +35,27 @@
import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.Simulator;
+import fr.ifremer.isisfish.types.Month;
import fr.ifremer.isisfish.types.TimeStep;
-import fr.ifremer.isisfish.types.Month;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixFactory;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import scripts.GravityModel;
+import scripts.ResultName;
+import scripts.SiMatrix;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+import static org.nuiton.i18n.I18n.n;
+
/**
* DefaultSimulator.java
*
- * Created: 21 août 2006 10:57:46
+ * Created: 21 aout 2006 10:57:46
*
* @author poussin
* @version $Revision: 1.19 $
@@ -134,12 +132,12 @@
control.setStep(step);
control.setProgress(step.getStep());
- control.setText(_("begin step " + step));
+ control.setText(t("begin step " + step));
//
// Reload parameters for current step
//
- control.setText(_("Reloading parameters"));
+ control.setText(t("Reloading parameters"));
// reload context parameters with db.rollbackTransaction() context
param.reloadContextParameters();
rules = param.getRules();
@@ -217,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) {
@@ -288,9 +287,9 @@
siMatrix.getMetiers(step),
pop.getPopulationGroup(),
pop.getPopulationZone() },
- new String[] { n_("Strategies"),
- n_("Metiers"), n_("Groups"),
- n_("Zones") });
+ new String[] { n("Strategies"),
+ n("Metiers"), n("Groups"),
+ n("Zones") });
}
resManager.addResult(step, pop, discard);
@@ -309,12 +308,11 @@
// add landing result
//
if (resManager.isEnabled(ResultName.MATRIX_LANDING_PER_MET)) {
- MatrixND landing = MatrixFactory.getInstance().create(
- populationMonitor.getCatch(pop));
+ MatrixND landing = populationMonitor.getCatch(pop).copy();
+ landing.setName(ResultName.MATRIX_LANDING_PER_MET);
if (discard != null) {
landing = landing.minus(discard);
}
- landing.setName(ResultName.MATRIX_LANDING_PER_MET);
resManager.addResult(step, pop, landing);
}
}
@@ -338,6 +336,7 @@
//
step = step.next();
}
+
}
protected boolean isEffortByCell(SimulationContext context) {
@@ -375,7 +374,7 @@
PopulationSeasonInfo info = pop.getPopulationSeasonInfo(month);
// group change
- MatrixND CA = null;
+ MatrixND CA;
if (step.getStep() == 0) {
CA = MatrixFactory.getInstance().matrixId(
pop.sizePopulationGroup() * pop.sizePopulationZone());
@@ -411,7 +410,7 @@
log.debug("N after mig: " + N);
- //Recrutement
+ // reproduction
MatrixND R = info.getReproductionMatrix(month, N);
log.debug("R: " + R);
@@ -440,7 +439,7 @@
resManager.addResult(step, pop, biomassBM);
}
- MatrixND abundance = N;
+ MatrixND abundance;
// compute fishing matrix only if there are one or more strategy
if (siMatrix.getStrategies(step).size() > 0) {
// compute some Matrix and add result
@@ -481,7 +480,7 @@
.matrixCatchWeightPerStrategyMetPerZonePop(step, pop,
catchPerStrategyMetPerZonePop);
resManager.addResult(step, pop, catchWeightPerStrategyMet);
- }
+ }
if (isEffortByCell(context)) {
MatrixND catchPerStrategyMetPerZoneMet = siMatrix
@@ -497,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);
@@ -512,7 +526,7 @@
}
/**
- * @param date
+ * @param step
* @param resManager
* @throws IsisFishException
* @throws TopiaException
@@ -555,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
Added: trunk/src/test/resources/test-database/simulators/SimulatorEffortByCell.java
===================================================================
--- trunk/src/test/resources/test-database/simulators/SimulatorEffortByCell.java (rev 0)
+++ trunk/src/test/resources/test-database/simulators/SimulatorEffortByCell.java 2014-07-29 14:44:48 UTC (rev 4074)
@@ -0,0 +1,54 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2009 - 2014 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
+ * published by the Free Software Foundation, either version 3 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-3.0.html>.
+ * #L%
+ */
+
+package simulators;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.simulator.SimulationContext;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.Simulator;
+
+/**
+ * Simulateur qui fixe la valeur de effortByCell a true pour force
+ * l'utilisation des calculs par cellule plutot que par zone.
+ *
+ * @author poussin
+ */
+public class SimulatorEffortByCell implements Simulator {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(SimulatorEffortByCell.class);
+
+ /**
+ * Called by isis don't modify signature
+ */
+ public void simulate(SimulationContext context) throws Exception {
+ SimulationParameter param = context.getSimulationStorage().getParameter();
+ param.getTagValue().put("effortByCell", "true");
+
+ DefaultSimulator simulator = new DefaultSimulator();
+ simulator.simulate(context);
+ }
+
+}
Property changes on: trunk/src/test/resources/test-database/simulators/SimulatorEffortByCell.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
Author: bpoussin
Date: 2014-07-29 13:59:25 +0200 (Tue, 29 Jul 2014)
New Revision: 4073
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4073
Log:
i18n 3.2 work now
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-07-29 11:25:57 UTC (rev 4072)
+++ trunk/pom.xml 2014-07-29 11:59:25 UTC (rev 4073)
@@ -486,7 +486,7 @@
<eugeneVersion>2.7.4</eugeneVersion>
<topiaVersion>2.9.1</topiaVersion>
<hibernateVersion>4.3.6.Final</hibernateVersion>
- <nuitonI18nVersion>3.1</nuitonI18nVersion>
+ <nuitonI18nVersion>3.2</nuitonI18nVersion>
<nuitonWidgetsVersion>1.1.1</nuitonWidgetsVersion>
<redmine.releaseFiles>target/isis-fish-${project.version}-bin.zip</redmine.releaseFiles>
1
0
r4072 - in trunk/src/main/java/fr/ifremer/isisfish: datastore export simulator ui/simulator
by bpoussin@users.forge.codelutin.com 29 Jul '14
by bpoussin@users.forge.codelutin.com 29 Jul '14
29 Jul '14
Author: bpoussin
Date: 2014-07-29 13:25:57 +0200 (Tue, 29 Jul 2014)
New Revision: 4072
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4072
Log:
(continuation) replace string with constante
Modified:
trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java
trunk/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java
trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java
trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java 2014-07-29 10:03:58 UTC (rev 4071)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java 2014-07-29 11:25:57 UTC (rev 4072)
@@ -35,6 +35,9 @@
import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.util.ConverterUtil;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETER_KEY;
+
/**
* Helper used to populate and extract instance parameters
* from simulation.
@@ -65,7 +68,7 @@
//ConvertUtilsBean beanUtils = ConverterUtil.getConverter(region
// .getStorage());
String exportName = JavaSourceStorage.getName(instance);
- String paramTag = propPrefix + "." + instanceIndex + ".parameter.";
+ String paramTag = propPrefix + "." + instanceIndex + DOT + PARAMETER_KEY + DOT;
for (Map.Entry<String, Class<?>> entry : JavaSourceStorage.getParameterNames(instance).entrySet()) {
String propName = entry.getKey();
@@ -120,7 +123,8 @@
Object value = RuleStorage.getParameterValue(instance, paramName);
paramValueString = beanUtils.convert(value);
if (paramValueString != null) {
- result.setProperty(propPrefix + "." + instanceIndex + ".parameter." + paramName, paramValueString);
+ result.setProperty(propPrefix + DOT + instanceIndex
+ + DOT + PARAMETER_KEY + DOT + paramName, paramValueString);
}
} catch (IsisFishException eee) {
if (log.isWarnEnabled()) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java 2014-07-29 10:03:58 UTC (rev 4071)
+++ trunk/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java 2014-07-29 11:25:57 UTC (rev 4072)
@@ -40,6 +40,7 @@
import fr.ifremer.isisfish.datastore.ExportStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.datastore.StorageHelper;
+import fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper;
/**
* Helper for exports manipulation.
@@ -131,7 +132,8 @@
*/
public static void populateSensitivityExport(int exportIndex, TopiaContext context,
SensitivityExport export, Properties props) {
- populateStorageParams(exportIndex, context, export, props, "sensitivityexport");
+ populateStorageParams(exportIndex, context, export, props,
+ SimulationParameterPropertiesHelper.SENSITIVITY_EXPORT_KEY);
}
/**
@@ -146,6 +148,7 @@
*/
public static Properties getSensitivityExportAsProperties(
int sensitivityExportIndex, TopiaContext context, SensitivityExport sensitivityExport) {
- return getParamsAsProperties(sensitivityExportIndex, context, sensitivityExport, "sensitivityexport");
+ return getParamsAsProperties(sensitivityExportIndex, context, sensitivityExport,
+ SimulationParameterPropertiesHelper.SENSITIVITY_EXPORT_KEY);
}
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2014-07-29 10:03:58 UTC (rev 4071)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2014-07-29 11:25:57 UTC (rev 4072)
@@ -81,6 +81,7 @@
import static org.nuiton.i18n.I18n.n;
import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.LIST_SEPARATOR;
/**
* Real {@link SimulationParameter} implementation.
@@ -240,7 +241,7 @@
// if not already set
if (isisFishVersion == null) {
if (propertiesParameters != null) {
- isisFishVersion = propertiesParameters.getProperty("isisFishVersion", "");
+ isisFishVersion = SimulationParameterPropertiesHelper.getIsisFishVersion(propertiesParameters);
} else {
// default value
isisFishVersion = IsisConfig.getVersion();
@@ -265,7 +266,8 @@
if (description == null) {
if (propertiesParameters != null) {
- description = propertiesParameters.getProperty("description", "");
+ description = SimulationParameterPropertiesHelper
+ .getDescription(propertiesParameters);
} else {
// default value
description = "";
@@ -385,8 +387,7 @@
Population population = populationDAO.findByName(name);
populations.add(population);
- String numberAsString = propertiesParameters.getProperty("population." + name + ".number");
- List number = MatrixHelper.convertStringToList(numberAsString);
+ List number = SimulationParameterPropertiesHelper.getPopulationNumbers(propertiesParameters, name);
MatrixND mat = getNumberOf(population);
mat.fromList(number);
} catch (TopiaException eee) {
@@ -455,7 +456,7 @@
String[] strategyList = SimulationParameterPropertiesHelper
.getStrategieNames(propertiesParameters);
for (String name : strategyList) {
- if (name != null && !"".equals(name)) {
+ if (StringUtils.isNotEmpty(name)) {
try {
Strategy str = strategyDAO.findByName(name);
strategies.add(str);
@@ -521,17 +522,18 @@
if (propertiesParameters != null) {
// simulation plan
- String[] planList = propertiesParameters.getProperty("plans",
- "").split(",");
+ String[] planList = SimulationParameterPropertiesHelper
+ .getSimulationPlanNames(propertiesParameters);
int planIndex = 0;
for (String name : planList) {
- if (name != null && !"".equals(name)) {
+ if (StringUtils.isNotEmpty(name)) {
try {
SimulationPlanStorage planStorage = SimulationPlanStorage.getSimulationPlan(name);
if (planStorage != null) { // since 4.0.0.3 can return null
SimulationPlan plan = planStorage.getNewInstance();
StorageHelper.populateStorageParams(planIndex++,
- getRegion().getStorage(), plan, propertiesParameters, "plan");
+ getRegion().getStorage(), plan, propertiesParameters,
+ SimulationParameterPropertiesHelper.PLAN_KEY);
simulationPlans.add(plan);
}
} catch (Exception eee) {
@@ -626,7 +628,7 @@
.getRuleNames(propertiesParameters);
int ruleIndex = 0;
for (String name : ruleList) {
- if (name != null && !"".equals(name)) {
+ if (StringUtils.isNotEmpty(name)) {
try {
Rule rule = RuleStorage.getRule(name).getNewInstance();
RuleHelper.populateRule(ruleIndex++, tx, rule, propertiesParameters);
@@ -683,9 +685,11 @@
// en version < 4.3, le parametre était nommé 'useOptimization'
// qualifiait le cache, il été renommé ensuite
if (VersionUtil.smallerThan(getIsisFishVersion(), "4.3.0.0")) {
- useCache = Boolean.valueOf(propertiesParameters.getProperty("useOptimization", "true"));
+ useCache = Boolean.valueOf(propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.USE_OPTIMIZATION_KEY, "true"));
} else {
- useCache = Boolean.valueOf(propertiesParameters.getProperty("useCache", "true"));
+ useCache = Boolean.valueOf(propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.USE_CACHE_KEY, "true"));
}
} else {
useCache = Boolean.TRUE;
@@ -707,7 +711,7 @@
if (useStatistic == null) {
if (propertiesParameters != null) {
- useStatistic = Boolean.valueOf(propertiesParameters.getProperty("useStatistic", "false"));
+ useStatistic = SimulationParameterPropertiesHelper.getUseStatistic(propertiesParameters);
} else {
useStatistic = Boolean.FALSE;
}
@@ -735,7 +739,7 @@
// exports
String[] exportList = SimulationParameterPropertiesHelper.getExportNames(propertiesParameters);
for (String name : exportList) {
- if (name != null && !"".equals(name)) {
+ if (StringUtils.isNotEmpty(name)) {
exportNames.add(name);
}
}
@@ -788,15 +792,16 @@
if (sensitivityAnalysis == null) {
if (propertiesParameters != null) {
- String analysisName = propertiesParameters
- .getProperty("sensitivityanalysis");
- if (!StringUtils.isEmpty(analysisName)) {
+ String analysisName = SimulationParameterPropertiesHelper
+ .getSensitivityAnalysis(propertiesParameters);
+ if (StringUtils.isNotEmpty(analysisName)) {
try {
SensitivityAnalysisStorage sensitivityStorage = SensitivityAnalysisStorage.getSensitivityAnalysis(analysisName);
sensitivityAnalysis = sensitivityStorage.getNewInstance();
// 0 = only single sensitivity
- StorageHelper.populateStorageParams(0, getRegion().getStorage(), sensitivityAnalysis,
- propertiesParameters, "sensitivity");
+ StorageHelper.populateStorageParams(0, getRegion().getStorage(),
+ sensitivityAnalysis, propertiesParameters,
+ SimulationParameterPropertiesHelper.SENSITIVITY_KEY);
} catch (Exception eee) {
sensitivityAnalysis = null;
if (log.isWarnEnabled()) {
@@ -842,8 +847,8 @@
}
// sensitivity export
- String[] sensitivityExportList = propertiesParameters
- .getProperty("sensitivityexports", "").split(",");
+ String[] sensitivityExportList = SimulationParameterPropertiesHelper
+ .getSensitivityExportNames(propertiesParameters);
int sensitivityExportIndex = 0;
for (String name : sensitivityExportList) {
try {
@@ -895,14 +900,17 @@
public Optimization getOptimization() {
if (optimization == null) {
if (propertiesParameters != null) {
- String optimizationName = propertiesParameters.getProperty("optimization");
+ String optimizationName = SimulationParameterPropertiesHelper
+ .getOptimizationName(propertiesParameters);
if (!StringUtils.isEmpty(optimizationName)) {
try {
- OptimizationStorage optimizationStorage = OptimizationStorage.getOptimization(optimizationName);
+ OptimizationStorage optimizationStorage =
+ OptimizationStorage.getOptimization(optimizationName);
optimization = optimizationStorage.getNewInstance();
// 0 = only single optimization
- StorageHelper.populateStorageParams(0, getRegion().getStorage(), optimization,
- propertiesParameters, "optimization");
+ StorageHelper.populateStorageParams(0, getRegion().getStorage(),
+ optimization, propertiesParameters,
+ SimulationParameterPropertiesHelper.OPTIMIZATION_KEY);
} catch (Exception eee) {
optimization = null;
if (log.isWarnEnabled()) {
@@ -925,7 +933,8 @@
if (VersionUtil.smallerThan(getIsisFishVersion(), "4.3.0.0")) {
useOptimization = Boolean.FALSE;
} else {
- useOptimization = SimulationParameterPropertiesHelper.getUseOptimization(propertiesParameters);
+ useOptimization = Boolean.valueOf(propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.USE_OPTIMIZATION_KEY, "false"));
}
} else {
useOptimization = Boolean.FALSE;
@@ -948,14 +957,17 @@
public Objective getObjective() {
if (objective == null) {
if (propertiesParameters != null) {
- String objectiveName = propertiesParameters.getProperty("objective");
+ String objectiveName = SimulationParameterPropertiesHelper
+ .getObjectiveName(propertiesParameters);
if (!StringUtils.isEmpty(objectiveName)) {
try {
- ObjectiveStorage objectiveStorage = ObjectiveStorage.getObjective(objectiveName);
+ ObjectiveStorage objectiveStorage =
+ ObjectiveStorage.getObjective(objectiveName);
objective = objectiveStorage.getNewInstance();
// 0 = only single objective
- StorageHelper.populateStorageParams(0, getRegion().getStorage(), objective,
- propertiesParameters, "objective");
+ StorageHelper.populateStorageParams(0, getRegion().getStorage(),
+ objective, propertiesParameters,
+ SimulationParameterPropertiesHelper.OBJECTIVE_KEY);
} catch (Exception eee) {
objective = null;
if (log.isWarnEnabled()) {
@@ -994,15 +1006,19 @@
}
// rules
- String[] optimizationExportList = propertiesParameters.getProperty("optimizationexports", "").split(",");
+ String[] optimizationExportList = SimulationParameterPropertiesHelper
+ .getOptimizationExportNames(propertiesParameters);
ConvertUtilsBean beanUtils = ConverterUtil.getConverter(tx);
int optimizationExportIndex = 0;
for (String name : optimizationExportList) {
- if (name != null && !"".equals(name)) {
+ if (StringUtils.isNotBlank(name)) {
try {
Export export = ExportStorage.getExport(name).getNewInstance();
Observation observation = null;
- String observationId = propertiesParameters.getProperty("optimizationobservation." + optimizationExportIndex);
+ String observationId = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.
+ OPTIMIZATION_OBSERVATION_KEY
+ + DOT + optimizationExportIndex);
if (StringUtils.isNotBlank(observationId)) {
observation = (Observation)beanUtils.convert(observationId, TopiaEntity.class);
}
@@ -1116,7 +1132,8 @@
if (numberOfYear == null) {
if (propertiesParameters != null) {
- numberOfYear = Integer.valueOf(propertiesParameters.getProperty("numberOfYear", "1"));
+ numberOfYear = SimulationParameterPropertiesHelper
+ .getNumberOfYear(propertiesParameters);
} else {
numberOfYear = 1;
}
@@ -1190,7 +1207,8 @@
if (generatedPreScript == null) {
if (propertiesParameters != null) {
- generatedPreScript = SimulationParameterPropertiesHelper.getGeneratedPreScript(propertiesParameters);
+ generatedPreScript = SimulationParameterPropertiesHelper
+ .getGeneratedPreScript(propertiesParameters);
} else {
generatedPreScript = "";
}
@@ -1212,7 +1230,8 @@
if (regionName == null) {
if (propertiesParameters != null) {
- regionName = propertiesParameters.getProperty("regionName", "");
+ regionName = SimulationParameterPropertiesHelper
+ .getRegionName(propertiesParameters);
} else {
// defaut value
regionName = "";
@@ -1238,8 +1257,8 @@
if (simulatorName == null) {
if (propertiesParameters != null) {
- simulatorName = propertiesParameters.getProperty(
- "simulatorName", "DefaultSimulator.java");
+ simulatorName = SimulationParameterPropertiesHelper
+ .getSimulatorName(propertiesParameters);
} else {
simulatorName = "DefaultSimulator.java";
}
@@ -1316,7 +1335,8 @@
if (simulLogLevel == null) {
if (propertiesParameters != null) {
- simulLogLevel = SimulationParameterPropertiesHelper.getSimulLogLevel(propertiesParameters);
+ simulLogLevel = SimulationParameterPropertiesHelper
+ .getSimulLogLevel(propertiesParameters);
} else {
simulLogLevel = "info";
}
@@ -1345,7 +1365,8 @@
if (scriptLogLevel == null) {
if (propertiesParameters != null) {
- scriptLogLevel = SimulationParameterPropertiesHelper.getScriptLogLevel(propertiesParameters);
+ scriptLogLevel = SimulationParameterPropertiesHelper
+ .getScriptLogLevel(propertiesParameters);
} else {
scriptLogLevel = "info";
}
@@ -1373,7 +1394,8 @@
public String getLibLogLevel() {
if (libLogLevel == null) {
if (propertiesParameters != null) {
- libLogLevel = SimulationParameterPropertiesHelper.getLibLogLevel(propertiesParameters);
+ libLogLevel = SimulationParameterPropertiesHelper
+ .getLibLogLevel(propertiesParameters);
} else {
libLogLevel = "error";
}
@@ -1634,7 +1656,7 @@
if (populations != null) {
String populationList = "";
for (Population pop : getPopulations()) {
- populationList += pop.getName() + ",";
+ populationList += pop.getName() + LIST_SEPARATOR;
MatrixND number = getNumberOf(pop);
String numberAsString = String.valueOf(number.toList());
result.setProperty(
@@ -1660,7 +1682,7 @@
String ruleList = "";
int ruleIndex = 0;
for (Rule rule : getRules()) {
- ruleList += RuleStorage.getName(rule) + ",";
+ ruleList += RuleStorage.getName(rule) + LIST_SEPARATOR;
Properties ruleProp = RuleHelper.getRuleAsProperties(
ruleIndex++, getRegion().getStorage(), rule);
result.putAll(ruleProp);
@@ -1683,7 +1705,7 @@
String planList = "";
int planIndex = 0;
for (SimulationPlan plan : getSimulationPlans()) {
- planList += SimulationPlanStorage.getName(plan) + ",";
+ planList += SimulationPlanStorage.getName(plan) + LIST_SEPARATOR;
Properties planProp = StorageHelper.getParamsAsProperties(planIndex++,
getRegion().getStorage(), plan, SimulationParameterPropertiesHelper.PLAN_KEY);
result.putAll(planProp);
@@ -1755,7 +1777,7 @@
ConvertUtilsBean beanUtils = ConverterUtil.getConverter(null);
for (Map.Entry<Export, Observation> exportObservationEntry : optimizationExportsObservations.entrySet()) {
Export export = exportObservationEntry.getKey();
- optimizationExportsList += ExportStorage.getName(export) + ",";
+ optimizationExportsList += ExportStorage.getName(export) + LIST_SEPARATOR;
// add in props observation id export index
Observation observation = exportObservationEntry.getValue();
@@ -1783,7 +1805,7 @@
}
// export names
- String exportList = StringUtils.join(getExportNames(), ",");
+ String exportList = StringUtils.join(getExportNames(), LIST_SEPARATOR);
result.setProperty(SimulationParameterPropertiesHelper.EXPORTS_KEY, exportList);
// number of sensitivity simulation
@@ -1821,7 +1843,7 @@
int sensitivityExportIndex = 0;
for (SensitivityExport sensitivityExport : getSensitivityExport()) {
sensitivityExportList += SensitivityExportStorage
- .getName(sensitivityExport) + ",";
+ .getName(sensitivityExport) + LIST_SEPARATOR;
Properties exportProp = ExportHelper.getSensitivityExportAsProperties(
sensitivityExportIndex++, getRegion().getStorage(), sensitivityExport);
result.putAll(exportProp);
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java 2014-07-29 10:03:58 UTC (rev 4071)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java 2014-07-29 11:25:57 UTC (rev 4072)
@@ -3,11 +3,13 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixHelper;
import org.nuiton.util.VersionUtil;
import static org.nuiton.i18n.I18n.t;
@@ -61,14 +63,15 @@
final public static String SENSITIVITY_ANALYSIS_KEY = "sensitivityanalysis";
final public static String SENSITIVITY_KEY = "sensitivity";
final public static String SENSITIVITY_EXPORTS_KEY = "sensitivityexports";
- final public static String SENSITIVITY_EXPORT_KEY = "sensitivityexports";
+ final public static String SENSITIVITY_EXPORT_KEY = "sensitivityexport";
final public static String POPULATION_KEY = "population";
final public static String NUMBER_KEY = "number";
final public static String NUMBER_OF_SENSITIVITY_SIMULATION_KEY = "numberOfSensitivitySimulation";
final public static String SENSITIVITY_ANALYSIS_ONLY_KEEP_FIRST_KEY = "sensitivityAnalysisOnlyKeepFirst";
final public static String TAG_VALUE_KEY = "tagValue";
+ final public static String PARAMETERS_KEY = "parameters";
+ final public static String PARAMETER_KEY = "parameter";
-
public static String getIsisFishVersion(Properties prop) {
String result = prop.getProperty(ISIS_FISH_VERSION_KEY, "");
return result;
@@ -119,7 +122,22 @@
return result;
}
- public static String[] getStrategieNames(Properties prop) {
+ /**
+ * Retourne les effectifs sous forme d'une liste de liste de double
+ * [[2, 3, 4], [5, 6, 7]]
+ *
+ * @param prop
+ * @param popName nom de la population dont on souhaite les effectifs
+ * @return
+ */
+ public static List getPopulationNumbers(Properties prop, String popName) {
+ String numberAsString = prop.getProperty(
+ POPULATION_KEY + DOT + popName + DOT + NUMBER_KEY);
+ List result = MatrixHelper.convertStringToList(numberAsString);
+ return result;
+ }
+
+ public static String[] getStrategieNames(Properties prop) {
String[] result = StringUtils.split(prop.getProperty(STRATEGIES_KEY, ""), LIST_SEPARATOR);
return result;
}
@@ -180,6 +198,16 @@
return result;
}
+ public static String getSensitivityAnalysis(Properties prop) {
+ String result = prop.getProperty(SENSITIVITY_ANALYSIS_KEY);
+ return result;
+ }
+
+ public static String[] getSensitivityExportNames(Properties prop) {
+ String[] result = StringUtils.split(prop.getProperty(SENSITIVITY_EXPORTS_KEY, ""), LIST_SEPARATOR);
+ return result;
+ }
+
public static int getNumberOfSensitivitySimulation(Properties prop) {
int result = Integer.valueOf(prop.getProperty(
NUMBER_OF_SENSITIVITY_SIMULATION_KEY, "-1"));
@@ -208,6 +236,11 @@
return result;
}
+ public static boolean getUseStatistic(Properties prop) {
+ boolean result = Boolean.valueOf(prop.getProperty(USE_STATISTIC_KEY, "false"));
+ return result;
+ }
+
public static String getSimulLogLevel(Properties prop) {
String result = prop.getProperty(SIMUL_LOG_LEVEL_KEY, "info");
return result;
@@ -249,7 +282,7 @@
public static Map<String, String> getParamAsString(Properties prop, String prefix, int index) {
Map<String, String> result = new HashMap<String, String>();
if (prop != null) {
- String paramTag = prefix + DOT + index + ".parameter.";
+ String paramTag = prefix + DOT + index + DOT + PARAMETER_KEY + DOT;
int paramTagLength = paramTag.length();
for (String key : prop.stringPropertyNames()) {
@@ -337,7 +370,7 @@
for (String name : getRuleNames(prop)) {
result.append(t("isisfish.params.toString.rule", name));
result.append('\n');
- for (Map.Entry<String, String> e : getParamAsString(prop, "rule", cpt++).entrySet()) {
+ for (Map.Entry<String, String> e : getParamAsString(prop, RULE_KEY, cpt++).entrySet()) {
result.append("\t").append(e.getKey()).append(" : ").append(e.getValue()).append("\n");
}
result.append("\n");
@@ -350,7 +383,7 @@
for (String plan : getSimulationPlanNames(prop)) {
result.append(t("isisfish.params.toString.plan", plan));
result.append('\n');
- for (Map.Entry<String, String> e : getParamAsString(prop, "plan", cpt++).entrySet()) {
+ for (Map.Entry<String, String> e : getParamAsString(prop, PLAN_KEY, cpt++).entrySet()) {
result.append("\t").append(e.getKey()).append(" : ").append(e.getValue()).append("\n");
}
result.append('\n');
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2014-07-29 10:03:58 UTC (rev 4071)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2014-07-29 11:25:57 UTC (rev 4072)
@@ -102,6 +102,13 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.NUMBER_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETER_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETERS_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.POPULATION_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULE_KEY;
+
/**
* SimulAction.
*
@@ -351,7 +358,8 @@
preRemoveRule((FactorGroup)factor, ruleIndex);
}
else {
- Pattern factorPathPattern = Pattern.compile("^(parameters\\.rule\\.)(\\d+)(.*)$");
+ Pattern factorPathPattern = Pattern.compile(
+ "^(" +PARAMETERS_KEY + "\\" + DOT + RULE_KEY + "\\" + DOT + ")(\\d+)(.*)$");
Matcher factorPathMatcher = factorPathPattern.matcher(factor.getPath());
if (factorPathMatcher.find()) {
Integer index = Integer.parseInt(factorPathMatcher.group(2));
@@ -1247,7 +1255,7 @@
// new factor with rule domain
if (source instanceof RuleChooser) {
- String factorPath = "parameters.rules";
+ String factorPath = PARAMETERS_KEY + DOT + RULE_KEY;
selectedFactor = getFactor(factorPath);
if (selectedFactor == null) {
selectedFactor = new Factor(t("isisfish.sensitivity.rulesfactorname"));
@@ -1259,7 +1267,7 @@
// new factor with matrix continous domain
else if (source instanceof MatrixPanelEditor) {
Population population = (Population)source.getClientProperty("sensitivityPopulation");
- String factorPath = "parameters.population." + population.getName() + ".number";
+ String factorPath = PARAMETERS_KEY + DOT + POPULATION_KEY + DOT + population.getName() + DOT + NUMBER_KEY;
selectedFactor = getFactor(factorPath);
if (selectedFactor == null) {
selectedFactor = new Factor(t("isisfish.sensitivity.populationfactorname", population.getName()));
@@ -1301,7 +1309,8 @@
// with rule list, if a rule is deleted, factor on it must
// be deleted too, et next factor must be renamed
int index = ruleChooser.getRulesList().indexOf(rule);
- String factorPath = "parameters.rule." + index + ".parameter." + paramName;
+ String factorPath = PARAMETERS_KEY + DOT + RULE_KEY + DOT + index + DOT
+ + PARAMETER_KEY + DOT + paramName;
//try {
/*// on a besoin de la valeur pour savoir s'il peut être continue
1
0
r4071 - trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher
by bpoussin@users.forge.codelutin.com 29 Jul '14
by bpoussin@users.forge.codelutin.com 29 Jul '14
29 Jul '14
Author: bpoussin
Date: 2014-07-29 12:03:58 +0200 (Tue, 29 Jul 2014)
New Revision: 4071
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4071
Log:
fixes #3953: When stop simulation, no end date and no statistics in log
Modified:
trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java
trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2014-07-29 08:15:06 UTC (rev 4070)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2014-07-29 10:03:58 UTC (rev 4071)
@@ -89,9 +89,7 @@
protected SimulationStorage simulation;
- /**
- * {@inheritDoc}
- */
+ @Override
public void simulate(SimulationService simulationService,
SimulationItem simulationItem) throws RemoteException {
@@ -355,8 +353,9 @@
//
SimulationContext context = SimulationContext.get();
- context.setSimulationControl(control != null ? control
- : new SimulationControl(simulation.getName()));
+ control = control != null ? control
+ : new SimulationControl(simulation.getName());
+ context.setSimulationControl(control);
// make compile directory outside getCompileDirectory() to improve performance
File compileDirectory = IsisFish.config.getCompileDirectory();
@@ -437,6 +436,11 @@
simulation.getInformation().addInformation(
context.getTimeStepStat().exportText(null).toString());
+ // on ajoute les info sur le resultStorage avant les exports qui
+ // peuvent changer les stats
+ ResultStorage resultStorage = simulation.getResultStorage();
+ simulation.getInformation().addInformation(resultStorage.getInfo());
+
//
// Ajout des nouveaux objets créés durant la simulation
//
@@ -457,22 +461,12 @@
//
context.fireAfterSimulation();
- message(control, t("isisfish.message.simulation.ended"));
-
- simulation.getInformation().setSimulationEnd(new java.util.Date());
-
- // la simulation est termine on avance la progress au dernier cran
- // attention on utilise ca aussi pour detecter la fin d'une simulation
- // quand date =progressMax
- control.setProgress(control.getProgress() + 1);
-
// suppression des résultats si l'utilisateur a demande à ne conserver
// que les resultats de seulement la première simulation d'une AS
- ResultStorage resultStorage = simulation.getResultStorage();
if (parameters.isSensitivityAnalysisOnlyKeepFirst() && !control.getId().endsWith("_0")) {
resultStorage.delete();
}
- simulation.getInformation().addInformation(resultStorage.getInfo());
+
resultStorage.close();
} catch (OutOfMemoryError eee) {
@@ -535,6 +529,17 @@
}
FileUtils.deleteQuietly(simulationBuildDirectory);
+
+ simulation.getInformation().setSimulationEnd(new java.util.Date());
+
+ // la simulation est termine on avance la progress au dernier cran
+ // attention on utilise ca aussi pour detecter la fin d'une simulation
+ // quand date =progressMax
+ control.setProgress(control.getProgress() + 1);
+
+ message(control, t("isisfish.message.simulation.ended"));
+ control.stopSimulation();
+
// context is used in TraceAspect.printStatistiqueAndClear()
SimulationContext.remove();
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java 2014-07-29 08:15:06 UTC (rev 4070)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java 2014-07-29 10:03:58 UTC (rev 4071)
@@ -633,6 +633,11 @@
}
try {
+ // FIXME poussin 20140729 je pense que ca pose probleme qu'un
+ // thread autre que le thread de simulation ferme les storages
+ // surtout que la condition est stopRequest (simulation pas forcement fini)
+ // ca ne poserait pas de probleme si la condition etait isRunning() == false
+ // Et surtout c'est tres bizarre que ce soit le travail d'un Monitor :(
simulation.closeStorage();
simulation.closeMemStorage();
} catch (TopiaException ex) {
1
0
r4070 - trunk/src/main/java/fr/ifremer/isisfish/util
by bpoussin@users.forge.codelutin.com 29 Jul '14
by bpoussin@users.forge.codelutin.com 29 Jul '14
29 Jul '14
Author: bpoussin
Date: 2014-07-29 10:15:06 +0200 (Tue, 29 Jul 2014)
New Revision: 4070
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4070
Log:
- fixes #5552 Ajout du nom du type d'?\195?\169quation dans le nom du fichier Java g?\195?\169n?\195?\169r?\195?\169
- replace deleteOnExit with delete during equation check
Modified:
trunk/src/main/java/fr/ifremer/isisfish/util/EvaluatorHelper.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/util/EvaluatorHelper.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/util/EvaluatorHelper.java 2014-07-24 16:41:17 UTC (rev 4069)
+++ trunk/src/main/java/fr/ifremer/isisfish/util/EvaluatorHelper.java 2014-07-29 08:15:06 UTC (rev 4070)
@@ -143,13 +143,12 @@
*/
public static int check(Class javaInterface, String script, PrintWriter out) {
try {
- File src = File.createTempFile("check", "equation");
- src.deleteOnExit();
+ File src = File.createTempFile("check" + javaInterface.getSimpleName(), "Equation");
+ src.delete(); // delete now, we don't need file, just name to create java file
String packageName = null;
String className = normalizeClassName(src.getName());
-
+
src = new File(src.getParentFile(), className + ".java");
- src.deleteOnExit();
// recherche la methode de l'interface
Method [] methods = javaInterface.getDeclaredMethods();
@@ -161,8 +160,11 @@
int compileResult = CompileHelper.compile(src.getParentFile(), src, src.getParentFile(), out);
File dest = new File(src.getParentFile(), className + ".class");
- dest.deleteOnExit();
+ // no more need file .java and .class remove them now
+ src.delete();
+ dest.delete();
+
return compileResult;
} catch (Exception eee) {
@@ -184,9 +186,11 @@
*/
public static Object evaluate(String packageName, String className,
Class javaInterface, String script, Object... args) {
- className = normalizeClassName(className);
+ // ajout du nom de l'interface dans le nom de la classe pour retrouver
+ // plus facilement a quelle equation correspond les fichiers sur disque.
+ className = javaInterface.getSimpleName() + normalizeClassName(className);
- Object result = null;
+ Object result;
Class clazz = null;
// recherche la methode de l'interface
1
0
Author: bpoussin
Date: 2014-07-24 18:41:17 +0200 (Thu, 24 Jul 2014)
New Revision: 4069
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4069
Log:
use i18n 3.1 (3.2 doesn't work)
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-07-24 15:45:05 UTC (rev 4068)
+++ trunk/pom.xml 2014-07-24 16:41:17 UTC (rev 4069)
@@ -486,7 +486,7 @@
<eugeneVersion>2.7.4</eugeneVersion>
<topiaVersion>2.9.1</topiaVersion>
<hibernateVersion>4.3.6.Final</hibernateVersion>
- <nuitonI18nVersion>3.2</nuitonI18nVersion>
+ <nuitonI18nVersion>3.1</nuitonI18nVersion>
<nuitonWidgetsVersion>1.1.1</nuitonWidgetsVersion>
<redmine.releaseFiles>target/isis-fish-${project.version}-bin.zip</redmine.releaseFiles>
1
0
r4068 - trunk/src/main/java/fr/ifremer/isisfish/util
by bpoussin@users.forge.codelutin.com 24 Jul '14
by bpoussin@users.forge.codelutin.com 24 Jul '14
24 Jul '14
Author: bpoussin
Date: 2014-07-24 17:45:05 +0200 (Thu, 24 Jul 2014)
New Revision: 4068
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4068
Log:
cache resize must be 2 :) 1.3 is not enougth (i found case with 1.6 between min and max)
Modified:
trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java 2014-07-24 15:07:49 UTC (rev 4067)
+++ trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java 2014-07-24 15:45:05 UTC (rev 4068)
@@ -59,7 +59,7 @@
/** number of time steps to cache by interpolating from the first step*/
// perhaps allow the configuration
- static public double CACHE_STEP = 1.3; // between 2 step, cache size is very close: 1.3 seem correct
+ static public double CACHE_STEP = 2; // between 2 step, cache size is very close: 2 seem correct
static public class IsisCacheBackendOnGuavaFactory implements IsisCacheBackend.Factory {
@Override
1
0
r4067 - trunk/src/main/java/fr/ifremer/isisfish/simulator
by bpoussin@users.forge.codelutin.com 24 Jul '14
by bpoussin@users.forge.codelutin.com 24 Jul '14
24 Jul '14
Author: bpoussin
Date: 2014-07-24 17:07:49 +0200 (Thu, 24 Jul 2014)
New Revision: 4067
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4067
Log:
replace string with const and move some code in helper
Modified:
trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java
trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2014-07-24 14:44:06 UTC (rev 4066)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2014-07-24 15:07:49 UTC (rev 4067)
@@ -54,7 +54,6 @@
import fr.ifremer.isisfish.IsisConfig;
import fr.ifremer.isisfish.IsisFishDAOHelper;
-import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.datastore.ExportStorage;
import fr.ifremer.isisfish.datastore.ObjectiveStorage;
import fr.ifremer.isisfish.datastore.OptimizationStorage;
@@ -76,12 +75,13 @@
import fr.ifremer.isisfish.rule.RuleHelper;
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityAnalysis;
import fr.ifremer.isisfish.util.ConverterUtil;
-import fr.ifremer.isisfish.util.StringConverter;
-import fr.ifremer.isisfish.util.TopiaEntityConverter;
+import java.util.Collections;
import org.apache.commons.beanutils.ConvertUtilsBean;
import static org.nuiton.i18n.I18n.n;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT;
+
/**
* Real {@link SimulationParameter} implementation.
*
@@ -733,7 +733,7 @@
if (propertiesParameters != null) {
// exports
- String[] exportList = propertiesParameters.getProperty("exports", "").split(",");
+ String[] exportList = SimulationParameterPropertiesHelper.getExportNames(propertiesParameters);
for (String name : exportList) {
if (name != null && !"".equals(name)) {
exportNames.add(name);
@@ -761,8 +761,8 @@
if (numberOfSensitivitySimulation == null) {
if (propertiesParameters != null) {
- numberOfSensitivitySimulation = Integer.valueOf(propertiesParameters.getProperty(
- "numberOfSensitivitySimulation", "-1"));
+ numberOfSensitivitySimulation =
+ SimulationParameterPropertiesHelper.getNumberOfSensitivitySimulation(propertiesParameters);
} else {
numberOfSensitivitySimulation = -1;
}
@@ -925,7 +925,7 @@
if (VersionUtil.smallerThan(getIsisFishVersion(), "4.3.0.0")) {
useOptimization = Boolean.FALSE;
} else {
- useOptimization = Boolean.valueOf(propertiesParameters.getProperty("useOptimization", "false"));
+ useOptimization = SimulationParameterPropertiesHelper.getUseOptimization(propertiesParameters);
}
} else {
useOptimization = Boolean.FALSE;
@@ -1046,7 +1046,7 @@
if (useSimulationPlan == null) {
if (propertiesParameters != null) {
- useSimulationPlan = Boolean.valueOf(propertiesParameters.getProperty("useSimulationPlan", "false"));
+ useSimulationPlan = SimulationParameterPropertiesHelper.getUseSimulationPlan(propertiesParameters);
} else {
useSimulationPlan = Boolean.FALSE;
}
@@ -1071,7 +1071,7 @@
if (simulationPlanNumber == null) {
if (propertiesParameters != null) {
- simulationPlanNumber = Integer.valueOf(propertiesParameters.getProperty("simulationPlanNumber", "-1"));
+ simulationPlanNumber = SimulationParameterPropertiesHelper.getSimulationPlanNumber(propertiesParameters);
} else {
simulationPlanNumber = -1;
}
@@ -1093,7 +1093,7 @@
if (sensitivityAnalysisOnlyKeepFirst == null) {
if (propertiesParameters != null) {
- sensitivityAnalysisOnlyKeepFirst = Boolean.valueOf(propertiesParameters.getProperty("sensitivityAnalysisOnlyKeepFirst", "-1"));
+ sensitivityAnalysisOnlyKeepFirst = SimulationParameterPropertiesHelper.isSensitivityAnalysisOnlyKeepFirst(propertiesParameters);
} else {
sensitivityAnalysisOnlyKeepFirst = Boolean.FALSE;
}
@@ -1141,7 +1141,7 @@
if (usePreScript == null) {
if (propertiesParameters != null) {
- usePreScript = Boolean.valueOf(propertiesParameters.getProperty("usePreScript", "false"));
+ usePreScript = SimulationParameterPropertiesHelper.getUsePreScript(propertiesParameters);
} else {
usePreScript = Boolean.FALSE;
}
@@ -1167,7 +1167,7 @@
if (preScript == null) {
if (propertiesParameters != null) {
- preScript = propertiesParameters.getProperty("preScript", "");
+ preScript = SimulationParameterPropertiesHelper.getPreScript(propertiesParameters);
} else {
preScript = "";
}
@@ -1190,7 +1190,7 @@
if (generatedPreScript == null) {
if (propertiesParameters != null) {
- generatedPreScript = propertiesParameters.getProperty("generatedPreScript", "");
+ generatedPreScript = SimulationParameterPropertiesHelper.getGeneratedPreScript(propertiesParameters);
} else {
generatedPreScript = "";
}
@@ -1266,12 +1266,9 @@
resultEnabled = new LinkedList<String>();
if (propertiesParameters != null) {
- String[] resultList = propertiesParameters.getProperty("resultNames", "").split(",");
- for (String name : resultList) {
- if (name != null && !"".equals(name)) {
- resultEnabled.add(name);
- }
- }
+ String[] resultList =
+ SimulationParameterPropertiesHelper.getResultNames(propertiesParameters);
+ Collections.addAll(resultEnabled, resultList);
}
}
return resultEnabled;
@@ -1292,16 +1289,10 @@
public Map<String, String> getTagValue() {
if (tagValue == null) {
- tagValue = new LinkedHashMap<String, String>();
-
if (propertiesParameters != null) {
- for (Object k : propertiesParameters.keySet()) {
- if (k.toString().startsWith("tagValue.")) {
- String key = k.toString().substring("tagValue.".length());
- String value = propertiesParameters.getProperty(k.toString());
- getTagValue().put(key, value);
- }
- }
+ tagValue = SimulationParameterPropertiesHelper.getTagValue(propertiesParameters);
+ } else {
+ tagValue = new LinkedHashMap<String, String>();
}
}
@@ -1325,7 +1316,7 @@
if (simulLogLevel == null) {
if (propertiesParameters != null) {
- simulLogLevel = propertiesParameters.getProperty("simulLogLevel", "info");
+ simulLogLevel = SimulationParameterPropertiesHelper.getSimulLogLevel(propertiesParameters);
} else {
simulLogLevel = "info";
}
@@ -1354,8 +1345,7 @@
if (scriptLogLevel == null) {
if (propertiesParameters != null) {
- scriptLogLevel = propertiesParameters.getProperty(
- "scriptLogLevel", "info");
+ scriptLogLevel = SimulationParameterPropertiesHelper.getScriptLogLevel(propertiesParameters);
} else {
scriptLogLevel = "info";
}
@@ -1383,7 +1373,7 @@
public String getLibLogLevel() {
if (libLogLevel == null) {
if (propertiesParameters != null) {
- libLogLevel = propertiesParameters.getProperty("libLogLevel", "error");
+ libLogLevel = SimulationParameterPropertiesHelper.getLibLogLevel(propertiesParameters);
} else {
libLogLevel = "error";
}
@@ -1614,25 +1604,29 @@
public Properties toProperties() {
Properties result = new SortedProperties();
- result.setProperty("isisFishVersion", getIsisFishVersion());
- result.setProperty("description", getDescription());
- result.setProperty("regionName", getRegionName());
- result.setProperty("numberOfYear", String.valueOf(getNumberOfYear()));
- result.setProperty("simulatorName", getSimulatorName());
- result.setProperty("useCache", String.valueOf(getUseCache()));
- result.setProperty("useStatistic", String.valueOf(getUseStatistic()));
+ result.setProperty(SimulationParameterPropertiesHelper.ISIS_FISH_VERSION_KEY, getIsisFishVersion());
+ result.setProperty(SimulationParameterPropertiesHelper.DESCRIPTION_KEY, getDescription());
+ result.setProperty(SimulationParameterPropertiesHelper.REGION_NAME_KEY, getRegionName());
+ result.setProperty(SimulationParameterPropertiesHelper.NUMBER_OF_YEAR_KEY, String.valueOf(getNumberOfYear()));
+ result.setProperty(SimulationParameterPropertiesHelper.SIMULATOR_NAME_KEY, getSimulatorName());
+ result.setProperty(SimulationParameterPropertiesHelper.USE_CACHE_KEY, String.valueOf(getUseCache()));
+ result.setProperty(SimulationParameterPropertiesHelper.USE_STATISTIC_KEY, String.valueOf(getUseStatistic()));
// strategies
if (strategies != null) {
String strategyList = "";
for (Strategy str : getStrategies()) {
- strategyList += str.getName() + ",";
+ strategyList += str.getName() + SimulationParameterPropertiesHelper.LIST_SEPARATOR;
}
- result.setProperty("strategies", StringUtil.substring(strategyList, 0, -1));
+ result.setProperty(SimulationParameterPropertiesHelper.STRATEGIES_KEY,
+ StringUtil.substring(strategyList, 0, -1));
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("strategies")) {
- result.setProperty("strategies", propertiesParameters.getProperty("strategies"));
+ if (propertiesParameters != null) {
+ String strs = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.STRATEGIES_KEY);
+ if (strs != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.STRATEGIES_KEY, strs);
+ }
}
}
@@ -1643,18 +1637,20 @@
populationList += pop.getName() + ",";
MatrixND number = getNumberOf(pop);
String numberAsString = String.valueOf(number.toList());
- result.setProperty("population." + pop.getName() + ".number", numberAsString);
+ result.setProperty(
+ SimulationParameterPropertiesHelper.POPULATION_KEY+ DOT + pop.getName()
+ + DOT + SimulationParameterPropertiesHelper.NUMBER_KEY, numberAsString);
}
- result.setProperty("populations", StringUtil.substring(
- populationList, 0, -1));
+ result.setProperty(SimulationParameterPropertiesHelper.POPULATIONS_KEY,
+ StringUtil.substring(populationList, 0, -1));
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("populations")) {
- result.setProperty("populations", propertiesParameters.getProperty("populations"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("population.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String pops = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.POPULATIONS_KEY);
+ if (pops != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.POPULATIONS_KEY, pops);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.POPULATION_KEY + DOT);
}
}
}
@@ -1665,20 +1661,19 @@
int ruleIndex = 0;
for (Rule rule : getRules()) {
ruleList += RuleStorage.getName(rule) + ",";
- Properties ruleProp = RuleHelper.getRuleAsProperties(ruleIndex++, getRegion().getStorage(), rule);
+ Properties ruleProp = RuleHelper.getRuleAsProperties(
+ ruleIndex++, getRegion().getStorage(), rule);
result.putAll(ruleProp);
}
- result.setProperty("rules", ruleList);
+ result.setProperty(SimulationParameterPropertiesHelper.RULES_KEY, ruleList);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("rules")) {
- result.setProperty("rules", propertiesParameters
- .getProperty("rules"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("rule.")) {
- result.setProperty(key, propertiesParameters
- .getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String rules = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.RULES_KEY);
+ if (rules != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.RULES_KEY, rules);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.RULE_KEY + DOT);
}
}
}
@@ -1690,19 +1685,18 @@
for (SimulationPlan plan : getSimulationPlans()) {
planList += SimulationPlanStorage.getName(plan) + ",";
Properties planProp = StorageHelper.getParamsAsProperties(planIndex++,
- getRegion().getStorage(), plan, "plan");
+ getRegion().getStorage(), plan, SimulationParameterPropertiesHelper.PLAN_KEY);
result.putAll(planProp);
}
- result.setProperty("plans", planList);
+ result.setProperty(SimulationParameterPropertiesHelper.PLANS_KEY, planList);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("plans")) {
- result.setProperty("plans", propertiesParameters
- .getProperty("plans"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("plan.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String plans = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.PLANS_KEY);
+ if (plans != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.PLANS_KEY, plans);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.PLAN_KEY + DOT);
}
}
}
@@ -1711,19 +1705,25 @@
if (objective != null) {
String objectiveName = ObjectiveStorage.getName(objective);
Properties objectiveProp = StorageHelper.getParamsAsProperties(0,
- getRegion().getStorage(), objective, "objective");
+ getRegion().getStorage(), objective,
+ SimulationParameterPropertiesHelper.OBJECTIVE_KEY);
result.putAll(objectiveProp);
- result.setProperty("objective", objectiveName);
+ result.setProperty(SimulationParameterPropertiesHelper.OBJECTIVE_KEY,
+ objectiveName);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("objective")) {
- result.setProperty("objective", propertiesParameters
- .getProperty("objective"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("objective.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
+ if (propertiesParameters != null) {
+ String objective = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.OBJECTIVE_KEY);
+ if (objective != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.OBJECTIVE_KEY, objective);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.OBJECTIVE_KEY + DOT);
+ } for (String key : propertiesParameters.stringPropertyNames()) {
+ if (key.startsWith(SimulationParameterPropertiesHelper.OBJECTIVE_KEY + DOT)) {
+ result.setProperty(key, propertiesParameters.getProperty(key));
+ }
}
- }
+
}
}
@@ -1731,18 +1731,19 @@
if (optimization != null) {
String optimizationName = ObjectiveStorage.getName(optimization);
Properties optimizationProp = StorageHelper.getParamsAsProperties(0,
- getRegion().getStorage(), optimization, "optimization");
+ getRegion().getStorage(), optimization,
+ SimulationParameterPropertiesHelper.OPTIMIZATION_KEY);
result.putAll(optimizationProp);
- result.setProperty("optimization", optimizationName);
+ result.setProperty(SimulationParameterPropertiesHelper.OPTIMIZATION_KEY,
+ optimizationName);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("optimization")) {
- result.setProperty("optimization", propertiesParameters
- .getProperty("optimization"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("optimization.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String optimization = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.OPTIMIZATION_KEY);
+ if (optimization != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.OPTIMIZATION_KEY, optimization);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.OPTIMIZATION_KEY + DOT);
}
}
}
@@ -1759,55 +1760,57 @@
// add in props observation id export index
Observation observation = exportObservationEntry.getValue();
if (observation != null) {
- result.setProperty("optimizationobservation." + optimizationExportIndex, beanUtils.convert(observation));
+ result.setProperty(
+ SimulationParameterPropertiesHelper.OPTIMIZATION_OBSERVATION_KEY + DOT
+ + optimizationExportIndex,
+ beanUtils.convert(observation));
}
optimizationExportIndex++;
}
- result.setProperty("optimizationexports", optimizationExportsList);
+ result.setProperty(SimulationParameterPropertiesHelper.OPTIMIZATION_EXPORTS_KEY,
+ optimizationExportsList);
} else {
if (propertiesParameters != null) {
- if (propertiesParameters.containsKey("optimizationexports")) {
- result.setProperty("optimizationexports", propertiesParameters.getProperty("optimizationexports"));
+ String optimizationExports = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.OPTIMIZATION_EXPORTS_KEY);
+ if (optimizationExports != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.OPTIMIZATION_EXPORTS_KEY,
+ optimizationExports);
}
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("optimizationobservation.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
- }
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.OPTIMIZATION_OBSERVATION_KEY + DOT);
}
}
// export names
- String exportList = "";
- for (String export : getExportNames()) {
- exportList += export + ",";
+ String exportList = StringUtils.join(getExportNames(), ",");
+ result.setProperty(SimulationParameterPropertiesHelper.EXPORTS_KEY, exportList);
- }
- result.setProperty("exports", exportList);
-
// number of sensitivity simulation
- result.setProperty("numberOfSensitivitySimulation", String
- .valueOf(getNumberOfSensitivitySimulation()));
+ result.setProperty(SimulationParameterPropertiesHelper.NUMBER_OF_SENSITIVITY_SIMULATION_KEY,
+ String.valueOf(getNumberOfSensitivitySimulation()));
// analysis name
if (sensitivityAnalysis != null) {
String analysisName = SensitivityAnalysisStorage
.getName(getSensitivityAnalysis());
- result.setProperty("sensitivityanalysis", analysisName);
+ result.setProperty(SimulationParameterPropertiesHelper.SENSITIVITY_ANALYSIS_KEY,
+ analysisName);
// analysis parameter
Properties analysisParams = StorageHelper.getParamsAsProperties(0,
- getRegion().getStorage(), getSensitivityAnalysis(), "sensitivity");
+ getRegion().getStorage(), getSensitivityAnalysis(),
+ SimulationParameterPropertiesHelper.SENSITIVITY_KEY);
result.putAll(analysisParams);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("sensitivityanalysis")) {
- result.setProperty("sensitivityanalysis",
- propertiesParameters.getProperty("sensitivityanalysis"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("sensitivity.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String sensitivityanalysis = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.SENSITIVITY_ANALYSIS_KEY);
+ if (sensitivityanalysis != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.SENSITIVITY_ANALYSIS_KEY,
+ sensitivityanalysis);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.SENSITIVITY_KEY + DOT);
}
}
}
@@ -1823,43 +1826,53 @@
sensitivityExportIndex++, getRegion().getStorage(), sensitivityExport);
result.putAll(exportProp);
}
- result.setProperty("sensitivityexports", sensitivityExportList);
+ result.setProperty(SimulationParameterPropertiesHelper.SENSITIVITY_EXPORTS_KEY,
+ sensitivityExportList);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("sensitivityexports")) {
- result.setProperty("sensitivityexports", propertiesParameters
- .getProperty("sensitivityexports"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("sensitivityexport.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String sensitivityexports = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.SENSITIVITY_EXPORTS_KEY);
+ if (sensitivityexports != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.SENSITIVITY_EXPORTS_KEY,
+ sensitivityexports);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.SENSITIVITY_EXPORTS_KEY + DOT);
}
}
}
// sensitivity params
- result.setProperty("sensitivityAnalysisOnlyKeepFirst", String.valueOf(isSensitivityAnalysisOnlyKeepFirst()));
+ result.setProperty(SimulationParameterPropertiesHelper.SENSITIVITY_ANALYSIS_ONLY_KEEP_FIRST_KEY,
+ String.valueOf(isSensitivityAnalysisOnlyKeepFirst()));
- result.setProperty("generatedPreScript", getGeneratedPreScript());
- result.setProperty("usePreScript", String.valueOf(getUsePreScript()));
- result.setProperty("preScript", getPreScript());
- result.setProperty("useSimulationPlan", String.valueOf(getUseSimulationPlan()));
- result.setProperty("simulationPlanNumber", String.valueOf(getSimulationPlanNumber()));
- result.setProperty("useOptimization", String.valueOf(getUseOptimization()));
+ result.setProperty(SimulationParameterPropertiesHelper.GENERATED_PRE_SCRIPT_KEY,
+ getGeneratedPreScript());
+ result.setProperty(SimulationParameterPropertiesHelper.USE_PRE_SCRIPT_KEY,
+ String.valueOf(getUsePreScript()));
+ result.setProperty(SimulationParameterPropertiesHelper.PRE_SCRIPT_KEY,
+ getPreScript());
+ result.setProperty(SimulationParameterPropertiesHelper.USE_SIMULATION_PLAN_KEY,
+ String.valueOf(getUseSimulationPlan()));
+ result.setProperty(SimulationParameterPropertiesHelper.SIMULATION_PLAN_NUMBER_KEY,
+ String.valueOf(getSimulationPlanNumber()));
+ result.setProperty(SimulationParameterPropertiesHelper.USE_OPTIMIZATION_KEY,
+ String.valueOf(getUseOptimization()));
- String resultList = "";
- for (String r : getResultEnabled()) {
- resultList += r + ",";
- }
- result.setProperty("resultNames", resultList);
+ String resultList = StringUtils.join(getResultEnabled(),
+ SimulationParameterPropertiesHelper.LIST_SEPARATOR);
+ result.setProperty(SimulationParameterPropertiesHelper.RESULT_NAMES_KEY, resultList);
for (Map.Entry<String, String> e : getTagValue().entrySet()) {
- result.setProperty("tagValue." + e.getKey(), e.getValue());
+ result.setProperty(SimulationParameterPropertiesHelper.TAG_VALUE_KEY+ DOT
+ + e.getKey(), e.getValue());
}
- result.setProperty("simulLogLevel", getSimulLogLevel());
- result.setProperty("scriptLogLevel", getScriptLogLevel());
- result.setProperty("libLogLevel", getLibLogLevel());
+ result.setProperty(SimulationParameterPropertiesHelper.SIMUL_LOG_LEVEL_KEY,
+ getSimulLogLevel());
+ result.setProperty(SimulationParameterPropertiesHelper.SCRIPT_LOG_LEVEL_KEY,
+ getScriptLogLevel());
+ result.setProperty(SimulationParameterPropertiesHelper.LIB_LOG_LEVEL_KEY,
+ getLibLogLevel());
return result;
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java 2014-07-24 14:44:06 UTC (rev 4066)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java 2014-07-24 15:07:49 UTC (rev 4067)
@@ -2,6 +2,7 @@
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
@@ -26,11 +27,18 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
final static private Log log = LogFactory.getLog(SimulationParameterPropertiesHelper.class);
+ final public static String DOT = ".";
+ final public static String LIST_SEPARATOR = ",";
+
final public static String ISIS_FISH_VERSION_KEY = "isisFishVersion";
final public static String SIMULATOR_NAME_KEY = "simulatorName";
final public static String POPULATIONS_KEY = "populations";
final public static String RULES_KEY = "rules";
+ final public static String RULE_KEY = "rule";
+ final public static String RESULT_NAMES_KEY = "resultNames";
+ final public static String EXPORTS_KEY = "exports";
final public static String PLANS_KEY = "plans";
+ final public static String PLAN_KEY = "plan";
final public static String STRATEGIES_KEY = "strategies";
final public static String DESCRIPTION_KEY = "description";
final public static String REGION_NAME_KEY = "regionName";
@@ -40,14 +48,27 @@
final public static String OPTIMIZATION_KEY = "optimization";
final public static String OBJECTIVE_KEY = "objective";
final public static String OPTIMIZATION_EXPORTS_KEY = "optimizationexports";
+ final public static String OPTIMIZATION_OBSERVATION_KEY = "optimizationobservation";
final public static String USE_CACHE_KEY = "useCache";
+ final public static String USE_STATISTIC_KEY = "useStatistic";
final public static String NUMBER_OF_YEAR_KEY = "numberOfYear";
final public static String GENERATED_PRE_SCRIPT_KEY = "generatedPreScript";
+ final public static String USE_PRE_SCRIPT_KEY = "usePreScript";
final public static String PRE_SCRIPT_KEY = "preScript";
final public static String SIMUL_LOG_LEVEL_KEY = "simulLogLevel";
- final public static String SCRIPT_LOG_LEVEL_KEY = "simulLogLevel";
- final public static String LIB_LOG_LEVEL_KEY = "simulLogLevel";
+ final public static String SCRIPT_LOG_LEVEL_KEY = "scriptLogLevel";
+ final public static String LIB_LOG_LEVEL_KEY = "libLogLevel";
+ final public static String SENSITIVITY_ANALYSIS_KEY = "sensitivityanalysis";
+ final public static String SENSITIVITY_KEY = "sensitivity";
+ final public static String SENSITIVITY_EXPORTS_KEY = "sensitivityexports";
+ final public static String SENSITIVITY_EXPORT_KEY = "sensitivityexports";
+ final public static String POPULATION_KEY = "population";
+ final public static String NUMBER_KEY = "number";
+ final public static String NUMBER_OF_SENSITIVITY_SIMULATION_KEY = "numberOfSensitivitySimulation";
+ final public static String SENSITIVITY_ANALYSIS_ONLY_KEEP_FIRST_KEY = "sensitivityAnalysisOnlyKeepFirst";
+ final public static String TAG_VALUE_KEY = "tagValue";
+
public static String getIsisFishVersion(Properties prop) {
String result = prop.getProperty(ISIS_FISH_VERSION_KEY, "");
return result;
@@ -94,26 +115,36 @@
}
public static String[] getPopulationNames(Properties prop) {
- String[] result = prop.getProperty(POPULATIONS_KEY, "").split(",");
+ String[] result = StringUtils.split(prop.getProperty(POPULATIONS_KEY, ""), LIST_SEPARATOR);
return result;
}
public static String[] getStrategieNames(Properties prop) {
- String[] result = prop.getProperty(STRATEGIES_KEY, "").split(",");
+ String[] result = StringUtils.split(prop.getProperty(STRATEGIES_KEY, ""), LIST_SEPARATOR);
return result;
}
public static String[] getRuleNames(Properties prop) {
- String[] result = prop.getProperty(RULES_KEY, "").split(",");
+ String[] result = StringUtils.split(prop.getProperty(RULES_KEY, ""), LIST_SEPARATOR);
return result;
}
+ public static String[] getResultNames(Properties prop) {
+ String[] result = StringUtils.split(prop.getProperty(RESULT_NAMES_KEY, ""), LIST_SEPARATOR);
+ return result;
+ }
+
+ public static String[] getExportNames(Properties prop) {
+ String[] result = StringUtils.split(prop.getProperty(EXPORTS_KEY, ""), LIST_SEPARATOR);
+ return result;
+ }
+
public static String[] getSimulationPlanNames(Properties prop) {
- String[] result = prop.getProperty(PLANS_KEY, "").split(",");
+ String[] result = StringUtils.split(prop.getProperty(PLANS_KEY, ""), LIST_SEPARATOR);
return result;
}
- private static boolean getUseOptimization(Properties prop) {
+ public static boolean getUseOptimization(Properties prop) {
boolean result;
// en version < 4.3, le parametre était nommé 'useOptimization'
// qualifiant le cache, il a été renommé ensuite
@@ -136,12 +167,12 @@
}
public static String[] getOptimizationExportNames(Properties prop) {
- String[] result = prop.getProperty(OPTIMIZATION_EXPORTS_KEY, "").split(",");
+ String[] result = StringUtils.split(prop.getProperty(OPTIMIZATION_EXPORTS_KEY, ""), LIST_SEPARATOR);
return result;
}
public static String getOptimizationObservationName(Properties prop, int index) {
- String result = prop.getProperty("optimizationobservation" + "." + index, "");
+ String result = prop.getProperty(OPTIMIZATION_OBSERVATION_KEY + DOT + index, "");
if (result.matches("[\\w.]+#[\\d.]+#[\\d.]+:(.+)")) {
result = result.replaceFirst("[\\w.]+#[\\d.]+#[\\d.]+:(.+)", "$1");
}
@@ -149,11 +180,29 @@
return result;
}
+ public static int getNumberOfSensitivitySimulation(Properties prop) {
+ int result = Integer.valueOf(prop.getProperty(
+ NUMBER_OF_SENSITIVITY_SIMULATION_KEY, "-1"));
+ return result;
+ }
+
+ public static boolean isSensitivityAnalysisOnlyKeepFirst(Properties prop) {
+ boolean result = Boolean.valueOf(prop.getProperty(
+ SENSITIVITY_ANALYSIS_ONLY_KEEP_FIRST_KEY, "-1"));
+ return result;
+ }
+
+
public static String getGeneratedPreScript(Properties prop) {
String result = prop.getProperty(GENERATED_PRE_SCRIPT_KEY, "");
return result;
}
+ public static boolean getUsePreScript(Properties prop) {
+ boolean result = Boolean.valueOf(prop.getProperty(USE_PRE_SCRIPT_KEY, "false"));
+ return result;
+ }
+
public static String getPreScript(Properties prop) {
String result = prop.getProperty(PRE_SCRIPT_KEY, "");
return result;
@@ -174,6 +223,20 @@
return result;
}
+ public static Map<String, String> getTagValue(Properties prop) {
+ int tagValueLength = (TAG_VALUE_KEY + DOT).length();
+ // preserve order
+ Map<String, String> result = new LinkedHashMap<String, String>();
+ for (String k : prop.stringPropertyNames()) {
+ if (k.startsWith(TAG_VALUE_KEY + DOT)) {
+ String key = k.substring(tagValueLength);
+ String value = prop.getProperty(k);
+ result.put(key, value);
+ }
+ }
+ return result;
+ }
+
/**
* Retourne les parametres sous forme de String pour une regles. Les regles
* sont numeroter dans l'ordre dans lequel on les recupere via #getRuleNames().
@@ -186,7 +249,7 @@
public static Map<String, String> getParamAsString(Properties prop, String prefix, int index) {
Map<String, String> result = new HashMap<String, String>();
if (prop != null) {
- String paramTag = prefix + "." + index + ".parameter.";
+ String paramTag = prefix + DOT + index + ".parameter.";
int paramTagLength = paramTag.length();
for (String key : prop.stringPropertyNames()) {
@@ -205,6 +268,21 @@
return result;
}
+ /**
+ * Copy all entry beginning with prefix from source to target
+ *
+ * @param source
+ * @param target
+ * @param prefix
+ */
+ public static void copy(Properties source, Properties target, String prefix) {
+ for (String key : source.stringPropertyNames()) {
+ if (StringUtils.startsWith(key, prefix)) {
+ target.setProperty(key, source.getProperty(key));
+ }
+ }
+ }
+
public static String toString(Properties prop) {
StringBuilder result = new StringBuilder();
result.append(
@@ -241,7 +319,7 @@
String sep = "";
for (String str : strs) {
result.append(sep).append(str);
- sep = ",";
+ sep = LIST_SEPARATOR;
}
result.append("\n\n");
@@ -250,7 +328,7 @@
sep = "";
for (String pop : getPopulationNames(prop)) {
result.append(sep).append(pop);
- sep = ",";
+ sep = LIST_SEPARATOR;
}
result.append("\n\n");
@@ -324,13 +402,16 @@
.append(":\n");
result.append(genScript);
}
- String prescript = getPreScript(prop);
- if (StringUtils.isNotBlank(prescript)) {
- result.append('\n');
- result.append(t("isisfish.params.toString.script.presimulation"))
- .append(":\n");
- result.append(prescript);
+ if (getUsePreScript(prop)) {
+ String prescript = getPreScript(prop);
+ if (StringUtils.isNotBlank(prescript)) {
+ result.append('\n');
+ result.append(t("isisfish.params.toString.script.presimulation"))
+ .append(":\n");
+ result.append(prescript);
+ }
}
+
result.append('\n');
result.append(t("isisfish.params.toString.simul.logger.level",
getSimulLogLevel(prop)));
1
0
r4066 - trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher
by echatellier@users.forge.codelutin.com 24 Jul '14
by echatellier@users.forge.codelutin.com 24 Jul '14
24 Jul '14
Author: echatellier
Date: 2014-07-24 16:44:06 +0200 (Thu, 24 Jul 2014)
New Revision: 4066
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4066
Log:
Fix i18n _
Modified:
trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationPlanPrepareJob.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationPlanPrepareJob.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationPlanPrepareJob.java 2014-07-24 14:41:53 UTC (rev 4065)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationPlanPrepareJob.java 2014-07-24 14:44:06 UTC (rev 4066)
@@ -222,7 +222,7 @@
}
return result;
} catch (Exception eee) {
- throw new IsisFishRuntimeException(I18n._("isisfish.error.evalute.plan.script"), eee);
+ throw new IsisFishRuntimeException(I18n.t("isisfish.error.evalute.plan.script"), eee);
}
}
1
0
r4065 - trunk/src/main/java/fr/ifremer/isisfish/simulator
by echatellier@users.forge.codelutin.com 24 Jul '14
by echatellier@users.forge.codelutin.com 24 Jul '14
24 Jul '14
Author: echatellier
Date: 2014-07-24 16:41:53 +0200 (Thu, 24 Jul 2014)
New Revision: 4065
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4065
Log:
Fix generics
Modified:
trunk/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java 2014-07-24 14:16:32 UTC (rev 4064)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java 2014-07-24 14:41:53 UTC (rev 4065)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2006 - 2014 Ifremer, Code Lutin, Cédric 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
@@ -44,10 +44,10 @@
*/
public class RuleMonitor {
- protected MultiKeyMap evalutionCondition = new MultiKeyMap();
+ protected MultiKeyMap<Object, Boolean> evalutionCondition = new MultiKeyMap<Object, Boolean>();
public boolean getEvalutionCondition(TimeStep step, Rule rule, Metier metier) {
- return (Boolean) this.evalutionCondition.get(step, rule, metier);
+ return this.evalutionCondition.get(step, rule, metier);
}
public void setEvaluationCondition(TimeStep step, Rule rule, Metier metier,
1
0