Isis-fish-data-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
- 322 discussions
Author: jcouteau
Date: 2009-04-16 12:00:03 +0000 (Thu, 16 Apr 2009)
New Revision: 107
Modified:
trunk/exports/SensitivityBiomassRelativeY6.java
trunk/exports/SensitivityBiomassY3.java
trunk/exports/SensitivityCapturesWeightRelativeY4.java
trunk/exports/SensitivityCapturesWeightY1.java
trunk/exports/SensitivityGenitorBiomassRelativeY5.java
trunk/exports/SensitivityGenitorBiomassY2.java
Log:
Refactoring of sensitivity standards exports
Modified: trunk/exports/SensitivityBiomassRelativeY6.java
===================================================================
--- trunk/exports/SensitivityBiomassRelativeY6.java 2009-04-14 17:45:33 UTC (rev 106)
+++ trunk/exports/SensitivityBiomassRelativeY6.java 2009-04-16 12:00:03 UTC (rev 107)
@@ -6,10 +6,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.math.matrix.MatrixIterator;
import org.codelutin.math.matrix.MatrixND;
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.export.SensitivityExport;
@@ -20,7 +20,8 @@
public class SensitivityBiomassRelativeY6 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(SensitivityBiomassRelativeY6.class);
+ static private Log log = LogFactory
+ .getLog(SensitivityBiomassRelativeY6.class);
protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
@@ -31,48 +32,27 @@
public void export(SimulationStorage simulation, Writer out)
throws Exception {
Date lastDate = simulation.getResultStorage().getLastDate();
- Date firstDate = new Date (11);
+ Date firstDate = new Date(11);
double biomass = 0.0;
double firstbiomass = 0.0;
-
- //Calculate the biomass on last time step
-
+
for (Population pop : simulation.getParameter().getPopulations()) {
if (pop.getName().equals(param_pop.getName())) {
- MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ ResultStorage resultStorage = simulation.getResultStorage();
+
+ //Get the biomass on december of the first year
+ MatrixND matfirstdate = resultStorage.getMatrix(firstDate, pop,
ResultName.MATRIX_BIOMASS);
- for (MatrixIterator i = mat.iterator(); i.hasNext();) {
- i.next();
- Object[] sems = i.getSemanticsCoordinates();
- Date date = (Date) sems[0];
+ firstbiomass = matfirstdate.sumAll();
- if (date.afterOrEquals(lastDate)) {
- biomass = biomass + i.getValue();
- }
- }
- }
- }
-
- //Calculate the biomass on december of first year
-
- for (Population pop : simulation.getParameter().getPopulations()) {
- if (pop.getName().equals(param_pop.getName())) {
- MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(lastDate, pop,
ResultName.MATRIX_BIOMASS);
- for (MatrixIterator i = mat.iterator(); i.hasNext();) {
- i.next();
- Object[] sems = i.getSemanticsCoordinates();
- Date date = (Date) sems[0];
+ biomass = matlastdate.sumAll();
- if (date.equals(firstDate)) {
- firstbiomass = firstbiomass + i.getValue();
- }
- }
}
}
-
- out.write(Double.toString(biomass/firstbiomass));
-
+ out.write(Double.toString(biomass / firstbiomass));
}
@Override
@@ -82,7 +62,7 @@
@Override
public String getExportFilename() {
- return "SensitivityBiomassRelative";
+ return "SensitivityBiomassRelativeY6";
}
@Override
Modified: trunk/exports/SensitivityBiomassY3.java
===================================================================
--- trunk/exports/SensitivityBiomassY3.java 2009-04-14 17:45:33 UTC (rev 106)
+++ trunk/exports/SensitivityBiomassY3.java 2009-04-16 12:00:03 UTC (rev 107)
@@ -6,10 +6,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.math.matrix.MatrixIterator;
import org.codelutin.math.matrix.MatrixND;
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.export.SensitivityExport;
@@ -30,25 +30,19 @@
@Override
public void export(SimulationStorage simulation, Writer out)
throws Exception {
- Date lastDate = simulation.getResultStorage().getLastDate();
+ ResultStorage resultStorage = simulation.getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
double biomass = 0.0;
for (Population pop : simulation.getParameter().getPopulations()) {
if (pop.getName().equals(param_pop.getName())) {
- MatrixND mat = simulation.getResultStorage().getMatrix(pop,
- ResultName.MATRIX_BIOMASS);
- for (MatrixIterator i = mat.iterator(); i.hasNext();) {
- i.next();
- Object[] sems = i.getSemanticsCoordinates();
- Date date = (Date) sems[0];
- if (date.afterOrEquals(lastDate)) {
- biomass = biomass + i.getValue();
- }
- }
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(lastDate, pop,
+ ResultName.MATRIX_BIOMASS);
+ biomass = matlastdate.sumAll();
}
}
out.write(Double.toString(biomass));
-
}
@Override
@@ -58,7 +52,7 @@
@Override
public String getExportFilename() {
- return "SensitivityBiomass";
+ return "SensitivityBiomassY3";
}
@Override
Modified: trunk/exports/SensitivityCapturesWeightRelativeY4.java
===================================================================
--- trunk/exports/SensitivityCapturesWeightRelativeY4.java 2009-04-14 17:45:33 UTC (rev 106)
+++ trunk/exports/SensitivityCapturesWeightRelativeY4.java 2009-04-16 12:00:03 UTC (rev 107)
@@ -6,10 +6,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.math.matrix.MatrixIterator;
import org.codelutin.math.matrix.MatrixND;
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.export.SensitivityExport;
@@ -20,7 +20,8 @@
public class SensitivityCapturesWeightRelativeY4 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(SensitivityCapturesWeightRelativeY4.class);
+ static private Log log = LogFactory
+ .getLog(SensitivityCapturesWeightRelativeY4.class);
protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
@@ -30,55 +31,36 @@
@Override
public void export(SimulationStorage simulation, Writer out)
throws Exception {
- Date lastDate = simulation.getResultStorage().getLastDate();
+ ResultStorage resultStorage = simulation.getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
Double capturesWeight = 0.0;
Double capturesWeightfirst = 0.0;
for (Population pop : simulation.getParameter().getPopulations()) {
if (pop.getName().equals(param_pop.getName())) {
- for (Date date = new Date(0); !date.after(lastDate); date = date
- .next()) {
- MatrixND mat = simulation
- .getResultStorage()
+ for (int i = 0; i < 12; i++) {
+
+ //Get the captures Weight of each month of the last year
+ MatrixND matlastdate = resultStorage
.getMatrix(
- date,
+ new Date(lastDate.getDate() - i),
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();
- double val = i.getValue();
- capturesWeight = capturesWeight + val;
- }
- }
- }
- }
- }
-
- for (Population pop : simulation.getParameter().getPopulations()) {
- if (pop.getName().equals(param_pop.getName())) {
- for (Date date = new Date(0); date.beforeOrEquals(new Date(11)); date = date
- .next()) {
- MatrixND mat = simulation
- .getResultStorage()
+ capturesWeight += matlastdate.sumAll();
+
+ //Get the captures Weight of each month of the first year
+ MatrixND matfirstdate = resultStorage
.getMatrix(
- date,
+ new Date(i),
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();
- double val = i.getValue();
- capturesWeightfirst = capturesWeightfirst + val;
- }
- }
+ capturesWeightfirst += matfirstdate.sumAll();
}
+
}
}
-
- out.write(Double.toString(capturesWeight/capturesWeightfirst));
+
+ out.write(Double.toString(capturesWeight / capturesWeightfirst));
}
@Override
@@ -88,7 +70,7 @@
@Override
public String getExportFilename() {
- return "SensitivityCapturesWeightRelative";
+ return "SensitivityCapturesWeightRelativeY4";
}
@Override
Modified: trunk/exports/SensitivityCapturesWeightY1.java
===================================================================
--- trunk/exports/SensitivityCapturesWeightY1.java 2009-04-14 17:45:33 UTC (rev 106)
+++ trunk/exports/SensitivityCapturesWeightY1.java 2009-04-16 12:00:03 UTC (rev 107)
@@ -6,10 +6,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.math.matrix.MatrixIterator;
import org.codelutin.math.matrix.MatrixND;
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.export.SensitivityExport;
@@ -20,7 +20,8 @@
public class SensitivityCapturesWeightY1 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(SensitivityCapturesWeightY1.class);
+ static private Log log = LogFactory
+ .getLog(SensitivityCapturesWeightY1.class);
protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
@@ -30,30 +31,26 @@
@Override
public void export(SimulationStorage simulation, Writer out)
throws Exception {
- Date lastDate = simulation.getResultStorage().getLastDate();
+ ResultStorage resultStorage = simulation.getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
Double capturesWeight = 0.0;
for (Population pop : simulation.getParameter().getPopulations()) {
if (pop.getName().equals(param_pop.getName())) {
- for (Date date = new Date(0); !date.after(lastDate); date = date
- .next()) {
- MatrixND mat = simulation
- .getResultStorage()
+ for (int i = 0; i < 12; i++) {
+
+ //Get the captures Weight of each month of the last year
+ MatrixND matlastdate = resultStorage
.getMatrix(
- date,
+ new Date(lastDate.getDate() - i),
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();
- double val = i.getValue();
- capturesWeight = capturesWeight + val;
- }
- }
+ capturesWeight += matlastdate.sumAll();
}
+
}
}
+
out.write(Double.toString(capturesWeight));
}
@@ -64,7 +61,7 @@
@Override
public String getExportFilename() {
- return "SensitivityCapturesWeight";
+ return "SensitivityCapturesWeightY1";
}
@Override
Modified: trunk/exports/SensitivityGenitorBiomassRelativeY5.java
===================================================================
--- trunk/exports/SensitivityGenitorBiomassRelativeY5.java 2009-04-14 17:45:33 UTC (rev 106)
+++ trunk/exports/SensitivityGenitorBiomassRelativeY5.java 2009-04-16 12:00:03 UTC (rev 107)
@@ -10,6 +10,7 @@
import org.codelutin.math.matrix.MatrixND;
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;
@@ -33,46 +34,41 @@
public void export(SimulationStorage simulation, Writer out)
throws Exception {
Date lastDate = simulation.getResultStorage().getLastDate();
- Date firstDate = new Date (11);
+ Date firstDate = new Date(11);
double biomass = 0.0;
double firstbiomass = 0.0;
-
+
for (Population pop : simulation.getParameter().getPopulations()) {
if (pop.getName().equals(param_pop.getName())) {
- MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ ResultStorage resultStorage = simulation.getResultStorage();
+
+ //Get the biomass of the last time step
+ MatrixND matfirstdate = resultStorage.getMatrix(pop,
ResultName.MATRIX_BIOMASS);
- for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = matfirstdate.iterator(); i.hasNext();) {
i.next();
Object[] sems = i.getSemanticsCoordinates();
- Date date = (Date) sems[0];
PopulationGroup group = (PopulationGroup) sems[1];
-
- if (date.afterOrEquals(lastDate)) {
- biomass = biomass + i.getValue()
+ Date date = (Date) sems[0];
+ if (date.equals(firstDate)) {
+ firstbiomass += i.getValue()
* group.getReproductionRate();
}
}
- }
- }
- //Calculate the biomass on december of first year
-
- for (Population pop : simulation.getParameter().getPopulations()) {
- if (pop.getName().equals(param_pop.getName())) {
- MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(pop,
ResultName.MATRIX_BIOMASS);
- for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) {
i.next();
Object[] sems = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sems[1];
Date date = (Date) sems[0];
-
- if (date.equals(firstDate)) {
- firstbiomass = firstbiomass + i.getValue();
- }
+ if (date.equals(lastDate))
+ biomass += i.getValue() * group.getReproductionRate();
}
}
}
-
out.write(Double.toString(biomass / firstbiomass));
}
@@ -83,7 +79,7 @@
@Override
public String getExportFilename() {
- return "SensitivityGenitorBiomassRelative";
+ return "SensitivityGenitorBiomassRelativeY5";
}
@Override
Modified: trunk/exports/SensitivityGenitorBiomassY2.java
===================================================================
--- trunk/exports/SensitivityGenitorBiomassY2.java 2009-04-14 17:45:33 UTC (rev 106)
+++ trunk/exports/SensitivityGenitorBiomassY2.java 2009-04-16 12:00:03 UTC (rev 107)
@@ -10,6 +10,7 @@
import org.codelutin.math.matrix.MatrixND;
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;
@@ -21,7 +22,8 @@
public class SensitivityGenitorBiomassY2 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(SensitivityGenitorBiomassY2.class);
+ static private Log log = LogFactory
+ .getLog(SensitivityGenitorBiomassY2.class);
protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
@@ -33,18 +35,21 @@
throws Exception {
Date lastDate = simulation.getResultStorage().getLastDate();
double biomass = 0.0;
+
for (Population pop : simulation.getParameter().getPopulations()) {
if (pop.getName().equals(param_pop.getName())) {
- MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ ResultStorage resultStorage = simulation.getResultStorage();
+
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(pop,
ResultName.MATRIX_BIOMASS);
- for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) {
i.next();
Object[] sems = i.getSemanticsCoordinates();
Date date = (Date) sems[0];
PopulationGroup group = (PopulationGroup) sems[1];
-
- if (date.afterOrEquals(lastDate)) {
- biomass = biomass + i.getValue()*group.getReproductionRate();
+ if (date.equals(lastDate)) {
+ biomass += i.getValue() * group.getReproductionRate();
}
}
}
@@ -59,7 +64,7 @@
@Override
public String getExportFilename() {
- return "SensitivityGenitorBiomass";
+ return "SensitivityGenitorBiomassY2";
}
@Override
1
0
Author: jcouteau
Date: 2009-04-14 17:45:33 +0000 (Tue, 14 Apr 2009)
New Revision: 106
Modified:
trunk/exports/SensitivityCapturesWeightRelativeY4.java
Log:
Modified: trunk/exports/SensitivityCapturesWeightRelativeY4.java
===================================================================
--- trunk/exports/SensitivityCapturesWeightRelativeY4.java 2009-04-14 17:41:56 UTC (rev 105)
+++ trunk/exports/SensitivityCapturesWeightRelativeY4.java 2009-04-14 17:45:33 UTC (rev 106)
@@ -1,4 +1,4 @@
-ppackage exports;
+package exports;
import static org.codelutin.i18n.I18n._;
1
0
Author: jcouteau
Date: 2009-04-14 17:41:56 +0000 (Tue, 14 Apr 2009)
New Revision: 105
Added:
trunk/exports/SensitivityBiomassReferenceY9.java
trunk/exports/SensitivityCapturesWeightRelativeY4.java
trunk/exports/SensitivityCapturesWeightY1.java
trunk/exports/SensitivityGenitorBiomassRelativeY5.java
Removed:
trunk/exports/SensitivityCapturesPoids.java
Modified:
trunk/exports/SensitivityGenitorBiomassY2.java
Log:
Adding exports. Fixing bugs on exports.
Added: trunk/exports/SensitivityBiomassReferenceY9.java
===================================================================
--- trunk/exports/SensitivityBiomassReferenceY9.java (rev 0)
+++ trunk/exports/SensitivityBiomassReferenceY9.java 2009-04-14 17:41:56 UTC (rev 105)
@@ -0,0 +1,80 @@
+package exports;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.io.File;
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+
+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.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+@Doc("Doc for SensitivityBiomass")
+public class SensitivityBiomassReferenceY9 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(SensitivityBiomassReferenceY9.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Doc("Path to the reference simulation exports")
+ public String param_referenceExports;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ File referenceExports=new File (param_referenceExports);
+ Date lastDate = simulation.getResultStorage().getLastDate();
+ double biomass = 0.0;
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Date date = (Date) sems[0];
+
+ if (date.afterOrEquals(lastDate)) {
+ biomass = biomass + i.getValue();
+ }
+ }
+ }
+ }
+ out.write(Double.toString(biomass));
+
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityBiomass";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
Deleted: trunk/exports/SensitivityCapturesPoids.java
===================================================================
--- trunk/exports/SensitivityCapturesPoids.java 2009-04-13 11:42:54 UTC (rev 104)
+++ trunk/exports/SensitivityCapturesPoids.java 2009-04-14 17:41:56 UTC (rev 105)
@@ -1,78 +0,0 @@
-package exports;
-
-import static org.codelutin.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.math.matrix.MatrixIterator;
-import org.codelutin.math.matrix.MatrixND;
-
-import scripts.ResultName;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.export.SensitivityExport;
-import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.util.Doc;
-
-@Doc("Doc for SensitivityCapturesPoids")
-public class SensitivityCapturesPoids implements SensitivityExport {
-
- /** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(SensitivityCapturesPoids.class);
-
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
-
- @Doc("Population")
- public Population param_pop;
-
- @Override
- public void export(SimulationStorage simulation, Writer out)
- throws Exception {
- Date lastDate = simulation.getResultStorage().getLastDate();
- Double capturesWeight = 0.0;
-
- for (Population pop : simulation.getParameter().getPopulations()) {
- if (pop.getName().equals(param_pop.getName())) {
- for (Date date = new Date(0); !date.after(lastDate); date = date
- .next()) {
- MatrixND mat = simulation
- .getResultStorage()
- .getMatrix(
- date,
- 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();
- capturesWeight = capturesWeight + i.getValue();
- }
- }
- }
- }
- }
- }
-
- @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");
- }
-
- @Override
- public String getExportFilename() {
- return "SensitivityCapturesPoids";
- }
-
- @Override
- public String getExtensionFilename() {
- return ".csv";
- }
-
- @Override
- public String[] getNecessaryResult() {
- return this.necessaryResult;
- }
-
-}
Added: trunk/exports/SensitivityCapturesWeightRelativeY4.java
===================================================================
--- trunk/exports/SensitivityCapturesWeightRelativeY4.java (rev 0)
+++ trunk/exports/SensitivityCapturesWeightRelativeY4.java 2009-04-14 17:41:56 UTC (rev 105)
@@ -0,0 +1,104 @@
+ppackage exports;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+@Doc("Doc for SensitivityCapturesPoids")
+public class SensitivityCapturesWeightRelativeY4 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(SensitivityCapturesWeightRelativeY4.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ Date lastDate = simulation.getResultStorage().getLastDate();
+ Double capturesWeight = 0.0;
+ Double capturesWeightfirst = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ for (Date date = new Date(0); !date.after(lastDate); date = date
+ .next()) {
+ MatrixND mat = simulation
+ .getResultStorage()
+ .getMatrix(
+ date,
+ 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();
+ double val = i.getValue();
+ capturesWeight = capturesWeight + val;
+ }
+ }
+ }
+ }
+ }
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ for (Date date = new Date(0); date.beforeOrEquals(new Date(11)); date = date
+ .next()) {
+ MatrixND mat = simulation
+ .getResultStorage()
+ .getMatrix(
+ date,
+ 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();
+ double val = i.getValue();
+ capturesWeightfirst = capturesWeightfirst + val;
+ }
+ }
+ }
+ }
+ }
+
+ out.write(Double.toString(capturesWeight/capturesWeightfirst));
+ }
+
+ @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");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityCapturesWeightRelative";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
Copied: trunk/exports/SensitivityCapturesWeightY1.java (from rev 102, trunk/exports/SensitivityCapturesPoids.java)
===================================================================
--- trunk/exports/SensitivityCapturesWeightY1.java (rev 0)
+++ trunk/exports/SensitivityCapturesWeightY1.java 2009-04-14 17:41:56 UTC (rev 105)
@@ -0,0 +1,80 @@
+package exports;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+@Doc("Doc for SensitivityCapturesPoids")
+public class SensitivityCapturesWeightY1 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(SensitivityCapturesWeightY1.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ Date lastDate = simulation.getResultStorage().getLastDate();
+ Double capturesWeight = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ for (Date date = new Date(0); !date.after(lastDate); date = date
+ .next()) {
+ MatrixND mat = simulation
+ .getResultStorage()
+ .getMatrix(
+ date,
+ 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();
+ double val = i.getValue();
+ capturesWeight = capturesWeight + val;
+ }
+ }
+ }
+ }
+ }
+ out.write(Double.toString(capturesWeight));
+ }
+
+ @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");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityCapturesWeight";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
Property changes on: trunk/exports/SensitivityCapturesWeightY1.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: trunk/exports/SensitivityGenitorBiomassRelativeY5.java
===================================================================
--- trunk/exports/SensitivityGenitorBiomassRelativeY5.java (rev 0)
+++ trunk/exports/SensitivityGenitorBiomassRelativeY5.java 2009-04-14 17:41:56 UTC (rev 105)
@@ -0,0 +1,99 @@
+package exports;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+
+import scripts.ResultName;
+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.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+@Doc("Doc for SensitivityBiomass")
+public class SensitivityGenitorBiomassRelativeY5 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityGenitorBiomassRelativeY5.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ Date lastDate = simulation.getResultStorage().getLastDate();
+ Date firstDate = new Date (11);
+ double biomass = 0.0;
+ double firstbiomass = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Date date = (Date) sems[0];
+ PopulationGroup group = (PopulationGroup) sems[1];
+
+ if (date.afterOrEquals(lastDate)) {
+ biomass = biomass + i.getValue()
+ * group.getReproductionRate();
+ }
+ }
+ }
+ }
+
+ //Calculate the biomass on december of first year
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Date date = (Date) sems[0];
+
+ if (date.equals(firstDate)) {
+ firstbiomass = firstbiomass + i.getValue();
+ }
+ }
+ }
+ }
+
+ out.write(Double.toString(biomass / firstbiomass));
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityGenitorBiomassRelative";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
\ No newline at end of file
Modified: trunk/exports/SensitivityGenitorBiomassY2.java
===================================================================
--- trunk/exports/SensitivityGenitorBiomassY2.java 2009-04-13 11:42:54 UTC (rev 104)
+++ trunk/exports/SensitivityGenitorBiomassY2.java 2009-04-14 17:41:56 UTC (rev 105)
@@ -50,7 +50,6 @@
}
}
out.write(Double.toString(biomass));
-
}
@Override
1
0
Author: jcouteau
Date: 2009-04-13 11:42:54 +0000 (Mon, 13 Apr 2009)
New Revision: 104
Removed:
trunk/exports/SensitivityBiomass.java
Modified:
trunk/exports/SensitivityBiomassRelativeY6.java
Log:
Fixed Y6 export
Deleted: trunk/exports/SensitivityBiomass.java
===================================================================
--- trunk/exports/SensitivityBiomass.java 2009-04-13 08:49:24 UTC (rev 103)
+++ trunk/exports/SensitivityBiomass.java 2009-04-13 11:42:54 UTC (rev 104)
@@ -1,74 +0,0 @@
-package exports;
-
-import static org.codelutin.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.math.matrix.MatrixIterator;
-import org.codelutin.math.matrix.MatrixND;
-
-import scripts.ResultName;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.export.SensitivityExport;
-import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.util.Doc;
-
-@Doc("Doc for SensitivityBiomass")
-public class SensitivityBiomass implements SensitivityExport {
-
- /** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(SensitivityBiomass.class);
-
- protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
-
- @Doc("Population")
- public Population param_pop;
-
- @Override
- public void export(SimulationStorage simulation, Writer out)
- throws Exception {
- Date lastDate = simulation.getResultStorage().getLastDate();
- double biomass = 0.0;
- for (Population pop : simulation.getParameter().getPopulations()) {
- if (pop.getName().equals(param_pop.getName())) {
- MatrixND mat = simulation.getResultStorage().getMatrix(pop,
- ResultName.MATRIX_BIOMASS);
- for (MatrixIterator i = mat.iterator(); i.hasNext();) {
- i.next();
- Object[] sems = i.getSemanticsCoordinates();
- Date date = (Date) sems[0];
-
- if (date.afterOrEquals(lastDate)) {
- biomass = biomass + i.getValue();
- }
- }
- }
- }
- out.write(Double.toString(biomass));
-
- }
-
- @Override
- public String getDescription() {
- return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
- }
-
- @Override
- public String getExportFilename() {
- return "SensitivityBiomass";
- }
-
- @Override
- public String getExtensionFilename() {
- return ".csv";
- }
-
- @Override
- public String[] getNecessaryResult() {
- return this.necessaryResult;
- }
-
-}
Modified: trunk/exports/SensitivityBiomassRelativeY6.java
===================================================================
--- trunk/exports/SensitivityBiomassRelativeY6.java 2009-04-13 08:49:24 UTC (rev 103)
+++ trunk/exports/SensitivityBiomassRelativeY6.java 2009-04-13 11:42:54 UTC (rev 104)
@@ -82,7 +82,7 @@
@Override
public String getExportFilename() {
- return "SensitivityBiomass";
+ return "SensitivityBiomassRelative";
}
@Override
1
0
Author: jcouteau
Date: 2009-04-13 08:49:24 +0000 (Mon, 13 Apr 2009)
New Revision: 103
Modified:
trunk/exports/SensitivityBiomassRelativeY6.java
Log:
Fix bad copy/paste
Modified: trunk/exports/SensitivityBiomassRelativeY6.java
===================================================================
--- trunk/exports/SensitivityBiomassRelativeY6.java 2009-04-13 08:30:32 UTC (rev 102)
+++ trunk/exports/SensitivityBiomassRelativeY6.java 2009-04-13 08:49:24 UTC (rev 103)
@@ -17,10 +17,10 @@
import fr.ifremer.isisfish.util.Doc;
@Doc("Doc for SensitivityBiomass")
-public class SensitivityBiomassY3 implements SensitivityExport {
+public class SensitivityBiomassRelativeY6 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(SensitivityBiomassY3.class);
+ static private Log log = LogFactory.getLog(SensitivityBiomassRelativeY6.class);
protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
1
0
Author: jcouteau
Date: 2009-04-13 08:30:32 +0000 (Mon, 13 Apr 2009)
New Revision: 102
Added:
trunk/exports/SensitivityBiomassRelativeY6.java
trunk/exports/SensitivityBiomassY3.java
trunk/exports/SensitivityGenitorBiomassY2.java
Log:
Added: trunk/exports/SensitivityBiomassRelativeY6.java
===================================================================
--- trunk/exports/SensitivityBiomassRelativeY6.java (rev 0)
+++ trunk/exports/SensitivityBiomassRelativeY6.java 2009-04-13 08:30:32 UTC (rev 102)
@@ -0,0 +1,98 @@
+package exports;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+@Doc("Doc for SensitivityBiomass")
+public class SensitivityBiomassY3 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(SensitivityBiomassY3.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ Date lastDate = simulation.getResultStorage().getLastDate();
+ Date firstDate = new Date (11);
+ double biomass = 0.0;
+ double firstbiomass = 0.0;
+
+ //Calculate the biomass on last time step
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Date date = (Date) sems[0];
+
+ if (date.afterOrEquals(lastDate)) {
+ biomass = biomass + i.getValue();
+ }
+ }
+ }
+ }
+
+ //Calculate the biomass on december of first year
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Date date = (Date) sems[0];
+
+ if (date.equals(firstDate)) {
+ firstbiomass = firstbiomass + i.getValue();
+ }
+ }
+ }
+ }
+
+ out.write(Double.toString(biomass/firstbiomass));
+
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityBiomass";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
\ No newline at end of file
Copied: trunk/exports/SensitivityBiomassY3.java (from rev 101, trunk/exports/SensitivityBiomass.java)
===================================================================
--- trunk/exports/SensitivityBiomassY3.java (rev 0)
+++ trunk/exports/SensitivityBiomassY3.java 2009-04-13 08:30:32 UTC (rev 102)
@@ -0,0 +1,74 @@
+package exports;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+@Doc("Doc for SensitivityBiomass")
+public class SensitivityBiomassY3 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(SensitivityBiomassY3.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ Date lastDate = simulation.getResultStorage().getLastDate();
+ double biomass = 0.0;
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Date date = (Date) sems[0];
+
+ if (date.afterOrEquals(lastDate)) {
+ biomass = biomass + i.getValue();
+ }
+ }
+ }
+ }
+ out.write(Double.toString(biomass));
+
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityBiomass";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
Property changes on: trunk/exports/SensitivityBiomassY3.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: trunk/exports/SensitivityGenitorBiomassY2.java
===================================================================
--- trunk/exports/SensitivityGenitorBiomassY2.java (rev 0)
+++ trunk/exports/SensitivityGenitorBiomassY2.java 2009-04-13 08:30:32 UTC (rev 102)
@@ -0,0 +1,76 @@
+package exports;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+
+import scripts.ResultName;
+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.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+@Doc("Doc for SensitivityBiomass")
+public class SensitivityGenitorBiomassY2 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(SensitivityGenitorBiomassY2.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ Date lastDate = simulation.getResultStorage().getLastDate();
+ double biomass = 0.0;
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Date date = (Date) sems[0];
+ PopulationGroup group = (PopulationGroup) sems[1];
+
+ if (date.afterOrEquals(lastDate)) {
+ biomass = biomass + i.getValue()*group.getReproductionRate();
+ }
+ }
+ }
+ }
+ out.write(Double.toString(biomass));
+
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityGenitorBiomass";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
1
0
Author: chatellier
Date: 2009-04-09 12:41:26 +0000 (Thu, 09 Apr 2009)
New Revision: 101
Modified:
trunk/pom.xml
Log:
Fix xsd location
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-04-08 12:44:22 UTC (rev 100)
+++ trunk/pom.xml 2009-04-09 12:41:26 UTC (rev 101)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--The version of maven's project object model-->
<modelVersion>4.0.0</modelVersion>
1
0
Author: jcouteau
Date: 2009-04-08 12:44:22 +0000 (Wed, 08 Apr 2009)
New Revision: 100
Modified:
trunk/sensitivity/SensitivityCalculatorRSobol.java
Log:
adding factors name support on sobol sensitivity analysis
Modified: trunk/sensitivity/SensitivityCalculatorRSobol.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRSobol.java 2009-04-08 10:19:07 UTC (rev 99)
+++ trunk/sensitivity/SensitivityCalculatorRSobol.java 2009-04-08 12:44:22 UTC (rev 100)
@@ -127,6 +127,23 @@
+ "a<-sobol(model=NULL,X1=X1,X2=X2,order=" + param_order
+ ",nboot=" + param_nboot + ")");
+ // Creating the factors vector.
+ String rInstruction = "factornames<-c(";
+ for (int i = 0; i < factorNumber; i++) {
+ if (i != (factorNumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R" + rInstruction);
+
// Export the sobol object for the second run in a .sobol file
engine.voidEval("dput(a,file=\".sobol\")");
log.info("Message sent to R" + "dput(a,file=\".sobol\")");
@@ -137,6 +154,11 @@
engine.voidEval("dput(X2,file=\".X2\")");
log.info("Message sent to R" + "dput(a,file=\".sobol\")");
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R"
+ + "dput(factornames,file=\".factornames\")");
+
// Get back experiment plan
/*dataframe = (double[]) engine.eval("a$X");*/
@@ -214,10 +236,26 @@
// Get the .X2 file
engine.voidEval("X2<-dget(\".X2\")");
log.info("Message sent to R : " + "X2<-dget(\".X2\")");
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
+ //Set X1 names
+ engine.voidEval("names(X1)<-factornames");
+ log.info("Message sent to R : " + "names(X1)<-factornames");
+ //Set X2 names
+ engine.voidEval("names(X2)<-factornames");
+ log.info("Message sent to R : " + "names(X2)<-factornames");
+
// Get the .sobol file
engine.voidEval("a<-dget(\".sobol\")");
log.info("Message sent to R : " + "a<-dget(\".sobol\")");
+ //Set a$X names
+ engine.voidEval("names(a$X)<-factornames");
+ log.info("Message sent to R : " + "names(a$X)<-factornames");
+
int scenariosNumber = (Integer) engine.eval("length(a$X[,1])");
log.info("Message sent to R : " + "length(a$X[,1])");
1
0
Author: jcouteau
Date: 2009-04-08 10:19:07 +0000 (Wed, 08 Apr 2009)
New Revision: 99
Modified:
trunk/sensitivity/SensitivityCalculatorJavaExpandGrid.java
trunk/sensitivity/SensitivityCalculatorRFast.java
trunk/sensitivity/SensitivityCalculatorRFrF2.java
trunk/sensitivity/SensitivityCalculatorRMorris.java
trunk/sensitivity/SensitivityCalculatorROptimumLHS.java
trunk/sensitivity/SensitivityCalculatorRRandomLHS.java
Log:
Set factor names in sensitivity exports
Modified: trunk/sensitivity/SensitivityCalculatorJavaExpandGrid.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorJavaExpandGrid.java 2009-04-07 15:25:54 UTC (rev 98)
+++ trunk/sensitivity/SensitivityCalculatorJavaExpandGrid.java 2009-04-08 10:19:07 UTC (rev 99)
@@ -105,11 +105,12 @@
.getMaxBound();
Double min = ((ContinuousDomain<Double>) factor.getDomain())
.getMinBound();
- int card = ((ContinuousDomain<? extends Serializable>) factor.getDomain()).getCardinality();
+ int card = ((ContinuousDomain<? extends Serializable>) factor
+ .getDomain()).getCardinality();
result = (int) Math.floor(rest / card);
rest = rest - (card * result);
- Double value = min + ((max - min) / (card-1) * rest);
+ Double value = min + ((max - min) / (card - 1) * rest);
if ((factor.getDomain() instanceof MatrixContinuousDomain)
|| (factor.getDomain() instanceof EquationContinuousDomain)) {
factor.setValueForIdentifier(value.toString());
@@ -118,7 +119,8 @@
}
}
if (factor.getDomain() instanceof DiscreteDomain) {
- int card = ((DiscreteDomain<? extends Serializable>) factor.getDomain()).getValues().size();
+ int card = ((DiscreteDomain<? extends Serializable>) factor
+ .getDomain()).getValues().size();
result = (int) Math.floor(rest / card);
rest = rest - (card * result);
factor.setValueForIdentifier(rest);
@@ -130,9 +132,9 @@
}
thisExperiment.setScenarios(thisExperimentScenarios);
-
- thisExperimentScenarios=thisExperiment.getScenarios();
+ thisExperimentScenarios = thisExperiment.getScenarios();
+
/*
* Call R to save the data for result analysis
*/
@@ -143,21 +145,21 @@
//Create the factors vectors
for (int j = 0; j < factorNumber; j++) {
Factor<? extends Serializable> factor = thisExperimentScenarios
- .get(0).getFactors().get(j);
- if (factor
- .getDomain() instanceof EquationContinuousDomain) {
+ .get(0).getFactors().get(j);
+ if (factor.getDomain() instanceof EquationContinuousDomain) {
String vector = "factor" + j + "<-c(";
for (int i = 0; i < scenariosNumber; i++) {
if (i < (scenariosNumber - 1)) {
vector = vector
- + ((EquationContinuousDomain<?>)thisExperimentScenarios
- .get(i).getFactors().get(j).getDomain()).getValue()
- + ",";
+ + ((EquationContinuousDomain<?>) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue() + ",";
} else {
vector = vector
- + ((EquationContinuousDomain<?>)thisExperimentScenarios
- .get(i).getFactors().get(j).getDomain()).getValue();
+ + ((EquationContinuousDomain<?>) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue();
}
}
@@ -220,6 +222,23 @@
engine.voidEval(dataframe);
log.info("Message sent to R : " + dataframe);
+ // Creating the factors vector.
+ String rInstruction = "factornames<-c(";
+ for (int i = 0; i < factorNumber; i++) {
+ if (i != (factorNumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R : " + rInstruction);
+
// Set output directory
engine.voidEval("setwd(\"" + outputdirectory.getAbsolutePath()
+ "\")");
@@ -231,6 +250,11 @@
log
.info("Message sent to R : write.csv(data,file=\".expandgrid\")");
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R : "
+ + "dput(factornames,file=\".factornames\")");
+
engine.terminate();
} catch (Exception e) {
@@ -268,6 +292,11 @@
log
.info("Message sent to R : factors<-read.csv(\".expandgrid.csv\")");
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
//Get back the factors number
int factorNumber = ((Double) engine.eval("length(factors)-1"))
.intValue();
@@ -348,7 +377,20 @@
.voidEval("names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
log
.info("Message sent to R : names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ engine.voidEval("row.names(exportsensitivity)<-factornames");
+ log.info("Message sent to R : "
+ + "row.names(exportsensitivity)<-factornames");
+ //Set dataforaov names
+ engine
+ .voidEval("resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ engine.voidEval("names(dataforaov)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dataforaov)<-resultsnames");
+
/*Set the export directory
*Export directory is the first simulation export directory.
*/
Modified: trunk/sensitivity/SensitivityCalculatorRFast.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRFast.java 2009-04-07 15:25:54 UTC (rev 98)
+++ trunk/sensitivity/SensitivityCalculatorRFast.java 2009-04-08 10:19:07 UTC (rev 99)
@@ -80,13 +80,13 @@
}
public SensitivityScenarios compute(DesignPlan plan, File outputdirectory) {
-
- if(param_n==0){
- param_n=17;
+
+ if (param_n == 0) {
+ param_n = 17;
}
-
- if(param_M==0){
- param_M=1;
+
+ if (param_M == 0) {
+ param_M = 1;
}
double[] dataframe = new double[0];
@@ -106,17 +106,6 @@
String rInstruction = "a<-fast99(model=NULL,factors=c("
+ factors.size();
- /* // Creating the factors vector.
- for (int i = 0; i < factorNumber; i++) {
- if (i != (factorNumber - 1)) {
- rInstruction = rInstruction + "\"" + factors.get(i).getName()
- + "\",";
- } else {
- rInstruction = rInstruction + "\"" + factors.get(i).getName()
- + "\"";
- }
- }*/
-
rInstruction = rInstruction + "), n=" + param_n + ",M=" + param_M;
rInstruction = rInstruction
@@ -133,6 +122,23 @@
engine.voidEval(rInstruction);
log.info("Message sent to R" + rInstruction);
+ // Creating the factors vector.
+ rInstruction = "factornames<-c(";
+ for (int i = 0; i < factorNumber; i++) {
+ if (i != (factorNumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R" + rInstruction);
+
// Set output directory
engine.voidEval("setwd(\"" + outputdirectory.getAbsolutePath()
+ "\")");
@@ -143,6 +149,11 @@
engine.voidEval("dput(a,file=\".fast99\")");
log.info("Message sent to R" + "dput(a,file=\".fast99\")");
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R"
+ + "dput(factornames,file=\".factornames\")");
+
// Get back experiment plan
Vector<REXP> dataframeVector = (Vector<REXP>) engine.eval("a$X");
@@ -201,13 +212,13 @@
public void analyzeResult(List<SimulationStorage> simulationStorages,
File outputdirectory) {
-
- if(param_n==0){
- param_n=17;
+
+ if (param_n == 0) {
+ param_n = 17;
}
-
- if(param_M==0){
- param_M=1;
+
+ if (param_M == 0) {
+ param_M = 1;
}
REngine engine = new RProxy();
@@ -229,9 +240,13 @@
engine.voidEval("a<-dget(\".fast99\")");
log.info("Message sent to R : " + "a<-dget(\".fast99\")");
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
/*int scenariosNumber = sensitivityScenarios.getScenarios().size();*/
- int scenariosNumber = (Integer)engine
- .eval("length(a$X[,1])");
+ int scenariosNumber = (Integer) engine.eval("length(a$X[,1])");
log.info("Message sent to R : " + "length(a$X[,1])");
int sensitivityNumber = simulationStorages.get(0).getParameter()
@@ -275,6 +290,7 @@
engine.voidEval("dfresults=data.frame(a$X,results)");
log.info("Message sent to R : "
+ "dfresults=data.frame(a$X,results)");
+
//Set working directory
engine.voidEval("setwd(\"" + outputdirectory.getAbsolutePath()
@@ -282,18 +298,30 @@
log.info("Message sent to R : setwd(\""
+ outputdirectory.getAbsolutePath() + "\")");
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
+ //Set V names
+ engine.voidEval("names(a$V)<-factornames");
+ log.info("Message sent to R : " + "names(a$V)<-factornames");
+
//Export V
engine.voidEval("write.csv(a$V,\""
+ simulationStorages.get(0).getParameter()
.getSensitivityExport().get(k)
- .getExportFilename()
- + "_V.csv\")");
+ .getExportFilename() + "_V.csv\")");
log.info("Message sent to R : "
+ "write.csv(a$V,\""
+ simulationStorages.get(0).getParameter()
.getSensitivityExport().get(k)
.getExportFilename() + "_V.csv\")");
+ //Set D1 names
+ engine.voidEval("names(a$D1)<-factornames");
+ log.info("Message sent to R : " + "names(a$D1)<-factornames");
+
//Export D1
engine.voidEval("write.csv(a$D1,\""
+ simulationStorages.get(0).getParameter()
@@ -305,6 +333,10 @@
.getSensitivityExport().get(k)
.getExportFilename() + "_D1.csv\")");
+ //Set Dt names
+ engine.voidEval("names(a$Dt)<-factornames");
+ log.info("Message sent to R : " + "names(a$Dt)<-factornames");
+
//Export Dt
engine.voidEval("write.csv(a$Dt,\""
+ simulationStorages.get(0).getParameter()
@@ -315,6 +347,15 @@
+ simulationStorages.get(0).getParameter()
.getSensitivityExport().get(k)
.getExportFilename() + "_Dt.csv\")");
+ //Set dfresults names
+ engine
+ .voidEval("resultsnames<-c(factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(factornames,\"Result\")");
+ engine.voidEval("names(dfresults)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dfresults)<-resultsnames");
//Export results
engine.voidEval("write.csv(dfresults,\""
Modified: trunk/sensitivity/SensitivityCalculatorRFrF2.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRFrF2.java 2009-04-07 15:25:54 UTC (rev 98)
+++ trunk/sensitivity/SensitivityCalculatorRFrF2.java 2009-04-08 10:19:07 UTC (rev 99)
@@ -21,6 +21,7 @@
import java.io.File;
import java.io.Serializable;
import java.util.List;
+import java.util.Vector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -30,6 +31,7 @@
import org.codelutin.math.matrix.MatrixFactory;
import org.codelutin.math.matrix.MatrixND;
import org.codelutin.util.FileUtil;
+import org.rosuda.JRI.REXP;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
@@ -52,7 +54,7 @@
* Last update : $Date: 2009-04-03 13:13:35 +0200 (ven., 03 avr. 2009) $ By :
* $Author: chatellier $
*/
-@Doc("FrF2 method")
+@Doc("FrF2 method, at least 4 factors need to be declared")
public class SensitivityCalculatorRFrF2 implements SensitivityCalculator {
/** to use log facility, just put in your code: log.info("..."); */
@@ -112,8 +114,39 @@
// Get back experiment plan
dataframe = (double[]) engine.eval("a$desnum");
+ /*Vector<REXP> dataframeVector = (Vector<REXP>) engine.eval("a$X");
+ dataframe = new double[dataframeVector.size()
+ * dataframeVector.get(0).asDoubleArray().length];
+ for (int i = 0; i < dataframeVector.size(); i++) {
+ for (int j = 0; j < dataframeVector.get(0).asDoubleArray().length; j++) {
+ dataframe[i * dataframeVector.get(0).asDoubleArray().length
+ + j] = dataframeVector.get(i).asDoubleArray()[j];
+ }
+ }*/
log.info("Message sent to R : " + "a$desnum");
+ // Creating the factors vector.
+ rInstruction = "factornames<-c(";
+ for (int i = 0; i < factorNumber; i++) {
+ if (i != (factorNumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R : " + rInstruction);
+
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R : "
+ + "dput(factornames,file=\".factornames\")");
+
} catch (RException e) {
e.printStackTrace();
}
@@ -286,6 +319,11 @@
log
.info("Message sent to R : factors<-read.csv(\".FrF2.csv\")");
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
//Get back the factors number
int factorNumber = ((Double) engine.eval("length(factors)-1"))
.intValue();
@@ -323,7 +361,6 @@
//get back the resolution
int resolution = (Integer) engine.eval("res.catlg(a$catentry)");
log.info("Message sent to R : " + "res.catlg(a$catentry)");
- log.info(resolution);
String aovCall;
@@ -355,13 +392,31 @@
}
}
}
- aovCall = aovCall.substring(0, aovCall.length()-1);
+ aovCall = aovCall.substring(0, aovCall.length() - 1);
aovCall = aovCall + ",data=dataforaov)";
engine.voidEval(aovCall);
log.info("Message sent to R : " + aovCall);
break;
+ case 5:
+ aovCall = "aovresult<-aov(result~";
+ for (int j = 0; j < factorNumber; j++) {
+ aovCall = aovCall + "factor" + j + "+";
+ }
+ for (int i = 0; i < factorNumber; i++) {
+ for (int j = 0; j < factorNumber; j++) {
+ if (i < j) {
+ aovCall = aovCall + "factor" + i + "*factor"
+ + j + "+";
+ }
+ }
+ }
+ aovCall = aovCall.substring(0, aovCall.length() - 1);
+ aovCall = aovCall + ",data=dataforaov)";
+ engine.voidEval(aovCall);
+ log.info("Message sent to R : " + aovCall);
+ break;
default:
- log.info("pas bien");
+ log.info("This resolution is not managed");
break;
}
@@ -398,9 +453,11 @@
.voidEval("names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
log
.info("Message sent to R : names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
-
-
-
+
+ engine.voidEval("row.names(exportsensitivity)<-factornames");
+ log.info("Message sent to R : "
+ + "row.names(exportsensitivity)<-factornames");
+
/*Set the export directory
*Export directory is the first simulation export directory.
*/
@@ -409,6 +466,17 @@
log.info("Message sent to R : setwd(\""
+ outputdirectory.getAbsolutePath() + "\")");
+ //Set dataforaov names
+ engine
+ .voidEval("resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ engine.voidEval("names(dataforaov)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dataforaov)<-resultsnames");
+
+
//Save the results with the scenarios.
engine.voidEval("write.csv(dataforaov,\""
+ simulationStorages.get(0).getParameter()
@@ -442,6 +510,6 @@
}
public String getDescription() {
- return "Implementation of FrF2 method method using R";
+ return "Implementation of FrF2 method method using R, at least 4 factors need to be declared";
}
}
Modified: trunk/sensitivity/SensitivityCalculatorRMorris.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRMorris.java 2009-04-07 15:25:54 UTC (rev 98)
+++ trunk/sensitivity/SensitivityCalculatorRMorris.java 2009-04-08 10:19:07 UTC (rev 99)
@@ -227,6 +227,22 @@
engine.voidEval(rInstruction);
log.info("Message sent to R" + rInstruction);
+ // Creating the factors vector.
+ rInstruction = "factornames<-c(";
+ for (int i = 0; i < factorNumber; i++) {
+ if (i != (factorNumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R" + rInstruction);
+
// Set output directory
engine.voidEval("setwd(\"" + outputdirectory.getAbsolutePath()
+ "\")");
@@ -237,6 +253,11 @@
engine.voidEval("dput(a,file=\".morris\")");
log.info("Message sent to R" + "dput(a,file=\".morris\")");
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R"
+ + "dput(factornames,file=\".factornames\")");
+
// Get back experiment plan
dataframe = (double[]) engine.eval("a$X");
log.info("Message sent to R" + "a$X");
@@ -302,6 +323,11 @@
engine.voidEval("a<-dget(\".morris\")");
log.info("Message sent to R : " + "a<-dget(\".morris\")");
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
/*int scenariosNumber = sensitivityScenarios.getScenarios().size();*/
int scenariosNumber = ((Double) engine
.eval("length(a$X)/length(a$factors)")).intValue();
@@ -361,12 +387,24 @@
engine.voidEval("df=data.frame(mu,mu.star,sigma)");
log.info("Message sent to R : "
+ "df=data.frame(mu,mu.star,sigma)");
+ engine.voidEval("row.names(df)<-factornames");
+ log.info("Message sent to R : " + "row.names(df)<-factornames");
//Create the data.frame of scenarios and results for export purpose
engine.voidEval("dfresults=data.frame(a$X,results)");
log.info("Message sent to R : "
- + "df=data.frame(mu,mu.star,sigma)");
+ + "dfresults=data.frame(a$X,results)");
+ //Set dfresults names
+ engine
+ .voidEval("resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ engine.voidEval("names(dfresults)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dfresults)<-resultsnames");
+
//Set working directory
engine.voidEval("setwd(\"" + outputdirectory.getAbsolutePath()
+ "\")");
Modified: trunk/sensitivity/SensitivityCalculatorROptimumLHS.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorROptimumLHS.java 2009-04-07 15:25:54 UTC (rev 98)
+++ trunk/sensitivity/SensitivityCalculatorROptimumLHS.java 2009-04-08 10:19:07 UTC (rev 99)
@@ -77,6 +77,7 @@
throws SensitivityException {
int factornumber = plan.getFactors().size();
+ List<Factor<? extends Serializable>> factors = plan.getFactors();
double[] dataframe = new double[0];
SensitivityScenarios thisExperiment = new SensitivityScenarios();
List<Scenario> thisExperimentScenarios = thisExperiment.getScenarios();
@@ -111,12 +112,10 @@
// Get back experiment plan
dataframe = (double[]) engine.eval("x");
log.info("Message sent to R : " + "x");
- log.info(dataframe);
// Transform the result from R in a matrix
MatrixND morris = MatrixFactory.getInstance().create(dataframe,
new int[] { factornumber, param_simulationNumber });
- log.info(morris);
// Setting up the scenarios.
for (int j = 0; j < param_simulationNumber; j++) {
@@ -222,6 +221,23 @@
engine.voidEval(data);
log.info("Message sent to R : " + data);
+ // Creating the factors vector.
+ rInstruction = "factornames<-c(";
+ for (int i = 0; i < factornumber; i++) {
+ if (i != (factornumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R : " + rInstruction);
+
// Set output directory
engine.voidEval("setwd(\"" + outputdirectory.getAbsolutePath()
+ "\")");
@@ -233,6 +249,11 @@
log.info("Message sent to R : "
+ "write.csv(data,file=\".optimumlhs.csv\")");
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R"
+ + "dput(factornames,file=\".factornames\")");
+
engine.terminate();
} catch (Exception e) {
@@ -277,6 +298,11 @@
log
.info("Message sent to R : factors<-read.csv(\".optimumlhs.csv\")");
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
//Get back the factors number
int factorNumber = ((Double) engine.eval("length(factors)-1"))
.intValue();
@@ -357,6 +383,9 @@
.voidEval("names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
log
.info("Message sent to R : names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ engine.voidEval("row.names(exportsensitivity)<-factornames");
+ log.info("Message sent to R : "
+ + "row.names(exportsensitivity)<-factornames");
/*Set the export directory
*Export directory is the first simulation export directory.
@@ -366,6 +395,16 @@
log.info("Message sent to R : setwd(\""
+ outputdirectory.getAbsolutePath() + "\")");
+ //Set dataforaov names
+ engine
+ .voidEval("resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ engine.voidEval("names(dataforaov)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dataforaov)<-resultsnames");
+
//Save the results with the scenarios.
engine.voidEval("write.csv(dataforaov,\""
+ simulationStorages.get(0).getParameter()
Modified: trunk/sensitivity/SensitivityCalculatorRRandomLHS.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRRandomLHS.java 2009-04-07 15:25:54 UTC (rev 98)
+++ trunk/sensitivity/SensitivityCalculatorRRandomLHS.java 2009-04-08 10:19:07 UTC (rev 99)
@@ -76,6 +76,7 @@
double[] dataframe = new double[0];
SensitivityScenarios thisExperiment = new SensitivityScenarios();
List<Scenario> thisExperimentScenarios = thisExperiment.getScenarios();
+ List<Factor<? extends Serializable>> factors = plan.getFactors();
if ((Integer) param_simulationNumber == 0) {
param_simulationNumber = 10;
@@ -206,6 +207,23 @@
engine.voidEval(data);
log.info("Message sent to R : " + data);
+ // Creating the factors vector.
+ String rInstruction = "factornames<-c(";
+ for (int i = 0; i < factornumber; i++) {
+ if (i != (factornumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R" + rInstruction);
+
// Set output directory
engine.voidEval("setwd(\"" + outputdirectory.getAbsolutePath()
+ "\")");
@@ -217,6 +235,11 @@
log.info("Message sent to R : "
+ "write.csv(data,file=\".randomlhs.csv\")");
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R"
+ + "dput(factornames,file=\".factornames\")");
+
engine.terminate();
} catch (Exception e) {
@@ -254,6 +277,11 @@
log
.info("Message sent to R : factors<-read.csv(\".randomlhs.csv\")");
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
//Get back the factors number
int factorNumber = ((Double) engine.eval("length(factors)-1"))
.intValue();
@@ -334,6 +362,9 @@
.voidEval("names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
log
.info("Message sent to R : names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ engine.voidEval("row.names(exportsensitivity)<-factornames");
+ log.info("Message sent to R : "
+ + "row.names(exportsensitivity)<-factornames");
/*Set the export directory
*Export directory is the first simulation export directory.
@@ -343,6 +374,16 @@
log.info("Message sent to R : setwd(\""
+ outputdirectory.getAbsolutePath() + "\")");
+ //Set dataforaov names
+ engine
+ .voidEval("resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ engine.voidEval("names(dataforaov)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dataforaov)<-resultsnames");
+
//Save the results with the scenarios.
engine.voidEval("write.csv(dataforaov,\""
+ simulationStorages.get(0).getParameter()
1
0
Author: jcouteau
Date: 2009-04-07 15:25:54 +0000 (Tue, 07 Apr 2009)
New Revision: 98
Removed:
trunk/exports/SensitivityBiomassPopage.java
trunk/exports/SensitivityCapturesPoidsPopage.java
Log:
Remove unused exports
Deleted: trunk/exports/SensitivityBiomassPopage.java
===================================================================
--- trunk/exports/SensitivityBiomassPopage.java 2009-04-07 15:09:00 UTC (rev 97)
+++ trunk/exports/SensitivityBiomassPopage.java 2009-04-07 15:25:54 UTC (rev 98)
@@ -1,71 +0,0 @@
-package exports;
-
-import static org.codelutin.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.math.matrix.MatrixIterator;
-import org.codelutin.math.matrix.MatrixND;
-
-import scripts.ResultName;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.export.SensitivityExport;
-import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.util.Doc;
-
-@Doc("Doc for SensitivityBiomassPopage")
-public class SensitivityBiomassPopage implements SensitivityExport {
-
- /** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(SensitivityBiomassPopage.class);
-
- protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
-
- @Override
- public void export(SimulationStorage simulation, Writer out)
- throws Exception {
- Date lastDate = simulation.getResultStorage().getLastDate();
- double biomass = 0.0;
- for (Population pop : simulation.getParameter().getPopulations()) {
- if (pop.getName().equals("popage")) {
- MatrixND mat = simulation.getResultStorage().getMatrix(pop,
- ResultName.MATRIX_BIOMASS);
- for (MatrixIterator i = mat.iterator(); i.hasNext();) {
- i.next();
- Object[] sems = i.getSemanticsCoordinates();
- Date date = (Date) sems[0];
-
- if (date.afterOrEquals(lastDate)) {
- biomass = biomass + i.getValue();
- }
- }
- }
- }
- out.write(Double.toString(biomass));
-
- }
-
- @Override
- public String getDescription() {
- return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
- }
-
- @Override
- public String getExportFilename() {
- return "SensitivityBiomassPopage";
- }
-
- @Override
- public String getExtensionFilename() {
- return ".csv";
- }
-
- @Override
- public String[] getNecessaryResult() {
- return this.necessaryResult;
- }
-
-}
Deleted: trunk/exports/SensitivityCapturesPoidsPopage.java
===================================================================
--- trunk/exports/SensitivityCapturesPoidsPopage.java 2009-04-07 15:09:00 UTC (rev 97)
+++ trunk/exports/SensitivityCapturesPoidsPopage.java 2009-04-07 15:25:54 UTC (rev 98)
@@ -1,75 +0,0 @@
-package exports;
-
-import static org.codelutin.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.math.matrix.MatrixIterator;
-import org.codelutin.math.matrix.MatrixND;
-
-import scripts.ResultName;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.export.SensitivityExport;
-import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.util.Doc;
-
-@Doc("Doc for SensitivityCapturesPoidsPopage")
-public class SensitivityCapturesPoidsPopage implements SensitivityExport {
-
- /** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(SensitivityCapturesPoidsPopage.class);
-
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
-
- @Override
- public void export(SimulationStorage simulation, Writer out)
- throws Exception {
- Date lastDate = simulation.getResultStorage().getLastDate();
- Double capturesWeight = 0.0;
-
- for (Population pop : simulation.getParameter().getPopulations()) {
- if (pop.getName().equals("popage")) {
- for (Date date = new Date(0); !date.after(lastDate); date = date
- .next()) {
- MatrixND mat = simulation
- .getResultStorage()
- .getMatrix(
- date,
- 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();
- capturesWeight=capturesWeight+i.getValue();
- }
- }
- }
- }
- }
- }
-
- @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");
- }
-
- @Override
- public String getExportFilename() {
- return "SensitivityCapturesPoidsPopage";
- }
-
- @Override
- public String getExtensionFilename() {
- return ".csv";
- }
-
- @Override
- public String[] getNecessaryResult() {
- return this.necessaryResult;
- }
-
-}
1
0