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-05-07 17:07:20 +0000 (Thu, 07 May 2009)
New Revision: 137
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
trunk/sensitivity/SensitivityCalculatorRSobol.java
trunk/sensitivity/SensitivityCalculatorRegularFractions.java
Log:
Sensitivity analysis (second pass) use less memory.
Modified: trunk/sensitivity/SensitivityCalculatorJavaExpandGrid.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorJavaExpandGrid.java 2009-05-07 16:40:51 UTC (rev 136)
+++ trunk/sensitivity/SensitivityCalculatorJavaExpandGrid.java 2009-05-07 17:07:20 UTC (rev 137)
@@ -28,6 +28,7 @@
import org.codelutin.util.FileUtil;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
@@ -114,7 +115,7 @@
Double value = min + ((max - min) / (card - 1) * rest);
if ((factor.getDomain() instanceof MatrixContinuousDomain)
|| (factor.getDomain() instanceof EquationContinuousDomain)) {
- factor.setValueForIdentifier(value.toString());
+ factor.setValueForIdentifier(value);
} else {
factor.setValueForIdentifier(value);
}
@@ -354,39 +355,39 @@
int factorNumber = ((Double) engine.eval("length(factors)-1"))
.intValue();
- int sensitivityNumber = simulationStorages.get(0).getParameter()
- .getSensitivityExport().size();
+ SimulationParameter param = simulationStorages.get(0)
+ .getParameter();
+ int sensitivityNumber = param.getSensitivityExport().size();
for (int k = 0; k < sensitivityNumber; k++) {
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
-
- //Create the results vectors
- String result = name + "<-c(";
+ // Creates the R expression to import results in R
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
+ String rInstruction = name + "<-c(";
for (int l = 0; l < simulationStorages.size(); l++) {
File importFile = new File(simulationStorages.get(l)
.getDirectory().toString()
+ File.separator
- + SimulationStorage.RESULT_EXPORT_DIRECTORY,
- simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExportFilename()
- + simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExtensionFilename());
+ + SimulationStorage.RESULT_EXPORT_DIRECTORY, param
+ .getSensitivityExport().get(k).getExportFilename()
+ + param.getSensitivityExport().get(k)
+ .getExtensionFilename());
String simulResult = FileUtil.readAsString(importFile);
double simulationResult = Double.valueOf(simulResult);
if (l < simulationStorages.size() - 1) {
- result = result + simulationResult + ",";
+ rInstruction = rInstruction + simulationResult + ",";
} else {
- result = result + simulationResult;
+ rInstruction = rInstruction + simulationResult;
}
}
- result = result + ")";
- engine.voidEval(result);
- log.info("Message sent to R : " + result);
+ rInstruction = rInstruction + ")";
+ log.info("Message sent to R : " + rInstruction);
+
+ // Send the simulation results
+ engine.voidEval(rInstruction);
+
//Put results in isis.simule
engine.voidEval("isis.simule<-data.frame(isis.simule," + name
+ ")");
@@ -477,23 +478,19 @@
//Save the results with the scenarios.
engine.voidEval("write.csv(dataforaov,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
log.info("Message sent to R : write.csv(dataforaov,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
//Save the sensitivity indices
engine.voidEval("write.csv(exportsensitivity,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
log.info("Message sent to R : write.csv(exportsensitivity,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
//FIXME export through java to enable export when using Rserve (when distant Rserve).
Modified: trunk/sensitivity/SensitivityCalculatorRFast.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRFast.java 2009-05-07 16:40:51 UTC (rev 136)
+++ trunk/sensitivity/SensitivityCalculatorRFast.java 2009-05-07 17:07:20 UTC (rev 137)
@@ -39,6 +39,7 @@
import org.rosuda.JRI.REXP;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Domain;
@@ -197,7 +198,7 @@
+ j] = dataframeVector.get(i).asDoubleArray()[j];
}
}
-
+
log.info("Message sent to R" + "a$X");
if (log.isDebugEnabled()) {
@@ -287,8 +288,8 @@
Factor factor = plan.getFactors().get(i);
if ((factor.getDomain() instanceof MatrixContinuousDomain)
|| (factor.getDomain() instanceof EquationContinuousDomain)) {
- factor.setValueForIdentifier(Double.valueOf(
- fast.getValue(new int[] { i, j })).toString());
+ factor.setValueForIdentifier(fast
+ .getValue(new int[] { i, j }));
} else {
Double value = (Double) ((ContinuousDomain) factor
.getDomain()).getMinBound()
@@ -346,26 +347,24 @@
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()
- .getSensitivityExport().size();
+ SimulationParameter param = simulationStorages.get(0)
+ .getParameter();
+ int sensitivityNumber = param.getSensitivityExport().size();
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
String rInstruction = name + "<-c(";
for (int l = 0; l < scenariosNumber; l++) {
File importFile = new File(simulationStorages.get(l)
.getDirectory().toString()
+ File.separator
- + SimulationStorage.RESULT_EXPORT_DIRECTORY,
- simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExportFilename()
- + simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExtensionFilename());
+ + SimulationStorage.RESULT_EXPORT_DIRECTORY, param
+ .getSensitivityExport().get(k).getExportFilename()
+ + param.getSensitivityExport().get(k)
+ .getExtensionFilename());
String simulResult = FileUtil.readAsString(importFile);
double simulationResult = Double.valueOf(simulResult);
if (l < simulationStorages.size() - 1) {
@@ -381,6 +380,9 @@
// Send the simulation results
engine.voidEval(rInstruction);
+ // Send the simulation results
+ engine.voidEval(rInstruction);
+
//Put results in isis.simule
engine.voidEval("isis.simule<-data.frame(isis.simule," + name
+ ")");
@@ -403,8 +405,8 @@
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
//Compute results
engine.voidEval("tell(a,y=" + name + ")");
@@ -447,13 +449,11 @@
//Export V
engine.voidEval("write.csv(a$V,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_V.csv\")");
log.info("Message sent to R : "
+ "write.csv(a$V,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_V.csv\")");
//Set D1 names
@@ -462,13 +462,11 @@
//Export D1
engine.voidEval("write.csv(a$D1,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_D1.csv\")");
log.info("Message sent to R : "
+ "write.csv(a$D1,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_D1.csv\")");
//Set Dt names
@@ -477,13 +475,11 @@
//Export Dt
engine.voidEval("write.csv(a$Dt,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Dt.csv\")");
log.info("Message sent to R : "
+ "write.csv(a$Dt,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Dt.csv\")");
//Set dfresults names
engine.voidEval("resultsnames<-c(factornames,\"Result\")");
@@ -495,13 +491,11 @@
//Export results
engine.voidEval("write.csv(dfresults,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
log.info("Message sent to R : "
+ "write.csv(results,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
//FIXME export through java to enable export when using Rserve
Modified: trunk/sensitivity/SensitivityCalculatorRFrF2.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRFrF2.java 2009-05-07 16:40:51 UTC (rev 136)
+++ trunk/sensitivity/SensitivityCalculatorRFrF2.java 2009-05-07 17:07:20 UTC (rev 137)
@@ -31,6 +31,7 @@
import org.codelutin.util.FileUtil;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
@@ -162,13 +163,11 @@
if ((factor.getDomain() instanceof MatrixContinuousDomain)
|| (factor.getDomain() instanceof EquationContinuousDomain)) {
if (frf2.getValue(new int[] { i, j }) == -1) {
- factor.setValueForIdentifier(Double.valueOf(0)
- .toString());
+ factor.setValueForIdentifier(0);
}
if (frf2.getValue(new int[] { i, j }) == 1) {
- factor.setValueForIdentifier(Double.valueOf(1)
- .toString());
+ factor.setValueForIdentifier(1);
}
} else {
if (frf2.getValue(new int[] { i, j }) == -1) {
@@ -290,8 +289,9 @@
REngine engine = new RProxy();
try {
- int sensitivityNumber = simulationStorages.get(0).getParameter()
- .getSensitivityExport().size();
+ SimulationParameter param = simulationStorages.get(0)
+ .getParameter();
+ int sensitivityNumber = param.getSensitivityExport().size();
for (int k = 0; k < sensitivityNumber; k++) {
@@ -322,31 +322,33 @@
int factorNumber = ((Double) engine.eval("length(factors)-1"))
.intValue();
- //Create the results vectors
- String result = "result<-c(";
+ // Creates the R expression to import results in R
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
+ String rInstruction = name + "<-c(";
for (int l = 0; l < simulationStorages.size(); l++) {
File importFile = new File(simulationStorages.get(l)
.getDirectory().toString()
+ File.separator
- + SimulationStorage.RESULT_EXPORT_DIRECTORY,
- simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExportFilename()
- + simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExtensionFilename());
+ + SimulationStorage.RESULT_EXPORT_DIRECTORY, param
+ .getSensitivityExport().get(k).getExportFilename()
+ + param.getSensitivityExport().get(k)
+ .getExtensionFilename());
String simulResult = FileUtil.readAsString(importFile);
double simulationResult = Double.valueOf(simulResult);
if (l < simulationStorages.size() - 1) {
- result = result + simulationResult + ",";
+ rInstruction = rInstruction + simulationResult + ",";
} else {
- result = result + simulationResult;
+ rInstruction = rInstruction + simulationResult;
}
}
- result = result + ")";
- engine.voidEval(result);
- log.info("Message sent to R : " + result);
+ rInstruction = rInstruction + ")";
+ log.info("Message sent to R : " + rInstruction);
+
+ // Send the simulation results
+ engine.voidEval(rInstruction);
+
//Create the dataforaov data.frame
String dataframe = "dataforaov<-data.frame(factors,result=result)";
engine.voidEval(dataframe);
@@ -472,23 +474,19 @@
//Save the results with the scenarios.
engine.voidEval("write.csv(dataforaov,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
log.info("Message sent to R : write.csv(dataforaov,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
//Save the sensitivity indices
engine.voidEval("write.csv(exportsensitivity,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
log.info("Message sent to R : write.csv(exportsensitivity,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
//FIXME export through java to enable export when using Rserve (when distant Rserve).
Modified: trunk/sensitivity/SensitivityCalculatorRMorris.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRMorris.java 2009-05-07 16:40:51 UTC (rev 136)
+++ trunk/sensitivity/SensitivityCalculatorRMorris.java 2009-05-07 17:07:20 UTC (rev 137)
@@ -37,6 +37,7 @@
import org.codelutin.util.FileUtil;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Domain;
@@ -343,25 +344,22 @@
.eval("length(a$X)/length(a$factors)")).intValue();
log.info("Message sent to R : " + "length(a$X)/length(a$factors)");
- int sensitivityNumber = simulationStorages.get(0).getParameter()
- .getSensitivityExport().size();
+ SimulationParameter param = simulationStorages.get(0).getParameter();
+ int sensitivityNumber = param.getSensitivityExport().size();
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
+ String name = param.getSensitivityExport().get(k).getExportFilename();
String rInstruction = name + "<-c(";
for (int l = 0; l < scenariosNumber; l++) {
File importFile = new File(simulationStorages.get(l)
.getDirectory().toString()
+ File.separator
+ SimulationStorage.RESULT_EXPORT_DIRECTORY,
- simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
+ param.getSensitivityExport().get(k)
.getExportFilename()
- + simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExtensionFilename());
String simulResult = FileUtil.readAsString(importFile);
double simulationResult = Double.valueOf(simulResult);
@@ -391,18 +389,15 @@
+ "attr(isis.simule,\"nomModel\")<-\"isis-fish-externe-R\"");
engine
.voidEval("attr(isis.simule,\"nomModel\")<-\"isis-fish-externe-R\"");
-
- log
- .info("Message sent to R : "
+
+ log.info("Message sent to R : "
+ "attr(isis.simule,\"call\")<-isis.MethodExp$call");
- engine
- .voidEval("attr(isis.simule,\"call\")<-isis.MethodExp$call");
+ engine.voidEval("attr(isis.simule,\"call\")<-isis.MethodExp$call");
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
+ String name = param.getSensitivityExport().get(k).getExportFilename();
//Compute results
engine.voidEval("tell(a,y=" + name + ")");
@@ -466,26 +461,22 @@
//Export sensitivity indices
engine.voidEval("write.csv(df,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
log.info("Message sent to R : "
+ "write.csv(df,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
//Export results
engine.voidEval("write.csv(dfresults,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
log.info("Message sent to R : "
+ "write.csv(results,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
//FIXME export through java to enable export when using Rserve
Modified: trunk/sensitivity/SensitivityCalculatorROptimumLHS.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorROptimumLHS.java 2009-05-07 16:40:51 UTC (rev 136)
+++ trunk/sensitivity/SensitivityCalculatorROptimumLHS.java 2009-05-07 17:07:20 UTC (rev 137)
@@ -36,6 +36,7 @@
import org.codelutin.util.FileUtil;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Domain;
@@ -182,10 +183,8 @@
Factor factor = plan.getFactors().get(i);
if ((factor.getDomain() instanceof MatrixContinuousDomain)
|| (factor.getDomain() instanceof EquationContinuousDomain)) {
- factor
- .setValueForIdentifier(Double.valueOf(
- morris.getValue(new int[] { i, j }))
- .toString());
+ factor.setValueForIdentifier(morris.getValue(new int[] {
+ i, j }));
} else {
Double value = (Double) ((ContinuousDomain) factor
.getDomain()).getMinBound()
@@ -445,29 +444,27 @@
param_simulationNumber = (Integer) (engine
.eval("length(factors[,1])"));
- int sensitivityNumber = simulationStorages.get(0).getParameter()
- .getSensitivityExport().size();
+ SimulationParameter param = simulationStorages.get(0)
+ .getParameter();
+ int sensitivityNumber = param.getSensitivityExport().size();
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
String rInstruction = name + "<-c(";
for (int l = 0; l < param_simulationNumber; l++) {
File importFile = new File(simulationStorages.get(l)
.getDirectory().toString()
+ File.separator
- + SimulationStorage.RESULT_EXPORT_DIRECTORY,
- simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExportFilename()
- + simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExtensionFilename());
+ + SimulationStorage.RESULT_EXPORT_DIRECTORY, param
+ .getSensitivityExport().get(k).getExportFilename()
+ + param.getSensitivityExport().get(k)
+ .getExtensionFilename());
String simulResult = FileUtil.readAsString(importFile);
double simulationResult = Double.valueOf(simulResult);
- if (l < param_simulationNumber - 1) {
+ if (l < simulationStorages.size() - 1) {
rInstruction = rInstruction + simulationResult + ",";
} else {
rInstruction = rInstruction + simulationResult;
@@ -480,6 +477,9 @@
// Send the simulation results
engine.voidEval(rInstruction);
+ // Send the simulation results
+ engine.voidEval(rInstruction);
+
//Put results in isis.simule
engine.voidEval("isis.simule<-data.frame(isis.simule," + name
+ ")");
@@ -501,8 +501,8 @@
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
//Create the dataforaov data.frame
String dataframe = "dataforaov<-data.frame(factors," + name
@@ -588,23 +588,19 @@
//Save the results with the scenarios.
engine.voidEval("write.csv(dataforaov,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
log.info("Message sent to R : write.csv(dataforaov,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
//Save the sensitivity indices
engine.voidEval("write.csv(exportsensitivity,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
log.info("Message sent to R : write.csv(exportsensitivity,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
//FIXME export through java to enable export when using Rserve (when distant Rserve).
Modified: trunk/sensitivity/SensitivityCalculatorRRandomLHS.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRRandomLHS.java 2009-05-07 16:40:51 UTC (rev 136)
+++ trunk/sensitivity/SensitivityCalculatorRRandomLHS.java 2009-05-07 17:07:20 UTC (rev 137)
@@ -36,6 +36,7 @@
import org.codelutin.util.FileUtil;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Domain;
@@ -118,8 +119,8 @@
//Get Isis R session
log.info("load(\".RData\")");
engine.voidEval("load(\".RData\")");
-
- //Set working directory for other results
+
+ //Set working directory for other results
log.info("setwd(\"" + outputdirectory + "\")");
engine.voidEval("setwd(\"" + outputdirectory + "\")");
@@ -129,8 +130,9 @@
//Create the scenarios
String rInstruction = "x<-randomLHS(%s,%s)";
- String rCall = String.format(rInstruction,param_simulationNumber,factornumber);
-
+ String rCall = String.format(rInstruction, param_simulationNumber,
+ factornumber);
+
if (param_modifR) {
JLabel label = new JLabel(
"Modifier le code R envoyé si vous le souhaitez");
@@ -147,7 +149,7 @@
JOptionPane.QUESTION_MESSAGE);
rCall = text.getText();
}
-
+
engine.voidEval(rCall);
log.info("Message sent to R : " + rCall);
@@ -166,8 +168,8 @@
Factor factor = plan.getFactors().get(i);
if ((factor.getDomain() instanceof MatrixContinuousDomain)
|| (factor.getDomain() instanceof EquationContinuousDomain)) {
- factor
- .setValueForIdentifier(morris.getValue(new int[] { i, j }));
+ factor.setValueForIdentifier(morris.getValue(new int[] {
+ i, j }));
} else {
Double value = (Double) ((ContinuousDomain) factor
.getDomain()).getMinBound()
@@ -411,33 +413,32 @@
//Get back the factors number
int factorNumber = ((Double) engine.eval("length(factors)-1"))
.intValue();
-
- //Get back the simulation number
- param_simulationNumber = (Integer)(engine.eval("length(factors[,1])"));
- int sensitivityNumber = simulationStorages.get(0).getParameter()
- .getSensitivityExport().size();
+ //Get back the simulation number
+ param_simulationNumber = (Integer) (engine
+ .eval("length(factors[,1])"));
+ SimulationParameter param = simulationStorages.get(0)
+ .getParameter();
+ int sensitivityNumber = param.getSensitivityExport().size();
+
for (int k = 0; k < sensitivityNumber; k++) {
- // Creates the R expression to import results in R
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
+ // Creates the R expression to import results in R
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
String rInstruction = name + "<-c(";
- for (int l = 0; l < param_simulationNumber; l++) {
+ for (int l = 0; l < simulationStorages.size(); l++) {
File importFile = new File(simulationStorages.get(l)
.getDirectory().toString()
+ File.separator
- + SimulationStorage.RESULT_EXPORT_DIRECTORY,
- simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExportFilename()
- + simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExtensionFilename());
+ + SimulationStorage.RESULT_EXPORT_DIRECTORY, param
+ .getSensitivityExport().get(k).getExportFilename()
+ + param.getSensitivityExport().get(k)
+ .getExtensionFilename());
String simulResult = FileUtil.readAsString(importFile);
double simulationResult = Double.valueOf(simulResult);
- if (l < param_simulationNumber - 1) {
+ if (l < simulationStorages.size() - 1) {
rInstruction = rInstruction + simulationResult + ",";
} else {
rInstruction = rInstruction + simulationResult;
@@ -471,8 +472,8 @@
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
//Create the dataforaov data.frame
String dataframe = "dataforaov<-data.frame(factors," + name
@@ -558,23 +559,19 @@
//Save the results with the scenarios.
engine.voidEval("write.csv(dataforaov,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
log.info("Message sent to R : write.csv(dataforaov,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
//Save the sensitivity indices
engine.voidEval("write.csv(exportsensitivity,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
log.info("Message sent to R : write.csv(exportsensitivity,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
//FIXME export through java to enable export when using Rserve (when distant Rserve).
Modified: trunk/sensitivity/SensitivityCalculatorRSobol.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRSobol.java 2009-05-07 16:40:51 UTC (rev 136)
+++ trunk/sensitivity/SensitivityCalculatorRSobol.java 2009-05-07 17:07:20 UTC (rev 137)
@@ -38,6 +38,7 @@
import org.rosuda.JRI.REXP;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Domain;
@@ -295,8 +296,8 @@
Factor factor = plan.getFactors().get(i);
if ((factor.getDomain() instanceof MatrixContinuousDomain)
|| (factor.getDomain() instanceof EquationContinuousDomain)) {
- factor.setValueForIdentifier(Double.valueOf(
- fast.getValue(new int[] { i, j })).toString());
+ factor.setValueForIdentifier(fast
+ .getValue(new int[] { i, j }));
} else {
Double value = (Double) ((ContinuousDomain) factor
.getDomain()).getMinBound()
@@ -370,26 +371,24 @@
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()
- .getSensitivityExport().size();
+ SimulationParameter param = simulationStorages.get(0)
+ .getParameter();
+ int sensitivityNumber = param.getSensitivityExport().size();
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
String rInstruction = name + "<-c(";
for (int l = 0; l < scenariosNumber; l++) {
File importFile = new File(simulationStorages.get(l)
.getDirectory().toString()
+ File.separator
- + SimulationStorage.RESULT_EXPORT_DIRECTORY,
- simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExportFilename()
- + simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExtensionFilename());
+ + SimulationStorage.RESULT_EXPORT_DIRECTORY, param
+ .getSensitivityExport().get(k).getExportFilename()
+ + param.getSensitivityExport().get(k)
+ .getExtensionFilename());
String simulResult = FileUtil.readAsString(importFile);
double simulationResult = Double.valueOf(simulResult);
if (l < simulationStorages.size() - 1) {
@@ -405,6 +404,9 @@
// Send the simulation results
engine.voidEval(rInstruction);
+ // Send the simulation results
+ engine.voidEval(rInstruction);
+
//Put results in isis.simule
engine.voidEval("isis.simule<-data.frame(isis.simule," + name
+ ")");
@@ -426,8 +428,8 @@
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
//Compute results
engine.voidEval("tell(a,y=" + name + ")");
@@ -461,47 +463,39 @@
//Export V
engine.voidEval("write.csv(a$V,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
log.info("Message sent to R : "
+ "write.csv(a$V,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_V.csv\")");
//Export DD
engine.voidEval("write.csv(a$D,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_D.csv\")");
log.info("Message sent to R : "
+ "write.csv(a$D,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_D.csv\")");
//Export S
engine.voidEval("write.csv(a$S,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_S.csv\")");
log.info("Message sent to R : "
+ "write.csv(a$S,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_S.csv\")");
//Export results
engine.voidEval("write.csv(dfresults,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
log.info("Message sent to R : "
+ "write.csv(results,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
//FIXME export through java to enable export when using Rserve
Modified: trunk/sensitivity/SensitivityCalculatorRegularFractions.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRegularFractions.java 2009-05-07 16:40:51 UTC (rev 136)
+++ trunk/sensitivity/SensitivityCalculatorRegularFractions.java 2009-05-07 17:07:20 UTC (rev 137)
@@ -19,6 +19,7 @@
import org.codelutin.util.FileUtil;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Domain;
@@ -381,39 +382,39 @@
int factorNumber = ((Double) engine.eval("length(factors)-1"))
.intValue();
- int sensitivityNumber = simulationStorages.get(0).getParameter()
- .getSensitivityExport().size();
+ SimulationParameter param = simulationStorages.get(0)
+ .getParameter();
+ int sensitivityNumber = param.getSensitivityExport().size();
for (int k = 0; k < sensitivityNumber; k++) {
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
-
- //Create the results vectors
- String result = name + "<-c(";
+ // Creates the R expression to import results in R
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
+ String rInstruction = name + "<-c(";
for (int l = 0; l < simulationStorages.size(); l++) {
File importFile = new File(simulationStorages.get(l)
.getDirectory().toString()
+ File.separator
- + SimulationStorage.RESULT_EXPORT_DIRECTORY,
- simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExportFilename()
- + simulationStorages.get(l).getParameter()
- .getSensitivityExport().get(k)
- .getExtensionFilename());
+ + SimulationStorage.RESULT_EXPORT_DIRECTORY, param
+ .getSensitivityExport().get(k).getExportFilename()
+ + param.getSensitivityExport().get(k)
+ .getExtensionFilename());
String simulResult = FileUtil.readAsString(importFile);
double simulationResult = Double.valueOf(simulResult);
if (l < simulationStorages.size() - 1) {
- result = result + simulationResult + ",";
+ rInstruction = rInstruction + simulationResult + ",";
} else {
- result = result + simulationResult;
+ rInstruction = rInstruction + simulationResult;
}
}
- result = result + ")";
- engine.voidEval(result);
- log.info("Message sent to R : " + result);
+ rInstruction = rInstruction + ")";
+ log.info("Message sent to R : " + rInstruction);
+
+ // Send the simulation results
+ engine.voidEval(rInstruction);
+
//Put results in isis.simule
engine.voidEval("isis.simule<-data.frame(isis.simule," + name
+ ")");
@@ -431,8 +432,7 @@
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String name = simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k).getExportFilename();
+ String name = param.getSensitivityExport().get(k).getExportFilename();
//Create the dataforaov data.frame
String dataframe = "dataforaov<-data.frame(factors," + name
@@ -518,23 +518,19 @@
//Save the results with the scenarios.
engine.voidEval("write.csv(dataforaov,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
log.info("Message sent to R : write.csv(dataforaov,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename() + "_Results.csv\")");
//Save the sensitivity indices
engine.voidEval("write.csv(exportsensitivity,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
log.info("Message sent to R : write.csv(exportsensitivity,\""
- + simulationStorages.get(0).getParameter()
- .getSensitivityExport().get(k)
+ + param.getSensitivityExport().get(k)
.getExportFilename()
+ "_SensitivityIndices.csv\")");
//FIXME export through java to enable export when using Rserve (when distant Rserve).
1
0
Author: jcouteau
Date: 2009-05-07 16:40:51 +0000 (Thu, 07 May 2009)
New Revision: 136
Modified:
trunk/exports/SensitivityCapturesWeightReferenceY7.java
trunk/exports/SensitivityCapturesWeightRelativeReferenceY10.java
trunk/exports/SensitivityCapturesWeightRelativeY4.java
trunk/exports/SensitivityCapturesWeightY1.java
Log:
Fix captures weight export
Modified: trunk/exports/SensitivityCapturesWeightReferenceY7.java
===================================================================
--- trunk/exports/SensitivityCapturesWeightReferenceY7.java 2009-05-07 12:41:53 UTC (rev 135)
+++ trunk/exports/SensitivityCapturesWeightReferenceY7.java 2009-05-07 16:40:51 UTC (rev 136)
@@ -24,7 +24,7 @@
static private Log log = LogFactory
.getLog(SensitivityCapturesWeightReferenceY7.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET };
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
@Doc("Population")
public Population param_pop;
@@ -53,7 +53,7 @@
.getMatrix(
new Date(lastDate.getDate() - i),
pop,
- ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET);
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
capturesWeight += matlastdate.sumAll();
//Get the reference captures Weight of each month of the last year
@@ -62,7 +62,7 @@
MatrixND matlastdatereference = referenceResultStorage
.getMatrix(
new Date(lastDate.getDate() - i),
- ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ " " + pop, tx);
capturesWeightReference += matlastdatereference.sumAll();
tx.commitTransaction();
Modified: trunk/exports/SensitivityCapturesWeightRelativeReferenceY10.java
===================================================================
--- trunk/exports/SensitivityCapturesWeightRelativeReferenceY10.java 2009-05-07 12:41:53 UTC (rev 135)
+++ trunk/exports/SensitivityCapturesWeightRelativeReferenceY10.java 2009-05-07 16:40:51 UTC (rev 136)
@@ -25,7 +25,7 @@
static private Log log = LogFactory
.getLog(SensitivityCapturesWeightRelativeReferenceY10.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET };
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
@Doc("Population")
public Population param_pop;
@@ -56,7 +56,7 @@
.getMatrix(
new Date(lastDate.getDate() - i),
pop,
- ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET);
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
capturesWeight += matlastdate.sumAll();
//Get the captures Weight of each month of the first year
@@ -64,7 +64,7 @@
.getMatrix(
new Date(i),
pop,
- ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET);
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
capturesWeightfirst += matfirstdate.sumAll();
//Get the reference captures Weight of each month of the last year
Modified: trunk/exports/SensitivityCapturesWeightRelativeY4.java
===================================================================
--- trunk/exports/SensitivityCapturesWeightRelativeY4.java 2009-05-07 12:41:53 UTC (rev 135)
+++ trunk/exports/SensitivityCapturesWeightRelativeY4.java 2009-05-07 16:40:51 UTC (rev 136)
@@ -23,7 +23,7 @@
static private Log log = LogFactory
.getLog(SensitivityCapturesWeightRelativeY4.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET };
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
@Doc("Population")
public Population param_pop;
@@ -45,7 +45,7 @@
.getMatrix(
new Date(lastDate.getDate() - i),
pop,
- ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET);
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
capturesWeight += matlastdate.sumAll();
//Get the captures Weight of each month of the first year
@@ -53,7 +53,7 @@
.getMatrix(
new Date(i),
pop,
- ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET);
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
capturesWeightfirst += matfirstdate.sumAll();
}
Modified: trunk/exports/SensitivityCapturesWeightY1.java
===================================================================
--- trunk/exports/SensitivityCapturesWeightY1.java 2009-05-07 12:41:53 UTC (rev 135)
+++ trunk/exports/SensitivityCapturesWeightY1.java 2009-05-07 16:40:51 UTC (rev 136)
@@ -23,7 +23,7 @@
static private Log log = LogFactory
.getLog(SensitivityCapturesWeightY1.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET };
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
@Doc("Population")
public Population param_pop;
@@ -44,7 +44,7 @@
.getMatrix(
new Date(lastDate.getDate() - i),
pop,
- ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET);
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
capturesWeight += matlastdate.sumAll();
}
1
0
Author: jcouteau
Date: 2009-05-07 12:41:53 +0000 (Thu, 07 May 2009)
New Revision: 135
Modified:
trunk/exports/RejetsNombre.java
trunk/scripts/GravityModel.java
trunk/scripts/SiMatrix.java
Log:
Fix 3 wrong files
Modified: trunk/exports/RejetsNombre.java
===================================================================
--- trunk/exports/RejetsNombre.java 2009-05-07 12:27:08 UTC (rev 134)
+++ trunk/exports/RejetsNombre.java 2009-05-07 12:41:53 UTC (rev 135)
@@ -61,7 +61,7 @@
for (Date date = new Date(0); !date.after(lastDate); date = date
.next()) {
MatrixND mat = simulation.getResultStorage().getMatrix(date,
- pop, ResultName.MATRIX_DISCARDS_PER_STR_MET);
+ pop, ResultName.MATRIX_DISCARDS_PER_STR_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();) {
Modified: trunk/scripts/GravityModel.java
===================================================================
--- trunk/scripts/GravityModel.java 2009-05-07 12:27:08 UTC (rev 134)
+++ trunk/scripts/GravityModel.java 2009-05-07 12:41:53 UTC (rev 135)
@@ -652,7 +652,7 @@
private double getDiscardsWeightPerStrMet(Strategy str, Metier metier,
PopulationGroup group, Zone zone, Date date) {
MatrixND mat = resultManager.getMatrix(date, group.getPopulation(),
- ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET);
+ ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
double result = 0;
if (mat != null) {
result = mat.getValue(str, metier, group, zone);
Modified: trunk/scripts/SiMatrix.java
===================================================================
--- trunk/scripts/SiMatrix.java 2009-05-07 12:27:08 UTC (rev 134)
+++ trunk/scripts/SiMatrix.java 2009-05-07 12:41:53 UTC (rev 135)
@@ -1801,7 +1801,7 @@
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = matrixDiscardPerStrategyMetPerZonePop.copy();
- result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET);
+ result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
for (PopulationGroup group : groups) {
MatrixND sub = result.getSubMatrix(2, group, 1);
1
0
r134 - in trunk: exports rules scripts simulators
by jcouteau@users.labs.libre-entreprise.org 07 May '09
by jcouteau@users.labs.libre-entreprise.org 07 May '09
07 May '09
Author: jcouteau
Date: 2009-05-07 12:27:08 +0000 (Thu, 07 May 2009)
New Revision: 134
Modified:
trunk/exports/CapturesNombre.java
trunk/exports/RejetsNombre.java
trunk/exports/RejetsPoids.java
trunk/rules/TACpoids.java
trunk/rules/TailleMin.java
trunk/scripts/ResultName.java
trunk/scripts/SiMatrix.java
trunk/simulators/DefaultSimulator.java
Log:
Repair wrong commit
Modified: trunk/exports/CapturesNombre.java
===================================================================
--- trunk/exports/CapturesNombre.java 2009-05-04 08:54:52 UTC (rev 133)
+++ trunk/exports/CapturesNombre.java 2009-05-07 12:27:08 UTC (rev 134)
@@ -35,7 +35,7 @@
/** 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 };
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP };
public String[] getNecessaryResult() {
return this.necessaryResult;
@@ -61,7 +61,7 @@
for (Date date = new Date(0); !date.after(lastDate); date = date
.next()) {
MatrixND mat = simulation.getResultStorage().getMatrix(date,
- pop, ResultName.MATRIX_CATCH_PER_STRATEGY_MET);
+ 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();) {
Modified: trunk/exports/RejetsNombre.java
===================================================================
--- trunk/exports/RejetsNombre.java 2009-05-04 08:54:52 UTC (rev 133)
+++ trunk/exports/RejetsNombre.java 2009-05-07 12:27:08 UTC (rev 134)
@@ -35,7 +35,7 @@
/** 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 };
+ protected String[] necessaryResult = { ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP };
public String[] getNecessaryResult() {
return this.necessaryResult;
Modified: trunk/exports/RejetsPoids.java
===================================================================
--- trunk/exports/RejetsPoids.java 2009-05-04 08:54:52 UTC (rev 133)
+++ trunk/exports/RejetsPoids.java 2009-05-07 12:27:08 UTC (rev 134)
@@ -35,7 +35,7 @@
/** 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
+ protected String[] necessaryResult = { ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP
};
@@ -63,7 +63,7 @@
for (Date date = new Date(0); !date.after(lastDate); date = date
.next()) {
MatrixND mat = simulation.getResultStorage().getMatrix(date,
- pop, ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET);
+ pop, ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_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();) {
Modified: trunk/rules/TACpoids.java
===================================================================
--- trunk/rules/TACpoids.java 2009-05-04 08:54:52 UTC (rev 133)
+++ trunk/rules/TACpoids.java 2009-05-07 12:27:08 UTC (rev 134)
@@ -313,7 +313,7 @@
log.info("catch = " + popMon.getCatch(pop));
discard = popMon.getCatch(pop).copy();
// ca ne doit pas pouvoir marcher car MATRIX_DISCARDS_PER_STR_MET est de dimension pop groupe str met - et discard n'a plus la dimension pop
- discard.setName(ResultName.MATRIX_DISCARDS_PER_STR_MET);
+ discard.setName(ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP);
popMon.addDiscard(date, pop, discard);
log.info("[TAC] add discard for " + pop + ": "
+ discard);
Modified: trunk/rules/TailleMin.java
===================================================================
--- trunk/rules/TailleMin.java 2009-05-04 08:54:52 UTC (rev 133)
+++ trunk/rules/TailleMin.java 2009-05-07 12:27:08 UTC (rev 134)
@@ -203,7 +203,7 @@
* param_propSurvie);
}
}
- discard.setName(ResultName.MATRIX_DISCARDS_PER_STR_MET);
+ discard.setName(ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP);
popMon.addDiscard(date, pop, discard);
}
}
Modified: trunk/scripts/ResultName.java
===================================================================
--- trunk/scripts/ResultName.java 2009-05-04 08:54:52 UTC (rev 133)
+++ trunk/scripts/ResultName.java 2009-05-07 12:27:08 UTC (rev 134)
@@ -41,95 +41,103 @@
* ensuite lors de la creation de la matrice.
* <p>
* Ceci permet d'avoir un endroit unique ou l'on voit l'ensemble des resultats
- * potentiellement disponible et de ne pas ce tromper en ecrivent le nom
- * d'un resultat
+ * potentiellement disponible et de ne pas ce tromper en ecrivent le nom d'un
+ * resultat
* <p>
- * Cette classe ne doit contenir que des noms de resultat en static public String
- * l'interface de lancement de simulation se base sur cette classe pour
+ * Cette classe ne doit contenir que des noms de resultat en static public
+ * String l'interface de lancement de simulation se base sur cette classe pour
* afficher l'ensemble des resultats disponible
*
* @author poussin
*/
public class ResultName {
@Doc(value = "do the doc of Result matrixDiscardsWeightPerStrMet")
- static final public String MATRIX_DISCARDS_WEIGHT_PER_STR_MET = n_("matrixDiscardsWeightPerStrMet");
+ static final public String MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP = n_("matrixDiscardsWeightPerStrMetPerZonePop");
- @Doc(value = "do the doc of Result matrixDiscardsPerStrMet")
- static final public String MATRIX_DISCARDS_PER_STR_MET = n_("matrixDiscardsPerStrMet");
- @Doc(value = "do the doc of Result matrixLandingPerMet")
+ @Doc(value = "do the doc of Result matrixDiscardsPerStrMet")
+ static final public String MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP = n_("matrixDiscardsPerStrMetPerZonePop");
+ @Doc(value = "do the doc of Result matrixLandingPerMet")
static final public String MATRIX_LANDING_PER_MET = n_("matrixLandingPerMet");
- @Doc(value = "do the doc of Result matrixEffortPerStrategyMet")
+ @Doc(value = "do the doc of Result matrixEffortPerStrategyMet")
static final public String MATRIX_EFFORT_PER_STRATEGY_MET = n_("matrixEffortPerStrategyMet");
- @Doc(value = "do the doc of Result matrixEffortNominalPerStrategyMet")
+ @Doc(value = "do the doc of Result matrixEffortNominalPerStrategyMet")
static final public String MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET = n_("matrixEffortNominalPerStrategyMet");
- @Doc(value = "do the doc of Result matrixStdTravelEffortPerStrategyMet")
+ @Doc(value = "do the doc of Result matrixStdTravelEffortPerStrategyMet")
static final public String MATRIX_STD_TRAVEL_EFFORT_PER_STRATEGY_MET = n_("matrixStdTravelEffortPerStrategyMet");
- @Doc(value = "do the doc of Result matrixEffortPerZonePop")
+ @Doc(value = "do the doc of Result matrixEffortPerZonePop")
static final public String MATRIX_EFFORT_PER_ZONE_POP = n_("matrixEffortPerZonePop");
- @Doc(value = "do the doc of Result matrixCatchRatePerStrategyMet")
- static final public String MATRIX_CATCH_RATE_PER_STRATEGY_MET = n_("matrixCatchRatePerStrategyMet");
- @Doc(value = "do the doc of Result matrixCatchPerStrategyMet")
- static final public String MATRIX_CATCH_PER_STRATEGY_MET = n_("matrixCatchPerStrategyMet");
- @Doc(value = "do the doc of Result matrixFishingMortality")
+ @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");
+ @Doc(value = "do the doc of Result matrixCatchPerStrategyMetPerZoneMet")
+ static final public String MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_MET = n_("matrixCatchPerStrategyMetPerZoneMet");
+ @Doc(value = "do the doc of Result matrixCatchPerStrategyMetPerZonePop")
+ static final public String MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP = n_("matrixCatchPerStrategyMetPerZonePop");
+ @Doc(value = "do the doc of Result matrixCatchWeightPerStrategyMetPerZoneMet")
+ static final public String MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_MET = n_("matrixCatchWeightPerStrategyMetPerZoneMet");
+ @Doc(value = "do the doc of Result matrixCatchWeightPerStrategyMetPerZonePop")
+ static final public String MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP = n_("matrixCatchWeightPerStrategyMetPerZonePop");
+ @Doc(value = "Disponible uniquement avec les simulations par Zone. do the doc of Result matrixFishingMortality")
static final public String MATRIX_FISHING_MORTALITY = n_("matrixFishingMortality");
- @Doc(value = "do the doc of Result matrixCatchWeightPerStrategyMet")
+ @Doc(value = "do the doc of Result matrixCatchWeightPerStrategyMet")
static final public String MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET = n_("matrixCatchWeightPerStrategyMet");
- @Doc(value = "do the doc of Result matrixAbundance")
+ @Doc(value = "do the doc of Result matrixAbundance")
static final public String MATRIX_ABUNDANCE = n_("matrixAbundance");
- @Doc(value = "do the doc of Result matrixBiomass")
+ @Doc(value = "do the doc of Result matrixBiomass")
+ static final public String MATRIX_ABUNDANCE_BEGIN_MONTH = n_("matrixAbundanceBeginMonth");
+ @Doc(value = "do the doc of Result matrixBiomass")
static final public String MATRIX_BIOMASS = n_("matrixBiomass");
+ @Doc(value = "do the doc of Result matrixBiomass")
+ static final public String MATRIX_BIOMASS_BEGIN_MONTH = n_("matrixBiomassBeginMonth");
- @Doc(value = "do the doc of Result matrixFishingTimePerMonthPerVessel")
+ @Doc(value = "do the doc of Result matrixFishingTimePerMonthPerVessel")
static final public String MATRIX_FISHING_TIME_PER_MONTH_PER_VESSEL = n_("matrixFishingTimePerMonthPerVessel");
- @Doc(value = "do the doc of Result matrixFuelCostsOfTravelPerVessel")
+ @Doc(value = "do the doc of Result matrixFuelCostsOfTravelPerVessel")
static final public String MATRIX_FUEL_COSTS_OF_TRAVEL_PER_VESSEL = n_("matrixFuelCostsOfTravelPerVessel");
- @Doc(value = "do the doc of Result matrixCostsOfFishingPerVessel")
+ @Doc(value = "do the doc of Result matrixCostsOfFishingPerVessel")
static final public String MATRIX_COSTS_OF_FISHING_PER_VESSEL = n_("matrixCostsOfFishingPerVessel");
- @Doc(value = "do the doc of Result matrixFuelCostsPerVessel")
+ @Doc(value = "do the doc of Result matrixFuelCostsPerVessel")
static final public String MATRIX_FUEL_COSTS_PER_VESSEL = n_("matrixFuelCostsPerVessel");
- @Doc(value = "do the doc of Result matrixRepairAndMaintenanceGearCostsPerVessel")
+ @Doc(value = "do the doc of Result matrixRepairAndMaintenanceGearCostsPerVessel")
static final public String MATRIX_REPAIR_AND_MAINTENANCE_GEAR_COSTS_PER_VESSEL = n_("matrixRepairAndMaintenanceGearCostsPerVessel");
- @Doc(value = "do the doc of Result matrixOtherRunningCostsPerVessel")
+ @Doc(value = "do the doc of Result matrixOtherRunningCostsPerVessel")
static final public String MATRIX_OTHER_RUNNING_COSTS_PER_VESSEL = n_("matrixOtherRunningCostsPerVessel");
- @Doc(value = "do the doc of Result matrixSharedNotFixedCostsPerVessel")
+ @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_FIXED_COSTS_PER_VESSEL_PER_MET = n_("matrixSharedFixedCostsPerVesselPerMet");
- @Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerSpeciesPerStrategyMet")
+ // static final public String MATRIX_SHARED_FIXED_COSTS_PER_VESSEL_PER_MET = n_("matrixSharedFixedCostsPerVesselPerMet");
+ @Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerSpeciesPerStrategyMet")
static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET = n_("matrixGrossValueOfLandingsPerSpeciesPerStrategyMet");
- @Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerStrategyMet")
+ @Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerStrategyMet")
static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET = n_("matrixGrossValueOfLandingsPerStrategyMet");
- @Doc(value = "do the doc of Result matrixGrossValueOfLandingsOtherSpeciesPerStrategyMet")
+ @Doc(value = "do the doc of Result matrixGrossValueOfLandingsOtherSpeciesPerStrategyMet")
static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_OTHER_SPECIES_PER_STRATEGY_MET = n_("matrixGrossValueOfLandingsOtherSpeciesPerStrategyMet");
- @Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerStrategyMetPerVessel")
+ @Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerStrategyMetPerVessel")
static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL = n_("matrixGrossValueOfLandingsPerStrategyMetPerVessel");
- @Doc(value = "do the doc of Result matrixNetValueOfLandingsPerStrategyMet")
+ @Doc(value = "do the doc of Result matrixNetValueOfLandingsPerStrategyMet")
static final public String MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET = n_("matrixNetValueOfLandingsPerStrategyMet");
- @Doc(value = "do the doc of Result matrixNetValueOfLandingsPerStrategyMetPerVessel")
+ @Doc(value = "do the doc of Result matrixNetValueOfLandingsPerStrategyMetPerVessel")
static final public String MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL = n_("matrixNetValueOfLandingsPerStrategyMetPerVessel");
- @Doc(value = "do the doc of Result matrixNetRenevueToSharePerStrategyMetPerVessel")
+ @Doc(value = "do the doc of Result matrixNetRenevueToSharePerStrategyMetPerVessel")
static final public String MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL = n_("matrixNetRenevueToSharePerStrategyMetPerVessel");
- @Doc(value = "do the doc of Result matrixCrewSharePerStrategyPerVessel")
+ @Doc(value = "do the doc of Result matrixCrewSharePerStrategyPerVessel")
static final public String MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL = n_("matrixCrewSharePerStrategyPerVessel");
- @Doc(value = "do the doc of Result matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel")
+ @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");
- @Doc(value = "do the doc of Result matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel")
+ @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");
- @Doc(value = "do the doc of Result matrixOwnerMarginOverVariableCostsPerStrategyPerVessel")
+ @Doc(value = "do the doc of Result matrixOwnerMarginOverVariableCostsPerStrategyPerVessel")
static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL = n_("matrixOwnerMarginOverVariableCostsPerStrategyPerVessel");
- @Doc(value = "do the doc of Result matrixOwnerMarginOverVariableCostsPerStrategy")
+ @Doc(value = "do the doc of Result matrixOwnerMarginOverVariableCostsPerStrategy")
static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY = n_("matrixOwnerMarginOverVariableCostsPerStrategy");
- @Doc(value = "do the doc of Result matrixVesselMarginOverVariableCostsPerStrategyPerVessel")
+ @Doc(value = "do the doc of Result matrixVesselMarginOverVariableCostsPerStrategyPerVessel")
static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL = n_("matrixVesselMarginOverVariableCostsPerStrategyPerVessel");
- @Doc(value = "do the doc of Result matrixVesselMarginOverVariableCostsPerStrategy")
+ @Doc(value = "do the doc of Result matrixVesselMarginOverVariableCostsPerStrategy")
static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY = n_("matrixVesselMarginOverVariableCostsPerStrategy");
- @Doc(value = "do the doc of Result matrixNoActivity")
+ @Doc(value = "do the doc of Result matrixNoActivity")
static final public String MATRIX_NO_ACTIVITY = n_("matrixNoActivity");
- @Doc(value = "do the doc of Result matrixMetierZone")
+ @Doc(value = "do the doc of Result matrixMetierZone")
static final public String MATRIX_METIER_ZONE = n_("matrixMetierZone");
- @Doc(value = "do the doc of Result matrixPrice")
+ @Doc(value = "do the doc of Result matrixPrice")
static final public String MATRIX_PRICE = n_("matrixPrice");
}
-
-
Modified: trunk/scripts/SiMatrix.java
===================================================================
--- trunk/scripts/SiMatrix.java 2009-05-04 08:54:52 UTC (rev 133)
+++ trunk/scripts/SiMatrix.java 2009-05-07 12:27:08 UTC (rev 134)
@@ -282,7 +282,7 @@
.getSemantics(4));
MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_CATCH_PER_STRATEGY_MET,
+ ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP,
new List[] { strategies, metiers, groups, zones },
new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
n_("Zones") });
@@ -333,7 +333,7 @@
// on somme sur les cellules
MatrixND result = matrixCatchPerStrategyMetPerCell.sumOverDim(4);
result = result.reduceDims(4);
- result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET);
+ result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP);
return result;
}
@@ -377,7 +377,7 @@
// on le passe en argument ce qui evite de le calculer 2 fois
// MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, date);
MatrixND result = matrixCatchRatePerStrategyMet.copy();
- result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET);
+ result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP);
for (PopulationGroup group : groups) {
MatrixND sub = result.getSubMatrix(2, group, 1);
@@ -409,7 +409,7 @@
List<Zone> zones = pop.getPopulationZone();
MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_CATCH_RATE_PER_STRATEGY_MET,
+ 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") });
@@ -1685,7 +1685,7 @@
List<Zone> zones = N.getSemantics(1);
MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_BIOMASS, new List[] { groups, zones },
+ ResultName.MATRIX_BIOMASS_BEGIN_MONTH, new List[] { groups, zones },
new String[] { n_("Groups"), n_("Zones") });
for (int g = 0; g < groups.size(); g++) {
@@ -1707,7 +1707,7 @@
List<Zone> zones = N.getSemantics(1);
MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_ABUNDANCE, new List[] { groups, zones },
+ ResultName.MATRIX_ABUNDANCE_BEGIN_MONTH, new List[] { groups, zones },
new String[] { n_("Groups"), n_("Zones") });
for (int g = 0; g < groups.size(); g++) {
Modified: trunk/simulators/DefaultSimulator.java
===================================================================
--- trunk/simulators/DefaultSimulator.java 2009-05-04 08:54:52 UTC (rev 133)
+++ trunk/simulators/DefaultSimulator.java 2009-05-07 12:27:08 UTC (rev 134)
@@ -283,7 +283,7 @@
if (discard != null || date.getDate() == 0) { // force discard for the first month to have discard in result
if (discard == null) {
discard = MatrixFactory.getInstance().create(
- ResultName.MATRIX_DISCARDS_PER_STR_MET,
+ ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP,
new List[] { siMatrix.getStrategies(date),
siMatrix.getMetiers(date),
pop.getPopulationGroup(),
@@ -295,7 +295,7 @@
resManager.addResult(date, pop, discard);
if (resManager
- .isEnabled(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET)) {
+ .isEnabled(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP)) {
MatrixND discardWeightPerStrategyMet = siMatrix
.matrixDiscardWeightPerStrategyMetPerZonePop(
pop, date, discard);
1
0
Author: jcouteau
Date: 2009-05-04 08:54:52 +0000 (Mon, 04 May 2009)
New Revision: 133
Modified:
trunk/rules/CantonnementPreSimu.java
Log:
correct nullpointer bug when param_gear is null
Modified: trunk/rules/CantonnementPreSimu.java
===================================================================
--- trunk/rules/CantonnementPreSimu.java 2009-04-30 15:23:04 UTC (rev 132)
+++ trunk/rules/CantonnementPreSimu.java 2009-05-04 08:54:52 UTC (rev 133)
@@ -129,7 +129,9 @@
// Rechargement du param_zone depuis le context courant
param_zone = zoneDao.findByTopiaId(param_zone.getTopiaId());
+ if (param_gear!=null){
param_gear = gearDao.findByTopiaId(param_gear.getTopiaId());
+ }
// List<Metier> metiers = metierDao.findAll();
List<Month> SaisonFermee = Month.getMonths(param_beginMonth, param_endMonth);
1
0
Author: chatellier
Date: 2009-04-30 15:23:04 +0000 (Thu, 30 Apr 2009)
New Revision: 132
Modified:
trunk/rules/CantonnementPreSimu.java
Log:
Rechargement des param depuis la base de donn?\195?\169es (erreur org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: fr.ifremer.isisfish.entities.ZoneImpl.cell, no session or session was closed)
Modified: trunk/rules/CantonnementPreSimu.java
===================================================================
--- trunk/rules/CantonnementPreSimu.java 2009-04-29 10:27:13 UTC (rev 131)
+++ trunk/rules/CantonnementPreSimu.java 2009-04-30 15:23:04 UTC (rev 132)
@@ -124,8 +124,13 @@
// MetierDAO metierDao = IsisFishDAOHelper.getMetierDAO(context.getDB());
ZoneDAO zoneDao = IsisFishDAOHelper.getZoneDAO(context.getDB());
+ GearDAO gearDao = IsisFishDAOHelper.getGearDAO(context.getDB());
MetierSeasonInfoDAO metierSeasonInfoDao = IsisFishDAOHelper.getMetierSeasonInfoDAO(context.getDB());
+ // Rechargement du param_zone depuis le context courant
+ param_zone = zoneDao.findByTopiaId(param_zone.getTopiaId());
+ param_gear = gearDao.findByTopiaId(param_gear.getTopiaId());
+
// List<Metier> metiers = metierDao.findAll();
List<Month> SaisonFermee = Month.getMonths(param_beginMonth, param_endMonth);
List<Cell> maillefermee = param_zone.getCell();
1
0
Author: jcouteau
Date: 2009-04-29 10:27:13 +0000 (Wed, 29 Apr 2009)
New Revision: 131
Modified:
trunk/sensitivity/SensitivityCalculatorRSobol.java
Log:
Adaptation de la m?\195?\169thode de Sobol au nouveau CDC
Pop-up d'erreur si facteur discret
Possibilit?\195?\169 de modifier l'instruction R
Modified: trunk/sensitivity/SensitivityCalculatorRSobol.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRSobol.java 2009-04-29 09:47:25 UTC (rev 130)
+++ trunk/sensitivity/SensitivityCalculatorRSobol.java 2009-04-29 10:27:13 UTC (rev 131)
@@ -19,10 +19,15 @@
package sensitivity;
import java.io.File;
-import java.io.Serializable;
import java.util.List;
import java.util.Vector;
+import javax.swing.Box;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTextPane;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.j2r.REngine;
@@ -33,11 +38,11 @@
import org.rosuda.JRI.REXP;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
+import fr.ifremer.isisfish.simulator.sensitivity.Domain;
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.Scenario;
-import fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator;
-import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityScenarios;
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
@@ -61,14 +66,14 @@
private static Log log = LogFactory
.getLog(SensitivityCalculatorRFast.class);
- @Doc("doc")
- public int param_n;
+ @Doc("the size of the 2 random samples")
+ public int param_n = 20;
- @Doc("an integer, the maximum order in the ANOVA decomposition (all indices up to this order will be computed)")
- public int param_order;
+ @Doc("the number of bootstrap replicates.")
+ public int param_nboot = 20;
- @Doc("doc")
- public int param_nboot;
+ @Doc("True to be able to modify the code sent to R")
+ public boolean param_modifR = false;
/**
* Retourne vrai si le calculateur sait gerer la cardinalité des facteurs
@@ -82,6 +87,8 @@
public SensitivityScenarios compute(DesignPlan plan, File outputdirectory) {
+ setIsisFactorsR(plan, outputdirectory);
+
double[] dataframe = new double[0];
int nbExperiments = 0;
int factorNumber = plan.getFactors().size();
@@ -92,14 +99,49 @@
//Test all factors, if one is discrete, return null
for (int i = 0; i < factorNumber; i++) {
if (factors.get(i).getDomain() instanceof DiscreteDomain) {
+ JOptionPane
+ .showMessageDialog(
+ null,
+ "Error",
+ factors.get(i).getName()
+ + " has a discrete domain, this is not acceptable for this method.",
+ JOptionPane.ERROR_MESSAGE);
return null;
}
}
+ String rInstruction = "a<-sobol2002(model=NULL,X1=X1,X2=X2,nboot=%s)";
+ String rCall = String.format(rInstruction, param_nboot);
+
+ if (param_modifR) {
+ JLabel label = new JLabel(
+ "Modifier le code R envoyé si vous le souhaitez");
+ JTextPane text = new JTextPane();
+ text.setText(rCall);
+ text.setSize(400, 400);
+ text.setPreferredSize(text.getSize());
+
+ Box box = Box.createVerticalBox();
+ box.add(label);
+ box.add(new JScrollPane(text));
+
+ JOptionPane.showMessageDialog(null, box, "R modif",
+ JOptionPane.QUESTION_MESSAGE);
+ rCall = text.getText();
+ }
+
REngine engine = new RProxy();
try {
+ //Set working directory to get Isis R session
+ log.info("setwd(\"" + outputdirectory.getParent() + "\")");
+ engine.voidEval("setwd(\"" + outputdirectory.getParent() + "\")");
+
+ //Get Isis R session
+ log.info("load(\".RData\")");
+ engine.voidEval("load(\".RData\")");
+
engine.voidEval("library(sensitivity)");
log.info("Message sent to R : " + "library(sensitivity)");
@@ -122,14 +164,11 @@
+ "X2<-data.frame(matrix(runif(" + factorNumber
+ "*" + param_n + "),nrow=" + param_n + "))");
- engine.voidEval("a<-sobol(model=NULL,X1=X1,X2=X2,order="
- + param_order + ",nboot=" + param_nboot + ")");
- log.info("Message sent to R : "
- + "a<-sobol(model=NULL,X1=X1,X2=X2,order=" + param_order
- + ",nboot=" + param_nboot + ")");
+ engine.voidEval(rCall);
+ log.info("Message sent to R : " + rCall);
// Creating the factors vector.
- String rInstruction = "factornames<-c(";
+ rInstruction = "factornames<-c(";
for (int i = 0; i < factorNumber; i++) {
if (i != (factorNumber - 1)) {
rInstruction = rInstruction + "\""
@@ -175,12 +214,76 @@
}
log.info("Message sent to R : " + "a$X");
+ nbExperiments = dataframe.length / factorNumber;
+
+ String isisFactorDistribution = "isis.factor.distribution<-data.frame(NomFacteur=c(%s),NomDistribution=c(%s),ParametreDistribution=c(%s))";
+
+ // Creating the vectors.
+ String distribution = "";
+ String parameters = "";
+ String factorNames = "";
+
+ for (int i = 0; i < factorNumber; i++) {
+ Domain domain = factors.get(i).getDomain();
+ if (i != 0) {
+ distribution += ",";
+ parameters += ",";
+ factorNames += ",";
+ }
+
+ distribution += "\"qunif\"";
+ parameters += "\"[" + ((ContinuousDomain) domain).getMinBound()
+ + ";" + ((ContinuousDomain) domain).getMaxBound()
+ + "]\"";
+ factorNames += "\"" + factors.get(i).getName() + "\"";
+ }
+
+ log.info("Message sent to R : "
+ + String.format(isisFactorDistribution, factorNames,
+ distribution, parameters));
+ engine.voidEval(String.format(isisFactorDistribution, factorNames,
+ distribution, parameters));
+
+ log.info("Message sent to R : " + "call<-a$call");
+ engine.voidEval("call<-a$call");
+
+ log
+ .info("Message sent to R : "
+ + "isis.MethodExp<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"call\"=call)");
+ engine
+ .voidEval("isis.MethodExp<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"call\"=call)");
+
+ log
+ .info("Message sent to R : "
+ + "attr(isis.MethodExp,\"nomModel\")<-\"isis-fish-externe-R\"");
+ engine
+ .voidEval("attr(isis.MethodExp,\"nomModel\")<-\"isis-fish-externe-R\"");
+
+ log.info("Message sent to R : " + "isis.simule<-data.frame(a$X)");
+ engine.voidEval("isis.simule<-data.frame(a$X)");
+
+ log
+ .info("Message sent to R : "
+ + "attr(isis.simule,\"nomModel\")<-\"isis-fish-externe-R\"");
+ engine
+ .voidEval("attr(isis.simule,\"nomModel\")<-\"isis-fish-externe-R\"");
+
+ log.info("Message sent to R : "
+ + "names(isis.simule)<-isis.factors[[1]]");
+ engine.voidEval("names(isis.simule)<-isis.factors[[1]]");
+
+ //Set working directory to save Isis R session
+ log.info("setwd(\"" + outputdirectory.getParent() + "\")");
+ engine.voidEval("setwd(\"" + outputdirectory.getParent() + "\")");
+
+ // Save Isis R session
+ log.info("save.image()");
+ engine.voidEval("save.image()");
+
} catch (Exception e) {
e.printStackTrace();
}
- nbExperiments = dataframe.length / factorNumber;
-
// Transform the result from R in a matrix
MatrixND fast = MatrixFactory.getInstance().create(dataframe,
new int[] { factorNumber, nbExperiments });
@@ -189,8 +292,7 @@
for (int j = 0; j < nbExperiments; j++) {
Scenario experimentScenario = new Scenario();
for (int i = 0; i < factorNumber; i++) {
- Factor factor = plan.getFactors()
- .get(i);
+ Factor factor = plan.getFactors().get(i);
if ((factor.getDomain() instanceof MatrixContinuousDomain)
|| (factor.getDomain() instanceof EquationContinuousDomain)) {
factor.setValueForIdentifier(Double.valueOf(
@@ -198,8 +300,8 @@
} else {
Double value = (Double) ((ContinuousDomain) factor
.getDomain()).getMinBound()
- + ((Double) ((ContinuousDomain) factor
- .getDomain()).getMaxBound() - (Double) ((ContinuousDomain) factor
+ + ((Double) ((ContinuousDomain) factor.getDomain())
+ .getMaxBound() - (Double) ((ContinuousDomain) factor
.getDomain()).getMinBound())
* fast.getValue(new int[] { i, j });
factor.setValueForIdentifier(value);
@@ -219,6 +321,14 @@
REngine engine = new RProxy();
try {
+ //Set working directory to get Isis R session
+ log.info("setwd(\"" + outputdirectory.getParent() + "\")");
+ engine.voidEval("setwd(\"" + outputdirectory.getParent() + "\")");
+
+ //Get Isis R session
+ log.info("load(\".RData\")");
+ engine.voidEval("load(\".RData\")");
+
// Call R
// Load sensitivity package into R (if package already loaded,
// nothing happens.
@@ -266,7 +376,9 @@
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String rInstruction = "results<-c(";
+ String name = simulationStorages.get(0).getParameter()
+ .getSensitivityExport().get(k).getExportFilename();
+ String rInstruction = name + "<-c(";
for (int l = 0; l < scenariosNumber; l++) {
File importFile = new File(simulationStorages.get(l)
.getDirectory().toString()
@@ -293,10 +405,49 @@
// Send the simulation results
engine.voidEval(rInstruction);
+ //Put results in isis.simule
+ engine.voidEval("isis.simule<-data.frame(isis.simule," + name
+ + ")");
+ log.info("Message sent to R : "
+ + "isis.simule<-data.frame(isis.simule," + name + ")");
+ }
+
+ //adding attribute to isis.Simule
+ log
+ .info("Message sent to R : "
+ + "attr(isis.simule,\"nomModel\")<-\"isis-fish-externe-R\"");
+ engine
+ .voidEval("attr(isis.simule,\"nomModel\")<-\"isis-fish-externe-R\"");
+
+ log.info("Message sent to R : "
+ + "attr(isis.simule,\"call\")<-isis.MethodExp$call");
+ engine.voidEval("attr(isis.simule,\"call\")<-isis.MethodExp$call");
+
+ for (int k = 0; k < sensitivityNumber; k++) {
+
+ // Creates the R expression to import results in R
+ String name = simulationStorages.get(0).getParameter()
+ .getSensitivityExport().get(k).getExportFilename();
+
//Compute results
- engine.voidEval("tell(a,y=results)");
- log.info("Message sent to R : " + "tell(a,y=results)");
+ engine.voidEval("tell(a,y=" + name + ")");
+ log.info("Message sent to R : " + "tell(a,y=" + name + ")");
+ //creating isis.methodAnalyse
+ log
+ .info("Message sent to R : "
+ + "isis.methodAnalyse<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"isis.simule\"=isis.simule,call_method=\"tell(a,y="
+ + name + ")" + "\",\"analysis_result\"=a)");
+ engine
+ .voidEval("isis.methodAnalyse<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"isis.simule\"=isis.simule,call_method=\"tell(a,y="
+ + name + ")" + "\",\"analysis_result\"=a)");
+
+ //setting isis.methodAnalyse attributes
+ log
+ .info("attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\")");
+ engine
+ .voidEval("attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\")");
+
//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 : "
@@ -354,14 +505,59 @@
.getExportFilename() + "_Results.csv\")");
//FIXME export through java to enable export when using Rserve
+ String renameIsisMethodAnalyse = "%s.isis.methodAnalyse<-isis.methodAnalyse";
+ String simulationName = simulationStorages.get(0).getName()
+ .replaceAll("-", "");
+ log.info("Message sent to R : "
+ + String.format(renameIsisMethodAnalyse, simulationName
+ + "." + name));
+ engine.voidEval(String.format(renameIsisMethodAnalyse,
+ simulationName + "." + name));
+
}
+
+ //Rename R objects for saving purpose
+
+ String renameIsisSimule = "%s.isis.simule<-isis.simule";
+ String renameIsisFactorDistribution = "%s.isis.factor.distribution<-isis.factor.distribution";
+ String renameIsisFactor = "%s.isis.factor<-isis.factors";
+ String renameIsisMethodExp = "%s.isis.methodExp<-isis.MethodExp";
+
+ String simulationName = simulationStorages.get(0).getName()
+ .replaceAll("-", "");
+
+ log.info("Message sent to R : "
+ + String.format(renameIsisSimule, simulationName));
+ engine.voidEval(String.format(renameIsisSimule, simulationName));
+
+ log.info("Message sent to R : "
+ + String.format(renameIsisFactorDistribution,
+ simulationName));
+ engine.voidEval(String.format(renameIsisFactorDistribution,
+ simulationName));
+
+ log.info("Message sent to R : "
+ + String.format(renameIsisFactor, simulationName));
+ engine.voidEval(String.format(renameIsisFactor, simulationName));
+
+ log.info("Message sent to R : "
+ + String.format(renameIsisMethodExp, simulationName));
+ engine.voidEval(String.format(renameIsisMethodExp, simulationName));
+
+ //Set working directory to save Isis R session
+ log.info("setwd(\"" + outputdirectory.getParent() + "\")");
+ engine.voidEval("setwd(\"" + outputdirectory.getParent() + "\")");
+
+ // Save Isis R session
+ log.info("save.image()");
+ engine.voidEval("save.image()");
} catch (Exception e) {
e.printStackTrace();
}
}
public String getDescription() {
- return "Implementation of Sobol method using R";
+ return "Implementation of Sobol method using R (use of the R sobol2002 method)";
}
}
1
0
Author: jcouteau
Date: 2009-04-29 09:47:25 +0000 (Wed, 29 Apr 2009)
New Revision: 130
Modified:
trunk/sensitivity/SensitivityCalculatorRFast.java
Log:
Adapt Fast method to new CDC
Pop-up message if one discrete factor
Possibility to modify R instruction
Modified: trunk/sensitivity/SensitivityCalculatorRFast.java
===================================================================
--- trunk/sensitivity/SensitivityCalculatorRFast.java 2009-04-29 09:35:53 UTC (rev 129)
+++ trunk/sensitivity/SensitivityCalculatorRFast.java 2009-04-29 09:47:25 UTC (rev 130)
@@ -19,10 +19,15 @@
package sensitivity;
import java.io.File;
-import java.io.Serializable;
import java.util.List;
import java.util.Vector;
+import javax.swing.Box;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTextPane;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.j2r.REngine;
@@ -34,12 +39,11 @@
import org.rosuda.JRI.REXP;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
+import fr.ifremer.isisfish.simulator.sensitivity.Domain;
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.Scenario;
-import fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator;
-
-import fr.ifremer.isisfish.simulator.sensitivity.AbstractSensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityScenarios;
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
@@ -63,12 +67,15 @@
private static Log log = LogFactory
.getLog(SensitivityCalculatorRFast.class);
- @Doc("an integer giving the sample size, i.e. the length of the discretization of the s-space (see Cukier et al.). (default=17)")
- public int param_n;
+ @Doc("an integer giving the sample size, i.e. the length of the discretization of the s-space (see Cukier et al.). (default=20)")
+ public int param_n = 20;
- @Doc("an integer specifying the interference parameter, i.e. the number of harmonics to sum in the Fourier series decomposition (see Cukier et al.). (default=1)")
- public int param_M;
+ @Doc("an integer specifying the interference parameter, i.e. the number of harmonics to sum in the Fourier series decomposition (see Cukier et al.). (default=6)")
+ public int param_M = 6;
+ @Doc("True to be able to modify the code sent to R")
+ public boolean param_modifR = false;
+
//public int[] param_omega;
/**
@@ -83,14 +90,8 @@
public SensitivityScenarios compute(DesignPlan plan, File outputdirectory) {
- if (param_n == 0) {
- param_n = 17;
- }
+ setIsisFactorsR(plan, outputdirectory);
- if (param_M == 0) {
- param_M = 1;
- }
-
double[] dataframe = new double[0];
int nbExperiments = 0;
int factorNumber = plan.getFactors().size();
@@ -101,28 +102,57 @@
//Test all factors, if one is discrete, return null
for (int i = 0; i < factorNumber; i++) {
if (factors.get(i).getDomain() instanceof DiscreteDomain) {
+ JOptionPane
+ .showMessageDialog(
+ null,
+ "Error",
+ factors.get(i).getName()
+ + " has a discrete domain, this is not acceptable for this method.",
+ JOptionPane.ERROR_MESSAGE);
return null;
}
}
- String rInstruction = "a<-fast99(model=NULL,factors=c("
- + factors.size();
+ String rInstruction = "a<-fast99(model=NULL,factors=c(%s), n=%s,M=%s, q = \"qunif\", q.arg=list(min=0,max=1))";
+ String rCall = String.format(rInstruction, factors.size(), param_n,
+ param_M);
- rInstruction = rInstruction + "), n=" + param_n + ",M=" + param_M;
+ if (param_modifR) {
+ JLabel label = new JLabel(
+ "Modifier le code R envoyé si vous le souhaitez");
+ JTextPane text = new JTextPane();
+ text.setText(rCall);
+ text.setSize(400, 400);
+ text.setPreferredSize(text.getSize());
- rInstruction = rInstruction
- + ", q = \"qunif\", q.arg=list(min=0,max=1))";
+ Box box = Box.createVerticalBox();
+ box.add(label);
+ box.add(new JScrollPane(text));
+ JOptionPane.showMessageDialog(null, box, "R modif",
+ JOptionPane.QUESTION_MESSAGE);
+ rCall = text.getText();
+ }
+
REngine engine = new RProxy();
try {
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\"" + outputdirectory.getParent() + "\")");
+ engine.voidEval("setwd(\"" + outputdirectory.getParent() + "\")");
+
+ //Get Isis R session
+ log.info("load(\".RData\")");
+ engine.voidEval("load(\".RData\")");
+
// Load sensitivity package into R (if package already loaded,
// nothing happens.
engine.voidEval("library(sensitivity)");
log.info("Message sent to R" + "library(sensitivity)");
// Run sensitivity analysis
- engine.voidEval(rInstruction);
- log.info("Message sent to R" + rInstruction);
+ engine.voidEval(rCall);
+ log.info("Message sent to R" + rCall);
// Creating the factors vector.
rInstruction = "factornames<-c(";
@@ -167,6 +197,7 @@
+ j] = dataframeVector.get(i).asDoubleArray()[j];
}
}
+
log.info("Message sent to R" + "a$X");
if (log.isDebugEnabled()) {
@@ -175,8 +206,73 @@
nbExperiments = dataframe.length / factorNumber;
- } catch (RException e) {
- e.printStackTrace();
+ String isisFactorDistribution = "isis.factor.distribution<-data.frame(NomFacteur=c(%s),NomDistribution=c(%s),ParametreDistribution=c(%s))";
+
+ // Creating the vectors.
+ String distribution = "";
+ String parameters = "";
+ String factorNames = "";
+
+ for (int i = 0; i < factorNumber; i++) {
+ Domain domain = factors.get(i).getDomain();
+ if (i != 0) {
+ distribution += ",";
+ parameters += ",";
+ factorNames += ",";
+ }
+
+ distribution += "\"qunif\"";
+ parameters += "\"[" + ((ContinuousDomain) domain).getMinBound()
+ + ";" + ((ContinuousDomain) domain).getMaxBound()
+ + "]\"";
+ factorNames += "\"" + factors.get(i).getName() + "\"";
+ }
+
+ log.info("Message sent to R : "
+ + String.format(isisFactorDistribution, factorNames,
+ distribution, parameters));
+ engine.voidEval(String.format(isisFactorDistribution, factorNames,
+ distribution, parameters));
+
+ log.info("Message sent to R : " + "call<-a$call");
+ engine.voidEval("call<-a$call");
+
+ log
+ .info("Message sent to R : "
+ + "isis.MethodExp<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"call\"=call)");
+ engine
+ .voidEval("isis.MethodExp<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"call\"=call)");
+
+ log
+ .info("Message sent to R : "
+ + "attr(isis.MethodExp,\"nomModel\")<-\"isis-fish-externe-R\"");
+ engine
+ .voidEval("attr(isis.MethodExp,\"nomModel\")<-\"isis-fish-externe-R\"");
+
+ log.info("Message sent to R : " + "isis.simule<-data.frame(a$X)");
+ engine.voidEval("isis.simule<-data.frame(a$X)");
+
+ log
+ .info("Message sent to R : "
+ + "attr(isis.simule,\"nomModel\")<-\"isis-fish-externe-R\"");
+ engine
+ .voidEval("attr(isis.simule,\"nomModel\")<-\"isis-fish-externe-R\"");
+
+ log.info("Message sent to R : "
+ + "names(isis.simule)<-isis.factors[[1]]");
+ engine.voidEval("names(isis.simule)<-isis.factors[[1]]");
+
+ //Set working directory to save Isis R session
+ log.info("setwd(\"" + outputdirectory.getParent() + "\")");
+ engine.voidEval("setwd(\"" + outputdirectory.getParent() + "\")");
+
+ // Save Isis R session
+ log.info("save.image()");
+ engine.voidEval("save.image()");
+
+ } catch (RException eee) {
+ eee.printStackTrace();
+ throw new RuntimeException("R evaluation failed", eee);
// Error while retrieving scenario
}
@@ -188,8 +284,7 @@
for (int j = 0; j < nbExperiments; j++) {
Scenario experimentScenario = new Scenario();
for (int i = 0; i < factorNumber; i++) {
- Factor factor = plan.getFactors()
- .get(i);
+ Factor factor = plan.getFactors().get(i);
if ((factor.getDomain() instanceof MatrixContinuousDomain)
|| (factor.getDomain() instanceof EquationContinuousDomain)) {
factor.setValueForIdentifier(Double.valueOf(
@@ -197,8 +292,8 @@
} else {
Double value = (Double) ((ContinuousDomain) factor
.getDomain()).getMinBound()
- + ((Double) ((ContinuousDomain) factor
- .getDomain()).getMaxBound() - (Double) ((ContinuousDomain) factor
+ + ((Double) ((ContinuousDomain) factor.getDomain())
+ .getMaxBound() - (Double) ((ContinuousDomain) factor
.getDomain()).getMinBound())
* fast.getValue(new int[] { i, j });
factor.setValueForIdentifier(value);
@@ -215,17 +310,17 @@
public void analyzeResult(List<SimulationStorage> simulationStorages,
File outputdirectory) {
- if (param_n == 0) {
- param_n = 17;
- }
-
- if (param_M == 0) {
- param_M = 1;
- }
-
REngine engine = new RProxy();
try {
+ //Set working directory to get Isis R session
+ log.info("setwd(\"" + outputdirectory.getParent() + "\")");
+ engine.voidEval("setwd(\"" + outputdirectory.getParent() + "\")");
+
+ //Get Isis R session
+ log.info("load(\".RData\")");
+ engine.voidEval("load(\".RData\")");
+
// Call R
// Load sensitivity package into R (if package already loaded,
// nothing happens.
@@ -257,7 +352,9 @@
for (int k = 0; k < sensitivityNumber; k++) {
// Creates the R expression to import results in R
- String rInstruction = "results<-c(";
+ String name = simulationStorages.get(0).getParameter()
+ .getSensitivityExport().get(k).getExportFilename();
+ String rInstruction = name + "<-c(";
for (int l = 0; l < scenariosNumber; l++) {
File importFile = new File(simulationStorages.get(l)
.getDirectory().toString()
@@ -284,15 +381,54 @@
// Send the simulation results
engine.voidEval(rInstruction);
+ //Put results in isis.simule
+ engine.voidEval("isis.simule<-data.frame(isis.simule," + name
+ + ")");
+ log.info("Message sent to R : "
+ + "isis.simule<-data.frame(isis.simule," + name + ")");
+
+ }
+
+ //adding attribute to isis.Simule
+ log
+ .info("Message sent to R : "
+ + "attr(isis.simule,\"nomModel\")<-\"isis-fish-externe-R\"");
+ engine
+ .voidEval("attr(isis.simule,\"nomModel\")<-\"isis-fish-externe-R\"");
+
+ log.info("Message sent to R : "
+ + "attr(isis.simule,\"call\")<-isis.MethodExp$call");
+ engine.voidEval("attr(isis.simule,\"call\")<-isis.MethodExp$call");
+
+ for (int k = 0; k < sensitivityNumber; k++) {
+
+ // Creates the R expression to import results in R
+ String name = simulationStorages.get(0).getParameter()
+ .getSensitivityExport().get(k).getExportFilename();
+
//Compute results
- engine.voidEval("tell(a,y=results)");
- log.info("Message sent to R : " + "tell(a,y=results)");
+ engine.voidEval("tell(a,y=" + name + ")");
+ log.info("Message sent to R : " + "tell(a,y=" + name + ")");
+ //creating isis.methodAnalyse
+ log
+ .info("Message sent to R : "
+ + "isis.methodAnalyse<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"isis.simule\"=isis.simule,call_method=\"tell(a,y="
+ + name + ")" + "\",\"analysis_result\"=a)");
+ engine
+ .voidEval("isis.methodAnalyse<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"isis.simule\"=isis.simule,call_method=\"tell(a,y="
+ + name + ")" + "\",\"analysis_result\"=a)");
+
+ //setting isis.methodAnalyse attributes
+ log
+ .info("attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\")");
+ engine
+ .voidEval("attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\")");
+
//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 : "
+ "dfresults=data.frame(a$X,results)");
-
//Set working directory
engine.voidEval("setwd(\"" + outputdirectory.getAbsolutePath()
@@ -350,11 +486,9 @@
.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("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");
@@ -371,7 +505,53 @@
.getExportFilename() + "_Results.csv\")");
//FIXME export through java to enable export when using Rserve
+ String renameIsisMethodAnalyse = "%s.isis.methodAnalyse<-isis.methodAnalyse";
+ String simulationName = simulationStorages.get(0).getName()
+ .replaceAll("-", "");
+ log.info("Message sent to R : "
+ + String.format(renameIsisMethodAnalyse, simulationName
+ + "." + name));
+ engine.voidEval(String.format(renameIsisMethodAnalyse,
+ simulationName + "." + name));
+
}
+
+ //Rename R objects for saving purpose
+
+ String renameIsisSimule = "%s.isis.simule<-isis.simule";
+ String renameIsisFactorDistribution = "%s.isis.factor.distribution<-isis.factor.distribution";
+ String renameIsisFactor = "%s.isis.factor<-isis.factors";
+ String renameIsisMethodExp = "%s.isis.methodExp<-isis.MethodExp";
+
+ String simulationName = simulationStorages.get(0).getName()
+ .replaceAll("-", "");
+
+ log.info("Message sent to R : "
+ + String.format(renameIsisSimule, simulationName));
+ engine.voidEval(String.format(renameIsisSimule, simulationName));
+
+ log.info("Message sent to R : "
+ + String.format(renameIsisFactorDistribution,
+ simulationName));
+ engine.voidEval(String.format(renameIsisFactorDistribution,
+ simulationName));
+
+ log.info("Message sent to R : "
+ + String.format(renameIsisFactor, simulationName));
+ engine.voidEval(String.format(renameIsisFactor, simulationName));
+
+ log.info("Message sent to R : "
+ + String.format(renameIsisMethodExp, simulationName));
+ engine.voidEval(String.format(renameIsisMethodExp, simulationName));
+
+ //Set working directory to save Isis R session
+ log.info("setwd(\"" + outputdirectory.getParent() + "\")");
+ engine.voidEval("setwd(\"" + outputdirectory.getParent() + "\")");
+
+ // Save Isis R session
+ log.info("save.image()");
+ engine.voidEval("save.image()");
+
} catch (Exception e) {
e.printStackTrace();
}
1
0
Author: chatellier
Date: 2009-04-29 09:35:53 +0000 (Wed, 29 Apr 2009)
New Revision: 129
Modified:
trunk/pom.xml
Log:
Update compiler version to 1.6
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-04-29 09:27:18 UTC (rev 128)
+++ trunk/pom.xml 2009-04-29 09:35:53 UTC (rev 129)
@@ -39,8 +39,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.6</source>
+ <target>1.6</target>
<excludes>
<exclude>**/simulations/**</exclude>
</excludes>
1
0
r128 - in trunk: analyseplans exports rules scripts
by jcouteau@users.labs.libre-entreprise.org 29 Apr '09
by jcouteau@users.labs.libre-entreprise.org 29 Apr '09
29 Apr '09
Author: jcouteau
Date: 2009-04-29 09:27:18 +0000 (Wed, 29 Apr 2009)
New Revision: 128
Modified:
trunk/analyseplans/Calibration.java
trunk/analyseplans/Max.java
trunk/exports/CapturesNombre.java
trunk/exports/CapturesPoids.java
trunk/exports/RejetsNombre.java
trunk/exports/RejetsPoids.java
trunk/rules/GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD.java
trunk/rules/TACpoids.java
trunk/scripts/GravityModel.java
trunk/scripts/ResultName.java
trunk/scripts/SiMatrix.java
Log:
Remove all accents to avoid formatting problems
Format code
Organize imports
Modified: trunk/analyseplans/Calibration.java
===================================================================
--- trunk/analyseplans/Calibration.java 2009-04-29 08:39:41 UTC (rev 127)
+++ trunk/analyseplans/Calibration.java 2009-04-29 09:27:18 UTC (rev 128)
@@ -2,341 +2,363 @@
import static org.codelutin.i18n.I18n._;
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+import org.codelutin.topia.TopiaContext;
+import org.codelutin.util.FileUtil;
+import org.codelutin.util.StringUtil;
import scripts.ResultName;
-
-import java.io.*;
-import java.util.*;
-
-import org.codelutin.math.matrix.*;
-
-import org.codelutin.topia.*;// pour pouvoir utiliser la methode StringUtil.toDouble()
-import org.codelutin.util.*;// pour pouvoir utiliser la methode StringUtil.toDouble()
-
-import fr.ifremer.isisfish.*;
-import fr.ifremer.isisfish.types.*;
-import fr.ifremer.isisfish.simulator.SimulationContext;
-import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.entities.*;
+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.entities.PopulationSeasonInfo;
import fr.ifremer.isisfish.simulator.AnalysePlan;
import fr.ifremer.isisfish.simulator.AnalysePlanContext;
-import fr.ifremer.isisfish.simulator.SimulationParameter;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.types.Month;
+import fr.ifremer.isisfish.util.Doc;
-import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
/**
* Calibration_bidon.java
- *
+ *
* Created: 8 mars 2007
- *
- * @author <>
+ *
+ * @author <>
* @version $Revision: 1.2 $
- *
- * Last update: $Date: 2007-11-02 17:43:14 $
- * by : $Author: bpoussin $
+ *
+ * Last update: $Date: 2007-11-02 17:43:14 $ by : $Author: bpoussin $
*/
public class Calibration implements AnalysePlan {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(Calibration.class);
- enum State {STATE_INIT, STATE_0, STATE_1, STATE_2, STATE_3, STATE_4};
-
+ enum State {
+ STATE_INIT, STATE_0, STATE_1, STATE_2, STATE_3, STATE_4
+ };
+
//parametres de la simu 3 points initiaux d un simplex d ordre 2
- @Doc(value="do the doc of param Population")
+ @Doc(value = "do the doc of param Population")
public Population param_Population = null;
- @Doc(value="do the doc of param M1 (devient un parametre du plan d analyse)")
+ @Doc(value = "do the doc of param M1 (devient un parametre du plan d analyse)")
public String param_M1 = "1e-5;1e-6";// devient un parametre du plan d analyse
- @Doc(value="do the doc of param M2 (devient un parametre du plan d analyse)")
+ @Doc(value = "do the doc of param M2 (devient un parametre du plan d analyse)")
public String param_M2 = "2e-4;2e-5";// devient un parametre du plan d analyse
- @Doc(value="do the doc of param M3 (devient un parametre du plan d analyse)")
+ @Doc(value = "do the doc of param M3 (devient un parametre du plan d analyse)")
public String param_M3 = "1e-4;1e-6";// devient un parametre du plan d analyse
- @Doc(value="do the doc of param pas (devient un parametre du plan d analyse)")
+ @Doc(value = "do the doc of param pas (devient un parametre du plan d analyse)")
public String param_pas = "1e-5";// devient un parametre du plan d analyse
- @Doc(value="nom + chemin du fichier contenant les debarquements observes par groupe pour la derniere annee")
+ @Doc(value = "nom + chemin du fichier contenant les debarquements observes par groupe pour la derniere annee")
public String param_nomfichier_debarquements = "";//nom + chemin du fichier contenant les debarquements observes par groupe pour la derniere annee
- protected File debarquementsObserves;
+ protected File debarquementsObserves;
protected MatrixND matrixDebarquement;
-
+
protected State state = State.STATE_INIT;
protected Experiences experiences = new Experiences();
-
-
+
/**
* @return the experiences
*/
public Experiences getExperiences() {
return this.experiences;
}
-
- public String [] necessaryResult = {
- ResultName.MATRIX_LANDING_PER_MET
- };
+ public String[] necessaryResult = { ResultName.MATRIX_LANDING_PER_MET };
+
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 _("Simplexe");
}
-
+
/**
* Appele au demarrage de la simulation, cette methode permet d'initialiser
* des valeurs
- * @param simulation La simulation pour lequel on utilise cette regle
+ *
+ * @param simulation
+ * La simulation pour lequel on utilise cette regle
*/
public void init(AnalysePlanContext context) throws Exception {
- if (param_nomfichier_debarquements==null || "".equals(param_nomfichier_debarquements)){
- debarquementsObserves = FileUtil.getFile(".*.csv", "fichier csv séparateur ';'");
- } else {
- debarquementsObserves = new File(param_nomfichier_debarquements);
- }
-// int nbYear = context.getParam().getNumberOfYear();
- TopiaContext db = context.getParam().getRegion().getStorage().beginTransaction();
- Population pop = (Population)db.findByTopiaId(param_Population.getTopiaId());
-
- int nbGroup = pop.sizePopulationGroup();
- matrixDebarquement = MatrixFactory.getInstance().create(new int[]{nbGroup});
-// List<PopulationGroup> groups = pop.getPopulationGroup();
-// matrixDebarquement = MatrixFactory.getInstance().create(new List[]{groups});
-
- matrixDebarquement.importCSV(new FileReader(debarquementsObserves),new int []{0});
- db.closeContext();
+ if (param_nomfichier_debarquements == null
+ || "".equals(param_nomfichier_debarquements)) {
+ debarquementsObserves = FileUtil.getFile(".*.csv",
+ "fichier csv séparateur ';'");
+ } else {
+ debarquementsObserves = new File(param_nomfichier_debarquements);
+ }
+ // int nbYear = context.getParam().getNumberOfYear();
+ TopiaContext db = context.getParam().getRegion().getStorage()
+ .beginTransaction();
+ Population pop = (Population) db.findByTopiaId(param_Population
+ .getTopiaId());
+
+ int nbGroup = pop.sizePopulationGroup();
+ matrixDebarquement = MatrixFactory.getInstance().create(
+ new int[] { nbGroup });
+ // List<PopulationGroup> groups = pop.getPopulationGroup();
+ // matrixDebarquement = MatrixFactory.getInstance().create(new List[]{groups});
+
+ matrixDebarquement.importCSV(new FileReader(debarquementsObserves),
+ new int[] { 0 });
+ db.closeContext();
}
-
+
/**
* 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
*/
- public boolean beforeSimulation(AnalysePlanContext context, SimulationStorage nextSimulation) throws Exception {
- boolean doNext = true;
+ public boolean beforeSimulation(AnalysePlanContext context,
+ SimulationStorage nextSimulation) throws Exception {
+ boolean doNext = true;
- int number = context.getNumber();
+ int number = context.getNumber();
- if (number < 3) {
- String [] M1 = param_M1.split(";");
- String [] M2 = param_M2.split(";");
- String [] M3 = param_M3.split(";");
- double [] q1 = StringUtil.toArrayDouble(M1[0], M2[0], M3[0]);
- double [] q2 = StringUtil.toArrayDouble(M1[1], M2[1], M3[1]);
-
- experiences.getExperience(number).q1 = q1[number];
- experiences.getExperience(number).q2 = q2[number];
+ if (number < 3) {
+ String[] M1 = param_M1.split(";");
+ String[] M2 = param_M2.split(";");
+ String[] M3 = param_M3.split(";");
+ double[] q1 = StringUtil.toArrayDouble(M1[0], M2[0], M3[0]);
+ double[] q2 = StringUtil.toArrayDouble(M1[1], M2[1], M3[1]);
- changeDB(experiences.getExperience(number), nextSimulation);
- } else {
- double q1 = 0;
- double q2 = 0;
-
- double lastCritere = experiences.getExperience(number-1).criteria;
- double g1 = (experiences.current.get(2).q1 + experiences.current.get(1).q1) / 2.0;
- double g2 = (experiences.current.get(2).q2 + experiences.current.get(1).q2) / 2.0;
-
- double worst1 = experiences.current.get(0).q1;
- double worst2 = experiences.current.get(0).q2;
+ experiences.getExperience(number).q1 = q1[number];
+ experiences.getExperience(number).q2 = q2[number];
-
- if (state == State.STATE_INIT) {
- // on fait la 4eme simulation dans tous les cas
- state = State.STATE_0;
- Collections.sort(experiences.current);
- q1 = 2 * g1 - worst1;
- q2 = 2 * g2 - worst2;
- } else if (state == State.STATE_0) {
- // on fait la 5eme avec des q qui dependent de la 4eme dans le dernier cas
- if (lastCritere < experiences.current.get(0).criteria) {
- state = State.STATE_1;
- q1 = g1 - ( g1 - worst1 ) / 2.0;
- q2 = g2 - ( g2 - worst2 ) / 2.0;
- } else if (lastCritere < experiences.current.get(1).criteria) {
- state = State.STATE_2;
- q1 = g1 + ( g1 - worst1 ) / 2.0;
- q2 = g2 + ( g2 - worst2 ) / 2.0;
- } else if (lastCritere < experiences.current.get(2).criteria) {
- state = State.STATE_INIT;
- experiences.current.remove(3);
- } else { // dernier cas possible: if (lastCritere > experiences.current.get(2).critere) {
- state = State.STATE_4;
- q1 = experiences.current.get(3).q1 + g1 - worst1;
- q2 = experiences.current.get(3).q2 + g2 - worst2;
- }
- } else if (state == State.STATE_1) {
- // la derniere simulation a ete faite
- if (lastCritere > experiences.current.get(0).criteria) {
- experiences.current.remove(3);
- experiences.current.remove(0);
- } else {
- // FIXME on supprime les 2 derniere qui vient d'etre faite, on risque donc de boucler
- experiences.current.remove(4);
- experiences.current.remove(3);
+ changeDB(experiences.getExperience(number), nextSimulation);
+ } else {
+ double q1 = 0;
+ double q2 = 0;
+
+ double lastCritere = experiences.getExperience(number - 1).criteria;
+ double g1 = (experiences.current.get(2).q1 + experiences.current
+ .get(1).q1) / 2.0;
+ double g2 = (experiences.current.get(2).q2 + experiences.current
+ .get(1).q2) / 2.0;
+
+ double worst1 = experiences.current.get(0).q1;
+ double worst2 = experiences.current.get(0).q2;
+
+ if (state == State.STATE_INIT) {
+ // on fait la 4eme simulation dans tous les cas
+ state = State.STATE_0;
+ Collections.sort(experiences.current);
+ q1 = 2 * g1 - worst1;
+ q2 = 2 * g2 - worst2;
+ } else if (state == State.STATE_0) {
+ // on fait la 5eme avec des q qui dependent de la 4eme dans le dernier cas
+ if (lastCritere < experiences.current.get(0).criteria) {
+ state = State.STATE_1;
+ q1 = g1 - (g1 - worst1) / 2.0;
+ q2 = g2 - (g2 - worst2) / 2.0;
+ } else if (lastCritere < experiences.current.get(1).criteria) {
+ state = State.STATE_2;
+ q1 = g1 + (g1 - worst1) / 2.0;
+ q2 = g2 + (g2 - worst2) / 2.0;
+ } else if (lastCritere < experiences.current.get(2).criteria) {
+ state = State.STATE_INIT;
+ experiences.current.remove(3);
+ } else { // dernier cas possible: if (lastCritere > experiences.current.get(2).critere) {
+ state = State.STATE_4;
+ q1 = experiences.current.get(3).q1 + g1 - worst1;
+ q2 = experiences.current.get(3).q2 + g2 - worst2;
+ }
+ } else if (state == State.STATE_1) {
+ // la derniere simulation a ete faite
+ if (lastCritere > experiences.current.get(0).criteria) {
+ experiences.current.remove(3);
+ experiences.current.remove(0);
+ } else {
+ // FIXME on supprime les 2 derniere qui vient d'etre faite, on risque donc de boucler
+ experiences.current.remove(4);
+ experiences.current.remove(3);
doNext = false;
- }
- state = State.STATE_INIT;
- } else if (state == State.STATE_2) {
- if (lastCritere > experiences.current.get(0).criteria) {
- experiences.current.remove(3);
- experiences.current.remove(0);
- } else {
- // FIXME on supprime les 2 derniere qui vient d'etre faite, on risque donc de boucler
- experiences.current.remove(4);
- experiences.current.remove(3);
+ }
+ state = State.STATE_INIT;
+ } else if (state == State.STATE_2) {
+ if (lastCritere > experiences.current.get(0).criteria) {
+ experiences.current.remove(3);
+ experiences.current.remove(0);
+ } else {
+ // FIXME on supprime les 2 derniere qui vient d'etre faite, on risque donc de boucler
+ experiences.current.remove(4);
+ experiences.current.remove(3);
doNext = false;
- }
- state = State.STATE_INIT;
- } else if (state == State.STATE_4) {
- if (lastCritere > experiences.current.get(3).criteria) {
- experiences.current.remove(3);
- experiences.current.remove(0);
- } else {
- experiences.current.remove(4);
- experiences.current.remove(0);
- }
- state = State.STATE_INIT;
- }
-
- experiences.getExperience(number).q1 = q1;
- experiences.getExperience(number).q2 = q2;
+ }
+ state = State.STATE_INIT;
+ } else if (state == State.STATE_4) {
+ if (lastCritere > experiences.current.get(3).criteria) {
+ experiences.current.remove(3);
+ experiences.current.remove(0);
+ } else {
+ experiences.current.remove(4);
+ experiences.current.remove(0);
+ }
+ state = State.STATE_INIT;
+ }
- changeDB(experiences.getExperience(number), nextSimulation);
- }
+ experiences.getExperience(number).q1 = q1;
+ experiences.getExperience(number).q2 = q2;
- return doNext;
+ changeDB(experiences.getExperience(number), nextSimulation);
+ }
+
+ return doNext;
}
/**
* Call after each simulation, compute criteria for last 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
*/
- public boolean afterSimulation(AnalysePlanContext context, SimulationStorage lastSimulation) throws Exception {
+ public boolean afterSimulation(AnalysePlanContext context,
+ SimulationStorage lastSimulation) throws Exception {
boolean doNext = true;
-
+
int number = context.getNumber();
ResultStorage result = lastSimulation.getResultStorage();
log.fatal("sim: " + lastSimulation + " result: " + result);
- MatrixND L = result.getMatrix(param_Population, ResultName.MATRIX_LANDING_PER_MET);
+ MatrixND L = result.getMatrix(param_Population,
+ ResultName.MATRIX_LANDING_PER_MET);
L = L.sumOverDim(0);// sum sur les mois, si on ajoute le pas (12) on peut sommer sur les annees
L = L.sumOverDim(1);// sum sur les strategies
L = L.sumOverDim(3);// sum sur les metiers
L = L.sumOverDim(4);// sum sur les zones
L = L.reduce(); // supprime les dim qui n ont qu un element
-
+
double crit = 0;
- for ( MatrixIterator g = L.iterator(); g.hasNext();){
+ for (MatrixIterator g = L.iterator(); g.hasNext();) {
g.next();
- int [] dim = g.getCoordinates();
+ int[] dim = g.getCoordinates();
double obs = matrixDebarquement.getValue(dim);
double simules = g.getValue();
- crit += Math.pow(obs-simules, 2);
+ crit += Math.pow(obs - simules, 2);
}
experiences.getExperience(number).criteria = crit;
-
+
return doNext;
}
/**
* Modify nextSimulation database with q1 and q2 in exp.
+ *
* @param exp
* @param nextSimulation
* @throws Exception
*/
- protected void changeDB(Experience exp, SimulationStorage nextSimulation) throws Exception {
- TopiaContext db = nextSimulation.getStorage().beginTransaction();//ouvrir un context pour modifier les donnees
- Population pop = (Population)db.findByTopiaId(param_Population.getTopiaId());
-// autre solution moins efficace:
-// PopulationDAO popDAO = IsisFishDAOHelper.getPopulationDAO(db);
-// Population Nephrops = dao.findByName(param_Population.getName());
+ protected void changeDB(Experience exp, SimulationStorage nextSimulation)
+ throws Exception {
+ TopiaContext db = nextSimulation.getStorage().beginTransaction();//ouvrir un context pour modifier les donnees
+ Population pop = (Population) db.findByTopiaId(param_Population
+ .getTopiaId());
+ // autre solution moins efficace:
+ // PopulationDAO popDAO = IsisFishDAOHelper.getPopulationDAO(db);
+ // Population Nephrops = dao.findByName(param_Population.getName());
- MatrixND c = pop.getCapturability();
+ MatrixND c = pop.getCapturability();
- for (MatrixIterator i = c.iterator(); i.hasNext();){
- i.next();
+ for (MatrixIterator i = c.iterator(); i.hasNext();) {
+ i.next();
- Object [] sem = i.getSemanticsCoordinates();
- PopulationGroup group = (PopulationGroup)sem[0];
- PopulationSeasonInfo season = (PopulationSeasonInfo)sem[1];
+ Object[] sem = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sem[0];
+ PopulationSeasonInfo season = (PopulationSeasonInfo) sem[1];
- if (season.getFirstMonth().after(Month.JULY) && group.getId() >=18){ //mois >= aout
- i.setValue(exp.q2);
- }
- else {
- i.setValue(exp.q1);
- }
- }
- db.commitTransaction();
- db.closeContext();
+ if (season.getFirstMonth().after(Month.JULY) && group.getId() >= 18) { //mois >= aout
+ i.setValue(exp.q2);
+ } else {
+ i.setValue(exp.q1);
+ }
+ }
+ db.commitTransaction();
+ db.closeContext();
}
-
+
public class Experiences {
/** contains last simplex and potentialy 2 more simulation */
- protected List<Experience> current = new ArrayList<Experience>();
+ protected List<Experience> current = new ArrayList<Experience>();
/** contains all experience done */
- protected List<Experience> history = new ArrayList<Experience>();
-
+ protected List<Experience> history = new ArrayList<Experience>();
+
/**
* @return the history
*/
public List<Experience> getHistory() {
return this.history;
}
-
+
/**
- * return experience requested, if this experience doesn't exist
- * create it.
+ * return experience requested, if this experience doesn't exist create
+ * it.
*
- * @param i simulation number
- * @return experience with simulation number fixed if new experience
- * is returned
+ * @param i
+ * simulation number
+ * @return experience with simulation number fixed if new experience is
+ * returned
*/
- public Experience getExperience(int i) {
- Experience result;
- if (i<history.size()) {
- result = history.get(i);
- } else {
- result = new Experience();
- result.simNumber = i;
- history.add(i, result);
- current.add(result);
- }
- return result;
- }
+ public Experience getExperience(int i) {
+ Experience result;
+ if (i < history.size()) {
+ result = history.get(i);
+ } else {
+ result = new Experience();
+ result.simNumber = i;
+ history.add(i, result);
+ current.add(result);
+ }
+ return result;
+ }
}
-
+
/**
* Use to keep q1, q2 and criteria of simulation
+ *
* @author poussin
*/
public class Experience implements Comparable {
- public int simNumber;
- public double criteria;
- public double q1;
- public double q2;
-
+ public int simNumber;
+ public double criteria;
+ public double q1;
+ public double q2;
+
/**
- * Permit to order experience, first is experience with smallest criteria
+ * Permit to order experience, first is experience with smallest
+ * criteria
*/
- public int compareTo(Object arg0) {
- Experience other = (Experience)arg0;
- int result = Double.compare(this.criteria, other.criteria);
- return result;
- }
+ public int compareTo(Object arg0) {
+ Experience other = (Experience) arg0;
+ int result = Double.compare(this.criteria, other.criteria);
+ return result;
+ }
}
}
-
Modified: trunk/analyseplans/Max.java
===================================================================
--- trunk/analyseplans/Max.java 2009-04-29 08:39:41 UTC (rev 127)
+++ trunk/analyseplans/Max.java 2009-04-29 09:27:18 UTC (rev 128)
@@ -5,45 +5,30 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import scripts.ResultName;
-
-import java.io.Writer;
-
-import org.codelutin.math.matrix.*;
-
-import fr.ifremer.isisfish.simulator.SimulationContext;
-import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.entities.*;
-import fr.ifremer.isisfish.simulator.AnalysePlan;
-import fr.ifremer.isisfish.simulator.AnalysePlanContext;
-import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.datastore.ResultStorage;
-
+import fr.ifremer.isisfish.simulator.AnalysePlanContext;
import fr.ifremer.isisfish.simulator.AnalysePlanIndependent;
-import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
+import fr.ifremer.isisfish.util.Doc;
/**
* Max.java
- *
+ *
* Created: 2 mars 2007
- *
+ *
* @author bpoussin <bpoussin(a)labs.libre-entreprise.org>
* @version $Revision: 1.2 $
- *
- * Last update: $Date: 2007-03-09 15:27:21 $
- * by : $Author: bpoussin $
+ *
+ * Last update: $Date: 2007-03-09 15:27:21 $ by : $Author: bpoussin $
*/
public class Max implements AnalysePlanIndependent {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(Max.class);
- @Doc(value="do the doc of param max")
- public int param_max = 10;
+ @Doc(value = "do the doc of param max")
+ public int param_max = 10;
-
- public String [] necessaryResult = {
+ public String[] necessaryResult = {
// put here all necessary result for this rule
// example:
// ResultName.MATRIX_BIOMASS,
@@ -56,41 +41,52 @@
/**
* 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 _("Permit to specify maximum simulation numbers");
}
-
+
/**
* Appel� au d�marrage de la simulation, cette m�thode permet d'initialiser
* des valeurs
- * @param simulation La simulation pour lequel on utilise cette regle
+ *
+ * @param simulation
+ * La simulation pour lequel on utilise cette regle
*/
public void init(AnalysePlanContext context) throws Exception {
-
+
}
-
+
/**
* 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
*/
- public boolean beforeSimulation(AnalysePlanContext context, SimulationStorage nextSimulation) throws Exception {
+ public boolean beforeSimulation(AnalysePlanContext context,
+ SimulationStorage nextSimulation) throws Exception {
boolean result = context.getNumber() < param_max;
return result;
}
/**
* Call after 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
*/
- public boolean afterSimulation(AnalysePlanContext context, SimulationStorage lastSimulation) throws Exception {
+ public boolean afterSimulation(AnalysePlanContext context,
+ SimulationStorage lastSimulation) throws Exception {
return true;
}
Modified: trunk/exports/CapturesNombre.java
===================================================================
--- trunk/exports/CapturesNombre.java 2009-04-29 08:39:41 UTC (rev 127)
+++ trunk/exports/CapturesNombre.java 2009-04-29 09:27:18 UTC (rev 128)
@@ -2,44 +2,41 @@
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 java.io.Writer;
-
-import org.codelutin.math.matrix.*;
-
import scripts.ResultName;
-
-import fr.ifremer.isisfish.entities.*;
+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.Zone;
import fr.ifremer.isisfish.export.Export;
import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.util.Doc;
-import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* CapturesNombre.java
- *
+ *
* Created: 23 novembre 2006
- *
+ *
* @author anonymous <anonymous(a)labs.libre-entreprise.org>
* @version $Revision: 1.4 $
- *
- * Last update: $Date: 2007-05-24 09:30:07 $
- * by : $Author: bpoussin $
+ *
+ * Last update: $Date: 2007-05-24 09:30:07 $ by : $Author: bpoussin $
*/
- @Doc(value="do the doc of class CaptureNombre")
+@Doc(value = "do the doc of class CaptureNombre")
public class CapturesNombre implements Export {
/** 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
- };
-
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_PER_STRATEGY_MET };
+
public String[] getNecessaryResult() {
return this.necessaryResult;
}
@@ -47,76 +44,80 @@
public String getExportFilename() {
return "CapturesNombre";
}
-
+
public String getExtensionFilename() {
return ".csv";
}
-
+
public String getDescription() {
return _("Export les captures en nombre de la simulation. tableau pop;metier;id;zone;nombre");
}
- public void export(SimulationStorage simulation, Writer out) throws Exception {
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
Date lastDate = simulation.getResultStorage().getLastDate();
-
+
for (Population pop : simulation.getParameter().getPopulations()) {
- for (Date date = new Date(0); !date.after(lastDate); date = date.next() ) {
- MatrixND mat = simulation.getResultStorage().getMatrix(date, pop,
- ResultName.MATRIX_CATCH_PER_STRATEGY_MET);
+ for (Date date = new Date(0); !date.after(lastDate); date = date
+ .next()) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(date,
+ pop, ResultName.MATRIX_CATCH_PER_STRATEGY_MET);
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();) {
+ 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];
+ Object[] sems = i.getSemanticsCoordinates();
+ Metier metier = (Metier) sems[1];
+ PopulationGroup group = (PopulationGroup) sems[2];
+ Zone zone = (Zone) sems[3];
double val = i.getValue();
- out.write(pop.getName() +";"+ metier.getName() +";"+ group.getId() +";"+ zone.getName() +";"+ date.getDate() +";"+ val +"\n");
+ out.write(pop.getName() + ";" + metier.getName() + ";"
+ + group.getId() + ";" + zone.getName() + ";"
+ + date.getDate() + ";" + val + "\n");
}
}
}
}
/*
-var Parametre=sim.getParametre();
-var Populations=Parametre.getPopulations();
-var PDate=Packages.fr.ifremer.nodb.Date;
+ var Parametre=sim.getParametre();
+ var Populations=Parametre.getPopulations();
+ var PDate=Packages.fr.ifremer.nodb.Date;
-var capture=0.0;
-var result="";
+ var capture=0.0;
+ var result="";
-writeln("debut de export captures nombre");
-var dateexport=new Packages.java.util.Date();
-var formatteur= new Packages.java.text.SimpleDateFormat();
-writeln("heure de debut: "+formatteur.format(dateexport));
-var finsimu=resultats.getLastDate().getDate();
+ writeln("debut de export captures nombre");
+ var dateexport=new Packages.java.util.Date();
+ var formatteur= new Packages.java.text.SimpleDateFormat();
+ writeln("heure de debut: "+formatteur.format(dateexport));
+ var finsimu=resultats.getLastDate().getDate();
-for (var ipop=Populations.iterator();ipop.hasNext();){
- var pop=ipop.next();
- for (var idate=0;idate<=finsimu;idate++){
- var date=new PDate(idate);
- var matrice=resultats.getMatrix(date,pop, "matriceCatchPerStrategyMet");
- var temp=matrice.sumOverDim(0);
- writeln("on a la matrice");
- for (var iiterateur=temp.iterator();iiterateur.next();){
- var coordonnees=iiterateur.getSemanticsCoordinates();
- var metier=coordonnees[1];
- var c=coordonnees[2];
- var z=coordonnees[3];
- capture=iiterateur.getValue();
- result+=pop.getNom()+";"+metier.getNom()+";"+c.getId()+";"+z.getNom()+";"+idate+";"+capture+"\n";
- }
- }
-}
+ for (var ipop=Populations.iterator();ipop.hasNext();){
+ var pop=ipop.next();
+ for (var idate=0;idate<=finsimu;idate++){
+ var date=new PDate(idate);
+ var matrice=resultats.getMatrix(date,pop, "matriceCatchPerStrategyMet");
+ var temp=matrice.sumOverDim(0);
+ writeln("on a la matrice");
+ for (var iiterateur=temp.iterator();iiterateur.next();){
+ var coordonnees=iiterateur.getSemanticsCoordinates();
+ var metier=coordonnees[1];
+ var c=coordonnees[2];
+ var z=coordonnees[3];
+ capture=iiterateur.getValue();
+ result+=pop.getNom()+";"+metier.getNom()+";"+c.getId()+";"+z.getNom()+";"+idate+";"+capture+"\n";
+ }
+ }
+ }
-writeln("fin de CapturesNombre");
+ writeln("fin de CapturesNombre");
-return ""+result;
+ return ""+result;
-*/
+ */
}
}
Modified: trunk/exports/CapturesPoids.java
===================================================================
--- trunk/exports/CapturesPoids.java 2009-04-29 08:39:41 UTC (rev 127)
+++ trunk/exports/CapturesPoids.java 2009-04-29 09:27:18 UTC (rev 128)
@@ -2,44 +2,41 @@
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 java.io.Writer;
-
-import org.codelutin.math.matrix.*;
-
import scripts.ResultName;
-
-import fr.ifremer.isisfish.entities.*;
+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.Zone;
import fr.ifremer.isisfish.export.Export;
import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.util.Doc;
-import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* CapturesPoids.java
- *
+ *
* Created: 23 novembre 2006
- *
+ *
* @author anonymous <anonymous(a)labs.libre-entreprise.org>
* @version $Revision: 1.4 $
- *
- * Last update: $Date: 2007-05-24 09:30:07 $
- * by : $Author: bpoussin $
+ *
+ * Last update: $Date: 2007-05-24 09:30:07 $ by : $Author: bpoussin $
*/
- @Doc(value="do the doc of class CapturesPoids")
+@Doc(value = "do the doc of class CapturesPoids")
public class CapturesPoids implements Export {
/** 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
- };
-
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET };
+
public String[] getNecessaryResult() {
return this.necessaryResult;
}
@@ -47,72 +44,76 @@
public String getExportFilename() {
return "CapturesPoids";
}
-
+
public String getExtensionFilename() {
return ".csv";
}
-
+
public String getDescription() {
return _("Export les captures en poids de la simulation. tableau pop;metier;id;zone;nombre");
}
- public void export(SimulationStorage simulation, Writer out) throws Exception {
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
Date lastDate = simulation.getResultStorage().getLastDate();
for (Population pop : simulation.getParameter().getPopulations()) {
- 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);
+ 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);
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();) {
+ 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];
+ Object[] sems = i.getSemanticsCoordinates();
+ Metier metier = (Metier) sems[1];
+ PopulationGroup group = (PopulationGroup) sems[2];
+ Zone zone = (Zone) sems[3];
double val = i.getValue();
- out.write(pop.getName() +";"+ metier.getName() +";"+ group.getId() +";"+ zone.getName() +";"+ date.getDate() +";"+ val +"\n");
+ out.write(pop.getName() + ";" + metier.getName() + ";"
+ + group.getId() + ";" + zone.getName() + ";"
+ + date.getDate() + ";" + val + "\n");
}
}
}
}
-/*
-var Parametre=sim.getParametre();
-var Populations=Parametre.getPopulations();
-var PDate=Packages.fr.ifremer.nodb.Date;
+ /*
+ var Parametre=sim.getParametre();
+ var Populations=Parametre.getPopulations();
+ var PDate=Packages.fr.ifremer.nodb.Date;
-var capture=0.0;
-var result="";
-writeln("debut de export captures poids");
-var dateexport=new Packages.java.util.Date();
-var formatteur= new Packages.java.text.SimpleDateFormat();
-writeln("heure de debut: "+formatteur.format(dateexport));
-var finsimu=resultats.getLastDate().getDate();
+ var capture=0.0;
+ var result="";
+ writeln("debut de export captures poids");
+ var dateexport=new Packages.java.util.Date();
+ var formatteur= new Packages.java.text.SimpleDateFormat();
+ writeln("heure de debut: "+formatteur.format(dateexport));
+ var finsimu=resultats.getLastDate().getDate();
-for (var ipop=Populations.iterator();ipop.hasNext();){
- var pop=ipop.next();
- for (var idate=0;idate<=finsimu;idate++){
- var date=new PDate(idate);
- var matrice=resultats.getMatrix(date,pop, "matriceCatchWeightPerStrategyMet");
- var temp=matrice.sumOverDim(0);
- writeln("on a la matrice");
- for (var iiterateur=temp.iterator();iiterateur.next();){
- var coordonnees=iiterateur.getSemanticsCoordinates();
- var metier=coordonnees[1];
- var c=coordonnees[2];
- var z=coordonnees[3];
- capture=iiterateur.getValue();
- result+=pop.getNom()+";"+metier.getNom()+";"+c.getId()+";"+z.getNom()+";"+idate+";"+capture+"\n";
- }
- }
-}
+ for (var ipop=Populations.iterator();ipop.hasNext();){
+ var pop=ipop.next();
+ for (var idate=0;idate<=finsimu;idate++){
+ var date=new PDate(idate);
+ var matrice=resultats.getMatrix(date,pop, "matriceCatchWeightPerStrategyMet");
+ var temp=matrice.sumOverDim(0);
+ writeln("on a la matrice");
+ for (var iiterateur=temp.iterator();iiterateur.next();){
+ var coordonnees=iiterateur.getSemanticsCoordinates();
+ var metier=coordonnees[1];
+ var c=coordonnees[2];
+ var z=coordonnees[3];
+ capture=iiterateur.getValue();
+ result+=pop.getNom()+";"+metier.getNom()+";"+c.getId()+";"+z.getNom()+";"+idate+";"+capture+"\n";
+ }
+ }
+ }
-writeln("fin de CapturesPoids");
-return ""+result;
+ writeln("fin de CapturesPoids");
+ return ""+result;
-*/
+ */
}
}
Modified: trunk/exports/RejetsNombre.java
===================================================================
--- trunk/exports/RejetsNombre.java 2009-04-29 08:39:41 UTC (rev 127)
+++ trunk/exports/RejetsNombre.java 2009-04-29 09:27:18 UTC (rev 128)
@@ -2,23 +2,23 @@
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 java.io.Writer;
-
-import org.codelutin.math.matrix.*;
-
import scripts.ResultName;
-
-import fr.ifremer.isisfish.entities.*;
+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.Zone;
import fr.ifremer.isisfish.export.Export;
import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.util.Doc;
-import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* RejetsNombre.java
*
Modified: trunk/exports/RejetsPoids.java
===================================================================
--- trunk/exports/RejetsPoids.java 2009-04-29 08:39:41 UTC (rev 127)
+++ trunk/exports/RejetsPoids.java 2009-04-29 09:27:18 UTC (rev 128)
@@ -2,23 +2,23 @@
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 java.io.Writer;
-
-import org.codelutin.math.matrix.*;
-
import scripts.ResultName;
-
-import fr.ifremer.isisfish.entities.*;
+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.Zone;
import fr.ifremer.isisfish.export.Export;
import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.util.Doc;
-import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* RejetsPoids.java
*
Modified: trunk/rules/GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD.java
===================================================================
--- trunk/rules/GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD.java 2009-04-29 08:39:41 UTC (rev 127)
+++ trunk/rules/GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD.java 2009-04-29 09:27:18 UTC (rev 128)
@@ -29,6 +29,7 @@
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.Date;
import fr.ifremer.isisfish.types.Month;
+import fr.ifremer.isisfish.util.Doc;
/**
* GraviteVPUE1Anchois.java
@@ -46,11 +47,15 @@
static private Log log = LogFactory
.getLog(GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD.class);
+ @Doc(value = "do the doc of param coeffOthers0")
public String param_nomfichier_coeffOthers0 = "Inputs_Langoustine/CoeffOthers_Intercept_Langoustine/CoeffOthersNephrops.csv";
+ @Doc(value = "do the doc of param coeffOthers1")
public String param_nomfichier_coeffOthers1 = "Inputs_Langoustine/CoeffOthers_Intercept_Langoustine/CoeffOthersHake.csv";
+ @Doc(value = "do the doc of param coeffOthers2")
public String param_nomfichier_coeffOthers2 = "Inputs_Langoustine/CoeffOthers_Intercept_Langoustine/CoeffOthersBenthic.csv";
+ @Doc(value = "do the doc of param gravite")
public boolean param_gravite = false;
- // doit �tre � vrai si gravite s'applique sinon la methode calcul uniquement les grossvalue otherspecies
+ // doit etre a vrai si gravite s'applique sinon la methode calcul uniquement les grossvalue otherspecies
static final protected String BETA_O = "BetaOthers";
static final protected String ALPHA_O = "AlphaOthers";
@@ -96,20 +101,20 @@
* @return L'aide ou la description de la regle
*/
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 et les gross Values otherSpecies");
+ return _("calcule les proportion par metier chaque mois en fonction de la VPUE du metier l'annee precedante et les gross Values otherSpecies");
/*"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 "+
- on remet propInitiale pour tous les m�tiers (premiere vue complete pour tous les metiers de la strategie - graviteVPUE1-, une alternative
- pourrait �tre de chercher lapremiere ann�e avant ann�e -1 pour laquelle le m�tier, ayant une propInitiale non nulle , aurait une VPUE (metier,mois) non nulle
- et recuperer la propStr (metier,mois) pour cette ann�e et on l'affecte ann�e courante - mois, les autres m�tiers se partageant la proportion d'effort restante
- en fonction de leur VPUE - graviteVPUE2-, une alternative pourrait etre de chercher la premiere ann�e avant ann�e -1 pour laquelle tous les m�tiers,
- ayant une propInitiale non nulle, auraient eu une propStr non nulle, (surement difficile � trouver) - - graviteVPUE3- d'autres hypoth�ses pourraient etre envisag�es)
+ " attention cette regle doit toujours etre mise avant les mesures de gestion"+
+ " si pour un metier Effort (metier annee-1,mois) = 0 et propinitiale (metier, mois) !=0 (ie metier potentiellement pratique), alors "+
+ on remet propInitiale pour tous les metiers (premiere vue complete pour tous les metiers de la strategie - graviteVPUE1-, une alternative
+ pourrait etre de chercher lapremiere annee avant annee -1 pour laquelle le metier, ayant une propInitiale non nulle , aurait une VPUE (metier,mois) non nulle
+ et recuperer la propStr (metier,mois) pour cette annee et on l'affecte annee courante - mois, les autres metiers se partageant la proportion d'effort restante
+ en fonction de leur VPUE - graviteVPUE2-, une alternative pourrait etre de chercher la premiere annee avant annee -1 pour laquelle tous les metiers,
+ ayant une propInitiale non nulle, auraient eu une propStr non nulle, (surement difficile a trouver) - - graviteVPUE3- d'autres hypotheses pourraient etre envisagees)
"*/
- /*Calcul des gross Value Other Species en fonction de l'effort par strategie et par m�tier � date
- Avant ann�e 1 (premiere ann�e d'appliaction de Gravit�) - il faut deja faire les calculs des grossValues des autres esp�ces
- A partir de l'ann�e 1 : Gravit� s'applique, il faut donc attendre de connaitre l'allocation de l'effort � date (dependant des gross values species et otherspecies � date - 1)
- pour pouvoir calculer les grossValueOtherSpecies � date
+ /*Calcul des gross Value Other Species en fonction de l'effort par strategie et par metier a date
+ Avant annee 1 (premiere annee d'appliaction de Gravite) - il faut deja faire les calculs des grossValues des autres especes
+ A partir de l'annee 1 : Gravite s'applique, il faut donc attendre de connaitre l'allocation de l'effort a date (dependant des gross values species et otherspecies a date - 1)
+ pour pouvoir calculer les grossValueOtherSpecies a date
*/
}
@@ -124,7 +129,7 @@
};
/**
- * Appel� au d�marrage de la simulation, cette m�thode permet d'initialiser
+ * Appele au demarrage de la simulation, cette methode permet d'initialiser
* des valeurs
*
* @param simulation
@@ -166,11 +171,11 @@
if (param_nomfichier_coeffOthers0 == null
|| "".equals(param_nomfichier_coeffOthers0)) {
CoeffOthers0 = FileUtil.getFile(".*.csv",
- "fichier 0 csv s�parateur ';'");
+ "fichier 0 csv separateur ';'");
CoeffOthers1 = FileUtil.getFile(".*.csv",
- "fichier 1 csv s�parateur ';'");
+ "fichier 1 csv separateur ';'");
CoeffOthers2 = FileUtil.getFile(".*.csv",
- "fichier 2 csv s�parateur ';'");
+ "fichier 2 csv separateur ';'");
} else {
CoeffOthers0 = new File(param_nomfichier_coeffOthers0);
CoeffOthers1 = new File(param_nomfichier_coeffOthers1);
@@ -261,7 +266,7 @@
}
/**
- * Si la condition est vrai alors cette action est execut�e avant le pas de
+ * Si la condition est vrai alors cette action est executee avant le pas de
* temps de la simulation.
*
* @param simulation
@@ -298,7 +303,7 @@
log.info("GrossValueOtherSpeciesPerStrMet initialisee "
+ GrossValueOtherSpeciesPerStrMet);
- // si ann�e>=1 alors on fait le calcul des gravit� puis on met � jour les gross value otherspecies
+ // si annee>=1 alors on fait le calcul des gravite puis on met a jour les gross value otherspecies
if ((date.getYear() > 0) & (param_gravite == true)) {
////////Initialisation des matrices qui resultent de la simulation////////////////////////////////////////////////////////////
log.info("calcul de Gravite");
@@ -319,7 +324,7 @@
.copy();
log.info("GrossValuePerStrMet calculee " + GrossValuePerStrMet);
- //ajouter pour tous les m�tiers les valeurs li�es qux autres esp�ces calcul�es par modele lineaire
+ //ajouter pour tous les metiers les valeurs liees qux autres especes calculees par modele lineaire
// Boucle sur les strategies de mes strategies
//List <Strategy> mStr = strs;
for (Strategy strIndex : strs) {
@@ -331,7 +336,7 @@
.getMonth());
Collection<EffortDescription> strMet = str
.getSetOfVessels().getPossibleMetiers();
- //2) calcul les valeurs non simulees du mois l ann�e pr�c�dante
+ //2) calcul les valeurs non simulees du mois l annee precedante
for (EffortDescription effort : strMet) {
Metier met = effort.getPossibleMetiers();
log.info("Boucle metier 1, metier possible: "
@@ -340,10 +345,10 @@
log.info("effort str" + str.getName() + met.getName()
+ " : " + eff);
- //GrossValueAutres par strat�gie
- // Hypothese 1 = pas de distinction entre les m�tiers n'agira donc pas sur la gravit�)
- // Hypothese 2 = a distinguer selon les m�tiers - agira sur la gravit�
- // l'hypothese est le resultat des coef dans la matrice en entr�e si tous identiques quelque soit le metier dans la strat�gie alors H1
+ //GrossValueAutres par strategie
+ // Hypothese 1 = pas de distinction entre les metiers n'agira donc pas sur la gravite)
+ // Hypothese 2 = a distinguer selon les metiers - agira sur la gravite
+ // l'hypothese est le resultat des coef dans la matrice en entree si tous identiques quelque soit le metier dans la strategie alors H1
// sinon H2
double valMetOther = matrixCoeffOthers.getValue(str,
met, ALPHA_O)
@@ -365,7 +370,7 @@
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
- valuePerUnitOfEffort.map(nanFunction); //r�initialisation avant calcul pour date
+ valuePerUnitOfEffort.map(nanFunction); //reinitialisation avant calcul pour date
for (Strategy str : strs) {
log.info("INFO: Boucle creation valuePerUnitEffort : "
@@ -389,9 +394,9 @@
// on teste effort pour le calcul des VPUE
// si effort != 0 , valeur/effort
//sinon (effort =0) , deux cas de figure :
- // 1. soit propInitiale =0 pour ce m�tier et dans ce cas VPUE =0 et ca ne doit pas impacter le calcul de la gravite pour les autres metiers de str
+ // 1. soit propInitiale =0 pour ce metier et dans ce cas VPUE =0 et ca ne doit pas impacter le calcul de la gravite pour les autres metiers de str
// 2. soit propInitiale! =0 et dans ce cas, on mettra PropInitiale pour tous les metiers de str
- if (effort > 0) {// a pech� au mois, annee-1
+ if (effort > 0) {// a peche au mois, annee-1
//on recupere la capture tot
double value = GrossValuePerStrMet.getValue(str,
strMetier);
@@ -402,21 +407,21 @@
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 peche avec ce metier
valuePerUnitOfEffort.setValue(str, strMetier, 0);
- log.info("n'a jamais p�che avec ce metier");
+ log.info("n'a jamais peche avec ce metier");
} else {// n'a pas peche au mois, annee -1, mais avait une prop d'effort non nul a l'annee=0
- testCondition = true;// ie somme est incompl�te mais pas grave car on mettra PropInitiale � tous les metiers
+ testCondition = true;// ie somme est incomplete mais pas grave car on mettra PropInitiale a tous les metiers
log
.info("n'a pas peche au mois, annee -1, mais avait une prop d'effort non nul a l'annee=0");
}
}
log.info("testCondition pour str" + str.getName() + ":"
+ testCondition);
- // � partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravit�
+ // a partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravite
double newProp = 0;
log
- .info("� partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravit�");
+ .info("a partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravite");
if (!testCondition) {
double SommeVPUEstrat = somme;
log.info("SommeVPUEstrat=" + SommeVPUEstrat);
@@ -447,13 +452,13 @@
log.info("PropStrNouvelle(metier="
+ strMetier.getName() + ")"
+ smi.getProportionMetier(strMetier));
- // annee>= 1 calcul des gross Value otherSpecies avec les nouvelles valeurs d'effort calcul�es par gravite
- //avec la nouvelle proportion on en d�duit la gross Value of Species de date pour ce str-met
+ // annee>= 1 calcul des gross Value otherSpecies avec les nouvelles valeurs d'effort calculees par gravite
+ //avec la nouvelle proportion on en deduit la gross Value of Species de date pour ce str-met
double valMetOtherSpecies = matrixCoeffOthers
.getValue(str, strMetier, ALPHA_O)
+ matrixCoeffOthers.getValue(str,
strMetier, BETA_O) * newProp;
- //tester si valMetOtherSpecies <= alors mettre � 0
+ //tester si valMetOtherSpecies <= alors mettre a 0
if (valMetOtherSpecies < 0) {
valMetOtherSpecies = 0;
}
@@ -467,9 +472,9 @@
}
}
// else ie on met propInitiale dans PropStr(str,annee,mois)
- // rien n'a faire car au debut de chaque pas de temps, PropStr est par d�faut initialis� � la valeur de la base de donn�es (val initiales)
+ // rien n'a faire car au debut de chaque pas de temps, PropStr est par defaut initialise a la valeur de la base de donnees (val initiales)
}//fin de boucle sur strategy
- // r�sultats grossvalue otherspecies mis dans le resultManager
+ // resultats grossvalue otherspecies mis dans le resultManager
resultmanager
.addResult(
date,
@@ -477,7 +482,7 @@
GrossValueOtherSpeciesPerStrMet);
} else if ((date.getYear() == 0) || (param_gravite == false)) {
- //si ann�e==0 alors on ne fait que le calcul des gross value other species
+ //si annee==0 alors on ne fait que le calcul des gross value other species
for (Strategy str : strs) {
log.info("INFO: Boucle creation valuePerUnitEffort : "
+ str.getName());
@@ -496,7 +501,7 @@
+ matrixCoeffOthers.getValue(str, strMetier,
BETA_O)
* smi.getProportionMetier(strMetier);
- //tester si valMetOtherSpecies <= alors mettre � 0
+ //tester si valMetOtherSpecies <= alors mettre a 0
if (valMetOtherSpecies < 0) {
valMetOtherSpecies = 0;
}
@@ -509,13 +514,13 @@
strMetier));
}
}
- // r�sultats grossvalue otherspecies mis dans le resultManager
+ // resultats grossvalue otherspecies mis dans le resultManager
resultmanager
.addResult(
date,
ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_OTHER_SPECIES_PER_STRATEGY_MET,
GrossValueOtherSpeciesPerStrMet);
- } // fin de calcul pour ann�e ==0
+ } // fin de calcul pour annee ==0
first = false;
}// fin de first= true
@@ -527,7 +532,7 @@
}
/**
- * Si la condition est vrai alors cette action est execut�e apres le pas de
+ * Si la condition est vrai alors cette action est executee apres le pas de
* temps de la simulation.
*
* @param simulation
Modified: trunk/rules/TACpoids.java
===================================================================
--- trunk/rules/TACpoids.java 2009-04-29 08:39:41 UTC (rev 127)
+++ trunk/rules/TACpoids.java 2009-04-29 09:27:18 UTC (rev 128)
@@ -42,13 +42,13 @@
*/
/**
- * TAC peut-etre utilis� pour les diff�rents TAC, en proportion des effectifs
+ * TAC peut-etre utilise pour les differents TAC, en proportion des effectifs
* et/ou avec survie ou non.
*
* <li>Pour utiliser le tac proportionnel, il faut mettre dans le parametre
- * propTac une valeur > 0, le TAC sera alors recalcul� a chaque mois de janvier.
- * <li>Pour utiliser la survie il faut mettre dans le param�tre propSurvie une
- * valeur > 0, automatiquement les suvie seront ajout� aux effectifs
+ * propTac une valeur > 0, le TAC sera alors recalcule a chaque mois de janvier.
+ * <li>Pour utiliser la survie il faut mettre dans le parametre propSurvie une
+ * valeur > 0, automatiquement les suvie seront ajoute aux effectifs
*
*/
public class TACpoids extends AbstractRule {
@@ -97,7 +97,7 @@
}
/**
- * Appel� au d�marrage de la simulation, cette m�thode permet d'initialiser
+ * Appele au demarrage de la simulation, cette methode permet d'initialiser
* des valeurs
*
* @param simulation
@@ -121,7 +121,7 @@
param_species = (Species) context.getDB().findByTopiaId(
param_species.getTopiaId());
- // on fait le calcul du tac si n�cessaire
+ // on fait le calcul du tac si necessaire
if (param_propTac > 0 && date.getMonth().equals(Month.JANUARY)) {
PopulationMonitor popMon = context.getPopulationMonitor();
param_tacInTons = popMon.getBiomass(param_species) * param_propTac;
@@ -149,7 +149,7 @@
}
/**
- * Si la condition est vrai alors cette action est execut�e avant le pas de
+ * Si la condition est vrai alors cette action est executee avant le pas de
* temps de la simulation.
*
* @param simulation
@@ -173,7 +173,7 @@
log.info("aimed Metier: " + aimedMetiers);*/
context.getMetierMonitor().addforbiddenMetier(metier);
- //r�cupere toutes les strat�gies pratiquant le m�tier et pour lesquelles la proportion !=0
+ //recupere toutes les strategies pratiquant le metier et pour lesquelles la proportion !=0
SiMatrix siMatrix = SiMatrix.getSiMatrix(context);
Set<Strategy> strs = new HashSet<Strategy>();
for (Strategy str : siMatrix.getStrategies(date)) {
@@ -208,7 +208,7 @@
&&*/!metier.getName().equalsIgnoreCase("nonActiviy")
&& !metier.getName().equalsIgnoreCase("nonActivie")
&& !metier.getName().equalsIgnoreCase(
- "non Activit�")
+ "non Activite")
&& !context.getMetierMonitor().getForbiddenMetier()
.contains(newMetier)) {
possibleMetierCase3.add(newMetier);
@@ -271,7 +271,7 @@
}
/**
- * Si la condition est vrai alors cette action est execut�e apres le pas de
+ * Si la condition est vrai alors cette action est executee apres le pas de
* temps de la simulation.
*
* @param simulation
Modified: trunk/scripts/GravityModel.java
===================================================================
--- trunk/scripts/GravityModel.java 2009-04-29 08:39:41 UTC (rev 127)
+++ trunk/scripts/GravityModel.java 2009-04-29 09:27:18 UTC (rev 128)
@@ -139,7 +139,7 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
* FishingTimePerMonthPerVessel[str,met,month] =
* FishingTimePerTrip[str,met,month]NbTripsPerMonth[str,month]
*
@@ -191,8 +191,9 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * FuelCostsOfTravelPerVessel[sov,met,month]�=�NbTripsPerMonth[str,month]*TravelTimePerTrip[sov,met,month]*UnitFuelCostsOfTravel[vt]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * FuelCostsOfTravelPerVessel[sov,met,month] =
+ * NbTripsPerMonth[str,month]*TravelTimePerTrip[sov,met,month]*UnitFuelCostsOfTravel[vt]
*
* @param str
* @param metier
@@ -249,7 +250,7 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
* CostsOfFishingPerVessel[str,met,month]= FishingTimePerMonthPerVessel
* [str,met,month] {NbFishingOperationsPerDay[sov,met]
* UnitCostsOfFishing[sov,met] / 24}
@@ -310,7 +311,7 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
* FuelCostsPerVessel[str,met,month] = FuelCostsOfTravelPerVessel
* [sov,met,month] + CostsOfFishingPerVessel [str,met,month]
*
@@ -362,8 +363,9 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * RepairAndMaintenanceGearCostsPerVessel[str,met,month]�=�FishingTimePerMonthPerVessel[str,met,month]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * RepairAndMaintenanceGearCostsPerVessel[str,met,month] =
+ * FishingTimePerMonthPerVessel[str,met,month]
* *RepairAndMaintenanceGearCostsPerDay[sov,met]/NbHoursPerDay
*
* @param str
@@ -421,8 +423,9 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * OtherRunningCostsPerVessel[str,met,month]=�FishingTimePerMonthPerVessel[str,met,month]*OtherRunningCostsPerDay[sov,met]/
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * OtherRunningCostsPerVessel[str,met,month] =
+ * FishingTimePerMonthPerVessel[str,met,month]*OtherRunningCostsPerDay[sov,met]/
* NbHoursPerDay
*
* @param str
@@ -480,9 +483,9 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * SharedNotFixedCostsPerVessel[str,met,month]=�FuelCostsPerVessel[str,met,month]
- * +�OtherRunningCostsPerVessel[str,met,month]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * SharedNotFixedCostsPerVessel[str,met,month]=FuelCostsPerVessel[str,met,month]
+ * +OtherRunningCostsPerVessel[str,met,month]
*
* @param str
* @param metier
@@ -585,9 +588,9 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month]�=�sum
- * over classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet
+ * 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
@@ -749,9 +752,9 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * GrossValueOfLandingsPerStrategyMetPerVessel[str,met,month]�=
- * GrossValueOfLandingsPerStrategyMet[str,met,month]�/[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * GrossValueOfLandingsPerStrategyMetPerVessel[str,met,month]=
+ * GrossValueOfLandingsPerStrategyMet[str,met,month]/[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)]
*
* @param str
* @param metier
@@ -810,8 +813,10 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * NetValueOfLandingsPerStrategyMet[str,met,month]�=�GrossValueOfLandingsPerStrategyMet[str,met,month]�(1-LandingCostRate[str,met]�)
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * NetValueOfLandingsPerStrategyMet[str,met,month] =
+ * GrossValueOfLandingsPerStrategyMet[str,met,month]
+ * (1-LandingCostRate[str,met])
*
* @param str
* @param metier
@@ -883,8 +888,10 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * NetValueOfLandingsPerStrategyMetPerVessel[str,met,month]�=�NetValueOfLandingsPerStrategyMet[str,met,month]�/[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * NetValueOfLandingsPerStrategyMetPerVessel[str,met,month] =
+ * NetValueOfLandingsPerStrategyMet[str,met,month]
+ * /[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)]
*
* @param str
* @param metier
@@ -942,10 +949,11 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * NetRevenueToSharePerStrategyMetPerVessel[str,met,month]�=�NetValueOfLandingsPerStrategyMetPerVessel[str,met,month]�-�SharedNotFixedCostsPerVessel
- * [str,met,month]*PropStr(str,met,month) - SharedFixedCostsPerVessel
- * PerMet[str,month]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * NetRevenueToSharePerStrategyMetPerVessel[str,met,month] =
+ * NetValueOfLandingsPerStrategyMetPerVessel[str,met,month] -
+ * SharedNotFixedCostsPerVessel [str,met,month]*PropStr(str,met,month) -
+ * SharedFixedCostsPerVessel PerMet[str,month]
*
* @param str
* @param metier
@@ -1003,8 +1011,9 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * CrewSharePerStrategyMetPerVessel[str,met,month]�=�NetRevenueToSharePerStrategyMetPerVessel[str,met,month]*CrewShareRate[sov,met]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * CrewSharePerStrategyMetPerVessel[str,met,month] =
+ * NetRevenueToSharePerStrategyMetPerVessel[str,met,month]*CrewShareRate[sov,met]
*
* @param str
* @param metier
@@ -1066,11 +1075,11 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
* OwnerMarginOverVariableCostsPerStrategyMetPerVessel[str,met,month] =
- * NetRevenueToSharePerStrategyMetPerVessel[str,met,month]�-
- * CrewSharePerStrategyMetPerVessel[str,met,month]�-
- * RepairAndMaintenanceGearCostsPerVes sel[str,met,month]�*
+ * NetRevenueToSharePerStrategyMetPerVessel[str,met,month] -
+ * CrewSharePerStrategyMetPerVessel[str,met,month] -
+ * RepairAndMaintenanceGearCostsPerVes sel[str,met,month] *
* PropStr(str,met,month)
*
* @param str
@@ -1130,9 +1139,10 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * VesselMarginOverVariableCostsPerStrategyMetPerVessel�[str,met,month]�=NetRevenueToSharePerStrategyMetPerVessel[str,met,month]-
- * RepairAndMaintenanceGearCostsPerVessel [str,met,month]�*
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * VesselMarginOverVariableCostsPerStrategyMetPerVessel [str,met,month]
+ * =NetRevenueToSharePerStrategyMetPerVessel[str,met,month]-
+ * RepairAndMaintenanceGearCostsPerVessel [str,met,month] *
* PropStr(str,met,month)
*
* @param str
@@ -1183,9 +1193,9 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * OwnerMarginOverVariableCostsPerStrategyPerVessel[str,month]�=�somme sur
- * tous les m�tiers de OwnerMarginOverVariableCostsPerStrategyMetPerVessel
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * OwnerMarginOverVariableCostsPerStrategyPerVessel[str,month] = somme sur
+ * tous les metiers de OwnerMarginOverVariableCostsPerStrategyMetPerVessel
* [str,met,month]
*
* @param str
@@ -1237,8 +1247,10 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * OwnerMarginOverVariableCostsPerStrategy[str,month]�=�OwnerMarginOverVariableCostsPerStrategyPerVessel[str,month]�*[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * OwnerMarginOverVariableCostsPerStrategy[str,month] =
+ * OwnerMarginOverVariableCostsPerStrategyPerVessel[str,month]
+ * *[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)]
*
* @param str
* @param date
@@ -1286,9 +1298,9 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * VesselMarginOverVariableCostsPerStrategyPerVessel[str,month]�= somme sur
- * tous les m�tiers de VesselMarginOverVariableCostsPerStrategyMetPerVessel�
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * VesselMarginOverVariableCostsPerStrategyPerVessel[str,month] = somme sur
+ * tous les metiers de VesselMarginOverVariableCostsPerStrategyMetPerVessel
* [str,met,month]
*
* @param str
@@ -1340,8 +1352,9 @@
}
/**
- * implant� suivant document ModifTable3PourBP25-07-2006.doc
- * VesselMarginOverVariableCostsPerStrategy[str,month]�=VesselMarginOverVariableCostsPerStrategyPerVessel�[str,month]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * VesselMarginOverVariableCostsPerStrategy[str,month]
+ * =VesselMarginOverVariableCostsPerStrategyPerVessel [str,month]
* *[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)]
*
* @param str
@@ -1362,7 +1375,7 @@
///////////////////////////////////////////////////////////////////////////
//
- // Methode non utilis�e directement dans GravityModel, mais dans les rules
+ // Methode non utilisee directement dans GravityModel, mais dans les rules
//
///////////////////////////////////////////////////////////////////////////
Modified: trunk/scripts/ResultName.java
===================================================================
--- trunk/scripts/ResultName.java 2009-04-29 08:39:41 UTC (rev 127)
+++ trunk/scripts/ResultName.java 2009-04-29 09:27:18 UTC (rev 128)
@@ -1,6 +1,6 @@
/* *##%
* Copyright (C) 2006
- * Code Lutin, C�dric Pineau, Benjamin Poussin
+ * 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
@@ -20,7 +20,7 @@
/* *
* ResultName.java
*
- * Created: 23 ao�t 2006 15:09:37
+ * Created: 23 aout 2006 15:09:37
*
* @author poussin
* @version $Revision: 1.10 $
@@ -37,16 +37,16 @@
/**
* Contient l'ensemble des noms des differents resultats. Le mieux lorsque l'on
- * veut un nouveau r�sultat est d'ajouter une constante ici, et de l'utiliser
- * ensuite lors de la cr�ation de la matrice.
+ * veut un nouveau resultat est d'ajouter une constante ici, et de l'utiliser
+ * ensuite lors de la creation de la matrice.
* <p>
- * Ceci permet d'avoir un endroit unique ou l'on voit l'ensemble des r�sultats
- * potentiellement disponible et de ne pas ce tromper en �crivent le nom
- * d'un r�sultat
+ * Ceci permet d'avoir un endroit unique ou l'on voit l'ensemble des resultats
+ * potentiellement disponible et de ne pas ce tromper en ecrivent le nom
+ * d'un resultat
* <p>
* Cette classe ne doit contenir que des noms de resultat en static public String
* l'interface de lancement de simulation se base sur cette classe pour
- * afficher l'ensemble des r�sultats disponible
+ * afficher l'ensemble des resultats disponible
*
* @author poussin
*/
Modified: trunk/scripts/SiMatrix.java
===================================================================
--- trunk/scripts/SiMatrix.java 2009-04-29 08:39:41 UTC (rev 127)
+++ trunk/scripts/SiMatrix.java 2009-04-29 09:27:18 UTC (rev 128)
@@ -20,7 +20,7 @@
/* *
* SiMatrix.java
*
- * Created: 21 ao�t 2006 15:53:01
+ * Created: 21 aout 2006 15:53:01
*
* @author poussin
* @version $Revision: 1.18 $
@@ -31,14 +31,13 @@
package scripts;
-import static org.codelutin.i18n.I18n._;
import static org.codelutin.i18n.I18n.n_;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -67,56 +66,59 @@
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.Date;
import fr.ifremer.isisfish.types.Month;
-import java.util.Arrays;
-import java.util.Set;
/**
* @author poussin
- *
+ *
*/
public class SiMatrix {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(SiMatrix.class);
-
+
protected SimulationContext context = null;
protected TopiaContext db = null;
-
+
/**
* Method used to get SiMatrix used for simulation
- * @param context context simulation
+ *
+ * @param context
+ * context simulation
* @return SiMatrix or null if no SiMatrix created for simulation
*/
- public static SiMatrix getSiMatrix(SimulationContext context) throws TopiaException {
- SiMatrix result = (SiMatrix)context.getValue(SiMatrix.class.getName());
+ public static SiMatrix getSiMatrix(SimulationContext context)
+ throws TopiaException {
+ SiMatrix result = (SiMatrix) context.getValue(SiMatrix.class.getName());
if (result == null) {
result = new SiMatrix(context);
}
return result;
}
-
+
private static void setSiMatrix(SimulationContext context, SiMatrix siMatrix) {
context.setValue(SiMatrix.class.getName(), siMatrix);
}
-
+
/**
*
- * @param context Simulation context
- * @param db TopiaContext with transaction opened. You must used this
- * TopiaContext and not used
- * SimulationContext.getSimulationStorage().getStorage()
- * @throws TopiaException
+ * @param context
+ * Simulation context
+ * @param db
+ * TopiaContext with transaction opened. You must used this
+ * TopiaContext and not used
+ * SimulationContext.getSimulationStorage().getStorage()
+ * @throws TopiaException
*/
public SiMatrix(SimulationContext context) throws TopiaException {
this.context = context;
this.db = context.getDB();
setSiMatrix(context, this);
}
-
+
/**
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
public List<Zone> getZones(Date date) throws TopiaException {
ZoneDAO dao = IsisFishDAOHelper.getZoneDAO(db);
@@ -126,12 +128,13 @@
/**
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
public List<Population> getPopulations(Date date) throws TopiaException {
List<Population> populations = new ArrayList<Population>();
- for (Population pop : context.getSimulationStorage().getParameter().getPopulations()) {
- Population tmp = (Population)db.findByTopiaId(pop.getTopiaId());
+ for (Population pop : context.getSimulationStorage().getParameter()
+ .getPopulations()) {
+ Population tmp = (Population) db.findByTopiaId(pop.getTopiaId());
populations.add(tmp);
}
return populations;
@@ -139,39 +142,40 @@
/**
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
public List<Strategy> getStrategies(Date date) throws TopiaException {
-// if (strategies == null) {
+ // if (strategies == null) {
List<Strategy> strategies = new ArrayList<Strategy>();
- for (Strategy str : context.getSimulationStorage().getParameter().getStrategies()) {
- Strategy tmp = (Strategy)db.findByTopiaId(str.getTopiaId());
- strategies.add(tmp);
- }
-// }
+ for (Strategy str : context.getSimulationStorage().getParameter()
+ .getStrategies()) {
+ Strategy tmp = (Strategy) db.findByTopiaId(str.getTopiaId());
+ strategies.add(tmp);
+ }
+ // }
return strategies;
}
public List<Metier> getMetiers(Date date) throws TopiaException {
-// if (metiers == null) {
- List<Metier> metiers = new ArrayList<Metier>();
- HashSet<Metier> tmp = new HashSet<Metier>();
- for (Strategy str : getStrategies(date)) {
- SetOfVessels sov = str.getSetOfVessels();
- for (EffortDescription effort : sov.getPossibleMetiers()) {
- Metier metier = effort.getPossibleMetiers();
- if (tmp.add(metier)) {
- metiers.add(metier);
- }
+ // if (metiers == null) {
+ List<Metier> metiers = new ArrayList<Metier>();
+ HashSet<Metier> tmp = new HashSet<Metier>();
+ for (Strategy str : getStrategies(date)) {
+ SetOfVessels sov = str.getSetOfVessels();
+ for (EffortDescription effort : sov.getPossibleMetiers()) {
+ Metier metier = effort.getPossibleMetiers();
+ if (tmp.add(metier)) {
+ metiers.add(metier);
}
}
-// }
+ }
+ // }
return metiers;
}
/**
- * Retourne les metiers pratiqu�s par une Strategie � une date donn�e
- * Un metier est pratiqu� si le PropStrMet est diff�rent de 0
+ * Retourne les metiers pratiques par une Strategie a une date donnee Un
+ * metier est pratique si le PropStrMet est different de 0
*
* @param str
* @param date
@@ -180,13 +184,13 @@
public List<Metier> getMetiers(Strategy str, Date date) {
StrategyMonthInfo info = str.getStrategyMonthInfo(date.getMonth());
MatrixND props = info.getProportionMetier();
-
+
List<Metier> result = new ArrayList<Metier>();
-
- for (MatrixIterator i=props.iterator(); i.hasNext();) {
+
+ for (MatrixIterator i = props.iterator(); i.hasNext();) {
i.next();
if (i.getValue() != 0) {
- Metier metier = (Metier)i.getSemanticsCoordinates()[0];
+ Metier metier = (Metier) i.getSemanticsCoordinates()[0];
result.add(metier);
}
}
@@ -194,26 +198,26 @@
}
/**
- * Retourne la matrix Metier x Zone qui correspond au zone utilis� par
- * un m�tier pour une date donn�e. Si la valeur de la matrice est 1 alors
- * la zone est utilis� par le m�tier, si elle vaut 0 alors elle n'est pas
- * utilis�e.
+ * Retourne la matrix Metier x Zone qui correspond au zone utilise par un
+ * metier pour une date donnee. Si la valeur de la matrice est 1 alors la
+ * zone est utilise par le metier, si elle vaut 0 alors elle n'est pas
+ * utilisee.
*
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
public MatrixND getMetierZone(Date date) throws TopiaException {
List<Metier> metiers = getMetiers(date);
List<Zone> zones = getZones(date);
-
+
MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_METIER_ZONE,
- new List[]{metiers, zones},
- new String[]{n_("Metiers"), n_("Zones")});
+ ResultName.MATRIX_METIER_ZONE, new List[] { metiers, zones },
+ new String[] { n_("Metiers"), n_("Zones") });
for (Metier metier : metiers) {
- Collection<Zone> zoneMetier = metier.getMetierSeasonInfo(date.getMonth()).getZone();
+ Collection<Zone> zoneMetier = metier.getMetierSeasonInfo(
+ date.getMonth()).getZone();
for (Zone zone : zoneMetier) {
result.setValue(metier, zone, 1);
}
@@ -224,25 +228,26 @@
public MatrixND matrixPrice(Date date, Population pop) {
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_PRICE,
- new List[]{groups},
- new String[]{n_("PopulationGroup")});
-
+ ResultName.MATRIX_PRICE, new List[] { groups },
+ new String[] { n_("PopulationGroup") });
+
for (PopulationGroup group : groups) {
result.setValue(group, group.getPrice());
}
-
+
return result;
}
-
- ///////////////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////////////
//
// Toutes les methodes suivantes ne sont utiles que pour
// matrixCatchPerStrategyMet
//
///////////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixCatchWeightPerStrategyMetPerZoneMet(Date date, Population pop, MatrixND matrixCatchPerStrategyMetPerZoneMet) throws TopiaException, IsisFishException {
+
+ public MatrixND matrixCatchWeightPerStrategyMetPerZoneMet(Date date,
+ Population pop, MatrixND matrixCatchPerStrategyMetPerZoneMet)
+ throws TopiaException, IsisFishException {
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = matrixCatchPerStrategyMetPerZoneMet.copy();
@@ -257,35 +262,43 @@
return result;
}
- public MatrixND matrixCatchPerStrategyMetPerZoneMet(MatrixND N, Population pop, Date date) throws TopiaException, IsisFishException {
-
- MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell(date, pop);
- MatrixND matrixCatchRatePerStrategyMetPerCell = matrixCatchRatePerStrategyMetPerCell(pop, date, matrixFishingMortalityPerCell);
- MatrixND matrixCatchPerStrategyMetPerCell = matrixCatchPerStrategyMetPerCell(N, pop, date, matrixCatchRatePerStrategyMetPerCell);
-
+ public MatrixND matrixCatchPerStrategyMetPerZoneMet(MatrixND N,
+ Population pop, Date date) throws TopiaException, IsisFishException {
+
+ MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell(
+ date, pop);
+ MatrixND matrixCatchRatePerStrategyMetPerCell = matrixCatchRatePerStrategyMetPerCell(
+ pop, date, matrixFishingMortalityPerCell);
+ MatrixND matrixCatchPerStrategyMetPerCell = matrixCatchPerStrategyMetPerCell(
+ N, pop, date, matrixCatchRatePerStrategyMetPerCell);
+
List<Strategy> strategies = getStrategies(date);
List<Metier> metiers = getMetiers(date);
- List<PopulationGroup> groups = matrixCatchPerStrategyMetPerCell.getSemantics(2);
+ List<PopulationGroup> groups = matrixCatchPerStrategyMetPerCell
+ .getSemantics(2);
List<Zone> zones = getZones(date);
- Set<Cell> cellPops = new HashSet(matrixCatchPerStrategyMetPerCell.getSemantics(4));
-
+ Set<Cell> cellPops = new HashSet(matrixCatchPerStrategyMetPerCell
+ .getSemantics(4));
+
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_CATCH_PER_STRATEGY_MET,
- new List[]{strategies, metiers, groups, zones},
- new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")});
-
+ new List[] { strategies, metiers, groups, zones },
+ new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
+ n_("Zones") });
+
// matrice temporaire ou les zones pops sont sommees
MatrixND tmp = matrixCatchPerStrategyMetPerCell.sumOverDim(3);
tmp = tmp.reduceDims(3);
-
+
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
- for(int g = 0; g<groups.size(); g++) {
+ 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);
- MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(date.getMonth());
+ MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(date
+ .getMonth());
Collection<Zone> zoneMet = infoMet.getZone();
for (Zone z : zoneMet) {
double value = 0;
@@ -304,15 +317,19 @@
}
}
}
-
+
return result;
}
-
- public MatrixND matrixCatchPerStrategyMetPerZonePop(MatrixND N, Population pop, Date date) throws TopiaException, IsisFishException {
- MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell(date, pop);
- MatrixND matrixCatchRatePerStrategyMetPerCell = matrixCatchRatePerStrategyMetPerCell(pop, date, matrixFishingMortalityPerCell);
- MatrixND matrixCatchPerStrategyMetPerCell = matrixCatchPerStrategyMetPerCell(N, pop, date, matrixCatchRatePerStrategyMetPerCell);
-
+
+ public MatrixND matrixCatchPerStrategyMetPerZonePop(MatrixND N,
+ Population pop, Date date) throws TopiaException, IsisFishException {
+ MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell(
+ date, pop);
+ MatrixND matrixCatchRatePerStrategyMetPerCell = matrixCatchRatePerStrategyMetPerCell(
+ pop, date, matrixFishingMortalityPerCell);
+ MatrixND matrixCatchPerStrategyMetPerCell = matrixCatchPerStrategyMetPerCell(
+ N, pop, date, matrixCatchRatePerStrategyMetPerCell);
+
// on somme sur les cellules
MatrixND result = matrixCatchPerStrategyMetPerCell.sumOverDim(4);
result = result.reduceDims(4);
@@ -320,9 +337,10 @@
return result;
}
-
+
public MatrixND matrixCatchWeightPerStrategyMetPerZonePop(Date date,
- Population pop, MatrixND matrixCatchPerStrategyMetPerZonePop) throws TopiaException, IsisFishException {
+ Population pop, MatrixND matrixCatchPerStrategyMetPerZonePop)
+ throws TopiaException, IsisFishException {
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = matrixCatchPerStrategyMetPerZonePop.copy();
@@ -337,33 +355,33 @@
return result;
}
-
/**
* Utilise pour le calcul en Zone
- *
- * Matrice des captures en nombre
- * dim [ Strategy x Metier x Classe x zonePop ]
- *
- * @param N l'abondance sous forme de matrice 2D [class x zone]
+ *
+ * Matrice des captures en nombre dim [ Strategy x Metier x Classe x zonePop ]
+ *
+ * @param N
+ * l'abondance sous forme de matrice 2D [class x zone]
* @param pop
* @param date
* @return
* @throws TopiaException
* @throws IsisFishException
*/
- public MatrixND matrixCatchPerStrategyMetPerZone(MatrixND N, Population pop,
- Date date, MatrixND matrixCatchRatePerStrategyMet) throws TopiaException, IsisFishException {
+ public MatrixND matrixCatchPerStrategyMetPerZone(MatrixND N,
+ Population pop, Date date, 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, date);
+ // MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, date);
MatrixND result = matrixCatchRatePerStrategyMet.copy();
result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET);
- for(PopulationGroup group : groups) {
+ for (PopulationGroup group : groups) {
MatrixND sub = result.getSubMatrix(2, group, 1);
- for(Zone zone : zones){
+ for (Zone zone : zones) {
MatrixND subsub = sub.getSubMatrix(3, zone, 1);
double val = N.getValue(group, zone);
subsub.mults(val);
@@ -373,17 +391,18 @@
}
/**
- * Utilise pour le calcul en Zone
- * Matrice des captures en poids
- * dim [ Strategy x Metier x Classe x zonePop ]
- *
+ * Utilise pour le calcul en Zone Matrice des captures en poids dim [
+ * Strategy x Metier x Classe x zonePop ]
+ *
* @param pop
* @param date
* @return
* @throws TopiaException
* @throws IsisFishException
*/
- public MatrixND matrixCatchRatePerStrategyMetPerZone(Population pop, Date date, MatrixND matrixFishingMortality) throws TopiaException, IsisFishException {
+ public MatrixND matrixCatchRatePerStrategyMetPerZone(Population pop,
+ Date date, MatrixND matrixFishingMortality) throws TopiaException,
+ IsisFishException {
List<Strategy> strategies = getStrategies(date);
List<Metier> metiers = getMetiers(date);
List<PopulationGroup> groups = pop.getPopulationGroup();
@@ -391,52 +410,53 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_CATCH_RATE_PER_STRATEGY_MET,
- new List[]{strategies, metiers, groups, zones},
- new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")});
+ new List[] { strategies, metiers, groups, zones },
+ new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
+ n_("Zones") });
- // Optimisation Hilaire
- for (int s=0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = getMetiers(str, date);
- 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);
- double effort = effortPerZonePop(str,metier,date,zone);
- if (effort > 0){
- for (int g=0; g < groups.size(); g++) {
- PopulationGroup group = groups.get(g);
- double value = catchRatePerStrategyMet(str, metier, date, group, zone, matrixFishingMortality);
- result.setValue(str, metier, group, zone, value);
- }
+ // Optimisation Hilaire
+ for (int s = 0; s < strategies.size(); s++) {
+ Strategy str = strategies.get(s);
+ metiers = getMetiers(str, date);
+ 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);
+ double effort = effortPerZonePop(str, metier, date, zone);
+ if (effort > 0) {
+ for (int g = 0; g < groups.size(); g++) {
+ PopulationGroup group = groups.get(g);
+ double value = catchRatePerStrategyMet(str, metier,
+ date, group, zone, matrixFishingMortality);
+ result.setValue(str, metier, group, zone, value);
}
}
}
}
+ }
return result;
}
- /**
+ /**
* @param str
* @param metier
* @param date
* @param zone
* @return
*/
- private double effortPerZonePop(Strategy str, Metier metier, Date date, Zone zonePop) {
+ private double effortPerZonePop(Strategy str, Metier metier, Date date,
+ Zone zonePop) {
Month month = date.getMonth();
Collection<Zone> zoneMet = metier.getMetierSeasonInfo(month).getZone();
double inter = nbCellInter(zoneMet, zonePop);
- double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier, date);
+ double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier,
+ date);
- if(log.isDebugEnabled()) {
- log.debug(
- " strategy=" + str +
- " metier=" + metier +
- " inter=" + inter +
- " effortPerStrategyPerCell=" + effortPerStrategyPerCell
- );
+ if (log.isDebugEnabled()) {
+ log.debug(" strategy=" + str + " metier=" + metier + " inter="
+ + inter + " effortPerStrategyPerCell="
+ + effortPerStrategyPerCell);
}
double result = effortPerStrategyPerCell * inter;
@@ -444,29 +464,37 @@
}
// Optimisation Hilaire
- private double catchRatePerStrategyMet(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone, MatrixND matrixFishingMortality) throws TopiaException, IsisFishException {
- double totalFishingMortality = totalFishingMortality(date, matrixFishingMortality).getValue(group, zone);
+ private double catchRatePerStrategyMet(Strategy str, Metier metier,
+ Date date, PopulationGroup group, Zone zone,
+ MatrixND matrixFishingMortality) throws TopiaException,
+ IsisFishException {
+ double totalFishingMortality = totalFishingMortality(date,
+ matrixFishingMortality).getValue(group, zone);
- if(totalFishingMortality == 0){
- if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + group + ", " + zone +")");}
+ if (totalFishingMortality == 0) {
+ if (log.isDebugEnabled()) {
+ log.debug("pas de totalFishingMortality pour (" + group + ", "
+ + zone + ")");
+ }
return 0;
}
- double fishingMortality = matrixFishingMortality.getValue(str, metier, group, zone);
- double totalCatchRate = totalCatchRate(date, group, zone, totalFishingMortality);
+ double fishingMortality = matrixFishingMortality.getValue(str, metier,
+ group, zone);
+ double totalCatchRate = totalCatchRate(date, group, zone,
+ totalFishingMortality);
- if(log.isDebugEnabled()) {
- log.debug(
- " totalFishingMortality=" + totalFishingMortality +
- " fishingMortality=" + fishingMortality +
- " totalCatchRate=" + totalCatchRate);
+ if (log.isDebugEnabled()) {
+ log.debug(" totalFishingMortality=" + totalFishingMortality
+ + " fishingMortality=" + fishingMortality
+ + " totalCatchRate=" + totalCatchRate);
}
- double result = fishingMortality / totalFishingMortality * totalCatchRate;
+ double result = fishingMortality / totalFishingMortality
+ * totalCatchRate;
return result;
}
-
/**
* @param date
* @param group
@@ -475,35 +503,37 @@
* @return
* @throws TopiaException
*/
- private double totalCatchRate(Date date, PopulationGroup group,
- Zone zone, double totalFishingMortality) throws TopiaException {
+ private double totalCatchRate(Date date, PopulationGroup group, Zone zone,
+ double totalFishingMortality) throws TopiaException {
double M = group.getNaturalDeathRate(zone) / Month.NUMBER_OF_MONTH;
- if(M == 0){
+ if (M == 0) {
// normalement il devrait y avoir de la mortalite naturelle
if (log.isWarnEnabled()) {
- log.warn("Pas de mortalit� naturelle pour: " + group);
+ log.warn("Pas de mortalite naturelle pour: " + group);
}
}
double F = totalFishingMortality;
double result = 0;
- if( M != 0 || F != 0){
- result = F/(F+M) * (1 - Math.exp(-(F+M)));
+ if (M != 0 || F != 0) {
+ result = F / (F + M) * (1 - Math.exp(-(F + M)));
}
return result;
}
/**
- * Returne une matrice de mortalite group x zone, donc somme sur str et metier
- *
+ * Returne une matrice de mortalite group x zone, donc somme sur str et
+ * metier
+ *
* @param date
* @param matrixFishingMortality
* @param group
* @param zone
* @return
*/
- private MatrixND totalFishingMortality(Date date, MatrixND matrixFishingMortality) {
+ private MatrixND totalFishingMortality(Date date,
+ MatrixND matrixFishingMortality) {
MatrixND result = matrixFishingMortality.sumOverDim(0);
result = result.sumOverDim(1);
result = result.reduceDims(0, 1);
@@ -511,16 +541,16 @@
}
/**
- * Matrice fishing mortality
- * dim [ Strategy x Metier x Classe x zonePop ]
- *
+ * Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop ]
+ *
* @param pop
* @param date
* @return
* @throws TopiaException
* @throws IsisFishException
*/
- public MatrixND matrixFishingMortality(Date date, Population pop) throws TopiaException, IsisFishException {
+ public MatrixND matrixFishingMortality(Date date, Population pop)
+ throws TopiaException, IsisFishException {
List<Strategy> strategies = getStrategies(date);
List<Metier> metiers = getMetiers(date);
List<PopulationGroup> groups = pop.getPopulationGroup();
@@ -529,8 +559,9 @@
// 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")});
+ new List[] { strategies, metiers, groups, zones },
+ new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
+ n_("Zones") });
Month month = date.getMonth();
PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
@@ -545,28 +576,35 @@
for (int m = 0; m < metiers.size(); m++) {
Metier metier = metiers.get(m);
- MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month);
+ 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);
+ Selectivity selectivity = gear
+ .getPopulationSelectivity(pop);
if (selectivity != null) {
// getCoefficient is equation evaluation
- double coeff = selectivity.getCoefficient(pop, group, metier);
+ 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, date, zone);
+ double effort = effortPerZonePop(str,
+ metier, date, zone);
if (effort > 0) { // put value only if <> 0
- double value = coeff * capturability * ciblage * effort;
- result.setValue(str, metier, group, zone, value);
+ double value = coeff
+ * capturability * ciblage
+ * effort;
+ result.setValue(str, metier, group,
+ zone, value);
}
}
}
@@ -580,31 +618,33 @@
}
/**
- * Matrice des captures en nombre
- * dim [ Strategy x Metier x Classe x zonePop ]
+ * Matrice des captures en nombre dim [ Strategy x Metier x Classe x zonePop ]
*
- * @param N l'abondance sous forme de matrice 2D [class x zone]
+ * @param N
+ * l'abondance sous forme de matrice 2D [class x zone]
* @param pop
* @param date
* @return
- * @throws TopiaException
- * @throws IsisFishException
+ * @throws TopiaException
+ * @throws IsisFishException
*/
- private MatrixND matrixCatchPerStrategyMetPerCell(MatrixND N, Population pop,
- Date date, MatrixND matrixCatchRatePerStrategyMetPerCell) throws TopiaException, IsisFishException {
+ private MatrixND matrixCatchPerStrategyMetPerCell(MatrixND N,
+ Population pop, Date date,
+ MatrixND matrixCatchRatePerStrategyMetPerCell)
+ 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, date);
+ // MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, date);
MatrixND result = matrixCatchRatePerStrategyMetPerCell.copy();
result.setName("matrixCatchPerStrategyMetPerCell");
- for(PopulationGroup group : groups) {
+ for (PopulationGroup group : groups) {
MatrixND sub = result.getSubMatrix(2, group, 1);
- for(Zone zone : zones){
+ for (Zone zone : zones) {
MatrixND subsub = sub.getSubMatrix(3, zone, 1);
- double val = N.getValue(group, zone) / (double)zone.sizeCell();
+ double val = N.getValue(group, zone) / (double) zone.sizeCell();
subsub.mults(val);
}
}
@@ -612,16 +652,17 @@
}
/**
- * Matrice des captures en poids
- * dim [ Strategy x Metier x Classe x zonePop ]
+ * Matrice des captures en poids dim [ Strategy x Metier x Classe x zonePop ]
*
* @param pop
* @param date
* @return
- * @throws TopiaException
- * @throws IsisFishException
+ * @throws TopiaException
+ * @throws IsisFishException
*/
- private MatrixND matrixCatchRatePerStrategyMetPerCell(Population pop, Date date, MatrixND matrixFishingMortalityPerCell) throws TopiaException, IsisFishException {
+ private MatrixND matrixCatchRatePerStrategyMetPerCell(Population pop,
+ Date date, MatrixND matrixFishingMortalityPerCell)
+ throws TopiaException, IsisFishException {
List<Strategy> strategies = getStrategies(date);
List<Metier> metiers = getMetiers(date);
List<PopulationGroup> groups = pop.getPopulationGroup();
@@ -630,33 +671,36 @@
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")});
-
-// for (int s=0; s < strategies.size(); s++) {
-// Strategy str = strategies.get(s);
-// metiers = getMetiers(str, date);
-// for (int m=0; m < metiers.size(); m++) {
-// Metier metier = metiers.get(m);
-// for (int g=0; g < groups.size(); g++) {
-// PopulationGroup group = groups.get(g);
-// for (int z=0; z < zones.size(); z++) {
-// Zone zone = zones.get(z);
-// double value = catchRatePerStrategyMet(str, metier, date, group, zone);
-// result.setValue(str, metier, group, zone, value);
-// }
-// }
-// }
-// }
-
-// if(totalFishingMortality == 0){
-// if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + pop + ")");}
-// } else {
- // Optimisation Hilaire
-
- MatrixND matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCell.sumOverDim(2);
- matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCellSumOverGroup.reduceDims(2);
-
+ new List[] { strategies, metiers, groups, zones, cells },
+ new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
+ n_("Zones"), n_("Cells") });
+
+ // for (int s=0; s < strategies.size(); s++) {
+ // Strategy str = strategies.get(s);
+ // metiers = getMetiers(str, date);
+ // for (int m=0; m < metiers.size(); m++) {
+ // Metier metier = metiers.get(m);
+ // for (int g=0; g < groups.size(); g++) {
+ // PopulationGroup group = groups.get(g);
+ // for (int z=0; z < zones.size(); z++) {
+ // Zone zone = zones.get(z);
+ // double value = catchRatePerStrategyMet(str, metier, date, group, zone);
+ // result.setValue(str, metier, group, zone, value);
+ // }
+ // }
+ // }
+ // }
+
+ // if(totalFishingMortality == 0){
+ // if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + pop + ")");}
+ // } else {
+ // 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, date);
@@ -667,35 +711,35 @@
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);
+ 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, date, group, zone, cell,
matrixFishingMortalityPerCell);
- result.setValue(new Object[]{str, metier, group,
- zone, cell}, value);
+ result.setValue(new Object[] { str, metier,
+ group, zone, cell }, value);
}
}
}
}
}
}
-// }
+ // }
-// for (Strategy str : strategies) {
-// List<Metier> metierStr = getMetiers(str, date);
-// for (Metier metier : metierStr) {
-// for (PopulationGroup group : groups) {
-// for (Zone zone : zones) {
-// double val = catchRatePerStrategyMet(str, metier, date, group, zone);
-// result.setValue(str, metier, group, zone, val);
-// }
-// }
-// }
-// }
+ // for (Strategy str : strategies) {
+ // List<Metier> metierStr = getMetiers(str, date);
+ // for (Metier metier : metierStr) {
+ // for (PopulationGroup group : groups) {
+ // for (Zone zone : zones) {
+ // double val = catchRatePerStrategyMet(str, metier, date, group, zone);
+ // result.setValue(str, metier, group, zone, val);
+ // }
+ // }
+ // }
+ // }
return result;
}
@@ -706,91 +750,94 @@
* @param group
* @param zone
* @return
- * @throws TopiaException
- * @throws IsisFishException
+ * @throws TopiaException
+ * @throws IsisFishException
*/
-// private double catchRatePerStrategyMet(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException {
-// double totalFishingMortality = totalFishingMortality(date, group, zone);
-//
-// if(totalFishingMortality == 0){
-// if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + group + ", " + zone +")");}
-// return 0;
-// }
-//
-// double fishingMortality = fishingMortality(str, metier, date, group, zone);
-// double totalCatchRate = totalCatchRate(date, group, zone, totalFishingMortality);
-//
-// if(log.isDebugEnabled()) {
-// log.debug(
-// " totalFishingMortality=" + totalFishingMortality +
-// " fishingMortality=" + fishingMortality +
-// " totalCatchRate=" + totalCatchRate);
-// }
-// double result = fishingMortality / totalFishingMortality * totalCatchRate;
-//
-// return result;
-// }
-
+ // private double catchRatePerStrategyMet(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException {
+ // double totalFishingMortality = totalFishingMortality(date, group, zone);
+ //
+ // if(totalFishingMortality == 0){
+ // if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + group + ", " + zone +")");}
+ // return 0;
+ // }
+ //
+ // double fishingMortality = fishingMortality(str, metier, date, group, zone);
+ // double totalCatchRate = totalCatchRate(date, group, zone, totalFishingMortality);
+ //
+ // if(log.isDebugEnabled()) {
+ // log.debug(
+ // " totalFishingMortality=" + totalFishingMortality +
+ // " fishingMortality=" + fishingMortality +
+ // " totalCatchRate=" + totalCatchRate);
+ // }
+ // double result = fishingMortality / totalFishingMortality * totalCatchRate;
+ //
+ // return result;
+ // }
// Optimisation Hilaire
private double catchRatePerStrategyMetPerCell(Strategy str, Metier metier,
Date date, PopulationGroup group, Zone zone, Cell cell,
- MatrixND matrixFishingMortalityPerCell) throws TopiaException, IsisFishException {
+ MatrixND matrixFishingMortalityPerCell) throws TopiaException,
+ IsisFishException {
double totalFishingMortality = totalFishingMortalityPerCell(date,
matrixFishingMortalityPerCell).getValue(group, zone);
- if(totalFishingMortality == 0){
- if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + group + ", " + zone +")");}
+ 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(date, group, zone, totalFishingMortality);
+ double fishingMortalityPerCell = matrixFishingMortalityPerCell
+ .getValue(new Object[] { str, metier, group, zone, cell });
+ double totalCatchRatePerCell = totalCatchRatePerCell(date, group, zone,
+ totalFishingMortality);
- if(log.isDebugEnabled()) {
- log.debug(
- " totalFishingMortality=" + totalFishingMortality +
- " fishingMortality=" + fishingMortalityPerCell +
- " totalCatchRate=" + totalCatchRatePerCell);
+ if (log.isDebugEnabled()) {
+ log.debug(" totalFishingMortality=" + totalFishingMortality
+ + " fishingMortality=" + fishingMortalityPerCell
+ + " totalCatchRate=" + totalCatchRatePerCell);
}
- double result =
- fishingMortalityPerCell / totalFishingMortality * totalCatchRatePerCell;
+ double result = fishingMortalityPerCell / totalFishingMortality
+ * totalCatchRatePerCell;
return result;
}
-
/**
* @param date
* @param group
* @param zone
* @param totalFishingMortality
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
private double totalCatchRatePerCell(Date date, PopulationGroup group,
- Zone zone, double totalFishingMortalityPerCell) throws TopiaException {
+ Zone zone, double totalFishingMortalityPerCell)
+ throws TopiaException {
double M = group.getNaturalDeathRate(zone) / Month.NUMBER_OF_MONTH;
- if(M == 0){
+ if (M == 0) {
// normalement il devrait y avoir de la mortalite naturelle
if (log.isWarnEnabled()) {
- log.warn("Pas de mortalit� naturelle pour: " + group);
+ log.warn("Pas de mortalite naturelle pour: " + group);
}
}
double F = totalFishingMortalityPerCell;
double result = 0;
- if( M != 0 || F != 0){
- result = F/(F+M) * (1 - Math.exp(-(F+M)));
+ if (M != 0 || F != 0) {
+ result = F / (F + M) * (1 - Math.exp(-(F + M)));
}
return result;
}
/**
- * Returne une matrice de mortalite group x zone, donc somme sur str et metier
+ * Returne une matrice de mortalite group x zone, donc somme sur str et
+ * metier
*
* @param date
* @param matrixFishingMortality
@@ -798,26 +845,27 @@
* @param zone
* @return
*/
- private MatrixND totalFishingMortalityPerCell(Date date, MatrixND matrixFishingMortalityPerCell) {
+ private MatrixND totalFishingMortalityPerCell(Date date,
+ MatrixND matrixFishingMortalityPerCell) {
MatrixND result = matrixFishingMortalityPerCell.sumOverDim(0);
result = result.sumOverDim(1);
result = result.reduceDims(0, 1);
return result;
}
-
// Nouvelle implantation suite a demande Steph et Sigrid: 20080208 (NouvellesEquationsfev2008ParCelluleAvecAlgo.odt)
/**
- * Matrice fishing mortality
- * dim [ Strategy x Metier x Classe x zonePop x cellPop]
+ * Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop x
+ * cellPop]
*
* @param pop
* @param date
* @return
- * @throws TopiaException
- * @throws IsisFishException
+ * @throws TopiaException
+ * @throws IsisFishException
*/
- public MatrixND matrixFishingMortalityPerCell(Date date, Population pop) throws TopiaException, IsisFishException {
+ public MatrixND matrixFishingMortalityPerCell(Date date, Population pop)
+ throws TopiaException, IsisFishException {
List<Strategy> strategies = getStrategies(date);
List<Metier> metiers = getMetiers(date);
List<PopulationGroup> groups = pop.getPopulationGroup();
@@ -827,8 +875,9 @@
// 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 List[] { strategies, metiers, groups, zones, cells },
+ new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
+ n_("Zones"), n_("Cells") });
Month month = date.getMonth();
PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
@@ -843,32 +892,46 @@
for (int m = 0; m < metiers.size(); m++) {
Metier metier = metiers.get(m);
- MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month);
+ 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);
+ Selectivity selectivity = gear
+ .getPopulationSelectivity(pop);
if (selectivity != null) {
// getCoefficient is equation evaluation
- double coeff = selectivity.getCoefficient(pop, group, metier);
+ 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, date);
+ double effort = effortPerStrategyPerCell(
+ str, metier, date);
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()) {
+ 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);
+ double value = coeff
+ * capturability
+ * ciblage * effort;
+ result.setValue(
+ new Object[] { str,
+ metier,
+ group,
+ zone,
+ cellMet },
+ value);
}
}
}
@@ -884,244 +947,243 @@
}
// Supprimee suite a demande Steph et Sigrid: 20080208 (NouvellesEquationsfev2008ParCelluleAvecAlgo.odt)
-// /**
-// * Matrice fishing mortality
-// * dim [ Strategy x Metier x Classe x zonePop ]
-// *
-// * @param pop
-// * @param date
-// * @return
-// * @throws TopiaException
-// * @throws IsisFishException
-// */
-// public MatrixND matrixFishingMortalityPerCell(Date date, Population pop) throws TopiaException, IsisFishException {
-// List<Strategy> strategies = getStrategies(date);
-// List<Metier> metiers = getMetiers(date);
-// 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 = date.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,date,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 date
+ // * @return
+ // * @throws TopiaException
+ // * @throws IsisFishException
+ // */
+ // public MatrixND matrixFishingMortalityPerCell(Date date, Population pop) throws TopiaException, IsisFishException {
+ // List<Strategy> strategies = getStrategies(date);
+ // List<Metier> metiers = getMetiers(date);
+ // 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 = date.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,date,zone);
+ // if (effort > 0){ // put value only if <> 0
+ // double value = coeff * capturability * ciblage * effort;
+ // result.setValue(str, metier, group, zone, value);
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ // return result;
+ // }
- // ne prendre que les metiers pratiqu� semble une bonne idee, mais en fait non, car cela oblige l'ordre des boucles
- // et donc ne permet pas autant d'optimisation que souhait�
-// public MatrixND matrixFishingMortality2(Date date, Population pop) throws TopiaException, IsisFishException {
-// List<Strategy> strategies = getStrategies(date);
-// List<Metier> metiers = getMetiers(date);
-// List<PopulationGroup> groups = pop.getPopulationGroup();
-// List<Zone> zones = pop.getPopulationZone();
+ // ne prendre que les metiers pratiques semble une bonne idee, mais en fait non, car cela oblige l'ordre des boucles
+ // et donc ne permet pas autant d'optimisation que souhaite
+ // public MatrixND matrixFishingMortality2(Date date, Population pop) throws TopiaException, IsisFishException {
+ // List<Strategy> strategies = getStrategies(date);
+ // List<Metier> metiers = getMetiers(date);
+ // 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")});
+ // // 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 = date.getMonth();
-// PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
+ // Month month = date.getMonth();
+ // PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
-// for (int s=0; s < strategies.size(); s++) {
-// Strategy str = strategies.get(s);
-// metiers = getMetiers(str, date);
-// for (int m=0; m < metiers.size(); m++) {
-// Metier metier = metiers.get(m);
-// Gear gear = metier.getGear();
-// Selectivity selectivity = gear.getPopulationSelectivity(pop);
-// if (selectivity != null) {
-// MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month);
-// for (int z=0; z < zones.size(); z++) {
-// Zone zone = zones.get(z);
-// double effort = effortPerZonePop(str,metier,date,zone);
-// if (effort > 0){ // put value only if <> 0
-// for (int g=0; g < groups.size(); g++) {
-// PopulationGroup group = groups.get(g);
-
-// // getTargetFactor seem to be simple
-// double ciblage = infoMet.getTargetFactor(group);
-// if (ciblage != 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
-// // getCoefficient is equation evaluation
-// double coeff = selectivity.getCoefficient(pop, group, metier);
-// if (coeff != 0) { // check 0, this prevent next call, for default value
-// double value = coeff * capturability * ciblage * effort;
-// result.setValue(str, metier, group, zone, value);
-// }
-// }
-// }
-// }
-// }
-// }
-// }
-// }
-// }
-// return result;
-// }
+ // for (int s=0; s < strategies.size(); s++) {
+ // Strategy str = strategies.get(s);
+ // metiers = getMetiers(str, date);
+ // for (int m=0; m < metiers.size(); m++) {
+ // Metier metier = metiers.get(m);
+ // Gear gear = metier.getGear();
+ // Selectivity selectivity = gear.getPopulationSelectivity(pop);
+ // if (selectivity != null) {
+ // MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month);
+ // for (int z=0; z < zones.size(); z++) {
+ // Zone zone = zones.get(z);
+ // double effort = effortPerZonePop(str,metier,date,zone);
+ // if (effort > 0){ // put value only if <> 0
+ // for (int g=0; g < groups.size(); g++) {
+ // PopulationGroup group = groups.get(g);
-// /**
-// * @param date
-// * @param group
-// * @param zone
-// * @return
-// * @throws TopiaException
-// * @throws IsisFishException
-// */
-// private double totalFishingMortality(Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException {
-// List<Strategy> strategies = getStrategies(date);
-//
-// float result = 0;
-//
-//// for(Strategy str : strategies){
-//// List<Metier> metierStr = getMetiers(str, date);
-//// for (Metier metier : metierStr) {
-//// // TODO peut etre ne pas le faire si classe.pop n'est pas
-//// /// peche par le metier
-//// result += fishingMortality(str, metier, date, group, zone);
-//// }
-//// }
-//
-// // Optimisation Hilaire
-// for(Strategy str : strategies){
-// List<Metier> metierStr = getMetiers(str, date);
-// for (Metier metier : metierStr) {
-// double effort=effortPerZonePop(str,metier,date,zone);
-// if (effort>0)
-// result += fishingMortality(str, metier, date, group, zone, effort);
-// }
-// }
-//
-// return result;
-// }
+ // // getTargetFactor seem to be simple
+ // double ciblage = infoMet.getTargetFactor(group);
+ // if (ciblage != 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
+ // // getCoefficient is equation evaluation
+ // double coeff = selectivity.getCoefficient(pop, group, metier);
+ // if (coeff != 0) { // check 0, this prevent next call, for default value
+ // double value = coeff * capturability * ciblage * effort;
+ // result.setValue(str, metier, group, zone, value);
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ // return result;
+ // }
+ // /**
+ // * @param date
+ // * @param group
+ // * @param zone
+ // * @return
+ // * @throws TopiaException
+ // * @throws IsisFishException
+ // */
+ // private double totalFishingMortality(Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException {
+ // List<Strategy> strategies = getStrategies(date);
+ //
+ // float result = 0;
+ //
+ //// for(Strategy str : strategies){
+ //// List<Metier> metierStr = getMetiers(str, date);
+ //// for (Metier metier : metierStr) {
+ //// // TODO peut etre ne pas le faire si classe.pop n'est pas
+ //// /// peche par le metier
+ //// result += fishingMortality(str, metier, date, group, zone);
+ //// }
+ //// }
+ //
+ // // Optimisation Hilaire
+ // for(Strategy str : strategies){
+ // List<Metier> metierStr = getMetiers(str, date);
+ // for (Metier metier : metierStr) {
+ // double effort=effortPerZonePop(str,metier,date,zone);
+ // if (effort>0)
+ // result += fishingMortality(str, metier, date, group, zone, effort);
+ // }
+ // }
+ //
+ // return result;
+ // }
// fusion fishingMortality and matrixFishingMortality for performance reason
-// /**
-// * @param str
-// * @param metier
-// * @param date
-// * @param group
-// * @param zone
-// * @return
-// * @throws IsisFishException
-// */
-// private double fishingMortality(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone, double effort) throws IsisFishException {
-// Month month = date.getMonth();
-// Population pop = group.getPopulation();
-// Gear gear = metier.getGear();
-//
-// Selectivity selectivity = gear.getPopulationSelectivity(pop);
-//
-// double result = 0;
-//
-// if (selectivity != null) {
-// MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month);
-// double ciblage = infoMet.getTargetFactor(group);
-//
-// PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
-// double capturability = infoPop.getCapturability(group);
-//
-// double coeff = selectivity.getCoefficient(pop, group, metier);
-//
-// // Optimisation Hilaire
-//// double effort = effortPerZonePop(str, metier, date, zone);
-//
-// // la methode est appeler des millions de fois, donc meme si
-// // on ne perd pas beaucoup de temps avec le if, on en perd deja
-// // trop
-//// if(log.isDebugEnabled()) {
-//// log.debug(
-//// " strategy=" + str +
-//// " metier=" + metier +
-//// " ciblage=" + ciblage +
-//// " capturabilite=" + capturability +
-//// " selectivity=" + coeff +
-//// " effort=" + effort);
-//// }
-//
-// result = coeff * capturability * ciblage * effort;
-// }
-//
-// return result;
-// }
+ // /**
+ // * @param str
+ // * @param metier
+ // * @param date
+ // * @param group
+ // * @param zone
+ // * @return
+ // * @throws IsisFishException
+ // */
+ // private double fishingMortality(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone, double effort) throws IsisFishException {
+ // Month month = date.getMonth();
+ // Population pop = group.getPopulation();
+ // Gear gear = metier.getGear();
+ //
+ // Selectivity selectivity = gear.getPopulationSelectivity(pop);
+ //
+ // double result = 0;
+ //
+ // if (selectivity != null) {
+ // MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month);
+ // double ciblage = infoMet.getTargetFactor(group);
+ //
+ // PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
+ // double capturability = infoPop.getCapturability(group);
+ //
+ // double coeff = selectivity.getCoefficient(pop, group, metier);
+ //
+ // // Optimisation Hilaire
+ //// double effort = effortPerZonePop(str, metier, date, zone);
+ //
+ // // la methode est appeler des millions de fois, donc meme si
+ // // on ne perd pas beaucoup de temps avec le if, on en perd deja
+ // // trop
+ //// if(log.isDebugEnabled()) {
+ //// log.debug(
+ //// " strategy=" + str +
+ //// " metier=" + metier +
+ //// " ciblage=" + ciblage +
+ //// " capturabilite=" + capturability +
+ //// " selectivity=" + coeff +
+ //// " effort=" + effort);
+ //// }
+ //
+ // result = coeff * capturability * ciblage * effort;
+ // }
+ //
+ // return result;
+ // }
// Supprimee suite a demande Steph et Sigrid: 20080208 (NouvellesEquationsfev2008ParCelluleAvecAlgo.odt)
-// /**
-// * @param str
-// * @param metier
-// * @param date
-// * @param zone
-// * @return
-// */
-// private double effortPerZonePop(Strategy str, Metier metier, Date date, Zone zonePop) {
-// Month month = date.getMonth();
-// Collection<Zone> zoneMet = metier.getMetierSeasonInfo(month).getZone();
-// double inter = nbCellInter(zoneMet, zonePop);
-//
-// double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier, date);
-//
-// if(log.isDebugEnabled()) {
-// log.debug(
-// " strategy=" + str +
-// " metier=" + metier +
-// " inter=" + inter +
-// " effortPerStrategyPerCell=" + effortPerStrategyPerCell
-// );
-// }
-//
-// double result = effortPerStrategyPerCell * inter;
-// return result;
-// }
+ // /**
+ // * @param str
+ // * @param metier
+ // * @param date
+ // * @param zone
+ // * @return
+ // */
+ // private double effortPerZonePop(Strategy str, Metier metier, Date date, Zone zonePop) {
+ // Month month = date.getMonth();
+ // Collection<Zone> zoneMet = metier.getMetierSeasonInfo(month).getZone();
+ // double inter = nbCellInter(zoneMet, zonePop);
+ //
+ // double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier, date);
+ //
+ // if(log.isDebugEnabled()) {
+ // log.debug(
+ // " strategy=" + str +
+ // " metier=" + metier +
+ // " inter=" + inter +
+ // " effortPerStrategyPerCell=" + effortPerStrategyPerCell
+ // );
+ // }
+ //
+ // double result = effortPerStrategyPerCell * inter;
+ // return result;
+ // }
/**
* @param str
@@ -1129,32 +1191,31 @@
* @param date
* @return
*/
- private double effortPerStrategyPerCell(Strategy str, Metier metier, Date date) {
+ private double effortPerStrategyPerCell(Strategy str, Metier metier,
+ Date date) {
Month month = date.getMonth();
StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
Collection<Zone> zones = metier.getMetierSeasonInfo(month).getZone();
double nbCell = getCells(zones).size();
- if(nbCell == 0){
+ 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()) log.warn("Calcul d'une distance pour le metier "+metier+" pour le mois "+month+" avec une zone sans maille: " + zones);
+ if (log.isWarnEnabled())
+ log.warn("Calcul d'une distance pour le metier " + metier
+ + " pour le mois " + month
+ + " avec une zone sans maille: " + zones);
return 0;
}
+ double effortPerStrategy = effortPerStrategyMet(str, metier, date);
- double effortPerStrategy = effortPerStrategyMet(str, metier, date);
-
- if(log.isDebugEnabled()) {
- log.debug(
- " strategy=" + str +
- " metier=" + metier +
- " nbCell=" + nbCell +
- " effortPerStrategy=" + effortPerStrategy
- );
+ if (log.isDebugEnabled()) {
+ log.debug(" strategy=" + str + " metier=" + metier + " nbCell="
+ + nbCell + " effortPerStrategy=" + effortPerStrategy);
}
- double result = effortPerStrategy/nbCell;
+ double result = effortPerStrategy / nbCell;
return result;
}
@@ -1174,18 +1235,15 @@
double propStrMet = smi.getProportionMetier(metier);
double effortPerVessel = effortPerStrategyPerVessel(str, metier, date);
- if(log.isDebugEnabled()) {
- log.debug(
- " strategy=" + str +
- " metier=" + metier +
- " propSetOfVessels=" + propSetOfVessels +
- " nbOfVessels=" + nbOfVessels +
- " propStrMet=" + propStrMet +
- " effortPerVessel=" + effortPerVessel
- );
+ if (log.isDebugEnabled()) {
+ log.debug(" strategy=" + str + " metier=" + metier
+ + " propSetOfVessels=" + propSetOfVessels + " nbOfVessels="
+ + nbOfVessels + " propStrMet=" + propStrMet
+ + " effortPerVessel=" + effortPerVessel);
}
- double result = propSetOfVessels * nbOfVessels * propStrMet * effortPerVessel;
+ double result = propSetOfVessels * nbOfVessels * propStrMet
+ * effortPerVessel;
return result;
}
@@ -1196,23 +1254,21 @@
* @param date
* @return
*/
- private double effortPerStrategyPerVessel(Strategy str, Metier metier, Date date) {
+ private double effortPerStrategyPerVessel(Strategy str, Metier metier,
+ Date date) {
Month month = date.getMonth();
StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
double nbTrips = smi.getNumberOfTrips();
double fishingTime = fishingTimePerTrip(str, metier, date);
- double stdEffortPerHour = stdEffortPerHour(date, str.getSetOfVessels(), metier);
+ double stdEffortPerHour = stdEffortPerHour(date, str.getSetOfVessels(),
+ metier);
- if(log.isDebugEnabled()) {
- log.debug(
- " strategy=" + str +
- " metier=" + metier +
- " nbTrips=" + nbTrips +
- " fishingTime=" + fishingTime +
- " stdEffortPerHour=" + stdEffortPerHour
- );
+ if (log.isDebugEnabled()) {
+ log.debug(" strategy=" + str + " metier=" + metier + " nbTrips="
+ + nbTrips + " fishingTime=" + fishingTime
+ + " stdEffortPerHour=" + stdEffortPerHour);
}
-
+
double result = nbTrips * fishingTime * stdEffortPerHour;
return result;
@@ -1232,38 +1288,36 @@
Collection<Zone> zone = metier.getMetierSeasonInfo(month).getZone();
if (zone == null) {
- if(log.isWarnEnabled()) log.warn(
- "missing zone for metier =" + metier +
- " for month" + month
- );
+ if (log.isWarnEnabled())
+ log.warn("missing zone for metier =" + metier + " for month"
+ + month);
}
- double tripDuration = smi.getTripType().getTripDuration().getHour();
+ double tripDuration = smi.getTripType().getTripDuration().getHour();
double travelTime = travelTimePerTrip(str.getSetOfVessels(), zone);
double result = tripDuration - travelTime;
- if (result < 0 ) {
- if(log.isWarnEnabled()) log.warn(
- " strategy=" + str +
- " metier=" + metier +
- " tripDuration=" + tripDuration +
- " travelTime=" + travelTime
- );
+ if (result < 0) {
+ if (log.isWarnEnabled())
+ log.warn(" strategy=" + str + " metier=" + metier
+ + " tripDuration=" + tripDuration + " travelTime="
+ + travelTime);
}
return result;
}
/**
- *
+ *
* @param setOfVessels
* @param zone
* @return
*/
- protected double travelTimePerTrip(SetOfVessels sov, Collection<Zone> zoneMetier) {
+ protected double travelTimePerTrip(SetOfVessels sov,
+ Collection<Zone> zoneMetier) {
Cell maille = sov.getPort().getCell();
- double result =
- 2 * distance(zoneMetier, maille) / sov.getVesselType().getSpeed();
+ double result = 2 * distance(zoneMetier, maille)
+ / sov.getVesselType().getSpeed();
return result;
}
@@ -1277,24 +1331,24 @@
double result = 0;
List<Cell> cells = getCells(zones);
- if(cells.size() == 0){
+ if (cells.size() == 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()) {
log.warn("Calcul d'une distance avec une zone sans maille");
}
return 0;
}
- for(Cell c : cells){
+ for (Cell c : cells) {
result += distance(c, cell);
}
- if(log.isDebugEnabled()) {
- log.debug(" result=" + result + " nbMaille="+cells.size());
+ if (log.isDebugEnabled()) {
+ log.debug(" result=" + result + " nbMaille=" + cells.size());
}
-
- result = result / (double)cells.size();
+
+ result = result / (double) cells.size();
return result;
}
@@ -1305,61 +1359,54 @@
*/
private double distance(Cell m1, Cell m2) {
double earthRadius = 6378.388;
- double p = 180/Math.PI;
+ double p = 180 / Math.PI;
- if(log.isDebugEnabled()) log.debug("p: " + p);
+ if (log.isDebugEnabled())
+ log.debug("p: " + p);
double m1lat = m1.getLatitude();
double m2lat = m2.getLatitude();
double m1lon = m1.getLongitude();
double m2lon = m2.getLongitude();
- if(log.isDebugEnabled()) log.debug(
- " m1lat=" + m1lat +
- " m2lat=" + m2lat +
- " m1lon=" + m1lon +
- " m2lonx=" + m2lon
- );
+ if (log.isDebugEnabled())
+ log.debug(" m1lat=" + m1lat + " m2lat=" + m2lat + " m1lon=" + m1lon
+ + " m2lonx=" + m2lon);
- double m1lat_div_p = m1lat/p;
- double m2lat_div_p = m2lat/p;
- double m1lon_div_p = m1lon/p;
- double m2lon_div_p = m2lon/p;
+ double m1lat_div_p = m1lat / p;
+ double m2lat_div_p = m2lat / p;
+ double m1lon_div_p = m1lon / p;
+ double m2lon_div_p = m2lon / p;
- if(log.isDebugEnabled()) log.debug(
- " m1lat_div_p=" + m1lat_div_p +
- " m2lat_div_p=" + m2lat_div_p +
- " m1lon_div_p=" + m1lon_div_p +
- " m2lon_div_p=" + m2lon_div_p
- );
+ if (log.isDebugEnabled())
+ log.debug(" m1lat_div_p=" + m1lat_div_p + " m2lat_div_p="
+ + m2lat_div_p + " m1lon_div_p=" + m1lon_div_p
+ + " m2lon_div_p=" + m2lon_div_p);
double sin_m1lat_div_p = Math.sin(m1lat_div_p);
double sin_m2lat_div_p = Math.sin(m2lat_div_p);
double cos_m1lat_div_p = Math.cos(m1lat_div_p);
double cos_m2lat_div_p = Math.cos(m2lat_div_p);
- if(log.isDebugEnabled()) log.debug(
- " sin_m1lat_div_p=" + sin_m1lat_div_p +
- " sin_m2lat_div_p=" + sin_m2lat_div_p +
- " cos_m1lat_div_p=" + cos_m1lat_div_p +
- " cos_m2lat_div_p=" + cos_m2lat_div_p
- );
+ if (log.isDebugEnabled())
+ log.debug(" sin_m1lat_div_p=" + sin_m1lat_div_p
+ + " sin_m2lat_div_p=" + sin_m2lat_div_p
+ + " cos_m1lat_div_p=" + cos_m1lat_div_p
+ + " cos_m2lat_div_p=" + cos_m2lat_div_p);
- double cos_m1lon_div_p_minus_m2lon_div_p = Math.cos(m1lon_div_p - m2lon_div_p);
+ double cos_m1lon_div_p_minus_m2lon_div_p = Math.cos(m1lon_div_p
+ - m2lon_div_p);
- if(log.isDebugEnabled()) log.debug(
- " cos_m1lon_div_p_minus_m2lon_div_p=" + cos_m1lon_div_p_minus_m2lon_div_p);
+ if (log.isDebugEnabled())
+ log.debug(" cos_m1lon_div_p_minus_m2lon_div_p="
+ + cos_m1lon_div_p_minus_m2lon_div_p);
- double acos = Math.acos(
- sin_m1lat_div_p
- * sin_m2lat_div_p
- +
- cos_m1lat_div_p
- * cos_m2lat_div_p
- * cos_m1lon_div_p_minus_m2lon_div_p
- );
+ double acos = Math.acos(sin_m1lat_div_p * sin_m2lat_div_p
+ + cos_m1lat_div_p * cos_m2lat_div_p
+ * cos_m1lon_div_p_minus_m2lon_div_p);
- if(log.isDebugEnabled()) log.debug(" acos=" + acos);
+ if (log.isDebugEnabled())
+ log.debug(" acos=" + acos);
double result = earthRadius * acos;
@@ -1374,19 +1421,18 @@
private double stdEffortPerHour(Date date, SetOfVessels sov, Metier metier) {
double result = 0;
EffortDescription ed = sov.getPossibleMetiers(metier);
- if(ed != null){
+ if (ed != null) {
double fstd = metier.getGear().getStandardisationFactor();
double etp = sov.getTechnicalEfficiency(date, metier);
- double val =
- fstd * etp * ed.getFishingOperation() * ed.getGearsNumberPerOperation();
+ double val = fstd * etp * ed.getFishingOperation()
+ * ed.getGearsNumberPerOperation();
result = val;
}
- result = result/24; // 24 heures
+ result = result / 24; // 24 heures
return result;
}
-
/**
* used here and in Rule (CantonnementPreSimu)
*
@@ -1400,7 +1446,7 @@
}
return result;
}
-
+
/**
* used here and in Rule (CantonnementPreSimu)
*
@@ -1414,76 +1460,81 @@
tmp.retainAll(zonePop.getCell());
return tmp.size();
}
-
+
///////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////
-
+
/**
* @param N
* @param pop
* @param date
* @return
- * @throws IsisFishException
- * @throws TopiaException
+ * @throws IsisFishException
+ * @throws TopiaException
*/
private MatrixND matrixAbundancePerCell(MatrixND N, Population pop,
- Date date, MatrixND matrixFishingMortality) throws TopiaException, IsisFishException {
+ Date date, MatrixND matrixFishingMortality) throws TopiaException,
+ IsisFishException {
List<PopulationGroup> groups = pop.getPopulationGroup();
List<Zone> zones = pop.getPopulationZone();
List<Cell> allCells = getCells(zones);
-
+
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_ABUNDANCE + "_PER_CELL",
- new List[]{groups, zones, allCells},
- new String[]{n_("Groups"), n_("Zones"), n_("Cells")});
+ new List[] { groups, zones, allCells },
+ new String[] { n_("Groups"), n_("Zones"), n_("Cells") });
- for (int g=0; g < groups.size(); g++) {
+ for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
- for (int z=0; z < zones.size(); z++) {
+ for (int z = 0; z < zones.size(); z++) {
Zone zone = zones.get(z);
List<Cell> cells = zone.getCell();
- for (int c=0; c<cells.size(); c++) {
+ for (int c = 0; c < cells.size(); c++) {
Cell cell = cells.get(c);
- double value = survivalRatePerCell(date, group, zone,
- cell, matrixFishingMortality);
+ double value = survivalRatePerCell(date, group, zone, cell,
+ matrixFishingMortality);
double n = N.getValue(g, z) / zone.sizeCell();
value *= n;
result.setValue(g, z, c, value);
}
}
}
-
+
return result;
}
-
+
/**
* Utilise pour le calcule en Cell
+ *
* @param N
* @param pop
* @param date
* @return
- * @throws IsisFishException
- * @throws TopiaException
+ * @throws IsisFishException
+ * @throws TopiaException
*/
public MatrixND matrixAbundance(MatrixND N, Population pop, Date date)
throws TopiaException, IsisFishException {
-
- MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell(date, pop);
-
- MatrixND result = matrixAbundancePerCell(N, pop, date, matrixFishingMortalityPerCell);
+
+ MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell(
+ date, pop);
+
+ MatrixND result = matrixAbundancePerCell(N, pop, date,
+ matrixFishingMortalityPerCell);
result = result.sumOverDim(2);
result = result.reduceDims(2);
result.setName(ResultName.MATRIX_ABUNDANCE);
-
- return result;
+
+ return result;
}
/**
* Utilise pour le calcule en Zone
+ *
* @param N
* @param pop
* @param date
@@ -1491,20 +1542,22 @@
* @throws IsisFishException
* @throws TopiaException
*/
- public MatrixND matrixAbundance(MatrixND N, Population pop, Date date, MatrixND matrixFishingMortality) throws TopiaException, IsisFishException {
+ public MatrixND matrixAbundance(MatrixND N, Population pop, Date date,
+ MatrixND matrixFishingMortality) throws TopiaException,
+ IsisFishException {
List<PopulationGroup> groups = pop.getPopulationGroup();
List<Zone> zones = pop.getPopulationZone();
MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_ABUNDANCE,
- new List[]{groups, zones},
- new String[]{n_("Groups"), n_("Zones")});
+ ResultName.MATRIX_ABUNDANCE, new List[] { groups, zones },
+ new String[] { n_("Groups"), n_("Zones") });
- for (int g=0; g < groups.size(); g++) {
+ for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
- for (int z=0; z < zones.size(); z++) {
+ for (int z = 0; z < zones.size(); z++) {
Zone zone = zones.get(z);
- double value = survivalRatePerZone(date, group, zone, matrixFishingMortality);
+ double value = survivalRatePerZone(date, group, zone,
+ matrixFishingMortality);
double n = N.getValue(g, z);
value *= n;
result.setValue(g, z, value);
@@ -1517,6 +1570,7 @@
/**
* Utilise pour la mortalite des poissons, lorsqu'aucune strategie n'est
* selectionnee.
+ *
* @param N
* @param pop
* @param date
@@ -1524,21 +1578,23 @@
* @throws IsisFishException
* @throws TopiaException
*/
- public MatrixND matrixAbundanceSsF(MatrixND N, Population pop, Date date) throws TopiaException, IsisFishException {
+ public MatrixND matrixAbundanceSsF(MatrixND N, Population pop, Date date)
+ throws TopiaException, IsisFishException {
List<PopulationGroup> groups = pop.getPopulationGroup();
List<Zone> zones = pop.getPopulationZone();
MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_ABUNDANCE,
- new List[]{groups, zones},
- new String[]{n_("Groups"), n_("Zones")});
+ ResultName.MATRIX_ABUNDANCE, new List[] { groups, zones },
+ new String[] { n_("Groups"), n_("Zones") });
- for (int g=0; g < groups.size(); g++) {
+ for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
- for (int z=0; z < zones.size(); z++) {
+ for (int z = 0; z < zones.size(); z++) {
Zone zone = zones.get(z);
- double M = group.getNaturalDeathRate(zone)/(double)Month.NUMBER_OF_MONTH;
- double value = (double)Math.exp(-M);;
+ double M = group.getNaturalDeathRate(zone)
+ / (double) Month.NUMBER_OF_MONTH;
+ double value = (double) Math.exp(-M);
+ ;
double n = N.getValue(g, z);
value *= n;
result.setValue(g, z, value);
@@ -1556,31 +1612,36 @@
* @throws IsisFishException
* @throws TopiaException
*/
- private double survivalRatePerZone(Date date, PopulationGroup group, Zone zone, MatrixND matrixFishingMortality) throws TopiaException, IsisFishException {
- double F = totalFishingMortality(date, matrixFishingMortality).getValue(group, zone); //totalFishingMortality(date, group, zone); // rem perf: totalFishingMortality a deja ete calcul�
- double M = group.getNaturalDeathRate(zone)/(double)Month.NUMBER_OF_MONTH;
- double result = Math.exp(-(F+M));
+ private double survivalRatePerZone(Date date, PopulationGroup group,
+ Zone zone, MatrixND matrixFishingMortality) throws TopiaException,
+ IsisFishException {
+ double F = totalFishingMortality(date, matrixFishingMortality)
+ .getValue(group, zone); //totalFishingMortality(date, group, zone); // rem perf: totalFishingMortality a deja ete calcul�
+ double M = group.getNaturalDeathRate(zone)
+ / (double) Month.NUMBER_OF_MONTH;
+ double result = Math.exp(-(F + M));
return result;
}
-
/**
* @param date
* @param group
* @param zone
* @return
- * @throws IsisFishException
- * @throws TopiaException
+ * @throws IsisFishException
+ * @throws TopiaException
*/
- private double survivalRatePerCell(Date date, PopulationGroup group, Zone zone,
- Cell cell, MatrixND matrixFishingMortalityPerCell) throws TopiaException, IsisFishException {
-
- double F = totalFishingMortalityPerCell(date, matrixFishingMortalityPerCell)
- .getValue(group, zone, cell); //totalFishingMortality(date, group, zone); // rem perf: totalFishingMortality a deja ete calcul�
- double M = group.getNaturalDeathRate(zone)/(double)Month.NUMBER_OF_MONTH;
- double result = (double)Math.exp(-(F+M));
+ private double survivalRatePerCell(Date date, PopulationGroup group,
+ Zone zone, Cell cell, MatrixND matrixFishingMortalityPerCell)
+ throws TopiaException, IsisFishException {
+ double F = totalFishingMortalityPerCell(date,
+ matrixFishingMortalityPerCell).getValue(group, zone, cell); //totalFishingMortality(date, group, zone); // rem perf: totalFishingMortality a deja ete calcul�
+ double M = group.getNaturalDeathRate(zone)
+ / (double) Month.NUMBER_OF_MONTH;
+ double result = (double) Math.exp(-(F + M));
+
return result;
}
@@ -1589,7 +1650,7 @@
//
//
///////////////////////////////////////////////////////////////////////////
-
+
/**
* @param n
* @param pop
@@ -1601,32 +1662,31 @@
List<Zone> zones = N.getSemantics(1);
MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_BIOMASS,
- new List[]{groups, zones},
- new String[]{n_("Groups"), n_("Zones")});
+ ResultName.MATRIX_BIOMASS, new List[] { groups, zones },
+ new String[] { n_("Groups"), n_("Zones") });
- for (int g=0; g < groups.size(); g++) {
+ 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++) {
+ 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, Date date) {
+ public MatrixND matrixBiomassBeginMonth(MatrixND N, Population pop,
+ Date date) {
List<PopulationGroup> groups = N.getSemantics(0);
List<Zone> zones = N.getSemantics(1);
MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_BIOMASS,
- new List[]{groups, zones},
- new String[]{n_("Groups"), n_("Zones")});
+ 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);
@@ -1641,14 +1701,14 @@
return result;
}
- public MatrixND matrixAbondanceBeginMonth(MatrixND N, Population pop, Date date) {
+ public MatrixND matrixAbondanceBeginMonth(MatrixND N, Population pop,
+ Date date) {
List<PopulationGroup> groups = N.getSemantics(0);
List<Zone> zones = N.getSemantics(1);
MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_ABUNDANCE,
- new List[]{groups, zones},
- new String[]{n_("Groups"), n_("Zones")});
+ ResultName.MATRIX_ABUNDANCE, new List[] { groups, zones },
+ new String[] { n_("Groups"), n_("Zones") });
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -1661,17 +1721,16 @@
return result;
}
-
///////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////
-
+
/**
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
public MatrixND matrixEffortPerStrategyMet(Date date) throws TopiaException {
List<Strategy> strategies = getStrategies(date);
@@ -1679,26 +1738,26 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_EFFORT_PER_STRATEGY_MET,
- new List[]{strategies, metiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ new List[] { strategies, metiers },
+ new String[] { n_("Strategies"), n_("Metiers") });
- for (int s=0; s < strategies.size(); s++) {
+ for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = getMetiers(str, date);
- for (int m=0; m < metiers.size(); m++) {
+ for (int m = 0; m < metiers.size(); m++) {
Metier metier = metiers.get(m);
double value = effortPerStrategyMet(str, metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// List<Metier> metierStr = getMetiers(str, date);
-// for(Metier metier : metierStr) {
-// double val = effortPerStrategyMet(str, metier, date); // rem perf: effortPerStrategyMet a deja ete calcul�
-// result.setValue(str, metier, val);
-// }
-// }
+ // for(Strategy str : strategies){
+ // List<Metier> metierStr = getMetiers(str, date);
+ // for(Metier metier : metierStr) {
+ // double val = effortPerStrategyMet(str, metier, date); // rem perf: effortPerStrategyMet a deja ete calcule
+ // result.setValue(str, metier, val);
+ // }
+ // }
return result;
}
@@ -1708,28 +1767,28 @@
//
//
///////////////////////////////////////////////////////////////////////////
-
-// /**
-// * @param pop
-// * @param date
-// * @return
-// */
-// public MatrixND matrixCatchWeightPerStrategyMet(Population pop,
-// Date date, MatrixND matrixCatchPerStrategyMet) {
-// List<PopulationGroup> groups = pop.getPopulationGroup();
-//
-// MatrixND result = matrixCatchPerStrategyMet.copy();
-// result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET);
-//
-// for(PopulationGroup group : groups){
-// MatrixND sub = result.getSubMatrix(2, group, 1);
-// double meanWeight = group.getMeanWeight();
-// sub.mults(meanWeight);
-// }
-//
-// return result;
-// }
+ // /**
+ // * @param pop
+ // * @param date
+ // * @return
+ // */
+ // public MatrixND matrixCatchWeightPerStrategyMet(Population pop,
+ // Date date, MatrixND matrixCatchPerStrategyMet) {
+ // List<PopulationGroup> groups = pop.getPopulationGroup();
+ //
+ // MatrixND result = matrixCatchPerStrategyMet.copy();
+ // result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET);
+ //
+ // for(PopulationGroup group : groups){
+ // MatrixND sub = result.getSubMatrix(2, group, 1);
+ // double meanWeight = group.getMeanWeight();
+ // sub.mults(meanWeight);
+ // }
+ //
+ // return result;
+ // }
+
/**
*
*
@@ -1739,18 +1798,18 @@
*/
public MatrixND matrixDiscardWeightPerStrategyMetPerZonePop(Population pop,
Date date, MatrixND matrixDiscardPerStrategyMetPerZonePop) {
- List<PopulationGroup> groups = pop.getPopulationGroup();
+ List<PopulationGroup> groups = pop.getPopulationGroup();
- MatrixND result = matrixDiscardPerStrategyMetPerZonePop.copy();
- result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET);
+ MatrixND result = matrixDiscardPerStrategyMetPerZonePop.copy();
+ result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET);
- for(PopulationGroup group : groups){
- MatrixND sub = result.getSubMatrix(2, group, 1);
- double meanWeight = group.getMeanWeight();
- sub.mults(meanWeight);
- }
+ for (PopulationGroup group : groups) {
+ MatrixND sub = result.getSubMatrix(2, group, 1);
+ double meanWeight = group.getMeanWeight();
+ sub.mults(meanWeight);
+ }
- return result;
+ return result;
}
}
1
0