r128 - in trunk: analyseplans exports rules scripts
Author: jcouteau Date: 2009-04-29 09:27:18 +0000 (Wed, 29 Apr 2009) New Revision: 128 Modified: trunk/analyseplans/Calibration.java trunk/analyseplans/Max.java trunk/exports/CapturesNombre.java trunk/exports/CapturesPoids.java trunk/exports/RejetsNombre.java trunk/exports/RejetsPoids.java trunk/rules/GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD.java trunk/rules/TACpoids.java trunk/scripts/GravityModel.java trunk/scripts/ResultName.java trunk/scripts/SiMatrix.java Log: Remove all accents to avoid formatting problems Format code Organize imports Modified: trunk/analyseplans/Calibration.java =================================================================== --- trunk/analyseplans/Calibration.java 2009-04-29 08:39:41 UTC (rev 127) +++ trunk/analyseplans/Calibration.java 2009-04-29 09:27:18 UTC (rev 128) @@ -2,341 +2,363 @@ import static org.codelutin.i18n.I18n._; +import java.io.File; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.codelutin.math.matrix.MatrixFactory; +import org.codelutin.math.matrix.MatrixIterator; +import org.codelutin.math.matrix.MatrixND; +import org.codelutin.topia.TopiaContext; +import org.codelutin.util.FileUtil; +import org.codelutin.util.StringUtil; import scripts.ResultName; - -import java.io.*; -import java.util.*; - -import org.codelutin.math.matrix.*; - -import org.codelutin.topia.*;// pour pouvoir utiliser la methode StringUtil.toDouble() -import org.codelutin.util.*;// pour pouvoir utiliser la methode StringUtil.toDouble() - -import fr.ifremer.isisfish.*; -import fr.ifremer.isisfish.types.*; -import fr.ifremer.isisfish.simulator.SimulationContext; -import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.entities.*; +import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; import fr.ifremer.isisfish.simulator.AnalysePlan; import fr.ifremer.isisfish.simulator.AnalysePlanContext; -import fr.ifremer.isisfish.simulator.SimulationParameter; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.types.Month; +import fr.ifremer.isisfish.util.Doc; -import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605) /** * Calibration_bidon.java - * + * * Created: 8 mars 2007 - * - * @author <> + * + * @author <> * @version $Revision: 1.2 $ - * - * Last update: $Date: 2007-11-02 17:43:14 $ - * by : $Author: bpoussin $ + * + * Last update: $Date: 2007-11-02 17:43:14 $ by : $Author: bpoussin $ */ public class Calibration implements AnalysePlan { /** to use log facility, just put in your code: log.info("..."); */ static private Log log = LogFactory.getLog(Calibration.class); - enum State {STATE_INIT, STATE_0, STATE_1, STATE_2, STATE_3, STATE_4}; - + enum State { + STATE_INIT, STATE_0, STATE_1, STATE_2, STATE_3, STATE_4 + }; + //parametres de la simu 3 points initiaux d un simplex d ordre 2 - @Doc(value="do the doc of param Population") + @Doc(value = "do the doc of param Population") public Population param_Population = null; - @Doc(value="do the doc of param M1 (devient un parametre du plan d analyse)") + @Doc(value = "do the doc of param M1 (devient un parametre du plan d analyse)") public String param_M1 = "1e-5;1e-6";// devient un parametre du plan d analyse - @Doc(value="do the doc of param M2 (devient un parametre du plan d analyse)") + @Doc(value = "do the doc of param M2 (devient un parametre du plan d analyse)") public String param_M2 = "2e-4;2e-5";// devient un parametre du plan d analyse - @Doc(value="do the doc of param M3 (devient un parametre du plan d analyse)") + @Doc(value = "do the doc of param M3 (devient un parametre du plan d analyse)") public String param_M3 = "1e-4;1e-6";// devient un parametre du plan d analyse - @Doc(value="do the doc of param pas (devient un parametre du plan d analyse)") + @Doc(value = "do the doc of param pas (devient un parametre du plan d analyse)") public String param_pas = "1e-5";// devient un parametre du plan d analyse - @Doc(value="nom + chemin du fichier contenant les debarquements observes par groupe pour la derniere annee") + @Doc(value = "nom + chemin du fichier contenant les debarquements observes par groupe pour la derniere annee") public String param_nomfichier_debarquements = "";//nom + chemin du fichier contenant les debarquements observes par groupe pour la derniere annee - protected File debarquementsObserves; + protected File debarquementsObserves; protected MatrixND matrixDebarquement; - + protected State state = State.STATE_INIT; protected Experiences experiences = new Experiences(); - - + /** * @return the experiences */ public Experiences getExperiences() { return this.experiences; } - - public String [] necessaryResult = { - ResultName.MATRIX_LANDING_PER_MET - }; + public String[] necessaryResult = { ResultName.MATRIX_LANDING_PER_MET }; + public String[] getNecessaryResult() { return this.necessaryResult; } /** * Permet d'afficher a l'utilisateur une aide sur le plan. + * * @return L'aide ou la description du plan */ public String getDescription() throws Exception { return _("Simplexe"); } - + /** * Appele au demarrage de la simulation, cette methode permet d'initialiser * des valeurs - * @param simulation La simulation pour lequel on utilise cette regle + * + * @param simulation + * La simulation pour lequel on utilise cette regle */ public void init(AnalysePlanContext context) throws Exception { - if (param_nomfichier_debarquements==null || "".equals(param_nomfichier_debarquements)){ - debarquementsObserves = FileUtil.getFile(".*.csv", "fichier csv séparateur ';'"); - } else { - debarquementsObserves = new File(param_nomfichier_debarquements); - } -// int nbYear = context.getParam().getNumberOfYear(); - TopiaContext db = context.getParam().getRegion().getStorage().beginTransaction(); - Population pop = (Population)db.findByTopiaId(param_Population.getTopiaId()); - - int nbGroup = pop.sizePopulationGroup(); - matrixDebarquement = MatrixFactory.getInstance().create(new int[]{nbGroup}); -// List<PopulationGroup> groups = pop.getPopulationGroup(); -// matrixDebarquement = MatrixFactory.getInstance().create(new List[]{groups}); - - matrixDebarquement.importCSV(new FileReader(debarquementsObserves),new int []{0}); - db.closeContext(); + if (param_nomfichier_debarquements == null + || "".equals(param_nomfichier_debarquements)) { + debarquementsObserves = FileUtil.getFile(".*.csv", + "fichier csv séparateur ';'"); + } else { + debarquementsObserves = new File(param_nomfichier_debarquements); + } + // int nbYear = context.getParam().getNumberOfYear(); + TopiaContext db = context.getParam().getRegion().getStorage() + .beginTransaction(); + Population pop = (Population) db.findByTopiaId(param_Population + .getTopiaId()); + + int nbGroup = pop.sizePopulationGroup(); + matrixDebarquement = MatrixFactory.getInstance().create( + new int[] { nbGroup }); + // List<PopulationGroup> groups = pop.getPopulationGroup(); + // matrixDebarquement = MatrixFactory.getInstance().create(new List[]{groups}); + + matrixDebarquement.importCSV(new FileReader(debarquementsObserves), + new int[] { 0 }); + db.closeContext(); } - + /** * Call before each simulation - * @param context plan context - * @param nextSimulation storage used for next simulation + * + * @param context + * plan context + * @param nextSimulation + * storage used for next simulation * @return true if we must do next simulation, false to stop plan * @throws Exception */ - public boolean beforeSimulation(AnalysePlanContext context, SimulationStorage nextSimulation) throws Exception { - boolean doNext = true; + public boolean beforeSimulation(AnalysePlanContext context, + SimulationStorage nextSimulation) throws Exception { + boolean doNext = true; - int number = context.getNumber(); + int number = context.getNumber(); - if (number < 3) { - String [] M1 = param_M1.split(";"); - String [] M2 = param_M2.split(";"); - String [] M3 = param_M3.split(";"); - double [] q1 = StringUtil.toArrayDouble(M1[0], M2[0], M3[0]); - double [] q2 = StringUtil.toArrayDouble(M1[1], M2[1], M3[1]); - - experiences.getExperience(number).q1 = q1[number]; - experiences.getExperience(number).q2 = q2[number]; + if (number < 3) { + String[] M1 = param_M1.split(";"); + String[] M2 = param_M2.split(";"); + String[] M3 = param_M3.split(";"); + double[] q1 = StringUtil.toArrayDouble(M1[0], M2[0], M3[0]); + double[] q2 = StringUtil.toArrayDouble(M1[1], M2[1], M3[1]); - changeDB(experiences.getExperience(number), nextSimulation); - } else { - double q1 = 0; - double q2 = 0; - - double lastCritere = experiences.getExperience(number-1).criteria; - double g1 = (experiences.current.get(2).q1 + experiences.current.get(1).q1) / 2.0; - double g2 = (experiences.current.get(2).q2 + experiences.current.get(1).q2) / 2.0; - - double worst1 = experiences.current.get(0).q1; - double worst2 = experiences.current.get(0).q2; + experiences.getExperience(number).q1 = q1[number]; + experiences.getExperience(number).q2 = q2[number]; - - if (state == State.STATE_INIT) { - // on fait la 4eme simulation dans tous les cas - state = State.STATE_0; - Collections.sort(experiences.current); - q1 = 2 * g1 - worst1; - q2 = 2 * g2 - worst2; - } else if (state == State.STATE_0) { - // on fait la 5eme avec des q qui dependent de la 4eme dans le dernier cas - if (lastCritere < experiences.current.get(0).criteria) { - state = State.STATE_1; - q1 = g1 - ( g1 - worst1 ) / 2.0; - q2 = g2 - ( g2 - worst2 ) / 2.0; - } else if (lastCritere < experiences.current.get(1).criteria) { - state = State.STATE_2; - q1 = g1 + ( g1 - worst1 ) / 2.0; - q2 = g2 + ( g2 - worst2 ) / 2.0; - } else if (lastCritere < experiences.current.get(2).criteria) { - state = State.STATE_INIT; - experiences.current.remove(3); - } else { // dernier cas possible: if (lastCritere > experiences.current.get(2).critere) { - state = State.STATE_4; - q1 = experiences.current.get(3).q1 + g1 - worst1; - q2 = experiences.current.get(3).q2 + g2 - worst2; - } - } else if (state == State.STATE_1) { - // la derniere simulation a ete faite - if (lastCritere > experiences.current.get(0).criteria) { - experiences.current.remove(3); - experiences.current.remove(0); - } else { - // FIXME on supprime les 2 derniere qui vient d'etre faite, on risque donc de boucler - experiences.current.remove(4); - experiences.current.remove(3); + changeDB(experiences.getExperience(number), nextSimulation); + } else { + double q1 = 0; + double q2 = 0; + + double lastCritere = experiences.getExperience(number - 1).criteria; + double g1 = (experiences.current.get(2).q1 + experiences.current + .get(1).q1) / 2.0; + double g2 = (experiences.current.get(2).q2 + experiences.current + .get(1).q2) / 2.0; + + double worst1 = experiences.current.get(0).q1; + double worst2 = experiences.current.get(0).q2; + + if (state == State.STATE_INIT) { + // on fait la 4eme simulation dans tous les cas + state = State.STATE_0; + Collections.sort(experiences.current); + q1 = 2 * g1 - worst1; + q2 = 2 * g2 - worst2; + } else if (state == State.STATE_0) { + // on fait la 5eme avec des q qui dependent de la 4eme dans le dernier cas + if (lastCritere < experiences.current.get(0).criteria) { + state = State.STATE_1; + q1 = g1 - (g1 - worst1) / 2.0; + q2 = g2 - (g2 - worst2) / 2.0; + } else if (lastCritere < experiences.current.get(1).criteria) { + state = State.STATE_2; + q1 = g1 + (g1 - worst1) / 2.0; + q2 = g2 + (g2 - worst2) / 2.0; + } else if (lastCritere < experiences.current.get(2).criteria) { + state = State.STATE_INIT; + experiences.current.remove(3); + } else { // dernier cas possible: if (lastCritere > experiences.current.get(2).critere) { + state = State.STATE_4; + q1 = experiences.current.get(3).q1 + g1 - worst1; + q2 = experiences.current.get(3).q2 + g2 - worst2; + } + } else if (state == State.STATE_1) { + // la derniere simulation a ete faite + if (lastCritere > experiences.current.get(0).criteria) { + experiences.current.remove(3); + experiences.current.remove(0); + } else { + // FIXME on supprime les 2 derniere qui vient d'etre faite, on risque donc de boucler + experiences.current.remove(4); + experiences.current.remove(3); doNext = false; - } - state = State.STATE_INIT; - } else if (state == State.STATE_2) { - if (lastCritere > experiences.current.get(0).criteria) { - experiences.current.remove(3); - experiences.current.remove(0); - } else { - // FIXME on supprime les 2 derniere qui vient d'etre faite, on risque donc de boucler - experiences.current.remove(4); - experiences.current.remove(3); + } + state = State.STATE_INIT; + } else if (state == State.STATE_2) { + if (lastCritere > experiences.current.get(0).criteria) { + experiences.current.remove(3); + experiences.current.remove(0); + } else { + // FIXME on supprime les 2 derniere qui vient d'etre faite, on risque donc de boucler + experiences.current.remove(4); + experiences.current.remove(3); doNext = false; - } - state = State.STATE_INIT; - } else if (state == State.STATE_4) { - if (lastCritere > experiences.current.get(3).criteria) { - experiences.current.remove(3); - experiences.current.remove(0); - } else { - experiences.current.remove(4); - experiences.current.remove(0); - } - state = State.STATE_INIT; - } - - experiences.getExperience(number).q1 = q1; - experiences.getExperience(number).q2 = q2; + } + state = State.STATE_INIT; + } else if (state == State.STATE_4) { + if (lastCritere > experiences.current.get(3).criteria) { + experiences.current.remove(3); + experiences.current.remove(0); + } else { + experiences.current.remove(4); + experiences.current.remove(0); + } + state = State.STATE_INIT; + } - changeDB(experiences.getExperience(number), nextSimulation); - } + experiences.getExperience(number).q1 = q1; + experiences.getExperience(number).q2 = q2; - return doNext; + changeDB(experiences.getExperience(number), nextSimulation); + } + + return doNext; } /** * Call after each simulation, compute criteria for last simulation - * @param context plan context - * @param nextSimulation storage used for next simulation + * + * @param context + * plan context + * @param nextSimulation + * storage used for next simulation * @return true if we must do next simulation, false to stop plan * @throws Exception */ - public boolean afterSimulation(AnalysePlanContext context, SimulationStorage lastSimulation) throws Exception { + public boolean afterSimulation(AnalysePlanContext context, + SimulationStorage lastSimulation) throws Exception { boolean doNext = true; - + int number = context.getNumber(); ResultStorage result = lastSimulation.getResultStorage(); log.fatal("sim: " + lastSimulation + " result: " + result); - MatrixND L = result.getMatrix(param_Population, ResultName.MATRIX_LANDING_PER_MET); + MatrixND L = result.getMatrix(param_Population, + ResultName.MATRIX_LANDING_PER_MET); L = L.sumOverDim(0);// sum sur les mois, si on ajoute le pas (12) on peut sommer sur les annees L = L.sumOverDim(1);// sum sur les strategies L = L.sumOverDim(3);// sum sur les metiers L = L.sumOverDim(4);// sum sur les zones L = L.reduce(); // supprime les dim qui n ont qu un element - + double crit = 0; - for ( MatrixIterator g = L.iterator(); g.hasNext();){ + for (MatrixIterator g = L.iterator(); g.hasNext();) { g.next(); - int [] dim = g.getCoordinates(); + int[] dim = g.getCoordinates(); double obs = matrixDebarquement.getValue(dim); double simules = g.getValue(); - crit += Math.pow(obs-simules, 2); + crit += Math.pow(obs - simules, 2); } experiences.getExperience(number).criteria = crit; - + return doNext; } /** * Modify nextSimulation database with q1 and q2 in exp. + * * @param exp * @param nextSimulation * @throws Exception */ - protected void changeDB(Experience exp, SimulationStorage nextSimulation) throws Exception { - TopiaContext db = nextSimulation.getStorage().beginTransaction();//ouvrir un context pour modifier les donnees - Population pop = (Population)db.findByTopiaId(param_Population.getTopiaId()); -// autre solution moins efficace: -// PopulationDAO popDAO = IsisFishDAOHelper.getPopulationDAO(db); -// Population Nephrops = dao.findByName(param_Population.getName()); + protected void changeDB(Experience exp, SimulationStorage nextSimulation) + throws Exception { + TopiaContext db = nextSimulation.getStorage().beginTransaction();//ouvrir un context pour modifier les donnees + Population pop = (Population) db.findByTopiaId(param_Population + .getTopiaId()); + // autre solution moins efficace: + // PopulationDAO popDAO = IsisFishDAOHelper.getPopulationDAO(db); + // Population Nephrops = dao.findByName(param_Population.getName()); - MatrixND c = pop.getCapturability(); + MatrixND c = pop.getCapturability(); - for (MatrixIterator i = c.iterator(); i.hasNext();){ - i.next(); + for (MatrixIterator i = c.iterator(); i.hasNext();) { + i.next(); - Object [] sem = i.getSemanticsCoordinates(); - PopulationGroup group = (PopulationGroup)sem[0]; - PopulationSeasonInfo season = (PopulationSeasonInfo)sem[1]; + Object[] sem = i.getSemanticsCoordinates(); + PopulationGroup group = (PopulationGroup) sem[0]; + PopulationSeasonInfo season = (PopulationSeasonInfo) sem[1]; - if (season.getFirstMonth().after(Month.JULY) && group.getId() >=18){ //mois >= aout - i.setValue(exp.q2); - } - else { - i.setValue(exp.q1); - } - } - db.commitTransaction(); - db.closeContext(); + if (season.getFirstMonth().after(Month.JULY) && group.getId() >= 18) { //mois >= aout + i.setValue(exp.q2); + } else { + i.setValue(exp.q1); + } + } + db.commitTransaction(); + db.closeContext(); } - + public class Experiences { /** contains last simplex and potentialy 2 more simulation */ - protected List<Experience> current = new ArrayList<Experience>(); + protected List<Experience> current = new ArrayList<Experience>(); /** contains all experience done */ - protected List<Experience> history = new ArrayList<Experience>(); - + protected List<Experience> history = new ArrayList<Experience>(); + /** * @return the history */ public List<Experience> getHistory() { return this.history; } - + /** - * return experience requested, if this experience doesn't exist - * create it. + * return experience requested, if this experience doesn't exist create + * it. * - * @param i simulation number - * @return experience with simulation number fixed if new experience - * is returned + * @param i + * simulation number + * @return experience with simulation number fixed if new experience is + * returned */ - public Experience getExperience(int i) { - Experience result; - if (i<history.size()) { - result = history.get(i); - } else { - result = new Experience(); - result.simNumber = i; - history.add(i, result); - current.add(result); - } - return result; - } + public Experience getExperience(int i) { + Experience result; + if (i < history.size()) { + result = history.get(i); + } else { + result = new Experience(); + result.simNumber = i; + history.add(i, result); + current.add(result); + } + return result; + } } - + /** * Use to keep q1, q2 and criteria of simulation + * * @author poussin */ public class Experience implements Comparable { - public int simNumber; - public double criteria; - public double q1; - public double q2; - + public int simNumber; + public double criteria; + public double q1; + public double q2; + /** - * Permit to order experience, first is experience with smallest criteria + * Permit to order experience, first is experience with smallest + * criteria */ - public int compareTo(Object arg0) { - Experience other = (Experience)arg0; - int result = Double.compare(this.criteria, other.criteria); - return result; - } + public int compareTo(Object arg0) { + Experience other = (Experience) arg0; + int result = Double.compare(this.criteria, other.criteria); + return result; + } } } - Modified: trunk/analyseplans/Max.java =================================================================== --- trunk/analyseplans/Max.java 2009-04-29 08:39:41 UTC (rev 127) +++ trunk/analyseplans/Max.java 2009-04-29 09:27:18 UTC (rev 128) @@ -5,45 +5,30 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import scripts.ResultName; - -import java.io.Writer; - -import org.codelutin.math.matrix.*; - -import fr.ifremer.isisfish.simulator.SimulationContext; -import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.entities.*; -import fr.ifremer.isisfish.simulator.AnalysePlan; -import fr.ifremer.isisfish.simulator.AnalysePlanContext; -import fr.ifremer.isisfish.simulator.SimulationParameter; import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.datastore.ResultStorage; - +import fr.ifremer.isisfish.simulator.AnalysePlanContext; import fr.ifremer.isisfish.simulator.AnalysePlanIndependent; -import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605) +import fr.ifremer.isisfish.util.Doc; /** * Max.java - * + * * Created: 2 mars 2007 - * + * * @author bpoussin <bpoussin@labs.libre-entreprise.org> * @version $Revision: 1.2 $ - * - * Last update: $Date: 2007-03-09 15:27:21 $ - * by : $Author: bpoussin $ + * + * Last update: $Date: 2007-03-09 15:27:21 $ by : $Author: bpoussin $ */ public class Max implements AnalysePlanIndependent { /** to use log facility, just put in your code: log.info("..."); */ static private Log log = LogFactory.getLog(Max.class); - @Doc(value="do the doc of param max") - public int param_max = 10; + @Doc(value = "do the doc of param max") + public int param_max = 10; - - public String [] necessaryResult = { + public String[] necessaryResult = { // put here all necessary result for this rule // example: // ResultName.MATRIX_BIOMASS, @@ -56,41 +41,52 @@ /** * Permet d'afficher a l'utilisateur une aide sur le plan. + * * @return L'aide ou la description du plan */ public String getDescription() throws Exception { return _("Permit to specify maximum simulation numbers"); } - + /** * Appel� au d�marrage de la simulation, cette m�thode permet d'initialiser * des valeurs - * @param simulation La simulation pour lequel on utilise cette regle + * + * @param simulation + * La simulation pour lequel on utilise cette regle */ public void init(AnalysePlanContext context) throws Exception { - + } - + /** * Call before each simulation - * @param context plan context - * @param nextSimulation storage used for next simulation + * + * @param context + * plan context + * @param nextSimulation + * storage used for next simulation * @return true if we must do next simulation, false to stop plan * @throws Exception */ - public boolean beforeSimulation(AnalysePlanContext context, SimulationStorage nextSimulation) throws Exception { + public boolean beforeSimulation(AnalysePlanContext context, + SimulationStorage nextSimulation) throws Exception { boolean result = context.getNumber() < param_max; return result; } /** * Call after each simulation - * @param context plan context - * @param nextSimulation storage used for next simulation + * + * @param context + * plan context + * @param nextSimulation + * storage used for next simulation * @return true if we must do next simulation, false to stop plan * @throws Exception */ - public boolean afterSimulation(AnalysePlanContext context, SimulationStorage lastSimulation) throws Exception { + public boolean afterSimulation(AnalysePlanContext context, + SimulationStorage lastSimulation) throws Exception { return true; } Modified: trunk/exports/CapturesNombre.java =================================================================== --- trunk/exports/CapturesNombre.java 2009-04-29 08:39:41 UTC (rev 127) +++ trunk/exports/CapturesNombre.java 2009-04-29 09:27:18 UTC (rev 128) @@ -2,44 +2,41 @@ import static org.codelutin.i18n.I18n._; +import java.io.Writer; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.codelutin.math.matrix.MatrixIterator; +import org.codelutin.math.matrix.MatrixND; -import java.io.Writer; - -import org.codelutin.math.matrix.*; - import scripts.ResultName; - -import fr.ifremer.isisfish.entities.*; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Metier; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.Zone; import fr.ifremer.isisfish.export.Export; import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.util.Doc; -import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605) - /** * CapturesNombre.java - * + * * Created: 23 novembre 2006 - * + * * @author anonymous <anonymous@labs.libre-entreprise.org> * @version $Revision: 1.4 $ - * - * Last update: $Date: 2007-05-24 09:30:07 $ - * by : $Author: bpoussin $ + * + * Last update: $Date: 2007-05-24 09:30:07 $ by : $Author: bpoussin $ */ - @Doc(value="do the doc of class CaptureNombre") +@Doc(value = "do the doc of class CaptureNombre") public class CapturesNombre implements Export { /** to use log facility, just put in your code: log.info("..."); */ static private Log log = LogFactory.getLog(CapturesNombre.class); - protected String [] necessaryResult = { - ResultName.MATRIX_CATCH_PER_STRATEGY_MET - }; - + protected String[] necessaryResult = { ResultName.MATRIX_CATCH_PER_STRATEGY_MET }; + public String[] getNecessaryResult() { return this.necessaryResult; } @@ -47,76 +44,80 @@ public String getExportFilename() { return "CapturesNombre"; } - + public String getExtensionFilename() { return ".csv"; } - + public String getDescription() { return _("Export les captures en nombre de la simulation. tableau pop;metier;id;zone;nombre"); } - public void export(SimulationStorage simulation, Writer out) throws Exception { + public void export(SimulationStorage simulation, Writer out) + throws Exception { Date lastDate = simulation.getResultStorage().getLastDate(); - + for (Population pop : simulation.getParameter().getPopulations()) { - for (Date date = new Date(0); !date.after(lastDate); date = date.next() ) { - MatrixND mat = simulation.getResultStorage().getMatrix(date, pop, - ResultName.MATRIX_CATCH_PER_STRATEGY_MET); + for (Date date = new Date(0); !date.after(lastDate); date = date + .next()) { + MatrixND mat = simulation.getResultStorage().getMatrix(date, + pop, ResultName.MATRIX_CATCH_PER_STRATEGY_MET); if (mat != null) { // can be null if simulation is stopped before last year simulation mat = mat.sumOverDim(0); //sum on strategy - for (MatrixIterator i=mat.iterator(); i.hasNext();) { + for (MatrixIterator i = mat.iterator(); i.hasNext();) { i.next(); - Object [] sems = i.getSemanticsCoordinates(); - Metier metier = (Metier)sems[1]; - PopulationGroup group = (PopulationGroup)sems[2]; - Zone zone = (Zone)sems[3]; + Object[] sems = i.getSemanticsCoordinates(); + Metier metier = (Metier) sems[1]; + PopulationGroup group = (PopulationGroup) sems[2]; + Zone zone = (Zone) sems[3]; double val = i.getValue(); - out.write(pop.getName() +";"+ metier.getName() +";"+ group.getId() +";"+ zone.getName() +";"+ date.getDate() +";"+ val +"\n"); + out.write(pop.getName() + ";" + metier.getName() + ";" + + group.getId() + ";" + zone.getName() + ";" + + date.getDate() + ";" + val + "\n"); } } } } /* -var Parametre=sim.getParametre(); -var Populations=Parametre.getPopulations(); -var PDate=Packages.fr.ifremer.nodb.Date; + var Parametre=sim.getParametre(); + var Populations=Parametre.getPopulations(); + var PDate=Packages.fr.ifremer.nodb.Date; -var capture=0.0; -var result=""; + var capture=0.0; + var result=""; -writeln("debut de export captures nombre"); -var dateexport=new Packages.java.util.Date(); -var formatteur= new Packages.java.text.SimpleDateFormat(); -writeln("heure de debut: "+formatteur.format(dateexport)); -var finsimu=resultats.getLastDate().getDate(); + writeln("debut de export captures nombre"); + var dateexport=new Packages.java.util.Date(); + var formatteur= new Packages.java.text.SimpleDateFormat(); + writeln("heure de debut: "+formatteur.format(dateexport)); + var finsimu=resultats.getLastDate().getDate(); -for (var ipop=Populations.iterator();ipop.hasNext();){ - var pop=ipop.next(); - for (var idate=0;idate<=finsimu;idate++){ - var date=new PDate(idate); - var matrice=resultats.getMatrix(date,pop, "matriceCatchPerStrategyMet"); - var temp=matrice.sumOverDim(0); - writeln("on a la matrice"); - for (var iiterateur=temp.iterator();iiterateur.next();){ - var coordonnees=iiterateur.getSemanticsCoordinates(); - var metier=coordonnees[1]; - var c=coordonnees[2]; - var z=coordonnees[3]; - capture=iiterateur.getValue(); - result+=pop.getNom()+";"+metier.getNom()+";"+c.getId()+";"+z.getNom()+";"+idate+";"+capture+"\n"; - } - } -} + for (var ipop=Populations.iterator();ipop.hasNext();){ + var pop=ipop.next(); + for (var idate=0;idate<=finsimu;idate++){ + var date=new PDate(idate); + var matrice=resultats.getMatrix(date,pop, "matriceCatchPerStrategyMet"); + var temp=matrice.sumOverDim(0); + writeln("on a la matrice"); + for (var iiterateur=temp.iterator();iiterateur.next();){ + var coordonnees=iiterateur.getSemanticsCoordinates(); + var metier=coordonnees[1]; + var c=coordonnees[2]; + var z=coordonnees[3]; + capture=iiterateur.getValue(); + result+=pop.getNom()+";"+metier.getNom()+";"+c.getId()+";"+z.getNom()+";"+idate+";"+capture+"\n"; + } + } + } -writeln("fin de CapturesNombre"); + writeln("fin de CapturesNombre"); -return ""+result; + return ""+result; -*/ + */ } } Modified: trunk/exports/CapturesPoids.java =================================================================== --- trunk/exports/CapturesPoids.java 2009-04-29 08:39:41 UTC (rev 127) +++ trunk/exports/CapturesPoids.java 2009-04-29 09:27:18 UTC (rev 128) @@ -2,44 +2,41 @@ import static org.codelutin.i18n.I18n._; +import java.io.Writer; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.codelutin.math.matrix.MatrixIterator; +import org.codelutin.math.matrix.MatrixND; -import java.io.Writer; - -import org.codelutin.math.matrix.*; - import scripts.ResultName; - -import fr.ifremer.isisfish.entities.*; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Metier; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.Zone; import fr.ifremer.isisfish.export.Export; import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.util.Doc; -import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605) - /** * CapturesPoids.java - * + * * Created: 23 novembre 2006 - * + * * @author anonymous <anonymous@labs.libre-entreprise.org> * @version $Revision: 1.4 $ - * - * Last update: $Date: 2007-05-24 09:30:07 $ - * by : $Author: bpoussin $ + * + * Last update: $Date: 2007-05-24 09:30:07 $ by : $Author: bpoussin $ */ - @Doc(value="do the doc of class CapturesPoids") +@Doc(value = "do the doc of class CapturesPoids") public class CapturesPoids implements Export { /** to use log facility, just put in your code: log.info("..."); */ static private Log log = LogFactory.getLog(CapturesPoids.class); - protected String [] necessaryResult = { - ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET - }; - + protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET }; + public String[] getNecessaryResult() { return this.necessaryResult; } @@ -47,72 +44,76 @@ public String getExportFilename() { return "CapturesPoids"; } - + public String getExtensionFilename() { return ".csv"; } - + public String getDescription() { return _("Export les captures en poids de la simulation. tableau pop;metier;id;zone;nombre"); } - public void export(SimulationStorage simulation, Writer out) throws Exception { + public void export(SimulationStorage simulation, Writer out) + throws Exception { Date lastDate = simulation.getResultStorage().getLastDate(); for (Population pop : simulation.getParameter().getPopulations()) { - for (Date date = new Date(0); !date.after(lastDate); date = date.next() ) { - MatrixND mat = simulation.getResultStorage().getMatrix(date, pop, - ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET); + for (Date date = new Date(0); !date.after(lastDate); date = date + .next()) { + MatrixND mat = simulation.getResultStorage().getMatrix(date, + pop, ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET); if (mat != null) { // can be null if simulation is stopped before last year simulation mat = mat.sumOverDim(0); //sum on strategy - for (MatrixIterator i=mat.iterator(); i.hasNext();) { + for (MatrixIterator i = mat.iterator(); i.hasNext();) { i.next(); - Object [] sems = i.getSemanticsCoordinates(); - Metier metier = (Metier)sems[1]; - PopulationGroup group = (PopulationGroup)sems[2]; - Zone zone = (Zone)sems[3]; + Object[] sems = i.getSemanticsCoordinates(); + Metier metier = (Metier) sems[1]; + PopulationGroup group = (PopulationGroup) sems[2]; + Zone zone = (Zone) sems[3]; double val = i.getValue(); - out.write(pop.getName() +";"+ metier.getName() +";"+ group.getId() +";"+ zone.getName() +";"+ date.getDate() +";"+ val +"\n"); + out.write(pop.getName() + ";" + metier.getName() + ";" + + group.getId() + ";" + zone.getName() + ";" + + date.getDate() + ";" + val + "\n"); } } } } -/* -var Parametre=sim.getParametre(); -var Populations=Parametre.getPopulations(); -var PDate=Packages.fr.ifremer.nodb.Date; + /* + var Parametre=sim.getParametre(); + var Populations=Parametre.getPopulations(); + var PDate=Packages.fr.ifremer.nodb.Date; -var capture=0.0; -var result=""; -writeln("debut de export captures poids"); -var dateexport=new Packages.java.util.Date(); -var formatteur= new Packages.java.text.SimpleDateFormat(); -writeln("heure de debut: "+formatteur.format(dateexport)); -var finsimu=resultats.getLastDate().getDate(); + var capture=0.0; + var result=""; + writeln("debut de export captures poids"); + var dateexport=new Packages.java.util.Date(); + var formatteur= new Packages.java.text.SimpleDateFormat(); + writeln("heure de debut: "+formatteur.format(dateexport)); + var finsimu=resultats.getLastDate().getDate(); -for (var ipop=Populations.iterator();ipop.hasNext();){ - var pop=ipop.next(); - for (var idate=0;idate<=finsimu;idate++){ - var date=new PDate(idate); - var matrice=resultats.getMatrix(date,pop, "matriceCatchWeightPerStrategyMet"); - var temp=matrice.sumOverDim(0); - writeln("on a la matrice"); - for (var iiterateur=temp.iterator();iiterateur.next();){ - var coordonnees=iiterateur.getSemanticsCoordinates(); - var metier=coordonnees[1]; - var c=coordonnees[2]; - var z=coordonnees[3]; - capture=iiterateur.getValue(); - result+=pop.getNom()+";"+metier.getNom()+";"+c.getId()+";"+z.getNom()+";"+idate+";"+capture+"\n"; - } - } -} + for (var ipop=Populations.iterator();ipop.hasNext();){ + var pop=ipop.next(); + for (var idate=0;idate<=finsimu;idate++){ + var date=new PDate(idate); + var matrice=resultats.getMatrix(date,pop, "matriceCatchWeightPerStrategyMet"); + var temp=matrice.sumOverDim(0); + writeln("on a la matrice"); + for (var iiterateur=temp.iterator();iiterateur.next();){ + var coordonnees=iiterateur.getSemanticsCoordinates(); + var metier=coordonnees[1]; + var c=coordonnees[2]; + var z=coordonnees[3]; + capture=iiterateur.getValue(); + result+=pop.getNom()+";"+metier.getNom()+";"+c.getId()+";"+z.getNom()+";"+idate+";"+capture+"\n"; + } + } + } -writeln("fin de CapturesPoids"); -return ""+result; + writeln("fin de CapturesPoids"); + return ""+result; -*/ + */ } } Modified: trunk/exports/RejetsNombre.java =================================================================== --- trunk/exports/RejetsNombre.java 2009-04-29 08:39:41 UTC (rev 127) +++ trunk/exports/RejetsNombre.java 2009-04-29 09:27:18 UTC (rev 128) @@ -2,23 +2,23 @@ import static org.codelutin.i18n.I18n._; +import java.io.Writer; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.codelutin.math.matrix.MatrixIterator; +import org.codelutin.math.matrix.MatrixND; -import java.io.Writer; - -import org.codelutin.math.matrix.*; - import scripts.ResultName; - -import fr.ifremer.isisfish.entities.*; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Metier; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.Zone; import fr.ifremer.isisfish.export.Export; import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.util.Doc; -import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605) - /** * RejetsNombre.java * Modified: trunk/exports/RejetsPoids.java =================================================================== --- trunk/exports/RejetsPoids.java 2009-04-29 08:39:41 UTC (rev 127) +++ trunk/exports/RejetsPoids.java 2009-04-29 09:27:18 UTC (rev 128) @@ -2,23 +2,23 @@ import static org.codelutin.i18n.I18n._; +import java.io.Writer; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.codelutin.math.matrix.MatrixIterator; +import org.codelutin.math.matrix.MatrixND; -import java.io.Writer; - -import org.codelutin.math.matrix.*; - import scripts.ResultName; - -import fr.ifremer.isisfish.entities.*; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Metier; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.Zone; import fr.ifremer.isisfish.export.Export; import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.util.Doc; -import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605) - /** * RejetsPoids.java * Modified: trunk/rules/GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD.java =================================================================== --- trunk/rules/GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD.java 2009-04-29 08:39:41 UTC (rev 127) +++ trunk/rules/GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD.java 2009-04-29 09:27:18 UTC (rev 128) @@ -29,6 +29,7 @@ import fr.ifremer.isisfish.simulator.SimulationContext; import fr.ifremer.isisfish.types.Date; import fr.ifremer.isisfish.types.Month; +import fr.ifremer.isisfish.util.Doc; /** * GraviteVPUE1Anchois.java @@ -46,11 +47,15 @@ static private Log log = LogFactory .getLog(GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD.class); + @Doc(value = "do the doc of param coeffOthers0") public String param_nomfichier_coeffOthers0 = "Inputs_Langoustine/CoeffOthers_Intercept_Langoustine/CoeffOthersNephrops.csv"; + @Doc(value = "do the doc of param coeffOthers1") public String param_nomfichier_coeffOthers1 = "Inputs_Langoustine/CoeffOthers_Intercept_Langoustine/CoeffOthersHake.csv"; + @Doc(value = "do the doc of param coeffOthers2") public String param_nomfichier_coeffOthers2 = "Inputs_Langoustine/CoeffOthers_Intercept_Langoustine/CoeffOthersBenthic.csv"; + @Doc(value = "do the doc of param gravite") public boolean param_gravite = false; - // doit �tre � vrai si gravite s'applique sinon la methode calcul uniquement les grossvalue otherspecies + // doit etre a vrai si gravite s'applique sinon la methode calcul uniquement les grossvalue otherspecies static final protected String BETA_O = "BetaOthers"; static final protected String ALPHA_O = "AlphaOthers"; @@ -96,20 +101,20 @@ * @return L'aide ou la description de la regle */ public String getDescription() throws Exception { - return _("calcule les proportion par m�tier chaque mois en fonction de la VPUE du m�tier l'ann�e pr�c�dante et les gross Values otherSpecies"); + return _("calcule les proportion par metier chaque mois en fonction de la VPUE du metier l'annee precedante et les gross Values otherSpecies"); /*"HYPOTHESES GRAVITE" - " attention cette r�gle doit toujours �tre mise avant les mesures de gestion"+ - " si pour un metier Effort (m�tier annee-1,mois) = 0 et propinitiale (m�tier, mois) !=0 (ie m�tier potentiellement pratiqu�), alors "+ - on remet propInitiale pour tous les m�tiers (premiere vue complete pour tous les metiers de la strategie - graviteVPUE1-, une alternative - pourrait �tre de chercher lapremiere ann�e avant ann�e -1 pour laquelle le m�tier, ayant une propInitiale non nulle , aurait une VPUE (metier,mois) non nulle - et recuperer la propStr (metier,mois) pour cette ann�e et on l'affecte ann�e courante - mois, les autres m�tiers se partageant la proportion d'effort restante - en fonction de leur VPUE - graviteVPUE2-, une alternative pourrait etre de chercher la premiere ann�e avant ann�e -1 pour laquelle tous les m�tiers, - ayant une propInitiale non nulle, auraient eu une propStr non nulle, (surement difficile � trouver) - - graviteVPUE3- d'autres hypoth�ses pourraient etre envisag�es) + " attention cette regle doit toujours etre mise avant les mesures de gestion"+ + " si pour un metier Effort (metier annee-1,mois) = 0 et propinitiale (metier, mois) !=0 (ie metier potentiellement pratique), alors "+ + on remet propInitiale pour tous les metiers (premiere vue complete pour tous les metiers de la strategie - graviteVPUE1-, une alternative + pourrait etre de chercher lapremiere annee avant annee -1 pour laquelle le metier, ayant une propInitiale non nulle , aurait une VPUE (metier,mois) non nulle + et recuperer la propStr (metier,mois) pour cette annee et on l'affecte annee courante - mois, les autres metiers se partageant la proportion d'effort restante + en fonction de leur VPUE - graviteVPUE2-, une alternative pourrait etre de chercher la premiere annee avant annee -1 pour laquelle tous les metiers, + ayant une propInitiale non nulle, auraient eu une propStr non nulle, (surement difficile a trouver) - - graviteVPUE3- d'autres hypotheses pourraient etre envisagees) "*/ - /*Calcul des gross Value Other Species en fonction de l'effort par strategie et par m�tier � date - Avant ann�e 1 (premiere ann�e d'appliaction de Gravit�) - il faut deja faire les calculs des grossValues des autres esp�ces - A partir de l'ann�e 1 : Gravit� s'applique, il faut donc attendre de connaitre l'allocation de l'effort � date (dependant des gross values species et otherspecies � date - 1) - pour pouvoir calculer les grossValueOtherSpecies � date + /*Calcul des gross Value Other Species en fonction de l'effort par strategie et par metier a date + Avant annee 1 (premiere annee d'appliaction de Gravite) - il faut deja faire les calculs des grossValues des autres especes + A partir de l'annee 1 : Gravite s'applique, il faut donc attendre de connaitre l'allocation de l'effort a date (dependant des gross values species et otherspecies a date - 1) + pour pouvoir calculer les grossValueOtherSpecies a date */ } @@ -124,7 +129,7 @@ }; /** - * Appel� au d�marrage de la simulation, cette m�thode permet d'initialiser + * Appele au demarrage de la simulation, cette methode permet d'initialiser * des valeurs * * @param simulation @@ -166,11 +171,11 @@ if (param_nomfichier_coeffOthers0 == null || "".equals(param_nomfichier_coeffOthers0)) { CoeffOthers0 = FileUtil.getFile(".*.csv", - "fichier 0 csv s�parateur ';'"); + "fichier 0 csv separateur ';'"); CoeffOthers1 = FileUtil.getFile(".*.csv", - "fichier 1 csv s�parateur ';'"); + "fichier 1 csv separateur ';'"); CoeffOthers2 = FileUtil.getFile(".*.csv", - "fichier 2 csv s�parateur ';'"); + "fichier 2 csv separateur ';'"); } else { CoeffOthers0 = new File(param_nomfichier_coeffOthers0); CoeffOthers1 = new File(param_nomfichier_coeffOthers1); @@ -261,7 +266,7 @@ } /** - * Si la condition est vrai alors cette action est execut�e avant le pas de + * Si la condition est vrai alors cette action est executee avant le pas de * temps de la simulation. * * @param simulation @@ -298,7 +303,7 @@ log.info("GrossValueOtherSpeciesPerStrMet initialisee " + GrossValueOtherSpeciesPerStrMet); - // si ann�e>=1 alors on fait le calcul des gravit� puis on met � jour les gross value otherspecies + // si annee>=1 alors on fait le calcul des gravite puis on met a jour les gross value otherspecies if ((date.getYear() > 0) & (param_gravite == true)) { ////////Initialisation des matrices qui resultent de la simulation//////////////////////////////////////////////////////////// log.info("calcul de Gravite"); @@ -319,7 +324,7 @@ .copy(); log.info("GrossValuePerStrMet calculee " + GrossValuePerStrMet); - //ajouter pour tous les m�tiers les valeurs li�es qux autres esp�ces calcul�es par modele lineaire + //ajouter pour tous les metiers les valeurs liees qux autres especes calculees par modele lineaire // Boucle sur les strategies de mes strategies //List <Strategy> mStr = strs; for (Strategy strIndex : strs) { @@ -331,7 +336,7 @@ .getMonth()); Collection<EffortDescription> strMet = str .getSetOfVessels().getPossibleMetiers(); - //2) calcul les valeurs non simulees du mois l ann�e pr�c�dante + //2) calcul les valeurs non simulees du mois l annee precedante for (EffortDescription effort : strMet) { Metier met = effort.getPossibleMetiers(); log.info("Boucle metier 1, metier possible: " @@ -340,10 +345,10 @@ log.info("effort str" + str.getName() + met.getName() + " : " + eff); - //GrossValueAutres par strat�gie - // Hypothese 1 = pas de distinction entre les m�tiers n'agira donc pas sur la gravit�) - // Hypothese 2 = a distinguer selon les m�tiers - agira sur la gravit� - // l'hypothese est le resultat des coef dans la matrice en entr�e si tous identiques quelque soit le metier dans la strat�gie alors H1 + //GrossValueAutres par strategie + // Hypothese 1 = pas de distinction entre les metiers n'agira donc pas sur la gravite) + // Hypothese 2 = a distinguer selon les metiers - agira sur la gravite + // l'hypothese est le resultat des coef dans la matrice en entree si tous identiques quelque soit le metier dans la strategie alors H1 // sinon H2 double valMetOther = matrixCoeffOthers.getValue(str, met, ALPHA_O) @@ -365,7 +370,7 @@ } ////////////////////////////////////////////////////////////////////////////////////////////////////////// - valuePerUnitOfEffort.map(nanFunction); //r�initialisation avant calcul pour date + valuePerUnitOfEffort.map(nanFunction); //reinitialisation avant calcul pour date for (Strategy str : strs) { log.info("INFO: Boucle creation valuePerUnitEffort : " @@ -389,9 +394,9 @@ // on teste effort pour le calcul des VPUE // si effort != 0 , valeur/effort //sinon (effort =0) , deux cas de figure : - // 1. soit propInitiale =0 pour ce m�tier et dans ce cas VPUE =0 et ca ne doit pas impacter le calcul de la gravite pour les autres metiers de str + // 1. soit propInitiale =0 pour ce metier et dans ce cas VPUE =0 et ca ne doit pas impacter le calcul de la gravite pour les autres metiers de str // 2. soit propInitiale! =0 et dans ce cas, on mettra PropInitiale pour tous les metiers de str - if (effort > 0) {// a pech� au mois, annee-1 + if (effort > 0) {// a peche au mois, annee-1 //on recupere la capture tot double value = GrossValuePerStrMet.getValue(str, strMetier); @@ -402,21 +407,21 @@ log.info("value/effort= " + vpue); somme += value / effort; } else if ((effort == 0) - & (smi.getProportionMetier(strMetier) == 0)) {// n'a jamais p�che avec ce metier + & (smi.getProportionMetier(strMetier) == 0)) {// n'a jamais peche avec ce metier valuePerUnitOfEffort.setValue(str, strMetier, 0); - log.info("n'a jamais p�che avec ce metier"); + log.info("n'a jamais peche avec ce metier"); } else {// n'a pas peche au mois, annee -1, mais avait une prop d'effort non nul a l'annee=0 - testCondition = true;// ie somme est incompl�te mais pas grave car on mettra PropInitiale � tous les metiers + testCondition = true;// ie somme est incomplete mais pas grave car on mettra PropInitiale a tous les metiers log .info("n'a pas peche au mois, annee -1, mais avait une prop d'effort non nul a l'annee=0"); } } log.info("testCondition pour str" + str.getName() + ":" + testCondition); - // � partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravit� + // a partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravite double newProp = 0; log - .info("� partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravit�"); + .info("a partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravite"); if (!testCondition) { double SommeVPUEstrat = somme; log.info("SommeVPUEstrat=" + SommeVPUEstrat); @@ -447,13 +452,13 @@ log.info("PropStrNouvelle(metier=" + strMetier.getName() + ")" + smi.getProportionMetier(strMetier)); - // annee>= 1 calcul des gross Value otherSpecies avec les nouvelles valeurs d'effort calcul�es par gravite - //avec la nouvelle proportion on en d�duit la gross Value of Species de date pour ce str-met + // annee>= 1 calcul des gross Value otherSpecies avec les nouvelles valeurs d'effort calculees par gravite + //avec la nouvelle proportion on en deduit la gross Value of Species de date pour ce str-met double valMetOtherSpecies = matrixCoeffOthers .getValue(str, strMetier, ALPHA_O) + matrixCoeffOthers.getValue(str, strMetier, BETA_O) * newProp; - //tester si valMetOtherSpecies <= alors mettre � 0 + //tester si valMetOtherSpecies <= alors mettre a 0 if (valMetOtherSpecies < 0) { valMetOtherSpecies = 0; } @@ -467,9 +472,9 @@ } } // else ie on met propInitiale dans PropStr(str,annee,mois) - // rien n'a faire car au debut de chaque pas de temps, PropStr est par d�faut initialis� � la valeur de la base de donn�es (val initiales) + // rien n'a faire car au debut de chaque pas de temps, PropStr est par defaut initialise a la valeur de la base de donnees (val initiales) }//fin de boucle sur strategy - // r�sultats grossvalue otherspecies mis dans le resultManager + // resultats grossvalue otherspecies mis dans le resultManager resultmanager .addResult( date, @@ -477,7 +482,7 @@ GrossValueOtherSpeciesPerStrMet); } else if ((date.getYear() == 0) || (param_gravite == false)) { - //si ann�e==0 alors on ne fait que le calcul des gross value other species + //si annee==0 alors on ne fait que le calcul des gross value other species for (Strategy str : strs) { log.info("INFO: Boucle creation valuePerUnitEffort : " + str.getName()); @@ -496,7 +501,7 @@ + matrixCoeffOthers.getValue(str, strMetier, BETA_O) * smi.getProportionMetier(strMetier); - //tester si valMetOtherSpecies <= alors mettre � 0 + //tester si valMetOtherSpecies <= alors mettre a 0 if (valMetOtherSpecies < 0) { valMetOtherSpecies = 0; } @@ -509,13 +514,13 @@ strMetier)); } } - // r�sultats grossvalue otherspecies mis dans le resultManager + // resultats grossvalue otherspecies mis dans le resultManager resultmanager .addResult( date, ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_OTHER_SPECIES_PER_STRATEGY_MET, GrossValueOtherSpeciesPerStrMet); - } // fin de calcul pour ann�e ==0 + } // fin de calcul pour annee ==0 first = false; }// fin de first= true @@ -527,7 +532,7 @@ } /** - * Si la condition est vrai alors cette action est execut�e apres le pas de + * Si la condition est vrai alors cette action est executee apres le pas de * temps de la simulation. * * @param simulation Modified: trunk/rules/TACpoids.java =================================================================== --- trunk/rules/TACpoids.java 2009-04-29 08:39:41 UTC (rev 127) +++ trunk/rules/TACpoids.java 2009-04-29 09:27:18 UTC (rev 128) @@ -42,13 +42,13 @@ */ /** - * TAC peut-etre utilis� pour les diff�rents TAC, en proportion des effectifs + * TAC peut-etre utilise pour les differents TAC, en proportion des effectifs * et/ou avec survie ou non. * * <li>Pour utiliser le tac proportionnel, il faut mettre dans le parametre - * propTac une valeur > 0, le TAC sera alors recalcul� a chaque mois de janvier. - * <li>Pour utiliser la survie il faut mettre dans le param�tre propSurvie une - * valeur > 0, automatiquement les suvie seront ajout� aux effectifs + * propTac une valeur > 0, le TAC sera alors recalcule a chaque mois de janvier. + * <li>Pour utiliser la survie il faut mettre dans le parametre propSurvie une + * valeur > 0, automatiquement les suvie seront ajoute aux effectifs * */ public class TACpoids extends AbstractRule { @@ -97,7 +97,7 @@ } /** - * Appel� au d�marrage de la simulation, cette m�thode permet d'initialiser + * Appele au demarrage de la simulation, cette methode permet d'initialiser * des valeurs * * @param simulation @@ -121,7 +121,7 @@ param_species = (Species) context.getDB().findByTopiaId( param_species.getTopiaId()); - // on fait le calcul du tac si n�cessaire + // on fait le calcul du tac si necessaire if (param_propTac > 0 && date.getMonth().equals(Month.JANUARY)) { PopulationMonitor popMon = context.getPopulationMonitor(); param_tacInTons = popMon.getBiomass(param_species) * param_propTac; @@ -149,7 +149,7 @@ } /** - * Si la condition est vrai alors cette action est execut�e avant le pas de + * Si la condition est vrai alors cette action est executee avant le pas de * temps de la simulation. * * @param simulation @@ -173,7 +173,7 @@ log.info("aimed Metier: " + aimedMetiers);*/ context.getMetierMonitor().addforbiddenMetier(metier); - //r�cupere toutes les strat�gies pratiquant le m�tier et pour lesquelles la proportion !=0 + //recupere toutes les strategies pratiquant le metier et pour lesquelles la proportion !=0 SiMatrix siMatrix = SiMatrix.getSiMatrix(context); Set<Strategy> strs = new HashSet<Strategy>(); for (Strategy str : siMatrix.getStrategies(date)) { @@ -208,7 +208,7 @@ &&*/!metier.getName().equalsIgnoreCase("nonActiviy") && !metier.getName().equalsIgnoreCase("nonActivie") && !metier.getName().equalsIgnoreCase( - "non Activit�") + "non Activite") && !context.getMetierMonitor().getForbiddenMetier() .contains(newMetier)) { possibleMetierCase3.add(newMetier); @@ -271,7 +271,7 @@ } /** - * Si la condition est vrai alors cette action est execut�e apres le pas de + * Si la condition est vrai alors cette action est executee apres le pas de * temps de la simulation. * * @param simulation Modified: trunk/scripts/GravityModel.java =================================================================== --- trunk/scripts/GravityModel.java 2009-04-29 08:39:41 UTC (rev 127) +++ trunk/scripts/GravityModel.java 2009-04-29 09:27:18 UTC (rev 128) @@ -139,7 +139,7 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc + * implante suivant document ModifTable3PourBP25-07-2006.doc * FishingTimePerMonthPerVessel[str,met,month] = * FishingTimePerTrip[str,met,month]NbTripsPerMonth[str,month] * @@ -191,8 +191,9 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * FuelCostsOfTravelPerVessel[sov,met,month]�=�NbTripsPerMonth[str,month]*TravelTimePerTrip[sov,met,month]*UnitFuelCostsOfTravel[vt] + * implante suivant document ModifTable3PourBP25-07-2006.doc + * FuelCostsOfTravelPerVessel[sov,met,month] = + * NbTripsPerMonth[str,month]*TravelTimePerTrip[sov,met,month]*UnitFuelCostsOfTravel[vt] * * @param str * @param metier @@ -249,7 +250,7 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc + * implante suivant document ModifTable3PourBP25-07-2006.doc * CostsOfFishingPerVessel[str,met,month]= FishingTimePerMonthPerVessel * [str,met,month] {NbFishingOperationsPerDay[sov,met] * UnitCostsOfFishing[sov,met] / 24} @@ -310,7 +311,7 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc + * implante suivant document ModifTable3PourBP25-07-2006.doc * FuelCostsPerVessel[str,met,month] = FuelCostsOfTravelPerVessel * [sov,met,month] + CostsOfFishingPerVessel [str,met,month] * @@ -362,8 +363,9 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * RepairAndMaintenanceGearCostsPerVessel[str,met,month]�=�FishingTimePerMonthPerVessel[str,met,month] + * implante suivant document ModifTable3PourBP25-07-2006.doc + * RepairAndMaintenanceGearCostsPerVessel[str,met,month] = + * FishingTimePerMonthPerVessel[str,met,month] * *RepairAndMaintenanceGearCostsPerDay[sov,met]/NbHoursPerDay * * @param str @@ -421,8 +423,9 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * OtherRunningCostsPerVessel[str,met,month]=�FishingTimePerMonthPerVessel[str,met,month]*OtherRunningCostsPerDay[sov,met]/ + * implante suivant document ModifTable3PourBP25-07-2006.doc + * OtherRunningCostsPerVessel[str,met,month] = + * FishingTimePerMonthPerVessel[str,met,month]*OtherRunningCostsPerDay[sov,met]/ * NbHoursPerDay * * @param str @@ -480,9 +483,9 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * SharedNotFixedCostsPerVessel[str,met,month]=�FuelCostsPerVessel[str,met,month] - * +�OtherRunningCostsPerVessel[str,met,month] + * implante suivant document ModifTable3PourBP25-07-2006.doc + * SharedNotFixedCostsPerVessel[str,met,month]=FuelCostsPerVessel[str,met,month] + * +OtherRunningCostsPerVessel[str,met,month] * * @param str * @param metier @@ -585,9 +588,9 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month]�=�sum - * over classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet + * implante suivant document ModifTable3PourBP25-07-2006.doc + * GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month]=sum over + * classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet * [str,met,pop,cl,month] ?DiscardsWeightPerStrategyMet [str,met,pop,cl,mo * nth] GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month] = * sum over classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet @@ -749,9 +752,9 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * GrossValueOfLandingsPerStrategyMetPerVessel[str,met,month]�= - * GrossValueOfLandingsPerStrategyMet[str,met,month]�/[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)] + * implante suivant document ModifTable3PourBP25-07-2006.doc + * GrossValueOfLandingsPerStrategyMetPerVessel[str,met,month]= + * GrossValueOfLandingsPerStrategyMet[str,met,month]/[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)] * * @param str * @param metier @@ -810,8 +813,10 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * NetValueOfLandingsPerStrategyMet[str,met,month]�=�GrossValueOfLandingsPerStrategyMet[str,met,month]�(1-LandingCostRate[str,met]�) + * implante suivant document ModifTable3PourBP25-07-2006.doc + * NetValueOfLandingsPerStrategyMet[str,met,month] = + * GrossValueOfLandingsPerStrategyMet[str,met,month] + * (1-LandingCostRate[str,met]) * * @param str * @param metier @@ -883,8 +888,10 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * NetValueOfLandingsPerStrategyMetPerVessel[str,met,month]�=�NetValueOfLandingsPerStrategyMet[str,met,month]�/[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)] + * implante suivant document ModifTable3PourBP25-07-2006.doc + * NetValueOfLandingsPerStrategyMetPerVessel[str,met,month] = + * NetValueOfLandingsPerStrategyMet[str,met,month] + * /[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)] * * @param str * @param metier @@ -942,10 +949,11 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * NetRevenueToSharePerStrategyMetPerVessel[str,met,month]�=�NetValueOfLandingsPerStrategyMetPerVessel[str,met,month]�-�SharedNotFixedCostsPerVessel - * [str,met,month]*PropStr(str,met,month) - SharedFixedCostsPerVessel - * PerMet[str,month] + * implante suivant document ModifTable3PourBP25-07-2006.doc + * NetRevenueToSharePerStrategyMetPerVessel[str,met,month] = + * NetValueOfLandingsPerStrategyMetPerVessel[str,met,month] - + * SharedNotFixedCostsPerVessel [str,met,month]*PropStr(str,met,month) - + * SharedFixedCostsPerVessel PerMet[str,month] * * @param str * @param metier @@ -1003,8 +1011,9 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * CrewSharePerStrategyMetPerVessel[str,met,month]�=�NetRevenueToSharePerStrategyMetPerVessel[str,met,month]*CrewShareRate[sov,met] + * implante suivant document ModifTable3PourBP25-07-2006.doc + * CrewSharePerStrategyMetPerVessel[str,met,month] = + * NetRevenueToSharePerStrategyMetPerVessel[str,met,month]*CrewShareRate[sov,met] * * @param str * @param metier @@ -1066,11 +1075,11 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc + * implante suivant document ModifTable3PourBP25-07-2006.doc * OwnerMarginOverVariableCostsPerStrategyMetPerVessel[str,met,month] = - * NetRevenueToSharePerStrategyMetPerVessel[str,met,month]�- - * CrewSharePerStrategyMetPerVessel[str,met,month]�- - * RepairAndMaintenanceGearCostsPerVes sel[str,met,month]�* + * NetRevenueToSharePerStrategyMetPerVessel[str,met,month] - + * CrewSharePerStrategyMetPerVessel[str,met,month] - + * RepairAndMaintenanceGearCostsPerVes sel[str,met,month] * * PropStr(str,met,month) * * @param str @@ -1130,9 +1139,10 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * VesselMarginOverVariableCostsPerStrategyMetPerVessel�[str,met,month]�=NetRevenueToSharePerStrategyMetPerVessel[str,met,month]- - * RepairAndMaintenanceGearCostsPerVessel [str,met,month]�* + * implante suivant document ModifTable3PourBP25-07-2006.doc + * VesselMarginOverVariableCostsPerStrategyMetPerVessel [str,met,month] + * =NetRevenueToSharePerStrategyMetPerVessel[str,met,month]- + * RepairAndMaintenanceGearCostsPerVessel [str,met,month] * * PropStr(str,met,month) * * @param str @@ -1183,9 +1193,9 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * OwnerMarginOverVariableCostsPerStrategyPerVessel[str,month]�=�somme sur - * tous les m�tiers de OwnerMarginOverVariableCostsPerStrategyMetPerVessel + * implante suivant document ModifTable3PourBP25-07-2006.doc + * OwnerMarginOverVariableCostsPerStrategyPerVessel[str,month] = somme sur + * tous les metiers de OwnerMarginOverVariableCostsPerStrategyMetPerVessel * [str,met,month] * * @param str @@ -1237,8 +1247,10 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * OwnerMarginOverVariableCostsPerStrategy[str,month]�=�OwnerMarginOverVariableCostsPerStrategyPerVessel[str,month]�*[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)] + * implante suivant document ModifTable3PourBP25-07-2006.doc + * OwnerMarginOverVariableCostsPerStrategy[str,month] = + * OwnerMarginOverVariableCostsPerStrategyPerVessel[str,month] + * *[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)] * * @param str * @param date @@ -1286,9 +1298,9 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * VesselMarginOverVariableCostsPerStrategyPerVessel[str,month]�= somme sur - * tous les m�tiers de VesselMarginOverVariableCostsPerStrategyMetPerVessel� + * implante suivant document ModifTable3PourBP25-07-2006.doc + * VesselMarginOverVariableCostsPerStrategyPerVessel[str,month] = somme sur + * tous les metiers de VesselMarginOverVariableCostsPerStrategyMetPerVessel * [str,met,month] * * @param str @@ -1340,8 +1352,9 @@ } /** - * implant� suivant document ModifTable3PourBP25-07-2006.doc - * VesselMarginOverVariableCostsPerStrategy[str,month]�=VesselMarginOverVariableCostsPerStrategyPerVessel�[str,month] + * implante suivant document ModifTable3PourBP25-07-2006.doc + * VesselMarginOverVariableCostsPerStrategy[str,month] + * =VesselMarginOverVariableCostsPerStrategyPerVessel [str,month] * *[PropNbVessels(str,sov)*NbVesselsSetOfVessels(sov)] * * @param str @@ -1362,7 +1375,7 @@ /////////////////////////////////////////////////////////////////////////// // - // Methode non utilis�e directement dans GravityModel, mais dans les rules + // Methode non utilisee directement dans GravityModel, mais dans les rules // /////////////////////////////////////////////////////////////////////////// Modified: trunk/scripts/ResultName.java =================================================================== --- trunk/scripts/ResultName.java 2009-04-29 08:39:41 UTC (rev 127) +++ trunk/scripts/ResultName.java 2009-04-29 09:27:18 UTC (rev 128) @@ -1,6 +1,6 @@ /* *##% * Copyright (C) 2006 - * Code Lutin, C�dric Pineau, Benjamin Poussin + * Code Lutin, Cedric Pineau, Benjamin Poussin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,7 +20,7 @@ /* * * ResultName.java * - * Created: 23 ao�t 2006 15:09:37 + * Created: 23 aout 2006 15:09:37 * * @author poussin * @version $Revision: 1.10 $ @@ -37,16 +37,16 @@ /** * Contient l'ensemble des noms des differents resultats. Le mieux lorsque l'on - * veut un nouveau r�sultat est d'ajouter une constante ici, et de l'utiliser - * ensuite lors de la cr�ation de la matrice. + * veut un nouveau resultat est d'ajouter une constante ici, et de l'utiliser + * ensuite lors de la creation de la matrice. * <p> - * Ceci permet d'avoir un endroit unique ou l'on voit l'ensemble des r�sultats - * potentiellement disponible et de ne pas ce tromper en �crivent le nom - * d'un r�sultat + * Ceci permet d'avoir un endroit unique ou l'on voit l'ensemble des resultats + * potentiellement disponible et de ne pas ce tromper en ecrivent le nom + * d'un resultat * <p> * Cette classe ne doit contenir que des noms de resultat en static public String * l'interface de lancement de simulation se base sur cette classe pour - * afficher l'ensemble des r�sultats disponible + * afficher l'ensemble des resultats disponible * * @author poussin */ Modified: trunk/scripts/SiMatrix.java =================================================================== --- trunk/scripts/SiMatrix.java 2009-04-29 08:39:41 UTC (rev 127) +++ trunk/scripts/SiMatrix.java 2009-04-29 09:27:18 UTC (rev 128) @@ -20,7 +20,7 @@ /* * * SiMatrix.java * - * Created: 21 ao�t 2006 15:53:01 + * Created: 21 aout 2006 15:53:01 * * @author poussin * @version $Revision: 1.18 $ @@ -31,14 +31,13 @@ package scripts; -import static org.codelutin.i18n.I18n._; import static org.codelutin.i18n.I18n.n_; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; -import java.util.Iterator; import java.util.List; +import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -67,56 +66,59 @@ import fr.ifremer.isisfish.simulator.SimulationContext; import fr.ifremer.isisfish.types.Date; import fr.ifremer.isisfish.types.Month; -import java.util.Arrays; -import java.util.Set; /** * @author poussin - * + * */ public class SiMatrix { /** to use log facility, just put in your code: log.info("..."); */ static private Log log = LogFactory.getLog(SiMatrix.class); - + protected SimulationContext context = null; protected TopiaContext db = null; - + /** * Method used to get SiMatrix used for simulation - * @param context context simulation + * + * @param context + * context simulation * @return SiMatrix or null if no SiMatrix created for simulation */ - public static SiMatrix getSiMatrix(SimulationContext context) throws TopiaException { - SiMatrix result = (SiMatrix)context.getValue(SiMatrix.class.getName()); + public static SiMatrix getSiMatrix(SimulationContext context) + throws TopiaException { + SiMatrix result = (SiMatrix) context.getValue(SiMatrix.class.getName()); if (result == null) { result = new SiMatrix(context); } return result; } - + private static void setSiMatrix(SimulationContext context, SiMatrix siMatrix) { context.setValue(SiMatrix.class.getName(), siMatrix); } - + /** * - * @param context Simulation context - * @param db TopiaContext with transaction opened. You must used this - * TopiaContext and not used - * SimulationContext.getSimulationStorage().getStorage() - * @throws TopiaException + * @param context + * Simulation context + * @param db + * TopiaContext with transaction opened. You must used this + * TopiaContext and not used + * SimulationContext.getSimulationStorage().getStorage() + * @throws TopiaException */ public SiMatrix(SimulationContext context) throws TopiaException { this.context = context; this.db = context.getDB(); setSiMatrix(context, this); } - + /** * @return - * @throws TopiaException + * @throws TopiaException */ public List<Zone> getZones(Date date) throws TopiaException { ZoneDAO dao = IsisFishDAOHelper.getZoneDAO(db); @@ -126,12 +128,13 @@ /** * @return - * @throws TopiaException + * @throws TopiaException */ public List<Population> getPopulations(Date date) throws TopiaException { List<Population> populations = new ArrayList<Population>(); - for (Population pop : context.getSimulationStorage().getParameter().getPopulations()) { - Population tmp = (Population)db.findByTopiaId(pop.getTopiaId()); + for (Population pop : context.getSimulationStorage().getParameter() + .getPopulations()) { + Population tmp = (Population) db.findByTopiaId(pop.getTopiaId()); populations.add(tmp); } return populations; @@ -139,39 +142,40 @@ /** * @return - * @throws TopiaException + * @throws TopiaException */ public List<Strategy> getStrategies(Date date) throws TopiaException { -// if (strategies == null) { + // if (strategies == null) { List<Strategy> strategies = new ArrayList<Strategy>(); - for (Strategy str : context.getSimulationStorage().getParameter().getStrategies()) { - Strategy tmp = (Strategy)db.findByTopiaId(str.getTopiaId()); - strategies.add(tmp); - } -// } + for (Strategy str : context.getSimulationStorage().getParameter() + .getStrategies()) { + Strategy tmp = (Strategy) db.findByTopiaId(str.getTopiaId()); + strategies.add(tmp); + } + // } return strategies; } public List<Metier> getMetiers(Date date) throws TopiaException { -// if (metiers == null) { - List<Metier> metiers = new ArrayList<Metier>(); - HashSet<Metier> tmp = new HashSet<Metier>(); - for (Strategy str : getStrategies(date)) { - SetOfVessels sov = str.getSetOfVessels(); - for (EffortDescription effort : sov.getPossibleMetiers()) { - Metier metier = effort.getPossibleMetiers(); - if (tmp.add(metier)) { - metiers.add(metier); - } + // if (metiers == null) { + List<Metier> metiers = new ArrayList<Metier>(); + HashSet<Metier> tmp = new HashSet<Metier>(); + for (Strategy str : getStrategies(date)) { + SetOfVessels sov = str.getSetOfVessels(); + for (EffortDescription effort : sov.getPossibleMetiers()) { + Metier metier = effort.getPossibleMetiers(); + if (tmp.add(metier)) { + metiers.add(metier); } } -// } + } + // } return metiers; } /** - * Retourne les metiers pratiqu�s par une Strategie � une date donn�e - * Un metier est pratiqu� si le PropStrMet est diff�rent de 0 + * Retourne les metiers pratiques par une Strategie a une date donnee Un + * metier est pratique si le PropStrMet est different de 0 * * @param str * @param date @@ -180,13 +184,13 @@ public List<Metier> getMetiers(Strategy str, Date date) { StrategyMonthInfo info = str.getStrategyMonthInfo(date.getMonth()); MatrixND props = info.getProportionMetier(); - + List<Metier> result = new ArrayList<Metier>(); - - for (MatrixIterator i=props.iterator(); i.hasNext();) { + + for (MatrixIterator i = props.iterator(); i.hasNext();) { i.next(); if (i.getValue() != 0) { - Metier metier = (Metier)i.getSemanticsCoordinates()[0]; + Metier metier = (Metier) i.getSemanticsCoordinates()[0]; result.add(metier); } } @@ -194,26 +198,26 @@ } /** - * Retourne la matrix Metier x Zone qui correspond au zone utilis� par - * un m�tier pour une date donn�e. Si la valeur de la matrice est 1 alors - * la zone est utilis� par le m�tier, si elle vaut 0 alors elle n'est pas - * utilis�e. + * Retourne la matrix Metier x Zone qui correspond au zone utilise par un + * metier pour une date donnee. Si la valeur de la matrice est 1 alors la + * zone est utilise par le metier, si elle vaut 0 alors elle n'est pas + * utilisee. * * @param date * @return - * @throws TopiaException + * @throws TopiaException */ public MatrixND getMetierZone(Date date) throws TopiaException { List<Metier> metiers = getMetiers(date); List<Zone> zones = getZones(date); - + MatrixND result = MatrixFactory.getInstance().create( - ResultName.MATRIX_METIER_ZONE, - new List[]{metiers, zones}, - new String[]{n_("Metiers"), n_("Zones")}); + ResultName.MATRIX_METIER_ZONE, new List[] { metiers, zones }, + new String[] { n_("Metiers"), n_("Zones") }); for (Metier metier : metiers) { - Collection<Zone> zoneMetier = metier.getMetierSeasonInfo(date.getMonth()).getZone(); + Collection<Zone> zoneMetier = metier.getMetierSeasonInfo( + date.getMonth()).getZone(); for (Zone zone : zoneMetier) { result.setValue(metier, zone, 1); } @@ -224,25 +228,26 @@ public MatrixND matrixPrice(Date date, Population pop) { List<PopulationGroup> groups = pop.getPopulationGroup(); MatrixND result = MatrixFactory.getInstance().create( - ResultName.MATRIX_PRICE, - new List[]{groups}, - new String[]{n_("PopulationGroup")}); - + ResultName.MATRIX_PRICE, new List[] { groups }, + new String[] { n_("PopulationGroup") }); + for (PopulationGroup group : groups) { result.setValue(group, group.getPrice()); } - + return result; } - - /////////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////////// // // Toutes les methodes suivantes ne sont utiles que pour // matrixCatchPerStrategyMet // /////////////////////////////////////////////////////////////////////////// - - public MatrixND matrixCatchWeightPerStrategyMetPerZoneMet(Date date, Population pop, MatrixND matrixCatchPerStrategyMetPerZoneMet) throws TopiaException, IsisFishException { + + public MatrixND matrixCatchWeightPerStrategyMetPerZoneMet(Date date, + Population pop, MatrixND matrixCatchPerStrategyMetPerZoneMet) + throws TopiaException, IsisFishException { List<PopulationGroup> groups = pop.getPopulationGroup(); MatrixND result = matrixCatchPerStrategyMetPerZoneMet.copy(); @@ -257,35 +262,43 @@ return result; } - public MatrixND matrixCatchPerStrategyMetPerZoneMet(MatrixND N, Population pop, Date date) throws TopiaException, IsisFishException { - - MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell(date, pop); - MatrixND matrixCatchRatePerStrategyMetPerCell = matrixCatchRatePerStrategyMetPerCell(pop, date, matrixFishingMortalityPerCell); - MatrixND matrixCatchPerStrategyMetPerCell = matrixCatchPerStrategyMetPerCell(N, pop, date, matrixCatchRatePerStrategyMetPerCell); - + public MatrixND matrixCatchPerStrategyMetPerZoneMet(MatrixND N, + Population pop, Date date) throws TopiaException, IsisFishException { + + MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell( + date, pop); + MatrixND matrixCatchRatePerStrategyMetPerCell = matrixCatchRatePerStrategyMetPerCell( + pop, date, matrixFishingMortalityPerCell); + MatrixND matrixCatchPerStrategyMetPerCell = matrixCatchPerStrategyMetPerCell( + N, pop, date, matrixCatchRatePerStrategyMetPerCell); + List<Strategy> strategies = getStrategies(date); List<Metier> metiers = getMetiers(date); - List<PopulationGroup> groups = matrixCatchPerStrategyMetPerCell.getSemantics(2); + List<PopulationGroup> groups = matrixCatchPerStrategyMetPerCell + .getSemantics(2); List<Zone> zones = getZones(date); - Set<Cell> cellPops = new HashSet(matrixCatchPerStrategyMetPerCell.getSemantics(4)); - + Set<Cell> cellPops = new HashSet(matrixCatchPerStrategyMetPerCell + .getSemantics(4)); + MatrixND result = MatrixFactory.getInstance().create( ResultName.MATRIX_CATCH_PER_STRATEGY_MET, - new List[]{strategies, metiers, groups, zones}, - new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")}); - + new List[] { strategies, metiers, groups, zones }, + new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"), + n_("Zones") }); + // matrice temporaire ou les zones pops sont sommees MatrixND tmp = matrixCatchPerStrategyMetPerCell.sumOverDim(3); tmp = tmp.reduceDims(3); - + for (int s = 0; s < strategies.size(); s++) { Strategy str = strategies.get(s); - for(int g = 0; g<groups.size(); g++) { + for (int g = 0; g < groups.size(); g++) { PopulationGroup group = groups.get(g); for (int m = 0; m < metiers.size(); m++) { Metier metier = metiers.get(m); - MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(date.getMonth()); + MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(date + .getMonth()); Collection<Zone> zoneMet = infoMet.getZone(); for (Zone z : zoneMet) { double value = 0; @@ -304,15 +317,19 @@ } } } - + return result; } - - public MatrixND matrixCatchPerStrategyMetPerZonePop(MatrixND N, Population pop, Date date) throws TopiaException, IsisFishException { - MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell(date, pop); - MatrixND matrixCatchRatePerStrategyMetPerCell = matrixCatchRatePerStrategyMetPerCell(pop, date, matrixFishingMortalityPerCell); - MatrixND matrixCatchPerStrategyMetPerCell = matrixCatchPerStrategyMetPerCell(N, pop, date, matrixCatchRatePerStrategyMetPerCell); - + + public MatrixND matrixCatchPerStrategyMetPerZonePop(MatrixND N, + Population pop, Date date) throws TopiaException, IsisFishException { + MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell( + date, pop); + MatrixND matrixCatchRatePerStrategyMetPerCell = matrixCatchRatePerStrategyMetPerCell( + pop, date, matrixFishingMortalityPerCell); + MatrixND matrixCatchPerStrategyMetPerCell = matrixCatchPerStrategyMetPerCell( + N, pop, date, matrixCatchRatePerStrategyMetPerCell); + // on somme sur les cellules MatrixND result = matrixCatchPerStrategyMetPerCell.sumOverDim(4); result = result.reduceDims(4); @@ -320,9 +337,10 @@ return result; } - + public MatrixND matrixCatchWeightPerStrategyMetPerZonePop(Date date, - Population pop, MatrixND matrixCatchPerStrategyMetPerZonePop) throws TopiaException, IsisFishException { + Population pop, MatrixND matrixCatchPerStrategyMetPerZonePop) + throws TopiaException, IsisFishException { List<PopulationGroup> groups = pop.getPopulationGroup(); MatrixND result = matrixCatchPerStrategyMetPerZonePop.copy(); @@ -337,33 +355,33 @@ return result; } - /** * Utilise pour le calcul en Zone - * - * Matrice des captures en nombre - * dim [ Strategy x Metier x Classe x zonePop ] - * - * @param N l'abondance sous forme de matrice 2D [class x zone] + * + * Matrice des captures en nombre dim [ Strategy x Metier x Classe x zonePop ] + * + * @param N + * l'abondance sous forme de matrice 2D [class x zone] * @param pop * @param date * @return * @throws TopiaException * @throws IsisFishException */ - public MatrixND matrixCatchPerStrategyMetPerZone(MatrixND N, Population pop, - Date date, MatrixND matrixCatchRatePerStrategyMet) throws TopiaException, IsisFishException { + public MatrixND matrixCatchPerStrategyMetPerZone(MatrixND N, + Population pop, Date date, MatrixND matrixCatchRatePerStrategyMet) + throws TopiaException, IsisFishException { List<PopulationGroup> groups = pop.getPopulationGroup(); List<Zone> zones = pop.getPopulationZone(); // on le passe en argument ce qui evite de le calculer 2 fois -// MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, date); + // MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, date); MatrixND result = matrixCatchRatePerStrategyMet.copy(); result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET); - for(PopulationGroup group : groups) { + for (PopulationGroup group : groups) { MatrixND sub = result.getSubMatrix(2, group, 1); - for(Zone zone : zones){ + for (Zone zone : zones) { MatrixND subsub = sub.getSubMatrix(3, zone, 1); double val = N.getValue(group, zone); subsub.mults(val); @@ -373,17 +391,18 @@ } /** - * Utilise pour le calcul en Zone - * Matrice des captures en poids - * dim [ Strategy x Metier x Classe x zonePop ] - * + * Utilise pour le calcul en Zone Matrice des captures en poids dim [ + * Strategy x Metier x Classe x zonePop ] + * * @param pop * @param date * @return * @throws TopiaException * @throws IsisFishException */ - public MatrixND matrixCatchRatePerStrategyMetPerZone(Population pop, Date date, MatrixND matrixFishingMortality) throws TopiaException, IsisFishException { + public MatrixND matrixCatchRatePerStrategyMetPerZone(Population pop, + Date date, MatrixND matrixFishingMortality) throws TopiaException, + IsisFishException { List<Strategy> strategies = getStrategies(date); List<Metier> metiers = getMetiers(date); List<PopulationGroup> groups = pop.getPopulationGroup(); @@ -391,52 +410,53 @@ MatrixND result = MatrixFactory.getInstance().create( ResultName.MATRIX_CATCH_RATE_PER_STRATEGY_MET, - new List[]{strategies, metiers, groups, zones}, - new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")}); + new List[] { strategies, metiers, groups, zones }, + new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"), + n_("Zones") }); - // Optimisation Hilaire - for (int s=0; s < strategies.size(); s++) { - Strategy str = strategies.get(s); - metiers = getMetiers(str, date); - for (int m=0; m < metiers.size(); m++) { - Metier metier = metiers.get(m); - for (int z=0; z < zones.size(); z++) { - Zone zone = zones.get(z); - double effort = effortPerZonePop(str,metier,date,zone); - if (effort > 0){ - for (int g=0; g < groups.size(); g++) { - PopulationGroup group = groups.get(g); - double value = catchRatePerStrategyMet(str, metier, date, group, zone, matrixFishingMortality); - result.setValue(str, metier, group, zone, value); - } + // Optimisation Hilaire + for (int s = 0; s < strategies.size(); s++) { + Strategy str = strategies.get(s); + metiers = getMetiers(str, date); + for (int m = 0; m < metiers.size(); m++) { + Metier metier = metiers.get(m); + for (int z = 0; z < zones.size(); z++) { + Zone zone = zones.get(z); + double effort = effortPerZonePop(str, metier, date, zone); + if (effort > 0) { + for (int g = 0; g < groups.size(); g++) { + PopulationGroup group = groups.get(g); + double value = catchRatePerStrategyMet(str, metier, + date, group, zone, matrixFishingMortality); + result.setValue(str, metier, group, zone, value); } } } } + } return result; } - /** + /** * @param str * @param metier * @param date * @param zone * @return */ - private double effortPerZonePop(Strategy str, Metier metier, Date date, Zone zonePop) { + private double effortPerZonePop(Strategy str, Metier metier, Date date, + Zone zonePop) { Month month = date.getMonth(); Collection<Zone> zoneMet = metier.getMetierSeasonInfo(month).getZone(); double inter = nbCellInter(zoneMet, zonePop); - double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier, date); + double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier, + date); - if(log.isDebugEnabled()) { - log.debug( - " strategy=" + str + - " metier=" + metier + - " inter=" + inter + - " effortPerStrategyPerCell=" + effortPerStrategyPerCell - ); + if (log.isDebugEnabled()) { + log.debug(" strategy=" + str + " metier=" + metier + " inter=" + + inter + " effortPerStrategyPerCell=" + + effortPerStrategyPerCell); } double result = effortPerStrategyPerCell * inter; @@ -444,29 +464,37 @@ } // Optimisation Hilaire - private double catchRatePerStrategyMet(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone, MatrixND matrixFishingMortality) throws TopiaException, IsisFishException { - double totalFishingMortality = totalFishingMortality(date, matrixFishingMortality).getValue(group, zone); + private double catchRatePerStrategyMet(Strategy str, Metier metier, + Date date, PopulationGroup group, Zone zone, + MatrixND matrixFishingMortality) throws TopiaException, + IsisFishException { + double totalFishingMortality = totalFishingMortality(date, + matrixFishingMortality).getValue(group, zone); - if(totalFishingMortality == 0){ - if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + group + ", " + zone +")");} + if (totalFishingMortality == 0) { + if (log.isDebugEnabled()) { + log.debug("pas de totalFishingMortality pour (" + group + ", " + + zone + ")"); + } return 0; } - double fishingMortality = matrixFishingMortality.getValue(str, metier, group, zone); - double totalCatchRate = totalCatchRate(date, group, zone, totalFishingMortality); + double fishingMortality = matrixFishingMortality.getValue(str, metier, + group, zone); + double totalCatchRate = totalCatchRate(date, group, zone, + totalFishingMortality); - if(log.isDebugEnabled()) { - log.debug( - " totalFishingMortality=" + totalFishingMortality + - " fishingMortality=" + fishingMortality + - " totalCatchRate=" + totalCatchRate); + if (log.isDebugEnabled()) { + log.debug(" totalFishingMortality=" + totalFishingMortality + + " fishingMortality=" + fishingMortality + + " totalCatchRate=" + totalCatchRate); } - double result = fishingMortality / totalFishingMortality * totalCatchRate; + double result = fishingMortality / totalFishingMortality + * totalCatchRate; return result; } - /** * @param date * @param group @@ -475,35 +503,37 @@ * @return * @throws TopiaException */ - private double totalCatchRate(Date date, PopulationGroup group, - Zone zone, double totalFishingMortality) throws TopiaException { + private double totalCatchRate(Date date, PopulationGroup group, Zone zone, + double totalFishingMortality) throws TopiaException { double M = group.getNaturalDeathRate(zone) / Month.NUMBER_OF_MONTH; - if(M == 0){ + if (M == 0) { // normalement il devrait y avoir de la mortalite naturelle if (log.isWarnEnabled()) { - log.warn("Pas de mortalit� naturelle pour: " + group); + log.warn("Pas de mortalite naturelle pour: " + group); } } double F = totalFishingMortality; double result = 0; - if( M != 0 || F != 0){ - result = F/(F+M) * (1 - Math.exp(-(F+M))); + if (M != 0 || F != 0) { + result = F / (F + M) * (1 - Math.exp(-(F + M))); } return result; } /** - * Returne une matrice de mortalite group x zone, donc somme sur str et metier - * + * Returne une matrice de mortalite group x zone, donc somme sur str et + * metier + * * @param date * @param matrixFishingMortality * @param group * @param zone * @return */ - private MatrixND totalFishingMortality(Date date, MatrixND matrixFishingMortality) { + private MatrixND totalFishingMortality(Date date, + MatrixND matrixFishingMortality) { MatrixND result = matrixFishingMortality.sumOverDim(0); result = result.sumOverDim(1); result = result.reduceDims(0, 1); @@ -511,16 +541,16 @@ } /** - * Matrice fishing mortality - * dim [ Strategy x Metier x Classe x zonePop ] - * + * Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop ] + * * @param pop * @param date * @return * @throws TopiaException * @throws IsisFishException */ - public MatrixND matrixFishingMortality(Date date, Population pop) throws TopiaException, IsisFishException { + public MatrixND matrixFishingMortality(Date date, Population pop) + throws TopiaException, IsisFishException { List<Strategy> strategies = getStrategies(date); List<Metier> metiers = getMetiers(date); List<PopulationGroup> groups = pop.getPopulationGroup(); @@ -529,8 +559,9 @@ // default value in matrix is 0 MatrixND result = MatrixFactory.getInstance().create( ResultName.MATRIX_FISHING_MORTALITY, - new List[]{strategies, metiers, groups, zones}, - new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")}); + new List[] { strategies, metiers, groups, zones }, + new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"), + n_("Zones") }); Month month = date.getMonth(); PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month); @@ -545,28 +576,35 @@ for (int m = 0; m < metiers.size(); m++) { Metier metier = metiers.get(m); - MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month); + MetierSeasonInfo infoMet = metier + .getMetierSeasonInfo(month); // getTargetFactor seem to be simple double ciblage = infoMet.getTargetFactor(group); if (ciblage != 0) { // check 0, this prevent next call, for default value Gear gear = metier.getGear(); - Selectivity selectivity = gear.getPopulationSelectivity(pop); + Selectivity selectivity = gear + .getPopulationSelectivity(pop); if (selectivity != null) { // getCoefficient is equation evaluation - double coeff = selectivity.getCoefficient(pop, group, metier); + double coeff = selectivity.getCoefficient(pop, + group, metier); if (coeff != 0) { // check 0, this prevent next call, for default value for (int s = 0; s < strategies.size(); s++) { Strategy str = strategies.get(s); for (int z = 0; z < zones.size(); z++) { Zone zone = zones.get(z); - double effort = effortPerZonePop(str, metier, date, zone); + double effort = effortPerZonePop(str, + metier, date, zone); if (effort > 0) { // put value only if <> 0 - double value = coeff * capturability * ciblage * effort; - result.setValue(str, metier, group, zone, value); + double value = coeff + * capturability * ciblage + * effort; + result.setValue(str, metier, group, + zone, value); } } } @@ -580,31 +618,33 @@ } /** - * Matrice des captures en nombre - * dim [ Strategy x Metier x Classe x zonePop ] + * Matrice des captures en nombre dim [ Strategy x Metier x Classe x zonePop ] * - * @param N l'abondance sous forme de matrice 2D [class x zone] + * @param N + * l'abondance sous forme de matrice 2D [class x zone] * @param pop * @param date * @return - * @throws TopiaException - * @throws IsisFishException + * @throws TopiaException + * @throws IsisFishException */ - private MatrixND matrixCatchPerStrategyMetPerCell(MatrixND N, Population pop, - Date date, MatrixND matrixCatchRatePerStrategyMetPerCell) throws TopiaException, IsisFishException { + private MatrixND matrixCatchPerStrategyMetPerCell(MatrixND N, + Population pop, Date date, + MatrixND matrixCatchRatePerStrategyMetPerCell) + throws TopiaException, IsisFishException { List<PopulationGroup> groups = pop.getPopulationGroup(); List<Zone> zones = pop.getPopulationZone(); // on le passe en argument ce qui evite de le calculer 2 fois -// MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, date); + // MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, date); MatrixND result = matrixCatchRatePerStrategyMetPerCell.copy(); result.setName("matrixCatchPerStrategyMetPerCell"); - for(PopulationGroup group : groups) { + for (PopulationGroup group : groups) { MatrixND sub = result.getSubMatrix(2, group, 1); - for(Zone zone : zones){ + for (Zone zone : zones) { MatrixND subsub = sub.getSubMatrix(3, zone, 1); - double val = N.getValue(group, zone) / (double)zone.sizeCell(); + double val = N.getValue(group, zone) / (double) zone.sizeCell(); subsub.mults(val); } } @@ -612,16 +652,17 @@ } /** - * Matrice des captures en poids - * dim [ Strategy x Metier x Classe x zonePop ] + * Matrice des captures en poids dim [ Strategy x Metier x Classe x zonePop ] * * @param pop * @param date * @return - * @throws TopiaException - * @throws IsisFishException + * @throws TopiaException + * @throws IsisFishException */ - private MatrixND matrixCatchRatePerStrategyMetPerCell(Population pop, Date date, MatrixND matrixFishingMortalityPerCell) throws TopiaException, IsisFishException { + private MatrixND matrixCatchRatePerStrategyMetPerCell(Population pop, + Date date, MatrixND matrixFishingMortalityPerCell) + throws TopiaException, IsisFishException { List<Strategy> strategies = getStrategies(date); List<Metier> metiers = getMetiers(date); List<PopulationGroup> groups = pop.getPopulationGroup(); @@ -630,33 +671,36 @@ MatrixND result = MatrixFactory.getInstance().create( "matrixCatchRatePerStrategyMetPerCell", - new List[]{strategies, metiers, groups, zones, cells}, - new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones"), n_("Cells")}); - -// for (int s=0; s < strategies.size(); s++) { -// Strategy str = strategies.get(s); -// metiers = getMetiers(str, date); -// for (int m=0; m < metiers.size(); m++) { -// Metier metier = metiers.get(m); -// for (int g=0; g < groups.size(); g++) { -// PopulationGroup group = groups.get(g); -// for (int z=0; z < zones.size(); z++) { -// Zone zone = zones.get(z); -// double value = catchRatePerStrategyMet(str, metier, date, group, zone); -// result.setValue(str, metier, group, zone, value); -// } -// } -// } -// } - -// if(totalFishingMortality == 0){ -// if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + pop + ")");} -// } else { - // Optimisation Hilaire - - MatrixND matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCell.sumOverDim(2); - matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCellSumOverGroup.reduceDims(2); - + new List[] { strategies, metiers, groups, zones, cells }, + new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"), + n_("Zones"), n_("Cells") }); + + // for (int s=0; s < strategies.size(); s++) { + // Strategy str = strategies.get(s); + // metiers = getMetiers(str, date); + // for (int m=0; m < metiers.size(); m++) { + // Metier metier = metiers.get(m); + // for (int g=0; g < groups.size(); g++) { + // PopulationGroup group = groups.get(g); + // for (int z=0; z < zones.size(); z++) { + // Zone zone = zones.get(z); + // double value = catchRatePerStrategyMet(str, metier, date, group, zone); + // result.setValue(str, metier, group, zone, value); + // } + // } + // } + // } + + // if(totalFishingMortality == 0){ + // if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + pop + ")");} + // } else { + // Optimisation Hilaire + + MatrixND matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCell + .sumOverDim(2); + matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCellSumOverGroup + .reduceDims(2); + for (int s = 0; s < strategies.size(); s++) { Strategy str = strategies.get(s); metiers = getMetiers(str, date); @@ -667,35 +711,35 @@ List<Cell> cellZones = zone.getCell(); for (int c = 0; c < cellZones.size(); c++) { Cell cell = cellZones.get(c); - double effort = matrixFishingMortalityPerCellSumOverGroup.getValue( - str, metier, zone, cell); + double effort = matrixFishingMortalityPerCellSumOverGroup + .getValue(str, metier, zone, cell); if (effort > 0) { for (int g = 0; g < groups.size(); g++) { PopulationGroup group = groups.get(g); double value = catchRatePerStrategyMetPerCell( str, metier, date, group, zone, cell, matrixFishingMortalityPerCell); - result.setValue(new Object[]{str, metier, group, - zone, cell}, value); + result.setValue(new Object[] { str, metier, + group, zone, cell }, value); } } } } } } -// } + // } -// for (Strategy str : strategies) { -// List<Metier> metierStr = getMetiers(str, date); -// for (Metier metier : metierStr) { -// for (PopulationGroup group : groups) { -// for (Zone zone : zones) { -// double val = catchRatePerStrategyMet(str, metier, date, group, zone); -// result.setValue(str, metier, group, zone, val); -// } -// } -// } -// } + // for (Strategy str : strategies) { + // List<Metier> metierStr = getMetiers(str, date); + // for (Metier metier : metierStr) { + // for (PopulationGroup group : groups) { + // for (Zone zone : zones) { + // double val = catchRatePerStrategyMet(str, metier, date, group, zone); + // result.setValue(str, metier, group, zone, val); + // } + // } + // } + // } return result; } @@ -706,91 +750,94 @@ * @param group * @param zone * @return - * @throws TopiaException - * @throws IsisFishException + * @throws TopiaException + * @throws IsisFishException */ -// private double catchRatePerStrategyMet(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException { -// double totalFishingMortality = totalFishingMortality(date, group, zone); -// -// if(totalFishingMortality == 0){ -// if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + group + ", " + zone +")");} -// return 0; -// } -// -// double fishingMortality = fishingMortality(str, metier, date, group, zone); -// double totalCatchRate = totalCatchRate(date, group, zone, totalFishingMortality); -// -// if(log.isDebugEnabled()) { -// log.debug( -// " totalFishingMortality=" + totalFishingMortality + -// " fishingMortality=" + fishingMortality + -// " totalCatchRate=" + totalCatchRate); -// } -// double result = fishingMortality / totalFishingMortality * totalCatchRate; -// -// return result; -// } - + // private double catchRatePerStrategyMet(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException { + // double totalFishingMortality = totalFishingMortality(date, group, zone); + // + // if(totalFishingMortality == 0){ + // if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + group + ", " + zone +")");} + // return 0; + // } + // + // double fishingMortality = fishingMortality(str, metier, date, group, zone); + // double totalCatchRate = totalCatchRate(date, group, zone, totalFishingMortality); + // + // if(log.isDebugEnabled()) { + // log.debug( + // " totalFishingMortality=" + totalFishingMortality + + // " fishingMortality=" + fishingMortality + + // " totalCatchRate=" + totalCatchRate); + // } + // double result = fishingMortality / totalFishingMortality * totalCatchRate; + // + // return result; + // } // Optimisation Hilaire private double catchRatePerStrategyMetPerCell(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone, Cell cell, - MatrixND matrixFishingMortalityPerCell) throws TopiaException, IsisFishException { + MatrixND matrixFishingMortalityPerCell) throws TopiaException, + IsisFishException { double totalFishingMortality = totalFishingMortalityPerCell(date, matrixFishingMortalityPerCell).getValue(group, zone); - if(totalFishingMortality == 0){ - if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + group + ", " + zone +")");} + if (totalFishingMortality == 0) { + if (log.isDebugEnabled()) { + log.debug("pas de totalFishingMortality pour (" + group + ", " + + zone + ")"); + } return 0; } - double fishingMortalityPerCell = matrixFishingMortalityPerCell.getValue( - new Object[]{str, metier, group, zone, cell}); - double totalCatchRatePerCell = - totalCatchRatePerCell(date, group, zone, totalFishingMortality); + double fishingMortalityPerCell = matrixFishingMortalityPerCell + .getValue(new Object[] { str, metier, group, zone, cell }); + double totalCatchRatePerCell = totalCatchRatePerCell(date, group, zone, + totalFishingMortality); - if(log.isDebugEnabled()) { - log.debug( - " totalFishingMortality=" + totalFishingMortality + - " fishingMortality=" + fishingMortalityPerCell + - " totalCatchRate=" + totalCatchRatePerCell); + if (log.isDebugEnabled()) { + log.debug(" totalFishingMortality=" + totalFishingMortality + + " fishingMortality=" + fishingMortalityPerCell + + " totalCatchRate=" + totalCatchRatePerCell); } - double result = - fishingMortalityPerCell / totalFishingMortality * totalCatchRatePerCell; + double result = fishingMortalityPerCell / totalFishingMortality + * totalCatchRatePerCell; return result; } - /** * @param date * @param group * @param zone * @param totalFishingMortality * @return - * @throws TopiaException + * @throws TopiaException */ private double totalCatchRatePerCell(Date date, PopulationGroup group, - Zone zone, double totalFishingMortalityPerCell) throws TopiaException { + Zone zone, double totalFishingMortalityPerCell) + throws TopiaException { double M = group.getNaturalDeathRate(zone) / Month.NUMBER_OF_MONTH; - if(M == 0){ + if (M == 0) { // normalement il devrait y avoir de la mortalite naturelle if (log.isWarnEnabled()) { - log.warn("Pas de mortalit� naturelle pour: " + group); + log.warn("Pas de mortalite naturelle pour: " + group); } } double F = totalFishingMortalityPerCell; double result = 0; - if( M != 0 || F != 0){ - result = F/(F+M) * (1 - Math.exp(-(F+M))); + if (M != 0 || F != 0) { + result = F / (F + M) * (1 - Math.exp(-(F + M))); } return result; } /** - * Returne une matrice de mortalite group x zone, donc somme sur str et metier + * Returne une matrice de mortalite group x zone, donc somme sur str et + * metier * * @param date * @param matrixFishingMortality @@ -798,26 +845,27 @@ * @param zone * @return */ - private MatrixND totalFishingMortalityPerCell(Date date, MatrixND matrixFishingMortalityPerCell) { + private MatrixND totalFishingMortalityPerCell(Date date, + MatrixND matrixFishingMortalityPerCell) { MatrixND result = matrixFishingMortalityPerCell.sumOverDim(0); result = result.sumOverDim(1); result = result.reduceDims(0, 1); return result; } - // Nouvelle implantation suite a demande Steph et Sigrid: 20080208 (NouvellesEquationsfev2008ParCelluleAvecAlgo.odt) /** - * Matrice fishing mortality - * dim [ Strategy x Metier x Classe x zonePop x cellPop] + * Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop x + * cellPop] * * @param pop * @param date * @return - * @throws TopiaException - * @throws IsisFishException + * @throws TopiaException + * @throws IsisFishException */ - public MatrixND matrixFishingMortalityPerCell(Date date, Population pop) throws TopiaException, IsisFishException { + public MatrixND matrixFishingMortalityPerCell(Date date, Population pop) + throws TopiaException, IsisFishException { List<Strategy> strategies = getStrategies(date); List<Metier> metiers = getMetiers(date); List<PopulationGroup> groups = pop.getPopulationGroup(); @@ -827,8 +875,9 @@ // default value in matrix is 0 MatrixND result = MatrixFactory.getInstance().create( "matrixFishingMortalityPerCell", - new List[]{strategies, metiers, groups, zones, cells}, - new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones"), n_("Cells")}); + new List[] { strategies, metiers, groups, zones, cells }, + new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"), + n_("Zones"), n_("Cells") }); Month month = date.getMonth(); PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month); @@ -843,32 +892,46 @@ for (int m = 0; m < metiers.size(); m++) { Metier metier = metiers.get(m); - MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month); + MetierSeasonInfo infoMet = metier + .getMetierSeasonInfo(month); // getTargetFactor seem to be simple double ciblage = infoMet.getTargetFactor(group); if (ciblage != 0) { // check 0, this prevent next call, for default value Gear gear = metier.getGear(); - Selectivity selectivity = gear.getPopulationSelectivity(pop); + Selectivity selectivity = gear + .getPopulationSelectivity(pop); if (selectivity != null) { // getCoefficient is equation evaluation - double coeff = selectivity.getCoefficient(pop, group, metier); + double coeff = selectivity.getCoefficient(pop, + group, metier); if (coeff != 0) { // check 0, this prevent next call, for default value for (int s = 0; s < strategies.size(); s++) { Strategy str = strategies.get(s); // l'effort d'une cellule du metier - double effort = effortPerStrategyPerCell(str, metier, date); + double effort = effortPerStrategyPerCell( + str, metier, date); if (effort > 0) { // put value only if <> 0 for (int z = 0; z < zones.size(); z++) { Zone zone = zones.get(z); - Set<Cell> cellPops = new HashSet<Cell>(zone.getCell()); - for (Cell cellMet : infoMet.getCells()) { + Set<Cell> cellPops = new HashSet<Cell>( + zone.getCell()); + for (Cell cellMet : infoMet + .getCells()) { if (cellPops.contains(cellMet)) { - double value = coeff * capturability * ciblage * effort; - result.setValue(new Object[]{str, metier, group, zone, cellMet}, value); + double value = coeff + * capturability + * ciblage * effort; + result.setValue( + new Object[] { str, + metier, + group, + zone, + cellMet }, + value); } } } @@ -884,244 +947,243 @@ } // Supprimee suite a demande Steph et Sigrid: 20080208 (NouvellesEquationsfev2008ParCelluleAvecAlgo.odt) -// /** -// * Matrice fishing mortality -// * dim [ Strategy x Metier x Classe x zonePop ] -// * -// * @param pop -// * @param date -// * @return -// * @throws TopiaException -// * @throws IsisFishException -// */ -// public MatrixND matrixFishingMortalityPerCell(Date date, Population pop) throws TopiaException, IsisFishException { -// List<Strategy> strategies = getStrategies(date); -// List<Metier> metiers = getMetiers(date); -// List<PopulationGroup> groups = pop.getPopulationGroup(); -// List<Zone> zones = pop.getPopulationZone(); -// -// // default value in matrix is 0 -// MatrixND result = MatrixFactory.getInstance().create( -// ResultName.MATRIX_FISHING_MORTALITY, -// new List[]{strategies, metiers, groups, zones}, -// new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")}); -// -// Month month = date.getMonth(); -// PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month); -// -// for (int g=0; g < groups.size(); g++) { -// PopulationGroup group = groups.get(g); -// -// // getCapturability is check matrix validity and create matrix if needed and get one value in -// double capturability = infoPop.getCapturability(group); -// if (capturability != 0) { // check 0, this prevent next call, for default value -// -// for (int m=0; m < metiers.size(); m++) { -// Metier metier = metiers.get(m); -// -// MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month); -// // getTargetFactor seem to be simple -// double ciblage = infoMet.getTargetFactor(group); -// -// if (ciblage != 0) { // check 0, this prevent next call, for default value -// -// Gear gear = metier.getGear(); -// Selectivity selectivity = gear.getPopulationSelectivity(pop); -// if (selectivity != null) { -// -// // getCoefficient is equation evaluation -// double coeff = selectivity.getCoefficient(pop, group, metier); -// if (coeff != 0) { // check 0, this prevent next call, for default value -// -// for (int s=0; s < strategies.size(); s++) { -// Strategy str = strategies.get(s); -// for (int z=0; z < zones.size(); z++) { -// Zone zone = zones.get(z); -// double effort = effortPerZonePop(str,metier,date,zone); -// if (effort > 0){ // put value only if <> 0 -// double value = coeff * capturability * ciblage * effort; -// result.setValue(str, metier, group, zone, value); -// } -// } -// } -// } -// } -// } -// } -// } -// } -// return result; -// } + // /** + // * Matrice fishing mortality + // * dim [ Strategy x Metier x Classe x zonePop ] + // * + // * @param pop + // * @param date + // * @return + // * @throws TopiaException + // * @throws IsisFishException + // */ + // public MatrixND matrixFishingMortalityPerCell(Date date, Population pop) throws TopiaException, IsisFishException { + // List<Strategy> strategies = getStrategies(date); + // List<Metier> metiers = getMetiers(date); + // List<PopulationGroup> groups = pop.getPopulationGroup(); + // List<Zone> zones = pop.getPopulationZone(); + // + // // default value in matrix is 0 + // MatrixND result = MatrixFactory.getInstance().create( + // ResultName.MATRIX_FISHING_MORTALITY, + // new List[]{strategies, metiers, groups, zones}, + // new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")}); + // + // Month month = date.getMonth(); + // PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month); + // + // for (int g=0; g < groups.size(); g++) { + // PopulationGroup group = groups.get(g); + // + // // getCapturability is check matrix validity and create matrix if needed and get one value in + // double capturability = infoPop.getCapturability(group); + // if (capturability != 0) { // check 0, this prevent next call, for default value + // + // for (int m=0; m < metiers.size(); m++) { + // Metier metier = metiers.get(m); + // + // MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month); + // // getTargetFactor seem to be simple + // double ciblage = infoMet.getTargetFactor(group); + // + // if (ciblage != 0) { // check 0, this prevent next call, for default value + // + // Gear gear = metier.getGear(); + // Selectivity selectivity = gear.getPopulationSelectivity(pop); + // if (selectivity != null) { + // + // // getCoefficient is equation evaluation + // double coeff = selectivity.getCoefficient(pop, group, metier); + // if (coeff != 0) { // check 0, this prevent next call, for default value + // + // for (int s=0; s < strategies.size(); s++) { + // Strategy str = strategies.get(s); + // for (int z=0; z < zones.size(); z++) { + // Zone zone = zones.get(z); + // double effort = effortPerZonePop(str,metier,date,zone); + // if (effort > 0){ // put value only if <> 0 + // double value = coeff * capturability * ciblage * effort; + // result.setValue(str, metier, group, zone, value); + // } + // } + // } + // } + // } + // } + // } + // } + // } + // return result; + // } - // ne prendre que les metiers pratiqu� semble une bonne idee, mais en fait non, car cela oblige l'ordre des boucles - // et donc ne permet pas autant d'optimisation que souhait� -// public MatrixND matrixFishingMortality2(Date date, Population pop) throws TopiaException, IsisFishException { -// List<Strategy> strategies = getStrategies(date); -// List<Metier> metiers = getMetiers(date); -// List<PopulationGroup> groups = pop.getPopulationGroup(); -// List<Zone> zones = pop.getPopulationZone(); + // ne prendre que les metiers pratiques semble une bonne idee, mais en fait non, car cela oblige l'ordre des boucles + // et donc ne permet pas autant d'optimisation que souhaite + // public MatrixND matrixFishingMortality2(Date date, Population pop) throws TopiaException, IsisFishException { + // List<Strategy> strategies = getStrategies(date); + // List<Metier> metiers = getMetiers(date); + // List<PopulationGroup> groups = pop.getPopulationGroup(); + // List<Zone> zones = pop.getPopulationZone(); -// // default value in matrix is 0 -// MatrixND result = MatrixFactory.getInstance().create( -// ResultName.MATRIX_FISHING_MORTALITY, -// new List[]{strategies, metiers, groups, zones}, -// new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")}); + // // default value in matrix is 0 + // MatrixND result = MatrixFactory.getInstance().create( + // ResultName.MATRIX_FISHING_MORTALITY, + // new List[]{strategies, metiers, groups, zones}, + // new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")}); -// Month month = date.getMonth(); -// PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month); + // Month month = date.getMonth(); + // PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month); -// for (int s=0; s < strategies.size(); s++) { -// Strategy str = strategies.get(s); -// metiers = getMetiers(str, date); -// for (int m=0; m < metiers.size(); m++) { -// Metier metier = metiers.get(m); -// Gear gear = metier.getGear(); -// Selectivity selectivity = gear.getPopulationSelectivity(pop); -// if (selectivity != null) { -// MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month); -// for (int z=0; z < zones.size(); z++) { -// Zone zone = zones.get(z); -// double effort = effortPerZonePop(str,metier,date,zone); -// if (effort > 0){ // put value only if <> 0 -// for (int g=0; g < groups.size(); g++) { -// PopulationGroup group = groups.get(g); - -// // getTargetFactor seem to be simple -// double ciblage = infoMet.getTargetFactor(group); -// if (ciblage != 0) { // check 0, this prevent next call, for default value -// // getCapturability is check matrix validity and create matrix if needed and get one value in -// double capturability = infoPop.getCapturability(group); -// if (capturability != 0) { // check 0, this prevent next call, for default value -// // getCoefficient is equation evaluation -// double coeff = selectivity.getCoefficient(pop, group, metier); -// if (coeff != 0) { // check 0, this prevent next call, for default value -// double value = coeff * capturability * ciblage * effort; -// result.setValue(str, metier, group, zone, value); -// } -// } -// } -// } -// } -// } -// } -// } -// } -// return result; -// } + // for (int s=0; s < strategies.size(); s++) { + // Strategy str = strategies.get(s); + // metiers = getMetiers(str, date); + // for (int m=0; m < metiers.size(); m++) { + // Metier metier = metiers.get(m); + // Gear gear = metier.getGear(); + // Selectivity selectivity = gear.getPopulationSelectivity(pop); + // if (selectivity != null) { + // MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month); + // for (int z=0; z < zones.size(); z++) { + // Zone zone = zones.get(z); + // double effort = effortPerZonePop(str,metier,date,zone); + // if (effort > 0){ // put value only if <> 0 + // for (int g=0; g < groups.size(); g++) { + // PopulationGroup group = groups.get(g); -// /** -// * @param date -// * @param group -// * @param zone -// * @return -// * @throws TopiaException -// * @throws IsisFishException -// */ -// private double totalFishingMortality(Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException { -// List<Strategy> strategies = getStrategies(date); -// -// float result = 0; -// -//// for(Strategy str : strategies){ -//// List<Metier> metierStr = getMetiers(str, date); -//// for (Metier metier : metierStr) { -//// // TODO peut etre ne pas le faire si classe.pop n'est pas -//// /// peche par le metier -//// result += fishingMortality(str, metier, date, group, zone); -//// } -//// } -// -// // Optimisation Hilaire -// for(Strategy str : strategies){ -// List<Metier> metierStr = getMetiers(str, date); -// for (Metier metier : metierStr) { -// double effort=effortPerZonePop(str,metier,date,zone); -// if (effort>0) -// result += fishingMortality(str, metier, date, group, zone, effort); -// } -// } -// -// return result; -// } + // // getTargetFactor seem to be simple + // double ciblage = infoMet.getTargetFactor(group); + // if (ciblage != 0) { // check 0, this prevent next call, for default value + // // getCapturability is check matrix validity and create matrix if needed and get one value in + // double capturability = infoPop.getCapturability(group); + // if (capturability != 0) { // check 0, this prevent next call, for default value + // // getCoefficient is equation evaluation + // double coeff = selectivity.getCoefficient(pop, group, metier); + // if (coeff != 0) { // check 0, this prevent next call, for default value + // double value = coeff * capturability * ciblage * effort; + // result.setValue(str, metier, group, zone, value); + // } + // } + // } + // } + // } + // } + // } + // } + // } + // return result; + // } + // /** + // * @param date + // * @param group + // * @param zone + // * @return + // * @throws TopiaException + // * @throws IsisFishException + // */ + // private double totalFishingMortality(Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException { + // List<Strategy> strategies = getStrategies(date); + // + // float result = 0; + // + //// for(Strategy str : strategies){ + //// List<Metier> metierStr = getMetiers(str, date); + //// for (Metier metier : metierStr) { + //// // TODO peut etre ne pas le faire si classe.pop n'est pas + //// /// peche par le metier + //// result += fishingMortality(str, metier, date, group, zone); + //// } + //// } + // + // // Optimisation Hilaire + // for(Strategy str : strategies){ + // List<Metier> metierStr = getMetiers(str, date); + // for (Metier metier : metierStr) { + // double effort=effortPerZonePop(str,metier,date,zone); + // if (effort>0) + // result += fishingMortality(str, metier, date, group, zone, effort); + // } + // } + // + // return result; + // } // fusion fishingMortality and matrixFishingMortality for performance reason -// /** -// * @param str -// * @param metier -// * @param date -// * @param group -// * @param zone -// * @return -// * @throws IsisFishException -// */ -// private double fishingMortality(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone, double effort) throws IsisFishException { -// Month month = date.getMonth(); -// Population pop = group.getPopulation(); -// Gear gear = metier.getGear(); -// -// Selectivity selectivity = gear.getPopulationSelectivity(pop); -// -// double result = 0; -// -// if (selectivity != null) { -// MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month); -// double ciblage = infoMet.getTargetFactor(group); -// -// PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month); -// double capturability = infoPop.getCapturability(group); -// -// double coeff = selectivity.getCoefficient(pop, group, metier); -// -// // Optimisation Hilaire -//// double effort = effortPerZonePop(str, metier, date, zone); -// -// // la methode est appeler des millions de fois, donc meme si -// // on ne perd pas beaucoup de temps avec le if, on en perd deja -// // trop -//// if(log.isDebugEnabled()) { -//// log.debug( -//// " strategy=" + str + -//// " metier=" + metier + -//// " ciblage=" + ciblage + -//// " capturabilite=" + capturability + -//// " selectivity=" + coeff + -//// " effort=" + effort); -//// } -// -// result = coeff * capturability * ciblage * effort; -// } -// -// return result; -// } + // /** + // * @param str + // * @param metier + // * @param date + // * @param group + // * @param zone + // * @return + // * @throws IsisFishException + // */ + // private double fishingMortality(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone, double effort) throws IsisFishException { + // Month month = date.getMonth(); + // Population pop = group.getPopulation(); + // Gear gear = metier.getGear(); + // + // Selectivity selectivity = gear.getPopulationSelectivity(pop); + // + // double result = 0; + // + // if (selectivity != null) { + // MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month); + // double ciblage = infoMet.getTargetFactor(group); + // + // PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month); + // double capturability = infoPop.getCapturability(group); + // + // double coeff = selectivity.getCoefficient(pop, group, metier); + // + // // Optimisation Hilaire + //// double effort = effortPerZonePop(str, metier, date, zone); + // + // // la methode est appeler des millions de fois, donc meme si + // // on ne perd pas beaucoup de temps avec le if, on en perd deja + // // trop + //// if(log.isDebugEnabled()) { + //// log.debug( + //// " strategy=" + str + + //// " metier=" + metier + + //// " ciblage=" + ciblage + + //// " capturabilite=" + capturability + + //// " selectivity=" + coeff + + //// " effort=" + effort); + //// } + // + // result = coeff * capturability * ciblage * effort; + // } + // + // return result; + // } // Supprimee suite a demande Steph et Sigrid: 20080208 (NouvellesEquationsfev2008ParCelluleAvecAlgo.odt) -// /** -// * @param str -// * @param metier -// * @param date -// * @param zone -// * @return -// */ -// private double effortPerZonePop(Strategy str, Metier metier, Date date, Zone zonePop) { -// Month month = date.getMonth(); -// Collection<Zone> zoneMet = metier.getMetierSeasonInfo(month).getZone(); -// double inter = nbCellInter(zoneMet, zonePop); -// -// double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier, date); -// -// if(log.isDebugEnabled()) { -// log.debug( -// " strategy=" + str + -// " metier=" + metier + -// " inter=" + inter + -// " effortPerStrategyPerCell=" + effortPerStrategyPerCell -// ); -// } -// -// double result = effortPerStrategyPerCell * inter; -// return result; -// } + // /** + // * @param str + // * @param metier + // * @param date + // * @param zone + // * @return + // */ + // private double effortPerZonePop(Strategy str, Metier metier, Date date, Zone zonePop) { + // Month month = date.getMonth(); + // Collection<Zone> zoneMet = metier.getMetierSeasonInfo(month).getZone(); + // double inter = nbCellInter(zoneMet, zonePop); + // + // double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier, date); + // + // if(log.isDebugEnabled()) { + // log.debug( + // " strategy=" + str + + // " metier=" + metier + + // " inter=" + inter + + // " effortPerStrategyPerCell=" + effortPerStrategyPerCell + // ); + // } + // + // double result = effortPerStrategyPerCell * inter; + // return result; + // } /** * @param str @@ -1129,32 +1191,31 @@ * @param date * @return */ - private double effortPerStrategyPerCell(Strategy str, Metier metier, Date date) { + private double effortPerStrategyPerCell(Strategy str, Metier metier, + Date date) { Month month = date.getMonth(); StrategyMonthInfo smi = str.getStrategyMonthInfo(month); Collection<Zone> zones = metier.getMetierSeasonInfo(month).getZone(); double nbCell = getCells(zones).size(); - if(nbCell == 0){ + if (nbCell == 0) { // normalement il devrait y avoir des mailles, mais pour les // ancienne zone AuPort, il n'y en avait pas - if(log.isWarnEnabled()) log.warn("Calcul d'une distance pour le metier "+metier+" pour le mois "+month+" avec une zone sans maille: " + zones); + if (log.isWarnEnabled()) + log.warn("Calcul d'une distance pour le metier " + metier + + " pour le mois " + month + + " avec une zone sans maille: " + zones); return 0; } + double effortPerStrategy = effortPerStrategyMet(str, metier, date); - double effortPerStrategy = effortPerStrategyMet(str, metier, date); - - if(log.isDebugEnabled()) { - log.debug( - " strategy=" + str + - " metier=" + metier + - " nbCell=" + nbCell + - " effortPerStrategy=" + effortPerStrategy - ); + if (log.isDebugEnabled()) { + log.debug(" strategy=" + str + " metier=" + metier + " nbCell=" + + nbCell + " effortPerStrategy=" + effortPerStrategy); } - double result = effortPerStrategy/nbCell; + double result = effortPerStrategy / nbCell; return result; } @@ -1174,18 +1235,15 @@ double propStrMet = smi.getProportionMetier(metier); double effortPerVessel = effortPerStrategyPerVessel(str, metier, date); - if(log.isDebugEnabled()) { - log.debug( - " strategy=" + str + - " metier=" + metier + - " propSetOfVessels=" + propSetOfVessels + - " nbOfVessels=" + nbOfVessels + - " propStrMet=" + propStrMet + - " effortPerVessel=" + effortPerVessel - ); + if (log.isDebugEnabled()) { + log.debug(" strategy=" + str + " metier=" + metier + + " propSetOfVessels=" + propSetOfVessels + " nbOfVessels=" + + nbOfVessels + " propStrMet=" + propStrMet + + " effortPerVessel=" + effortPerVessel); } - double result = propSetOfVessels * nbOfVessels * propStrMet * effortPerVessel; + double result = propSetOfVessels * nbOfVessels * propStrMet + * effortPerVessel; return result; } @@ -1196,23 +1254,21 @@ * @param date * @return */ - private double effortPerStrategyPerVessel(Strategy str, Metier metier, Date date) { + private double effortPerStrategyPerVessel(Strategy str, Metier metier, + Date date) { Month month = date.getMonth(); StrategyMonthInfo smi = str.getStrategyMonthInfo(month); double nbTrips = smi.getNumberOfTrips(); double fishingTime = fishingTimePerTrip(str, metier, date); - double stdEffortPerHour = stdEffortPerHour(date, str.getSetOfVessels(), metier); + double stdEffortPerHour = stdEffortPerHour(date, str.getSetOfVessels(), + metier); - if(log.isDebugEnabled()) { - log.debug( - " strategy=" + str + - " metier=" + metier + - " nbTrips=" + nbTrips + - " fishingTime=" + fishingTime + - " stdEffortPerHour=" + stdEffortPerHour - ); + if (log.isDebugEnabled()) { + log.debug(" strategy=" + str + " metier=" + metier + " nbTrips=" + + nbTrips + " fishingTime=" + fishingTime + + " stdEffortPerHour=" + stdEffortPerHour); } - + double result = nbTrips * fishingTime * stdEffortPerHour; return result; @@ -1232,38 +1288,36 @@ Collection<Zone> zone = metier.getMetierSeasonInfo(month).getZone(); if (zone == null) { - if(log.isWarnEnabled()) log.warn( - "missing zone for metier =" + metier + - " for month" + month - ); + if (log.isWarnEnabled()) + log.warn("missing zone for metier =" + metier + " for month" + + month); } - double tripDuration = smi.getTripType().getTripDuration().getHour(); + double tripDuration = smi.getTripType().getTripDuration().getHour(); double travelTime = travelTimePerTrip(str.getSetOfVessels(), zone); double result = tripDuration - travelTime; - if (result < 0 ) { - if(log.isWarnEnabled()) log.warn( - " strategy=" + str + - " metier=" + metier + - " tripDuration=" + tripDuration + - " travelTime=" + travelTime - ); + if (result < 0) { + if (log.isWarnEnabled()) + log.warn(" strategy=" + str + " metier=" + metier + + " tripDuration=" + tripDuration + " travelTime=" + + travelTime); } return result; } /** - * + * * @param setOfVessels * @param zone * @return */ - protected double travelTimePerTrip(SetOfVessels sov, Collection<Zone> zoneMetier) { + protected double travelTimePerTrip(SetOfVessels sov, + Collection<Zone> zoneMetier) { Cell maille = sov.getPort().getCell(); - double result = - 2 * distance(zoneMetier, maille) / sov.getVesselType().getSpeed(); + double result = 2 * distance(zoneMetier, maille) + / sov.getVesselType().getSpeed(); return result; } @@ -1277,24 +1331,24 @@ double result = 0; List<Cell> cells = getCells(zones); - if(cells.size() == 0){ + if (cells.size() == 0) { // normalement il devrait y avoir des mailles, mais pour les // ancienne zone AuPort, il n'y en avait pas - if(log.isWarnEnabled()) { + if (log.isWarnEnabled()) { log.warn("Calcul d'une distance avec une zone sans maille"); } return 0; } - for(Cell c : cells){ + for (Cell c : cells) { result += distance(c, cell); } - if(log.isDebugEnabled()) { - log.debug(" result=" + result + " nbMaille="+cells.size()); + if (log.isDebugEnabled()) { + log.debug(" result=" + result + " nbMaille=" + cells.size()); } - - result = result / (double)cells.size(); + + result = result / (double) cells.size(); return result; } @@ -1305,61 +1359,54 @@ */ private double distance(Cell m1, Cell m2) { double earthRadius = 6378.388; - double p = 180/Math.PI; + double p = 180 / Math.PI; - if(log.isDebugEnabled()) log.debug("p: " + p); + if (log.isDebugEnabled()) + log.debug("p: " + p); double m1lat = m1.getLatitude(); double m2lat = m2.getLatitude(); double m1lon = m1.getLongitude(); double m2lon = m2.getLongitude(); - if(log.isDebugEnabled()) log.debug( - " m1lat=" + m1lat + - " m2lat=" + m2lat + - " m1lon=" + m1lon + - " m2lonx=" + m2lon - ); + if (log.isDebugEnabled()) + log.debug(" m1lat=" + m1lat + " m2lat=" + m2lat + " m1lon=" + m1lon + + " m2lonx=" + m2lon); - double m1lat_div_p = m1lat/p; - double m2lat_div_p = m2lat/p; - double m1lon_div_p = m1lon/p; - double m2lon_div_p = m2lon/p; + double m1lat_div_p = m1lat / p; + double m2lat_div_p = m2lat / p; + double m1lon_div_p = m1lon / p; + double m2lon_div_p = m2lon / p; - if(log.isDebugEnabled()) log.debug( - " m1lat_div_p=" + m1lat_div_p + - " m2lat_div_p=" + m2lat_div_p + - " m1lon_div_p=" + m1lon_div_p + - " m2lon_div_p=" + m2lon_div_p - ); + if (log.isDebugEnabled()) + log.debug(" m1lat_div_p=" + m1lat_div_p + " m2lat_div_p=" + + m2lat_div_p + " m1lon_div_p=" + m1lon_div_p + + " m2lon_div_p=" + m2lon_div_p); double sin_m1lat_div_p = Math.sin(m1lat_div_p); double sin_m2lat_div_p = Math.sin(m2lat_div_p); double cos_m1lat_div_p = Math.cos(m1lat_div_p); double cos_m2lat_div_p = Math.cos(m2lat_div_p); - if(log.isDebugEnabled()) log.debug( - " sin_m1lat_div_p=" + sin_m1lat_div_p + - " sin_m2lat_div_p=" + sin_m2lat_div_p + - " cos_m1lat_div_p=" + cos_m1lat_div_p + - " cos_m2lat_div_p=" + cos_m2lat_div_p - ); + if (log.isDebugEnabled()) + log.debug(" sin_m1lat_div_p=" + sin_m1lat_div_p + + " sin_m2lat_div_p=" + sin_m2lat_div_p + + " cos_m1lat_div_p=" + cos_m1lat_div_p + + " cos_m2lat_div_p=" + cos_m2lat_div_p); - double cos_m1lon_div_p_minus_m2lon_div_p = Math.cos(m1lon_div_p - m2lon_div_p); + double cos_m1lon_div_p_minus_m2lon_div_p = Math.cos(m1lon_div_p + - m2lon_div_p); - if(log.isDebugEnabled()) log.debug( - " cos_m1lon_div_p_minus_m2lon_div_p=" + cos_m1lon_div_p_minus_m2lon_div_p); + if (log.isDebugEnabled()) + log.debug(" cos_m1lon_div_p_minus_m2lon_div_p=" + + cos_m1lon_div_p_minus_m2lon_div_p); - double acos = Math.acos( - sin_m1lat_div_p - * sin_m2lat_div_p - + - cos_m1lat_div_p - * cos_m2lat_div_p - * cos_m1lon_div_p_minus_m2lon_div_p - ); + double acos = Math.acos(sin_m1lat_div_p * sin_m2lat_div_p + + cos_m1lat_div_p * cos_m2lat_div_p + * cos_m1lon_div_p_minus_m2lon_div_p); - if(log.isDebugEnabled()) log.debug(" acos=" + acos); + if (log.isDebugEnabled()) + log.debug(" acos=" + acos); double result = earthRadius * acos; @@ -1374,19 +1421,18 @@ private double stdEffortPerHour(Date date, SetOfVessels sov, Metier metier) { double result = 0; EffortDescription ed = sov.getPossibleMetiers(metier); - if(ed != null){ + if (ed != null) { double fstd = metier.getGear().getStandardisationFactor(); double etp = sov.getTechnicalEfficiency(date, metier); - double val = - fstd * etp * ed.getFishingOperation() * ed.getGearsNumberPerOperation(); + double val = fstd * etp * ed.getFishingOperation() + * ed.getGearsNumberPerOperation(); result = val; } - result = result/24; // 24 heures + result = result / 24; // 24 heures return result; } - /** * used here and in Rule (CantonnementPreSimu) * @@ -1400,7 +1446,7 @@ } return result; } - + /** * used here and in Rule (CantonnementPreSimu) * @@ -1414,76 +1460,81 @@ tmp.retainAll(zonePop.getCell()); return tmp.size(); } - + /////////////////////////////////////////////////////////////////////////// // // // /////////////////////////////////////////////////////////////////////////// - + /** * @param N * @param pop * @param date * @return - * @throws IsisFishException - * @throws TopiaException + * @throws IsisFishException + * @throws TopiaException */ private MatrixND matrixAbundancePerCell(MatrixND N, Population pop, - Date date, MatrixND matrixFishingMortality) throws TopiaException, IsisFishException { + Date date, MatrixND matrixFishingMortality) throws TopiaException, + IsisFishException { List<PopulationGroup> groups = pop.getPopulationGroup(); List<Zone> zones = pop.getPopulationZone(); List<Cell> allCells = getCells(zones); - + MatrixND result = MatrixFactory.getInstance().create( ResultName.MATRIX_ABUNDANCE + "_PER_CELL", - new List[]{groups, zones, allCells}, - new String[]{n_("Groups"), n_("Zones"), n_("Cells")}); + new List[] { groups, zones, allCells }, + new String[] { n_("Groups"), n_("Zones"), n_("Cells") }); - for (int g=0; g < groups.size(); g++) { + for (int g = 0; g < groups.size(); g++) { PopulationGroup group = groups.get(g); - for (int z=0; z < zones.size(); z++) { + for (int z = 0; z < zones.size(); z++) { Zone zone = zones.get(z); List<Cell> cells = zone.getCell(); - for (int c=0; c<cells.size(); c++) { + for (int c = 0; c < cells.size(); c++) { Cell cell = cells.get(c); - double value = survivalRatePerCell(date, group, zone, - cell, matrixFishingMortality); + double value = survivalRatePerCell(date, group, zone, cell, + matrixFishingMortality); double n = N.getValue(g, z) / zone.sizeCell(); value *= n; result.setValue(g, z, c, value); } } } - + return result; } - + /** * Utilise pour le calcule en Cell + * * @param N * @param pop * @param date * @return - * @throws IsisFishException - * @throws TopiaException + * @throws IsisFishException + * @throws TopiaException */ public MatrixND matrixAbundance(MatrixND N, Population pop, Date date) throws TopiaException, IsisFishException { - - MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell(date, pop); - - MatrixND result = matrixAbundancePerCell(N, pop, date, matrixFishingMortalityPerCell); + + MatrixND matrixFishingMortalityPerCell = matrixFishingMortalityPerCell( + date, pop); + + MatrixND result = matrixAbundancePerCell(N, pop, date, + matrixFishingMortalityPerCell); result = result.sumOverDim(2); result = result.reduceDims(2); result.setName(ResultName.MATRIX_ABUNDANCE); - - return result; + + return result; } /** * Utilise pour le calcule en Zone + * * @param N * @param pop * @param date @@ -1491,20 +1542,22 @@ * @throws IsisFishException * @throws TopiaException */ - public MatrixND matrixAbundance(MatrixND N, Population pop, Date date, MatrixND matrixFishingMortality) throws TopiaException, IsisFishException { + public MatrixND matrixAbundance(MatrixND N, Population pop, Date date, + MatrixND matrixFishingMortality) throws TopiaException, + IsisFishException { List<PopulationGroup> groups = pop.getPopulationGroup(); List<Zone> zones = pop.getPopulationZone(); MatrixND result = MatrixFactory.getInstance().create( - ResultName.MATRIX_ABUNDANCE, - new List[]{groups, zones}, - new String[]{n_("Groups"), n_("Zones")}); + ResultName.MATRIX_ABUNDANCE, new List[] { groups, zones }, + new String[] { n_("Groups"), n_("Zones") }); - for (int g=0; g < groups.size(); g++) { + for (int g = 0; g < groups.size(); g++) { PopulationGroup group = groups.get(g); - for (int z=0; z < zones.size(); z++) { + for (int z = 0; z < zones.size(); z++) { Zone zone = zones.get(z); - double value = survivalRatePerZone(date, group, zone, matrixFishingMortality); + double value = survivalRatePerZone(date, group, zone, + matrixFishingMortality); double n = N.getValue(g, z); value *= n; result.setValue(g, z, value); @@ -1517,6 +1570,7 @@ /** * Utilise pour la mortalite des poissons, lorsqu'aucune strategie n'est * selectionnee. + * * @param N * @param pop * @param date @@ -1524,21 +1578,23 @@ * @throws IsisFishException * @throws TopiaException */ - public MatrixND matrixAbundanceSsF(MatrixND N, Population pop, Date date) throws TopiaException, IsisFishException { + public MatrixND matrixAbundanceSsF(MatrixND N, Population pop, Date date) + throws TopiaException, IsisFishException { List<PopulationGroup> groups = pop.getPopulationGroup(); List<Zone> zones = pop.getPopulationZone(); MatrixND result = MatrixFactory.getInstance().create( - ResultName.MATRIX_ABUNDANCE, - new List[]{groups, zones}, - new String[]{n_("Groups"), n_("Zones")}); + ResultName.MATRIX_ABUNDANCE, new List[] { groups, zones }, + new String[] { n_("Groups"), n_("Zones") }); - for (int g=0; g < groups.size(); g++) { + for (int g = 0; g < groups.size(); g++) { PopulationGroup group = groups.get(g); - for (int z=0; z < zones.size(); z++) { + for (int z = 0; z < zones.size(); z++) { Zone zone = zones.get(z); - double M = group.getNaturalDeathRate(zone)/(double)Month.NUMBER_OF_MONTH; - double value = (double)Math.exp(-M);; + double M = group.getNaturalDeathRate(zone) + / (double) Month.NUMBER_OF_MONTH; + double value = (double) Math.exp(-M); + ; double n = N.getValue(g, z); value *= n; result.setValue(g, z, value); @@ -1556,31 +1612,36 @@ * @throws IsisFishException * @throws TopiaException */ - private double survivalRatePerZone(Date date, PopulationGroup group, Zone zone, MatrixND matrixFishingMortality) throws TopiaException, IsisFishException { - double F = totalFishingMortality(date, matrixFishingMortality).getValue(group, zone); //totalFishingMortality(date, group, zone); // rem perf: totalFishingMortality a deja ete calcul� - double M = group.getNaturalDeathRate(zone)/(double)Month.NUMBER_OF_MONTH; - double result = Math.exp(-(F+M)); + private double survivalRatePerZone(Date date, PopulationGroup group, + Zone zone, MatrixND matrixFishingMortality) throws TopiaException, + IsisFishException { + double F = totalFishingMortality(date, matrixFishingMortality) + .getValue(group, zone); //totalFishingMortality(date, group, zone); // rem perf: totalFishingMortality a deja ete calcul� + double M = group.getNaturalDeathRate(zone) + / (double) Month.NUMBER_OF_MONTH; + double result = Math.exp(-(F + M)); return result; } - /** * @param date * @param group * @param zone * @return - * @throws IsisFishException - * @throws TopiaException + * @throws IsisFishException + * @throws TopiaException */ - private double survivalRatePerCell(Date date, PopulationGroup group, Zone zone, - Cell cell, MatrixND matrixFishingMortalityPerCell) throws TopiaException, IsisFishException { - - double F = totalFishingMortalityPerCell(date, matrixFishingMortalityPerCell) - .getValue(group, zone, cell); //totalFishingMortality(date, group, zone); // rem perf: totalFishingMortality a deja ete calcul� - double M = group.getNaturalDeathRate(zone)/(double)Month.NUMBER_OF_MONTH; - double result = (double)Math.exp(-(F+M)); + private double survivalRatePerCell(Date date, PopulationGroup group, + Zone zone, Cell cell, MatrixND matrixFishingMortalityPerCell) + throws TopiaException, IsisFishException { + double F = totalFishingMortalityPerCell(date, + matrixFishingMortalityPerCell).getValue(group, zone, cell); //totalFishingMortality(date, group, zone); // rem perf: totalFishingMortality a deja ete calcul� + double M = group.getNaturalDeathRate(zone) + / (double) Month.NUMBER_OF_MONTH; + double result = (double) Math.exp(-(F + M)); + return result; } @@ -1589,7 +1650,7 @@ // // /////////////////////////////////////////////////////////////////////////// - + /** * @param n * @param pop @@ -1601,32 +1662,31 @@ List<Zone> zones = N.getSemantics(1); MatrixND result = MatrixFactory.getInstance().create( - ResultName.MATRIX_BIOMASS, - new List[]{groups, zones}, - new String[]{n_("Groups"), n_("Zones")}); + ResultName.MATRIX_BIOMASS, new List[] { groups, zones }, + new String[] { n_("Groups"), n_("Zones") }); - for (int g=0; g < groups.size(); g++) { + for (int g = 0; g < groups.size(); g++) { PopulationGroup group = groups.get(g); double meanWeight = group.getMeanWeight(); - for (int z=0; z < zones.size(); z++) { + for (int z = 0; z < zones.size(); z++) { Zone zone = zones.get(z); double n = N.getValue(group, zone); double value = n * meanWeight; result.setValue(group, zone, value); } } - + return result; } - public MatrixND matrixBiomassBeginMonth(MatrixND N, Population pop, Date date) { + public MatrixND matrixBiomassBeginMonth(MatrixND N, Population pop, + Date date) { List<PopulationGroup> groups = N.getSemantics(0); List<Zone> zones = N.getSemantics(1); MatrixND result = MatrixFactory.getInstance().create( - ResultName.MATRIX_BIOMASS, - new List[]{groups, zones}, - new String[]{n_("Groups"), n_("Zones")}); + ResultName.MATRIX_BIOMASS, new List[] { groups, zones }, + new String[] { n_("Groups"), n_("Zones") }); for (int g = 0; g < groups.size(); g++) { PopulationGroup group = groups.get(g); @@ -1641,14 +1701,14 @@ return result; } - public MatrixND matrixAbondanceBeginMonth(MatrixND N, Population pop, Date date) { + public MatrixND matrixAbondanceBeginMonth(MatrixND N, Population pop, + Date date) { List<PopulationGroup> groups = N.getSemantics(0); List<Zone> zones = N.getSemantics(1); MatrixND result = MatrixFactory.getInstance().create( - ResultName.MATRIX_ABUNDANCE, - new List[]{groups, zones}, - new String[]{n_("Groups"), n_("Zones")}); + ResultName.MATRIX_ABUNDANCE, new List[] { groups, zones }, + new String[] { n_("Groups"), n_("Zones") }); for (int g = 0; g < groups.size(); g++) { PopulationGroup group = groups.get(g); @@ -1661,17 +1721,16 @@ return result; } - /////////////////////////////////////////////////////////////////////////// // // // /////////////////////////////////////////////////////////////////////////// - + /** * @param date * @return - * @throws TopiaException + * @throws TopiaException */ public MatrixND matrixEffortPerStrategyMet(Date date) throws TopiaException { List<Strategy> strategies = getStrategies(date); @@ -1679,26 +1738,26 @@ MatrixND result = MatrixFactory.getInstance().create( ResultName.MATRIX_EFFORT_PER_STRATEGY_MET, - new List[]{strategies, metiers}, - new String[]{n_("Strategies"), n_("Metiers")}); + new List[] { strategies, metiers }, + new String[] { n_("Strategies"), n_("Metiers") }); - for (int s=0; s < strategies.size(); s++) { + for (int s = 0; s < strategies.size(); s++) { Strategy str = strategies.get(s); metiers = getMetiers(str, date); - for (int m=0; m < metiers.size(); m++) { + for (int m = 0; m < metiers.size(); m++) { Metier metier = metiers.get(m); double value = effortPerStrategyMet(str, metier, date); result.setValue(str, metier, value); } } -// for(Strategy str : strategies){ -// List<Metier> metierStr = getMetiers(str, date); -// for(Metier metier : metierStr) { -// double val = effortPerStrategyMet(str, metier, date); // rem perf: effortPerStrategyMet a deja ete calcul� -// result.setValue(str, metier, val); -// } -// } + // for(Strategy str : strategies){ + // List<Metier> metierStr = getMetiers(str, date); + // for(Metier metier : metierStr) { + // double val = effortPerStrategyMet(str, metier, date); // rem perf: effortPerStrategyMet a deja ete calcule + // result.setValue(str, metier, val); + // } + // } return result; } @@ -1708,28 +1767,28 @@ // // /////////////////////////////////////////////////////////////////////////// - -// /** -// * @param pop -// * @param date -// * @return -// */ -// public MatrixND matrixCatchWeightPerStrategyMet(Population pop, -// Date date, MatrixND matrixCatchPerStrategyMet) { -// List<PopulationGroup> groups = pop.getPopulationGroup(); -// -// MatrixND result = matrixCatchPerStrategyMet.copy(); -// result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET); -// -// for(PopulationGroup group : groups){ -// MatrixND sub = result.getSubMatrix(2, group, 1); -// double meanWeight = group.getMeanWeight(); -// sub.mults(meanWeight); -// } -// -// return result; -// } + // /** + // * @param pop + // * @param date + // * @return + // */ + // public MatrixND matrixCatchWeightPerStrategyMet(Population pop, + // Date date, MatrixND matrixCatchPerStrategyMet) { + // List<PopulationGroup> groups = pop.getPopulationGroup(); + // + // MatrixND result = matrixCatchPerStrategyMet.copy(); + // result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET); + // + // for(PopulationGroup group : groups){ + // MatrixND sub = result.getSubMatrix(2, group, 1); + // double meanWeight = group.getMeanWeight(); + // sub.mults(meanWeight); + // } + // + // return result; + // } + /** * * @@ -1739,18 +1798,18 @@ */ public MatrixND matrixDiscardWeightPerStrategyMetPerZonePop(Population pop, Date date, MatrixND matrixDiscardPerStrategyMetPerZonePop) { - List<PopulationGroup> groups = pop.getPopulationGroup(); + List<PopulationGroup> groups = pop.getPopulationGroup(); - MatrixND result = matrixDiscardPerStrategyMetPerZonePop.copy(); - result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET); + MatrixND result = matrixDiscardPerStrategyMetPerZonePop.copy(); + result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET); - for(PopulationGroup group : groups){ - MatrixND sub = result.getSubMatrix(2, group, 1); - double meanWeight = group.getMeanWeight(); - sub.mults(meanWeight); - } + for (PopulationGroup group : groups) { + MatrixND sub = result.getSubMatrix(2, group, 1); + double meanWeight = group.getMeanWeight(); + sub.mults(meanWeight); + } - return result; + return result; } }
participants (1)
-
jcouteau@users.labs.libre-entreprise.org