Isis-fish-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
September 2009
- 3 participants
- 94 discussions
r2594 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier
by chatellier@users.labs.libre-entreprise.org 10 Sep '09
by chatellier@users.labs.libre-entreprise.org 10 Sep '09
10 Sep '09
Author: chatellier
Date: 2009-09-10 07:47:36 +0000 (Thu, 10 Sep 2009)
New Revision: 2594
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoTargetSpeciesModel.java
Log:
Fix impossible cast
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoTargetSpeciesModel.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoTargetSpeciesModel.java 2009-09-10 07:44:26 UTC (rev 2593)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoTargetSpeciesModel.java 2009-09-10 07:47:36 UTC (rev 2594)
@@ -1,5 +1,5 @@
/* *##%
- * Copyright (C) 2009 Code Lutin
+ * Copyright (C) 2009 Ifremer, Code Lutin
*
* 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,6 @@
import static org.codelutin.i18n.I18n._;
-import java.awt.Checkbox;
import java.awt.Component;
import java.util.List;
@@ -229,7 +228,7 @@
case 2:
Boolean bValue = (Boolean)value;
c = new JCheckBox();
- ((Checkbox)c).setState(bValue);
+ ((JCheckBox)c).setSelected(bValue);
break;
default:
throw new IndexOutOfBoundsException("No such column " + column);
1
0
r2593 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity
by chatellier@users.labs.libre-entreprise.org 10 Sep '09
by chatellier@users.labs.libre-entreprise.org 10 Sep '09
10 Sep '09
Author: chatellier
Date: 2009-09-10 07:44:26 +0000 (Thu, 10 Sep 2009)
New Revision: 2593
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelper.java
Log:
Fix potential NPE
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelper.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelper.java 2009-09-10 07:42:43 UTC (rev 2592)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelper.java 2009-09-10 07:44:26 UTC (rev 2593)
@@ -524,7 +524,7 @@
result = ((MetierSeasonInfoSpeciesEditorUI) c)
.getMetierSeasonInfo().getSpeciesTargetSpecies();
- } else if (result instanceof PopulationZonesEditorUI) {
+ } else if (c instanceof PopulationZonesEditorUI) {
result = ((PopulationZonesEditorUI) c)
.getFieldPopulationMappingZoneReproZoneRecru().getMatrix();
1
0
r2592 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher
by chatellier@users.labs.libre-entreprise.org 10 Sep '09
by chatellier@users.labs.libre-entreprise.org 10 Sep '09
10 Sep '09
Author: chatellier
Date: 2009-09-10 07:42:43 +0000 (Thu, 10 Sep 2009)
New Revision: 2592
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationExecutor.java
Log:
Fix impossible cast
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationExecutor.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationExecutor.java 2009-09-09 16:27:51 UTC (rev 2591)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationExecutor.java 2009-09-10 07:42:43 UTC (rev 2592)
@@ -122,7 +122,7 @@
// un simple suspend du thread n'est pas bon, car la tache ne
// serait alors jamais executer et ce n'est pas forcement ce que
// l'on souhaite
- if (r instanceof SimulationItem) {
+ if (r instanceof SimulationJob) {
SimulationService.getService().resubmit((SimulationJob) r);
}
throw new RuntimeException(
1
0
r2591 - in isis-fish/trunk/src/test: java/fr/ifremer/isisfish/util resources/test-database resources/test-database/analyseplans resources/test-database/exports resources/test-database/rules resources/test-database/scripts resources/test-database/sensitivity resources/test-database/sensitivityexports
by chatellier@users.labs.libre-entreprise.org 09 Sep '09
by chatellier@users.labs.libre-entreprise.org 09 Sep '09
09 Sep '09
Author: chatellier
Date: 2009-09-09 16:27:51 +0000 (Wed, 09 Sep 2009)
New Revision: 2591
Added:
isis-fish/trunk/src/test/resources/test-database/analyseplans/CalibrationSimplexePasVariable2Capturabilite.java
isis-fish/trunk/src/test/resources/test-database/analyseplans/SimulationNumberRestriction.java
isis-fish/trunk/src/test/resources/test-database/rules/EffortReduction.java
isis-fish/trunk/src/test/resources/test-database/rules/GraviteVPUE1.java
isis-fish/trunk/src/test/resources/test-database/rules/TotalClosure.java
isis-fish/trunk/src/test/resources/test-database/sensitivity/
isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorJavaExpandGrid.java
isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRFast.java
isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRFrF2.java
isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRMorris.java
isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorROptimumLHS.java
isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRRandomLHS.java
isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRSobol.java
isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRegularFractions.java
isis-fish/trunk/src/test/resources/test-database/sensitivity/regularfractions.R
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightReferenceY7.java
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeReferenceY10.java
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeY4.java
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightY1.java
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassReferenceY8.java
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeReferenceY11.java
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeY5.java
isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassY2.java
Removed:
isis-fish/trunk/src/test/resources/test-database/analyseplans/Calibration.java
isis-fish/trunk/src/test/resources/test-database/analyseplans/Max.java
isis-fish/trunk/src/test/resources/test-database/rules/GraviteCPUE.java
isis-fish/trunk/src/test/resources/test-database/rules/RecrutementLangoustine.java
Modified:
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/JavadocHelperTest.java
isis-fish/trunk/src/test/resources/test-database/exports/Abundances.java
isis-fish/trunk/src/test/resources/test-database/exports/Biomasses.java
isis-fish/trunk/src/test/resources/test-database/exports/CapturesNombre.java
isis-fish/trunk/src/test/resources/test-database/exports/CapturesPoids.java
isis-fish/trunk/src/test/resources/test-database/exports/CellsDefinition.java
isis-fish/trunk/src/test/resources/test-database/exports/EffortsMetier.java
isis-fish/trunk/src/test/resources/test-database/exports/MetierZone.java
isis-fish/trunk/src/test/resources/test-database/exports/NonActivite.java
isis-fish/trunk/src/test/resources/test-database/exports/OwnerMargin.java
isis-fish/trunk/src/test/resources/test-database/exports/RegionDefinition.java
isis-fish/trunk/src/test/resources/test-database/exports/RejetsNombre.java
isis-fish/trunk/src/test/resources/test-database/exports/RejetsPoids.java
isis-fish/trunk/src/test/resources/test-database/exports/VesselMargin.java
isis-fish/trunk/src/test/resources/test-database/exports/ZonesDefinition.java
isis-fish/trunk/src/test/resources/test-database/rules/Cantonnement.java
isis-fish/trunk/src/test/resources/test-database/rules/CantonnementPreSimu.java
isis-fish/trunk/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java
isis-fish/trunk/src/test/resources/test-database/rules/InterdictionEngin.java
isis-fish/trunk/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java
isis-fish/trunk/src/test/resources/test-database/rules/TACpoids.java
isis-fish/trunk/src/test/resources/test-database/rules/TailleMin.java
isis-fish/trunk/src/test/resources/test-database/scripts/GravityModel.java
isis-fish/trunk/src/test/resources/test-database/scripts/ResultName.java
isis-fish/trunk/src/test/resources/test-database/scripts/RuleUtil.java
isis-fish/trunk/src/test/resources/test-database/scripts/SiMatrix.java
Log:
Mise ?\195?\160 jour de la database de test.
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/JavadocHelperTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/JavadocHelperTest.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/JavadocHelperTest.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -57,7 +57,7 @@
File currentDirectory = getCurrentDatabaseDirectory();
File destinationDirectory = new File(getTestDirectory(), "isis-docs");
- File testJavaFile = new File(currentDirectory, "analyseplans" + File.separatorChar + "Calibration.java");
+ File testJavaFile = new File(currentDirectory, "analyseplans" + File.separatorChar + "CalibrationSimplexePasVariable2Capturabilite.java");
PrintWriter out = new PrintWriter(System.out);
int result = JavadocHelper.generateJavadoc(currentDirectory, testJavaFile,
Deleted: isis-fish/trunk/src/test/resources/test-database/analyseplans/Calibration.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/analyseplans/Calibration.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/analyseplans/Calibration.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -1,342 +0,0 @@
-package analyseplans;
-
-import static org.codelutin.i18n.I18n._;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-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.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.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-/**
- * Calibration_bidon.java
- *
- * Created: 8 mars 2007
- *
- * @author <>
- * @version $Revision: 1.2 $
- *
- * 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};
-
- //parametres de la simu 3 points initiaux d un simplex d ordre 2
- @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)")
- 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)")
- 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)")
- 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)")
- 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")
- public String param_nomfichier_debarquements = "";//nom + chemin du fichier contenant les debarquements observes par groupe pour la derniere annee
-
- 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[] 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
- */
- 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();
- }
-
- /**
- * Call before each simulation
- * @param context plan context
- * @param nextSimulation storage used for next simulation
- * @return true if we must do next simulation, false to stop plan
- * @throws Exception
- */
- public boolean beforeSimulation(AnalysePlanContext context, SimulationStorage nextSimulation) throws Exception {
- boolean doNext = true;
-
- 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];
-
- 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);
- 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;
-
- 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
- * @return true if we must do next simulation, false to stop plan
- * @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);
- 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();){
- g.next();
- int [] dim = g.getCoordinates();
- double obs = matrixDebarquement.getValue(dim);
- double simules = g.getValue();
- 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());
-
- MatrixND c = pop.getCapturability();
-
- for (MatrixIterator i = c.iterator(); i.hasNext();){
- i.next();
-
- 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();
- }
-
- public class Experiences {
- /** contains last simplex and potentialy 2 more simulation */
- protected List<Experience> current = new ArrayList<Experience>();
- /** contains all experience done */
- 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.
- *
- * @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;
- }
- }
-
- /**
- * 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;
-
- /**
- * 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;
- }
- }
-
-}
-
Added: isis-fish/trunk/src/test/resources/test-database/analyseplans/CalibrationSimplexePasVariable2Capturabilite.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/analyseplans/CalibrationSimplexePasVariable2Capturabilite.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/analyseplans/CalibrationSimplexePasVariable2Capturabilite.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,481 @@
+package analyseplans;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.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 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.util.Doc;
+
+/**
+ * CalibrationSimplexePasVariable2Capturabilite.
+ *
+ * Created: 17 septembre 2007
+ *
+ * @author <>
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author: bpoussin $
+ */
+/////***You can modify class name if you want
+/////***BUT attention : file name and class name must be the same (without the extention ".java"), ie here : "CalibrationSimplexePasVariable2Capturabilite"
+public class CalibrationSimplexePasVariable2Capturabilite implements
+ AnalysePlan {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(CalibrationSimplexePasVariable2Capturabilite.class);
+
+ enum State {
+ STATE_INIT, STATE_0, STATE_1, STATE_2, STATE_3, STATE_4
+ };
+
+ /////***here must appear the path to export the historic file ("Historic.csv")
+ //where q1, q2 and criteria computed at each simulation are written
+ /////***Attention : before beginning a new calibration rename your eventual
+ //old file Historic.csv otherwise it will be lost
+ protected File exportHistoric = new File("Historic.csv");
+ protected String exportHisto = "";
+
+ @Doc("Population which parameters are calibrated")
+ public Population param_Population = null;
+ @Doc("First initial point of the simplex: de la forme(\"xx;yy\")")
+ public String param_M1 = "2.42e-5;2.11e-6";// devient un parametre du plan d analyse
+ @Doc("Second initial point of the simplex")
+ public String param_M2 = "2.34e-5;2.59e-6";// devient un parametre du plan d analyse
+ @Doc("Third initial point of the simplex")
+ public String param_M3 = "2.59e-5;2.41e-6";// devient un parametre du plan d analyse
+
+ ///// ***put here the path and name of the file containing the data on which you calibrate your fichery ( here observed catches)
+ @Doc(value = "file name and path of observed landings")
+ public String param_nomfichier_debarquements = "Observedlandings2001-2003.csv";//in row : time ; in columns : age or length group
+ protected File debarquementsObserves;
+ protected MatrixND matrixDebarquement;
+
+ protected State state = State.STATE_INIT;
+ public Experiences experiences = new Experiences();
+ public String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+ /**
+ * Permet d'afficher a l'utilisateur une aide sur le plan.
+ * @return L'aide ou la description du plan
+ */
+ public String getDescription() throws Exception {
+ return _("Calibration using variable step Simplex method (Walters): user gives a file of observations (here catches) by time step and group (.csv), output will try to approach oservations by changing the values of catchability");
+ }
+
+ /**
+ * Appele au demarrage de la simulation, cette methode permet d'initialiser
+ * des valeurs
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void init(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());
+
+ /////*** specify dimention of the matrix containning observations (observed landings for instance)
+ /////*** numbers of group/columns : could be equal to your number of classes in ISIS but may also be different if your had only aggregated data
+ int nbGroup = 4;
+ /////*** enter number of observation per year (if you have observation by quarter put 4) / lines of the observations file
+ int nbTrim = nbYear * 4;
+ int[] dimMatrix = { nbTrim, nbGroup };
+ matrixDebarquement = MatrixFactory.getInstance().create(dimMatrix);
+ //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, 0 });
+ log.info("MatrixDebarquement : " + matrixDebarquement);
+ //db.closeContext();
+ }
+
+ double g1;
+ double g2;
+ double worst1;
+ double worst2;
+
+ /**
+ * Call before each simulation
+ * @param context plan context
+ * @param nextSimulation storage used for next simulation
+ * @return true if we must do next simulation, false to stop plan
+ * @throws Exception
+ */
+ public boolean beforeSimulation(AnalysePlanContext context,
+ SimulationStorage nextSimulation) throws Exception {
+ boolean doNext = true;
+ boolean doBoucle = true;
+ log.info("before simulation");
+
+ int number = context.getNumber();
+
+ if (number < 3) {
+ log.info("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];
+
+ changeDB(experiences.getExperience(number), nextSimulation);
+
+ } else {
+
+ double q1 = 1000;
+ double q2 = 1000;
+ double lastCritere = experiences.getExperience(number - 1).criteria;
+ while (doBoucle) {
+ doBoucle = false;
+ if (state == State.STATE_INIT) {
+ doBoucle = false;
+ log.info("state init");
+
+ //ordonne les 3 premieres experiences selon leur critere
+ Collections.sort(experiences.current);
+ //log.info("SIMPLEXE : current 0 = " + experiences.current.get(0).criteria + "current 1 = " + experiences.current.get(1).criteria + "current 2 = " + experiences.current.get(2).criteria );
+ log.info("SIMPLEXE : current 0 = "
+ + experiences.current.get(0).criteria
+ + "current 1 = "
+ + experiences.current.get(1).criteria
+ + "current 2 = "
+ + experiences.current.get(2).criteria);
+ log.info("SIMPLEXE : Best q1 = "
+ + experiences.current.get(0).q1 + " q2 = "
+ + experiences.current.get(0).q2);
+ log.info("SIMPLEXE : NextBest q1 = "
+ + experiences.current.get(1).q1 + " q2 = "
+ + experiences.current.get(1).q2);
+ log.info("SIMPLEXE : Worst q1 = "
+ + experiences.current.get(2).q1 + " q2 = "
+ + experiences.current.get(2).q2);
+
+ //Calcul et evaluation de R
+ double g1 = (experiences.current.get(0).q1 + experiences.current
+ .get(1).q1) / 2.0;
+ double g2 = (experiences.current.get(0).q2 + experiences.current
+ .get(1).q2) / 2.0;
+ double worst1 = experiences.current.get(2).q1;
+ double worst2 = experiences.current.get(2).q2;
+
+ state = State.STATE_0;
+
+ q1 = 2 * g1 - worst1;
+ q2 = 2 * g2 - worst2;
+
+ log.info("R : q1 = " + q1 + " q2 = " + q2);
+
+ } else if (state == State.STATE_0) {
+ doBoucle = false;
+ log.info("state 0");
+
+ // on fait la 5eme avec des q qui dependent de la 4eme dans le dernier cas
+ //log.info("g1 = " + g1 + " " + "g2 = " + g2);
+ //log.info("worst1 = " + worst1 + " " + "worst2 = " + worst2);
+
+ if (lastCritere > experiences.current.get(2).criteria) {
+ log.info("State 0 : R : lastCtritere > current2 : R pire de W");
+ state = State.STATE_1;
+ //calcul de Cw
+ q1 = ((experiences.current.get(0).q1 + experiences.current
+ .get(1).q1) / 2.0)
+ - (((experiences.current.get(0).q1 + experiences.current
+ .get(1).q1) / 2.0) - experiences.current
+ .get(2).q1) / 2.0;
+ q2 = ((experiences.current.get(0).q2 + experiences.current
+ .get(1).q2) / 2.0)
+ - (((experiences.current.get(0).q2 + experiences.current
+ .get(1).q2) / 2.0) - experiences.current
+ .get(2).q2) / 2.0;
+ log.info("Cw : q1 = " + q1 + " q2 = " + q2);
+
+ } else if (lastCritere > experiences.current.get(1).criteria) {
+ log.info("State 0 :R : lastCritere > current 1 : R meilleur que W et moins bon que N");
+ state = State.STATE_2;
+ // calcul de Cr
+ q1 = ((experiences.current.get(0).q1 + experiences.current
+ .get(1).q1) / 2.0)
+ + (((experiences.current.get(0).q1 + experiences.current
+ .get(1).q1) / 2.0) - experiences.current
+ .get(2).q1) / 2.0;
+ q2 = ((experiences.current.get(0).q2 + experiences.current
+ .get(1).q2) / 2.0)
+ + (((experiences.current.get(0).q2 + experiences.current
+ .get(1).q2) / 2.0) - experiences.current
+ .get(2).q2) / 2.0;
+ log.info("Cr : q1 = " + q1 + " q2 = " + q2);
+
+ } else if (lastCritere > experiences.current.get(0).criteria) {
+ log.info("State 0 :R : lastCritere > current0 : R meilleur que N et moins bon que B");
+ state = State.STATE_INIT;
+ experiences.current.remove(2);//remove(3)avant
+ doBoucle = true;
+ log.info("remove W, simplex BNR");
+
+ } else { // dernier cas possible: if (lastCritere < experiences.current.get(0).critere) {
+ log.info("State 0 :R : lastCritere < current 0 : R meilleur que B, calcul de E");
+ state = State.STATE_4;
+
+ q1 = experiences.getExperience(number - 1).q1
+ + (experiences.current.get(0).q1 + experiences.current
+ .get(1).q1) / 2.0
+ - experiences.current.get(2).q1;
+ q2 = experiences.getExperience(number - 1).q2
+ + (experiences.current.get(0).q2 + experiences.current
+ .get(1).q2) / 2.0
+ - experiences.current.get(2).q2;
+ //q1 = experiences.current.get(3).q1 + (experiences.current.get(0).q1 + experiences.current.get(1).q1) / 2.0 - experiences.current.get(2).q1;
+ //q2 = experiences.current.get(3).q2 + (experiences.current.get(0).q2 + experiences.current.get(1).q2) / 2.0 - experiences.current.get(2).q2;
+ log.info("E : q1 = " + q1 + " q2 = " + q2);
+ }
+
+ } else if (state == State.STATE_1) {
+ log.info("state 1, simplex BNCw");
+ experiences.current.remove(3);
+ experiences.current.remove(2);
+ state = State.STATE_INIT;
+ doBoucle = true;
+
+ } else if (state == State.STATE_2) {
+ log.info("state 2, simplex BNCr");
+ experiences.current.remove(3);
+ experiences.current.remove(2);
+ state = State.STATE_INIT;
+ doBoucle = true;
+
+ } else if (state == State.STATE_4) {
+ log.info("state 4 :comparaison de E a B");
+ doBoucle = true;
+ if (lastCritere < experiences.current.get(0).criteria) {
+ log.info("E meilleur que B, remove 2 et 3 : simplex BNE");
+ experiences.current.remove(3);
+ experiences.current.remove(2);
+ } else {
+ log.info("E moins bon que B, remove 2 et 4, simplex BNR");
+ experiences.current.remove(4);
+ experiences.current.remove(2);
+ }
+
+ state = State.STATE_INIT;
+ }
+
+ }//fin du while
+ //on remplit la table experiences
+ experiences.getExperience(number).q1 = q1;
+ experiences.getExperience(number).q2 = q2;
+
+ log.info("on change Q dans la DB avec : q1 = " + q1 + " " + "q2 = " + q2);
+
+ // on change la valeur de q dans la DB
+ changeDB(experiences.getExperience(number), nextSimulation);
+ }// fin du else (number > 3)
+ return doNext;
+ }// fin du before simulation
+
+ /**
+
+ * Call after each simulation, compute criteria for last simulation
+ * @param context plan context
+ * @param lastSimulation 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 {
+ boolean doNext = true;
+ log.info("after simulation");
+ int number = context.getNumber();
+ ResultStorage result = lastSimulation.getResultStorage();
+
+ /////*** Simulated catches are cumulated over strategies, areas and metiers
+
+ MatrixND L2 = result.getMatrix(param_Population,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ // log.info("dim de L2" + " " + Arrays.toString(L2.getDim()));
+ /////*** If some strategies, metiers or areas must not be included in the cumulated catches see below else put "//" at the beginning of line 297 and replace "L2" by "L" at line 289
+ /////*** the strategies or so to exclude must be at the begining or end of the list you enter in the parameters interface
+ /////*** fill the line MatrixND L = L2.getSubMatrix(a,b,c).copy(); as follow :
+ /////*** a = 1 if you want to exclude strategies, 2 if metiers and 4 if areas
+ /////*** b = indice of the first object considered
+ /////*** c = number of object to keep after b, b included
+ MatrixND L = L2.getSubMatrix(1, 2, 4).copy(); // for instance : keep strategies 2,3,4,5
+ //log.info("sous matrice extraite");
+ L = L.sumOverDim(1);// sum over strategies
+ L = L.sumOverDim(2);// sum over metiers
+ L = L.sumOverDim(4);// sum over zones
+ log.info("sommes sur les strategies, metiers et zones faites");
+
+ /////*** if observations are cumulated by groups else put "//" at the beginning of the following line
+ L = L.sumOverDim(3);
+ /////*** else if number of groups in your database differs from number of groups in observations ... write me an e-mail
+
+ ////*** if observations are cumulated over quarter put 3, over year 12, else put "//" at the beginning of the following line
+ L = L.sumOverDim(0, 3);
+
+ L = L.reduce();
+
+ ///////////////////Calcul du critere//////////////////
+ log.info("calcul du critere");
+ log.info("dim de L" + " " + Arrays.toString(L.getDim()));
+ log.info("dim de obs" + " "
+ + Arrays.toString(matrixDebarquement.getDim()));
+ double crit = 0;
+ for (MatrixIterator g = L.iterator(); g.hasNext();) {
+ g.next();
+ //boucle sur les trimestres et les classes d age
+
+ int[] dim = g.getCoordinates();
+
+ double obs = matrixDebarquement.getValue(dim);
+ double simules = g.getValue();
+
+ crit += Math.pow(obs - simules, 2); // crit = crit + (obs-simules)^2
+ }// fin du for
+ log.info("critere " + number + " = " + crit);
+
+ //ajoute le critere dans la table experiences
+ experiences.getExperience(number).criteria = crit;
+
+ //ecriture de la table historic
+ exportHisto += experiences.getExperience(number).q1 + ";"
+ + experiences.getExperience(number).q2 + ";"
+ + experiences.getExperience(number).criteria + "\n";
+ org.codelutin.util.FileUtil.writeString(exportHistoric, exportHisto);
+
+ return doNext;
+
+ }// fin du after simulation
+
+ /**
+ * Modify nextSimulation database with q1 and q2 in exp.
+ *
+ * @param exp
+ * @param nextSimulation
+ * @throws Exception
+ */
+ protected void changeDB(Experience exp, SimulationStorage nextSimulation)
+ throws Exception {
+ //methode appelee dans before simualtion
+ TopiaContext db = nextSimulation.getStorage().beginTransaction();//ouvrir un context pour modifier les donnees
+ Population pop = (Population) db.findByTopiaId(param_Population.getTopiaId()); //reccupere la pop ciblee
+ MatrixND c = pop.getCapturability(); // reccupere la matrice de capturabilité
+
+ //log.info("Pour cette simulation : q1 = " + exp.q1 + ";" + "q2 = " + exp.q2 );
+
+ /////*** that is where you explain how to fill the catchability matrix with q1 and q2
+ for (MatrixIterator i = c.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sem = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sem[0];
+ //PopulationSeasonInfo season = (PopulationSeasonInfo) sem[1];
+
+ ////*** exemple when q2 corresponds to the 12 first groups (groups 0 to 11)
+ if (group.getId() < 12) {
+ i.setValue(exp.q2);
+ } else {
+ i.setValue(exp.q1);
+ }
+
+ /////*** exemple when it depends on seasons and groups
+ /* if (season.getFirstMonth().after(Month.JULY) && group.getId() >=18){ //month >= aout && groupID >= 18
+ i.setValue(exp.q2);
+ }else {
+ i.setValue(exp.q1);
+ }
+ */
+
+ }//fin du for
+
+ db.commitTransaction(); // effectue la modification
+ db.closeContext(); // ferme le context
+ }
+
+ static public class Experiences {
+ // cree la liste experiences ou sont stoqués q1,q2 et critere pour chaque simulation
+
+ /** contains last simplex and potentialy 2 more simulation */
+ public List<Experience> current = new ArrayList<Experience>();
+
+ /** contains all experience done */
+ public List<Experience> history = new ArrayList<Experience>();
+
+ /**
+ * 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
+ */
+ 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;
+ }//fin de la definition de getExperience
+
+ /**
+ * @return the history
+ */
+ public List<Experience> getHistory() {
+ return this.history;
+ }
+ }// fin de la creation des listes experiences
+
+ static public class Experience implements Comparable<Experience> {
+ public int simNumber;
+ public double criteria;
+ public double q1;
+ public double q2;
+
+ /**
+ * Permit to order experience, first is experience with smallest criteria
+ */
+ public int compareTo(Experience other) {
+ int result = Double.compare(this.criteria, other.criteria);
+ return result;
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: isis-fish/trunk/src/test/resources/test-database/analyseplans/CalibrationSimplexePasVariable2Capturabilite.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Deleted: isis-fish/trunk/src/test/resources/test-database/analyseplans/Max.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/analyseplans/Max.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/analyseplans/Max.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -1,97 +0,0 @@
-package analyseplans;
-
-import static org.codelutin.i18n.I18n._;
-
-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.AnalysePlanIndependent;
-import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
-/**
- * Max.java
- *
- * Created: 2 mars 2007
- *
- * @author bpoussin <bpoussin at labs.libre-entreprise.org>
- * @version $Revision: 1.2 $
- *
- * 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;
-
-
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_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 _("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
- */
- public void init(AnalysePlanContext context) throws Exception {
-
- }
-
- /**
- * Call before each simulation
- * @param context plan context
- * @param nextSimulation storage used for next simulation
- * @return true if we must do next simulation, false to stop plan
- * @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
- * @return true if we must do next simulation, false to stop plan
- * @throws Exception
- */
- public boolean afterSimulation(AnalysePlanContext context, SimulationStorage lastSimulation) throws Exception {
- return true;
- }
-
-}
Added: isis-fish/trunk/src/test/resources/test-database/analyseplans/SimulationNumberRestriction.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/analyseplans/SimulationNumberRestriction.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/analyseplans/SimulationNumberRestriction.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,96 @@
+package analyseplans;
+
+import static org.codelutin.i18n.I18n._;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.AnalysePlanContext;
+import fr.ifremer.isisfish.simulator.AnalysePlanIndependent;
+import fr.ifremer.isisfish.util.Doc;
+
+/**
+ * ExempleSimulationsIndependantes.java
+ *
+ * Created: 2 mars 2007
+ *
+ * @author bpoussin <bpoussin at labs.libre-entreprise.org>
+ * @version $Revision$
+ *
+ * Last update: $Date$ by : $Author: bpoussin $
+ */
+public class SimulationNumberRestriction implements AnalysePlanIndependent {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(SimulationNumberRestriction.class);
+
+ @Doc(value = "do the doc of param max")
+ public int param_max = 10;
+
+ public String[] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ };
+
+ @Override
+ 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
+ */
+ @Override
+ 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 context La simulation pour lequel on utilise cette regle
+ */
+ @Override
+ public void init(AnalysePlanContext context) throws Exception {
+
+ }
+
+ /**
+ * Call before each simulation
+ *
+ * @param context
+ * plan context
+ * @param nextSimulation
+ * storage used for next simulation
+ * @return true if we must do next simulation, false to stop plan
+ * @throws Exception
+ */
+ @Override
+ 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 lastSimulation storage used for last simulation
+ * @return true if we must do next simulation, false to stop plan
+ * @throws Exception
+ */
+ @Override
+ public boolean afterSimulation(AnalysePlanContext context,
+ SimulationStorage lastSimulation) throws Exception {
+ return true;
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/analyseplans/SimulationNumberRestriction.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: isis-fish/trunk/src/test/resources/test-database/exports/Abundances.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/Abundances.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/Abundances.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -14,10 +14,7 @@
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; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* Abundance.java
*
@@ -29,7 +26,6 @@
* Last update: $Date: 2007-05-24 09:30:07 $
* by : $Author: bpoussin $
*/
- at Doc(value="do the doc of class Abundances")
public class Abundances implements Export {
/** to use log facility, just put in your code: log.info("..."); */
@@ -52,7 +48,7 @@
}
public String getDescription() {
- return _("Export les abondances en nombre tableau avec des lignes pop;id;zone;date;nombre.");
+ return _("Exporte les abondances en nombre tableau avec des lignes pop;id;zone;date;nombre.");
}
public void export(SimulationStorage simulation, Writer out) throws Exception {
Modified: isis-fish/trunk/src/test/resources/test-database/exports/Biomasses.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/Biomasses.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/Biomasses.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -15,10 +15,7 @@
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; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* Biomasses.java
*
@@ -30,7 +27,6 @@
* Last update: $Date: 2007-05-24 09:30:07 $
* by : $Author: bpoussin $
*/
- @Doc(value="do the doc of class Biomasses")
public class Biomasses implements Export {
/** to use log facility, just put in your code: log.info("..."); */
@@ -53,7 +49,7 @@
}
public String getDescription() {
- return _("Export les biomasses tableau avec des lignes pop;id;zone;date;nombre");
+ return _("Exporte les biomasses tableau avec des lignes pop;id;zone;date;nombre");
}
public void export(SimulationStorage simulation, Writer out) throws Exception {
Modified: isis-fish/trunk/src/test/resources/test-database/exports/CapturesNombre.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/CapturesNombre.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/CapturesNombre.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -2,44 +2,39 @@
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; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* CapturesNombre.java
- *
+ *
* Created: 23 novembre 2006
- *
+ *
* @author anonymous <anonymous at 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")
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_PER_ZONE_POP
- };
-
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP };
+
public String[] getNecessaryResult() {
return this.necessaryResult;
}
@@ -47,76 +42,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_PER_ZONE_POP);
+ 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_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();) {
+ 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: isis-fish/trunk/src/test/resources/test-database/exports/CapturesPoids.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/CapturesPoids.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/CapturesPoids.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -2,44 +2,39 @@
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; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* CapturesPoids.java
- *
+ *
* Created: 23 novembre 2006
- *
+ *
* @author anonymous <anonymous at 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")
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_PER_ZONE_POP
- };
-
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+
public String[] getNecessaryResult() {
return this.necessaryResult;
}
@@ -47,72 +42,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_PER_ZONE_POP);
+ for (Date date = new Date(0); !date.after(lastDate); date = date
+ .next()) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(date,
+ pop, ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
if (mat != null) { // can be null if simulation is stopped before last year simulation
mat = mat.sumOverDim(0); //sum on strategy
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ 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: isis-fish/trunk/src/test/resources/test-database/exports/CellsDefinition.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/CellsDefinition.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/CellsDefinition.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -1,22 +1,18 @@
package exports;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import static org.codelutin.i18n.I18n._;
import java.io.Writer;
import java.util.List;
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.math.matrix.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.topia.TopiaContext;
-import fr.ifremer.isisfish.entities.*;
-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.entities.Cell;
+import fr.ifremer.isisfish.export.Export;
-import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* CellsDefinition.java
*
@@ -28,7 +24,6 @@
* Last update: $Date: 2007-05-24 09:30:07 $
* by : $Author: bpoussin $
*/
- @Doc(value="do the doc of class CellsDefinition")
public class CellsDefinition implements Export {
/** to use log facility, just put in your code: log.info("..."); */
@@ -58,11 +53,14 @@
}
public void export(SimulationStorage simulation, Writer out) throws Exception {
- List<Cell> cells = simulation.getFisheryRegion().getCell();
+ TopiaContext tx = simulation.getStorage().beginTransaction();
+ List<Cell> cells = SimulationStorage.getFisheryRegion(tx).getCell();
for (Cell cell : cells) {
out.write(cell + ";" + cell.getLongitude() + ";" + cell.getLatitude() + "\n");
}
+
+ tx.closeContext();
}
}
Modified: isis-fish/trunk/src/test/resources/test-database/exports/EffortsMetier.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/EffortsMetier.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/EffortsMetier.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -15,10 +15,7 @@
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; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* EffortsMetier.java
*
@@ -30,7 +27,6 @@
* Last update: $Date: 2007-05-24 09:30:07 $
* by : $Author: bpoussin $
*/
- @Doc(value="do the doc of class EffortsMetier")
public class EffortsMetier implements Export {
/** to use log facility, just put in your code: log.info("..."); */
Modified: isis-fish/trunk/src/test/resources/test-database/exports/MetierZone.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/MetierZone.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/MetierZone.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -10,14 +10,10 @@
import scripts.ResultName;
-import fr.ifremer.isisfish.entities.*;
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; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* MetierZone.java
*
@@ -29,7 +25,6 @@
* Last update: $Date: 2007-05-24 09:30:07 $
* by : $Author: bpoussin $
*/
- @Doc(value="do the doc of class MetierZone")
public class MetierZone implements Export {
/** to use log facility, just put in your code: log.info("..."); */
Modified: isis-fish/trunk/src/test/resources/test-database/exports/NonActivite.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/NonActivite.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/NonActivite.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -17,8 +17,6 @@
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.datastore.ResultStorage;
-import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* NonActivite.java
*
@@ -30,7 +28,6 @@
* Last update: $Date: 2007-05-24 09:30:07 $
* by : $Author: bpoussin $
*/
- @Doc(value="do the doc of class NonActivite")
public class NonActivite implements Export {
/** to use log facility, just put in your code: log.info("..."); */
Modified: isis-fish/trunk/src/test/resources/test-database/exports/OwnerMargin.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/OwnerMargin.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/OwnerMargin.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -15,10 +15,7 @@
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; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* OwnerMargin.java
*
@@ -30,7 +27,6 @@
* Last update: $Date: 2007-05-24 09:30:07 $
* by : $Author: bpoussin $
*/
- @Doc(value="do the doc of class OwnerMargin")
public class OwnerMargin implements Export {
/** to use log facility, just put in your code: log.info("..."); */
@@ -53,7 +49,7 @@
}
public String getDescription() {
- return _("cvs out strategy;date;value");
+ return _("Exporte les profits du patrons, retourne un tableau strategy;date;value");
}
public void export(SimulationStorage simulation, Writer out) throws Exception {
Modified: isis-fish/trunk/src/test/resources/test-database/exports/RegionDefinition.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/RegionDefinition.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/RegionDefinition.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -6,15 +6,12 @@
import java.io.Writer;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.math.matrix.*;
+import org.codelutin.topia.TopiaContext;
import fr.ifremer.isisfish.entities.*;
import fr.ifremer.isisfish.export.Export;
import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.datastore.ResultStorage;
-import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* RegionDefinition.java
*
@@ -26,7 +23,6 @@
* Last update: $Date: 2007-05-24 10:05:22 $
* by : $Author: bpoussin $
*/
- @Doc(value="do the doc of class RegionDefinition")
public class RegionDefinition implements Export {
/** to use log facility, just put in your code: log.info("..."); */
@@ -57,7 +53,9 @@
public void export(SimulationStorage simulation, Writer out) throws Exception {
// NomRegion LatituteMin LatitudeMax LongitudeMin LongitudeMax PasLatitude PasLongitude
- FisheryRegion region = simulation.getFisheryRegion();
+ TopiaContext tx = simulation.getStorage().beginTransaction();
+ FisheryRegion region = SimulationStorage.getFisheryRegion(tx);
+
out.write(region.getName() + ";"
+ region.getMinLatitude() + ";"
+ region.getMaxLatitude() + ";"
@@ -66,6 +64,8 @@
+ region.getCellLengthLatitude() + ";"
+ region.getCellLengthLongitude() +
"\n");
+
+ tx.closeContext();
}
}
Modified: isis-fish/trunk/src/test/resources/test-database/exports/RejetsNombre.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/RejetsNombre.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/RejetsNombre.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -2,44 +2,39 @@
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; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* RejetsNombre.java
- *
+ *
* Created: 23 novembre 2006
- *
+ *
* @author anonymous <anonymous at 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 RejetsNombre")
public class RejetsNombre implements Export {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(RejetsNombre.class);
- protected String [] necessaryResult = {
- ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP
- };
-
+ protected String[] necessaryResult = { ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP };
+
public String[] getNecessaryResult() {
return this.necessaryResult;
}
@@ -47,74 +42,79 @@
public String getExportFilename() {
return "RejetsNombre";
}
-
+
public String getExtensionFilename() {
return ".csv";
}
-
+
public String getDescription() {
return _("Export les rejets en nombre de la simulation. tableau pop;metier;id;zone;date;nombre");
}
- public void export(SimulationStorage simulation, Writer out) throws Exception {
- Date lastDate = simulation.getResultStorage().getLastDate();
-
+ 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_DISCARDS_PER_STR_MET_PER_ZONE_POP);
+ 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_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();) {
+ 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 rejets 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();
+ var capture=0.0;
+ var result="";
+ writeln("debut de export rejets 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 ,"Rejet par metier");
- if (matrice==null){
- matrice=MatrixFactory.create(resultats.getMatrix(new PDate(0),pop ,"Rejet par metier"));
- matrice.mults(0);
- }
- 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 ,"Rejet par metier");
+ if (matrice==null){
+ matrice=MatrixFactory.create(resultats.getMatrix(new PDate(0),pop ,"Rejet par metier"));
+ matrice.mults(0);
+ }
+ 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 RejetsNombre");
-return ""+result;
-*/
+ writeln("fin de RejetsNombre");
+ return ""+result;
+ */
}
}
Modified: isis-fish/trunk/src/test/resources/test-database/exports/RejetsPoids.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/RejetsPoids.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/RejetsPoids.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -2,45 +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; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* RejetsPoids.java
- *
+ *
* Created: 23 novembre 2006
- *
+ *
* @author anonymous <anonymous at 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 RejetsPoids")
public class RejetsPoids implements Export {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(RejetsPoids.class);
- protected String [] necessaryResult = {
- ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP
-
+ protected String[] necessaryResult = { ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP
+
};
-
+
public String[] getNecessaryResult() {
return this.necessaryResult;
}
@@ -48,73 +44,78 @@
public String getExportFilename() {
return "RejetsPoids";
}
-
+
public String getExtensionFilename() {
return ".csv";
}
-
+
public String getDescription() {
return _("Export les rejets en poids de la simulation. tableau pop;metier;id;zone;date;nombre");
}
- public void export(SimulationStorage simulation, Writer out) throws Exception {
- Date lastDate = simulation.getResultStorage().getLastDate();
-
+ 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_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
+ 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_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();) {
+ 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 rejets 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 rejets 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, "Rejet par metier");
- if (matrice==null){
- matrice=MatrixFactory.create(resultats.getMatrix(new PDate(0),pop ,"Rejet par metier"));
- matrice.mults(0);
- }
- var temp=matrice.sumOverDim(0);
- 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()*c.getPoidsMoyen();
- 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, "Rejet par metier");
+ if (matrice==null){
+ matrice=MatrixFactory.create(resultats.getMatrix(new PDate(0),pop ,"Rejet par metier"));
+ matrice.mults(0);
+ }
+ var temp=matrice.sumOverDim(0);
+ 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()*c.getPoidsMoyen();
+ result+=pop.getNom()+";"+metier.getNom()+";"+c.getId()+";"+z.getNom()+";"+idate+";"+capture+"\n";
+ }
+ }
+ }
-writeln("fin de RejetsPoids");
-return ""+result;
-*/
+ writeln("fin de RejetsPoids");
+ return ""+result;
+ */
}
}
Modified: isis-fish/trunk/src/test/resources/test-database/exports/VesselMargin.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/VesselMargin.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/VesselMargin.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -15,10 +15,7 @@
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; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* VesselMargin.java
*
@@ -30,7 +27,6 @@
* Last update: $Date: 2007-05-24 09:30:07 $
* by : $Author: bpoussin $
*/
- @Doc(value="do the doc of class VesselMargin")
public class VesselMargin implements Export {
/** to use log facility, just put in your code: log.info("..."); */
Modified: isis-fish/trunk/src/test/resources/test-database/exports/ZonesDefinition.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/exports/ZonesDefinition.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/exports/ZonesDefinition.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -7,16 +7,13 @@
import java.util.List;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.math.matrix.*;
+import org.codelutin.topia.TopiaContext;
import fr.ifremer.isisfish.entities.*;
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; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
/**
* ZonesDefinition.java
*
@@ -28,7 +25,6 @@
* Last update: $Date: 2007-05-24 09:30:07 $
* by : $Author: bpoussin $
*/
- @Doc(value="do the doc of class ZoneDefinition")
public class ZonesDefinition implements Export {
/** to use log facility, just put in your code: log.info("..."); */
@@ -58,7 +54,9 @@
}
public void export(SimulationStorage simulation, Writer out) throws Exception {
- List<Zone> zones = simulation.getFisheryRegion().getZone();
+ TopiaContext tx = simulation.getStorage().beginTransaction();
+ List<Zone> zones = SimulationStorage.getFisheryRegion(tx).getZone();
+
Date lastDate = simulation.getResultStorage().getLastDate();
for (Date date = new Date(0); !date.after(lastDate); date = date.next() ) {
@@ -68,6 +66,8 @@
}
}
}
+
+ tx.closeContext();
}
}
Modified: isis-fish/trunk/src/test/resources/test-database/rules/Cantonnement.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/Cantonnement.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/rules/Cantonnement.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -46,17 +46,17 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(Cantonnement.class);
- @Doc(value="do the doc of param zone")
+ @Doc(value="Zone de fermeture")
public Zone param_zone = null;
- @Doc(value="do the doc of param gear")
+ @Doc(value="Engin concernés")
public Gear param_gear = null;
- @Doc(value="do the doc of param beginDate")
+ @Doc(value="Begin date")
public Date param_beginDate = new Date(0);
- @Doc(value="do the doc of param endDate")
+ @Doc(value="End date")
public Date param_endDate = new Date(119);
- @Doc(value="do the doc of param beginMonth")
+ @Doc(value="Begin month")
public Month param_beginMonth = Month.JANUARY;
- @Doc(value="do the doc of param endMonth")
+ @Doc(value="End month")
public Month param_endMonth = Month.DECEMBER;
public String [] necessaryResult = {
@@ -76,20 +76,23 @@
* @return L'aide ou la description de la regle
*/
public String getDescription() throws Exception {
+ // fermeture saisiniere de zone qui peut être réduite à un engin
+ // et a certaines années de la simulation
return _("Cantonnement: can be used to Cantonnement with gear if you put gear in parameter");
}
/**
* 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 context La simulation pour lequel on utilise cette regle
*/
public void init(SimulationContext context) throws Exception {
+
}
/**
* La condition qui doit etre vrai pour faire les actions
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
* @return vrai si on souhaite que les actions soit faites
*/
public boolean condition(SimulationContext context, Date date, Metier metier) throws Exception {
@@ -149,7 +152,7 @@
/**
* Si la condition est vrai alors cette action est executée avant le pas
* de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
*/
public void preAction(SimulationContext context, Date date, Metier metier) throws Exception {
MetierMonitor metierMon = context.getMetierMonitor();
@@ -320,7 +323,7 @@
/**
* Si la condition est vrai alors cette action est executée apres le pas
* de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
*/
public void postAction(SimulationContext context, Date date, Metier metier) throws Exception {
// nothing
Modified: isis-fish/trunk/src/test/resources/test-database/rules/CantonnementPreSimu.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/CantonnementPreSimu.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/rules/CantonnementPreSimu.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -10,10 +10,7 @@
import scripts.SiMatrix;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -31,7 +28,7 @@
import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
/**
- * Cantonnement.java
+ * CantonnementPreSimu.java
*
* Created: 30 novembre 2006
*
@@ -46,15 +43,13 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(CantonnementPreSimu.class);
- @Doc(value="do the doc of param zone")
+ @Doc(value="Zone de fermature")
public Zone param_zone = null;
- @Doc(value="do the doc of param gear")
+ @Doc(value="Engin concernés")
public Gear param_gear = null;
- @Doc(value="do the doc of param enginSelective")
- public boolean param_enginSelective = true;
- @Doc(value="do the doc of param beginMonth")
+ @Doc(value="Begin month")
public Month param_beginMonth = Month.JANUARY;
- @Doc(value="do the doc of param endMonth")
+ @Doc(value="End month")
public Month param_endMonth = Month.DECEMBER;
protected Map<Month, MatrixND> tableNonActivite = new HashMap<Month, MatrixND>();
@@ -117,7 +112,7 @@
/**
* 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 context La simulation pour lequel on utilise cette regle
*/
public void init(SimulationContext context) throws Exception {
SiMatrix siMatrix = SiMatrix.getSiMatrix(context);
@@ -125,7 +120,7 @@
// MetierDAO metierDao = IsisFishDAOHelper.getMetierDAO(context.getDB());
ZoneDAO zoneDao = IsisFishDAOHelper.getZoneDAO(context.getDB());
MetierSeasonInfoDAO metierSeasonInfoDao = IsisFishDAOHelper.getMetierSeasonInfoDAO(context.getDB());
-
+
// List<Metier> metiers = metierDao.findAll();
List<Month> SaisonFermee = Month.getMonths(param_beginMonth, param_endMonth);
List<Cell> maillefermee = param_zone.getCell();
@@ -641,7 +636,7 @@
/**
* La condition qui doit etre vrai pour faire les actions
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
* @return vrai si on souhaite que les actions soit faites
*/
public boolean condition(SimulationContext context, Date date, Metier metier) throws Exception {
@@ -668,7 +663,7 @@
/**
* Si la condition est vrai alors cette action est executée avant le pas
* de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
*/
public void preAction(SimulationContext context, Date date, Metier metier) throws Exception {
// on ne doit le faire qu'une seul fois quelque soit le nombre de metier
@@ -704,7 +699,7 @@
/**
* Si la condition est vrai alors cette action est executée apres le pas
* de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
*/
public void postAction(SimulationContext context, Date date, Metier metier) throws Exception {
affectNonActivite = false;
Modified: isis-fish/trunk/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -2,32 +2,35 @@
import static org.codelutin.i18n.I18n._;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import scripts.ResultName;
import scripts.SiMatrix;
-
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.codelutin.math.matrix.*;
-
import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.entities.EffortDescription;
+import fr.ifremer.isisfish.entities.EffortDescriptionDAO;
+import fr.ifremer.isisfish.entities.FisheryRegion;
+import fr.ifremer.isisfish.entities.Gear;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.entities.MetierDAO;
+import fr.ifremer.isisfish.entities.MetierSeasonInfo;
+import fr.ifremer.isisfish.entities.MetierSeasonInfoDAO;
+import fr.ifremer.isisfish.entities.SetOfVessels;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.entities.StrategyMonthInfo;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.rule.AbstractRule;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.Date;
import fr.ifremer.isisfish.types.Month;
-import fr.ifremer.isisfish.entities.*;
-import fr.ifremer.isisfish.rule.AbstractRule;
-import fr.ifremer.isisfish.datastore.RegionStorage;
-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)
-
/**
- * TailleMin.java
+ * ChangementParamControlablePresimu.java
*
* Created: 30 novembre 2006
*
@@ -42,15 +45,15 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(ChangementParamControlablePresimu.class);
- @Doc(value="do the doc of param zone")
+ @Doc(value="Zone de fermeture")
public Zone param_zone = null;
- @Doc(value="do the doc of param gear")
+ @Doc(value="Engin concernés")
public Gear param_gear = null;
- @Doc(value="do the doc of param beginMonth")
+ @Doc(value="Begin month")
public Month param_beginMonth = Month.JANUARY;
- @Doc(value="do the doc of param endMonth")
+ @Doc(value="End month")
public Month param_endMonth = Month.DECEMBER;
- @Doc(value="do the doc of param newParamValue")
+ @Doc(value="New param controlable value")
public String param_newParamValue = "80";
public String [] necessaryResult = {
@@ -75,7 +78,7 @@
/**
* 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 context La simulation pour lequel on utilise cette regle
*/
public void init(SimulationContext context) throws Exception {
SiMatrix siMatrix = SiMatrix.getSiMatrix(context);
@@ -134,7 +137,8 @@
MetierSeasonInfo NouveauInfoSaison = infoDao.create();
NouveauInfoSaison.setMetier(NouveauMetier);
NouveauInfoSaison.setMonths(sais);
- NouveauInfoSaison.setZone(infsais.getZone());
+ // EC : new ArrayList<Zone>() fix error "Found shared references to a collection"
+ NouveauInfoSaison.setZone(new ArrayList<Zone>(infsais.getZone()));
NouveauInfoSaison.setComment("créé durant la simulation");
NouveauMetier.addMetierSeasonInfo(NouveauInfoSaison);
}
@@ -294,8 +298,8 @@
}
/**
- * La condition qui doit etre vrai pour faire les actions
- * @param simulation La simulation pour lequel on utilise cette regle
+ * La condition qui doit etre vrai pour faire les actions.
+ * @param context La simulation pour lequel on utilise cette regle
* @return vrai si on souhaite que les actions soit faites
*/
public boolean condition(SimulationContext context, Date date, Metier metier) throws Exception {
@@ -303,18 +307,18 @@
}
/**
- * Si la condition est vrai alors cette action est executée avant le pas
+ * Si la condition est vrai alors cette action est executée avant le pas.
* de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
*/
public void preAction(SimulationContext context, Date date, Metier metier) throws Exception {
// nothing
}
/**
- * Si la condition est vrai alors cette action est executée apres le pas
+ * Si la condition est vrai alors cette action est executée apres le pas.
* de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
*/
public void postAction(SimulationContext context, Date date, Metier metier) throws Exception {
// nothing
Added: isis-fish/trunk/src/test/resources/test-database/rules/EffortReduction.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/EffortReduction.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/rules/EffortReduction.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,139 @@
+package rules;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import scripts.SiMatrix;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.rule.AbstractRule;
+import fr.ifremer.isisfish.simulator.SimulationContext;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+/**
+ * EffortReduction.java
+ *
+ * Created: 3 septembre 2008
+ *
+ * @author anonymous <anonymous at labs.libre-entreprise.org>
+ * @version $Revision$
+ */
+public class EffortReduction extends AbstractRule {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(EffortReduction.class);
+
+ @Doc("Begin date")
+ public Date param_beginDate = new Date(0);
+ @Doc("End date")
+ public Date param_endDate = new Date(59);
+
+ @Doc("Pourcentage de reduction d effort applique.")
+ public double param_PercentReduction = 0.5;
+
+ boolean first = true;
+
+ protected String[] necessaryResult = {};
+
+ /**
+ * @return the necessaryResult
+ */
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+ /**
+ * Permet d'afficher a l'utilisateur une aide sur la regle.
+ * @return L'aide ou la description de la regle
+ */
+ public String getDescription() {
+ return _("Reduce monthly effort of each strategy of the percent indicated");
+ }
+
+ /**
+ * Appele au demarrage de la simulation, cette methode permet d'initialiser
+ * des valeurs.
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void init(SimulationContext context) throws Exception {
+ }
+
+ /**
+ * La condition qui doit etre vrai pour faire les actions
+ * @param context La simulation pour lequel on utilise cette regle
+ * @return vrai si on souhaite que les actions soit faites
+ */
+ public boolean condition(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+
+ boolean result = true;
+ if (date.before(param_beginDate)) {
+ result = false;
+ } else if (date.after(param_endDate)) {
+ result = false;
+ }
+ if (result)
+ System.out.println("condition vraie");
+ return result;
+ }
+
+ /**
+ * Si la condition est vrai alors cette action est executee avant le pas
+ * de temps de la simulation.
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void preAction(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+ // shinte la boucle metier
+ if (first) {
+ first = false;
+ SiMatrix siMatrix = SiMatrix.getSiMatrix(context);
+ List<Strategy> strs = siMatrix.getStrategies(date);
+ for (Strategy str : strs) {
+ System.out.println("strategy evaluee : " + str.getName());
+
+ /* Dans un premiere temps tant que l inactivit? est un entier on utilise
+ * la proportion du nombre de bateaux de la strategie pour reduire l effort
+ * ce qu on ferait aussi pour une mesure de reduction du nombre de bateaux mais
+ * comme actuellement on ne tient pas compte de l economie... ca revient au meme
+ * En fait passer par l inactivit? n est pas la meilleure facon de modifier
+ * l effort le mieux serait d agir sur un autre coeff qui est multipli? a
+ * l effort (Fstd ou ciblage) car comme ca le code serait generique mais on
+ * ne verrait pas que l effort nominal est modifi?...
+ */
+
+ double propOld = str.getProportionSetOfVessels();
+ double newProp = propOld * (1 - param_PercentReduction);
+ str.setProportionSetOfVessels(newProp);
+
+ /* int Inact = str.getStrategyMonthInfo(date.getMonth()).getMinInactivityDays();
+ System.out.println("inactivity old = "+ Inact);
+ int nbDays = date.getMonth().getNumbersOfDays();
+ System.out.println("nbDays = "+nbDays);
+ double newInact = nbDays-((nbDays-Inact)*(1-param_PercentReduction));
+ System.out.println("newInact = "+newInact);
+ int ni = (int) newInact ;
+ System.out.println("ni = "+ ni);
+ str.getStrategyMonthInfo(date.getMonth()).setMinInactivityDays(ni);
+ System.out.println("setMinInactivityDays : " + str.getStrategyMonthInfo(date.getMonth()).getMinInactivityDays());
+ */
+ }
+ }
+ }
+
+ /**
+ * Si la condition est vrai alors cette action est executee apres le pas
+ * de temps de la simulation.
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void postAction(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+ first = true;
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/rules/EffortReduction.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Deleted: isis-fish/trunk/src/test/resources/test-database/rules/GraviteCPUE.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/GraviteCPUE.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/rules/GraviteCPUE.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -1,484 +0,0 @@
-package rules;
-
-import static org.codelutin.i18n.I18n._;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import scripts.GravityModel;
-import scripts.ResultName;
-import scripts.SiMatrix;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.codelutin.math.matrix.*;
-
-import fr.ifremer.isisfish.simulator.SimulationContext;
-import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.types.Month;
-import fr.ifremer.isisfish.entities.*;
-import fr.ifremer.isisfish.rule.AbstractRule;
-import fr.ifremer.isisfish.datastore.ResultStorage;
-
-/**
- * GraviteCPUE.java
- *
- * Created: 30 novembre 2006
- *
- * @author anonymous <anonymous at labs.libre-entreprise.org>
- * @version $Revision: 1.2 $
- *
- * Last update: $Date: 2007-07-18 08:59:38 $
- * by : $Author: hilaire $
- */
-public class GraviteCPUE extends AbstractRule {
-
- /** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(GraviteCPUE.class);
-
- /** stocke la somme des prop initiales [str x month] */
- private MatrixND SommePropInitial = null;
- /** stocke par strat*met, la dernière attractivite pour chaque mois
- * [str x met x month] */
- private MatrixND HistoriqueCPUE = null;
-
- /** va permettre de stocker a chaque pas de temps la somme des attractivite [str] */
- MatrixND SommeCPUEstrat = null;
- /** va permettre de stocker a chaque pas de temps la somme des proportions
- * pour les metiers n'ayant pas d'attractivite [str] */
- MatrixND SommeProp = null;
-
- /** permet de stocker les CPUE standardiser [str x met] */
- private MatrixND catchPerUnitOfEffort = null;
-
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP,
- ResultName.MATRIX_EFFORT_PER_STRATEGY_MET,
- };
-
- public String[] getNecessaryResult() {
- return this.necessaryResult;
- }
-
- /**
- * Permet d'afficher a l'utilisateur une aide sur la regle.
- * @return L'aide ou la description de la regle
- */
- public String getDescription() throws Exception {
- // TODO
- return _("GraviteCPUE");
- }
-
- /**
- * function used to initialise MatrixND to NaN double
- */
- private MapFunction nanFunction = new MapFunction() {
- public double apply(double value) {
- return Double.NaN;
- }
- };
-
- /**
- * 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
- */
- public void init(SimulationContext context) throws Exception {
- Date date = new Date(0);
-
- List<Strategy> strs = SiMatrix.getSiMatrix(context).getStrategies(date);
- List<Metier> metiers = SiMatrix.getSiMatrix(context).getMetiers(date);
- List<Month> months = Arrays.asList(Month.MONTH);
-
- SommePropInitial = MatrixFactory.getInstance().create("SommePropInitial",
- new List[]{strs, months}, new String[]{"Strategies", "Months"});
- SommePropInitial.map(nanFunction);
-
- HistoriqueCPUE = MatrixFactory.getInstance().create("HistoriqueCPUE",
- new List[]{strs, metiers, months}, new String[]{"Strategies", "Metiers", "Months"});
- HistoriqueCPUE.map(nanFunction);
-
-
- SommeCPUEstrat = MatrixFactory.getInstance().create("SommeCPUEstrat",
- new List[]{strs}, new String[]{"Strategies"});
- SommeCPUEstrat.map(nanFunction);
-
- SommeProp = MatrixFactory.getInstance().create("SommeProp",
- new List[]{strs}, new String[]{"Strategies"});
- SommeProp.map(nanFunction);
-
- catchPerUnitOfEffort = MatrixFactory.getInstance().create("ValuePerUnitOfEffort",
- new List[]{strs, metiers}, new String[]{"Strategies", "Metiers"});
- catchPerUnitOfEffort.map(nanFunction);
-
- for (Strategy str : strs) {
- List<Metier> strMetiers = SiMatrix.getSiMatrix(context).getMetiers(str, date);
- List<StrategyMonthInfo> infos = str.getStrategyMonthInfo();
- for (StrategyMonthInfo info : infos) {
- double somme = 0;
- for (Metier strMetier : strMetiers) {
- somme += info.getProportionMetier(strMetier);
- }
- // FIXME soit on somme pour toutes les str le meme metier; donc pas de notion de str.getName dans la cle
- // soit pour une str on somme tous ces metiers (mais ce doit etre 1; donc pas de notion de metier.getName dans la cle
- SommePropInitial.setValue(str, info.getMonth(), somme);
- }
- }
-
-/*
-var allStr = SiMatrice.getListStrategies();
-
-for(var i=0; i<allStr.size(); i++){
- var str=allStr.get(i);
- var metiers=str.getSetOfVessels().getMetiers();
- var ListeStrMonthInfos=str.getStrategyMonthInfos();
- for (var j=0; j<ListeStrMonthInfos.size();j++){
- var somme=0;
- var StrMonthInfo=ListeStrMonthInfos.get(j);
- for (var k=0;k<metiers.size();k++){
- var metier=metiers.get(k);
- somme+=StrMonthInfo.getProportionMetier(metier);
- }
- this.p.SommePropInitial.put(new Chaine(str.getName()+"-"+metier.getNom()+"-"+StrMonthInfo.getMonth().getNumMois()),somme);
- }
-}
-
- //permet de stocker les CPUE standardiser
-CatchperUnitOfEffort = MatrixFactory.create("ValuePerUnitOfEffort",new Array(allStr,SiMatrice.getListMetiers()),new Array("Strategies","Metiers"));
-*/
- }
- /**
- * La condition qui doit etre vrai pour faire les actions
- * @param simulation La simulation pour lequel on utilise cette regle
- * @return vrai si on souhaite que les actions soit faites
- */
- public boolean condition(SimulationContext context, Date date, Metier metier) throws Exception {
- // Il faut etre au moins au deuxieme pas de temps.
- // FIXME 2eme pas de temps ou 2eme annee ? ici c 2eme annee et non pas 2eme mois
- return date.getYear() > 0;
- }
-
- /**
- * Si la condition est vrai alors cette action est executée avant le pas
- * de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
- */
- public void preAction(SimulationContext context, Date date, Metier metier) throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("Gravite Action avant metier:"+ metier + "date:"+ date);
- }
-
- List<Strategy> strs = SiMatrix.getSiMatrix(context).getStrategies(date);
- List<Population> populations = SiMatrix.getSiMatrix(context).getPopulations(date);
-
- double newPropDiv = 0;
-
- ResultStorage resultmanager = context.getSimulationStorage().getResultStorage();
-
- //on commence par creer une matrice de capture par strategie met
- MatrixND catchWeigthPerStrMet = null;
- for (Population pop : populations){
- MatrixND temp = resultmanager.getMatrix(
- date.previousYear(),
- pop,
- ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
- // on somme sur les zones
- temp=temp.sumOverDim(3);
- // on somme sur les groupes
- temp=temp.sumOverDim(2);
- if (catchWeigthPerStrMet == null) {
- catchWeigthPerStrMet = temp;
- } else {
- catchWeigthPerStrMet.add(temp);
- }
- }
-
- MatrixND effortPerStrMet = resultmanager.getMatrix(
- date.previousYear(),
- ResultName.MATRIX_EFFORT_PER_STRATEGY_MET);
-
- for (Strategy str : strs){
- List<Metier> strMetiers = SiMatrix.getSiMatrix(context).getMetiers(str, date);
- for (Metier strMetier : strMetiers){
- double effort = effortPerStrMet.getValue(str, strMetier);
- if (effort > 0){
- EffortDescription effortdesc = str.getSetOfVessels().getPossibleMetiers(strMetier);
- int nombreop=effortdesc.getFishingOperation();
- int nombregear=effortdesc.getGearsNumberPerOperation();
- double param=strMetier.getGearParameterValueAsDouble();
- double facteur = param * nombreop * nombregear*strMetier.getGear().getStandardisationFactor() / 24.0;
- //on restandardise l'effort
- effort /= facteur;
- //on recupere la capture tot
- Object group = catchWeigthPerStrMet.getSemantics(2).get(0);
- Object zone = catchWeigthPerStrMet.getSemantics(3).get(0);
-
- double capture = catchWeigthPerStrMet.getValue(str, strMetier, group, zone);
-
- catchPerUnitOfEffort.setValue(str, strMetier, capture/effort);
- }
- }
- }
-
-
-
- for (Strategy str : strs){
- List<Metier> strMetiers = SiMatrix.getSiMatrix(context).getMetiers(str, date);
- StrategyMonthInfo info = str.getStrategyMonthInfo(date.getMonth());
-
- if(strMetiers.contains(metier)){
- // on verifie que le metier est bien un metier possible
- double CPUE = Double.NaN;
- if (SommeCPUEstrat.getValue(str) == Double.NaN){
- if (effortPerStrMet.getValue(str, metier) > 0){
- CPUE = catchPerUnitOfEffort.getValue(str, metier);
- }
- }
-
- if (CPUE != Double.NaN){
- if (log.isDebugEnabled()) {
- log.debug("on a une CPUE l'année n-1, on la met dans l'historique\n" + info + " " + metier);
- }
- HistoriqueCPUE.setValue(str, metier, info.getMonth(), CPUE);
- } else {
- if (log.isDebugEnabled()) {
- log.debug("ou calcul déjà fait ou pas de CPUE à l'année n-1");
- }
- CPUE = HistoriqueCPUE.getValue(str, metier, info.getMonth());
- if (CPUE != Double.NaN) {
- if (log.isDebugEnabled()) {
- log.debug("on a une CPUE dans le passé: " + CPUE);
- }
- } else{
- if (log.isDebugEnabled()) {
- log.debug("on a pas de CPUE dans le passé, on remet donc la poportion initiale");
- }
- }
- }
- if (CPUE != Double.NaN) {
- // si on a une CPUE, il faut aller voir l'attractivite des autres metiers: 2 cas de figure:
- // soit on en retrouve une dans le passe qui est son attractivite
- // soit on en retrouve pas et dans ce cas le, la proportion d'effort sera celle initiale de la db
- // on a alors newProp=(1-sum(pmet1))*CPUE/somme(CPUEmet2)
- // avec pmet1 la proprtion initiale pour les metiers pour lesquels on a pas retrouve de CPUE, CPUEmet2, la CPUE pour les
- // metiers qui ont eu une CPUE dans le passe, et CPUE la CPUE du metier courant
- if (SommeCPUEstrat.getValue(str) == Double.NaN){
- double SommeCPUE=0;
- double PropTot=0;
- for (Metier strMetier : strMetiers){
- double temp = Double.NaN;
- if (effortPerStrMet.getValue(str, strMetier) > 0){
- temp = catchPerUnitOfEffort.getValue(str, strMetier);
- }
- if (temp != Double.NaN){
- if (log.isDebugEnabled()) {
- log.debug("on a une CPUE l'année n-1, on l'ajoute à p.SommeCPUEstrat");
- }
- HistoriqueCPUE.setValue(str, metier, info.getMonth(), temp);
- SommeCPUE += temp;
- }
- else{
- if (log.isDebugEnabled()) {
- log.debug("on a pas de CPUE l'année n-1, on regarde si il y en a dans le passé");
- }
- temp = HistoriqueCPUE.getValue(str, metier, info.getMonth());
- if (temp != Double.NaN){
- if (log.isDebugEnabled()) {
- log.debug("on a une CPUE dans le passé: "+temp);
- }
- SommeCPUE+=temp;
- }
- else{
- if (log.isDebugEnabled()) {
- log.debug("on a pas de CPUE dans le passé, on l'ajoute donc à p.SommeProp");
- }
- PropTot += info.getProportionMetier(strMetier);
- }
- }
- }
- SommeCPUEstrat.setValue(str, SommeCPUE);
- SommeProp.setValue(str, PropTot);
- }
-
- if (SommeCPUEstrat.getValue(str) > 0){
- newPropDiv = (SommePropInitial.getValue(str, info.getMonth()) - SommeProp.getValue(str))
- * CPUE / SommeCPUEstrat.getValue(str);
- if (log.isDebugEnabled()) {
- log.debug("newpropdiv: " + newPropDiv);
- }
- info.setProportionMetier(metier, newPropDiv);
- }
- else { // c'est le cas e priori quasi impossible oe y a toujours eu une CPUE nulle quelquesoit le metier, dans ce cas le on remet aussi la prop iniitiale
- if (log.isDebugEnabled()) {
- log.debug("aucun metier n'a d'attractivite, on remet la prop initiale");
- }
- }
- }
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("fin Gravite CPUEAction avant");
- }
-
-/*
-writeln("Gravite Action avant metier:"+p.metier+ "date:"+ p.date);
-var Chaine=Packages.java.lang.String;
-
-
-
-var month=p.date.getMois();
-var allStr = SiMatrice.getListStrategies();
-var newPropDiv=0.0;
-
-if (!p.CalculCatch){
- var resultmanager=control.getResultatManager();
-
- //on commence par creer une matrice de capture par strategie met
- var ListePopulation=SiMatrice.getListPopulations();
- pop=ListePopulation.get(0);
- var CaptureParStrMet=resultmanager.getMatrix(new Packages.fr.ifremer.nodb.Date(p.date.getDate()-12),pop,"matriceCatchWeightPerStrategyMet");
- CaptureParStrMet=CaptureParStrMet.sumOverDim(3);
- CaptureParStrMet=CaptureParStrMet.sumOverDim(2);
- writeln(CaptureParStrMet);
- for (var ipop=1;ipop<ListePopulation.size();ipop++){
- var pop=ListePopulation.get(ipop);
- var temp=resultmanager.getMatrix(new Packages.fr.ifremer.nodb.Date(p.date.getDate()-12),pop,"matriceCatchWeightPerStrategyMet");
- temp=temp.sumOverDim(3);
- temp=temp.sumOverDim(2);
- writeln(temp);
- CaptureParStrMet.add(temp);
- writeln(CaptureParStrMet);
- }
-
- var Effort=resultmanager.getMatrix(new Packages.fr.ifremer.nodb.Date(p.date.getDate()-12),"matriceEffortPerStrategyMet");
- writeln("on récupère la matrice d'effort");
- for (var iStrategie=allStr.iterator();iStrategie.hasNext();){
- var Strategie=iStrategie.next();
- var listeMet=Strategie.getSetOfVessels().getMetiers();
- for (imetier=listeMet.iterator();imetier.hasNext();){
- var metier=imetier.next();
- var effort=Effort.getValue(Strategie,metier);
- if (effort>0){
- var effortdesc=Strategie.getSetOfVessels().getEffort(metier);
- var nombreop=effortdesc.getFishingOperation();
- var nombregear=effortdesc.getGearsNumberPerOperation();
- var param=metier.getValeurParamControlable();
- var facteur=metier.getValeurParamControlable()*nombreop*nombregear/24.0;
- //on restandardise l'effort
- effort/=facteur;
- //on recupere la capture tot
- var dim3=new Packages.java.util.ArrayList(CaptureParStrMet.getSemantics(3));
- var dim2=new Packages.java.util.ArrayList(CaptureParStrMet.getSemantics(2));
-
- var capture=CaptureParStrMet.getValue(Strategie,metier,dim2.get(0),dim3.get(0));
-
- p.CatchperUnitOfEffort.setValue(Strategie,metier,capture/effort);
- }
- }
- }
- p.CalculCatch=true;
-}
-
-
-
-for(var i=0; i<allStr.size(); i++){
- var str = allStr.get(i);
- var strMonthInfo = str.getStrategyMonthInfo(month);
- var propStrMet = strMonthInfo.getPropStrMetier(p.metier);
-
- if(str.getSetOfVessels().getMetiers().contains(p.metier)){
-//on verifie que le metier est bien un metier possible
- var CPUE=null;
- if (!p.SommeCPUEstrat.containsKey(new Chaine(str.getName()))){
- if (GravityModel.getEffortPerStrategyMet(str, p.metier, new Packages.fr.ifremer.nodb.Date(p.date.getDate()-12))>0){
- CPUE=p.CatchperUnitOfEffort.getValue(str,p.metier);
- }
- }
- if (CPUE!=null){
- writeln("on a une CPUE l'année n-1, on la met dans l'historique");
- writeln(strMonthInfo+" "+p.metier);
- p.HistoriqueCPUE.put(new Chaine(str.getName()+"-"+p.metier.getNom()+"-"+strMonthInfo.getMonth().getNumMois()),CPUE);
- }
- else{
- writeln ("ou calcul déjà fait ou pas de CPUE à l'année n-1");
- CPUE=p.HistoriqueCPUE.get(new Chaine(str.getName()+"-"+p.metier.getNom()+"-"+strMonthInfo.getMonth().getNumMois()));
- if (CPUE!=null){
- writeln ("on a une CPUE dans le passé: "+CPUE);
- }
- else{
- writeln ("on a pas de CPUE dans le passé, on remet donc la poportion initiale");
- }
- }
- if (CPUE!=null) {
-//si on a une CPUE, il faut aller voir l'attractivite des autres metiers: 2 cas de figure:
-// soit on en retrouve une dans le passe qui est son attractivite
-// soit on en retrouve pas et dans ce cas le, la proportion d'effort sera celle initiale de la db
-//on a alors newProp=(1-sum(pmet1))*CPUE/somme(CPUEmet2)
-//avec pmet1 la proprtion initiale pour les metiers pour lesquels on a pas retrouve de CPUE, CPUEmet2, la CPUE pour les
-//metiers qui ont eu une CPUE dans le passe, et CPUE la CPUE du metier courant
- if (!p.SommeCPUEstrat.containsKey(str.getName())){
- var SommeCPUE=0;
- var PropTot=0;
- var metiers=str.getSetOfVessels().getMetiers();
- for (var imetiers=metiers.iterator();imetiers.hasNext();){
- var metier=imetiers.next();
- var temp=null;
- if (GravityModel.getEffortPerStrategyMet(str, metier, new Packages.fr.ifremer.nodb.Date(p.date.getDate()-12))>0){
- temp=p.CatchperUnitOfEffort.getValue(str,metier);
- }
- if (temp!=null){
- writeln("on a une CPUE l'année n-1, on l'ajoute à p.SommeCPUEstrat");
- p.HistoriqueCPUE.put(new Chaine(str.getName()+"-"+metier.getNom()+"-"+strMonthInfo.getMonth().getNumMois()),CPUE);
- SommeCPUE+=temp;
- }
- else{
- writeln ("on a pas de CPUE l'année n-1, on regarde si il y en a dans le passé");
- temp=p.HistoriqueCPUE.get(new Chaine(str.getName()+"-"+metier.getNom()+"-"+strMonthInfo.getMonth().getNumMois()));
- if (temp!=null){
- writeln ("on a une CPUE dans le passé: "+temp);
- SommeCPUE+=temp;
- }
- else{
- writeln ("on a pas de CPUE dans le passé, on l'ajoute donc à p.SommeProp");
- PropTot+=strMonthInfo.getProportionMetier(metier);
- }
- }
- }
- p.SommeCPUEstrat.put(new Chaine(str.getName()),SommeCPUE);
- p.SommeProp.put(new Chaine(str.getName()),PropTot);
- }
- if (p.SommeCPUEstrat.get(new Chaine(str.getName()))>0){
- newPropDiv = (p.SommePropInitial.get(new Chaine(str.getName()+"-"+strMonthInfo.getMonth().getNumMois()))-p.SommeProp.get(new Chaine(str.getName())))*CPUE/ p.SommeCPUEstrat.get(new Chaine(str.getName()));
- writeln("newpropdiv: "+newPropDiv);
- strMonthInfo.setProportionMetier(p.metier, new Packages.java.lang.Float(newPropDiv));
- }
- else { // c'est le cas e priori quasi impossible oe y a toujours eu une CPUE nulle quelquesoit le metier, dans ce cas le on remet aussi la prop iniitiale
- writeln("aucun metier n'a d'attractivite, on remet la prop initiale");
- }
- }
- }
-}
-
-writeln("fin Gravite CPUEAction avant");
-return p.gestionMetier;
-*/
- }
-
- /**
- * Si la condition est vrai alors cette action est executée apres le pas
- * de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
- */
- public void postAction(SimulationContext context, Date date, Metier metier) throws Exception {
- SommeCPUEstrat.map(nanFunction);
- SommeProp.map(nanFunction);
- catchPerUnitOfEffort.map(nanFunction);
- }
-
-}
Added: isis-fish/trunk/src/test/resources/test-database/rules/GraviteVPUE1.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/GraviteVPUE1.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/rules/GraviteVPUE1.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,291 @@
+package rules;
+
+import static org.codelutin.i18n.I18n._;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import scripts.ResultName;
+import scripts.SiMatrix;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Collection;
+
+import org.codelutin.math.matrix.*;
+
+import fr.ifremer.isisfish.simulator.SimulationContext;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.types.Month;
+import fr.ifremer.isisfish.entities.*;
+import fr.ifremer.isisfish.rule.AbstractRule;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+
+/**
+ * GraviteVPUE1.java
+ *
+ * Created: 26 aout 2008
+ *
+ * @author anonymous <anonymous at labs.libre-entreprise.org>
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author: 2SY- Sigrid+Youen+Stephanie $
+ */
+public class GraviteVPUE1 extends AbstractRule {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(GraviteVPUE1.class);
+
+ /** stocke la somme des prop initiales [str x month] */
+ private MatrixND SommePropInitial = null;
+ /** stocke par strat*met, la dernière attractivite pour chaque mois [str x met x month] */
+
+ /** permet de stocker les CPUE nominales [str x met] */
+ private MatrixND valuePerUnitOfEffort = null;
+
+ public String[] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ //ResultName.MATRIX_EFFORT_PER_STRATEGY_MET,
+ ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET, // garder la ,
+
+ };
+
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+ /**
+ * Permet d'afficher a l'utilisateur une aide sur la regle.
+ * @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");
+ /*"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)
+ "*/
+ }
+
+ /**
+ * function used to initialise MatrixND to NaN double
+ */
+ private MapFunction nanFunction = new MapFunction() {
+ public double apply(double value) {
+ return Double.NaN;
+ }
+ };
+
+ /**
+ * Appelé au démarrage de la simulation, cette méthode permet d'initialiser
+ * des valeurs
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void init(SimulationContext context) throws Exception {
+ Date date = new Date(0);
+
+ List<Strategy> strs = SiMatrix.getSiMatrix(context).getStrategies(date);
+ List<Metier> metiers = SiMatrix.getSiMatrix(context).getMetiers(date);
+ List<Month> months = Arrays.asList(Month.MONTH);
+
+ SommePropInitial = MatrixFactory.getInstance().create(
+ "SommePropInitial", new List[] { strs, months },
+ new String[] { "Strategies", "Months" });
+ SommePropInitial.map(nanFunction);
+
+ valuePerUnitOfEffort = MatrixFactory.getInstance().create(
+ "ValuePerUnitOfEffort", new List[] { strs, metiers },
+ new String[] { "Strategies", "Metiers" });
+ valuePerUnitOfEffort.map(nanFunction);
+
+ for (Strategy str : strs) {
+ List<Metier> strMetiers = SiMatrix.getSiMatrix(context).getMetiers(
+ str, date);
+ List<StrategyMonthInfo> infos = str.getStrategyMonthInfo();
+ for (StrategyMonthInfo info : infos) {
+ double somme = 0;
+ for (Metier strMetier : strMetiers) {
+ somme += info.getProportionMetier(strMetier);
+ }
+ // FIXME soit on somme pour toutes les str le meme metier; donc pas de notion de str.getName dans la cle
+ // soit pour une str on somme tous ces metiers (mais ce doit etre 1; donc pas de notion de metier.getName dans la cle
+ SommePropInitial.setValue(str, info.getMonth(), somme);
+ }
+ }
+
+ }
+
+ /**
+ * La condition qui doit etre vrai pour faire les actions
+ * @param context La simulation pour lequel on utilise cette regle
+ * @return vrai si on souhaite que les actions soit faites
+ */
+ public boolean condition(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+ // Il faut etre au moins au deuxieme pas de temps.
+ return date.getYear() > 0;
+ }
+
+ // Booleen permettant que ne boucler que sur un seul metier dans la preaction :
+ boolean first = true;
+
+ /**
+ * Si la condition est vrai alors cette action est executée avant le pas
+ * de temps de la simulation.
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void preAction(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+ if (log.isDebugEnabled()) {
+ log.debug("first = " + first + "date:" + date);
+ }
+ System.out.println("first = " + first
+ + " ,on passe dans la preaction ?");
+ if (first) { // on passe dans preaction pour la premiere fois
+ System.out.println("Oui, preaction : ");
+
+ List<Strategy> strs = SiMatrix.getSiMatrix(context).getStrategies(
+ date);
+ //List<Population> populations = SiMatrix.getSiMatrix(context)
+ // .getPopulations(date);
+ ResultStorage resultmanager = context.getSimulationStorage()
+ .getResultStorage();
+
+ ////////Initialisation des matrices qui resultent de la simulation////////////////////////////////////////////////////////////
+
+ //Calcul de l effort nominal par strategy met
+ MatrixND EffortNominalPerStrMet = null;
+ EffortNominalPerStrMet = resultmanager.getMatrix(date
+ .previousYear(),
+ ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET);
+ System.out.println("EffortNominalPerStrMet calculee "
+ + EffortNominalPerStrMet);
+
+ //on commence par creer une matrice de valeurs (somme sur ttes les especes capturees) par strategie met
+ MatrixND GrossValuePerStrMet = null;
+ GrossValuePerStrMet = resultmanager.getMatrix(date.previousYear(),
+ ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET);
+
+ System.out.println("GrossValuePerStrMet calculee "
+ + GrossValuePerStrMet);
+
+ //ajouter pour tous les métiers les valeurs liées qux autres espèces calculées par modele lineaire
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////
+ valuePerUnitOfEffort.map(nanFunction); //réinitialisation avant calcul pour date
+
+ for (Strategy str : strs) {
+ System.out
+ .println("INFO: Boucle creation valuePerUnitEffort : "
+ + str.getName());
+ // log.info("Boucle creation catchperuniteffort : "+ str.getName());
+ StrategyMonthInfo smi = str.getStrategyMonthInfo(date
+ .getMonth());
+ Collection<EffortDescription> strMet = str.getSetOfVessels()
+ .getPossibleMetiers();
+ //SiMatrix.getSiMatrix(context).getMetiers(str, date);
+
+ // boucle pour tester s'il existe un metier pour lequel effort(metier)=0 et PropInitiale(metier)=0 (Condition)
+ boolean testCondition = false;
+ double somme = 0;//initialisation de la somme des VPUE des metiers de la strategie
+ for (EffortDescription ed : strMet) {
+ Metier strMetier = ed.getPossibleMetiers();
+ System.out.println("Pour str=" + str.getName()
+ + " et metier=" + strMetier.getName());
+ double effort = EffortNominalPerStrMet.getValue(str,
+ strMetier);
+ // 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
+ // 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
+ //on recupere la capture tot
+ double value = GrossValuePerStrMet.getValue(str,
+ strMetier);
+ System.out.println("DEBUG: value : " + value);
+ System.out.println("DEBUG: effort : " + effort);
+ double vpue = value / effort;
+ valuePerUnitOfEffort.setValue(str, strMetier, vpue);
+ System.out.println("value/effort= " + vpue);
+ somme += value / effort;
+ } else if ((effort == 0)
+ & (smi.getProportionMetier(strMetier) == 0)) {// n'a jamais pêche avec ce metier
+ valuePerUnitOfEffort.setValue(str, strMetier, 0);
+ System.out.println("n'a jamais pêche avec ce metier");
+ } else {// n'a pas peche au mois, annee -1, mais avait une prop d'effort non nul a l'annee=0
+ testCondition = true;// ie somme est incomplète mais pas grave car on mettra PropInitiale à tous les metiers
+ System.out.println("n'a pas peche au mois, annee -1, mais avait une prop d'effort non nul a l'annee=0");
+ }
+ }
+ System.out.println("testCondition pour str" + str.getName()
+ + ":" + testCondition);
+ // A partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravité
+ double newProp = 0;
+ System.out
+ .println("A partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravité");
+ if (!testCondition) {
+ double SommeVPUEstrat = somme;
+ System.out.println("SommeVPUEstrat=" + SommeVPUEstrat);
+ for (EffortDescription ed : strMet) {
+ Metier strMetier = ed.getPossibleMetiers();
+ System.out.println("PropStrInitiale(metier="
+ + strMetier.getName() + ")"
+ + smi.getProportionMetier(strMetier));
+ System.out.println("SommePropInitial.getValue(str, date.getMonth()="
+ + SommePropInitial.getValue(str, date
+ .getMonth()));
+ System.out.println("valuePerUnitOfEffort.getValue(str, strMetier)"
+ + valuePerUnitOfEffort.getValue(str,
+ strMetier));
+ if (SommeVPUEstrat == 0) {
+ newProp = 0;
+ } else {
+ newProp = SommePropInitial.getValue(str, date
+ .getMonth())
+ * valuePerUnitOfEffort.getValue(str,
+ strMetier) / SommeVPUEstrat;
+ }
+ System.out.println("newProp(metier="
+ + strMetier.getName() + ")" + newProp);
+ smi.setProportionMetier(strMetier, newProp);
+ System.out.println("PropStrNouvelle(metier="
+ + strMetier.getName() + ")"
+ + smi.getProportionMetier(strMetier));
+ }
+ }
+ // 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)
+
+ }//fin de boucle sur strategy
+
+ first = false;
+
+ }// fin de first= true
+
+ if (log.isDebugEnabled()) {
+ log.debug("fin Gravite CPUEAction avant");
+ }
+
+ }
+
+ /**
+ * Si la condition est vrai alors cette action est executée apres le pas
+ * de temps de la simulation.
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void postAction(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+ first = true;
+ }
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/rules/GraviteVPUE1.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: isis-fish/trunk/src/test/resources/test-database/rules/InterdictionEngin.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/InterdictionEngin.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/rules/InterdictionEngin.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -1,7 +1,6 @@
package rules;
import static org.codelutin.i18n.I18n._;
-import static org.codelutin.i18n.I18n.n_;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -9,7 +8,6 @@
import scripts.ResultName;
import scripts.SiMatrix;
-import java.io.Writer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -22,9 +20,6 @@
import fr.ifremer.isisfish.types.Month;
import fr.ifremer.isisfish.entities.*;
import fr.ifremer.isisfish.rule.AbstractRule;
-import fr.ifremer.isisfish.datastore.RegionStorage;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
@@ -44,13 +39,13 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(InterdictionEngin.class);
- @Doc(value="do the doc of param gear")
+ @Doc(value="Prohibited gear")
public Gear param_gear = null;
- @Doc(value="do the doc of param beginDate")
+ @Doc(value="Begin date")
public Date param_beginDate = new Date(0);
- @Doc(value="do the doc of param endDate")
+ @Doc(value="End date")
public Date param_endDate = new Date(119);
- @Doc(value="do the doc of param beginMonth")
+ @Doc(value="Begin month")
public Month param_beginMonth = Month.JANUARY;
@Doc(value="do the doc of param endMonth")
public Month param_endMonth = Month.DECEMBER;
@@ -71,20 +66,22 @@
* @return L'aide ou la description de la regle
*/
public String getDescription() throws Exception {
+ // interdiction des metiers utilisant cet engin
return _("Prohibited gear");
}
/**
* 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 context La simulation pour lequel on utilise cette regle
*/
public void init(SimulationContext context) throws Exception {
- // TODO
+ // nothing
}
+
/**
* La condition qui doit etre vrai pour faire les actions
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
* @return vrai si on souhaite que les actions soit faites
*/
public boolean condition(SimulationContext context, Date date, Metier metier) throws Exception {
@@ -133,7 +130,7 @@
/**
* Si la condition est vrai alors cette action est executée avant le pas
* de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
*/
public void preAction(SimulationContext context, Date date, Metier metier) throws Exception {
log.info("le metier vise par l'interdiction : " + metier);
@@ -158,12 +155,12 @@
// 1er cas:l'effort est reporte sur un metier de la meme strategie,
// n'ayant pas l'espece comme capture principale et pechant avec le meme engin
- List<EffortDescription> MetiersPossibles= new ArrayList<EffortDescription>(Strat.getSetOfVessels().getPossibleMetiers());
+ List<EffortDescription> MetiersPossibles = new ArrayList<EffortDescription>(Strat.getSetOfVessels().getPossibleMetiers());
// on verifie que les metiers sont bien pratiques au mois courant,
// qu'ils n'ont pas le meme engin et qu'ils ne sont pas
// interdits par ailleurs
- for (Iterator<EffortDescription> effort=MetiersPossibles.iterator(); effort.hasNext();) {
+ for (Iterator<EffortDescription> effort = MetiersPossibles.iterator(); effort.hasNext();) {
Metier met = effort.next().getPossibleMetiers();
if (StratMonthInfo.getProportionMetier(met) == 0
|| met.getGear().equals(metier.getGear())
@@ -187,7 +184,7 @@
StratMonthInfo.setProportionMetier(metier, 0); //le metier vise a alors une proportion nulle
}
// s'il n'y a pas de metier alternatif, on passe a nonActivite
- else{
+ else {
MatrixND matNonActivite = metierMon.getOrCreateNoActivity(date,
ResultName.MATRIX_NO_ACTIVITY,
siMatrix.getStrategies(date),
@@ -270,7 +267,7 @@
/**
* Si la condition est vrai alors cette action est executée apres le pas
* de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
*/
public void postAction(SimulationContext context, Date date, Metier metier) throws Exception {
// nothing
Modified: isis-fish/trunk/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -8,7 +8,6 @@
import scripts.ResultName;
-import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -24,13 +23,11 @@
import fr.ifremer.isisfish.entities.*;
import fr.ifremer.isisfish.rule.AbstractRule;
import fr.ifremer.isisfish.datastore.RegionStorage;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
/**
- * InterdictionEngin.java
+ * InterdictionEnginPreSimu.
*
* Created: 30 novembre 2006
*
@@ -77,13 +74,13 @@
/**
* 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 context La simulation pour lequel on utilise cette regle
*/
public void init(SimulationContext context) throws Exception {
MetierMonitor metierMon = context.getMetierMonitor();
- Month moisDeb = param_beginMonth;
- Month moisFin = param_endMonth;
+ //Month moisDeb = param_beginMonth;
+ //Month moisFin = param_endMonth;
Gear EnginInterdit = param_gear;
log.info("nom de l'engin interdit "+EnginInterdit.getName());
@@ -224,7 +221,7 @@
}
/**
* La condition qui doit etre vrai pour faire les actions
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
* @return vrai si on souhaite que les actions soit faites
*/
public boolean condition(SimulationContext context, Date date, Metier metier) throws Exception {
@@ -251,7 +248,7 @@
/**
* Si la condition est vrai alors cette action est executée avant le pas
* de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
*/
public void preAction(SimulationContext context, Date date, Metier metier) throws Exception {
// on ne doit le faire qu'une seul fois quelque soit le nombre de metier
@@ -261,10 +258,10 @@
MetierMonitor metierMon = context.getMetierMonitor();
MatrixND noActivity = metierMon.getNoActivity(date);
- if (noActivity == null){
+ if (noActivity == null) {
metierMon.setNoActivity(date, mat.copy());
}
- else{
+ else {
noActivity = noActivity.add(mat);
}
// fin
@@ -287,7 +284,7 @@
/**
* Si la condition est vrai alors cette action est executée apres le pas
* de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour lequel on utilise cette regle
*/
public void postAction(SimulationContext context, Date date, Metier metier) throws Exception {
affectNonActivite = false;
Deleted: isis-fish/trunk/src/test/resources/test-database/rules/RecrutementLangoustine.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/RecrutementLangoustine.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/rules/RecrutementLangoustine.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -1,184 +0,0 @@
-package rules;
-
-import static org.codelutin.i18n.I18n._;
-
-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 org.codelutin.topia.TopiaContext;
-import org.codelutin.util.StringUtil;
-
-import fr.ifremer.isisfish.IsisFishDAOHelper;
-import fr.ifremer.isisfish.simulator.PopulationMonitor;
-import fr.ifremer.isisfish.simulator.SimulationContext;
-import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.types.Month;
-import fr.ifremer.isisfish.entities.*;
-import fr.ifremer.isisfish.rule.AbstractRule;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.datastore.ResultStorage;
-
-import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
-
-/**
- * RecrutementLangoustine.java
- *
- * Created: 22 mars 2007
- *
- * @author stephanie MAHEVAS <smahevas at ifremer.fr>
- * @version $Revision: 1.1 $
- *
- * Last update: $Date: 2007-03-22 17:33:56 $
- * by : $Author: bpoussin $
- */
-public class RecrutementLangoustine extends AbstractRule {
-
- /** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(RecrutementLangoustine.class);
-
- @Doc(value="do the doc of param recrut1998")
- public double param_recrut1998 =0;
- @Doc(value="do the doc of param recrut1999")
- public double param_recrut1999 =0;
- @Doc(value="do the doc of param recrut2000")
- public double param_recrut2000 =0;
- @Doc(value="do the doc of param recrut2001")
- public double param_recrut2001 =0;
- @Doc(value="do the doc of param recrut2002")
- public double param_recrut2002 =0;
- @Doc(value="do the doc of param recrut2003")
- public double param_recrut2003 =0;
- @Doc(value="do the doc of param recrut2004")
- public double param_recrut2004 =0;
- @Doc(value="do the doc of param recrut2005")
- public double param_recrut2005 =0;
-
- public double [] recru = null;
-
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- };
-
- public String[] getNecessaryResult() {
- return this.necessaryResult;
- }
-
- /**
- * Permet d'afficher a l'utilisateur une aide sur la regle.
- * @return L'aide ou la description de la regle
- */
- public String getDescription() throws Exception {
- // TODO
- return _("TODO description rule");
- }
-
- /**
- * 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
- */
- public void init(SimulationContext context) throws Exception {
- // remarque on pourrait aussi avoir un seul parametre de regle
- // par exemple param_recru_depuis_1998 = "0;0;0;0;0;0;0;0";
- // on ferait alors
- // recru = StringUtil.toArrayDouble(param_recru_depuis_1998.split(";"));
-
- recru = new double[]{
- param_recrut1998,
- param_recrut1999,
- param_recrut2000,
- param_recrut2001,
- param_recrut2002,
- param_recrut2003,
- param_recrut2004,
- param_recrut2005,
- };
- }
- /**
- * La condition qui doit etre vrai pour faire les actions
- * @param simulation La simulation pour lequel on utilise cette regle
- * @return vrai si on souhaite que les actions soit faites
- */
- public boolean condition(SimulationContext context, Date date, Metier metier) throws Exception {
- boolean result = false;
- if (date.getMonth().equals(Month.SEPTEMBER) ||
- date.getMonth().equals(Month.OCTOBER)
- || date.getMonth().equals(Month.NOVEMBER)
- ||date.getMonth().equals(Month.DECEMBER)) {
- result = true;
- }
- return result;
-/*
-writeln("recrutement CIEM");
-var mois = p.date.getMois().getNumMois();
-//si le recrutement a lieu en octobre
-if( mois==8 ||mois==9 || mois==10 || mois==11){
-//??&& p.oprfaite==false{
-var result = true;
-}
- return result ;
-*/
-
- }
-
- /**
- * Si la condition est vrai alors cette action est executée avant
-le pas
- * de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
- */
- public void preAction(SimulationContext context, Date date, Metier metier) throws Exception {
- TopiaContext db = context.getDB();
-
- PopulationDAO popDao = IsisFishDAOHelper.getPopulationDAO(db);
- Population pop = popDao.findByName("nephrops");
- PopulationGroup group0 = pop.getPopulationGroup().get(0);
-
- ZoneDAO zoneDao = IsisFishDAOHelper.getZoneDAO(db);
- Zone zone1 = zoneDao.findByName("zone L21E7");
- Zone zone2 = zoneDao.findByName("zone L21E8");
- Zone zone3 = zoneDao.findByName("zone L22E6");
- Zone zone4 = zoneDao.findByName("zone L22E7");
- Zone zone5 = zoneDao.findByName("zone L23E5");
- Zone zone6 = zoneDao.findByName("zone L23E6");
- Zone zone7 = zoneDao.findByName("zone L23E7");
- Zone zone8 = zoneDao.findByName("zone L24E5");
- Zone zone9 = zoneDao.findByName("zone L24E6");
-
- int year = date.getYear();
- MatrixND matN = context.getPopulationMonitor().getN(pop);
-
- double coefR =4/(Math.exp(-0.6/12))*(1+ Math.exp(-0.3/12)+ Math.exp(-0.6/12)+ Math.exp(-0.9/12));
-
- double R = recru[year] * coefR / 9.0;
-
- matN.setValue(group0, zone1, R);
- matN.setValue(group0, zone2, R);
- matN.setValue(group0, zone3, R);
- matN.setValue(group0, zone4, R);
- matN.setValue(group0, zone5, R);
- matN.setValue(group0, zone6, R);
- matN.setValue(group0, zone7, R);
- matN.setValue(group0, zone8, R);
- matN.setValue(group0, zone9, R);
-
- }
-
- /**
- * Si la condition est vrai alors cette action est executée apres le pas
- * de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
- */
- public void postAction(SimulationContext context, Date date, Metier metier) throws Exception {
- // TODO
- }
-
-}
\ No newline at end of file
Modified: isis-fish/trunk/src/test/resources/test-database/rules/TACpoids.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/TACpoids.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/rules/TACpoids.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -1,21 +1,19 @@
package rules;
+import static org.codelutin.i18n.I18n._;
+
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
-import static org.codelutin.i18n.I18n._;
-
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 scripts.ResultName;
import scripts.RuleUtil;
import scripts.SiMatrix;
-
+import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.entities.EffortDescription;
import fr.ifremer.isisfish.entities.Metier;
import fr.ifremer.isisfish.entities.Population;
@@ -29,107 +27,112 @@
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.Date;
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)
-
/**
- * TAC.java
- *
+ * 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 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
+ *
* Created: 7 septembre 2006
*
* @author anonymous <anonymous at labs.libre-entreprise.org>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.3 $
*
- * Last update: $Date: 2007-11-20 15:50:09 $
- * by : $Author: bpoussin $
+ * Last update: $Date: 290607 $
+ * by : $Author: sigrid $
*/
-
-/**
- * TAC peut-etre utilisé pour les différents 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
- *
- */
public class TACpoids extends AbstractRule {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(TACpoids.class);
- @Doc(value="do the doc of param species")
+ @Doc("Affected species")
public Species param_species = null;
- @Doc(value="do the doc of param beginDate")
+ @Doc("Debin date")
public Date param_beginDate = new Date(0);
- @Doc(value="do the doc of param endDate")
- public Date param_endDate = new Date(22);
- @Doc(value="do the doc of param propSurvie")
+ @Doc("End date")
+ public Date param_endDate = new Date(90);
+ @Doc("Proportion de survie")
public double param_propSurvie = 0;
- @Doc(value="do the doc of param propTac")
+ @Doc("Proportionnal TAC")
public double param_propTac = 0;
- /** TAC in tonne */
- public double param_tacInTons = 0;
-
+ /** TAC in tonnes */
+ @Doc("TAC in tons")
+ public double param_tacInTons = 900;
+
boolean affectation = false;
-
- protected String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+
+ protected String[] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
-
+
/**
* @return the necessaryResult
*/
public String[] getNecessaryResult() {
return this.necessaryResult;
}
-
+
/**
* Permet d'afficher a l'utilisateur une aide sur la regle.
+ *
* @return L'aide ou la description de la regle
*/
public String getDescription() {
- return _("TAC weight in tons.\nIf you want survival discard use propSurvie other than 0.\nIf you wish TAC computed use propTac other than 0.");
+ return _("TAC weight in tons.\nIf you want survival discard use propSurvie other than 0.\nIf you wish TAC computed as a proportion of the biomass use propTac other than 0.");
}
-
+
/**
- * 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 La simulation pour lequel on utilise cette regle
+ *
+ * @param context La simulation pour lequel on utilise cette regle
*/
- public void init(SimulationContext context) throws Exception {
+ public void init(SimulationContext context) throws Exception {
}
-
+
/**
* La condition qui doit etre vrai pour faire les actions
- * @param simulation La simulation pour lequel on utilise cette regle
+ *
+ * @param context La simulation pour lequel on utilise cette regle
* @return vrai si on souhaite que les actions soit faites
*/
- public boolean condition(SimulationContext context, Date date, Metier metier) throws Exception {
+ public boolean condition(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+
+ log.info("test si TAC atteint");
// read species in current session
- param_species = (Species)context.getDB().findByTopiaId(param_species.getTopiaId());
-
- // on fait le calcul du tac si nécessaire
- if (param_propTac > 0 && date.getMonth().equals(Month.JANUARY)){
+ param_species = (Species) context.getDB().findByTopiaId(
+ param_species.getTopiaId());
+
+ // 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;
- }
-
+ }
+
boolean result = false;
- if(date.before(param_beginDate)) {
+ if (date.before(param_beginDate)) {
result = false;
- } else if(date.after(param_endDate)) {
- result = false;
+ } else if (date.after(param_endDate)) {
+ result = false;
} else {
- TargetSpecies ts = metier.getMetierSeasonInfo(date.getMonth()).getSpeciesTargetSpecies(param_species);
+ TargetSpecies ts = metier.getMetierSeasonInfo(date.getMonth())
+ .getSpeciesTargetSpecies(param_species);
if (ts != null) {
- double catchTons = RuleUtil.getTotalCatchTons(context, param_species, date);
- log.info("[TAC] catchTons = " + catchTons + " >= param_tacInTons:" + param_tacInTons );
+ double catchTons = RuleUtil.getTotalCatchTons(context,
+ param_species, date);
+ log.info("[TAC] catchTons = " + catchTons
+ + " >= param_tacInTons:" + param_tacInTons);
if (catchTons >= param_tacInTons) {
result = true;
}
@@ -137,39 +140,46 @@
}
return result;
}
-
+
/**
- * Si la condition est vrai alors cette action est executée avant le pas
- * de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * Si la condition est vrai alors cette action est executee avant le pas de
+ * temps de la simulation.
+ *
+ * @param context La simulation pour lequel on utilise cette regle
*/
- public void preAction(SimulationContext context, Date date, Metier metier) throws Exception {
+ public void preAction(SimulationContext context, Date date, Metier metier)
+ throws Exception {
affectation = false;
+
log.info("[TAC] preAction for: " + metier);
-
- TargetSpecies ts = metier.getMetierSeasonInfo(date.getMonth()).getSpeciesTargetSpecies(param_species);
- if(ts != null && ts.getPrimaryCatch()) {
+ log.info(" TAC atteint [TAC] preAction for: " + metier);
+ TargetSpecies ts = metier.getMetierSeasonInfo(date.getMonth())
+ .getSpeciesTargetSpecies(param_species);
+ if (ts != null && ts.getPrimaryCatch()) {
// recupere tous les metiers qui ont l'espece en capture principale =>metiers vises
- List<Metier> aimedMetiers = context.getDB().find("select distinct(metierSeasonInfo.metier) " +
- "from fr.ifremer.isisfish.entities.TargetSpecies " +
- "where species=? and primaryCatch=true", param_species);
+ // aimedMetiers ne fonctionne pas je ne sais pas pourquoi ! mais au final forbiddenMetier aura le meme effet
+ /*List<Metier> aimedMetiers = context.getDB().find("select distinct(metierSeasonInfo.metier) " +
+ "from fr.ifremer.isisfish.entities.TargetSpecies" +
+ "where species=? and primaryCatch=true", param_species);
- log.info("aimed Metier: " + aimedMetiers);
+ 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)) {
- double prop = str.getStrategyMonthInfo(date.getMonth()).getProportionMetier(metier);
+ double prop = str.getStrategyMonthInfo(date.getMonth())
+ .getProportionMetier(metier);
if (prop != 0) {
strs.add(str);
}
}
-
- for (Strategy str : strs){
- StrategyMonthInfo smi = str.getStrategyMonthInfo(date.getMonth());
-
+
+ for (Strategy str : strs) {
+ StrategyMonthInfo smi = str.getStrategyMonthInfo(date
+ .getMonth());
+
// 1er cas de figure: l'effort est reporte sur un metier de la
// meme strategie, n'ayant pas l'espece comme capture principale
// et pechant avec le meme engin
@@ -181,35 +191,38 @@
// sans consideration sur les engins, et pour lesquels la
// proportion peut etre nulle
Set<Metier> possibleMetierCase3 = new HashSet<Metier>();
-
- for (EffortDescription effort : str.getSetOfVessels().getPossibleMetiers()) {
+
+ for (EffortDescription effort : str.getSetOfVessels()
+ .getPossibleMetiers()) {
Metier newMetier = effort.getPossibleMetiers();
if (
- !aimedMetiers.contains(newMetier)
- && !metier.getName().equalsIgnoreCase("nonActiviy")
+ /*!aimedMetiers.contains(newMetier)
+ &&*/!metier.getName().equalsIgnoreCase("nonActiviy")
&& !metier.getName().equalsIgnoreCase("nonActivie")
- && !context.getMetierMonitor().getForbiddenMetier().contains(newMetier)
- ) {
+ && !metier.getName().equalsIgnoreCase(
+ "non Activite")
+ && !context.getMetierMonitor().getForbiddenMetier()
+ .contains(newMetier)) {
possibleMetierCase3.add(newMetier);
-
+
if (smi.getProportionMetier(newMetier) != 0) {
possibleMetierCase2.add(newMetier);
-
+
if (metier.getGear().equals(newMetier.getGear())) {
possibleMetierCase1.add(newMetier);
}
}
}
}
-
+
Set<Metier> possibleMetier = null;
- if (possibleMetierCase1.size() != 0){
+ if (possibleMetierCase1.size() != 0) {
log.info("[TAC] Use case 1");
possibleMetier = possibleMetierCase1;
} else if (possibleMetierCase2.size() != 0) {
log.info("[TAC] Use case 2");
possibleMetier = possibleMetierCase2;
- } else if (possibleMetierCase3.size() != 0){
+ } else if (possibleMetierCase3.size() != 0) {
log.info("[TAC] Use case 3");
possibleMetier = possibleMetierCase3;
}
@@ -219,46 +232,51 @@
// possibles dans la meme strategie si un metier possible existe
// bien la repartion est proportionnelle a l'effort deja alloue
// dans la strategie
-
- double somme=0;
- for (Metier met : possibleMetierCase1) {
+
+ double somme = 0;
+ for (Metier met : possibleMetier) {
somme += smi.getProportionMetier(met);
}
- for (Metier met : possibleMetierCase1) {
- double newProportion =
- smi.getProportionMetier(met)
- + (smi.getProportionMetier(metier)
- * smi.getProportionMetier(met) / somme);
+ for (Metier met : possibleMetier) {
+ double newProportion = smi.getProportionMetier(met)
+ + (smi.getProportionMetier(metier)
+ * smi.getProportionMetier(met) / somme);
smi.setProportionMetier(met, newProportion);
}
- smi.setProportionMetier(metier, 0); //le metier vise a alors une proportion nulle
- } else{
+ smi.setProportionMetier(metier, 0); //le metier vise a alors une proportion nulle
+ log.info("[TAC] il y a des metiers possibles");
+ } else {
log.info("[TAC] Use no activity");
-
+
// sinon on met tout dans le metier nonActivite
MetierMonitor metierMon = context.getMetierMonitor();
MatrixND mat = metierMon.getOrCreateNoActivity(date,
- ResultName.MATRIX_NO_ACTIVITY,
- siMatrix.getStrategies(date),
- siMatrix.getMetiers(date));
+ ResultName.MATRIX_NO_ACTIVITY, siMatrix
+ .getStrategies(date), siMatrix
+ .getMetiers(date));
mat.setValue(str, metier, smi.getProportionMetier(metier));
-
+
smi.getProportionMetier().setValue(metier, 0);
- }
+ }
}
}
}
-
+
/**
- * Si la condition est vrai alors cette action est executée apres le pas
- * de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * Si la condition est vrai alors cette action est executee apres le pas de
+ * temps de la simulation.
+ *
+ * @param context La simulation pour lequel on utilise cette regle
*/
- public void postAction(SimulationContext context, Date date, Metier metier) throws Exception {
+ public void postAction(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+ ResultStorage resultmanager = context.getSimulationStorage()
+ .getResultStorage();
log.info("[TAC] postAction for: " + metier);
- TargetSpecies ts = metier.getMetierSeasonInfo(date.getMonth()).getSpeciesTargetSpecies(param_species);
- if(ts != null){
- if (!affectation){
+ TargetSpecies ts = metier.getMetierSeasonInfo(date.getMonth())
+ .getSpeciesTargetSpecies(param_species);
+ if (ts != null) {
+ if (!affectation) {
// ATTENTION
// les captures pour cette metapop ne sont plus du qu'au metier
// pour qui l'espece est secondaire: elles sont affectees aux
@@ -270,36 +288,46 @@
// pour les captures)
//////
PopulationMonitor popMon = context.getPopulationMonitor();
+ log.info("popMon biomass" + popMon.getBiomass(param_species));
for (Population pop : param_species.getPopulation()) {
- // si on a deja une matrice rejet on le vide (elle vient
- // forcement de la regle taille minimale or si le tac est
- // atteint, tout va dorenavent dans les rejets et on mais
- // TOUTES les captures dans les rejets
- MatrixND discard = popMon.getDiscard(date, pop);
- if (discard != null) {
- discard.mults(0);
- }
-
- discard = popMon.getCatch(pop).copy();
- discard.setName(ResultName.MATRIX_DISCARDS_PER_STR_MET);
- popMon.addDiscard(date, pop, discard);
- log.info("[TAC] add discard for " + pop + ": " + discard);
-
- if (param_propSurvie > 0) {
- MatrixND eff = popMon.getN(pop);
- //on réajoute les survivants aux effectifs
- for (MatrixIterator i=discard.iterator(); i.next();){
- Object [] coord = i.getSemanticsCoordinates();
- eff.setValue(coord[2],coord[3],
- eff.getValue(coord[2],coord[3])+i.getValue()*param_propSurvie);
+ if (!pop.getName().equals("Population_new")) {
+ log.info("pop : " + pop.getName());
+ // si on a deja une matrice rejet on le vide (elle vient
+ // forcement de la regle taille minimale or si le tac est
+ // atteint, tout va dorenavent dans les rejets et on mais
+ // TOUTES les captures dans les rejets
+ MatrixND discard = popMon.getDiscard(date, pop);
+ log.info("discard : " + discard);
+ if (discard != null) {
+ discard.mults(0);
}
+ 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_PER_ZONE_POP);
+ popMon.addDiscard(date, pop, discard);
+ log.info("[TAC] add discard for " + pop + ": "
+ + discard);
+ // ne manquerait-il pas
+ resultmanager.addResult(date, pop, discard);
+ if (param_propSurvie > 0) {
+ MatrixND eff = popMon.getN(pop);
+ //on réajoute les survivants aux effectifs
+ for (MatrixIterator i = discard.iterator(); i
+ .next();) {
+ Object[] coord = i.getSemanticsCoordinates();
+ eff.setValue(coord[2], coord[3], eff.getValue(
+ coord[2], coord[3])
+ + i.getValue() * param_propSurvie);
+ }
+ }
+
}
+ // on a affecte une fois cette meta pop au rejet il ne faut pas
+ // le refaire
+ affectation = true;
}
-
- // on a affecte une fois cette meta pop au rejet il ne faut pas
- // le refaire
- affectation=true;
}
}
}
Modified: isis-fish/trunk/src/test/resources/test-database/rules/TailleMin.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/TailleMin.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/rules/TailleMin.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -2,30 +2,30 @@
import static org.codelutin.i18n.I18n._;
+import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
import scripts.ResultName;
import scripts.SiMatrix;
-
-import java.io.Writer;
-import java.util.List;
-
-import org.codelutin.math.matrix.*;
-
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.entities.MetierSeasonInfo;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.Species;
+import fr.ifremer.isisfish.entities.TargetSpecies;
+import fr.ifremer.isisfish.rule.AbstractRule;
import fr.ifremer.isisfish.simulator.PopulationMonitor;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.entities.*;
-import fr.ifremer.isisfish.rule.AbstractRule;
-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)
-
/**
- * TailleMin.java
- *
+ * Cette methode remplace aussi TailleMinSurvieRejet si propSurvie est > 0
+ *
* Created: 30 novembre 2006
*
* @author anonymous <anonymous at labs.libre-entreprise.org>
@@ -34,27 +34,23 @@
* Last update: $Date: 2007-01-24 18:25:34 $
* by : $Author: bpoussin $
*/
-
-/**
- * Cette methode remplace aussi TailleMinSurvieRejet si propSurvie est > 0
- */
public class TailleMin extends AbstractRule {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(TailleMin.class);
- @Doc(value="do the doc of param beginDate")
+ @Doc(value = "Begin date")
public Date param_beginDate = new Date(0);
- @Doc(value="do the doc of param endDate")
+ @Doc(value = "End date")
public Date param_endDate = new Date(119);
- @Doc(value="do the doc of param species")
+ @Doc(value = "Affected species")
public Species param_species = null;
- @Doc(value="do the doc of param TailleMin")
+ @Doc(value = "Taille minimale")
public double param_TailleMin = 27;
- @Doc(value="do the doc of param propSurvie")
+ @Doc(value = "Proportion de survie")
public double param_propSurvie = 0;
- public String [] necessaryResult = {
+ public String[] necessaryResult = {
// put here all necessary result for this rule
// example:
// ResultName.MATRIX_BIOMASS,
@@ -67,21 +63,22 @@
/**
* Permet d'afficher a l'utilisateur une aide sur la regle.
+ *
* @return L'aide ou la description de la regle
*/
public String getDescription() throws Exception {
- // TODO
- return _("TODO description rule");
+ return _("");
}
-
+
/**
* 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 context La simulation pour lequel on utilise cette regle
*/
public void init(SimulationContext context) throws Exception {
}
-
+
/**
* @param context
* @param date
@@ -93,16 +90,18 @@
MetierSeasonInfo info = metier.getMetierSeasonInfo(date.getMonth());
TargetSpecies target = info.getSpeciesTargetSpecies(species);
boolean result = target != null;
-
+
return result;
}
-
+
/**
* La condition qui doit etre vrai pour faire les actions
- * @param simulation La simulation pour lequel on utilise cette regle
+ *
+ * @param context La simulation pour lequel on utilise cette regle
* @return vrai si on souhaite que les actions soit faites
*/
- public boolean condition(SimulationContext context, Date date, Metier metier) throws Exception {
+ public boolean condition(SimulationContext context, Date date, Metier metier)
+ throws Exception {
log.info("Recherche si la taille Minimale s'applique");
boolean result = true;
if (date.before(param_beginDate)) {
@@ -110,56 +109,62 @@
} else if (date.after(param_endDate)) {
result = false;
} else if (isCaptureDate(date, param_species, metier) != true) {
- result=false;
+ result = false;
}
log.info("fin de condition TailleMin:" + result);
return result;
-
+
// fin
-
+
/*
-writeln("Recherche si la taille Minimale s'applique (oldValue="+oldValue);
-var metier=p.metier;
-var result = true;
-if(oldValue != undefined)
- result = oldValue;
-else if (Regle_libUtil.isCaptureDate(p.date,p.metapop, metier)!=true)
- result=false;
-else if(p.date.before(p.dateDeb))
- result = false;
-else if(p.date.after(p.dateFin))
- result = false;
+ writeln("Recherche si la taille Minimale s'applique (oldValue="+oldValue);
+ var metier=p.metier;
+ var result = true;
+ if(oldValue != undefined)
+ result = oldValue;
+ else if (Regle_libUtil.isCaptureDate(p.date,p.metapop, metier)!=true)
+ result=false;
+ else if(p.date.before(p.dateDeb))
+ result = false;
+ else if(p.date.after(p.dateFin))
+ result = false;
-writeln("fin de condition TailleMin:"+result);
-return result;
-*/
+ writeln("fin de condition TailleMin:"+result);
+ return result;
+ */
}
-
+
/**
- * Si la condition est vrai alors cette action est executée avant le pas
- * de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * Si la condition est vrai alors cette action est executée avant le pas de
+ * temps de la simulation.
+ *
+ * @param context La simulation pour lequel on utilise cette regle
*/
- public void preAction(SimulationContext context, Date date, Metier metier) throws Exception {
+ public void preAction(SimulationContext context, Date date, Metier metier)
+ throws Exception {
// nothing
}
-
+
/**
- * Si la condition est vrai alors cette action est executée apres le pas
- * de temps de la simulation.
- * @param simulation La simulation pour lequel on utilise cette regle
+ * Si la condition est vrai alors cette action est executée apres le pas de
+ * temps de la simulation.
+ *
+ * @param context La simulation pour lequel on utilise cette regle
*/
- public void postAction(SimulationContext context, Date date, Metier metier) throws Exception {
- log.info("*$*$*$* TailleMin.actionApres:" + date + " metapop:" + param_species + " metier:" + metier);
+ public void postAction(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+ log.info("*$*$*$* TailleMin.actionApres:" + date + " metapop:"
+ + param_species + " metier:" + metier);
- if(isCaptureDate(date, param_species, metier)){
- log.info("*$*$*$* ok affecte capture infÃ?rieure Ã? TailleMin au rejet");
+ if (isCaptureDate(date, param_species, metier)) {
+ log
+ .info("*$*$*$* ok affecte capture infÃ?rieure Ã? TailleMin au rejet");
// ATTENTION
// les captures pour cette metapop ne sont plus du qu'au metier pour qui
// l'espece est secondaire: elles sont affectees aux rejets
-
+
//pb : ne se fait pas par metier
//il faut une matrice pour chaques pas de temps qui stocke les rejets
//par metier, par metapop et par classes d'age (comme pour les captures)
@@ -169,67 +174,69 @@
PopulationMonitor popMon = context.getPopulationMonitor();
SiMatrix siMatrix = SiMatrix.getSiMatrix(context);
List<Population> pops = siMatrix.getPopulations(date);
-
+
for (Population pop : pops) {
if (pop.getSpecies().equals(param_species)) {
if (popMon.getDiscard(date, pop) == null) {
MatrixND discard = popMon.getCatch(pop).copy();
MatrixND eff = popMon.getN(pop);
-
- for (MatrixIterator i=discard.iterator(); i.next();) {
- Object [] coordonnees = i.getSemanticsCoordinates();
- PopulationGroup group = (PopulationGroup)coordonnees[2];
+
+ for (MatrixIterator i = discard.iterator(); i.next();) {
+ Object[] coordonnees = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) coordonnees[2];
if (group.getLength() >= param_TailleMin) {
i.setValue(0);
} else if (param_propSurvie > 0) {
eff.setValue(coordonnees[2], coordonnees[3],
- eff.getValue(coordonnees[2], coordonnees[3])
- + i.getValue() * param_propSurvie);
+ eff.getValue(coordonnees[2],
+ coordonnees[3])
+ + i.getValue()
+ * 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);
}
}
}
-
+
log.info("fin de affecterCaptureRejetTailleMin");
-
- //on a affecte une fois cette meta pop au rejet il ne faut pas le refaire
+
+ //on a affecte une fois cette meta pop au rejet il ne faut pas le refaire
}
// fin
-
+
/*
-writeln("*$*$*$* TailleMin.actionApres:"+p.date+" metapop:"+p.metapop+" metier:"+p.metier);
-if(Regle_libUtil.isCaptureDate(p.date,p.metapop, p.metier)){
- writeln("*$*$*$* ok affecte capture infÃ?rieure Ã? TailleMin au rejet");
- // ATTENTION
- // les captures pour cette metapop ne sont plus du qu'au metier pour qui
- // l'espece est secondaire: elles sont affectees aux rejets
+ writeln("*$*$*$* TailleMin.actionApres:"+p.date+" metapop:"+p.metapop+" metier:"+p.metier);
+ if(Regle_libUtil.isCaptureDate(p.date,p.metapop, p.metier)){
+ writeln("*$*$*$* ok affecte capture infÃ?rieure Ã? TailleMin au rejet");
+ // ATTENTION
+ // les captures pour cette metapop ne sont plus du qu'au metier pour qui
+ // l'espece est secondaire: elles sont affectees aux rejets
- //pb : ne se fait pas par metier
- //il faut une matrice pour chaques pas de temps qui stocke les rejets
- //par metier, par metapop et par classes d'age (comme pour les captures)
- //////
-writeln("deb de affecterCaptureREJETTailleMin");
-var suivi = null;
+ //pb : ne se fait pas par metier
+ //il faut une matrice pour chaques pas de temps qui stocke les rejets
+ //par metier, par metapop et par classes d'age (comme pour les captures)
+ //////
+ writeln("deb de affecterCaptureREJETTailleMin");
+ var suivi = null;
-//recherche du suivi pour les pop qui ont une certaine meta pop
-for(var i=0; i< suiviePop.size(); i++){
- if(suiviePop.get(i).getPop().getMetaPopulation().equals(metapop)){
+ //recherche du suivi pour les pop qui ont une certaine meta pop
+ for(var i=0; i< suiviePop.size(); i++){
+ if(suiviePop.get(i).getPop().getMetaPopulation().equals(metapop)){
suivi = suiviePop.get(i);
var populations=suivi.getPop();
- //si on a pas deja creer le rejet on le cree et on en fait un resultat
+ //si on a pas deja creer le rejet on le cree et on en fait un resultat
var matRejet = suivi.getRejet(date);
if (matRejet==null){
var matRejetBis = MatrixFactory.create(suivi.getCapture());
var eff=suivi.getN();
-//on encapsule les objets des 4 dimensions de la matrice capture
+ //on encapsule les objets des 4 dimensions de la matrice capture
for (var iiterateur=matRejetBis.iterator();iiterateur.next();){
var coordonnees=iiterateur.getSemanticsCoordinates();
var classe=coordonnees[2];
@@ -243,18 +250,18 @@
matRejetBis.setName("Rejet par metier");
suivi.addRejet(date,matRejetBis);
}
- }
-}
+ }
+ }
-writeln("fin de affecterCaptureRejetTailleMin");
+ writeln("fin de affecterCaptureRejetTailleMin");
- //on a affecte une fois cette meta pop au rejet il ne faut pas le refaire
-}
+ //on a affecte une fois cette meta pop au rejet il ne faut pas le refaire
+ }
-return p.gestionMetier;
-*/
+ return p.gestionMetier;
+ */
}
}
Added: isis-fish/trunk/src/test/resources/test-database/rules/TotalClosure.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/rules/TotalClosure.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/rules/TotalClosure.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,119 @@
+package rules;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixND;
+
+import scripts.ResultName;
+import scripts.SiMatrix;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.entities.StrategyMonthInfo;
+import fr.ifremer.isisfish.rule.AbstractRule;
+import fr.ifremer.isisfish.simulator.MetierMonitor;
+import fr.ifremer.isisfish.simulator.SimulationContext;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.types.Month;
+
+/**
+ * Remplace aussi Cantonnement Engin.
+ *
+ * Created: 29 aout 2007
+ * @author sigrid
+ * @version $Revision$
+ */
+public class TotalClosure extends AbstractRule {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(TotalClosure.class);
+
+ public Date param_beginDate = new Date(100);
+ public Date param_endDate = new Date(119);
+ public Month param_beginMonth = Month.JANUARY;
+ public Month param_endMonth = Month.JANUARY;
+
+ public String[] necessaryResult = {
+ ResultName.MATRIX_NO_ACTIVITY
+ };
+
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+ public String getDescription() throws Exception {
+ return _("Total closure of the fishery");
+ }
+
+ /**
+ * Appelé au démarrage de la simulation, cette methode permet d'initialiser des valeurs.
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void init(SimulationContext context) throws Exception {
+ }
+
+ /**
+ * La condition qui doit etre vrai pour faire les actions.
+ * @param context La simulation pour lequel on utilise cette regle
+ * @return vrai si on souhaite que les actions soit faites
+ */
+ public boolean condition(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+ boolean result = true;
+ if (date.before(param_beginDate)) {
+ result = false;
+ } else if (date.after(param_endDate)) {
+ result = false;
+ }
+
+ if (date.getMonth().before(param_beginMonth)) {
+ result = false;
+ } else if (date.getMonth().after(param_endMonth)) {
+ result = false;
+ }
+ return result;
+ }
+
+ /**
+ * Si la condition est vrai alors cette action est executee avant le pas
+ * de temps de la simulation.
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void preAction(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+ MetierMonitor metierMon = context.getMetierMonitor();
+
+ //MetierSeasonInfo infoMetier = metier.getMetierSeasonInfo(date
+ // .getMonth());
+
+ SiMatrix siMatrix = SiMatrix.getSiMatrix(context);
+ MatrixND noActivity = metierMon.getOrCreateNoActivity(date,
+ ResultName.MATRIX_NO_ACTIVITY, siMatrix.getStrategies(date),
+ siMatrix.getMetiers(date));
+ metierMon.addforbiddenMetier(metier);
+ List<Strategy> strategies = siMatrix.getStrategies(date);
+
+ for (Strategy str : strategies) {
+ StrategyMonthInfo info = str.getStrategyMonthInfo(date.getMonth());
+ double prop = info.getProportionMetier(metier);
+ if (prop != 0) {
+ noActivity.setValue(str, metier, prop);
+ info.setProportionMetier(metier, 0);
+ }
+ }
+ }
+
+ /**
+ * Si la condition est vrai alors cette action est executee apres le pas
+ * de temps de la simulation.
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void postAction(SimulationContext context, Date date, Metier metier)
+ throws Exception {
+ // nothing
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/rules/TotalClosure.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: isis-fish/trunk/src/test/resources/test-database/scripts/GravityModel.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/scripts/GravityModel.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/scripts/GravityModel.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -1,6 +1,6 @@
/* *##%
- * Copyright (C) 2006
- * Code Lutin, C?dric Pineau, Benjamin Poussin
+ * Copyright (C) 2006 - 2009
+ * Code Lutin, Cédric 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
@@ -17,21 +17,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*##%*/
-/* *
- * GravityModel.java
- *
- * Created: 4 sept. 06 15:49:08
- *
- * @author poussin
- * @version $Revision: 1.9 $
- *
- * Last update: $Date: 2007-03-01 17:16:12 $
- * by : $Author: bpoussin $
- */
-
package scripts;
-import static org.codelutin.i18n.I18n._;
import static org.codelutin.i18n.I18n.n_;
import java.util.Collection;
@@ -58,17 +45,22 @@
import fr.ifremer.isisfish.types.Month;
import fr.ifremer.isisfish.types.TimeUnit;
-
/**
+ * GravityModel.java
+ *
+ * Created: 4 sept. 06 15:49:08
+ *
* @author poussin
+ * @version $Revision: 1.9 $
*
+ * Last update: $Date: 2007-03-01 17:16:12 $
+ * by : $Author: bpoussin $
*/
-
public class GravityModel {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(GravityModel.class);
-
+
protected SimulationContext context = null;
protected TopiaContext db = null;
protected SiMatrix siMatrix = null;
@@ -76,20 +68,24 @@
/**
* Method used to get GravityModel used for simulation
- * @param context context simulation
+ *
+ * @param context
+ * context simulation
* @return GravityModel or null if no GravityModel created for simulation
*/
public static GravityModel getGravityModel(SimulationContext context) {
- GravityModel result = (GravityModel)context.getValue(GravityModel.class.getName());
+ GravityModel result = (GravityModel) context
+ .getValue(GravityModel.class.getName());
return result;
}
-
- private static void setGravityModel(SimulationContext context, GravityModel gravityModel) {
+
+ private static void setGravityModel(SimulationContext context,
+ GravityModel gravityModel) {
context.setValue(GravityModel.class.getName(), gravityModel);
}
-
-
- public GravityModel(SimulationContext context, SiMatrix siMatrix) throws TopiaException, StorageException{
+
+ public GravityModel(SimulationContext context, SiMatrix siMatrix)
+ throws TopiaException, StorageException {
this.context = context;
this.db = context.getDB();
this.resultManager = context.getSimulationStorage().getResultStorage();
@@ -105,103 +101,95 @@
// MatrixFishingTimePerMonthPerVessel
//////////////////////////////////////////////////////////////////////
- public MatrixND matrixFishingTimePerMonthPerVessel(Date date) throws TopiaException{
+ public MatrixND matrixFishingTimePerMonthPerVessel(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_FISHING_TIME_PER_MONTH_PER_VESSEL,
- 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 = siMatrix.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 = fishingTimePerMonthPerVessel(str, metier, date);
result.setValue(str, metier, value);
}
}
-
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = fishingTimePerMonthPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
/**
- * implant? suivant document ModifTable3PourBP25-07-2006.doc
- * FishingTimePerMonthPerVessel[str,met,month] = FishingTimePerTrip[str,met,month]NbTripsPerMonth[str,month]
-
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * FishingTimePerMonthPerVessel[str,met,month] =
+ * FishingTimePerTrip[str,met,month]NbTripsPerMonth[str,month]
+ *
* @param str
* @param metier
* @param date
* @return
*/
- private double fishingTimePerMonthPerVessel(Strategy str, Metier metier, Date date) {
- Month month = date.getMonth();
- double timePerTrip = siMatrix.fishingTimePerTrip(str, metier, date);
- double nbTrip = str.getStrategyMonthInfo(month).getNumberOfTrips();
- return timePerTrip * nbTrip;
- }
+ private double fishingTimePerMonthPerVessel(Strategy str, Metier metier,
+ Date date) {
+ Month month = date.getMonth();
+ double timePerTrip = siMatrix.fishingTimePerTrip(str, metier, date);
+ double nbTrip = str.getStrategyMonthInfo(month).getNumberOfTrips();
+ return timePerTrip * nbTrip;
+ }
-
//////////////////////////////////////////////////////////////////////
// matrixFuelCostsOfTravelPerVessel
//////////////////////////////////////////////////////////////////////
- public MatrixND matrixFuelCostsOfTravelPerVessel(Date date) throws TopiaException{
+ public MatrixND matrixFuelCostsOfTravelPerVessel(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_FUEL_COSTS_OF_TRAVEL_PER_VESSEL,
- 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 = siMatrix.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 = fuelCostsOfTravelPerVessel(str, metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = fuelCostsOfTravelPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
/**
- * 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
* @param date
* @return
*/
- private double fuelCostsOfTravelPerVessel(Strategy str, Metier metier, Date date) {
+ private double fuelCostsOfTravelPerVessel(Strategy str, Metier metier,
+ Date date) {
Month month = date.getMonth();
double nbTrip = str.getStrategyMonthInfo(month).getNumberOfTrips();
Collection<Zone> zone = metier.getMetierSeasonInfo(month).getZone();
// TODO: verifier que travelTime est bien en heure, car le unitFuelCost est l'unite par heure
- double travelTime = siMatrix.travelTimePerTrip(str.getSetOfVessels(), zone);
- double unitFuelCost = str.getSetOfVessels().getVesselType().getUnitFuelCostOfTravel();
+ double travelTime = siMatrix.travelTimePerTrip(str.getSetOfVessels(),
+ zone);
+ double unitFuelCost = str.getSetOfVessels().getVesselType()
+ .getUnitFuelCostOfTravel();
return nbTrip * travelTime * unitFuelCost;
}
@@ -210,94 +198,87 @@
// matrixCostsOfFishingPerVessel
//////////////////////////////////////////////////////////////////////
- public MatrixND matrixCostsOfFishingPerVessel(Date date) throws TopiaException{
+ public MatrixND matrixCostsOfFishingPerVessel(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_COSTS_OF_FISHING_PER_VESSEL,
- 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 = siMatrix.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 = costsOfFishingPerVessel(str, metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = costsOfFishingPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
/**
- * implant? suivant document ModifTable3PourBP25-07-2006.doc
- * CostsOfFishingPerVessel[str,met,month]= FishingTimePerMonthPerVessel [str,met,month] {NbFishingOperationsPerDay[sov,met] UnitCostsOfFishing[sov,met] / 24}
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * CostsOfFishingPerVessel[str,met,month]= FishingTimePerMonthPerVessel
+ * [str,met,month] {NbFishingOperationsPerDay[sov,met]
+ * UnitCostsOfFishing[sov,met] / 24}
*
* @param str
* @param metier
* @param date
* @return
*/
- private double costsOfFishingPerVessel(Strategy str, Metier metier, Date date) {
+ private double costsOfFishingPerVessel(Strategy str, Metier metier,
+ Date date) {
double fishingTime = fishingTimePerMonthPerVessel(str, metier, date);
- EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(metier);
+ EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+ metier);
int nbOperation = 0;
double unitCostOfFishing = 0;
- if(effort != null){
+ if (effort != null) {
nbOperation = effort.getFishingOperation();
unitCostOfFishing = effort.getUnitCostOfFishing();
}
- return fishingTime * ( nbOperation * unitCostOfFishing / TimeUnit.HOUR_PER_DAY);
+ return fishingTime
+ * (nbOperation * unitCostOfFishing / TimeUnit.HOUR_PER_DAY);
}
//////////////////////////////////////////////////////////////////////
// matrixFuelCostsPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixFuelCostsPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixFuelCostsPerVessel(Date date) throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_FUEL_COSTS_PER_VESSEL,
- 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 = siMatrix.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 = fuelCostsPerVessel(str, metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = fuelCostsPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
/**
- * implant? suivant document ModifTable3PourBP25-07-2006.doc
- * FuelCostsPerVessel[str,met,month] = FuelCostsOfTravelPerVessel [sov,met,month] + CostsOfFishingPerVessel [str,met,month]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * FuelCostsPerVessel[str,met,month] = FuelCostsOfTravelPerVessel
+ * [sov,met,month] + CostsOfFishingPerVessel [str,met,month]
*
* @param str
* @param metier
@@ -314,52 +295,58 @@
//////////////////////////////////////////////////////////////////////
// matrixRepairAndMaintenanceGearCostsPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixRepairAndMaintenanceGearCostsPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixRepairAndMaintenanceGearCostsPerVessel(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_REPAIR_AND_MAINTENANCE_GEAR_COSTS_PER_VESSEL,
- new List[]{strategies, metiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ new 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 = siMatrix.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 = repairAndMaintenanceGearCostsPerVessel(str, metier, date);
+ double value = repairAndMaintenanceGearCostsPerVessel(str,
+ metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = repairAndMaintenanceGearCostsPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
+ // for(Strategy str : strategies){
+ // metiers = siMatrix.getMetiers(str, date);
+ // for(Metier metier : metiers) {
+ // double value = repairAndMaintenanceGearCostsPerVessel(str, metier, date);
+ // result.setValue(str, metier, value);
+ // }
+ // }
return result;
}
/**
- * implant? suivant document ModifTable3PourBP25-07-2006.doc
- * RepairAndMaintenanceGearCostsPerVessel[str,met,month]?=?FishingTimePerMonthPerVessel[str,met,month] *RepairAndMaintenanceGearCostsPerDay[sov,met]/NbHoursPerDay
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * RepairAndMaintenanceGearCostsPerVessel[str,met,month] =
+ * FishingTimePerMonthPerVessel[str,met,month]
+ * *RepairAndMaintenanceGearCostsPerDay[sov,met]/NbHoursPerDay
*
* @param str
* @param metier
* @param date
* @return
*/
- private double repairAndMaintenanceGearCostsPerVessel(Strategy str, Metier metier, Date date) {
+ private double repairAndMaintenanceGearCostsPerVessel(Strategy str,
+ Metier metier, Date date) {
double fishingTime = fishingTimePerMonthPerVessel(str, metier, date);
- EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(metier);
+ EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+ metier);
double repair = 0;
- if(effort != null){
+ if (effort != null) {
repair = effort.getRepairAndMaintenanceGearCost();
}
// FIXME verifier qu'il faut bien retourner 0, si pas d'effort
@@ -369,52 +356,50 @@
//////////////////////////////////////////////////////////////////////
// matrixOtherRunningCostsPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixOtherRunningCostsPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixOtherRunningCostsPerVessel(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_OTHER_RUNNING_COSTS_PER_VESSEL,
- 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 = siMatrix.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 = otherRunningCostsPerVessel(str, metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = otherRunningCostsPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
/**
- * implant? suivant document ModifTable3PourBP25-07-2006.doc
- * OtherRunningCostsPerVessel[str,met,month]=?FishingTimePerMonthPerVessel[str,met,month]*OtherRunningCostsPerDay[sov,met]/ NbHoursPerDay
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * OtherRunningCostsPerVessel[str,met,month] =
+ * FishingTimePerMonthPerVessel[str,met,month]*OtherRunningCostsPerDay[sov,met]/
+ * NbHoursPerDay
*
* @param str
* @param metier
* @param date
* @return
*/
- private double otherRunningCostsPerVessel(Strategy str, Metier metier, Date date) {
+ private double otherRunningCostsPerVessel(Strategy str, Metier metier,
+ Date date) {
double fishingTime = fishingTimePerMonthPerVessel(str, metier, date);
- EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(metier);
+ EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+ metier);
double otherCosts = 0;
- if(effort != null){
+ if (effort != null) {
otherCosts = effort.getOtherRunningCost();
}
// FIXME verifier qu'il faut bien retourner 0, si pas d'effort
@@ -424,156 +409,112 @@
//////////////////////////////////////////////////////////////////////
// matrixSharedNotFixedCostsPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixSharedNotFixedCostsPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixSharedNotFixedCostsPerVessel(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_SHARED_NOT_FIXED_COSTS_PER_VESSEL,
- 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 = siMatrix.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 = sharedNotFixedCostsPerVessel(str, metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = sharedNotFixedCostsPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
/**
- * 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
* @param date
* @return
*/
- private double sharedNotFixedCostsPerVessel(Strategy str, Metier metier, Date date) {
+ private double sharedNotFixedCostsPerVessel(Strategy str, Metier metier,
+ Date date) {
double fuelCostsPerVessel = fuelCostsPerVessel(str, metier, date);
- double otherRunningCostsPerVessel = otherRunningCostsPerVessel(str, metier, date);
+ double otherRunningCostsPerVessel = otherRunningCostsPerVessel(str,
+ metier, date);
return fuelCostsPerVessel + otherRunningCostsPerVessel;
- }
+ }
//////////////////////////////////////////////////////////////////////
- // matrixSharedFixedCostsPerVesselPerMet
- //////////////////////////////////////////////////////////////////////
-// Supprime avec Steph le 20070227
-// public MatrixND matrixSharedFixedCostsPerVesselPerMet(Date date) throws TopiaException{
-// List<Strategy> strategies = siMatrix.getStrategies(date);
-//
-// MatrixND result = MatrixFactory.getInstance().create(
-// ResultName.MATRIX_SHARED_FIXED_COSTS_PER_VESSEL_PER_MET,
-// new List[]{strategies},
-// new String[]{n_("Strategies")});
-//
-// for (int s=0; s < strategies.size(); s++) {
-// Strategy str = strategies.get(s);
-// double value = sharedFixedCostsPerVesselPerMet(str, date);
-// result.setValue(s, value);
-// }
-//// for(Strategy str : strategies){
-//// double value = sharedFixedCostsPerVesselPerMet(str, date);
-//// result.setValue(str, value);
-//// }
-//
-// return result;
-// }
-//
-// /**
-// * implant? suivant document ModifTable3PourBP25-07-2006.doc
-// * SharedFixedCostsPerVesselPerMet [str,month]=FixedCostsPerMonth[sov]/NbMet[sov]
-// *
-// * @param str
-// * @param date
-// * @return
-// */
-// private double sharedFixedCostsPerVesselPerMet(Strategy str, Date date) {
-// SetOfVessels sov = str.getSetOfVessels();
-// double fixedCosts = sov.getFixedCosts();
-// int nbMet = sov.sizePossibleMetiers();
-//
-// return fixedCosts / (double)nbMet;
-// }
-
- //////////////////////////////////////////////////////////////////////
// matrixGrossValueOfLandingsPerSpeciesPerStrategyMet
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixGrossValueOfLandingsPerSpeciesPerStrategyMet(Date date) throws TopiaException{
+ public MatrixND matrixGrossValueOfLandingsPerSpeciesPerStrategyMet(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
List<Population> pops = siMatrix.getPopulations(date);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET,
- new List[]{strategies, metiers, pops},
- new String[]{n_("Strategies"), n_("Metiers"), n_("Populations")});
+ MatrixND result = MatrixFactory
+ .getInstance()
+ .create(
+ ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET,
+ new List[] { strategies, metiers, pops },
+ new String[] { n_("Strategies"), n_("Metiers"),
+ n_("Populations") });
- for (int p=0; p < pops.size(); p++) {
+ for (int p = 0; p < pops.size(); p++) {
Population pop = pops.get(p);
- for (int s=0; s < strategies.size(); s++) {
+ for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = siMatrix.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 = grossValueOfLandingsPerSpeciesPerStrategyMet(str, metier, pop, date);
+ double value = grossValueOfLandingsPerSpeciesPerStrategyMet(
+ str, metier, pop, date);
result.setValue(str, metier, pop, value);
}
}
}
-// for(Population pop : pops){
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = grossValueOfLandingsPerSpeciesPerStrategyMet(str, metier, pop, date);
-// result.setValue(str, metier, pop, value);
-// }
-// }
-// }
-
return result;
}
/**
- * implant? suivant document ModifTable3PourBP25-07-2006.doc
- * GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month]?=?sum over classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet [str,met,pop,cl,month] ?DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
-nth]
- * GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month] = sum over classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet [str,met,pop,cl,month] -DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
-nth])]
- *
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month]=sum over
+ * classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet
+ * [str,met,pop,cl,month] ?DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
+ * nth] GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month] =
+ * sum over classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet
+ * [str,met,pop,cl,month] -DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
+ * nth])]
+ *
* @param str
* @param metier
* @param pop
* @param date
* @return
*/
- private double grossValueOfLandingsPerSpeciesPerStrategyMet(Strategy str, Metier metier, Population pop, Date date) {
+ private double grossValueOfLandingsPerSpeciesPerStrategyMet(Strategy str,
+ Metier metier, Population pop, Date date) {
List<PopulationGroup> groups = pop.getPopulationGroup();
double result = 0;
- for(PopulationGroup group : groups){
+ for (PopulationGroup group : groups) {
double price = group.getPrice();
Collection<Zone> zones = pop.getPopulationZone();
- for(Zone zone : zones){
- double catchWeight = getCatchWeightPerStrMetPerZonePop(str, metier, group, zone, date);
- double discardsWeight = getDiscardsWeightPerStrMet(str, metier, group, zone, date);
+ for (Zone zone : zones) {
+ double catchWeight = getCatchWeightPerStrMetPerZonePop(str,
+ metier, group, zone, date);
+ double discardsWeight = getDiscardsWeightPerStrMet(str, metier,
+ group, zone, date);
// FIXME demander/verifier que ce le bon calcule
result += price * (catchWeight - discardsWeight);
}
@@ -589,10 +530,12 @@
* @param date
* @return
*/
- private double getCatchWeightPerStrMetPerZonePop(Strategy str, Metier metier, PopulationGroup group, Zone zone, Date date) {
- MatrixND mat = resultManager.getMatrix(date, group.getPopulation(), ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
- double result = 0;
- if(mat != null){
+ private double getCatchWeightPerStrMetPerZonePop(Strategy str,
+ Metier metier, PopulationGroup group, Zone zone, Date date) {
+ MatrixND mat = resultManager.getMatrix(date, group.getPopulation(),
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ double result = 0;
+ if (mat != null) {
result = mat.getValue(str, metier, group, zone);
}
return result;
@@ -606,10 +549,12 @@
* @param date
* @return
*/
- 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_PER_ZONE_POP);
- double result = 0;
- if(mat != null){
+ 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_PER_ZONE_POP);
+ double result = 0;
+ if (mat != null) {
result = mat.getValue(str, metier, group, zone);
}
return result;
@@ -618,33 +563,28 @@
//////////////////////////////////////////////////////////////////////
// matrixGrossValueOfLandingsPerStrategyMet
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixGrossValueOfLandingsPerStrategyMet(Date date) throws TopiaException{
+
+ public MatrixND matrixGrossValueOfLandingsPerStrategyMet(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_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 = siMatrix.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 = grossValueOfLandingsPerStrategyMet(str, metier, date);
+ double value = grossValueOfLandingsPerStrategyMet(str, metier,
+ date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = grossValueOfLandingsPerStrategyMet(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
-
+
return result;
}
@@ -653,14 +593,16 @@
* @param metier
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double grossValueOfLandingsPerStrategyMet(Strategy str, Metier metier, Date date) throws TopiaException {
+ private double grossValueOfLandingsPerStrategyMet(Strategy str,
+ Metier metier, Date date) throws TopiaException {
List<Population> pops = siMatrix.getPopulations(date);
double result = 0;
- for(int i=0; i<pops.size(); i++){
- Population pop = (Population)pops.get(i);
- result += grossValueOfLandingsPerSpeciesPerStrategyMet(str, metier, pop, date);
+ for (int i = 0; i < pops.size(); i++) {
+ Population pop = (Population) pops.get(i);
+ result += grossValueOfLandingsPerSpeciesPerStrategyMet(str, metier,
+ pop, date);
}
return result;
}
@@ -668,433 +610,450 @@
//////////////////////////////////////////////////////////////////////
// matrixGrossValueOfLandingsPerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixGrossValueOfLandingsPerStrategyMetPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixGrossValueOfLandingsPerStrategyMetPerVessel(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
- new List[]{strategies, metiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ MatrixND result = MatrixFactory
+ .getInstance()
+ .create(
+ ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
+ new List[] { strategies, metiers },
+ new String[] { n_("Strategies"), n_("Metiers") });
- for (int s=0; s < strategies.size(); s++) {
+ for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = siMatrix.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 = grossValueOfLandingsPerStrategyMetPerVessel(str, metier, date);
+ double value = grossValueOfLandingsPerStrategyMetPerVessel(str,
+ metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = grossValueOfLandingsPerStrategyMetPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
/**
- * 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
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double grossValueOfLandingsPerStrategyMetPerVessel(Strategy str, Metier metier, Date date) throws TopiaException {
- double grossValueOfLandingsPerStrategyMet = grossValueOfLandingsPerStrategyMet(str, metier, date);
+ private double grossValueOfLandingsPerStrategyMetPerVessel(Strategy str,
+ Metier metier, Date date) throws TopiaException {
+ double grossValueOfLandingsPerStrategyMet = grossValueOfLandingsPerStrategyMet(
+ str, metier, date);
// FIXME verifier que c bien cette donn?e qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
double proportionSetOfVessels = str.getProportionSetOfVessels();
double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
- double grossValueOfLandingsOtherSpeciesPerStrategyMet = grossValueOfLandingsOtherSpeciesPerStrategyMet(str,metier,date);
+ double grossValueOfLandingsOtherSpeciesPerStrategyMet = grossValueOfLandingsOtherSpeciesPerStrategyMet(
+ str, metier, date);
-
- return (grossValueOfLandingsPerStrategyMet + grossValueOfLandingsOtherSpeciesPerStrategyMet) / (proportionSetOfVessels * numberOfVessels);
+ return (grossValueOfLandingsPerStrategyMet + grossValueOfLandingsOtherSpeciesPerStrategyMet)
+ / (proportionSetOfVessels * numberOfVessels);
}
//////////////////////////////////////////////////////////////////////
// matrixNetValueOfLandingsPerStrategyMet
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixNetValueOfLandingsPerStrategyMet(Date date) throws TopiaException{
+
+ public MatrixND matrixNetValueOfLandingsPerStrategyMet(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_NET_VALUE_OF_LANDINGS_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 = siMatrix.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 = netValueOfLandingsPerStrategyMet(str, metier, date);
+ double value = netValueOfLandingsPerStrategyMet(str, metier,
+ date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = netValueOfLandingsPerStrategyMet(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
/**
- * 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
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double netValueOfLandingsPerStrategyMet(Strategy str, Metier metier, Date date) throws TopiaException {
- double grossValue = grossValueOfLandingsPerStrategyMet(str, metier, date);
- EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(metier);
+ private double netValueOfLandingsPerStrategyMet(Strategy str,
+ Metier metier, Date date) throws TopiaException {
+ double grossValue = grossValueOfLandingsPerStrategyMet(str, metier,
+ date);
+ EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+ metier);
double landingCost = 1;
// FIXME demander si le metier n'a pas d'effort s'il faut que landingCost soit bien a 1
- if(effort != null){
+ if (effort != null) {
landingCost -= effort.getLandingCosts();
}
- double grossValueOfLandingsOtherSpeciesPerStrategyMet = grossValueOfLandingsOtherSpeciesPerStrategyMet(str,metier,date);
-
- double result = (grossValue + grossValueOfLandingsOtherSpeciesPerStrategyMet)* landingCost;
+ double grossValueOfLandingsOtherSpeciesPerStrategyMet = grossValueOfLandingsOtherSpeciesPerStrategyMet(
+ str, metier, date);
+
+ double result = (grossValue + grossValueOfLandingsOtherSpeciesPerStrategyMet)
+ * landingCost;
return result;
- }
+ }
- private double grossValueOfLandingsOtherSpeciesPerStrategyMet(Strategy str, Metier metier, Date date) throws TopiaException {
+ private double grossValueOfLandingsOtherSpeciesPerStrategyMet(Strategy str,
+ Metier metier, Date date) throws TopiaException {
// FIXME evaluer l'equation dans suivant le doc des equations
return 0;
}
-
+
//////////////////////////////////////////////////////////////////////
// matrixNetValueOfLandingsPerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixNetValueOfLandingsPerStrategyMetPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixNetValueOfLandingsPerStrategyMetPerVessel(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
- new List[]{strategies, metiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ MatrixND result = MatrixFactory
+ .getInstance()
+ .create(
+ ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
+ new List[] { strategies, metiers },
+ new String[] { n_("Strategies"), n_("Metiers") });
- for (int s=0; s < strategies.size(); s++) {
+ for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = siMatrix.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 = netValueOfLandingsPerStrategyMetPerVessel(str, metier, date);
+ double value = netValueOfLandingsPerStrategyMetPerVessel(str,
+ metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = netValueOfLandingsPerStrategyMetPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
-
/**
- * 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
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double netValueOfLandingsPerStrategyMetPerVessel(Strategy str, Metier metier, Date date) throws TopiaException {
- double netValueOfLandingsPerStrategyMet = netValueOfLandingsPerStrategyMet(str, metier, date);
- // FIXME verifier que c bien cette donn?e qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
+ private double netValueOfLandingsPerStrategyMetPerVessel(Strategy str,
+ Metier metier, Date date) throws TopiaException {
+ double netValueOfLandingsPerStrategyMet = netValueOfLandingsPerStrategyMet(
+ str, metier, date);
+ // FIXME verifier que c bien cette donnée qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
double proportionSetOfVessels = str.getProportionSetOfVessels();
double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
- return netValueOfLandingsPerStrategyMet / (proportionSetOfVessels * numberOfVessels);
+ return netValueOfLandingsPerStrategyMet
+ / (proportionSetOfVessels * numberOfVessels);
}
//////////////////////////////////////////////////////////////////////
// matrixNetRenevueToSharePerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixNetRenevueToSharePerStrategyMetPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixNetRenevueToSharePerStrategyMetPerVessel(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL,
- new List[]{strategies, metiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ MatrixND result = MatrixFactory
+ .getInstance()
+ .create(
+ ResultName.MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL,
+ new List[] { strategies, metiers },
+ new String[] { n_("Strategies"), n_("Metiers") });
- for (int s=0; s < strategies.size(); s++) {
+ for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = siMatrix.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 = netRenevueToSharePerStrategyMetPerVessel(str, metier, date);
+ double value = netRenevueToSharePerStrategyMetPerVessel(str,
+ metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = netRenevueToSharePerStrategyMetPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
/**
- * 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
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double netRenevueToSharePerStrategyMetPerVessel(Strategy str, Metier metier, Date date) throws TopiaException {
- double netRenevueToSharePerStrategyMetPerVessel = netValueOfLandingsPerStrategyMetPerVessel(str, metier, date);
- double sharedNotFixedCostsPerVessel = sharedNotFixedCostsPerVessel(str, metier, date);
- double propStr = str.getStrategyMonthInfo(date.getMonth()).getProportionMetier(metier);
+ private double netRenevueToSharePerStrategyMetPerVessel(Strategy str,
+ Metier metier, Date date) throws TopiaException {
+ double netRenevueToSharePerStrategyMetPerVessel = netValueOfLandingsPerStrategyMetPerVessel(
+ str, metier, date);
+ double sharedNotFixedCostsPerVessel = sharedNotFixedCostsPerVessel(str,
+ metier, date);
+ double propStr = str.getStrategyMonthInfo(date.getMonth())
+ .getProportionMetier(metier);
- double result = netRenevueToSharePerStrategyMetPerVessel - sharedNotFixedCostsPerVessel * propStr;
+ double result = netRenevueToSharePerStrategyMetPerVessel
+ - sharedNotFixedCostsPerVessel * propStr;
return result;
}
//////////////////////////////////////////////////////////////////////
// matrixCrewSharePerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixCrewSharePerStrategyMetPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixCrewSharePerStrategyMetPerVessel(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL,
- 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 = siMatrix.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 = crewSharePerStrategyMetPerVessel(str, metier, date);
+ double value = crewSharePerStrategyMetPerVessel(str, metier,
+ date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = crewSharePerStrategyMetPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
-
/**
- * 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
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double crewSharePerStrategyMetPerVessel(Strategy str, Metier metier, Date date) throws TopiaException {
- double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(str, metier, date);
+ private double crewSharePerStrategyMetPerVessel(Strategy str,
+ Metier metier, Date date) throws TopiaException {
+ double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
+ str, metier, date);
- EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(metier);
+ EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+ metier);
double crewShareRate = 0;
- if(effort != null){
+ if (effort != null) {
crewShareRate = effort.getCrewShareRate();
}
// FIXME verifier qu'il faut bien retourner 0, si pas d'effort
return netRenevueToShare * crewShareRate;
- }
+ }
//////////////////////////////////////////////////////////////////////
// matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel(
+ Date date) throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
- new List[]{strategies, metiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ MatrixND result = MatrixFactory
+ .getInstance()
+ .create(
+ ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
+ new List[] { strategies, metiers },
+ new String[] { n_("Strategies"), n_("Metiers") });
- for (int s=0; s < strategies.size(); s++) {
+ for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = siMatrix.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 = ownerMarginOverVariableCostsPerStrategyMetPerVessel(str, metier, date);
+ double value = ownerMarginOverVariableCostsPerStrategyMetPerVessel(
+ str, metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = ownerMarginOverVariableCostsPerStrategyMetPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
-
/**
- * implant? suivant document ModifTable3PourBP25-07-2006.doc
- * OwnerMarginOverVariableCostsPerStrategyMetPerVessel[str,met,month] = NetRevenueToSharePerStrategyMetPerVessel[str,met,month]?- CrewSharePerStrategyMetPerVessel[str,met,month]?- RepairAndMaintenanceGearCostsPerVes
-sel[str,met,month]?* PropStr(str,met,month)
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * OwnerMarginOverVariableCostsPerStrategyMetPerVessel[str,met,month] =
+ * NetRevenueToSharePerStrategyMetPerVessel[str,met,month] -
+ * CrewSharePerStrategyMetPerVessel[str,met,month] -
+ * RepairAndMaintenanceGearCostsPerVes sel[str,met,month] *
+ * PropStr(str,met,month)
*
* @param str
* @param metier
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double ownerMarginOverVariableCostsPerStrategyMetPerVessel(Strategy str, Metier metier, Date date) throws TopiaException {
- double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(str, metier, date);
+ private double ownerMarginOverVariableCostsPerStrategyMetPerVessel(
+ Strategy str, Metier metier, Date date) throws TopiaException {
+ double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
+ str, metier, date);
double crewShare = crewSharePerStrategyMetPerVessel(str, metier, date);
- double repair = repairAndMaintenanceGearCostsPerVessel(str, metier, date);
- double propStr = str.getStrategyMonthInfo(date.getMonth()).getProportionMetier(metier);
+ double repair = repairAndMaintenanceGearCostsPerVessel(str, metier,
+ date);
+ double propStr = str.getStrategyMonthInfo(date.getMonth())
+ .getProportionMetier(metier);
return netRenevueToShare - crewShare - repair * propStr;
- }
+ }
-
//////////////////////////////////////////////////////////////////////
// matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel(
+ Date date) throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
List<Metier> metiers = siMatrix.getMetiers(date);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
- new List[]{strategies, metiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ MatrixND result = MatrixFactory
+ .getInstance()
+ .create(
+ ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
+ new List[] { strategies, metiers },
+ new String[] { n_("Strategies"), n_("Metiers") });
- for (int s=0; s < strategies.size(); s++) {
+ for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = siMatrix.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 = vesselMarginOverVariableCostsPerStrategyMetPerVessel(str, metier, date);
+ double value = vesselMarginOverVariableCostsPerStrategyMetPerVessel(
+ str, metier, date);
result.setValue(str, metier, value);
}
}
-// for(Strategy str : strategies){
-// metiers = siMatrix.getMetiers(str, date);
-// for(Metier metier : metiers) {
-// double value = vesselMarginOverVariableCostsPerStrategyMetPerVessel(str, metier, date);
-// result.setValue(str, metier, value);
-// }
-// }
return result;
}
/**
- * implant? suivant document ModifTable3PourBP25-07-2006.doc
- * VesselMarginOverVariableCostsPerStrategyMetPerVessel?[str,met,month]?=NetRevenueToSharePerStrategyMetPerVessel[str,met,month]- RepairAndMaintenanceGearCostsPerVessel [str,met,month]?* PropStr(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
* @param metier
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double vesselMarginOverVariableCostsPerStrategyMetPerVessel(Strategy str, Metier metier, Date date) throws TopiaException {
- double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(str, metier, date);
- double repair = repairAndMaintenanceGearCostsPerVessel(str, metier, date);
- double propStr = str.getStrategyMonthInfo(date.getMonth()).getProportionMetier(metier);
+ private double vesselMarginOverVariableCostsPerStrategyMetPerVessel(
+ Strategy str, Metier metier, Date date) throws TopiaException {
+ double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
+ str, metier, date);
+ double repair = repairAndMaintenanceGearCostsPerVessel(str, metier,
+ date);
+ double propStr = str.getStrategyMonthInfo(date.getMonth())
+ .getProportionMetier(metier);
return netRenevueToShare - repair * propStr;
- }
-
+ }
+
//////////////////////////////////////////////////////////////////////
// matrixOwnerMarginOverVariableCostsPerStrategyPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixOwnerMarginOverVariableCostsPerStrategyPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixOwnerMarginOverVariableCostsPerStrategyPerVessel(
+ Date date) throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
- new List[]{strategies},
- new String[]{n_("Strategies")});
+ MatrixND result = MatrixFactory
+ .getInstance()
+ .create(
+ ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
+ new List[] { strategies },
+ new String[] { n_("Strategies") });
- for (int s=0; s < strategies.size(); s++) {
+ for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
- double value = ownerMarginOverVariableCostsPerStrategyPerVessel(str, date);
+ double value = ownerMarginOverVariableCostsPerStrategyPerVessel(
+ str, date);
result.setValue(s, value);
}
-// for(Strategy str : strategies){
-// double value = ownerMarginOverVariableCostsPerStrategyPerVessel(str, date);
-// result.setValue(str, value);
-// }
return result;
}
-
+
/**
- * implant? suivant document ModifTable3PourBP25-07-2006.doc
- * OwnerMarginOverVariableCostsPerStrategyPerVessel[str,month]?=?somme sur tous les m?tiers de OwnerMarginOverVariableCostsPerStrategyMetPerVessel [str,met,month]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * OwnerMarginOverVariableCostsPerStrategyPerVessel[str,month] = somme sur
+ * tous les metiers de OwnerMarginOverVariableCostsPerStrategyMetPerVessel
+ * [str,met,month]
*
* @param str
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double ownerMarginOverVariableCostsPerStrategyPerVessel(Strategy str, Date date) throws TopiaException {
+ private double ownerMarginOverVariableCostsPerStrategyPerVessel(
+ Strategy str, Date date) throws TopiaException {
SetOfVessels sov = str.getSetOfVessels();
Collection<EffortDescription> efforts = sov.getPossibleMetiers();
float result = 0;
-
+
for (EffortDescription effort : efforts) {
Metier metier = effort.getPossibleMetiers();
- result += ownerMarginOverVariableCostsPerStrategyMetPerVessel(str, metier, date);
+ result += ownerMarginOverVariableCostsPerStrategyMetPerVessel(str,
+ metier, date);
}
return result;
}
@@ -1102,80 +1061,87 @@
//////////////////////////////////////////////////////////////////////
// matrixOwnerMarginOverVariableCostsPerStrategy
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixOwnerMarginOverVariableCostsPerStrategy(Date date) throws TopiaException{
+
+ public MatrixND matrixOwnerMarginOverVariableCostsPerStrategy(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
- new List[]{strategies},
- new String[]{n_("Strategies")});
+ MatrixND result = MatrixFactory
+ .getInstance()
+ .create(
+ ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
+ new List[] { strategies },
+ new String[] { n_("Strategies") });
- for (int s=0; s < strategies.size(); s++) {
+ for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
double value = ownerMarginOverVariableCostsPerStrategy(str, date);
result.setValue(s, value);
}
-// for(Strategy str : strategies){
-// double value = ownerMarginOverVariableCostsPerStrategy(str, date);
-// result.setValue(str, value);
-// }
return result;
}
/**
- * 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
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double ownerMarginOverVariableCostsPerStrategy(Strategy str, Date date) throws TopiaException {
- double ownerMarginOverVariableCostsPerStrategyPerVessel = ownerMarginOverVariableCostsPerStrategyPerVessel(str, date);
+ private double ownerMarginOverVariableCostsPerStrategy(Strategy str,
+ Date date) throws TopiaException {
+ double ownerMarginOverVariableCostsPerStrategyPerVessel = ownerMarginOverVariableCostsPerStrategyPerVessel(
+ str, date);
double proportionSetOfVessels = str.getProportionSetOfVessels();
double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
- return ownerMarginOverVariableCostsPerStrategyPerVessel * (proportionSetOfVessels * numberOfVessels);
- }
+ return ownerMarginOverVariableCostsPerStrategyPerVessel
+ * (proportionSetOfVessels * numberOfVessels);
+ }
//////////////////////////////////////////////////////////////////////
// matrixVesselMarginOverVariableCostsPerStrategyPerVessel
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixVesselMarginOverVariableCostsPerStrategyPerVessel(Date date) throws TopiaException{
+
+ public MatrixND matrixVesselMarginOverVariableCostsPerStrategyPerVessel(
+ Date date) throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
- new List[]{strategies},
- new String[]{n_("Strategies")});
+ MatrixND result = MatrixFactory
+ .getInstance()
+ .create(
+ ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
+ new List[] { strategies },
+ new String[] { n_("Strategies") });
- for (int s=0; s < strategies.size(); s++) {
+ for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
- double value = vesselMarginOverVariableCostsPerStrategyPerVessel(str, date);
+ double value = vesselMarginOverVariableCostsPerStrategyPerVessel(
+ str, date);
result.setValue(s, value);
}
-// for(Strategy str : strategies){
-// double value = vesselMarginOverVariableCostsPerStrategyPerVessel(str, date);
-// result.setValue(str, value);
-// }
return result;
}
-
+
/**
- * implant? suivant document ModifTable3PourBP25-07-2006.doc
- * VesselMarginOverVariableCostsPerStrategyPerVessel[str,month]?= somme sur tous les m?tiers de VesselMarginOverVariableCostsPerStrategyMetPerVessel? [str,met,month]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * VesselMarginOverVariableCostsPerStrategyPerVessel[str,month] = somme sur
+ * tous les metiers de VesselMarginOverVariableCostsPerStrategyMetPerVessel
+ * [str,met,month]
*
* @param str
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double vesselMarginOverVariableCostsPerStrategyPerVessel(Strategy str, Date date) throws TopiaException {
+ private double vesselMarginOverVariableCostsPerStrategyPerVessel(
+ Strategy str, Date date) throws TopiaException {
SetOfVessels sov = str.getSetOfVessels();
Collection<EffortDescription> efforts = sov.getPossibleMetiers();
@@ -1183,74 +1149,80 @@
for (EffortDescription effort : efforts) {
Metier metier = effort.getPossibleMetiers();
- result += vesselMarginOverVariableCostsPerStrategyMetPerVessel(str, metier, date);
+ result += vesselMarginOverVariableCostsPerStrategyMetPerVessel(str,
+ metier, date);
}
return result;
- }
+ }
-
//////////////////////////////////////////////////////////////////////
// matrixVesselMarginOverVariableCostsPerStrategy
//////////////////////////////////////////////////////////////////////
-
- public MatrixND matrixVesselMarginOverVariableCostsPerStrategy(Date date) throws TopiaException{
+
+ public MatrixND matrixVesselMarginOverVariableCostsPerStrategy(Date date)
+ throws TopiaException {
List<Strategy> strategies = siMatrix.getStrategies(date);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
- new List[]{strategies},
- new String[]{n_("Strategies")});
+ MatrixND result = MatrixFactory
+ .getInstance()
+ .create(
+ ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
+ new List[] { strategies },
+ new String[] { n_("Strategies") });
- for (int s=0; s < strategies.size(); s++) {
+ for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
double value = vesselMarginOverVariableCostsPerStrategy(str, date);
result.setValue(s, value);
}
-// for(Strategy str : strategies){
-// double value = vesselMarginOverVariableCostsPerStrategy(str, date);
-// result.setValue(str, value);
-// }
return result;
}
/**
- * implant? suivant document ModifTable3PourBP25-07-2006.doc
- * VesselMarginOverVariableCostsPerStrategy[str,month]?=VesselMarginOverVariableCostsPerStrategyPerVessel?[str,month] *[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)]
+ * implante suivant document ModifTable3PourBP25-07-2006.doc
+ * VesselMarginOverVariableCostsPerStrategy[str,month]
+ * =VesselMarginOverVariableCostsPerStrategyPerVessel [str,month]
+ * *[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)]
*
* @param str
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
- private double vesselMarginOverVariableCostsPerStrategy(Strategy str, Date date) throws TopiaException {
- double vesselMarginOverVariableCostsPerStrategyPerVessel = vesselMarginOverVariableCostsPerStrategyPerVessel(str, date);
+ private double vesselMarginOverVariableCostsPerStrategy(Strategy str,
+ Date date) throws TopiaException {
+ double vesselMarginOverVariableCostsPerStrategyPerVessel = vesselMarginOverVariableCostsPerStrategyPerVessel(
+ str, date);
double proportionSetOfVessels = str.getProportionSetOfVessels();
double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
- return vesselMarginOverVariableCostsPerStrategyPerVessel * (proportionSetOfVessels * numberOfVessels);
+ return vesselMarginOverVariableCostsPerStrategyPerVessel
+ * (proportionSetOfVessels * numberOfVessels);
}
-
///////////////////////////////////////////////////////////////////////////
//
- // Methode non utilis?e directement dans GravityModel, mais dans les rules
+ // Methode non utilisee directement dans GravityModel, mais dans les rules
//
///////////////////////////////////////////////////////////////////////////
- public double valuePerUnitFishingEffort(Strategy str, Metier metier, Date date) throws TopiaException{
- List<Population> pops = siMatrix.getPopulations(date);
+ public double valuePerUnitFishingEffort(Strategy str, Metier metier,
+ Date date) throws TopiaException {
+ List<Population> pops = siMatrix.getPopulations(date);
- double result = 0;
+ double result = 0;
- for(Population pop : pops){
+ for (Population pop : pops) {
List<PopulationGroup> groups = pop.getPopulationGroup();
Collection<Zone> zones = pop.getPopulationZone();
- for(PopulationGroup group : groups){
+ for (PopulationGroup group : groups) {
double price = group.getPrice();
- for(Zone zone : zones){
- double catchValue = getCatchWeightPerStrMetPerZonePop(str, metier, group, zone, date);
- double discards = getDiscardsWeightPerStrMet(str, metier, group, zone, date);
+ for (Zone zone : zones) {
+ double catchValue = getCatchWeightPerStrMetPerZonePop(str,
+ metier, group, zone, date);
+ double discards = getDiscardsWeightPerStrMet(str, metier,
+ group, zone, date);
result += price * (catchValue - discards);
}
}
@@ -1258,7 +1230,7 @@
double effort = getEffortPerStrategyMet(str, metier, date);
- if(effort == 0){
+ if (effort == 0) {
result = 0;
} else {
result = result / effort;
@@ -1274,28 +1246,32 @@
* @return
*/
public double getEffortPerStrategyMet(Strategy str, Metier metier, Date date) {
- MatrixND mat = resultManager.getMatrix(date, ResultName.MATRIX_EFFORT_PER_STRATEGY_MET);
+ MatrixND mat = resultManager.getMatrix(date,
+ ResultName.MATRIX_EFFORT_PER_STRATEGY_MET);
double result = 0;
- if(mat != null){
+ if (mat != null) {
result = mat.getValue(str, metier);
}
return result;
}
- public double landingPerUnitFishingEffort(Strategy str, Metier metier, Date date) throws TopiaException{
+ public double landingPerUnitFishingEffort(Strategy str, Metier metier,
+ Date date) throws TopiaException {
List<Population> pops = siMatrix.getPopulations(date);
double effort = getEffortPerStrategyMet(str, metier, date);
double result = 0;
- if(effort != 0){ // s'il n'y a pas d'effort on retournera 0
- for(Population pop : pops){
+ if (effort != 0) { // s'il n'y a pas d'effort on retournera 0
+ for (Population pop : pops) {
List<PopulationGroup> groups = pop.getPopulationGroup();
Collection<Zone> zones = pop.getPopulationZone();
- for(PopulationGroup group : groups){
- for(Zone zone : zones){
- double catchValue = getCatchWeightPerStrMetPerZonePop(str, metier, group, zone, date);
- double discards = getDiscardsWeightPerStrMet(str, metier, group, zone, date);
+ for (PopulationGroup group : groups) {
+ for (Zone zone : zones) {
+ double catchValue = getCatchWeightPerStrMetPerZonePop(
+ str, metier, group, zone, date);
+ double discards = getDiscardsWeightPerStrMet(str,
+ metier, group, zone, date);
result += catchValue - discards;
}
}
@@ -1305,7 +1281,4 @@
return result;
}
-
}
-
-
Modified: isis-fish/trunk/src/test/resources/test-database/scripts/ResultName.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/scripts/ResultName.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/scripts/ResultName.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -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,103 +37,105 @@
/**
* 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
+ * 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_PER_ZONE_POP = 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_PER_ZONE_POP = 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 matrixStdTravelEffortPerStrategyMet")
+ @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")
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 = "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")
+ @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")
+ @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")
+ @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")
+ @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 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 matrixBiomassBeginMonth")
+ @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 matrixBiomassBeginMonth")
- static final public String MATRIX_ABONDANCE_BEGIN_MONTH = n_("matrixAbondanceBeginMonth");
- @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 matrixGrossValueOfLandingsPerStrategyMetPerVessel")
+ @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")
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: isis-fish/trunk/src/test/resources/test-database/scripts/RuleUtil.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/scripts/RuleUtil.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/scripts/RuleUtil.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -14,7 +14,7 @@
import fr.ifremer.isisfish.types.Date;
/**
- * ChangeMatrixBackend.java
+ * RuleUtil.
*
* Created: 6 septembre 2006
*
@@ -34,22 +34,21 @@
* @param species l'espece sur lequel on souhaite le total
* @param date la date pour laquel on veut le calcul, cet argument est
* passe seulement pour que le cache ne retourne pas toujours la meme valeur
- * @return
+ * @return total catch in tons
*/
public static double getTotalCatchTons(SimulationContext context, Species species, Date date) {
double result = 0;
for (Population pop : species.getPopulation()) {
MatrixND mat = context.getPopulationMonitor().getHoldCatch(pop);
- if(mat!=null) {
+ if (mat != null) {
mat = mat.copy();
mat = mat.sumOverDim(0); // sum over Strategies
mat = mat.sumOverDim(1); // sum over metiers
mat = mat.sumOverDim(3); // sum over zones
-// List<PopulationGroup> groups = mat.getSemantics(2);
List<PopulationGroup> groups = pop.getPopulationGroup();
-
- for (int c=0; c<groups.size(); c++) {
+
+ for (int c = 0; c < groups.size(); c++) {
PopulationGroup group = groups.get(c);
double weight = group.getMeanWeight();
result += mat.getValue(0, 0, c, 0) * weight / 1000.0;
@@ -58,8 +57,4 @@
}
return result;
}
-
-
-
-
}
Modified: isis-fish/trunk/src/test/resources/test-database/scripts/SiMatrix.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/scripts/SiMatrix.java 2009-09-09 15:35:02 UTC (rev 2590)
+++ isis-fish/trunk/src/test/resources/test-database/scripts/SiMatrix.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -1,6 +1,6 @@
/* *##%
- * Copyright (C) 2006
- * Code Lutin, Benjamin Poussin
+ * Copyright (C) 2006 - 2009
+ * Ifremer, Code Lutin, Benjamin Poussin
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -17,28 +17,15 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*##%*/
-/* *
- * SiMatrix.java
- *
- * Created: 21 ao?t 2006 15:53:01
- *
- * @author poussin
- * @version $Revision: 1.18 $
- *
- * Last update: $Date: 2007-11-02 17:53:20 $
- * by : $Author: bpoussin $
- */
-
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 +54,66 @@
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;
/**
+ * SiMatrix.java
+ *
+ * Created: 21 aout 2006 15:53:01
+ *
* @author poussin
+ * @version $Revision: 1.18 $
*
+ * Last update: $Date: 2007-11-02 17:53:20 $
+ * by : $Author: bpoussin $
*/
-
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
+ * @throws TopiaException
*/
- 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 +123,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 +137,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 +179,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 +193,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 +223,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 +257,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_PER_ZONE_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 +312,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 +332,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 +350,33 @@
return result;
}
-
/**
* Utilise pour le calcul en Zone
- *
- * 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 pop
* @param date
+ * @param matrixCatchRatePerStrategyMet
* @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_PER_ZONE_POP);
- 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 +386,19 @@
}
/**
- * 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
+ * @param matrixFishingMortality
* @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 +406,53 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_CATCH_RATE_PER_STRATEGY_MET_PER_ZONE_POP,
- new List[]{strategies, metiers, groups, zones},
- new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")});
+ new 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 +460,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 +499,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 +537,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 +555,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 +572,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 +614,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 +648,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 +667,16 @@
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") });
+
+ // 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,130 +687,107 @@
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);
-// }
-// }
-// }
-// }
return result;
}
/**
+ * catchRatePerStrategyMetPerCell.
+ *
+ * Optimisation Hilaire
+ *
* @param str
* @param metier
* @param date
* @param group
* @param zone
+ * @param cell
+ * @param matrixFishingMortalityPerCell
* @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;
-// }
-
- // 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);
+ MatrixND totalFishingMortalityPerCell = totalFishingMortalityPerCell(
+ date, matrixFishingMortalityPerCell);
+ double totalFishingMortality = totalFishingMortalityPerCell.getValue(
+ group, zone, cell);
- 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 +795,28 @@
* @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]
*
+ * Nouvelle implantation suite a demande Steph et Sigrid: 20080208 (NouvellesEquationsfev2008ParCelluleAvecAlgo.odt)
+ *
* @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 +826,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,7 +843,8 @@
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);
@@ -854,13 +855,14 @@
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);
@@ -868,7 +870,13 @@
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);
+ result.setValue(
+ new Object[] { str,
+ metier,
+ group,
+ zone,
+ cellMet },
+ value);
}
}
}
@@ -883,278 +891,37 @@
return result;
}
- // 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;
-// }
-
- // 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();
-
-// // 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 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;
-// }
-
-// /**
-// * @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;
-// }
-
- // 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
* @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);
+ //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;
}
@@ -1165,14 +932,14 @@
* @param date
* @return
*/
- private double effortPerStrategyMet(Strategy str, Metier metier, Date date) {
+ private double effortNominalPerStrategyMet(Strategy str, Metier metier, Date date) {
Month month = date.getMonth();
StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
-
+
double propSetOfVessels = str.getProportionSetOfVessels();
int nbOfVessels = str.getSetOfVessels().getNumberOfVessels();
double propStrMet = smi.getProportionMetier(metier);
- double effortPerVessel = effortPerStrategyPerVessel(str, metier, date);
+ double effortNominalPerVessel = effortNominalPerStrategyPerVessel(str, metier, date);
if(log.isDebugEnabled()) {
log.debug(
@@ -1181,38 +948,93 @@
" propSetOfVessels=" + propSetOfVessels +
" nbOfVessels=" + nbOfVessels +
" propStrMet=" + propStrMet +
- " effortPerVessel=" + effortPerVessel
+ " effortPerVessel=" + effortNominalPerVessel
);
}
- double result = propSetOfVessels * nbOfVessels * propStrMet * effortPerVessel;
+ double result = propSetOfVessels * nbOfVessels * propStrMet * effortNominalPerVessel;
return result;
}
-
+
/**
* @param str
* @param metier
* @param date
* @return
*/
- private double effortPerStrategyPerVessel(Strategy str, Metier metier, Date date) {
+ private double effortNominalPerStrategyPerVessel(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);
+
if(log.isDebugEnabled()) {
log.debug(
" strategy=" + str +
" metier=" + metier +
" nbTrips=" + nbTrips +
- " fishingTime=" + fishingTime +
- " stdEffortPerHour=" + stdEffortPerHour
+ " fishingTime=" + fishingTime
+
);
}
-
+ // nominal timeAtSea = nbTrips * fishingTime;
+ //
+ double result = nbTrips * fishingTime;
+
+ return result;
+ }
+
+ /**
+ * @param str
+ * @param metier
+ * @param date
+ * @return
+ */
+ private double effortPerStrategyMet(Strategy str, Metier metier, Date date) {
+ Month month = date.getMonth();
+ StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
+
+ double propSetOfVessels = str.getProportionSetOfVessels();
+ int nbOfVessels = str.getSetOfVessels().getNumberOfVessels();
+ 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);
+ }
+
+ double result = propSetOfVessels * nbOfVessels * propStrMet
+ * effortPerVessel;
+
+ return result;
+ }
+
+ /**
+ * @param str
+ * @param metier
+ * @param date
+ * @return
+ */
+ 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);
+
+ if (log.isDebugEnabled()) {
+ log.debug(" strategy=" + str + " metier=" + metier + " nbTrips="
+ + nbTrips + " fishingTime=" + fishingTime
+ + " stdEffortPerHour=" + stdEffortPerHour);
+ }
+
double result = nbTrips * fishingTime * stdEffortPerHour;
return result;
@@ -1232,38 +1054,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 +1097,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 +1125,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 +1187,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 +1212,7 @@
}
return result;
}
-
+
/**
* used here and in Rule (CantonnementPreSimu)
*
@@ -1414,97 +1226,105 @@
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
+ * 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
+ * Utilise pour le calcule en Zone.
+ *
* @param N
* @param pop
* @param date
+ * @param matrixFishingMortality
* @return
* @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 +1337,7 @@
/**
* Utilise pour la mortalite des poissons, lorsqu'aucune strategie n'est
* selectionnee.
+ *
* @param N
* @param pop
* @param date
@@ -1524,21 +1345,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 +1379,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,9 +1417,9 @@
//
//
///////////////////////////////////////////////////////////////////////////
-
+
/**
- * @param n
+ * @param N
* @param pop
* @param date
* @return
@@ -1601,32 +1429,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_BEGIN_MONTH,
- new List[]{groups, zones},
- new String[]{n_("Groups"), n_("Zones")});
+ ResultName.MATRIX_BIOMASS_BEGIN_MONTH, new List[] { groups, zones },
+ new String[] { n_("Groups"), n_("Zones") });
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -1641,14 +1468,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_ABONDANCE_BEGIN_MONTH,
- new List[]{groups, zones},
- new String[]{n_("Groups"), n_("Zones")});
+ ResultName.MATRIX_ABUNDANCE_BEGIN_MONTH, new List[] { groups, zones },
+ new String[] { n_("Groups"), n_("Zones") });
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -1661,17 +1488,16 @@
return result;
}
-
///////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////
-
+
/**
* @param date
* @return
- * @throws TopiaException
+ * @throws TopiaException
*/
public MatrixND matrixEffortPerStrategyMet(Date date) throws TopiaException {
List<Strategy> strategies = getStrategies(date);
@@ -1679,27 +1505,19 @@
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);
-// }
-// }
-
return result;
}
@@ -1708,49 +1526,56 @@
//
//
///////////////////////////////////////////////////////////////////////////
-
-// /**
-// * @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
+ * @param matrixDiscardPerStrategyMetPerZonePop
* @return
*/
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_PER_ZONE_POP);
+ MatrixND result = matrixDiscardPerStrategyMetPerZonePop.copy();
+ result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
- for(PopulationGroup group : groups){
- MatrixND sub = result.getSubMatrix(2, group, 1);
- double meanWeight = group.getMeanWeight();
- sub.mults(meanWeight);
- }
+ for (PopulationGroup group : groups) {
+ MatrixND sub = result.getSubMatrix(2, group, 1);
+ double meanWeight = group.getMeanWeight();
+ sub.mults(meanWeight);
+ }
- return result;
+ return result;
}
+ ///////////////////////////////////////////////////////////////////////////
+ //
+ //
+ //
+ ///////////////////////////////////////////////////////////////////////////
+ public MatrixND matrixEffortNominalPerStrategyMet(Date date) throws TopiaException {
+
+ List<Strategy> strategies = getStrategies(date);
+ List<Metier> metiers = getMetiers(date);
+
+ MatrixND result = MatrixFactory.getInstance().create(
+ ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET,
+ new List[]{strategies, metiers},
+ new String[]{n_("Strategies"), n_("Metiers")});
+
+ for (int s=0; s < strategies.size(); s++) {
+ Strategy str = strategies.get(s);
+ metiers = getMetiers(str, date);
+ for (int m=0; m < metiers.size(); m++) {
+ Metier metier = metiers.get(m);
+ double value = effortNominalPerStrategyMet(str, metier, date);
+ result.setValue(str, metier, value);
+ }
+ }
+
+ return result;
+ }
}
Added: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorJavaExpandGrid.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorJavaExpandGrid.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorJavaExpandGrid.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,623 @@
+/* *##%
+ * Copyright (C) 2006 - 2009 Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package sensitivity;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.j2r.REngine;
+import org.codelutin.j2r.RProxy;
+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;
+import fr.ifremer.isisfish.simulator.sensitivity.Scenario;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityException;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityScenarios;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
+import fr.ifremer.isisfish.util.Doc;
+
+/**
+ * Implementation of ExpandGrid method using Java
+ *
+ * @author jcouteau
+ * @version $Revision$
+ *
+ */
+public class SensitivityCalculatorJavaExpandGrid extends
+ AbstractSensitivityCalculator {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityCalculatorJavaExpandGrid.class);
+
+ @Doc("Interaction order")
+ public int param_order = 2;
+
+ /**
+ * Retourne vrai si le calculateur sait gerer la cardinalité des facteurs
+ * continue.
+ *
+ * @return <tt>true</tt> s'il sait la gerer
+ */
+ @Override
+ public boolean canManageCardinality() {
+ return false;
+ }
+
+ @Override
+ public SensitivityScenarios compute(DesignPlan plan, File outputdirectory)
+ throws SensitivityException {
+
+ setIsisFactorsR(plan, outputdirectory);
+
+ int k = 1; //number of sensitivity scenarios (initialization)
+ int factorNumber = plan.getFactors().size(); //number of factors
+ List<Factor<?, ?>> factors = plan.getFactors(); //list of factors
+
+ for (int i = 0; i < factorNumber; i++) {
+ if (factors.get(i).getDomain() instanceof ContinuousDomain) {
+ if (((ContinuousDomain) factors.get(i).getDomain())
+ .getCardinality() != 0) {
+ k = k
+ * ((ContinuousDomain) factors.get(i).getDomain())
+ .getCardinality();
+ }
+ } else if (factors.get(i).getDomain() instanceof DiscreteDomain) {
+ if (((DiscreteDomain) factors.get(i).getDomain()).getValues()
+ .size() != 0) {
+ k = k
+ * ((DiscreteDomain) factors.get(i).getDomain())
+ .getValues().size();
+ }
+ }
+ }
+
+ SensitivityScenarios thisExperiment = new SensitivityScenarios();
+ List<Scenario> thisExperimentScenarios = thisExperiment.getScenarios();
+
+ for (int i = 0; i < k; i++) {
+ int result = 0; //used for the euclidian division
+ int rest = i; //used for the euclidian division
+ Scenario experimentScenario = new Scenario();
+ for (int j = 0; j < factorNumber; j++) {
+ Factor factor = factors.get(j);
+ if (factor.getDomain() instanceof ContinuousDomain) {
+ Double max = ((ContinuousDomain) factor.getDomain())
+ .getMaxBound();
+ Double min = ((ContinuousDomain) factor.getDomain())
+ .getMinBound();
+ int card = ((ContinuousDomain) factor.getDomain())
+ .getCardinality();
+ result = (int) Math.floor(rest / card);
+ rest = rest - (card * result);
+
+ Double value = min + ((max - min) / (card - 1) * rest);
+ if ((factor.getDomain() instanceof MatrixContinuousDomain)
+ || (factor.getDomain() instanceof EquationContinuousDomain)) {
+ factor.setValueForIdentifier(value);
+ } else {
+ factor.setValueForIdentifier(value);
+ }
+ }
+ if (factor.getDomain() instanceof DiscreteDomain) {
+ int card = ((DiscreteDomain) factor.getDomain())
+ .getValues().size();
+ result = (int) Math.floor(rest / card);
+ rest = rest - (card * result);
+ factor.setValueForIdentifier(rest);
+ }
+ rest = result;
+ experimentScenario.addFactor(factor);
+ }
+ thisExperimentScenarios.add(experimentScenario);
+
+ }
+ thisExperiment.setScenarios(thisExperimentScenarios);
+
+ thisExperimentScenarios = thisExperiment.getScenarios();
+
+ /*
+ * Call R to save the data for result analysis
+ */
+ int scenariosNumber = thisExperimentScenarios.size();
+
+ REngine engine = new RProxy();
+ try {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ String dataframe = "data<-data.frame(";
+
+ //Create the factors vectors and the dataframe instruction
+ for (int j = 0; j < factorNumber; j++) {
+ Factor factor = thisExperimentScenarios.get(0).getFactors()
+ .get(j);
+ if (factor.getDomain() instanceof EquationContinuousDomain) {
+
+ //String vector = "factor" + j + "<-c(";
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < scenariosNumber; i++) {
+ if (i < (scenariosNumber - 1)) {
+ vector = vector
+ + ((EquationContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue() + ",";
+ } else {
+ vector = vector
+ + ((EquationContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ } else if (factor.getDomain() instanceof MatrixContinuousDomain) {
+ //String vector = "factor" + j + "<-c(";
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < scenariosNumber; i++) {
+ if (i < (scenariosNumber - 1)) {
+ vector = vector
+ + ((MatrixContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue() + ",";
+ } else {
+ vector = vector
+ + ((MatrixContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ } else {
+ //String vector = "factor" + j + "<-c(";
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < scenariosNumber; i++) {
+ if (i < (scenariosNumber - 1)) {
+ vector = vector
+ + thisExperimentScenarios.get(i)
+ .getFactors().get(j).getValue()
+ + ",";
+ } else {
+ vector = vector
+ + thisExperimentScenarios.get(i)
+ .getFactors().get(j).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ }
+
+ if (j < factorNumber - 1) {
+ dataframe = dataframe
+ + factor.getName().replaceAll(" ", "") + "=factor("
+ + factor.getName().replaceAll(" ", "") + "),";
+ } else {
+ dataframe += factor.getName().replaceAll(" ", "")
+ + "=factor(" + factor.getName().replaceAll(" ", "")
+ + "))";
+ }
+
+ }
+ engine.voidEval(dataframe);
+ log.info("Message sent to R : " + dataframe);
+
+ // Creating the factors vector.
+ String rInstruction = "factornames<-c(";
+ for (int i = 0; i < factorNumber; i++) {
+ if (i != (factorNumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R : " + rInstruction);
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Export the data.frame object for the second run in a .expandgrid file
+ engine.voidEval("write.csv(data,file=\".expandgrid.csv\")");
+ log
+ .info("Message sent to R : write.csv(data,file=\".expandgrid\")");
+
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R : "
+ + "dput(factornames,file=\".factornames\")");
+
+ //Create the isis.factor.distribution
+ log.info("Message sent to R : "
+ + "isis.factor.distribution<-c(0.0)");
+ engine.voidEval("isis.factor.distribution<-c(0.0)");
+
+ //Create isis.MethodExp
+ log
+ .info("Message sent to R : "
+ + "isis.MethodExp<-list(isis.factor,isis.factor.distribution,call_méthode=\"isis-fish-externeR\")");
+ engine
+ .voidEval("isis.MethodExp<-list(isis.factor,isis.factor.distribution,call_méthode=\"isis-fish-externeR\")");
+
+ log
+ .info("Message sent to R : "
+ + "attr(isis.MethodExp,\"nomModel\")<-\"isis-fish-externe-R\"");
+ engine
+ .voidEval("attr(isis.MethodExp,\"nomModel\")<-\"isis-fish-externe-R\"");
+
+ //Create isis.Simule
+ log.info("Message sent to R : " + "isis.simule<-data.frame(data)");
+ engine.voidEval("isis.simule<-data.frame(data)");
+
+ 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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ engine.terminate();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ // Error while processing
+ }
+
+ return thisExperiment;
+ }
+
+ @Override
+ public void analyzeResult(List<SimulationStorage> simulationStorages,
+ File outputdirectory) throws SensitivityException {
+
+ REngine engine = new RProxy();
+ try {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get back the scenarios
+ engine.voidEval("factors<-read.csv(\".expandgrid.csv\")");
+ log
+ .info("Message sent to R : factors<-read.csv(\".expandgrid.csv\")");
+
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
+ //Get back the factors number
+ int factorNumber = ((Double) engine.eval("length(factors)-1"))
+ .intValue();
+
+ 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 = 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, 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) {
+ rInstruction = rInstruction + simulationResult + ",";
+ } else {
+ rInstruction = rInstruction + simulationResult;
+ }
+ }
+ 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
+ + ")");
+ log.info("Message sent to R : "
+ + "isis.simule<-data.frame(isis.simule," + name + ")");
+
+ //Create the dataforaov data.frame
+ String dataframe = "dataforaov<-data.frame(factors," + name
+ + "=" + name + ")";
+ engine.voidEval(dataframe);
+ log.info("Message sent to R : " + dataframe);
+
+ //Call aov()
+ String aovCall = "aovresult<-aov(" + name + "~(";
+ for (int j = 0; j < factorNumber; j++) {
+ log.info("Message sent to R : " + "names(factors)["
+ + (j + 2) + "]");
+
+ if (j < (factorNumber - 1)) {
+ aovCall = aovCall
+ + engine
+ .eval("names(factors)[" + (j + 2) + "]")
+ + "+";
+ } else {
+ aovCall = aovCall
+ + engine
+ .eval("names(factors)[" + (j + 2) + "]")
+ + ")";
+ if(param_order>1){
+ aovCall+="^" + param_order + ",data=dataforaov)";
+ }else{
+ aovCall+=",data=dataforaov)";
+ }
+ }
+ }
+ engine.voidEval(aovCall);
+ log.info("Message sent to R : " + aovCall);
+
+ /*Export the results
+ *Export format is csv, data separated by ','
+ *Results Export name is sensitivityExportName_Results.csv
+ *Sensitivity Indices export name is sensitivityExportName_SensitivityIndices.csv
+ */
+
+ //Compute Sum of Squares and Sensitivity indices
+ engine.voidEval("SoS<-summary(aovresult)[[1]][1:"
+ + factorNumber + ",2]");
+ log.info("Message sent to R : SoS<-summary(aovresult)[[1]][1:"
+ + factorNumber + ",2]");
+ engine
+ .voidEval("names(SoS)<-dimnames(summary(aovresult)[[1]])[[1]][1:"
+ + factorNumber + "]");
+ log
+ .info("Message sent to R : names(SoS)<-dimnames(summary(aovresult)[[1]])[[1]][1:"
+ + factorNumber + "]");
+ engine.voidEval("IndSensibilite<-SoS/sum(SoS)");
+ log.info("Message sent to R : IndSensibilite<-SoS/sum(SoS)");
+
+ //Create a data.frame to export sensitivity important results in one file.
+ engine.voidEval("exportsensitivity=data.frame(SoS[1:"
+ + factorNumber + "],IndSensibilite[1:" + factorNumber
+ + "])");
+ log
+ .info("Message sent to R : exportsensitivity=data.frame(SoS[1:"
+ + factorNumber
+ + "],IndSensibilite[1:"
+ + factorNumber + "])");
+ engine
+ .voidEval("names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ log
+ .info("Message sent to R : names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ engine.voidEval("row.names(exportsensitivity)<-factornames");
+ log.info("Message sent to R : "
+ + "row.names(exportsensitivity)<-factornames");
+
+ //Set dataforaov names
+ engine
+ .voidEval("resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ engine.voidEval("names(dataforaov)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dataforaov)<-resultsnames");
+
+ /*Set the export directory
+ *Export directory is the first simulation export directory.
+ */
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+
+ //Save the results with the scenarios.
+ engine.voidEval("write.csv(dataforaov,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+ log.info("Message sent to R : write.csv(dataforaov,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+
+ //Save the sensitivity indices
+ engine.voidEval("write.csv(exportsensitivity,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ log.info("Message sent to R : write.csv(exportsensitivity,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ //FIXME export through java to enable export when using Rserve (when distant Rserve).
+
+ //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=\""
+ + aovCall + "\""
+ + ",\"analysis_result\"=list(aovresult,IndSensibilite))");
+ engine
+ .voidEval("isis.methodAnalyse<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"isis.simule\"=isis.simule,call_method=\""
+ + aovCall
+ + "\""
+ + ",\"analysis_result\"=list(aovresult,IndSensibilite))");
+
+ log
+ .info("Message sent to R : "
+ + "attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\"");
+ engine
+ .voidEval("attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\"");
+
+ 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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ engine.terminate();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ // Error while processing
+ }
+
+ }
+
+ @Override
+ public String getDescription() {
+ return "Implementation of Expand Grid method using Java";
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorJavaExpandGrid.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRFast.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRFast.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRFast.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,609 @@
+/* *##%
+ * Copyright (C) 2006 - 2009 Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package sensitivity;
+
+import java.io.File;
+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;
+import org.codelutin.j2r.RException;
+import org.codelutin.j2r.RProxy;
+import org.codelutin.math.matrix.MatrixFactory;
+import org.codelutin.math.matrix.MatrixND;
+import org.codelutin.util.FileUtil;
+import org.rosuda.JRI.REXP;
+
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
+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.SensitivityScenarios;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
+import fr.ifremer.isisfish.util.Doc;
+
+/**
+ * Implementation of Fast method using R.
+ *
+ * @author jcouteau
+ * @version $Revision$
+ *
+ * Last update : $Date$ By :
+ * $Author: jcouteau $
+ */
+public class SensitivityCalculatorRFast extends AbstractSensitivityCalculator {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ 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=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=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;
+
+ /**
+ * Retourne vrai si le calculateur sait gerer la cardinalité des facteurs
+ * continue.
+ *
+ * @return <tt>true</tt> s'il sait la gerer
+ */
+ @Override
+ public boolean canManageCardinality() {
+ return true;
+ }
+
+ @Override
+ public SensitivityScenarios compute(DesignPlan plan, File outputdirectory) {
+
+ setIsisFactorsR(plan, outputdirectory);
+
+ double[] dataframe = new double[0];
+ int nbExperiments = 0;
+ int factorNumber = plan.getFactors().size();
+ List<Factor<?, ?>> factors = plan.getFactors();
+ SensitivityScenarios thisExperiment = new SensitivityScenarios();
+ List<Scenario> thisExperimentScenarios = thisExperiment.getScenarios();
+
+ //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,
+ factors.get(i).getName()
+ + " has a discrete domain, this is not acceptable for this method.",
+ "Error", JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ }
+ String rInstruction = "a<-fast99(model=NULL,factors=%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);
+
+ 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 {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".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(rCall);
+ log.info("Message sent to R" + rCall);
+
+ // Creating the factors vector.
+ rInstruction = "factornames<-c(";
+ for (int i = 0; i < factorNumber; i++) {
+ if (i != (factorNumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R" + rInstruction);
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R" + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Export the fast99 object for the second run in a .fast99 file
+ engine.voidEval("dput(a,file=\".fast99\")");
+ log.info("Message sent to R" + "dput(a,file=\".fast99\")");
+
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R"
+ + "dput(factornames,file=\".factornames\")");
+
+ // Get back experiment plan
+
+ Vector<REXP> dataframeVector = (Vector<REXP>) engine.eval("a$X");
+ dataframe = new double[dataframeVector.size()
+ * dataframeVector.get(0).asDoubleArray().length];
+ for (int i = 0; i < dataframeVector.size(); i++) {
+ for (int j = 0; j < dataframeVector.get(0).asDoubleArray().length; j++) {
+ if (String.valueOf(
+ dataframeVector.get(i).asDoubleArray()[j])
+ .toString().equals("NaN")) {
+ log
+ .error("Wrong parameters for the fast method, non-numeric values were generated");
+ JOptionPane
+ .showMessageDialog(
+ null,
+ "The parameters for this method need to be changed, non-numeric values where generated (you may want to increase the n parameter)",
+ "Error", JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ dataframe[i * dataframeVector.get(0).asDoubleArray().length
+ + j] = dataframeVector.get(i).asDoubleArray()[j];
+ }
+ }
+
+ log.info("Message sent to R" + "a$X");
+
+ if (log.isDebugEnabled()) {
+ log.debug("rInstruction = " + rInstruction);
+ }
+
+ 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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ } catch (RException eee) {
+ eee.printStackTrace();
+ throw new RuntimeException("R evaluation failed", eee);
+ // Error while retrieving scenario
+ }
+
+ // Transform the result from R in a matrix
+ MatrixND fast = MatrixFactory.getInstance().create(dataframe,
+ new int[] { factorNumber, nbExperiments });
+
+ // Setting up the scenarios.
+ for (int j = 0; j < nbExperiments; j++) {
+ Scenario experimentScenario = new Scenario();
+ for (int i = 0; i < factorNumber; i++) {
+ Factor factor = plan.getFactors().get(i);
+ if ((factor.getDomain() instanceof MatrixContinuousDomain)
+ || (factor.getDomain() instanceof EquationContinuousDomain)) {
+ factor.setValueForIdentifier(fast
+ .getValue(new int[] { i, j }));
+ } else {
+ Double value = (Double) ((ContinuousDomain) factor
+ .getDomain()).getMinBound()
+ + ((Double) ((ContinuousDomain) factor.getDomain())
+ .getMaxBound() - (Double) ((ContinuousDomain) factor
+ .getDomain()).getMinBound())
+ * fast.getValue(new int[] { i, j });
+ factor.setValueForIdentifier(value);
+ }
+ experimentScenario.addFactor(factor);
+ }
+ thisExperimentScenarios.add(experimentScenario);
+ thisExperiment.setScenarios(thisExperimentScenarios);
+ }
+ return thisExperiment;
+
+ }
+
+ @Override
+ public void analyzeResult(List<SimulationStorage> simulationStorages,
+ File outputdirectory) {
+
+ REngine engine = new RProxy();
+ try {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ // Call R
+ // Load sensitivity package into R (if package already loaded,
+ // nothing happens.
+ engine.voidEval("library(sensitivity)");
+ log.info("Message sent to R : " + "library(sensitivity)");
+
+ //Set the working directory (for import and exports)
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Export the morris object for the second run in a .morris file
+ engine.voidEval("a<-dget(\".fast99\")");
+ log.info("Message sent to R : " + "a<-dget(\".fast99\")");
+
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
+ /*int scenariosNumber = sensitivityScenarios.getScenarios().size();*/
+ int scenariosNumber = (Integer) engine.eval("length(a$X[,1])");
+ log.info("Message sent to R : " + "length(a$X[,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 = 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, 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) {
+ rInstruction = rInstruction + simulationResult + ",";
+ } else {
+ rInstruction = rInstruction + simulationResult;
+ }
+ }
+ rInstruction = rInstruction + ")";
+
+ log.info("Message sent to R : " + rInstruction);
+
+ // 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
+ + ")");
+ 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 = param.getSensitivityExport().get(k)
+ .getExportFilename();
+
+ //Compute 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().replaceAll("\\\\",
+ "/") + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
+ //Set V names
+ engine.voidEval("names(a$V)<-factornames");
+ log.info("Message sent to R : " + "names(a$V)<-factornames");
+
+ //Export V
+ engine.voidEval("write.csv(a$V,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_V.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(a$V,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_V.csv\")");
+
+ //Set D1 names
+ engine.voidEval("names(a$D1)<-factornames");
+ log.info("Message sent to R : " + "names(a$D1)<-factornames");
+
+ //Export D1
+ engine.voidEval("write.csv(a$D1,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_D1.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(a$D1,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_D1.csv\")");
+
+ //Set Dt names
+ engine.voidEval("names(a$Dt)<-factornames");
+ log.info("Message sent to R : " + "names(a$Dt)<-factornames");
+
+ //Export Dt
+ engine.voidEval("write.csv(a$Dt,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Dt.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(a$Dt,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Dt.csv\")");
+ //Set dfresults names
+ engine.voidEval("resultsnames<-c(factornames,\"Result\")");
+ log.info("Message sent to R : "
+ + "resultsnames<-c(factornames,\"Result\")");
+ engine.voidEval("names(dfresults)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dfresults)<-resultsnames");
+
+ //Export results
+ engine.voidEval("write.csv(dfresults,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(results,\""
+ + param.getSensitivityExport().get(k)
+ .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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public String getDescription() {
+ return "Implementation of FAST method using R";
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRFast.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRFrF2.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRFrF2.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRFrF2.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,525 @@
+/* *##%
+ * Copyright (C) 2006 - 2009 Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package sensitivity;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.j2r.REngine;
+import org.codelutin.j2r.RException;
+import org.codelutin.j2r.RProxy;
+import org.codelutin.math.matrix.MatrixFactory;
+import org.codelutin.math.matrix.MatrixND;
+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;
+import fr.ifremer.isisfish.simulator.sensitivity.Scenario;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityScenarios;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
+import fr.ifremer.isisfish.util.Doc;
+
+/**
+ * Implementation of FrF2 method using R.
+ *
+ * @author jcouteau
+ * @version $Revision$
+ *
+ * Last update : $Date$ By :
+ * $Author: chatellier $
+ */
+public class SensitivityCalculatorRFrF2 extends AbstractSensitivityCalculator {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ private static Log log = LogFactory
+ .getLog(SensitivityCalculatorRFrF2.class);
+
+ @Doc("is the arabic numeral for the requested resolution of the design( 3 <= resolution <= 5). (if resolution=3, model = sum(Xi), if resolution = 4 or 5, model = sum(Xi)+sum(XiXj)")
+ public int param_resolution;
+
+ /**
+ * Retourne vrai si le calculateur sait gerer la cardinalité des facteurs
+ * continue.
+ *
+ * @return <tt>true</tt> s'il sait la gerer
+ */
+ @Override
+ public boolean canManageCardinality() {
+ return true;
+ }
+
+ @Override
+ public SensitivityScenarios compute(DesignPlan plan, File outputdirectory) {
+
+ double[] dataframe = new double[0];
+ int nbExperiments = 0;
+ int factorNumber = plan.getFactors().size();
+ List<Factor<?, ?>> factors = plan.getFactors();
+ SensitivityScenarios thisExperiment = new SensitivityScenarios();
+ List<Scenario> thisExperimentScenarios = thisExperiment.getScenarios();
+
+ //Test all factors, if one is discrete, return null
+ for (int i = 0; i < factorNumber; i++) {
+ if (factors.get(i).getDomain() instanceof DiscreteDomain) {
+ return null;
+ }
+ }
+
+ REngine engine = new RProxy();
+
+ try {
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ engine.voidEval("library(FrF2)");
+ log.info("Message sent to R : " + "library(FrF2)");
+
+ //Set the working directory (for import and exports)
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ String rInstruction = "a<-FrF2(nfactors=" + factorNumber
+ + ",resolution=" + param_resolution + ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R : " + rInstruction);
+
+ // Export the FrF2 object for the second run in a .FrF2 file
+ engine.voidEval("dput(a,file=\".FrF2\")");
+ log.info("Message sent to R" + "dput(a,file=\".FrF2\")");
+
+ // Get back experiment plan
+ dataframe = (double[]) engine.eval("a$desnum");
+ /*Vector<REXP> dataframeVector = (Vector<REXP>) engine.eval("a$X");
+ dataframe = new double[dataframeVector.size()
+ * dataframeVector.get(0).asDoubleArray().length];
+ for (int i = 0; i < dataframeVector.size(); i++) {
+ for (int j = 0; j < dataframeVector.get(0).asDoubleArray().length; j++) {
+ dataframe[i * dataframeVector.get(0).asDoubleArray().length
+ + j] = dataframeVector.get(i).asDoubleArray()[j];
+ }
+ }*/
+ log.info("Message sent to R : " + "a$desnum");
+
+ // Creating the factors vector.
+ rInstruction = "factornames<-c(";
+ for (int i = 0; i < factorNumber; i++) {
+ if (i != (factorNumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R : " + rInstruction);
+
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R : "
+ + "dput(factornames,file=\".factornames\")");
+
+ } catch (RException e) {
+ e.printStackTrace();
+ }
+
+ nbExperiments = dataframe.length / factorNumber;
+
+ // Transform the result from R in a matrix
+ MatrixND frf2 = MatrixFactory.getInstance().create(dataframe,
+ new int[] { factorNumber, nbExperiments });
+
+ // Setting up the scenarios.
+ for (int j = 0; j < nbExperiments; j++) {
+ Scenario experimentScenario = new Scenario();
+ for (int i = 0; i < factorNumber; i++) {
+ Factor factor = plan.getFactors().get(i);
+ if ((factor.getDomain() instanceof MatrixContinuousDomain)
+ || (factor.getDomain() instanceof EquationContinuousDomain)) {
+ if (frf2.getValue(new int[] { i, j }) == -1) {
+ factor.setValueForIdentifier(0);
+ }
+
+ if (frf2.getValue(new int[] { i, j }) == 1) {
+ factor.setValueForIdentifier(1);
+ }
+ } else {
+ if (frf2.getValue(new int[] { i, j }) == -1) {
+ factor.setValueForIdentifier(((ContinuousDomain) factor
+ .getDomain()).getMinBound());
+ }
+
+ if (frf2.getValue(new int[] { i, j }) == 1) {
+ factor.setValueForIdentifier(((ContinuousDomain) factor
+ .getDomain()).getMaxBound());
+ }
+ }
+ experimentScenario.addFactor(factor);
+ }
+ thisExperimentScenarios.add(experimentScenario);
+ thisExperiment.setScenarios(thisExperimentScenarios);
+ }
+ try {
+ //Create the factors vectors
+ for (int j = 0; j < factorNumber; j++) {
+ Factor factor = thisExperimentScenarios.get(0).getFactors()
+ .get(j);
+ if (factor.getDomain() instanceof EquationContinuousDomain) {
+
+ String vector = "factor" + j + "<-c(";
+ for (int i = 0; i < nbExperiments; i++) {
+ if (i < (nbExperiments - 1)) {
+ vector = vector
+ + ((EquationContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue() + ",";
+ } else {
+ vector = vector
+ + ((EquationContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ } else if (factor.getDomain() instanceof MatrixContinuousDomain) {
+ String vector = "factor" + j + "<-c(";
+ for (int i = 0; i < nbExperiments; i++) {
+ if (i < (nbExperiments - 1)) {
+ vector = vector
+ + ((MatrixContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue() + ",";
+ } else {
+ vector = vector
+ + ((MatrixContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ } else {
+ String vector = "factor" + j + "<-c(";
+ for (int i = 0; i < nbExperiments; i++) {
+ if (i < (nbExperiments - 1)) {
+ vector = vector
+ + thisExperimentScenarios.get(i)
+ .getFactors().get(j).getValue()
+ + ",";
+ } else {
+ vector = vector
+ + thisExperimentScenarios.get(i)
+ .getFactors().get(j).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ }
+ }
+
+ //Create the data data.frame from the factors
+ String data = "data<-data.frame(";
+ for (int j = 0; j < factorNumber; j++) {
+ if (j < factorNumber - 1) {
+ data = data + "factor" + j + "=factor(factor" + j + "),";
+ } else {
+ data = data + "factor" + j + "=factor(factor" + j + "))";
+ }
+
+ }
+ engine.voidEval(data);
+ log.info("Message sent to R : " + data);
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Export the scenario matrix for the second run in a .FrF2.csv file
+ engine.voidEval("write.csv(data,file=\".FrF2.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(data,file=\".FrF2.csv\")");
+
+ engine.terminate();
+
+ } catch (RException e) {
+ e.printStackTrace();
+ }
+ return thisExperiment;
+
+ }
+
+ @Override
+ public void analyzeResult(List<SimulationStorage> simulationStorages,
+ File outputdirectory) {
+
+ REngine engine = new RProxy();
+ try {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ SimulationParameter param = simulationStorages.get(0)
+ .getParameter();
+ int sensitivityNumber = param.getSensitivityExport().size();
+
+ for (int k = 0; k < sensitivityNumber; k++) {
+
+ engine.voidEval("library(FrF2)");
+ log.info("Message sent to R : " + "library(FrF2)");
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+
+ //Get back the FrF2 object
+ engine.voidEval("a<-dget(\".FrF2\")");
+ log.info("Message sent to R : a<-dget(\".FrF2\")");
+
+ //Get back the scenarios
+ engine.voidEval("factors<-read.csv(\".FrF2.csv\")");
+ log
+ .info("Message sent to R : factors<-read.csv(\".FrF2.csv\")");
+
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
+ //Get back the factors number
+ int factorNumber = ((Double) engine.eval("length(factors)-1"))
+ .intValue();
+
+ // 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, 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) {
+ rInstruction = rInstruction + simulationResult + ",";
+ } else {
+ rInstruction = rInstruction + simulationResult;
+ }
+ }
+ 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);
+ log.info("Message sent to R : " + dataframe);
+
+ //get back the resolution
+ int resolution = (Integer) engine.eval("res.catlg(a$catentry)");
+ log.info("Message sent to R : " + "res.catlg(a$catentry)");
+
+ String aovCall;
+
+ switch (resolution) {
+ case 3:
+ //Call aov()
+ aovCall = "aovresult<-aov(result~";
+ for (int j = 0; j < factorNumber; j++) {
+ if (j < (factorNumber - 1)) {
+ aovCall = aovCall + "factor" + j + "+";
+ } else {
+ aovCall = aovCall + "factor" + j
+ + ",data=dataforaov)";
+ }
+ }
+ engine.voidEval(aovCall);
+ log.info("Message sent to R : " + aovCall);
+ break;
+ case 4:
+ aovCall = "aovresult<-aov(result~";
+ for (int j = 0; j < factorNumber; j++) {
+ aovCall = aovCall + "factor" + j + "+";
+ }
+ for (int i = 0; i < factorNumber; i++) {
+ for (int j = 0; j < factorNumber; j++) {
+ if (i < j) {
+ aovCall = aovCall + "factor" + i + "*factor"
+ + j + "+";
+ }
+ }
+ }
+ aovCall = aovCall.substring(0, aovCall.length() - 1);
+ aovCall = aovCall + ",data=dataforaov)";
+ engine.voidEval(aovCall);
+ log.info("Message sent to R : " + aovCall);
+ break;
+ case 5:
+ aovCall = "aovresult<-aov(result~";
+ for (int j = 0; j < factorNumber; j++) {
+ aovCall = aovCall + "factor" + j + "+";
+ }
+ for (int i = 0; i < factorNumber; i++) {
+ for (int j = 0; j < factorNumber; j++) {
+ if (i < j) {
+ aovCall = aovCall + "factor" + i + "*factor"
+ + j + "+";
+ }
+ }
+ }
+ aovCall = aovCall.substring(0, aovCall.length() - 1);
+ aovCall = aovCall + ",data=dataforaov)";
+ engine.voidEval(aovCall);
+ log.info("Message sent to R : " + aovCall);
+ break;
+ default:
+ log.info("This resolution is not managed");
+ break;
+ }
+
+ /*Export the results
+ *Export format is csv, data separated by ','
+ *Results Export name is sensitivityExportName_Results.csv
+ *Sensitivity Indices export name is sensitivityExportName_SensitivityIndices.csv
+ */
+
+ //Compute Sum of Squares and Sensitivity indices
+ engine.voidEval("SoS<-summary(aovresult)[[1]][1:"
+ + factorNumber + ",2]");
+ log.info("Message sent to R : SoS<-summary(aovresult)[[1]][1:"
+ + factorNumber + ",2]");
+ engine
+ .voidEval("names(SoS)<-dimnames(summary(aovresult)[[1]])[[1]][1:"
+ + factorNumber + "]");
+ log
+ .info("Message sent to R : names(SoS)<-dimnames(summary(aovresult)[[1]])[[1]][1:"
+ + factorNumber + "]");
+ engine.voidEval("IndSensibilite<-SoS/sum(SoS)");
+ log.info("Message sent to R : IndSensibilite<-SoS/sum(SoS)");
+
+ //Create a data.frame to export sensitivity important results in one file.
+ engine.voidEval("exportsensitivity=data.frame(SoS[1:"
+ + factorNumber + "],IndSensibilite[1:" + factorNumber
+ + "])");
+ log
+ .info("Message sent to R : exportsensitivity=data.frame(SoS[1:"
+ + factorNumber
+ + "],IndSensibilite[1:"
+ + factorNumber + "])");
+ engine
+ .voidEval("names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ log
+ .info("Message sent to R : names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+
+ engine.voidEval("row.names(exportsensitivity)<-factornames");
+ log.info("Message sent to R : "
+ + "row.names(exportsensitivity)<-factornames");
+
+ /*Set the export directory
+ *Export directory is the first simulation export directory.
+ */
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+
+ //Set dataforaov names
+ engine
+ .voidEval("resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ engine.voidEval("names(dataforaov)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dataforaov)<-resultsnames");
+
+ //Save the results with the scenarios.
+ engine.voidEval("write.csv(dataforaov,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+ log.info("Message sent to R : write.csv(dataforaov,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+
+ //Save the sensitivity indices
+ engine.voidEval("write.csv(exportsensitivity,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ log.info("Message sent to R : write.csv(exportsensitivity,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ //FIXME export through java to enable export when using Rserve (when distant Rserve).
+ engine.terminate();
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ // Error while processing
+ }
+
+ }
+
+ @Override
+ public String getDescription() {
+ return "Implementation of FrF2 method method using R, at least 4 factors need to be declared";
+ }
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRFrF2.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRMorris.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRMorris.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRMorris.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,572 @@
+/* *##%
+ * Copyright (C) 2006 - 2009 Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package sensitivity;
+
+import java.io.File;
+import java.util.List;
+
+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;
+import org.codelutin.j2r.RException;
+import org.codelutin.j2r.RProxy;
+import org.codelutin.math.matrix.MatrixFactory;
+import org.codelutin.math.matrix.MatrixND;
+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;
+import fr.ifremer.isisfish.simulator.sensitivity.Factor;
+import fr.ifremer.isisfish.simulator.sensitivity.Scenario;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityScenarios;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
+import fr.ifremer.isisfish.util.Doc;
+
+/**
+ * Implementation of Morris method using R.
+ *
+ * @author jcouteau
+ * @version $Revision$
+ *
+ * Last update : $Date$ By :
+ * $Author: jcouteau $
+ */
+public class SensitivityCalculatorRMorris extends AbstractSensitivityCalculator {
+
+ @Doc("Integer giving the number of repetitions of the design, i.e. the number of elementary effect computed per factor. (Default value : 4)")
+ public int param_r = 4;
+
+ @Doc("True to be able to modify the code sent to R")
+ public boolean param_modifR = false;
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ private static Log log = LogFactory
+ .getLog(SensitivityCalculatorRMorris.class);
+
+ /**
+ * Retourne vrai si le calculateur sait gerer la cardinalité des facteurs
+ * continue.
+ *
+ * @return <tt>true</tt> s'il sait la gerer
+ */
+ @Override
+ public boolean canManageCardinality() {
+ return false;
+ }
+
+ @Override
+ public SensitivityScenarios compute(DesignPlan plan, File outputdirectory) {
+
+ setIsisFactorsR(plan, outputdirectory);
+
+ double[] dataframe = new double[0];
+ int nbExperiments = 0;
+ int factorNumber = plan.getFactors().size();
+ List<Factor<?, ?>> factors = plan.getFactors();
+
+ if (param_r == 0) {
+ param_r = 4;
+ }
+
+ //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;
+ }
+ }
+
+ // Creating the vectors.
+ String factorNames = "";
+ String levels = "";
+ String gridJump = "";
+ String binf = "";
+ String bsup = "";
+ for (int i = 0; i < factorNumber; i++) {
+ Domain domain = factors.get(i).getDomain();
+ if (i != 0) {
+ factorNames += ",";
+ levels += ",";
+ gridJump += ",";
+ binf += ",";
+ bsup += ",";
+ }
+
+ factorNames += "\"" + factors.get(i).getName() + "\"";
+
+ levels += ((ContinuousDomain) domain).getCardinality();
+
+ gridJump += (Integer) (((ContinuousDomain) domain).getCardinality() / 2);
+
+ binf += ((ContinuousDomain) domain).getMinBound();
+
+ bsup += ((ContinuousDomain) domain).getMaxBound();
+ }
+
+ String rInstruction = "a<-morris(model=NULL,factors=c(%s),r=%s,design=list(type=\"oat\",levels=c(%s),grid.jump=c(%s)),binf=c(%s),bsup=c(%s))";
+
+ String rCall = String.format(rInstruction, factorNames, param_r,
+ levels, gridJump, binf, bsup);
+
+ 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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".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(rCall);
+ log.info("Message sent to R : " + rCall);
+
+ // Creating the factors vector.
+ rInstruction = "factornames<-c(%s)";
+ rCall = String.format(rInstruction, factorNames);
+
+ engine.voidEval(rCall);
+ log.info("Message sent to R : " + rCall);
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Export the morris object for the second run in a .morris file
+ engine.voidEval("dput(a,file=\".morris\")");
+ log.info("Message sent to R : " + "dput(a,file=\".morris\")");
+
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R : "
+ + "dput(factornames,file=\".factornames\")");
+
+ // Get back experiment plan
+ dataframe = (double[]) engine.eval("a$X");
+ log.info("Message sent to R : " + "a$X");
+
+ if (log.isDebugEnabled()) {
+ log.debug("rInstruction = " + rInstruction);
+ }
+
+ nbExperiments = dataframe.length / factorNumber;
+
+ String isisFactorDistribution = "isis.factor.distribution<-data.frame(NomFacteur=c(%s),NomDistribution=c(%s),ParametreDistribution=c(%s))";
+
+ String distribution = "";
+ String parameters = "";
+
+ for (int i = 0; i < factorNumber; i++) {
+ Domain domain = factors.get(i).getDomain();
+ if (i != 0) {
+ distribution += ",";
+ parameters += ",";
+ }
+
+ distribution += "\"qunif\"";
+ parameters += "\"[" + ((ContinuousDomain) domain).getMinBound()
+ + ";" + ((ContinuousDomain) domain).getMaxBound()
+ + "]\"";
+ }
+
+ 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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ } catch (RException eee) {
+ eee.printStackTrace();
+ throw new RuntimeException("R evaluation failed", eee);
+ // Error while retrieving scenario
+ }
+
+ // Transform the result from R in a matrix
+ MatrixND morris = MatrixFactory.getInstance().create(dataframe,
+ new int[] { factorNumber, nbExperiments });
+
+ // Setting up the scenarios.
+ SensitivityScenarios thisExperiment = new SensitivityScenarios();
+ List<Scenario> thisExperimentScenarios = thisExperiment.getScenarios();
+ for (int j = 0; j < nbExperiments; j++) {
+ Scenario experimentScenario = new Scenario();
+ for (int i = 0; i < factorNumber; i++) {
+ Factor factor = factors.get(i);
+ if ((factor.getDomain() instanceof MatrixContinuousDomain)
+ || (factor.getDomain() instanceof EquationContinuousDomain)) {
+ factor
+ .setValueForIdentifier((Double) morris.getValue(i,
+ j));
+ } else {
+ factor.setValueForIdentifier(morris.getValue(new int[] { i,
+ j }));
+ }
+ experimentScenario.addFactor(factor);
+ }
+ thisExperimentScenarios.add(experimentScenario);
+ thisExperiment.setScenarios(thisExperimentScenarios);
+ }
+ return thisExperiment;
+
+ }
+
+ @Override
+ public void analyzeResult(List<SimulationStorage> simulationStorages,
+ File outputdirectory) {
+
+ REngine engine = new RProxy();
+ try {
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ // Call R
+ // Load sensitivity package into R (if package already loaded,
+ // nothing happens.
+ engine.voidEval("library(sensitivity)");
+ log.info("Message sent to R : " + "library(sensitivity)");
+
+ //Set the working directory (for import and exports)
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Export the morris object for the second run in a .morris file
+ engine.voidEval("a<-dget(\".morris\")");
+ log.info("Message sent to R : " + "a<-dget(\".morris\")");
+
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
+ int scenariosNumber = ((Double) engine
+ .eval("length(a$X)/length(a$factors)")).intValue();
+ log.info("Message sent to R : " + "length(a$X)/length(a$factors)");
+
+ 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 = 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, 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) {
+ rInstruction = rInstruction + simulationResult + ",";
+ } else {
+ rInstruction = rInstruction + simulationResult;
+ }
+ }
+ 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
+ + ")");
+ 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 = param.getSensitivityExport().get(k)
+ .getExportFilename();
+
+ //Compute 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\")");
+
+ // Get back the sensitivity results, mu, mu star and sigma.
+ engine.voidEval("mu<-apply(a$ee, 2, mean)");
+ log.info("Message sent to R : " + "mu<-apply(a$ee, 2, mean)");
+ engine
+ .voidEval("mu.star <- apply(a$ee, 2, function(a) mean(abs(a)))");
+ log
+ .info("Message sent to R : "
+ + "mu.star <- apply(a$ee, 2, function(a) mean(abs(a)))");
+ engine.voidEval("sigma <- apply(a$ee, 2, sd)");
+ log
+ .info("Message sent to R : "
+ + "sigma <- apply(a$ee, 2, sd)");
+
+ //Create the data.frame of sensitivity indices for export purpose
+ engine.voidEval("df=data.frame(mu,mu.star,sigma)");
+ log.info("Message sent to R : "
+ + "df=data.frame(mu,mu.star,sigma)");
+ engine.voidEval("row.names(df)<-factornames");
+ log.info("Message sent to R : " + "row.names(df)<-factornames");
+
+ //Create the data.frame of scenarios and results for export purpose
+ engine.voidEval("dfresults=data.frame(a$X,name)");
+ log.info("Message sent to R : "
+ + "dfresults=data.frame(a$X,name)");
+
+ //Set dfresults names
+ engine
+ .voidEval("resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ engine.voidEval("names(dfresults)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dfresults)<-resultsnames");
+
+ //Set working directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+
+ //Export sensitivity indices
+ engine.voidEval("write.csv(df,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(df,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+
+ //Export results
+ engine.voidEval("write.csv(dfresults,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(results,\""
+ + param.getSensitivityExport().get(k)
+ .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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Override
+ public String getDescription() {
+ return "Implementation of Morris method using R";
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRMorris.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorROptimumLHS.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorROptimumLHS.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorROptimumLHS.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,724 @@
+/* *##%
+ * Copyright (C) 2006 - 2009 Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package sensitivity;
+
+import java.io.File;
+import java.util.List;
+
+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;
+import org.codelutin.j2r.RProxy;
+import org.codelutin.math.matrix.MatrixFactory;
+import org.codelutin.math.matrix.MatrixND;
+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;
+import fr.ifremer.isisfish.simulator.sensitivity.Factor;
+import fr.ifremer.isisfish.simulator.sensitivity.Scenario;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityException;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityScenarios;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
+import fr.ifremer.isisfish.util.Doc;
+
+/**
+ * save.image() Implementation of Optimum Latin Hypercube method using R.
+ *
+ * @author jcouteau
+ * @version $Revision$
+ */
+public class SensitivityCalculatorROptimumLHS extends
+ AbstractSensitivityCalculator {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityCalculatorROptimumLHS.class);
+
+ @Doc("Number of simulations (default=10)")
+ public int param_simulationNumber = 10;
+ @Doc("The maximum number of times the Columnwise Pairwise algorithm is applied to all the columns(default=2).")
+ public int param_MaxSweeps = 2;
+ @Doc("The optimal stopping criterion (between 0 and 1) (default=0.1).")
+ public double param_eps = 0.1;
+ @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
+ * continue.
+ *
+ * @return <tt>true</tt> s'il sait la gerer
+ */
+ @Override
+ public boolean canManageCardinality() {
+ return true;
+ }
+
+ @Override
+ public SensitivityScenarios compute(DesignPlan plan, File outputdirectory)
+ throws SensitivityException {
+
+ setIsisFactorsR(plan, outputdirectory);
+
+ int factornumber = plan.getFactors().size();
+ List<Factor<?, ?>> factors = plan.getFactors();
+ double[] dataframe = new double[0];
+ SensitivityScenarios thisExperiment = new SensitivityScenarios();
+ List<Scenario> thisExperimentScenarios = thisExperiment.getScenarios();
+
+ //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;
+ }
+ }
+
+ REngine engine = new RProxy();
+
+ if ((Integer) param_simulationNumber == 0) {
+ param_simulationNumber = 10;
+ }
+ if ((Integer) param_MaxSweeps == 0) {
+ param_MaxSweeps = 2;
+ }
+
+ if ((Double) param_eps == 0) {
+ param_eps = 0.1;
+ }
+
+ try {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ //Load the lhs library
+ engine.voidEval("library(lhs)");
+ log.info("Message sent to R : " + "library(lhs)");
+
+ //Remove all objects that will be used
+ engine.voidEval("remove(\"isis.factor.distribution\")");
+ engine.voidEval("remove(\"isis.simule\")");
+ engine.voidEval("remove(\"isis.MethodExp\")");
+ engine.voidEval("remove(\"isis.methodAnalyse\")");
+
+ String rInstruction = "x<-optimumLHS(n=%s,k=%s,maxSweeps=%s,eps=%s)";
+
+ String rCall = String.format(rInstruction, param_simulationNumber,
+ factornumber, param_MaxSweeps, param_eps);
+
+ 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();
+ }
+
+ //Create the scenarios
+ engine.voidEval(rCall);
+ log.info("Message sent to R : " + rCall);
+
+ // Get back experiment plan
+ dataframe = (double[]) engine.eval("x");
+ log.info("Message sent to R : " + "x");
+
+ // Transform the result from R in a matrix
+ MatrixND morris = MatrixFactory.getInstance().create(dataframe,
+ new int[] { factornumber, param_simulationNumber });
+
+ // Setting up the scenarios.
+ for (int j = 0; j < param_simulationNumber; j++) {
+ Scenario experimentScenario = new Scenario();
+ for (int i = 0; i < factornumber; i++) {
+ Factor factor = plan.getFactors().get(i);
+ if ((factor.getDomain() instanceof MatrixContinuousDomain)
+ || (factor.getDomain() instanceof EquationContinuousDomain)) {
+ factor.setValueForIdentifier(morris.getValue(new int[] {
+ i, j }));
+ } else {
+ Double value = (Double) ((ContinuousDomain) factor
+ .getDomain()).getMinBound()
+ + ((Double) ((ContinuousDomain) factor
+ .getDomain()).getMaxBound() - (Double) ((ContinuousDomain) factor
+ .getDomain()).getMinBound())
+ * morris.getValue(new int[] { i, j });
+ factor.setValueForIdentifier(value);
+ }
+ experimentScenario.addFactor(factor);
+ }
+ thisExperimentScenarios.add(experimentScenario);
+ thisExperiment.setScenarios(thisExperimentScenarios);
+ }
+
+ String isisFactorDistribution = "isis.factor.distribution<-data.frame(NomFacteur=c(%s),NomDistribution=c(%s),ParametreDistribution=c(%s))";
+
+ String distribution = "";
+ String parameters = "";
+ String factorNames = "";
+
+ for (int i = 0; i < factors.size(); i++) {
+ Domain domain = factors.get(i).getDomain();
+ if (i != 0) {
+ distribution += ",";
+ factorNames += ",";
+ parameters += ",";
+ }
+
+ factorNames += "\"" + factors.get(i).getName() + "\"";
+ distribution += "\"qunif\"";
+ parameters += "\"[" + ((ContinuousDomain) domain).getMinBound()
+ + ";" + ((ContinuousDomain) domain).getMaxBound()
+ + "]\"";
+ }
+
+ 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<-" + "\"x<-optimumLHS(n="
+ + param_simulationNumber + ",k=" + factornumber
+ + ",maxSweeps=" + param_MaxSweeps + ",eps=" + param_eps
+ + ")\"");
+ engine.voidEval("call<-" + "\"x<-optimumLHS(n="
+ + param_simulationNumber + ",k=" + factornumber
+ + ",maxSweeps=" + param_MaxSweeps + ",eps=" + param_eps
+ + ")\"");
+
+ 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(x)");
+ engine.voidEval("isis.simule<-data.frame(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]]");
+
+ String data = "data<-data.frame(";
+
+ //Create the factors vectors and the dataframe instruction
+ for (int j = 0; j < factors.size(); j++) {
+ Factor factor = thisExperimentScenarios.get(0).getFactors()
+ .get(j);
+ if (factor.getDomain() instanceof EquationContinuousDomain) {
+
+ //String vector = "factor" + j + "<-c(";
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < param_simulationNumber; i++) {
+ if (i < (param_simulationNumber - 1)) {
+ vector = vector
+ + ((EquationContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue() + ",";
+ } else {
+ vector = vector
+ + ((EquationContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ } else if (factor.getDomain() instanceof MatrixContinuousDomain) {
+ //String vector = "factor" + j + "<-c(";
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < param_simulationNumber; i++) {
+ if (i < (param_simulationNumber - 1)) {
+ vector = vector
+ + ((MatrixContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue() + ",";
+ } else {
+ vector = vector
+ + ((MatrixContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ } else {
+ //String vector = "factor" + j + "<-c(";
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < param_simulationNumber; i++) {
+ if (i < (param_simulationNumber - 1)) {
+ vector = vector
+ + thisExperimentScenarios.get(i)
+ .getFactors().get(j).getValue()
+ + ",";
+ } else {
+ vector = vector
+ + thisExperimentScenarios.get(i)
+ .getFactors().get(j).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ }
+
+ if (j < factors.size() - 1) {
+ data += factor.getName().replaceAll(" ", "") + "=factor("
+ + factor.getName().replaceAll(" ", "") + "),";
+ } else {
+ data += factor.getName().replaceAll(" ", "") + "=factor("
+ + factor.getName().replaceAll(" ", "") + "))";
+ }
+
+ }
+ engine.voidEval(data);
+ log.info("Message sent to R : " + data);
+
+ // Creating the factors vector.
+ rInstruction = "factornames<-c(";
+ for (int i = 0; i < factornumber; i++) {
+ if (i != (factornumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R" + rInstruction);
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Export the scenario matrix for the second run in a .optimumlhs.csv file
+ engine.voidEval("write.csv(data,file=\".optimumlhs.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(data,file=\".optimumlhs.csv\")");
+
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R"
+ + "dput(factornames,file=\".factornames\")");
+
+ //Set working directory to save Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ engine.terminate();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ // Error while processing
+ }
+
+ return thisExperiment;
+ }
+
+ @Override
+ public void analyzeResult(List<SimulationStorage> simulationStorages,
+ File outputdirectory) throws SensitivityException {
+
+ if ((Integer) param_simulationNumber == 0) {
+ param_simulationNumber = 10;
+ }
+ if ((Integer) param_MaxSweeps == 0) {
+ param_MaxSweeps = 2;
+ }
+
+ if ((Double) param_eps == 0) {
+ param_eps = 0.1;
+ }
+
+ REngine engine = new RProxy();
+ try {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get back the scenarios
+ engine.voidEval("factors<-read.csv(\".optimumlhs.csv\")");
+ log
+ .info("Message sent to R : factors<-read.csv(\".optimumlhs.csv\")");
+
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
+ //Get back the factors number
+ int factorNumber = ((Double) engine.eval("length(factors)-1"))
+ .intValue();
+
+ //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 = 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, 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) {
+ rInstruction = rInstruction + simulationResult + ",";
+ } else {
+ rInstruction = rInstruction + simulationResult;
+ }
+ }
+ rInstruction = rInstruction + ")";
+
+ log.info("Message sent to R : " + rInstruction);
+
+ // 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
+ + ")");
+ 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 = param.getSensitivityExport().get(k)
+ .getExportFilename();
+
+ //Create the dataforaov data.frame
+ String dataframe = "dataforaov<-data.frame(factors," + name
+ + "=" + name + ")";
+ engine.voidEval(dataframe);
+ log.info("Message sent to R : " + dataframe);
+
+ //Call aov()
+ String aovCall = "aovresult<-aov(" + name + "~";
+ for (int j = 0; j < factorNumber; j++) {
+ log.info("Message sent to R : " + "names(factors)["
+ + (j + 2) + "]");
+
+ if (j < (factorNumber - 1)) {
+ aovCall = aovCall
+ + engine
+ .eval("names(factors)[" + (j + 2) + "]")
+ + "+";
+ } else {
+ aovCall = aovCall
+ + engine
+ .eval("names(factors)[" + (j + 2) + "]")
+ + ",data=dataforaov)";
+ }
+ }
+ engine.voidEval(aovCall);
+ log.info("Message sent to R : " + aovCall);
+
+ /*Export the results
+ *Export format is csv, data separated by ','
+ *Results Export name is sensitivityExportName_Results.csv
+ *Sensitivity Indices export name is sensitivityExportName_SensitivityIndices.csv
+ */
+
+ //Compute Sum of Squares and Sensitivity indices
+ engine.voidEval("SoS<-summary(aovresult)[[1]][1:"
+ + factorNumber + ",2]");
+ log.info("Message sent to R : SoS<-summary(aovresult)[[1]][1:"
+ + factorNumber + ",2]");
+ engine
+ .voidEval("names(SoS)<-dimnames(summary(aovresult)[[1]])[[1]][1:"
+ + factorNumber + "]");
+ log
+ .info("Message sent to R : names(SoS)<-dimnames(summary(aovresult)[[1]])[[1]][1:"
+ + factorNumber + "]");
+ engine.voidEval("IndSensibilite<-SoS/sum(SoS)");
+ log.info("Message sent to R : IndSensibilite<-SoS/sum(SoS)");
+
+ //Create a data.frame to export sensitivity important results in one file.
+ engine.voidEval("exportsensitivity=data.frame(SoS[1:"
+ + factorNumber + "],IndSensibilite[1:" + factorNumber
+ + "])");
+ log
+ .info("Message sent to R : exportsensitivity=data.frame(SoS[1:"
+ + factorNumber
+ + "],IndSensibilite[1:"
+ + factorNumber + "])");
+ engine
+ .voidEval("names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ log
+ .info("Message sent to R : names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ engine.voidEval("row.names(exportsensitivity)<-factornames");
+ log.info("Message sent to R : "
+ + "row.names(exportsensitivity)<-factornames");
+
+ //Set dataforaov names
+ engine
+ .voidEval("resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ engine.voidEval("names(dataforaov)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dataforaov)<-resultsnames");
+
+ /*Set the export directory
+ *Export directory is the first simulation export directory.
+ */
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+
+ //Save the results with the scenarios.
+ engine.voidEval("write.csv(dataforaov,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+ log.info("Message sent to R : write.csv(dataforaov,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+
+ //Save the sensitivity indices
+ engine.voidEval("write.csv(exportsensitivity,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ log.info("Message sent to R : write.csv(exportsensitivity,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ //FIXME export through java to enable export when using Rserve (when distant Rserve).
+
+ //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=\""
+ + aovCall + "\""
+ + ",\"analysis_result\"=list(aovresult,IndSensibilite))");
+ engine
+ .voidEval("isis.methodAnalyse<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"isis.simule\"=isis.simule,call_method=\""
+ + aovCall
+ + "\""
+ + ",\"analysis_result\"=list(aovresult,IndSensibilite))");
+
+ log
+ .info("Message sent to R : "
+ + "attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\"");
+ engine
+ .voidEval("attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\"");
+
+ 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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ engine.terminate();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ // Error while processing
+ }
+
+ }
+
+ @Override
+ public String getDescription() {
+ return "Implementation of Random Latin Hypercube method method using R";
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorROptimumLHS.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRRandomLHS.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRRandomLHS.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRRandomLHS.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,699 @@
+/* *##%
+ * Copyright (C) 2006 - 2009 Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package sensitivity;
+
+import java.io.File;
+import java.util.List;
+
+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;
+import org.codelutin.j2r.RProxy;
+import org.codelutin.math.matrix.MatrixFactory;
+import org.codelutin.math.matrix.MatrixND;
+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;
+import fr.ifremer.isisfish.simulator.sensitivity.Factor;
+import fr.ifremer.isisfish.simulator.sensitivity.Scenario;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityException;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityScenarios;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
+import fr.ifremer.isisfish.util.Doc;
+
+/**
+ * Implementation of Random Latin Hypercube method using R.
+ *
+ * @author jcouteau
+ * @version $Revision$
+ */
+public class SensitivityCalculatorRRandomLHS extends
+ AbstractSensitivityCalculator {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityCalculatorRRandomLHS.class);
+
+ @Doc("Simulation number (default=10)")
+ public int param_simulationNumber = 10;
+ @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
+ * continue.
+ *
+ * @return <tt>true</tt> s'il sait la gerer
+ */
+ @Override
+ public boolean canManageCardinality() {
+ return true;
+ }
+
+ @Override
+ public SensitivityScenarios compute(DesignPlan plan, File outputdirectory)
+ throws SensitivityException {
+
+ setIsisFactorsR(plan, outputdirectory);
+
+ int factornumber = plan.getFactors().size();
+ double[] dataframe = new double[0];
+ SensitivityScenarios thisExperiment = new SensitivityScenarios();
+ List<Scenario> thisExperimentScenarios = thisExperiment.getScenarios();
+ List<Factor<?, ?>> factors = plan.getFactors();
+
+ //Test all factors, if one is discrete, return null
+ for (int i = 0; i < factors.size(); 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;
+ }
+ }
+
+ if ((Integer) param_simulationNumber == 0) {
+ param_simulationNumber = 10;
+ }
+
+ REngine engine = new RProxy();
+ try {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ //Set working directory for other results
+ log.info("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Load the lhs library
+ engine.voidEval("library(lhs)");
+ log.info("Message sent to R : " + "library(lhs)");
+
+ //Create the scenarios
+ String rInstruction = "x<-randomLHS(%s,%s)";
+ String rCall = String.format(rInstruction, param_simulationNumber,
+ factornumber);
+
+ 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();
+ }
+
+ engine.voidEval(rCall);
+ log.info("Message sent to R : " + rCall);
+
+ // Get back experiment plan
+ dataframe = (double[]) engine.eval("x");
+ log.info("Message sent to R" + "x");
+
+ // Transform the result from R in a matrix
+ MatrixND morris = MatrixFactory.getInstance().create(dataframe,
+ new int[] { factornumber, param_simulationNumber });
+
+ // Setting up the scenarios.
+ for (int j = 0; j < param_simulationNumber; j++) {
+ Scenario experimentScenario = new Scenario();
+ for (int i = 0; i < factornumber; i++) {
+ Factor factor = plan.getFactors().get(i);
+ if ((factor.getDomain() instanceof MatrixContinuousDomain)
+ || (factor.getDomain() instanceof EquationContinuousDomain)) {
+ factor.setValueForIdentifier(morris.getValue(new int[] {
+ i, j }));
+ } else {
+ Double value = (Double) ((ContinuousDomain) factor
+ .getDomain()).getMinBound()
+ + ((Double) ((ContinuousDomain) factor
+ .getDomain()).getMaxBound() - (Double) ((ContinuousDomain) factor
+ .getDomain()).getMinBound())
+ * morris.getValue(new int[] { i, j });
+ factor.setValueForIdentifier(value);
+ }
+ experimentScenario.addFactor(factor);
+ }
+ thisExperimentScenarios.add(experimentScenario);
+ thisExperiment.setScenarios(thisExperimentScenarios);
+ }
+
+ String isisFactorDistribution = "isis.factor.distribution<-data.frame(NomFacteur=c(%s),NomDistribution=c(%s),ParametreDistribution=c(%s))";
+
+ String distribution = "";
+ String parameters = "";
+ String factorNames = "";
+
+ for (int i = 0; i < factors.size(); i++) {
+ Domain domain = factors.get(i).getDomain();
+ if (i != 0) {
+ distribution += ",";
+ factorNames += ",";
+ parameters += ",";
+ }
+
+ factorNames += "\"" + factors.get(i).getName() + "\"";
+ distribution += "\"qunif\"";
+ parameters += "\"[" + ((ContinuousDomain) domain).getMinBound()
+ + ";" + ((ContinuousDomain) domain).getMaxBound()
+ + "]\"";
+ }
+
+ 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<-" + "\"x<-randomLHS("
+ + param_simulationNumber + "," + factornumber + ")\"");
+ engine.voidEval("call<-" + "\"x<-randomLHS("
+ + param_simulationNumber + "," + factornumber + ")\"");
+
+ 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(x)");
+ engine.voidEval("isis.simule<-data.frame(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]]");
+
+ String data = "data<-data.frame(";
+
+ //Create the factors vectors and the dataframe instruction
+ for (int j = 0; j < factors.size(); j++) {
+ Factor factor = thisExperimentScenarios.get(0).getFactors()
+ .get(j);
+ if (factor.getDomain() instanceof EquationContinuousDomain) {
+
+ //String vector = "factor" + j + "<-c(";
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < param_simulationNumber; i++) {
+ if (i < (param_simulationNumber - 1)) {
+ vector = vector
+ + ((EquationContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue() + ",";
+ } else {
+ vector = vector
+ + ((EquationContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ } else if (factor.getDomain() instanceof MatrixContinuousDomain) {
+ //String vector = "factor" + j + "<-c(";
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < param_simulationNumber; i++) {
+ if (i < (param_simulationNumber - 1)) {
+ vector = vector
+ + ((MatrixContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue() + ",";
+ } else {
+ vector = vector
+ + ((MatrixContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ } else {
+ //String vector = "factor" + j + "<-c(";
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < param_simulationNumber; i++) {
+ if (i < (param_simulationNumber - 1)) {
+ vector = vector
+ + thisExperimentScenarios.get(i)
+ .getFactors().get(j).getValue()
+ + ",";
+ } else {
+ vector = vector
+ + thisExperimentScenarios.get(i)
+ .getFactors().get(j).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ }
+
+ if (j < factors.size() - 1) {
+ data += factor.getName().replaceAll(" ", "") + "=factor("
+ + factor.getName().replaceAll(" ", "") + "),";
+ } else {
+ data += factor.getName().replaceAll(" ", "") + "=factor("
+ + factor.getName().replaceAll(" ", "") + "))";
+ }
+
+ }
+ engine.voidEval(data);
+ log.info("Message sent to R : " + data);
+
+ // Creating the factors vector.
+ rInstruction = "factornames<-c(";
+ for (int i = 0; i < factornumber; i++) {
+ if (i != (factornumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R" + rInstruction);
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Export the scenario matrix for the second run in a .randomlhs.csv file
+ engine.voidEval("write.csv(data,file=\".randomlhs.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(data,file=\".randomlhs.csv\")");
+
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R"
+ + "dput(factornames,file=\".factornames\")");
+
+ //Set working directory to save Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ engine.terminate();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ // Error while processing
+ }
+
+ return thisExperiment;
+ }
+
+ @Override
+ public void analyzeResult(List<SimulationStorage> simulationStorages,
+ File outputdirectory) throws SensitivityException {
+
+ if ((Integer) param_simulationNumber == 0) {
+ param_simulationNumber = 10;
+ }
+
+ REngine engine = new RProxy();
+ try {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get back the scenarios
+ engine.voidEval("factors<-read.csv(\".randomlhs.csv\")");
+ log
+ .info("Message sent to R : factors<-read.csv(\".randomlhs.csv\")");
+
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
+ //Get back the factors number
+ int factorNumber = ((Double) engine.eval("length(factors)-1"))
+ .intValue();
+
+ //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 = 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, 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) {
+ rInstruction = rInstruction + simulationResult + ",";
+ } else {
+ rInstruction = rInstruction + simulationResult;
+ }
+ }
+ 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
+ + ")");
+ 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 = param.getSensitivityExport().get(k)
+ .getExportFilename();
+
+ //Create the dataforaov data.frame
+ String dataframe = "dataforaov<-data.frame(factors," + name
+ + "=" + name + ")";
+ engine.voidEval(dataframe);
+ log.info("Message sent to R : " + dataframe);
+
+ //Call aov()
+ String aovCall = "aovresult<-aov(" + name + "~";
+ for (int j = 0; j < factorNumber; j++) {
+ log.info("Message sent to R : " + "names(factors)["
+ + (j + 2) + "]");
+
+ if (j < (factorNumber - 1)) {
+ aovCall = aovCall
+ + engine
+ .eval("names(factors)[" + (j + 2) + "]")
+ + "+";
+ } else {
+ aovCall = aovCall
+ + engine
+ .eval("names(factors)[" + (j + 2) + "]")
+ + ",data=dataforaov)";
+ }
+ }
+ engine.voidEval(aovCall);
+ log.info("Message sent to R : " + aovCall);
+
+ /*Export the results
+ *Export format is csv, data separated by ','
+ *Results Export name is sensitivityExportName_Results.csv
+ *Sensitivity Indices export name is sensitivityExportName_SensitivityIndices.csv
+ */
+
+ //Compute Sum of Squares and Sensitivity indices
+ engine.voidEval("SoS<-summary(aovresult)[[1]][1:"
+ + factorNumber + ",2]");
+ log.info("Message sent to R : SoS<-summary(aovresult)[[1]][1:"
+ + factorNumber + ",2]");
+ engine
+ .voidEval("names(SoS)<-dimnames(summary(aovresult)[[1]])[[1]][1:"
+ + factorNumber + "]");
+ log
+ .info("Message sent to R : names(SoS)<-dimnames(summary(aovresult)[[1]])[[1]][1:"
+ + factorNumber + "]");
+ engine.voidEval("IndSensibilite<-SoS/sum(SoS)");
+ log.info("Message sent to R : IndSensibilite<-SoS/sum(SoS)");
+
+ //Create a data.frame to export sensitivity important results in one file.
+ engine.voidEval("exportsensitivity=data.frame(SoS[1:"
+ + factorNumber + "],IndSensibilite[1:" + factorNumber
+ + "])");
+ log
+ .info("Message sent to R : exportsensitivity=data.frame(SoS[1:"
+ + factorNumber
+ + "],IndSensibilite[1:"
+ + factorNumber + "])");
+ engine
+ .voidEval("names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ log
+ .info("Message sent to R : names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ engine.voidEval("row.names(exportsensitivity)<-factornames");
+ log.info("Message sent to R : "
+ + "row.names(exportsensitivity)<-factornames");
+
+ //Set dataforaov names
+ engine
+ .voidEval("resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ engine.voidEval("names(dataforaov)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dataforaov)<-resultsnames");
+
+ /*Set the export directory
+ *Export directory is the first simulation export directory.
+ */
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+
+ //Save the results with the scenarios.
+ engine.voidEval("write.csv(dataforaov,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+ log.info("Message sent to R : write.csv(dataforaov,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+
+ //Save the sensitivity indices
+ engine.voidEval("write.csv(exportsensitivity,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ log.info("Message sent to R : write.csv(exportsensitivity,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ //FIXME export through java to enable export when using Rserve (when distant Rserve).
+
+ //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=\""
+ + aovCall + "\""
+ + ",\"analysis_result\"=list(aovresult,IndSensibilite))");
+ engine
+ .voidEval("isis.methodAnalyse<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"isis.simule\"=isis.simule,call_method=\""
+ + aovCall
+ + "\""
+ + ",\"analysis_result\"=list(aovresult,IndSensibilite))");
+
+ log
+ .info("Message sent to R : "
+ + "attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\"");
+ engine
+ .voidEval("attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\"");
+
+ 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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ engine.terminate();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ // Error while processing
+ }
+
+ }
+
+ @Override
+ public String getDescription() {
+ return "Implementation of Random Latin Hypercube method method using R";
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRRandomLHS.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRSobol.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRSobol.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRSobol.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,596 @@
+/* *##%
+ * Copyright (C) 2006 - 2009 Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package sensitivity;
+
+import java.io.File;
+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;
+import org.codelutin.j2r.RProxy;
+import org.codelutin.math.matrix.MatrixFactory;
+import org.codelutin.math.matrix.MatrixND;
+import org.codelutin.util.FileUtil;
+import org.rosuda.JRI.REXP;
+
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
+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.SensitivityScenarios;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
+import fr.ifremer.isisfish.util.Doc;
+
+/**
+ * Implementation of Sobol method using R.
+ *
+ * @author jcouteau
+ * @version $Revision$
+ *
+ * Last update : $Date$ By :
+ * $Author: jcouteau $
+ */
+public class SensitivityCalculatorRSobol extends AbstractSensitivityCalculator {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ private static Log log = LogFactory
+ .getLog(SensitivityCalculatorRFast.class);
+
+ @Doc("the size of the 2 random samples")
+ public int param_n = 20;
+
+ @Doc("the number of bootstrap replicates.")
+ public int param_nboot = 20;
+
+ @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
+ * continue.
+ *
+ * @return <tt>true</tt> s'il sait la gerer
+ */
+ @Override
+ public boolean canManageCardinality() {
+ return true;
+ }
+
+ @Override
+ public SensitivityScenarios compute(DesignPlan plan, File outputdirectory) {
+
+ setIsisFactorsR(plan, outputdirectory);
+
+ double[] dataframe = new double[0];
+ int nbExperiments = 0;
+ int factorNumber = plan.getFactors().size();
+ List<Factor<?, ?>> factors = plan.getFactors();
+ SensitivityScenarios thisExperiment = new SensitivityScenarios();
+ List<Scenario> thisExperimentScenarios = thisExperiment.getScenarios();
+
+ //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 {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ engine.voidEval("library(sensitivity)");
+ log.info("Message sent to R : " + "library(sensitivity)");
+
+ //Set the working directory (for import and exports)
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ engine.voidEval("X1<-data.frame(matrix(runif(" + factorNumber + "*"
+ + param_n + "),nrow=" + param_n + "))");
+ log
+ .info("Message sent to R : "
+ + "X1<-data.frame(matrix(runif(" + factorNumber
+ + "*" + param_n + "),nrow=" + param_n + "))");
+ engine.voidEval("X2<-data.frame(matrix(runif(" + factorNumber + "*"
+ + param_n + "),nrow=" + param_n + "))");
+ log
+ .info("Message sent to R : "
+ + "X2<-data.frame(matrix(runif(" + factorNumber
+ + "*" + param_n + "),nrow=" + param_n + "))");
+
+ engine.voidEval(rCall);
+ log.info("Message sent to R : " + rCall);
+
+ // Creating the factors vector.
+ rInstruction = "factornames<-c(";
+ for (int i = 0; i < factorNumber; i++) {
+ if (i != (factorNumber - 1)) {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\",";
+ } else {
+ rInstruction = rInstruction + "\""
+ + factors.get(i).getName() + "\"";
+ }
+ }
+
+ rInstruction += ")";
+
+ engine.voidEval(rInstruction);
+ log.info("Message sent to R" + rInstruction);
+
+ // Export the sobol object for the second run in a .sobol file
+ engine.voidEval("dput(a,file=\".sobol\")");
+ log.info("Message sent to R" + "dput(a,file=\".sobol\")");
+ // Export the X1 object for the second run in a .X1 file
+ engine.voidEval("dput(X1,file=\".X1\")");
+ log.info("Message sent to R" + "dput(a,file=\".sobol\")");
+ // Export the X2 object for the second run in a .X2 file
+ engine.voidEval("dput(X2,file=\".X2\")");
+ log.info("Message sent to R" + "dput(a,file=\".sobol\")");
+
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R"
+ + "dput(factornames,file=\".factornames\")");
+
+ // Get back experiment plan
+ /*dataframe = (double[]) engine.eval("a$X");*/
+
+ Vector<REXP> dataframeVector = (Vector<REXP>) engine.eval("a$X");
+ int dataframevectorsize = dataframeVector.size();
+ int dataframevectorlength = dataframeVector.get(0).asDoubleArray().length;
+ dataframe = new double[dataframevectorsize * dataframevectorlength];
+ for (int i = 0; i < dataframeVector.size(); i++) {
+ for (int j = 0; j < dataframeVector.get(0).asDoubleArray().length; j++) {
+ dataframe[i * dataframeVector.get(0).asDoubleArray().length
+ + j] = dataframeVector.get(i).asDoubleArray()[j];
+ }
+ }
+ log.info("Message sent to R : " + "a$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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Transform the result from R in a matrix
+ MatrixND fast = MatrixFactory.getInstance().create(dataframe,
+ new int[] { factorNumber, nbExperiments });
+
+ // Setting up the scenarios.
+ for (int j = 0; j < nbExperiments; j++) {
+ Scenario experimentScenario = new Scenario();
+ for (int i = 0; i < factorNumber; i++) {
+ Factor factor = plan.getFactors().get(i);
+ if ((factor.getDomain() instanceof MatrixContinuousDomain)
+ || (factor.getDomain() instanceof EquationContinuousDomain)) {
+ factor.setValueForIdentifier(fast
+ .getValue(new int[] { i, j }));
+ } else {
+ Double value = (Double) ((ContinuousDomain) factor
+ .getDomain()).getMinBound()
+ + ((Double) ((ContinuousDomain) factor.getDomain())
+ .getMaxBound() - (Double) ((ContinuousDomain) factor
+ .getDomain()).getMinBound())
+ * fast.getValue(new int[] { i, j });
+ factor.setValueForIdentifier(value);
+ }
+ experimentScenario.addFactor(factor);
+ }
+ thisExperimentScenarios.add(experimentScenario);
+ thisExperiment.setScenarios(thisExperimentScenarios);
+ }
+ return thisExperiment;
+
+ }
+
+ @Override
+ public void analyzeResult(List<SimulationStorage> simulationStorages,
+ File outputdirectory) {
+
+ REngine engine = new RProxy();
+ try {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ // Call R
+ // Load sensitivity package into R (if package already loaded,
+ // nothing happens.
+ engine.voidEval("library(sensitivity)");
+ log.info("Message sent to R : " + "library(sensitivity)");
+
+ //Set the working directory (for import and exports)
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Get the .X1 file
+ engine.voidEval("X1<-dget(\".X1\")");
+ log.info("Message sent to R : " + "X1<-dget(\".X1\")");
+ // Get the .X2 file
+ engine.voidEval("X2<-dget(\".X2\")");
+ log.info("Message sent to R : " + "X2<-dget(\".X2\")");
+ // Get the factornames object in the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
+ //Set X1 names
+ engine.voidEval("names(X1)<-factornames");
+ log.info("Message sent to R : " + "names(X1)<-factornames");
+ //Set X2 names
+ engine.voidEval("names(X2)<-factornames");
+ log.info("Message sent to R : " + "names(X2)<-factornames");
+
+ // Get the .sobol file
+ engine.voidEval("a<-dget(\".sobol\")");
+ log.info("Message sent to R : " + "a<-dget(\".sobol\")");
+
+ //Set a$X names
+ engine.voidEval("names(a$X)<-factornames");
+ log.info("Message sent to R : " + "names(a$X)<-factornames");
+
+ int scenariosNumber = (Integer) engine.eval("length(a$X[,1])");
+ log.info("Message sent to R : " + "length(a$X[,1])");
+
+ 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 = 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, 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) {
+ rInstruction = rInstruction + simulationResult + ",";
+ } else {
+ rInstruction = rInstruction + simulationResult;
+ }
+ }
+ rInstruction = rInstruction + ")";
+
+ log.info("Message sent to R : " + rInstruction);
+
+ // 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
+ + ")");
+ 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 = param.getSensitivityExport().get(k)
+ .getExportFilename();
+
+ //Compute 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().replaceAll("\\\\",
+ "/") + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+
+ //Export V
+ engine.voidEval("write.csv(a$V,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(a$V,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_V.csv\")");
+
+ //Export DD
+ engine.voidEval("write.csv(a$D,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_D.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(a$D,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_D.csv\")");
+
+ //Export S
+ engine.voidEval("write.csv(a$S,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_S.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(a$S,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_S.csv\")");
+
+ //Export results
+ engine.voidEval("write.csv(dfresults,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+ log.info("Message sent to R : "
+ + "write.csv(results,\""
+ + param.getSensitivityExport().get(k)
+ .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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public String getDescription() {
+ return "Implementation of Sobol method using R (use of the R sobol2002 method)";
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRSobol.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRegularFractions.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRegularFractions.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRegularFractions.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,664 @@
+package sensitivity;
+
+import java.io.File;
+import java.util.List;
+
+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;
+import org.codelutin.j2r.RException;
+import org.codelutin.j2r.RProxy;
+import org.codelutin.math.matrix.MatrixFactory;
+import org.codelutin.math.matrix.MatrixND;
+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;
+import fr.ifremer.isisfish.simulator.sensitivity.Factor;
+import fr.ifremer.isisfish.simulator.sensitivity.Scenario;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityException;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityScenarios;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityCalculatorRegularFractions extends
+ AbstractSensitivityCalculator {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ private static Log log = LogFactory
+ .getLog(SensitivityCalculatorRFrF2.class);
+
+ @Doc("the path of the directory where the R function is stored (do not indicate the RegularFractions.R file name)")
+ public String param_pathToFunction = "";
+
+ @Doc("unique prime number of levels of all input and unit factors")
+ public int param_p = 2;
+
+ @Doc("number of unit factors (so that there are N=p^r units)")
+ public int param_r = 2;
+
+ @Doc("resolution of the fraction")
+ public int param_resolution = 2;
+
+ @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
+ * continue.
+ *
+ * @return <tt>true</tt> s'il sait la gerer
+ */
+ @Override
+ public boolean canManageCardinality() {
+ return true;
+ }
+
+ @Override
+ public SensitivityScenarios compute(DesignPlan plan, File outputdirectory) {
+
+ setIsisFactorsR(plan, outputdirectory);
+
+ double[] dataframeplan = new double[0];
+ int factorNumber = plan.getFactors().size();
+ List<Factor<?, ?>> factors = plan.getFactors();
+ SensitivityScenarios thisExperiment = new SensitivityScenarios();
+ List<Scenario> thisExperimentScenarios = thisExperiment.getScenarios();
+
+ String factorNames = "";
+
+ //Test all factors, if one is discrete, return null
+ //Create a string with all factors names
+ for (int i = 0; i < factorNumber; i++) {
+ Domain domain = factors.get(i).getDomain();
+ if (i != 0) {
+ factorNames += ",";
+ }
+
+ factorNames += "\"" + factors.get(i).getName() + "\"";
+
+ if (domain 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;
+ }
+ }
+
+ REngine engine = new RProxy();
+
+ try {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //outputdirectory.getName();
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ //Set the working directory (to import the R function)
+ engine.voidEval("setwd(\""
+ + param_pathToFunction.replaceAll("\\\\", "/") + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + param_pathToFunction.replaceAll("\\\\", "/") + "\")");
+
+ //Import the function
+ log.info("source(\"regularfractions.R\")");
+ engine.voidEval("source(\"regularfractions.R\")");
+
+ //Create the instruction
+ String rInstruction = "x<-regular.fraction(%s,%s,%s,%s)";
+ String rCall = String.format(rInstruction, factors.size(), param_p,
+ param_r, param_resolution);
+
+ 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();
+ }
+
+ // Run function
+ engine.voidEval(rCall);
+ log.info("Message sent to R : " + rCall);
+
+ // Run function
+ engine.voidEval("call<-\"" + rCall + "\"");
+ log.info("Message sent to R : " + "call<-\"" + rCall + "\"");
+
+ // Creating the factors vector.
+ rInstruction = "factornames<-c(%s)";
+ rCall = String.format(rInstruction, factorNames);
+
+ engine.voidEval(rCall);
+ log.info("Message sent to R : " + rCall);
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : " + "setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Export the result object for the second run in a .regularfractions file
+ engine.voidEval("dput(x,file=\".regularfractions\")");
+ log.info("Message sent to R : "
+ + "dput(x,file=\".regularfractions\")");
+
+ // Export the factornames object for the second run in a .factornames file
+ engine.voidEval("dput(factornames,file=\".factornames\")");
+ log.info("Message sent to R : "
+ + "dput(factornames,file=\".factornames\")");
+
+ // Get back experiment plan
+ dataframeplan = (double[]) engine.eval("x[[1]]");
+ log.info("Message sent to R : " + "x[[1]]");
+
+ //Get back the simulation number
+ log.info("length(x[[1]][,1])");
+ int simulationNumber = (Integer) engine.eval("length(x[[1]][,1])");
+
+ // Transform the result from R in a matrix
+ MatrixND morris = MatrixFactory.getInstance().create(dataframeplan,
+ new int[] { factors.size(), simulationNumber });
+
+ // Setting up the scenarios.
+ for (int j = 0; j < simulationNumber; j++) {
+ Scenario experimentScenario = new Scenario();
+ for (int i = 0; i < factors.size(); i++) {
+ Factor factor = plan.getFactors().get(i);
+ if ((factor.getDomain() instanceof MatrixContinuousDomain)
+ || (factor.getDomain() instanceof EquationContinuousDomain)) {
+ factor.setValueForIdentifier(morris.getValue(new int[] {
+ i, j }));
+ } else {
+ Double value = (Double) ((ContinuousDomain) factor
+ .getDomain()).getMinBound()
+ + ((Double) ((ContinuousDomain) factor
+ .getDomain()).getMaxBound() - (Double) ((ContinuousDomain) factor
+ .getDomain()).getMinBound())
+ * (morris.getValue(new int[] { i, j }) / (param_p - 1));
+ factor.setValueForIdentifier(value);
+ }
+ experimentScenario.addFactor(factor);
+ }
+ thisExperimentScenarios.add(experimentScenario);
+ thisExperiment.setScenarios(thisExperimentScenarios);
+ }
+
+ String dataframe = "data<-data.frame(";
+
+ //Create the factors vectors and the dataframe instruction
+ for (int j = 0; j < factorNumber; j++) {
+ Factor factor = thisExperimentScenarios.get(0).getFactors()
+ .get(j);
+ if (factor.getDomain() instanceof EquationContinuousDomain) {
+
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < simulationNumber; i++) {
+ if (i < (simulationNumber - 1)) {
+ vector = vector
+ + ((EquationContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue() + ",";
+ } else {
+ vector = vector
+ + ((EquationContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ } else if (factor.getDomain() instanceof MatrixContinuousDomain) {
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < simulationNumber; i++) {
+ if (i < (simulationNumber - 1)) {
+ vector = vector
+ + ((MatrixContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue() + ",";
+ } else {
+ vector = vector
+ + ((MatrixContinuousDomain) thisExperimentScenarios
+ .get(i).getFactors().get(j)
+ .getDomain()).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ } else {
+ String vector = factor.getName().replaceAll(" ", "")
+ + "<-c(";
+ for (int i = 0; i < simulationNumber; i++) {
+ if (i < (simulationNumber - 1)) {
+ vector = vector
+ + thisExperimentScenarios.get(i)
+ .getFactors().get(j).getValue()
+ + ",";
+ } else {
+ vector = vector
+ + thisExperimentScenarios.get(i)
+ .getFactors().get(j).getValue();
+ }
+
+ }
+ vector = vector + ")";
+ engine.voidEval(vector);
+ log.info("Message sent to R : " + vector);
+ }
+
+ if (j < factorNumber - 1) {
+ dataframe = dataframe
+ + factor.getName().replaceAll(" ", "") + "=factor("
+ + factor.getName().replaceAll(" ", "") + "),";
+ } else {
+ dataframe += factor.getName().replaceAll(" ", "")
+ + "=factor(" + factor.getName().replaceAll(" ", "")
+ + "))";
+ }
+
+ }
+ engine.voidEval(dataframe);
+ log.info("Message sent to R : " + dataframe);
+
+ log.info("Message sent to R : "
+ + "isis.factor.distribution<-c(0.0)");
+ engine.voidEval("isis.factor.distribution<-c(0.0)");
+
+ 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\"");
+
+ //Create isis.Simule
+ log.info("Message sent to R : " + "isis.simule<-data.frame(data)");
+ engine.voidEval("isis.simule<-data.frame(data)");
+
+ 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]]");
+
+ // Export the data.frame object for the second run in a .data file
+ engine.voidEval("write.csv(data,file=\".data.csv\")");
+ log.info("Message sent to R : write.csv(data,file=\".data.csv\")");
+
+ //Set working directory to save Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ engine.terminate();
+
+ } catch (RException eee) {
+ eee.printStackTrace();
+ throw new RuntimeException("R evaluation failed", eee);
+ }
+
+ return thisExperiment;
+
+ }
+
+ @Override
+ public void analyzeResult(List<SimulationStorage> simulationStorages,
+ File outputdirectory) throws SensitivityException {
+
+ REngine engine = new RProxy();
+ try {
+
+ //Clear session
+ log.info("rm(list=ls())");
+ engine.voidEval("rm(list=ls())");
+
+ //Set working directory to get Isis R session
+ log.info("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ //Get Isis R session
+ log.info("load(\"" + outputdirectory.getName() + ".RData\")");
+ engine
+ .voidEval("load(\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ // Set output directory
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Get the regularfractions object from the .regularfractions file
+ engine.voidEval("x<-dget(\".regularfractions\")");
+ log.info("Message sent to R : " + "x<-dget(\".regularfractions\")");
+
+ // Get the factornames object from the .factornames file
+ engine.voidEval("factornames<-dget(\".factornames\")");
+ log.info("Message sent to R : "
+ + "factornames<-dget(\".factornames\")");
+
+ //Get back the scenarios
+ engine.voidEval("factors<-read.csv(\".data.csv\")");
+ log.info("Message sent to R : factors<-read.csv(\".data.csv\")");
+
+ //Get back the factors number
+ int factorNumber = ((Double) engine.eval("length(factors)-1"))
+ .intValue();
+
+ 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 = 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, 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) {
+ rInstruction = rInstruction + simulationResult + ",";
+ } else {
+ rInstruction = rInstruction + simulationResult;
+ }
+ }
+ 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
+ + ")");
+ 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\"");
+
+ for (int k = 0; k < sensitivityNumber; k++) {
+
+ // Creates the R expression to import results in R
+ String name = param.getSensitivityExport().get(k)
+ .getExportFilename();
+
+ //Create the dataforaov data.frame
+ String dataframe = "dataforaov<-data.frame(factors," + name
+ + "=" + name + ")";
+ engine.voidEval(dataframe);
+ log.info("Message sent to R : " + dataframe);
+
+ //Call aov()
+ String aovCall = "aovresult<-aov(" + name + "~(";
+ for (int j = 0; j < factorNumber; j++) {
+ log.info("Message sent to R : " + "names(factors)["
+ + (j + 2) + "]");
+
+ if (j < (factorNumber - 1)) {
+ aovCall = aovCall
+ + engine
+ .eval("names(factors)[" + (j + 2) + "]")
+ + "+";
+ } else {
+ aovCall = aovCall
+ + engine
+ .eval("names(factors)[" + (j + 2) + "]")
+ + ")";
+ if (param_resolution <= 4) {
+ aovCall += ",data=dataforaov)";
+ } else {
+ aovCall += "^2,data=dataforaov)";
+ }
+ }
+ }
+ engine.voidEval(aovCall);
+ log.info("Message sent to R : " + aovCall);
+
+ /*Export the results
+ *Export format is csv, data separated by ','
+ *Results Export name is sensitivityExportName_Results.csv
+ *Sensitivity Indices export name is sensitivityExportName_SensitivityIndices.csv
+ */
+
+ //Compute Sum of Squares and Sensitivity indices
+ engine.voidEval("SoS<-summary(aovresult)[[1]][1:"
+ + factorNumber + ",2]");
+ log.info("Message sent to R : SoS<-summary(aovresult)[[1]][1:"
+ + factorNumber + ",2]");
+ engine
+ .voidEval("names(SoS)<-dimnames(summary(aovresult)[[1]])[[1]][1:"
+ + factorNumber + "]");
+ log
+ .info("Message sent to R : names(SoS)<-dimnames(summary(aovresult)[[1]])[[1]][1:"
+ + factorNumber + "]");
+ engine.voidEval("IndSensibilite<-SoS/sum(SoS)");
+ log.info("Message sent to R : IndSensibilite<-SoS/sum(SoS)");
+
+ //Create a data.frame to export sensitivity important results in one file.
+ engine.voidEval("exportsensitivity=data.frame(SoS[1:"
+ + factorNumber + "],IndSensibilite[1:" + factorNumber
+ + "])");
+ log
+ .info("Message sent to R : exportsensitivity=data.frame(SoS[1:"
+ + factorNumber
+ + "],IndSensibilite[1:"
+ + factorNumber + "])");
+ engine
+ .voidEval("names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ log
+ .info("Message sent to R : names(exportsensitivity)<-c(\"Sum Of Squares\",\"Sensitivity indices\")");
+ engine.voidEval("row.names(exportsensitivity)<-factornames");
+ log.info("Message sent to R : "
+ + "row.names(exportsensitivity)<-factornames");
+
+ //Set dataforaov names
+ engine
+ .voidEval("resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ log
+ .info("Message sent to R : "
+ + "resultsnames<-c(\"Simulation\",factornames,\"Result\")");
+ engine.voidEval("names(dataforaov)<-resultsnames");
+ log.info("Message sent to R : "
+ + "names(dataforaov)<-resultsnames");
+
+ /*Set the export directory
+ *Export directory is the first simulation export directory.
+ */
+ engine.voidEval("setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+ log.info("Message sent to R : setwd(\""
+ + outputdirectory.getAbsolutePath().replaceAll("\\\\",
+ "/") + "\")");
+
+ //Save the results with the scenarios.
+ engine.voidEval("write.csv(dataforaov,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+ log.info("Message sent to R : write.csv(dataforaov,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename() + "_Results.csv\")");
+
+ //Save the sensitivity indices
+ engine.voidEval("write.csv(exportsensitivity,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ log.info("Message sent to R : write.csv(exportsensitivity,\""
+ + param.getSensitivityExport().get(k)
+ .getExportFilename()
+ + "_SensitivityIndices.csv\")");
+ //FIXME export through java to enable export when using Rserve (when distant Rserve).
+
+ //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=\""
+ + aovCall + "\""
+ + ",\"analysis_result\"=list(aovresult,IndSensibilite))");
+ engine
+ .voidEval("isis.methodAnalyse<-list(\"isis.factors\"=isis.factors,\"isis.factor.distribution\"=isis.factor.distribution,\"isis.simule\"=isis.simule,call_method=\""
+ + aovCall
+ + "\""
+ + ",\"analysis_result\"=list(aovresult,IndSensibilite))");
+
+ log
+ .info("Message sent to R : "
+ + "attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\"");
+ engine
+ .voidEval("attr(isis.methodAnalyse,\"nomModel\")<-\"isis-fish-externe-R\"");
+
+ 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().replaceAll("\\\\", "/")
+ + "\")");
+ engine.voidEval("setwd(\""
+ + outputdirectory.getParent().replaceAll("\\\\", "/")
+ + "\")");
+
+ // Save Isis R session
+ log.info("save.image(file=\"" + outputdirectory.getName() + ".RData\")");
+ engine.voidEval("save.image(file=\"" + outputdirectory.getName()
+ + ".RData\")");
+
+ engine.terminate();
+
+ } catch (Exception eee) {
+ eee.printStackTrace();
+ throw new RuntimeException("R evaluation failed", eee);
+ }
+
+ }
+
+ @Override
+ public String getDescription() {
+ return "Implementation of Regular fractions method using R";
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivity/SensitivityCalculatorRegularFractions.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivity/regularfractions.R
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivity/regularfractions.R (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivity/regularfractions.R 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,211 @@
+#================================================================================
+# FONCTIONS DE CALCUL D'UNE FRACTION REGULIERE DE RESOLUTION DONNEE
+# Auteur: H. Monod, INRA Jouy en Josas
+# Copyright INRA 2009
+# Ce programme est une version preliminaire et simplifiee d'une librairie R
+# en preparation par A. Kobilinsky, H. Monod, A. Bouvier
+#================================================================================
+regular.fraction <- function(s,p,r,resolution){
+ # DESCRIPTION
+ # generates a regular fractional factorial design of given resolution,
+ # for s factors at p levels in p^r units
+ # ARGUMENTS
+ # s : number of input factors
+ # p : unique prime number of levels of all input and unit factors
+ # r : number of unit factors (so that there are N=p^r units)
+ # resolution : resolution of the fraction
+ # max.sol : maximum number of solutions
+ # DETAILS
+ # This is a simplified version of a more general library in preparation.
+ # In this version, all factors must have the same prime number of levels
+ # and only fractions with a given resolution can be constructed. The first
+ # q factors are used as basic factors. The first solution is kept although
+ # it may not be the most interesting one (no control of aberration). This
+ # function is programmed entirely in R and so it is not efficient with respect
+ # to computer time. There is no explicit check on the arguments and so it
+ # is up to the user to restrict p to a prime number such as 2, 3, 5 or 7.
+ # OUTPUT:
+ # a list with two components: plan (the design in base p) and matrice.cle
+ # (the design key). The design has N=p^r rows (units) and s columns (factors).
+ # All its elements are integers modulo p that represent the factor levels.
+
+ # ensemble ineligible
+ cat("Determination des termes ineligibles: ")
+ ineligible <- diag(s)
+ for(reso in 2:(resolution-1)){
+ combis <- combn(s,reso)
+ ncombi <- ncol(combis)
+ select <- cbind( c(combis), rep(seq(ncombi),rep(reso,ncombi)) )
+ ineli <- matrix(0,s,ncombi)
+ ineli[select] <- 1
+ ineligible <- cbind(ineligible,ineli)
+ }
+ cat(ncol(ineligible)," termes ineligibles.\n")
+ if( (p!=2) ){
+ ineligible <- representative.basep(ineligible,p)
+ }
+ # Identification of the last non-zero coefficients in each ineligible trt character
+ ineligible.lnz <- apply(ineligible, 2, function(x){max(seq(along=x)[x!=0])})
+ # initialisation of PhiStar by using the first q factors as basic factors
+ PhiStar <- diag(r)
+ #
+ f <- ncol(PhiStar)
+ if(s == f){
+ check <- !any(apply(((PhiStar %*% ineligible)%%p)==0, 2, all))
+ if(check) return(list(PhiStar))
+ }
+ # Calculation of the set of initially admissible elements of U*
+ admissible <- t(convertinto.basep(seq((p^r)-1),p))
+ nb.admissible <- ncol(admissible)
+ # Backtrack search - preliminaries
+ eeU <- list(length=s-f)
+ leeU <- rep(NA,s-f)
+ neeU <- rep(0,s-f)
+ # Backtrack search
+ cat("Recherche d'une solution (algorithme backtrack).\n")
+ jprev <- 0 ; j <- 1
+ solved <- FALSE
+ while((j > 0)&(!solved)){
+ PhiStar <- PhiStar[,seq(f+j-1), drop=FALSE]
+ if(jprev < j){
+ ineligible.j <- ineligible[ seq(f+j-1), ineligible.lnz==(f+j), drop=FALSE ]
+ admissible.keep <- planor.kernelcheck.basep(PhiStar, admissible, ineligible.j, p)
+ eeU[[j]] <- seq(nb.admissible)[admissible.keep]
+ leeU[j] <- length(eeU[[j]])
+ neeU[j] <- 0
+ }
+ if(neeU[j] < leeU[j]){
+ neeU[j] <- neeU[j]+1
+ newcolj <- (eeU[[j]])[neeU[j]]
+ PhiStar <- cbind(PhiStar,admissible[,newcolj])
+ if(j == (s-f)){
+ cat("Solution obtenue. ")
+ solved <- TRUE
+ jprev <- j ; j <- j
+ }
+ else{
+ jprev <- j ; j <- j+1
+ }
+ }
+ else{
+ jprev <- j ; j <- j-1
+ }
+ }
+ if(solved){
+ # Construction du plan
+ plan <- crossing(rep(p,r),start=0) %*% PhiStar %%p
+ # Sortie
+ out <- list(plan=plan, matrice.cle=PhiStar, p=p)
+ }
+ else{
+ cat("Pas de solution. ")
+ out <- NULL
+ }
+ cat("Recherche terminee.\n")
+ return(out)
+}
+#---------------------------------------------------------------------------
+planor.kernelcheck.basep <- function(PhiStar, admissible, IneligibleSet, p){
+ ImagesIS <- (- PhiStar %*% IneligibleSet)%%p
+ avoid <- convertfrom.basep( t(ImagesIS), p)
+ candidate <- convertfrom.basep( t(admissible), p)
+ test <- !(candidate %in% avoid)
+ return(test)
+}
+#---------------------------------------------------------------------------
+convertinto.basep <- function (x, p) {
+ # Conversion of an integer or integer vector x into base p
+ # The coefficients are ordered by increasing powers of p
+ if (!is.numeric(x))
+ stop("cannot decompose non-numeric arguments")
+ if (length(x) > 1) {
+ l <- matrix(0, length(x), length(Recall(max(x),p)))
+ for(i in seq(along = x)){
+ dec.i <- Recall(x[i],p)
+ l[i, seq(along=dec.i) ] <- dec.i
+ }
+ return(l)
+ }
+ if (x != round(x) || x < 0)
+ return(x)
+ val <- x%%p
+ while ( (x <- x%/%p) > 0 ) {
+ newval <- x%%p
+ val <- c(val,newval)
+ }
+ return(val)
+}
+#---------------------------------------------------------------------------
+convertfrom.basep <- function (x, p) {
+ # Conversion of integers x coded as vectors of coefficients in base p
+ # to classical integers in base 10
+
+ if (!is.numeric(x))
+ stop("cannot recompose non-numeric arguments")
+ if( (max(x)>p) || (min(x)<0) )
+ stop("x must be reduced modulo p")
+ if (is.matrix(x)) {
+ l <- rep(NA, nrow(x))
+ for(i in seq(along = l)){
+ l[i] <- Recall(x[i,],p)
+ }
+ return(l)
+ }
+ val <- sum( x * p^(seq(along=x)-1) )
+ return(val)
+}
+#---------------------------------------------------------------------------
+inverses.basep <- function(p){
+ # Raw calculation of the inverses modulo p
+
+ if(p==2) return(1)
+ else if(p==3) return(c(1,2))
+ products <- outer(seq(2,p-2), seq(2,p-2), "*")%%p
+ inverses <- 1 + apply(products, 1, function(x){ seq(along=x)[x==1] })
+ return( c(1,inverses,p-1) )
+}
+#---------------------------------------------------------------------------
+representative.basep <- function(mat,p){
+ # generates the minimal set of representatives in base p
+ # of the columns x of matrix mat
+
+ mat <- as.matrix(mat)
+ #
+ if(p==2) return(mat %%2)
+ #
+ representative <- NULL
+ for(j in seq(ncol(mat))){
+ x <- mat[,j]
+ select <- seq(x)[x != 0]
+ nbtocross <- length(select)-1
+ if( nbtocross <= 0 ) mat.j <- x
+ else{
+ select <- select[seq(nbtocross)]
+ N <- (p-1)^nbtocross
+ mat.j <- matrix(x, nrow(mat), N)
+ mat.j[select,] <- t( crossing(rep(p-1,nbtocross),start=1) )
+ }
+ representative <- cbind(representative, mat.j)
+ }
+ return(representative %%p)
+}
+#---------------------------------------------------------------------------
+crossing <- function(n,start=1){
+ # Generates all n1 x n2 x ... x ns combinations of size s with n1,...,ns integers
+
+ N <- prod(n)
+ s <- length(n)
+ n <- c(n,1)
+ crosses <- matrix(NA, N, s)
+ for(i in seq(s))
+ {
+ motif <- start + seq(n[s+1-i])-1
+ repet1 <- rep( prod(n[s+1-i+seq(i)]), n[s+1-i] )
+ if(i==s){ repet2 <- 1 }
+ else{ repet2 <- prod(n[seq(s-i)]) }
+ crosses[,s-i+1] <- rep( rep( motif, repet1 ), repet2 )
+ }
+ return(crosses)
+}
+#---------------------------------------------------------------------------
+
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,100 @@
+package sensitivityexports;
+
+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.MatrixND;
+import org.codelutin.topia.TopiaContext;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityBiomassReferenceY9 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityBiomassReferenceY9.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Doc("Name of the reference simulation")
+ public String param_referenceSimulation = "";
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ SimulationStorage referenceSimulation = SimulationStorage
+ .getSimulation(param_referenceSimulation);
+ ResultStorage referenceResultStorage = referenceSimulation
+ .getResultStorage();
+ ResultStorage resultStorage = simulation.getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
+ Double biomass = 0.0;
+ Double referenceBiomass = 0.0;
+
+ System.out.println("reference simul : " + param_referenceSimulation);
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(lastDate, pop,
+ ResultName.MATRIX_BIOMASS);
+ biomass = matlastdate.sumAll();
+ System.out.println("matlastdate:" + (Object) matlastdate);
+
+ TopiaContext tx = referenceSimulation.getStorage()
+ .beginTransaction();
+
+ MatrixND matreferencelastdate = referenceResultStorage
+ .getMatrix(lastDate, ResultName.MATRIX_BIOMASS + " "
+ + pop, tx);
+ referenceBiomass = matreferencelastdate.sumAll();
+
+ tx.commitTransaction();
+ tx.closeContext();
+ }
+ }
+ System.out.println("simulationStorage:" + simulation);
+ System.out.println("referenece simulation:" + referenceSimulation);
+ System.out.println("resultStorage:" + resultStorage);
+ System.out.println("referenceStroagr:" + referenceResultStorage);
+ System.out.println("biomass:" + biomass);
+ System.out.println("referenceBiomass:" + referenceBiomass);
+
+ out.write(Double.toString(biomass / referenceBiomass));
+
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityBiomassReferenceY9";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,110 @@
+package sensitivityexports;
+
+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.MatrixND;
+import org.codelutin.topia.TopiaContext;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityBiomassRelativeReferenceY12 implements
+ SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityBiomassRelativeReferenceY12.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Doc("Name of the reference simulation")
+ public String param_referenceSimulation = "";
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ SimulationStorage referenceSimulation = SimulationStorage
+ .getSimulation(param_referenceSimulation);
+ ResultStorage resultStorage = simulation.getResultStorage();
+ ResultStorage referenceResultStorage = referenceSimulation
+ .getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
+ Date firstDate = new Date(11);
+ double biomass = 0.0;
+ double firstbiomass = 0.0;
+ double biomassReference = 0.0;
+ double firstbiomassReference = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+
+ //Get the biomass on december of the first year
+ MatrixND matfirstdate = resultStorage.getMatrix(firstDate, pop,
+ ResultName.MATRIX_BIOMASS);
+ firstbiomass = matfirstdate.sumAll();
+
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(lastDate, pop,
+ ResultName.MATRIX_BIOMASS);
+ biomass = matlastdate.sumAll();
+
+ //Get the biomass on december of the first year
+ TopiaContext tx = referenceSimulation.getStorage()
+ .beginTransaction();
+ MatrixND matfirstdatereference = referenceResultStorage
+ .getMatrix(firstDate, ResultName.MATRIX_BIOMASS + " "
+ + pop, tx);
+ firstbiomassReference = matfirstdatereference.sumAll();
+ tx.commitTransaction();
+ tx.closeContext();
+
+ //Get the biomass of the last time step
+ tx = referenceSimulation.getStorage().beginTransaction();
+ MatrixND matlastdatereference = referenceResultStorage
+ .getMatrix(lastDate, ResultName.MATRIX_BIOMASS + " "
+ + pop, tx);
+ biomassReference = matlastdatereference.sumAll();
+ tx.commitTransaction();
+ tx.closeContext();
+
+ }
+ }
+
+ out.write(Double.toString((biomass / firstbiomass)
+ / (biomassReference / firstbiomassReference)));
+
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityBiomassRelativeReferenceY12";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
\ No newline at end of file
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,77 @@
+package sensitivityexports;
+
+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.MatrixND;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityBiomassRelativeY6 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityBiomassRelativeY6.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ ResultStorage resultStorage = simulation.getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
+ Date firstDate = new Date(11);
+ double biomass = 0.0;
+ double firstbiomass = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+
+ //Get the biomass on december of the first year
+ MatrixND matfirstdate = resultStorage.getMatrix(firstDate, pop,
+ ResultName.MATRIX_BIOMASS);
+ firstbiomass = matfirstdate.sumAll();
+
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(lastDate, pop,
+ ResultName.MATRIX_BIOMASS);
+ biomass = matlastdate.sumAll();
+
+ }
+ }
+ out.write(Double.toString(biomass / firstbiomass));
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityBiomassRelativeY6";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
\ No newline at end of file
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,67 @@
+package sensitivityexports;
+
+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.MatrixND;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityBiomassY3 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(SensitivityBiomassY3.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ ResultStorage resultStorage = simulation.getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
+ double biomass = 0.0;
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(lastDate, pop,
+ ResultName.MATRIX_BIOMASS);
+ biomass = matlastdate.sumAll();
+ }
+ }
+ out.write(Double.toString(biomass));
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityBiomassY3";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightReferenceY7.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightReferenceY7.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightReferenceY7.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,98 @@
+package sensitivityexports;
+
+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.MatrixND;
+import org.codelutin.topia.TopiaContext;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityCapturesWeightReferenceY7 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityCapturesWeightReferenceY7.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Doc("Name of the reference simulation")
+ public String param_referenceSimulation = "";
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ SimulationStorage referenceSimulation = SimulationStorage
+ .getSimulation(param_referenceSimulation);
+ ResultStorage referenceResultStorage = referenceSimulation
+ .getResultStorage();
+ ResultStorage resultStorage = simulation.getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
+ Double capturesWeight = 0.0;
+ Double capturesWeightReference = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ for (int i = 0; i < 12; i++) {
+
+ //Get the captures Weight of each month of the last year
+ MatrixND matlastdate = resultStorage
+ .getMatrix(
+ new Date(lastDate.getDate() - i),
+ pop,
+ 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
+ TopiaContext tx = referenceSimulation.getStorage()
+ .beginTransaction();
+ MatrixND matlastdatereference = referenceResultStorage
+ .getMatrix(
+ new Date(lastDate.getDate() - i),
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ + " " + pop, tx);
+ capturesWeightReference += matlastdatereference.sumAll();
+ tx.commitTransaction();
+ tx.closeContext();
+
+ }
+
+ }
+ }
+
+ out.write(Double.toString(capturesWeight / capturesWeightReference));
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityCapturesWeightReferenceY7";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
\ No newline at end of file
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightReferenceY7.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeReferenceY10.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeReferenceY10.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeReferenceY10.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,118 @@
+package sensitivityexports;
+
+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.MatrixND;
+import org.codelutin.topia.TopiaContext;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityCapturesWeightRelativeReferenceY10 implements
+ SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityCapturesWeightRelativeReferenceY10.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Doc("Name of the reference simulation")
+ public String param_referenceSimulation = "";
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ SimulationStorage referenceSimulation = SimulationStorage
+ .getSimulation(param_referenceSimulation);
+ ResultStorage referenceResultStorage = referenceSimulation
+ .getResultStorage();
+ ResultStorage resultStorage = simulation.getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
+ Double capturesWeight = 0.0;
+ Double capturesWeightfirst = 0.0;
+ Double capturesWeightreference = 0.0;
+ Double capturesWeightfirstreference = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ for (int i = 0; i < 12; i++) {
+
+ //Get the captures Weight of each month of the last year
+ MatrixND matlastdate = resultStorage
+ .getMatrix(
+ new Date(lastDate.getDate() - i),
+ pop,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ capturesWeight += matlastdate.sumAll();
+
+ //Get the captures Weight of each month of the first year
+ MatrixND matfirstdate = resultStorage
+ .getMatrix(
+ new Date(i),
+ pop,
+ 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
+
+ TopiaContext tx = referenceSimulation.getStorage()
+ .beginTransaction();
+
+ MatrixND matlastdatereference = referenceResultStorage
+ .getMatrix(
+ new Date(lastDate.getDate() - i),
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ + " " + pop, tx);
+ capturesWeightreference += matlastdatereference.sumAll();
+
+ //Get the reference captures Weight of each month of the first year
+ MatrixND matfirstdatereference = referenceResultStorage
+ .getMatrix(
+ new Date(i),
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ + " " + pop, tx);
+ capturesWeightfirstreference += matfirstdatereference
+ .sumAll();
+ tx.commitTransaction();
+ tx.closeContext();
+ }
+ }
+ }
+ out.write(Double.toString((capturesWeight / capturesWeightfirst)
+ / (capturesWeightreference / capturesWeightfirstreference)));
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityCapturesWeightRelativeReferenceY10";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeReferenceY10.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeY4.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeY4.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeY4.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,85 @@
+package sensitivityexports;
+
+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.MatrixND;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityCapturesWeightRelativeY4 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityCapturesWeightRelativeY4.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ ResultStorage resultStorage = simulation.getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
+ Double capturesWeight = 0.0;
+ Double capturesWeightfirst = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ for (int i = 0; i < 12; i++) {
+
+ //Get the captures Weight of each month of the last year
+ MatrixND matlastdate = resultStorage
+ .getMatrix(
+ new Date(lastDate.getDate() - i),
+ pop,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ capturesWeight += matlastdate.sumAll();
+
+ //Get the captures Weight of each month of the first year
+ MatrixND matfirstdate = resultStorage
+ .getMatrix(
+ new Date(i),
+ pop,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ capturesWeightfirst += matfirstdate.sumAll();
+ }
+
+ }
+ }
+
+ out.write(Double.toString(capturesWeight / capturesWeightfirst));
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityCapturesWeightRelativeY4";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeY4.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightY1.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightY1.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightY1.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,76 @@
+package sensitivityexports;
+
+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.MatrixND;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityCapturesWeightY1 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityCapturesWeightY1.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ ResultStorage resultStorage = simulation.getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
+ Double capturesWeight = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ for (int i = 0; i < 12; i++) {
+
+ //Get the captures Weight of each month of the last year
+ MatrixND matlastdate = resultStorage
+ .getMatrix(
+ new Date(lastDate.getDate() - i),
+ pop,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ capturesWeight += matlastdate.sumAll();
+ }
+
+ }
+ }
+
+ out.write(Double.toString(capturesWeight));
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityCapturesWeightY1";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightY1.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassReferenceY8.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassReferenceY8.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassReferenceY8.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,107 @@
+package sensitivityexports;
+
+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 org.codelutin.topia.TopiaContext;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityGenitorBiomassReferenceY8 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityGenitorBiomassReferenceY8.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Doc("Name of the reference simulation")
+ public String param_referenceSimulation = "";
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ SimulationStorage referenceSimulation = SimulationStorage
+ .getSimulation(param_referenceSimulation);
+ ResultStorage referenceResultStorage = referenceSimulation
+ .getResultStorage();
+ ResultStorage resultStorage = simulation.getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
+ Double biomass = 0.0;
+ Double referenceBiomass = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Date date = (Date) sems[0];
+ if (date.equals(lastDate)) {
+ biomass += i.getValue() * group.getReproductionRate();
+ }
+ }
+
+ //Get the reference biomass of the last time step
+ TopiaContext tx = referenceSimulation.getStorage()
+ .beginTransaction();
+ MatrixND matlastdatereference = referenceResultStorage
+ .getMatrix(ResultName.MATRIX_BIOMASS + " " + pop, tx);
+ for (MatrixIterator i = matlastdatereference.iterator(); i
+ .hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Date date = (Date) sems[0];
+ if (date.equals(lastDate)) {
+ referenceBiomass += i.getValue()
+ * group.getReproductionRate();
+ }
+ }
+ tx.commitTransaction();
+ tx.closeContext();
+ }
+ }
+ out.write(Double.toString(biomass / referenceBiomass));
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityGenitorBiomassReferenceY8";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassReferenceY8.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeReferenceY11.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeReferenceY11.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeReferenceY11.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,142 @@
+package sensitivityexports;
+
+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 org.codelutin.topia.TopiaContext;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityGenitorBiomassRelativeReferenceY11 implements
+ SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityGenitorBiomassRelativeReferenceY11.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Doc("Name of the reference simulation")
+ public String param_referenceSimulation = "";
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ SimulationStorage referenceSimulation = SimulationStorage
+ .getSimulation(param_referenceSimulation);
+ ResultStorage resultStorage = simulation.getResultStorage();
+ ResultStorage referenceResultStorage = referenceSimulation
+ .getResultStorage();
+ Date lastDate = resultStorage.getLastDate();
+ Date firstDate = new Date(11);
+ double biomass = 0.0;
+ double firstbiomass = 0.0;
+ double biomassReference = 0.0;
+ double firstbiomassReference = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+
+ //Get the biomass of the first time step
+ MatrixND matfirstdate = resultStorage.getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = matfirstdate.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Date date = (Date) sems[0];
+ if (date.equals(firstDate)) {
+ firstbiomass += i.getValue()
+ * group.getReproductionRate();
+ }
+ }
+
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Date date = (Date) sems[0];
+ if (date.equals(lastDate)) {
+ biomass = biomass + i.getValue()
+ * group.getReproductionRate();
+ }
+ }
+
+ //Get the reference biomass of the first time step
+ TopiaContext tx = referenceSimulation.getStorage()
+ .beginTransaction();
+ MatrixND matfirstdatereference = referenceResultStorage
+ .getMatrix(ResultName.MATRIX_BIOMASS + " " + pop, tx);
+ for (MatrixIterator i = matfirstdatereference.iterator(); i
+ .hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Date date = (Date) sems[0];
+ if (date.equals(firstDate)) {
+ firstbiomassReference += i.getValue()
+ * group.getReproductionRate();
+ }
+ }
+
+ //Get the reference biomass of the last time step
+ MatrixND matlastdatereference = referenceResultStorage
+ .getMatrix(ResultName.MATRIX_BIOMASS + " " + pop, tx);
+ for (MatrixIterator i = matlastdatereference.iterator(); i
+ .hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Date date = (Date) sems[0];
+ if (date.equals(lastDate)) {
+ biomassReference += i.getValue()
+ * group.getReproductionRate();
+ }
+ }
+ tx.commitTransaction();
+ tx.closeContext();
+ }
+ }
+ out.write(Double.toString((biomass / firstbiomass)
+ / (biomassReference / firstbiomassReference)));
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityGenitorBiomassRelativeReferenceY11";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
\ No newline at end of file
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeReferenceY11.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeY5.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeY5.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeY5.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,94 @@
+package sensitivityexports;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityGenitorBiomassRelativeY5 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityGenitorBiomassRelativeY5.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ Date lastDate = simulation.getResultStorage().getLastDate();
+ Date firstDate = new Date(11);
+ double biomass = 0.0;
+ double firstbiomass = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ ResultStorage resultStorage = simulation.getResultStorage();
+
+ //Get the biomass of the first time step
+ MatrixND matfirstdate = resultStorage.getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = matfirstdate.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Date date = (Date) sems[0];
+ if (date.equals(firstDate)) {
+ firstbiomass += i.getValue()
+ * group.getReproductionRate();
+ }
+ }
+
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Date date = (Date) sems[0];
+ if (date.equals(lastDate))
+ biomass += i.getValue() * group.getReproductionRate();
+ }
+ }
+ }
+ out.write(Double.toString(biomass / firstbiomass));
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityGenitorBiomassRelativeY5";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
\ No newline at end of file
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeY5.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassY2.java
===================================================================
--- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassY2.java (rev 0)
+++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassY2.java 2009-09-09 16:27:51 UTC (rev 2591)
@@ -0,0 +1,79 @@
+package sensitivityexports;
+
+import static org.codelutin.i18n.I18n._;
+
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+
+import scripts.ResultName;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.util.Doc;
+
+public class SensitivityGenitorBiomassY2 implements SensitivityExport {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(SensitivityGenitorBiomassY2.class);
+
+ protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+
+ @Doc("Population")
+ public Population param_pop;
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ Date lastDate = simulation.getResultStorage().getLastDate();
+ double biomass = 0.0;
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ if (pop.getName().equals(param_pop.getName())) {
+ ResultStorage resultStorage = simulation.getResultStorage();
+
+ //Get the biomass of the last time step
+ MatrixND matlastdate = resultStorage.getMatrix(pop,
+ ResultName.MATRIX_BIOMASS);
+ for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Date date = (Date) sems[0];
+ PopulationGroup group = (PopulationGroup) sems[1];
+ if (date.equals(lastDate)) {
+ biomass += i.getValue() * group.getReproductionRate();
+ }
+ }
+ }
+ }
+ out.write(Double.toString(biomass));
+ }
+
+ @Override
+ public String getDescription() {
+ return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "SensitivityGenitorBiomassY2";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+}
Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassY2.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
1
0
r2590 - isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util
by chatellier@users.labs.libre-entreprise.org 09 Sep '09
by chatellier@users.labs.libre-entreprise.org 09 Sep '09
09 Sep '09
Author: chatellier
Date: 2009-09-09 15:35:02 +0000 (Wed, 09 Sep 2009)
New Revision: 2590
Modified:
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/EvaluateHelperTest.java
Log:
Ajout d'un test sur la compilation des equations (ne fonctionne pas)
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/EvaluateHelperTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/EvaluateHelperTest.java 2009-09-04 17:43:44 UTC (rev 2589)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/EvaluateHelperTest.java 2009-09-09 15:35:02 UTC (rev 2590)
@@ -21,8 +21,8 @@
import java.util.HashMap;
import java.util.Map;
-import junit.framework.Assert;
-
+import org.junit.Assert;
+import org.junit.Ignore;
import org.junit.Test;
import fr.ifremer.isisfish.AbstractIsisFishTest;
@@ -75,7 +75,7 @@
args.put("context", null);
args.put("age", 2.0);
args.put("group", null);
- Object result = EvaluatorHelper.evaluate("org.codelutin.equation",
+ Object result = EvaluatorHelper.evaluate("fr.isisfish.equation",
"TestEvaluate", PopulationGrowth.class, equationContent, args);
Assert.assertNotNull(result);
@@ -95,17 +95,37 @@
args.put("group", null);
String equationContent = "return length * 2.0;";
- Object result = EvaluatorHelper.evaluate("org.codelutin.equation",
+ Object result = EvaluatorHelper.evaluate("fr.isisfish.equation",
"TestDoubleContentEvaluate", PopulationGrowthReverse.class,
equationContent, args);
Assert.assertNotNull(result);
Assert.assertEquals("4.0", result.toString());
equationContent = "return length * 3.0;";
- result = EvaluatorHelper.evaluate("org.codelutin.equation",
+ result = EvaluatorHelper.evaluate("fr.isisfish.equation",
"TestDoubleContentEvaluate", PopulationGrowthReverse.class,
equationContent, args);
Assert.assertNotNull(result);
Assert.assertEquals("6.0", result.toString());
}
+
+ /**
+ * Test que le repertoire des scripts en bien présent
+ * dans le classpath de compilation.
+ */
+ @Ignore
+ public void testEquationWithDatabaseContent() {
+ Map<String, Object> args = new HashMap<String, Object>();
+ args.put("context", null);
+ args.put("length", 2.0);
+ args.put("group", null);
+
+ String equationContent = "String name = scripts.ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP;";
+ equationContent += "return length * 2.0;";
+ Object result = EvaluatorHelper.evaluate("fr.isisfish.equation",
+ "TestEquationWithDatabaseContent", PopulationGrowthReverse.class,
+ equationContent, args);
+ Assert.assertNotNull(result);
+ Assert.assertEquals("4.0", result.toString());
+ }
}
1
0
Author: chatellier
Date: 2009-09-04 17:43:44 +0000 (Fri, 04 Sep 2009)
New Revision: 2589
Modified:
isis-fish/trunk/changelog.txt
Log:
Update changelog
Modified: isis-fish/trunk/changelog.txt
===================================================================
--- isis-fish/trunk/changelog.txt 2009-09-04 17:42:32 UTC (rev 2588)
+++ isis-fish/trunk/changelog.txt 2009-09-04 17:43:44 UTC (rev 2589)
@@ -1,3 +1,7 @@
+isis-fish (3.2.0.6) stable; urgency=low
+
+ --
+
isis-fish (3.2.0.5) stable; urgency=low
* Fix export loaded too early (not in correct classloader)
@@ -5,7 +9,7 @@
* Fix a date comparison problem (frequent in windows)
* Restore running status progress bar indeterminate state
- --
+ -- ven. sept. 4 19:41:17 CEST 2009
isis-fish (3.2.0.5-rc3) stable; urgency=low
1
0
r2588 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish
by chatellier@users.labs.libre-entreprise.org 04 Sep '09
by chatellier@users.labs.libre-entreprise.org 04 Sep '09
04 Sep '09
Author: chatellier
Date: 2009-09-04 17:42:32 +0000 (Fri, 04 Sep 2009)
New Revision: 2588
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java
Log:
Next version
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2009-09-04 16:57:15 UTC (rev 2587)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2009-09-04 17:42:32 UTC (rev 2588)
@@ -119,7 +119,7 @@
* migration de donnees demande automatiquement un changement de version
* d'application.
*/
- protected final static VersionNumber version = new VersionNumber(3, 2, 0, 5);
+ protected final static VersionNumber version = new VersionNumber(3, 2, 0, 6);
protected final static VersionNumber databaseVersion = new VersionNumber(
version.getNumber(0), version.getNumber(1));
protected final static VersionNumber apiVersion = new VersionNumber(
1
0
Author: chatellier
Date: 2009-09-04 16:57:15 +0000 (Fri, 04 Sep 2009)
New Revision: 2587
Modified:
isis-fish/trunk/pom.xml
Log:
[maven-release-plugin] prepare for next development iteration
Modified: isis-fish/trunk/pom.xml
===================================================================
--- isis-fish/trunk/pom.xml 2009-09-04 16:57:11 UTC (rev 2586)
+++ isis-fish/trunk/pom.xml 2009-09-04 16:57:15 UTC (rev 2587)
@@ -13,7 +13,7 @@
<groupId>ifremer</groupId>
<artifactId>isis-fish</artifactId>
- <version>3.2.0.5</version>
+ <version>3.2.0.6-SNAPSHOT</version>
<!-- POM Relationships : Inheritance : Dependencies -->
<dependencies>
@@ -585,9 +585,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/tags/isis-fish-3.2.0.5</connection>
- <developerConnection>scm:svn:svn+ssh://chatellier at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/tags/isis-fish-3.2.0.5</developerConnection>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/isis-fish/tags/…</url>
+ <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/trunk</connection>
+ <developerConnection>scm:svn:svn+ssh://chatellier at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/trunk</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/isis-fish/trunk…</url>
</scm>
<!--Code Lutin Repository-->
1
0
r2586 - in isis-fish/tags: . isis-fish-3.2.0.5
by chatellier@users.labs.libre-entreprise.org 04 Sep '09
by chatellier@users.labs.libre-entreprise.org 04 Sep '09
04 Sep '09
Author: chatellier
Date: 2009-09-04 16:57:11 +0000 (Fri, 04 Sep 2009)
New Revision: 2586
Added:
isis-fish/tags/isis-fish-3.2.0.5/
isis-fish/tags/isis-fish-3.2.0.5/pom.xml
Removed:
isis-fish/tags/isis-fish-3.2.0.5/pom.xml
Log:
[maven-release-plugin] copy for tag isis-fish-3.2.0.5
Deleted: isis-fish/tags/isis-fish-3.2.0.5/pom.xml
===================================================================
--- isis-fish/trunk/pom.xml 2009-09-04 16:43:48 UTC (rev 2584)
+++ isis-fish/tags/isis-fish-3.2.0.5/pom.xml 2009-09-04 16:57:11 UTC (rev 2586)
@@ -1,770 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinproject</artifactId>
- <version>3.5</version>
- </parent>
-
- <groupId>ifremer</groupId>
- <artifactId>isis-fish</artifactId>
- <version>3.2.0.5-SNAPSHOT</version>
-
- <!-- POM Relationships : Inheritance : Dependencies -->
- <dependencies>
-
- <!--Compile-->
-
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <scope>compile</scope>
- </dependency>
-
- <!--Librairies CodeLutin-->
- <dependency>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinutil</artifactId>
- <version>${lutinutil.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.codelutin.topia</groupId>
- <artifactId>topia-persistence</artifactId>
- <version>${topia.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.codelutin</groupId>
- <artifactId>topia-service</artifactId>
- <version>${topia.service.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinmatrix</artifactId>
- <version>${lutinmatrix.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinwidget</artifactId>
- <version>${lutinwidget.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <!--Jaxx-->
- <dependency>
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
- <version>${jaxx.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-runtime-validator</artifactId>
- <version>${jaxx.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-runtime-swing-widget</artifactId>
- <version>${jaxx.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- Utilisé dans les scripts -->
- <dependency>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinj2r</artifactId>
- <version>${lutinj2r.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <!--Commons-->
- <dependency>
- <groupId>commons-jxpath</groupId>
- <artifactId>commons-jxpath</artifactId>
- <version>1.2</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-math</artifactId>
- <version>2.0</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.1</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.8.0</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.4</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1</version>
- <scope>compile</scope>
- </dependency>
-
- <!--Other-->
- <dependency>
- <groupId>jfreechart</groupId>
- <artifactId>jfreechart</artifactId>
- <version>0.9.3</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>jcommon</groupId>
- <artifactId>jcommon</artifactId>
- <version>0.7.0</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- XML-RPC Client and server -->
- <dependency>
- <groupId>org.apache.xmlrpc</groupId>
- <artifactId>xmlrpc-client</artifactId>
- <version>${xmlrpc.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.xmlrpc</groupId>
- <artifactId>xmlrpc-server</artifactId>
- <version>${xmlrpc.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.1</version>
- <scope>runtime</scope>
- </dependency>
-
- <!-- encore utilise pour les pre-scripts -->
- <dependency>
- <groupId>org.beanshell</groupId>
- <artifactId>bsh</artifactId>
- <version>2.0b4</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>openmap</groupId>
- <artifactId>openmap</artifactId>
- <version>${openmap.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.fife</groupId>
- <artifactId>rsyntaxtextarea</artifactId>
- <version>1.3.4</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>com.jcraft</groupId>
- <artifactId>jsch</artifactId>
- <version>0.1.42</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- Utilisé lors de l'import xml v2 (entre autre) -->
- <dependency>
- <groupId>jaxen</groupId>
- <artifactId>jaxen</artifactId>
- <version>1.1.1</version>
- <scope>runtime</scope>
- </dependency>
-
- <!-- Change this dependence if you change database -->
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>1.1.117</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- aspectwerkz -->
- <dependency>
- <groupId>aspectwerkz</groupId>
- <artifactId>aspectwerkz</artifactId>
- <version>${aspectwerkz.version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>aspectwerkz</groupId>
- <artifactId>aspectwerkz-jdk5</artifactId>
- <version>${aspectwerkz.version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>aspectwerkz</groupId>
- <artifactId>aspectwerkz-core</artifactId>
- <version>${aspectwerkz.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- ssj pour les calculs stockastiques -->
- <dependency>
- <groupId>ssj</groupId>
- <artifactId>ssj</artifactId>
- <version>2.1.1</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>ssj</groupId>
- <artifactId>Blas</artifactId>
- <version>20081007</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>ssj</groupId>
- <artifactId>colt</artifactId>
- <version>20081007</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>ssj</groupId>
- <artifactId>interpreter</artifactId>
- <version>1.6.8</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>ssj</groupId>
- <artifactId>language</artifactId>
- <version>1.6.7</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>ssj</groupId>
- <artifactId>logger</artifactId>
- <version>1.6.4</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>ssj</groupId>
- <artifactId>optimization</artifactId>
- <version>20081007</version>
- <scope>runtime</scope>
- </dependency>
- <!-- fin ssj pour les calculs stockastiques -->
-
- <!-- debut svnkit pour communication subversion -->
- <dependency>
- <groupId>org.tmatesoft</groupId>
- <artifactId>svnkit</artifactId>
- <version>1.2.3.5521</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>com.trilead</groupId>
- <artifactId>trilead-ssh2</artifactId>
- <version>build213-svnkit-1.2</version>
- <scope>runtime</scope>
- </dependency>
- <!-- fin svnkit pour communication subversion -->
-
- <dependency>
- <groupId>org.freemarker</groupId>
- <artifactId>freemarker</artifactId>
- <version>2.3.15</version>
- </dependency>
-
- <dependency>
- <groupId>net.sourceforge.cpdetector</groupId>
- <artifactId>cpdetector</artifactId>
- <version>1.0.7</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>tools</artifactId>
- <version>1.6.0</version>
- </dependency>
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
- <name>IsisFish</name>
- <description>Simulateur de pecherie complexe.</description>
- <inceptionYear>1999</inceptionYear>
-
- <licenses>
- <license>
- <name>GPL</name>
- <url>http://www.gnu.org/copyleft/gpl.html</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
- <packaging>jar</packaging>
-
- <properties>
- <!-- id du projet du labs -->
- <labs.id>8</labs.id>
-
- <!-- nom du projet du labs -->
- <labs.project>isis-fish</labs.project>
-
- <!-- Custom version -->
- <jaxx.version>1.5.1</jaxx.version>
- <topia.version>2.1.6.1</topia.version>
- <topia.service.version>1.0.3</topia.service.version>
- <lutinmatrix.version>1.3</lutinmatrix.version>
- <lutinutil.version>1.0.6</lutinutil.version>
- <i18n.version>0.9</i18n.version>
- <lutinwidget.version>0.14.1</lutinwidget.version>
- <generator.version>0.64</generator.version>
- <lutinj2r.version>0.4</lutinj2r.version>
- <jrst.version>0.8.4</jrst.version>
- <license-switcher.version>0.6</license-switcher.version>
- <openmap.version>4.6.4</openmap.version>
- <aspectwerkz.version>2.0</aspectwerkz.version>
- <xmlrpc.version>3.1.2</xmlrpc.version>
-
- <!-- for compilation test to run -->
- <maven.test.forkMode>once</maven.test.forkMode>
-
- <!--Main class in JAR -->
- <maven.jar.main.class>fr.ifremer.isisfish.IsisFish</maven.jar.main.class>
-
- <!-- jnlp -->
- <keystorepath>${codelutin.keystorepath}</keystorepath>
- <keystorealias>CodeLutin</keystorealias>
- <keystorepass>codelutin</keystorepass>
- <jnlp.build.directory>${project.build.directory}/jnlp</jnlp.build.directory>
-
- <jnlpCodebase>${project.url}</jnlpCodebase>
- <!-- to test jnlp file locally -->
- <jnlpCodebase>file://${jnlp.build.directory}</jnlpCodebase>
- </properties>
-
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.codelutin</groupId>
- <artifactId>maven-generator-plugin</artifactId>
- <version>${generator.version}</version>
- <executions>
- <execution>
- <id>Generator</id>
- <phase>generate-sources</phase>
- <configuration>
- <srcDirZuml>${project.basedir}/src/main/xmi</srcDirZuml>
- <srcXmiDest>${maven.gen.dir}/xmi/</srcXmiDest>
- <fullPackagePath>fr.ifremer.isisfish</fullPackagePath>
- <extractedPackages>fr.ifremer.isisfish</extractedPackages>
- <!--Config generator-->
- <srcGenDest>${maven.gen.dir}/objectmodel/</srcGenDest>
- <includes>**/*.objectmodel</includes>
- <templates>org.codelutin.topia.generator.TopiaMetaGenerator</templates>
- <excludeTemplates>
- <value>org.codelutin.topia.generator.EntityEnumGenerator</value>
- <value>org.codelutin.topia.generator.EntityProviderGenerator</value>
- </excludeTemplates>
- <destDirGen>${maven.gen.dir}/java</destDirGen>
- <defaultPackage>fr.ifremer.isisfish</defaultPackage>
- <copyVersionDir>${project.basedir}/src/main/resources/oldmappings/%MODELNAME%
- </copyVersionDir>
- <copyVersionFiles>**/*.hbm.xml</copyVersionFiles>
- <copyOverwrite>true</copyOverwrite>
- </configuration>
- <goals>
- <goal>zargo2xmi</goal>
- <goal>xmi2objectmodel</goal>
- <goal>generate</goal>
- <goal>copyVersionFiles</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.codelutin.topia</groupId>
- <artifactId>topia-persistence</artifactId>
- <version>${topia.version}</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- </plugin>
-
- <plugin>
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>maven-jaxx-plugin</artifactId>
- <version>${jaxx.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <extraImportList>jaxx.runtime.SwingUtil,static jaxx.runtime.Util.getStringValue</extraImportList>
- <addSourcesToClassPath>true</addSourcesToClassPath>
- <addProjectClassPath>true</addProjectClassPath>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codelutin</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
- <version>${i18n.version}</version>
- <configuration>
- <entries>
- <entry>
- <basedir>${maven.gen.dir}/java/</basedir>
- <specificGoal>parserJava</specificGoal>
- <includes>
- <param>**\/**UI.java</param>
- </includes>
- </entry>
- </entries>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>parserJava</goal>
- <goal>gen</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <!-- Always process jrst files, but only called on pre-site phase -->
- <plugin>
- <groupId>org.codelutin</groupId>
- <artifactId>maven-jrst-plugin</artifactId>
- <version>${jrst.version}</version>
- <configuration>
- <defaultLocale>fr</defaultLocale>
- </configuration>
- <executions>
- <execution>
- <phase>pre-site</phase>
- <goals>
- <goal>jrst</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-4</version>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/bin.xml</descriptor>
- </descriptors>
- <attach>false</attach>
- </configuration>
- <executions>
- <execution>
- <phase>verify</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
-
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>lib/</classpathPrefix>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemProperties>
- <property>
- <name>java.io.tmpdir</name>
- <value>${project.build.directory}/surefire-workdir</value>
- </property>
- </systemProperties>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.6</version>
- <configuration>
- <links>
- <link>http://java.sun.com/javase/6/docs/api/</link>
- <link>http://lutinutil.labs.libre-entreprise.org/lutinutil/apidocs/</link>
- <link>http://lutinmatrix.labs.libre-entreprise.org/lutinmatrix/apidocs/</link>
- <link>http://topia.labs.libre-entreprise.org/topia/topia-persistence/apidocs/</link>
- </links>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>2.1</version>
- </plugin>
- </plugins>
- </reporting>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <scm>
- <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/trunk</connection>
- <developerConnection>scm:svn:svn+ssh://chatellier at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/trunk</developerConnection>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/isis-fish/trunk…</url>
- </scm>
-
- <!--Code Lutin Repository-->
- <repositories>
- <repository>
- <id>codelutin-repository</id>
- <name>CodeLutinRepository</name>
- <url>http://lutinbuilder.labs.libre-entreprise.org/maven2</url>
- <snapshots>
- <enabled>true</enabled>
- <checksumPolicy>warn</checksumPolicy>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- <checksumPolicy>warn</checksumPolicy>
- </releases>
- </repository>
- </repositories>
-
- <profiles>
- <profile>
- <id>release-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
-
- <!-- always add license and third-party files to classpath -->
- <plugin>
- <groupId>org.codelutin</groupId>
- <artifactId>maven-license-switcher-plugin</artifactId>
- <version>${license-switcher.version}</version>
- <configuration>
- <licenseName>${license-switcher.licenseName}</licenseName>
- </configuration>
- <executions>
- <execution>
- <id>attach-licenses</id>
- <goals>
- <!--goal>license</goal-->
- <goal>third-party</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <!-- Ajout des libs signe par Sun dans un fichier jnlp separe -->
- <execution>
- <id>JnlpSun</id>
- <phase>verify</phase>
- <configuration>
- <tasks>
- <mkdir dir="${jnlp.build.directory}" />
- <copy file="${project.basedir}/src/main/jnlp/sun.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
- <filterset>
- <filter token="lib-javahelp" value="javahelp-2.0.02.jar" />
- <filter token="lib-activation" value="activation-1.1.jar" />
- <filter token="lib-mail" value="mail-1.4.jar" />
- <filter token="url" value="${jnlpCodebase}" />
- </filterset>
- </copy>
- <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
- <filterset>
- <filter token="lib" value="jxlayer-3.0.1.jar" />
- <filter token="url" value="${jnlpCodebase}" />
- </filterset>
- </copy>
-
- <copy verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false">
- <fileset dir="${project.build.directory}/lib">
- <include name="javahelp-2.0.02.jar" />
- <include name="activation-1.1.jar" />
- <include name="mail-1.4.jar" />
- <include name="jxlayer-3.0.1.jar" />
- </fileset>
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>JnlpToSite</id>
- <phase>pre-site</phase>
- <configuration>
- <tasks>
- <mkdir dir="${maven.site.gen.dir}/resources" />
- <copy todir="${maven.site.gen.dir}/resources" verbose="true" failonerror="false" overwrite="false">
- <fileset dir="${jnlp.build.directory}">
- <include name="**" />
- </fileset>
- <!-- should be better to use the deployed assembly in lutinbuilder ? -->
- <fileset dir="target">
- <include name="${project.build.finalName}-bin.zip" />
- </fileset>
-
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo.webstart</groupId>
- <artifactId>webstart-maven-plugin</artifactId>
- <version>1.0-alpha-2-cl_20090204</version>
- <executions>
- <execution>
- <phase>verify</phase>
- <goals>
- <goal>jnlp-inline</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <force>false</force>
- <dependencies>
- <excludes>
- <exclude>javax.help:javahelp</exclude>
- <exclude>javax.mail:mail</exclude>
- <exclude>javax.activation:activation</exclude>
- <exclude>org.swinglabs:jxlayer</exclude>
- </excludes>
- </dependencies>
- <libPath>lib</libPath>
- <extensions>
- <sun>sun.jnlp</sun>
- <jxlayer>jxlayer.jnlp</jxlayer>
- </extensions>
- <jnlp>
- <outputFile>isis-fish-v3.jnlp</outputFile>
- <mainClass>${maven.jar.main.class}</mainClass>
- <allPermissions>true</allPermissions>
- <offlineAllowed>true</offlineAllowed>
- </jnlp>
-
- <sign>
- <keystore>${keystorepath}</keystore>
- <keypass />
- <storepass>${keystorepass}</storepass>
- <storetype />
- <alias>${keystorealias}</alias>
- <validity />
- <dnameCn />
- <dnameOu />
- <dnameO />
- <dnameL />
- <dnameSt />
- <dnameC />
- <verify>true</verify>
- <keystoreConfig>
- <delete>false</delete>
- <gen>false</gen>
- </keystoreConfig>
- </sign>
- <pack200>false</pack200>
- <gzip>true</gzip>
- <verbose>false</verbose>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
- </profile>
-
- </profiles>
-
-</project>
Copied: isis-fish/tags/isis-fish-3.2.0.5/pom.xml (from rev 2585, isis-fish/trunk/pom.xml)
===================================================================
--- isis-fish/tags/isis-fish-3.2.0.5/pom.xml (rev 0)
+++ isis-fish/tags/isis-fish-3.2.0.5/pom.xml 2009-09-04 16:57:11 UTC (rev 2586)
@@ -0,0 +1,770 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinproject</artifactId>
+ <version>3.5</version>
+ </parent>
+
+ <groupId>ifremer</groupId>
+ <artifactId>isis-fish</artifactId>
+ <version>3.2.0.5</version>
+
+ <!-- POM Relationships : Inheritance : Dependencies -->
+ <dependencies>
+
+ <!--Compile-->
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!--Librairies CodeLutin-->
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinutil</artifactId>
+ <version>${lutinutil.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codelutin.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${topia.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>topia-service</artifactId>
+ <version>${topia.service.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinmatrix</artifactId>
+ <version>${lutinmatrix.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinwidget</artifactId>
+ <version>${lutinwidget.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!--Jaxx-->
+ <dependency>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-runtime-swing</artifactId>
+ <version>${jaxx.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-runtime-validator</artifactId>
+ <version>${jaxx.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-runtime-swing-widget</artifactId>
+ <version>${jaxx.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Utilisé dans les scripts -->
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinj2r</artifactId>
+ <version>${lutinj2r.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!--Commons-->
+ <dependency>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ <version>1.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-math</artifactId>
+ <version>2.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.8.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>1.6.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!--Other-->
+ <dependency>
+ <groupId>jfreechart</groupId>
+ <artifactId>jfreechart</artifactId>
+ <version>0.9.3</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jcommon</groupId>
+ <artifactId>jcommon</artifactId>
+ <version>0.7.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- XML-RPC Client and server -->
+ <dependency>
+ <groupId>org.apache.xmlrpc</groupId>
+ <artifactId>xmlrpc-client</artifactId>
+ <version>${xmlrpc.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.xmlrpc</groupId>
+ <artifactId>xmlrpc-server</artifactId>
+ <version>${xmlrpc.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- encore utilise pour les pre-scripts -->
+ <dependency>
+ <groupId>org.beanshell</groupId>
+ <artifactId>bsh</artifactId>
+ <version>2.0b4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>openmap</groupId>
+ <artifactId>openmap</artifactId>
+ <version>${openmap.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.fife</groupId>
+ <artifactId>rsyntaxtextarea</artifactId>
+ <version>1.3.4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <version>0.1.42</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Utilisé lors de l'import xml v2 (entre autre) -->
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ <version>1.1.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- Change this dependence if you change database -->
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.1.117</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- aspectwerkz -->
+ <dependency>
+ <groupId>aspectwerkz</groupId>
+ <artifactId>aspectwerkz</artifactId>
+ <version>${aspectwerkz.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>aspectwerkz</groupId>
+ <artifactId>aspectwerkz-jdk5</artifactId>
+ <version>${aspectwerkz.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>aspectwerkz</groupId>
+ <artifactId>aspectwerkz-core</artifactId>
+ <version>${aspectwerkz.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- ssj pour les calculs stockastiques -->
+ <dependency>
+ <groupId>ssj</groupId>
+ <artifactId>ssj</artifactId>
+ <version>2.1.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>ssj</groupId>
+ <artifactId>Blas</artifactId>
+ <version>20081007</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>ssj</groupId>
+ <artifactId>colt</artifactId>
+ <version>20081007</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>ssj</groupId>
+ <artifactId>interpreter</artifactId>
+ <version>1.6.8</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>ssj</groupId>
+ <artifactId>language</artifactId>
+ <version>1.6.7</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>ssj</groupId>
+ <artifactId>logger</artifactId>
+ <version>1.6.4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>ssj</groupId>
+ <artifactId>optimization</artifactId>
+ <version>20081007</version>
+ <scope>runtime</scope>
+ </dependency>
+ <!-- fin ssj pour les calculs stockastiques -->
+
+ <!-- debut svnkit pour communication subversion -->
+ <dependency>
+ <groupId>org.tmatesoft</groupId>
+ <artifactId>svnkit</artifactId>
+ <version>1.2.3.5521</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.trilead</groupId>
+ <artifactId>trilead-ssh2</artifactId>
+ <version>build213-svnkit-1.2</version>
+ <scope>runtime</scope>
+ </dependency>
+ <!-- fin svnkit pour communication subversion -->
+
+ <dependency>
+ <groupId>org.freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.15</version>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.cpdetector</groupId>
+ <artifactId>cpdetector</artifactId>
+ <version>1.0.7</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+ <name>IsisFish</name>
+ <description>Simulateur de pecherie complexe.</description>
+ <inceptionYear>1999</inceptionYear>
+
+ <licenses>
+ <license>
+ <name>GPL</name>
+ <url>http://www.gnu.org/copyleft/gpl.html</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+ <packaging>jar</packaging>
+
+ <properties>
+ <!-- id du projet du labs -->
+ <labs.id>8</labs.id>
+
+ <!-- nom du projet du labs -->
+ <labs.project>isis-fish</labs.project>
+
+ <!-- Custom version -->
+ <jaxx.version>1.5.1</jaxx.version>
+ <topia.version>2.1.6.1</topia.version>
+ <topia.service.version>1.0.3</topia.service.version>
+ <lutinmatrix.version>1.3</lutinmatrix.version>
+ <lutinutil.version>1.0.6</lutinutil.version>
+ <i18n.version>0.9</i18n.version>
+ <lutinwidget.version>0.14.1</lutinwidget.version>
+ <generator.version>0.64</generator.version>
+ <lutinj2r.version>0.4</lutinj2r.version>
+ <jrst.version>0.8.4</jrst.version>
+ <license-switcher.version>0.6</license-switcher.version>
+ <openmap.version>4.6.4</openmap.version>
+ <aspectwerkz.version>2.0</aspectwerkz.version>
+ <xmlrpc.version>3.1.2</xmlrpc.version>
+
+ <!-- for compilation test to run -->
+ <maven.test.forkMode>once</maven.test.forkMode>
+
+ <!--Main class in JAR -->
+ <maven.jar.main.class>fr.ifremer.isisfish.IsisFish</maven.jar.main.class>
+
+ <!-- jnlp -->
+ <keystorepath>${codelutin.keystorepath}</keystorepath>
+ <keystorealias>CodeLutin</keystorealias>
+ <keystorepass>codelutin</keystorepass>
+ <jnlp.build.directory>${project.build.directory}/jnlp</jnlp.build.directory>
+
+ <jnlpCodebase>${project.url}</jnlpCodebase>
+ <!-- to test jnlp file locally -->
+ <jnlpCodebase>file://${jnlp.build.directory}</jnlpCodebase>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-generator-plugin</artifactId>
+ <version>${generator.version}</version>
+ <executions>
+ <execution>
+ <id>Generator</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <srcDirZuml>${project.basedir}/src/main/xmi</srcDirZuml>
+ <srcXmiDest>${maven.gen.dir}/xmi/</srcXmiDest>
+ <fullPackagePath>fr.ifremer.isisfish</fullPackagePath>
+ <extractedPackages>fr.ifremer.isisfish</extractedPackages>
+ <!--Config generator-->
+ <srcGenDest>${maven.gen.dir}/objectmodel/</srcGenDest>
+ <includes>**/*.objectmodel</includes>
+ <templates>org.codelutin.topia.generator.TopiaMetaGenerator</templates>
+ <excludeTemplates>
+ <value>org.codelutin.topia.generator.EntityEnumGenerator</value>
+ <value>org.codelutin.topia.generator.EntityProviderGenerator</value>
+ </excludeTemplates>
+ <destDirGen>${maven.gen.dir}/java</destDirGen>
+ <defaultPackage>fr.ifremer.isisfish</defaultPackage>
+ <copyVersionDir>${project.basedir}/src/main/resources/oldmappings/%MODELNAME%
+ </copyVersionDir>
+ <copyVersionFiles>**/*.hbm.xml</copyVersionFiles>
+ <copyOverwrite>true</copyOverwrite>
+ </configuration>
+ <goals>
+ <goal>zargo2xmi</goal>
+ <goal>xmi2objectmodel</goal>
+ <goal>generate</goal>
+ <goal>copyVersionFiles</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.codelutin.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${topia.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <version>${jaxx.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <extraImportList>jaxx.runtime.SwingUtil,static jaxx.runtime.Util.getStringValue</extraImportList>
+ <addSourcesToClassPath>true</addSourcesToClassPath>
+ <addProjectClassPath>true</addProjectClassPath>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <version>${i18n.version}</version>
+ <configuration>
+ <entries>
+ <entry>
+ <basedir>${maven.gen.dir}/java/</basedir>
+ <specificGoal>parserJava</specificGoal>
+ <includes>
+ <param>**\/**UI.java</param>
+ </includes>
+ </entry>
+ </entries>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Always process jrst files, but only called on pre-site phase -->
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-jrst-plugin</artifactId>
+ <version>${jrst.version}</version>
+ <configuration>
+ <defaultLocale>fr</defaultLocale>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>jrst</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-4</version>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/bin.xml</descriptor>
+ </descriptors>
+ <attach>false</attach>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>lib/</classpathPrefix>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>java.io.tmpdir</name>
+ <value>${project.build.directory}/surefire-workdir</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <links>
+ <link>http://java.sun.com/javase/6/docs/api/</link>
+ <link>http://lutinutil.labs.libre-entreprise.org/lutinutil/apidocs/</link>
+ <link>http://lutinmatrix.labs.libre-entreprise.org/lutinmatrix/apidocs/</link>
+ <link>http://topia.labs.libre-entreprise.org/topia/topia-persistence/apidocs/</link>
+ </links>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>2.1</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/tags/isis-fish-3.2.0.5</connection>
+ <developerConnection>scm:svn:svn+ssh://chatellier at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/tags/isis-fish-3.2.0.5</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/isis-fish/tags/…</url>
+ </scm>
+
+ <!--Code Lutin Repository-->
+ <repositories>
+ <repository>
+ <id>codelutin-repository</id>
+ <name>CodeLutinRepository</name>
+ <url>http://lutinbuilder.labs.libre-entreprise.org/maven2</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </releases>
+ </repository>
+ </repositories>
+
+ <profiles>
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+
+ <!-- always add license and third-party files to classpath -->
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-license-switcher-plugin</artifactId>
+ <version>${license-switcher.version}</version>
+ <configuration>
+ <licenseName>${license-switcher.licenseName}</licenseName>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-licenses</id>
+ <goals>
+ <!--goal>license</goal-->
+ <goal>third-party</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!-- Ajout des libs signe par Sun dans un fichier jnlp separe -->
+ <execution>
+ <id>JnlpSun</id>
+ <phase>verify</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${jnlp.build.directory}" />
+ <copy file="${project.basedir}/src/main/jnlp/sun.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
+ <filterset>
+ <filter token="lib-javahelp" value="javahelp-2.0.02.jar" />
+ <filter token="lib-activation" value="activation-1.1.jar" />
+ <filter token="lib-mail" value="mail-1.4.jar" />
+ <filter token="url" value="${jnlpCodebase}" />
+ </filterset>
+ </copy>
+ <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
+ <filterset>
+ <filter token="lib" value="jxlayer-3.0.1.jar" />
+ <filter token="url" value="${jnlpCodebase}" />
+ </filterset>
+ </copy>
+
+ <copy verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false">
+ <fileset dir="${project.build.directory}/lib">
+ <include name="javahelp-2.0.02.jar" />
+ <include name="activation-1.1.jar" />
+ <include name="mail-1.4.jar" />
+ <include name="jxlayer-3.0.1.jar" />
+ </fileset>
+ </copy>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>JnlpToSite</id>
+ <phase>pre-site</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${maven.site.gen.dir}/resources" />
+ <copy todir="${maven.site.gen.dir}/resources" verbose="true" failonerror="false" overwrite="false">
+ <fileset dir="${jnlp.build.directory}">
+ <include name="**" />
+ </fileset>
+ <!-- should be better to use the deployed assembly in lutinbuilder ? -->
+ <fileset dir="target">
+ <include name="${project.build.finalName}-bin.zip" />
+ </fileset>
+
+ </copy>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo.webstart</groupId>
+ <artifactId>webstart-maven-plugin</artifactId>
+ <version>1.0-alpha-2-cl_20090204</version>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>jnlp-inline</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <force>false</force>
+ <dependencies>
+ <excludes>
+ <exclude>javax.help:javahelp</exclude>
+ <exclude>javax.mail:mail</exclude>
+ <exclude>javax.activation:activation</exclude>
+ <exclude>org.swinglabs:jxlayer</exclude>
+ </excludes>
+ </dependencies>
+ <libPath>lib</libPath>
+ <extensions>
+ <sun>sun.jnlp</sun>
+ <jxlayer>jxlayer.jnlp</jxlayer>
+ </extensions>
+ <jnlp>
+ <outputFile>isis-fish-v3.jnlp</outputFile>
+ <mainClass>${maven.jar.main.class}</mainClass>
+ <allPermissions>true</allPermissions>
+ <offlineAllowed>true</offlineAllowed>
+ </jnlp>
+
+ <sign>
+ <keystore>${keystorepath}</keystore>
+ <keypass />
+ <storepass>${keystorepass}</storepass>
+ <storetype />
+ <alias>${keystorealias}</alias>
+ <validity />
+ <dnameCn />
+ <dnameOu />
+ <dnameO />
+ <dnameL />
+ <dnameSt />
+ <dnameC />
+ <verify>true</verify>
+ <keystoreConfig>
+ <delete>false</delete>
+ <gen>false</gen>
+ </keystoreConfig>
+ </sign>
+ <pack200>false</pack200>
+ <gzip>true</gzip>
+ <verbose>false</verbose>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+
+</project>
1
0
Author: chatellier
Date: 2009-09-04 16:57:07 +0000 (Fri, 04 Sep 2009)
New Revision: 2585
Modified:
isis-fish/trunk/pom.xml
Log:
[maven-release-plugin] prepare release isis-fish-3.2.0.5
Modified: isis-fish/trunk/pom.xml
===================================================================
--- isis-fish/trunk/pom.xml 2009-09-04 16:43:48 UTC (rev 2584)
+++ isis-fish/trunk/pom.xml 2009-09-04 16:57:07 UTC (rev 2585)
@@ -13,7 +13,7 @@
<groupId>ifremer</groupId>
<artifactId>isis-fish</artifactId>
- <version>3.2.0.5-SNAPSHOT</version>
+ <version>3.2.0.5</version>
<!-- POM Relationships : Inheritance : Dependencies -->
<dependencies>
@@ -585,9 +585,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/trunk</connection>
- <developerConnection>scm:svn:svn+ssh://chatellier at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/trunk</developerConnection>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/isis-fish/trunk…</url>
+ <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/tags/isis-fish-3.2.0.5</connection>
+ <developerConnection>scm:svn:svn+ssh://chatellier at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/tags/isis-fish-3.2.0.5</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/isis-fish/tags/…</url>
</scm>
<!--Code Lutin Repository-->
1
0