Isis-fish-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
August 2014
- 1 participants
- 11 discussions
r4104 - in branches/4.3.0-log4j2: . src/main/java/fr/ifremer/isisfish/util src/test/java/fr/ifremer/isisfish/util
by echatellier@users.forge.codelutin.com 29 Aug '14
by echatellier@users.forge.codelutin.com 29 Aug '14
29 Aug '14
Author: echatellier
Date: 2014-08-29 15:39:04 +0200 (Fri, 29 Aug 2014)
New Revision: 4104
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4104
Log:
refs #568: D?\195?\169pendances non incluses dans la simulation
Added:
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/DependencyUtil.java
branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/util/DependencyUtilTest.java
Modified:
branches/4.3.0-log4j2/pom.xml
Modified: branches/4.3.0-log4j2/pom.xml
===================================================================
--- branches/4.3.0-log4j2/pom.xml 2014-08-29 08:58:39 UTC (rev 4103)
+++ branches/4.3.0-log4j2/pom.xml 2014-08-29 13:39:04 UTC (rev 4104)
@@ -75,6 +75,13 @@
</dependency>
<dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>5.0.3</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-profiling</artifactId>
<version>3.0</version>
@@ -325,6 +332,24 @@
<artifactId>svnkit</artifactId>
<version>1.8.5</version>
<scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>jna</artifactId>
+ <groupId>net.java.dev.jna</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jsch.agentproxy.connector-factory</artifactId>
+ <groupId>com.jcraft</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>sqljet</artifactId>
+ <groupId>org.tmatesoft.sqljet</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>platform</artifactId>
+ <groupId>net.java.dev.jna</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- fin svnkit pour communication subversion -->
@@ -352,13 +377,6 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- <version>1.3</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<!-- ************************************************************* -->
Added: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/DependencyUtil.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/DependencyUtil.java (rev 0)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/DependencyUtil.java 2014-08-29 13:39:04 UTC (rev 4104)
@@ -0,0 +1,252 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2014 Ifremer, Code Lutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.TypePath;
+
+import fr.ifremer.isisfish.datastore.ExportStorage;
+import fr.ifremer.isisfish.datastore.FormuleStorage;
+import fr.ifremer.isisfish.datastore.ObjectiveStorage;
+import fr.ifremer.isisfish.datastore.OptimizationStorage;
+import fr.ifremer.isisfish.datastore.RuleStorage;
+import fr.ifremer.isisfish.datastore.ScriptStorage;
+import fr.ifremer.isisfish.datastore.SensitivityAnalysisStorage;
+import fr.ifremer.isisfish.datastore.SensitivityExportStorage;
+import fr.ifremer.isisfish.datastore.SimulationPlanStorage;
+import fr.ifremer.isisfish.datastore.SimulatorStorage;
+
+/**
+ * Class utilitaire chargées d'inspecter le bytecode de certaines classe des scripts utilisateur
+ * d'IsisFish pour en extraire des informations.
+ *
+ * @author Eric Chatellier
+ */
+public class DependencyUtil {
+
+ private static final Log log = LogFactory.getLog(DependencyUtil.class);
+
+ /**
+ * Extrait les dépendences d'une class compilé à partir de son bytecode en ne conservant que
+ * les dependances des scripts utilisateurs.
+ *
+ * @param clazz la classe à analyser
+ * @return extract class set
+ */
+ public static Set<String> extractDependencies(Class<?> clazz) {
+ return extractDependencies(clazz, true);
+ }
+
+ /**
+ * Extrait les dépendences d'une class compilé à partir de son bytecode.
+ *
+ * @param clazz la classe à analyser
+ * @param onlyUserScript only keep user script types
+ * @return extract class set
+ */
+ public static Set<String> extractDependencies(Class<?> clazz, final boolean onlyUserScript) {
+ final Set<String> result = new HashSet<>();
+
+ // method body visitor
+ final MethodVisitor mv = new MethodVisitor(Opcodes.ASM5) {
+
+ @Override
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ registerDescriptor(result, desc, onlyUserScript);
+ return super.visitAnnotation(desc, visible);
+ }
+
+ @Override
+ public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
+ registerDescriptor(result, desc, onlyUserScript);
+ return super.visitTypeAnnotation(typeRef, typePath, desc, visible);
+ }
+
+ @Override
+ public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
+ registerDescriptor(result, desc, onlyUserScript);
+ return super.visitParameterAnnotation(parameter, desc, visible);
+ }
+
+ @Override
+ public void visitTypeInsn(int opcode, String type) {
+ registerType(result, type, onlyUserScript);
+ super.visitTypeInsn(opcode, type);
+ }
+
+ @Override
+ public void visitFieldInsn(int opcode, String owner, String name, String desc) {
+ registerType(result, owner, onlyUserScript);
+ registerDescriptor(result, desc, onlyUserScript);
+ super.visitFieldInsn(opcode, owner, name, desc);
+ }
+
+ @Override
+ public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
+ registerType(result, owner, onlyUserScript);
+ registerDescriptor(result, desc, onlyUserScript);
+ super.visitMethodInsn(opcode, owner, name, desc, itf);
+ }
+
+ @Override
+ public void visitLdcInsn(Object cst) {
+ if (cst instanceof Type) {
+ registerType(result, ((Type)cst).getClassName(), onlyUserScript);
+ }
+ super.visitLdcInsn(cst);
+ }
+
+ @Override
+ public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
+ registerType(result, type, onlyUserScript);
+ super.visitTryCatchBlock(start, end, handler, type);
+ }
+
+ @Override
+ public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
+ registerDescriptor(result, desc, onlyUserScript);
+ super.visitLocalVariable(name, desc, signature, start, end, index);
+ }
+ };
+
+ // class visitor
+ ClassVisitor visitor = new ClassVisitor(Opcodes.ASM5) {
+
+ @Override
+ public void visit(int version, int access, String name,
+ String signature, String superName, String[] interfaces) {
+ registerType(result, superName, onlyUserScript);
+ super.visit(version, access, name, signature, superName, interfaces);
+ }
+
+ @Override
+ public AnnotationVisitor visitAnnotation(String desc,
+ boolean visible) {
+ registerDescriptor(result, desc, onlyUserScript);
+ return super.visitAnnotation(desc, visible);
+ }
+
+ @Override
+ public FieldVisitor visitField(int access, String name,
+ String desc, String signature, Object value) {
+ registerDescriptor(result, desc, onlyUserScript);
+ return super.visitField(access, name, desc, signature, value);
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int access, String name,
+ String desc, String signature, String[] exceptions) {
+ registerDescriptor(result, desc, onlyUserScript);
+ return mv;
+ }
+ };
+
+ // parse inpu class
+ try (InputStream in = clazz.getResourceAsStream("/" + clazz.getName().replace('.', '/') + ".class")) {
+ ClassReader classReader = new ClassReader(in);
+ classReader.accept(visitor, 0);
+ } catch (IOException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't extract dependencies", ex);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Register type if necessary (depends on another user script).
+ *
+ * @param types types collection
+ * @param type type to add
+ * @param onlyUserScript only keep user script types
+ */
+ protected static void registerType(Set<String> types, String type, boolean onlyUserScript) {
+ //System.out.println("==> " + type);
+ if (!onlyUserScript || StringUtils.startsWithAny(type,
+ ExportStorage.EXPORT_PATH,
+ FormuleStorage.FORMULE_PATH,
+ ObjectiveStorage.OBJECTIVE_PATH,
+ OptimizationStorage.OPTIMIZATION_PATH,
+ RuleStorage.RULE_PATH,
+ ScriptStorage.SCRIPT_PATH,
+ SensitivityAnalysisStorage.SENSITIVITY_ANALYSIS_PATH,
+ SensitivityExportStorage.SENSITIVITY_EXPORT_PATH,
+ SimulationPlanStorage.SIMULATION_PLAN_PATH,
+ SimulatorStorage.SIMULATOR_PATH)) {
+ String dotType = type.replace('/', '.');
+ types.add(dotType);
+ }
+ }
+
+ /**
+ * Clean type to extract valid class name.
+ *
+ * Ex:
+ * <ul>
+ * <li>Lfr/ifremer/isisfish/types/Month;</li>
+ * <li>[Ljava/lang/String;</li>
+ * <li>(Ljava/lang/Class;)Lorg/apache/commons/logging/Log;</li>
+ *
+ * @param types types collection
+ * @param descriptor descriptor
+ * @param onlyUserScript only keep user script types
+ */
+ protected static void registerDescriptor(Set<String> types, String descriptor, boolean onlyUserScript) {
+ if (descriptor.startsWith("(")) {
+ int endIndex = descriptor.indexOf(')');
+ registerDescriptor(types, descriptor.substring(1, endIndex), onlyUserScript);
+ registerDescriptor(types, descriptor.substring(endIndex + 1), onlyUserScript);
+ } else {
+ Pattern pattern = Pattern.compile("\\[*L([^;]+);|\\[[ZBCSIFDJ]|[ZBCSIFDJ]");
+ Matcher matcher = pattern.matcher(descriptor);
+ while (matcher.find()) {
+ String match = matcher.group(1);
+ // sinon c'est un type primitif
+ if (match != null) {
+ registerType(types, match, onlyUserScript);
+ }
+ }
+ }
+ }
+}
Property changes on: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/DependencyUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/util/DependencyUtilTest.java
===================================================================
--- branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/util/DependencyUtilTest.java (rev 0)
+++ branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/util/DependencyUtilTest.java 2014-08-29 13:39:04 UTC (rev 4104)
@@ -0,0 +1,142 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2014 Ifremer, Code Lutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package fr.ifremer.isisfish.util;
+
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import fr.ifremer.isisfish.AbstractIsisFishTest;
+import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.datastore.RuleStorage;
+import fr.ifremer.isisfish.datastore.ScriptStorage;
+import fr.ifremer.isisfish.datastore.SimulatorStorage;
+
+/**
+ * Test concernant la gestion du bytecode des scripts utilisateur.
+ *
+ * @author Eric Chatellier
+ */
+public class DependencyUtilTest extends AbstractIsisFishTest {
+
+ /**
+ * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien
+ * extraites.
+ *
+ * @throws IsisFishException
+ */
+ @Test
+ public void testExtractDependencies1() throws IsisFishException {
+ SimulatorStorage simulatorByCell = SimulatorStorage.getSimulator("SimulatorEffortByCell");
+ Class<?> clazz = simulatorByCell.getCodeClass();
+ Set<String> deps = DependencyUtil.extractDependencies(clazz, false);
+ Assert.assertTrue(deps.size() >= 10);
+ Assert.assertTrue(deps.contains("simulators.DefaultSimulator"));
+ }
+
+ /**
+ * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien
+ * extraites.
+ *
+ * @throws IsisFishException
+ */
+ @Test
+ public void testExtractDependencies2() throws IsisFishException {
+ SimulatorStorage simulator = SimulatorStorage.getSimulator("DefaultSimulator");
+ Class<?> clazz = simulator.getCodeClass();
+ Set<String> deps = DependencyUtil.extractDependencies(clazz, false);
+ Assert.assertTrue(deps.size() >= 35);
+ Assert.assertTrue(deps.contains("scripts.GravityModel"));
+ Assert.assertTrue(deps.contains("scripts.ResultName"));
+ Assert.assertTrue(deps.contains("scripts.SiMatrix"));
+
+ }
+
+ /**
+ * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien
+ * extraites.
+ *
+ * @throws IsisFishException
+ */
+ @Test
+ public void testExtractDependencies3() throws IsisFishException {
+ RuleStorage cantonnement = RuleStorage.getRule("Cantonnement");
+ Class<?> clazz = cantonnement.getCodeClass();
+ Set<String> deps = DependencyUtil.extractDependencies(clazz, false);
+ Assert.assertTrue(deps.size() >= 30);
+ Assert.assertTrue(deps.contains("scripts.ResultName"));
+ }
+
+ /**
+ * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien
+ * extraites.
+ *
+ * @throws IsisFishException
+ */
+ @Test
+ public void testExtractDependencies4() throws IsisFishException {
+ ScriptStorage script = ScriptStorage.getScript("SiMatrix");
+ Class<?> clazz = script.getCodeClass();
+ Set<String> deps = DependencyUtil.extractDependencies(clazz, false);
+ Assert.assertTrue(deps.size() >= 51);
+ Assert.assertTrue(deps.contains("scripts.ObjectiveFunctionBaranov"));
+ Assert.assertTrue(deps.contains("scripts.ObjectiveFunction"));
+ Assert.assertTrue(deps.contains("scripts.MinimisationUtil"));
+ Assert.assertTrue(deps.contains("scripts.ResultName"));
+ }
+
+ /**
+ * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien
+ * extraites.
+ *
+ * @throws IsisFishException
+ */
+ @Test
+ public void testExtractDependencies5() throws IsisFishException {
+ ScriptStorage script = ScriptStorage.getScript("GravityModel");
+ Class<?> clazz = script.getCodeClass();
+ Set<String> deps = DependencyUtil.extractDependencies(clazz, false);
+ Assert.assertTrue(deps.size() >= 31);
+ Assert.assertTrue(deps.contains("scripts.SiMatrix"));
+ Assert.assertTrue(deps.contains("scripts.ResultName"));
+ }
+
+ /**
+ * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien
+ * extraites.
+ *
+ * @throws IsisFishException
+ */
+ @Test
+ public void testExtractDependencies6() throws IsisFishException {
+ ScriptStorage script = ScriptStorage.getScript("ObjectiveFunctionBaranov");
+ Class<?> clazz = script.getCodeClass();
+ Set<String> deps = DependencyUtil.extractDependencies(clazz, false);
+ Assert.assertTrue(deps.size() >= 4);
+ Assert.assertTrue(deps.contains("scripts.ObjectiveFunction"));
+ Assert.assertTrue(deps.contains("fr.ifremer.isisfish.util.Nocache"));
+ }
+}
Property changes on: branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/util/DependencyUtilTest.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r4103 - branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/entity
by echatellier@users.forge.codelutin.com 29 Aug '14
by echatellier@users.forge.codelutin.com 29 Aug '14
29 Aug '14
Author: echatellier
Date: 2014-08-29 10:58:39 +0200 (Fri, 29 Aug 2014)
New Revision: 4103
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4103
Log:
Remove useless hamcrest complicated code
Modified:
branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/entity/TopiaDAOTest.java
Modified: branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/entity/TopiaDAOTest.java
===================================================================
--- branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/entity/TopiaDAOTest.java 2014-08-28 15:52:19 UTC (rev 4102)
+++ branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/entity/TopiaDAOTest.java 2014-08-29 08:58:39 UTC (rev 4103)
@@ -3,7 +3,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 2014 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -26,7 +26,6 @@
import java.io.IOException;
import java.util.List;
-import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
@@ -84,7 +83,7 @@
population2.setName("thon");
allPopulation = populationDAO.findAll();
Assert.assertEquals(2, allPopulation.size());
- Assert.assertThat(allPopulation, CoreMatchers.hasItem(population2));
+ Assert.assertTrue(allPopulation.contains(population2));
context.rollbackTransaction();
@@ -93,7 +92,7 @@
population3.setName("requin");
allPopulation = populationDAO.findAll();
Assert.assertEquals(2, allPopulation.size());
- Assert.assertThat(allPopulation, CoreMatchers.hasItem(population3));
+ Assert.assertTrue(allPopulation.contains(population3));
context.commitTransaction();
simulation.closeStorage();
1
0
r4102 - in branches/4.3.0-log4j2: . src/main/assembly
by echatellier@users.forge.codelutin.com 28 Aug '14
by echatellier@users.forge.codelutin.com 28 Aug '14
28 Aug '14
Author: echatellier
Date: 2014-08-28 17:52:19 +0200 (Thu, 28 Aug 2014)
New Revision: 4102
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4102
Log:
Fix assembly and default memory
Added:
branches/4.3.0-log4j2/src/main/assembly/isisfish-log4j2.xml
Removed:
branches/4.3.0-log4j2/src/main/assembly/isisfish-log4j.properties
Modified:
branches/4.3.0-log4j2/pom.xml
branches/4.3.0-log4j2/src/main/assembly/bin.xml
branches/4.3.0-log4j2/src/main/assembly/isisfish.bat
branches/4.3.0-log4j2/src/main/assembly/isisfish.sh
Modified: branches/4.3.0-log4j2/pom.xml
===================================================================
--- branches/4.3.0-log4j2/pom.xml 2014-08-28 14:25:25 UTC (rev 4101)
+++ branches/4.3.0-log4j2/pom.xml 2014-08-28 15:52:19 UTC (rev 4102)
@@ -364,7 +364,7 @@
<!-- ************************************************************* -->
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>IsisFish</name>
+ <name>ISIS-Fish</name>
<description>Simulateur de pecherie complexe.</description>
<inceptionYear>1999</inceptionYear>
Modified: branches/4.3.0-log4j2/src/main/assembly/bin.xml
===================================================================
--- branches/4.3.0-log4j2/src/main/assembly/bin.xml 2014-08-28 14:25:25 UTC (rev 4101)
+++ branches/4.3.0-log4j2/src/main/assembly/bin.xml 2014-08-28 15:52:19 UTC (rev 4102)
@@ -6,7 +6,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 1999 - 2013 Ifremer, CodeLutin, Eric Chatellier
+ Copyright (C) 1999 - 2014 Ifremer, CodeLutin, Eric Chatellier
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -60,7 +60,7 @@
<directory>src/main/assembly</directory>
<outputDirectory />
<includes>
- <include>isisfish-log4j.properties</include>
+ <include>isisfish-log4j.xml</include>
</includes>
</fileSet>
</fileSets>
Deleted: branches/4.3.0-log4j2/src/main/assembly/isisfish-log4j.properties
===================================================================
--- branches/4.3.0-log4j2/src/main/assembly/isisfish-log4j.properties 2014-08-28 14:25:25 UTC (rev 4101)
+++ branches/4.3.0-log4j2/src/main/assembly/isisfish-log4j.properties 2014-08-28 15:52:19 UTC (rev 4102)
@@ -1,45 +0,0 @@
-###
-# #%L
-# IsisFish
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2011 - 2013 Ifremer, CodeLutin, Chatellier Eric
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/gpl-3.0.html>.
-# #L%
-###
-# Global logging configuration
-log4j.rootLogger=ERROR, stdout
-
-# Console output...
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-
-# Package level
-log4j.logger.fr.ifremer.isisfish=INFO
-log4j.logger.analyseplans=INFO
-log4j.logger.exports=INFO
-log4j.logger.formules=INFO
-log4j.logger.rules=INFO
-log4j.logger.scripts=INFO
-log4j.logger.sensitivity=INFO
-log4j.logger.sensitivityexports=INFO
-log4j.logger.simulators=INFO
-
-# Add your configuration here
-#log4j.logger.org.nuiton.j2r=DEBUG
Added: branches/4.3.0-log4j2/src/main/assembly/isisfish-log4j2.xml
===================================================================
--- branches/4.3.0-log4j2/src/main/assembly/isisfish-log4j2.xml (rev 0)
+++ branches/4.3.0-log4j2/src/main/assembly/isisfish-log4j2.xml 2014-08-28 15:52:19 UTC (rev 4102)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ IsisFish
+ %%
+ Copyright (C) 1999 - 2014 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+
+<!-- To use this file, add "-Dlog4j.configurationFile=isisfish-log4j2.xml" on command line -->
+<Configuration packages="fr.ifremer.isisfish.logging" strict="true">
+
+ <Filters>
+ <SimulationThresholdFilter onMatch="ACCEPT" onMismatch="NEUTRAL" />
+ </Filters>
+
+ <Appenders>
+
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%5p [%t] (%F:%L) %M - %m%n" />
+ </Console>
+
+ <Routing name="SimulationSpecificAppender">
+ <Routes pattern="$${ctx:simulationId}">
+
+ <!-- This route is chosen if ThreadContext has no value for key simulationId. -->
+ <Route key="${ctx:simulationId}">
+ <Null name="Null" />
+ </Route>
+
+ <!-- This route is chosen if ThreadContext has a value for simulationId
+ The value dynamically determines the name of the log file. -->
+ <Route>
+ <File name="SimulationFileAppender-${ctx:simulationId}" fileName="${ctx:simulationLogFile}">
+ <PatternLayout>
+ <Pattern>%p|%d{ABSOLUTE}|%F|%L|%M|%m%n</Pattern>
+ </PatternLayout>
+ </File>
+ </Route>
+ </Routes>
+ </Routing>
+ </Appenders>
+
+ <Loggers>
+ <Logger name="fr.ifremer.isisfish" level="info"/>
+ <Logger name="org.nuiton" level="warn"/>
+ <Logger name="exports" level="info"/>
+ <Logger name="formules" level="info"/>
+ <Logger name="objectives" level="info"/>
+ <Logger name="optimizations" level="info"/>
+ <Logger name="rules" level="info"/>
+ <Logger name="scripts" level="info"/>
+ <Logger name="sensitivityanalysis" level="info"/>
+ <Logger name="sensitivityexports" level="info"/>
+ <Logger name="simulationplans" level="info"/>
+ <Logger name="simulators" level="info"/>
+
+ <Root level="error">
+ <AppenderRef ref="Console" />
+ <AppenderRef ref="SimulationSpecificAppender" />
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
Property changes on: branches/4.3.0-log4j2/src/main/assembly/isisfish-log4j2.xml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/4.3.0-log4j2/src/main/assembly/isisfish.bat
===================================================================
--- branches/4.3.0-log4j2/src/main/assembly/isisfish.bat 2014-08-28 14:25:25 UTC (rev 4101)
+++ branches/4.3.0-log4j2/src/main/assembly/isisfish.bat 2014-08-28 15:52:19 UTC (rev 4102)
@@ -1,8 +1,8 @@
@echo off
rem Uncomment following 2 lines to easy configure R for ISIS-Fish
-rem SET R_HOME=C:\Program Files\R\R-3.0.0
+rem SET R_HOME=C:\Program Files\R\R-3.1.0
rem SET PATH=%PATH%;%R_HOME%\bin\i386
echo [Script] Isis starting...
-java -Xmx900M -jar ${project.build.finalName}.${project.packaging} %1 %2 %3 %4 %5 %6 %7 %8 %9 > debug.txt 2>&1
+java -Xmx2048M -jar ${project.build.finalName}.${project.packaging} %1 %2 %3 %4 %5 %6 %7 %8 %9 > debug.txt 2>&1
Modified: branches/4.3.0-log4j2/src/main/assembly/isisfish.sh
===================================================================
--- branches/4.3.0-log4j2/src/main/assembly/isisfish.sh 2014-08-28 14:25:25 UTC (rev 4101)
+++ branches/4.3.0-log4j2/src/main/assembly/isisfish.sh 2014-08-28 15:52:19 UTC (rev 4102)
@@ -1,5 +1,5 @@
#!/bin/bash
-MEMORY="-Xmx1024M"
+MEMORY="-Xmx2048M"
java $MEMORY -jar ${project.build.finalName}.${project.packaging} $* &> debug.txt
1
0
r4101 - in branches/4.3.0-log4j2: . src/main/assembly src/main/java/fr/ifremer/isisfish src/main/java/fr/ifremer/isisfish/util src/test/java/fr/ifremer/isisfish
by echatellier@users.forge.codelutin.com 28 Aug '14
by echatellier@users.forge.codelutin.com 28 Aug '14
28 Aug '14
Author: echatellier
Date: 2014-08-28 16:25:25 +0200 (Thu, 28 Aug 2014)
New Revision: 4101
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4101
Log:
Use jri installed by R with rJava R package.
Added:
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/RUtil.java
Modified:
branches/4.3.0-log4j2/pom.xml
branches/4.3.0-log4j2/src/main/assembly/isisfish.bat
branches/4.3.0-log4j2/src/main/assembly/isisfish.sh
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisFish.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/JavadocHelper.java
branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java
Modified: branches/4.3.0-log4j2/pom.xml
===================================================================
--- branches/4.3.0-log4j2/pom.xml 2014-08-27 14:00:36 UTC (rev 4100)
+++ branches/4.3.0-log4j2/pom.xml 2014-08-28 14:25:25 UTC (rev 4101)
@@ -66,7 +66,15 @@
<scope>compile</scope>
</dependency>
+ <!-- Temp update for log4j 2 detection -->
<dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging</artifactId>
+ <version>3.2.0.Beta1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-profiling</artifactId>
<version>3.0</version>
Modified: branches/4.3.0-log4j2/src/main/assembly/isisfish.bat
===================================================================
--- branches/4.3.0-log4j2/src/main/assembly/isisfish.bat 2014-08-27 14:00:36 UTC (rev 4100)
+++ branches/4.3.0-log4j2/src/main/assembly/isisfish.bat 2014-08-28 14:25:25 UTC (rev 4101)
@@ -5,4 +5,4 @@
rem SET PATH=%PATH%;%R_HOME%\bin\i386
echo [Script] Isis starting...
-java -Xmx900M -Djri.load.classpath.libs=true -jar ${project.build.finalName}.${project.packaging} %1 %2 %3 %4 %5 %6 %7 %8 %9 > debug.txt 2>&1
+java -Xmx900M -jar ${project.build.finalName}.${project.packaging} %1 %2 %3 %4 %5 %6 %7 %8 %9 > debug.txt 2>&1
Modified: branches/4.3.0-log4j2/src/main/assembly/isisfish.sh
===================================================================
--- branches/4.3.0-log4j2/src/main/assembly/isisfish.sh 2014-08-27 14:00:36 UTC (rev 4100)
+++ branches/4.3.0-log4j2/src/main/assembly/isisfish.sh 2014-08-28 14:25:25 UTC (rev 4101)
@@ -2,4 +2,4 @@
MEMORY="-Xmx1024M"
-java $MEMORY -Djri.load.classpath.libs=true -jar ${project.build.finalName}.${project.packaging} $* &> debug.txt
+java $MEMORY -jar ${project.build.finalName}.${project.packaging} $* &> debug.txt
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisFish.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisFish.java 2014-08-27 14:00:36 UTC (rev 4100)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisFish.java 2014-08-28 14:25:25 UTC (rev 4101)
@@ -83,6 +83,7 @@
import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.util.IsisCache;
import fr.ifremer.isisfish.util.IsisMatrixSemanticMapper;
+import fr.ifremer.isisfish.util.RUtil;
import fr.ifremer.isisfish.vcs.VCS;
import fr.ifremer.isisfish.vcs.VCSActionEvent;
import fr.ifremer.isisfish.vcs.VCSException;
@@ -120,16 +121,10 @@
}
public static void main(String... args) throws Exception {
-
- // TODO as of 20140720, hibernate fails to detect log4j 2.0, force slf4j
- System.setProperty("org.jboss.logging.provider", "slf4j");
-
+
// permet de faire fonctionner la compilation en webstart
System.setSecurityManager(null);
- // set Rtype in jni mode
- System.setProperty("R.type", "jni");
-
// initialisation de l'application
init(args);
@@ -143,6 +138,9 @@
log.info("PATH: " + System.getenv("PATH"));
}
+ // init R way for isis
+ RUtil.initJri();
+
// action after init
config.doAction(IsisConfig.STEP_AFTER_INIT);
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/JavadocHelper.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/JavadocHelper.java 2014-08-27 14:00:36 UTC (rev 4100)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/JavadocHelper.java 2014-08-28 14:25:25 UTC (rev 4101)
@@ -39,7 +39,6 @@
import java.util.List;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.reflect.MethodUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.FileUtil;
Added: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/RUtil.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/RUtil.java (rev 0)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/RUtil.java 2014-08-28 14:25:25 UTC (rev 4101)
@@ -0,0 +1,137 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2006 - 2012 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.util.List;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Utility class fo R integration with isis fish.
+ *
+ * @author Eric Chatellier
+ */
+public class RUtil {
+
+ private static final Log log = LogFactory.getLog(RUtil.class);
+
+ /**
+ * Try to call "R" process to get location where jri is installed.
+ */
+ public static void initJri() {
+
+ // set Rtype in jni mode
+ System.setProperty("R.type", "jni");
+
+ try {
+ ProcessBuilder pb = new ProcessBuilder("Rscript", "-e", "installed.packages()[which(installed.packages()[,1]=='rJava'),]['LibPath']");
+ Process process = pb.start();
+ int exitValue = process.waitFor();
+
+ if (exitValue == 0) {
+ // normal exit
+ parseRscriptOutput(process.getInputStream());
+ } else {
+ // R trouvé, mais la commande R a échoué
+ InputStream err = process.getErrorStream();
+ if (log.isErrorEnabled()) {
+ log.error("Can't call Rscript : " + IOUtils.toString(err));
+ }
+ }
+ } catch (IOException ex) {
+ // Le processus n'a pas pu être lancé (R non trouvé)
+ if (log.isDebugEnabled()) {
+ log.debug("Can't find R", ex);
+ }
+ } catch (InterruptedException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't find R", ex);
+ }
+ }
+ }
+
+ /**
+ * Parse valid Rscript output to find if rJava is installed and where it is installed.
+ *
+ * @param is process output
+ * @throws IOException
+ */
+ protected static void parseRscriptOutput(InputStream is) throws IOException {
+ List<String> output = IOUtils.readLines(is);
+
+ // 1 lignes = commande OK, mais rJava n'est pas installé
+ // 2 lignes = commande OK et rJava est installé
+ if (output.size() == 1) {
+ //installRJava();
+ } else if (output.size() == 2) {
+ // get install location without ""
+ String location = output.get(1).trim();
+ location = StringUtils.removeStart(location, "\"");
+ location = StringUtils.removeEnd(location, "\"");
+ // build full library path
+ location = location.replace('/', File.separatorChar);
+ location += File.separator + "rJava" + File.separator + "jri";
+ setJavaLibraryPath(location);
+ } else if (log.isErrorEnabled()) {
+ log.error("Can't analyze Rscript output. was: ");
+ for (String line : output) {
+ log.error(line);
+ }
+ }
+ }
+
+ /**
+ * Set runtime java library path.
+ *
+ * http://fahdshariff.blogspot.fr/2011/08/changing-java-library-path-at-runtim…
+ *
+ * @param newValue new value to set
+ */
+ protected static void setJavaLibraryPath(String newValue) {
+ if (log.isInfoEnabled()) {
+ log.info("Adding '" + newValue + "' to java.library.path");
+ }
+ System.setProperty("java.library.path", newValue);
+
+ //set sys_paths to null
+ try {
+ final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths");
+ sysPathsField.setAccessible(true);
+ sysPathsField.set(null, null);
+ } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Cant' reset ClassLoader#sys_paths value", ex);
+ }
+ }
+ }
+}
Property changes on: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/RUtil.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java
===================================================================
--- branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java 2014-08-27 14:00:36 UTC (rev 4100)
+++ branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java 2014-08-28 14:25:25 UTC (rev 4101)
@@ -86,9 +86,6 @@
@BeforeClass
public static void init() throws Exception {
- // TODO as of 20140720, hibernate fails to detect log4j 2.0, force slf4j
- System.setProperty("org.jboss.logging.provider", "slf4j");
-
File mavenTestDir = getTestDirectory();
dirIsisBase = FileUtil.createTempDirectory("isisdbtest", "", mavenTestDir);
1
0
r4100 - in branches/4.3.0-log4j2: . src/main/java/fr/ifremer/isisfish src/main/java/fr/ifremer/isisfish/datastore src/main/java/fr/ifremer/isisfish/vcs src/main/resources src/test/java/fr/ifremer/isisfish/vcs
by echatellier@users.forge.codelutin.com 27 Aug '14
by echatellier@users.forge.codelutin.com 27 Aug '14
27 Aug '14
Author: echatellier
Date: 2014-08-27 16:00:36 +0200 (Wed, 27 Aug 2014)
New Revision: 4100
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4100
Log:
fixes #5688: Extract static version to properties file
Added:
branches/4.3.0-log4j2/src/main/resources/isis-config-4
Modified:
branches/4.3.0-log4j2/pom.xml
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisFish.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCS.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java
branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java
Modified: branches/4.3.0-log4j2/pom.xml
===================================================================
--- branches/4.3.0-log4j2/pom.xml 2014-08-27 13:06:43 UTC (rev 4099)
+++ branches/4.3.0-log4j2/pom.xml 2014-08-27 14:00:36 UTC (rev 4100)
@@ -20,7 +20,7 @@
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
- <version>3.0-rc-7</version>
+ <version>3.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
@@ -514,6 +514,23 @@
</distributionManagement>
<build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>isis-config-4</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <excludes>
+ <exclude>isis-config-4</exclude>
+ </excludes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+
<pluginManagement>
<plugins>
<plugin>
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2014-08-27 13:06:43 UTC (rev 4099)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2014-08-27 14:00:36 UTC (rev 4100)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2002 - 2012 Ifremer, Code Lutin, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2002 - 2014 Ifremer, Code Lutin, Benjamin Poussin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -45,12 +45,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.config.ApplicationConfig;
+import org.nuiton.config.ArgumentsParserException;
import org.nuiton.config.ConfigOptionDef;
-import org.nuiton.converter.ConverterUtil;
import org.nuiton.math.matrix.DoubleBigVector;
import org.nuiton.math.matrix.DoubleSparseHashVector;
import org.nuiton.util.StringUtil;
-import org.nuiton.util.Version;
+import org.nuiton.util.version.Version;
+import org.nuiton.util.version.Versions;
import fr.ifremer.isisfish.actions.ExportAction;
import fr.ifremer.isisfish.actions.ImportAction;
@@ -82,6 +83,9 @@
/** Class logger. */
static private Log log = LogFactory.getLog(IsisConfig.class);
+ /** Numero de version majeure d'isis fish. */
+ public static final int ISIS_FISH_MAJOR_VERSION = 4;
+
/**
* Config step after init.
*
@@ -128,18 +132,10 @@
* migration de donnees demande automatiquement un changement de version
* d'application.
*/
- protected final static Version version = new Version(4, 3, 2, 0);
+ protected static Version version;
+ protected static Version databaseVersion;
+ protected static Version apiVersion;
- protected final static Version majorVersion = new Version(version.getNumber(0));
- protected final static Version databaseVersion = new Version(
- version.getNumber(0), version.getNumber(1));
- protected final static Version apiVersion = new Version(
- version.getNumber(0), version.getNumber(1), version.getNumber(2));
-
- public static Version getVersionNumber() {
- return version;
- }
-
/**
* Le nombre global ex: 3.2.0.0
*
@@ -168,9 +164,6 @@
return apiVersion;
}
- static final public String COPYRIGHT_TEXT = "Version " + getVersion() + " IFREMER-MAERHA © 2000-2014";
- static final public String CONFIG_FILENAME = "isis-config-" + majorVersion.toString();
-
/** separateur de liste */
static final public String SEP = ",";
@@ -200,6 +193,26 @@
}
}
}
+
+ @Override
+ public ApplicationConfig parse(String... args) throws ArgumentsParserException {
+ ApplicationConfig config = super.parse(args);
+ postInitWithVersion(config.getOption("isisfish.version"));
+ return config;
+ }
+
+ /**
+ * Initialize avec des valeurs par defaut des options dans la valeur dépend de la version.
+ *
+ * @param fullVersion full version (ex 4.3.1.9)
+ */
+ protected void postInitWithVersion(String fullVersion) {
+ IsisConfig.version = Versions.valueOf(fullVersion);
+ IsisConfig.databaseVersion = Versions.extractVersion(IsisConfig.version, 0, 1);
+ IsisConfig.apiVersion = Versions.extractVersion(IsisConfig.version, 0, 2);
+
+ setDefaultOption(Option.SIMULATOR_SSH_ISIS_HOME.key, "/home3/caparmor/poussin/isis-fish-" + apiVersion.toString());
+ }
//////////////////////////////////////////////////
// Methode d'acces aux options
@@ -1078,8 +1091,8 @@
*/
public static enum Option implements ConfigOptionDef {
- CONFIG_FILE(CONFIG_FILE_NAME, n("isisfish.config.main.configFileName.description"), CONFIG_FILENAME),
- ISIS_HOME_DIRECTORY("isis.home.directory", n("isisfish.config.main.compileDirectory.description"), getUserHome() + File.separator + "isis-fish-" + majorVersion.toString()),
+ CONFIG_FILE(CONFIG_FILE_NAME, n("isisfish.config.main.configFileName.description"), "isis-config-" + ISIS_FISH_MAJOR_VERSION),
+ ISIS_HOME_DIRECTORY("isis.home.directory", n("isisfish.config.main.compileDirectory.description"), getUserHome() + File.separator + "isis-fish-" + ISIS_FISH_MAJOR_VERSION),
COMPILATION_DIRECTORY("compilation.directory", n("isisfish.config.main.compileDirectory.description"), "${isis.home.directory}" + File.separator + "isis-build"),
MONITORING_DIRECTORY("monitoring.directory", n("isisfish.config.main.monitoringDirectory.description"), "${isis.home.directory}" + File.separator + "isis-monitoring"),
JAVADOC_DIRECTORY("javadoc.directory", n("isisfish.config.main.javadocDirectory.description"), "${isis.home.directory}" + File.separator + "isis-docs"),
@@ -1122,9 +1135,9 @@
/** Serveur accessible par ssh : user home directory */
SIMULATOR_SSH_USER_HOME("simulation.ssh.userhome", n("isisfish.config.main.simulation.ssh.userhome.description"), ""),
/** Serveur accessible par ssh : remote data path */
- SIMULATOR_SSH_DATAPATH("simulation.ssh.datapath", n("isisfish.config.main.simulation.ssh.datapath.description"), "isis-fish-" + majorVersion.toString() + "/isis-database"),
+ SIMULATOR_SSH_DATAPATH("simulation.ssh.datapath", n("isisfish.config.main.simulation.ssh.datapath.description"), "isis-fish-4/isis-database"),
/** Serveur accessible par ssh : remote isis home install */
- SIMULATOR_SSH_ISIS_HOME("simulation.ssh.isis.home", n("isisfish.config.main.simulation.ssh.isis.home.description"), "/home3/caparmor/poussin/isis-fish-" + IsisConfig.getApiVersion()),
+ SIMULATOR_SSH_ISIS_HOME("simulation.ssh.isis.home", n("isisfish.config.main.simulation.ssh.isis.home.description"), null),
/** Serveur accessible par ssh : remote tmp path */
SIMULATOR_SSH_TMPPATH("simulation.ssh.tmppath", n("isisfish.config.main.simulation.ssh.tmppath.description"), "isis-tmp"),
/** Serveur accessible par SSH : emplacement de Java (full path) */
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisFish.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisFish.java 2014-08-27 13:06:43 UTC (rev 4099)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisFish.java 2014-08-27 14:00:36 UTC (rev 4100)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2005 - 2013 Ifremer, CodeLutin, Chatellier Eric
+ * Copyright (C) 2005 - 2014 Ifremer, CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -58,7 +58,7 @@
import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.math.matrix.MatrixFactory;
import org.nuiton.topia.TopiaException;
-import org.nuiton.util.Version;
+import org.nuiton.util.version.Version;
import org.nuiton.widget.SwingSession;
import com.bbn.openmap.MapBean;
@@ -130,6 +130,9 @@
// set Rtype in jni mode
System.setProperty("R.type", "jni");
+ // initialisation de l'application
+ init(args);
+
// i18n is not inited here
if (log.isInfoEnabled()) {
log.info("Starting Isis-Fish " + IsisConfig.getVersion() + " with args : " + java.util.Arrays.toString(args));
@@ -140,13 +143,6 @@
log.info("PATH: " + System.getenv("PATH"));
}
- // initialisation de l'application
- init(args);
-
- if (log.isDebugEnabled()) {
- log.debug(t("isisfish.launch.init.done", config.getElapsedTimeAsString()));
- }
-
// action after init
config.doAction(IsisConfig.STEP_AFTER_INIT);
@@ -181,6 +177,13 @@
}
/**
+ * Initialize isis fish version from properties files.
+ */
+ protected static void initVersion() {
+
+ }
+
+ /**
* Start cron service (if enabled).
*/
protected static void startCronService() {
@@ -256,6 +259,10 @@
// after init shutdown hook
Runtime.getRuntime().addShutdownHook(new IsisQuitHook());
+
+ if (log.isDebugEnabled()) {
+ log.debug(t("isisfish.launch.init.done", config.getElapsedTimeAsString()));
+ }
}
/**
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2014-08-27 13:06:43 UTC (rev 4099)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2014-08-27 14:00:36 UTC (rev 4100)
@@ -37,7 +37,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.ListenerSet;
-import org.nuiton.util.Version;
+import org.nuiton.util.version.Version;
import fr.ifremer.isisfish.IsisConfig;
import fr.ifremer.isisfish.IsisFish;
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCS.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCS.java 2014-08-27 13:06:43 UTC (rev 4099)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCS.java 2014-08-27 14:00:36 UTC (rev 4100)
@@ -30,7 +30,7 @@
import java.util.List;
import java.util.Map;
-import org.nuiton.util.Version;
+import org.nuiton.util.version.Version;
/**
* Version control system.
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java 2014-08-27 13:06:43 UTC (rev 4099)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java 2014-08-27 14:00:36 UTC (rev 4100)
@@ -31,7 +31,7 @@
import java.util.List;
import java.util.Map;
-import org.nuiton.util.Version;
+import org.nuiton.util.version.Version;
/**
* VCSNone (svn or vcs) must extends this class. This class can be used as dummy
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java 2014-08-27 13:06:43 UTC (rev 4099)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java 2014-08-27 14:00:36 UTC (rev 4100)
@@ -40,7 +40,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.Version;
+import org.nuiton.util.version.Version;
import org.tmatesoft.svn.core.ISVNDirEntryHandler;
import org.tmatesoft.svn.core.ISVNLogEntryHandler;
import org.tmatesoft.svn.core.SVNCommitInfo;
Added: branches/4.3.0-log4j2/src/main/resources/isis-config-4
===================================================================
--- branches/4.3.0-log4j2/src/main/resources/isis-config-4 (rev 0)
+++ branches/4.3.0-log4j2/src/main/resources/isis-config-4 2014-08-27 14:00:36 UTC (rev 4100)
@@ -0,0 +1 @@
+isisfish.version=${project.version}
Modified: branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java
===================================================================
--- branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java 2014-08-27 13:06:43 UTC (rev 4099)
+++ branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java 2014-08-27 14:00:36 UTC (rev 4100)
@@ -37,7 +37,8 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.Version;
+import org.nuiton.util.version.Version;
+import org.nuiton.util.version.Versions;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -326,7 +327,7 @@
vcs.add(Arrays.asList(fileToAdd), "ajout d'un fichier");
// test switchTag
- vcs.setTag(new Version(3, 1, 0));
+ vcs.setTag(Versions.valueOf("3.1.0"));
Assert.assertTrue(vcs.getTag().startsWith("/tags/3.1.0"));
Assert.assertEquals(FILECONTENTTAG, FileUtils.readFileToString(version));
Assert.assertTrue(demo.exists());
@@ -890,10 +891,10 @@
log.info("testGetDiff()");
}
- Version version = new Version(3, 1, 0);
+ Version version = Versions.valueOf("3.1.0");
Assert.assertTrue(vcs.isTag(version));
- version = new Version(3, 2, 0);
+ version = Versions.valueOf("3.2.0");
Assert.assertFalse(vcs.isTag(version));
}
@@ -1144,7 +1145,7 @@
}
// chechout tags
- vcs.checkout(new Version(3, 1, 0), false);
+ vcs.checkout(Versions.valueOf("3.1.0"), false);
// modif on remote repo on tag :)
File file = new File(vcs.getLocalRepository(), "scripts"
@@ -1173,7 +1174,7 @@
FileUtils.writeStringToFile(file2, "oooooo");
// try to update...
- List<File> filesInConflict = vcs.setTag(new Version(3, 1, 0));
+ List<File> filesInConflict = vcs.setTag(Versions.valueOf("3.1.0"));
Assert.assertNotNull(filesInConflict);
Assert.assertEquals(1, filesInConflict.size());
log.debug("Conflicts are : " + filesInConflict);
1
0
Author: echatellier
Date: 2014-08-27 15:06:43 +0200 (Wed, 27 Aug 2014)
New Revision: 4099
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4099
Log:
Update libs
Modified:
branches/4.3.0-log4j2/pom.xml
Modified: branches/4.3.0-log4j2/pom.xml
===================================================================
--- branches/4.3.0-log4j2/pom.xml 2014-08-21 15:44:13 UTC (rev 4098)
+++ branches/4.3.0-log4j2/pom.xml 2014-08-27 13:06:43 UTC (rev 4099)
@@ -20,16 +20,9 @@
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
- <version>3.0-rc-6</version>
+ <version>3.0-rc-7</version>
<scope>compile</scope>
</dependency>
-
- <!-- <dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-converter</artifactId>
- <version>1.0</version>
- <scope>compile</scope>
- </dependency> -->
<dependency>
<groupId>org.nuiton</groupId>
@@ -311,7 +304,7 @@
<!-- ssj pour les calculs stockastiques -->
<dependency>
- <groupId>ssj</groupId>
+ <groupId>ca.umontreal.iro</groupId>
<artifactId>ssj</artifactId>
<version>2.5</version>
<scope>runtime</scope>
@@ -343,7 +336,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>17.0</version>
+ <version>18.0</version>
</dependency>
<!-- Tests -->
@@ -492,7 +485,7 @@
<signatureVersion>1.0</signatureVersion>
<!-- Dependencies version -->
- <jaxxVersion>2.10</jaxxVersion>
+ <jaxxVersion>2.11</jaxxVersion>
<eugeneVersion>2.13</eugeneVersion>
<topiaVersion>2.9.2</topiaVersion>
<hibernateVersion>4.3.6.Final</hibernateVersion>
1
0
r4098 - in branches/4.3.0-log4j2: . src/main/java/fr/ifremer/isisfish src/main/java/fr/ifremer/isisfish/entities src/main/java/fr/ifremer/isisfish/map src/main/java/fr/ifremer/isisfish/simulator src/main/java/fr/ifremer/isisfish/ui/input src/main/java/fr/ifremer/isisfish/ui/input/check src/main/java/fr/ifremer/isisfish/ui/input/model src/main/resources src/main/xmi src/test/java/fr/ifremer/isisfish src/test/resources/test-database/rules
by echatellier@users.forge.codelutin.com 21 Aug '14
by echatellier@users.forge.codelutin.com 21 Aug '14
21 Aug '14
Author: echatellier
Date: 2014-08-21 17:44:13 +0200 (Thu, 21 Aug 2014)
New Revision: 4098
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4098
Log:
Update libs (topia...)
Removed:
branches/4.3.0-log4j2/src/main/resources/log4j.properties
Modified:
branches/4.3.0-log4j2/pom.xml
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationSeasonInfoImpl.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/StrategyImpl.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/TargetSpeciesImpl.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesStructuredUI.jaxx
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckRegion.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java
branches/4.3.0-log4j2/src/main/resources/log4j2.xml
branches/4.3.0-log4j2/src/main/resources/sensitivity.properties
branches/4.3.0-log4j2/src/main/xmi/isis-fish.properties
branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java
branches/4.3.0-log4j2/src/test/resources/test-database/rules/TACpoids.java
Modified: branches/4.3.0-log4j2/pom.xml
===================================================================
--- branches/4.3.0-log4j2/pom.xml 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/pom.xml 2014-08-21 15:44:13 UTC (rev 4098)
@@ -11,7 +11,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>isis-fish</artifactId>
- <version>4.3.1.1-SNAPSHOT</version>
+ <version>4.3.2.0-SNAPSHOT</version>
<!-- POM Relationships : Inheritance : Dependencies -->
<dependencies>
@@ -20,35 +20,29 @@
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
- <version>3.0-rc-4</version>
+ <version>3.0-rc-6</version>
<scope>compile</scope>
</dependency>
- <dependency>
+ <!-- <dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-converter</artifactId>
<version>1.0</version>
<scope>compile</scope>
- </dependency>
-
+ </dependency> -->
+
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-config</artifactId>
- <version>3.0-alpha-3</version>
+ <version>3.0-rc-1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-validator</artifactId>
- <version>3.0-rc-1</version>
+ <version>3.0-rc-2</version>
<scope>compile</scope>
- <exclusions>
- <exclusion>
- <artifactId>javassist</artifactId>
- <groupId>javassist</groupId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
@@ -63,12 +57,6 @@
<artifactId>topia-persistence</artifactId>
<version>${topiaVersion}</version>
<scope>compile</scope>
- <exclusions>
- <exclusion>
- <artifactId>javassist</artifactId>
- <groupId>javassist</groupId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
@@ -210,7 +198,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
- <version>1.3.2</version>
+ <version>1.3.3</version>
<exclusions>
<exclusion>
<artifactId>activation</artifactId>
@@ -238,6 +226,13 @@
<version>2.0.2</version>
<scope>compile</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>2.0.2</version>
+ <scope>compile</scope>
+ </dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
@@ -305,7 +300,7 @@
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
- <version>1.8.1</version>
+ <version>1.8.2</version>
</dependency>
<dependency>
@@ -497,11 +492,11 @@
<signatureVersion>1.0</signatureVersion>
<!-- Dependencies version -->
- <jaxxVersion>2.8.7</jaxxVersion>
- <eugeneVersion>2.7.4</eugeneVersion>
- <topiaVersion>2.9.1</topiaVersion>
+ <jaxxVersion>2.10</jaxxVersion>
+ <eugeneVersion>2.13</eugeneVersion>
+ <topiaVersion>2.9.2</topiaVersion>
<hibernateVersion>4.3.6.Final</hibernateVersion>
- <nuitonI18nVersion>3.2</nuitonI18nVersion>
+ <nuitonI18nVersion>3.3</nuitonI18nVersion>
<nuitonWidgetsVersion>1.1.1</nuitonWidgetsVersion>
<redmine.releaseFiles>target/isis-fish-${project.version}-bin.zip</redmine.releaseFiles>
@@ -540,10 +535,10 @@
<version>${jaxxVersion}</version>
<dependencies>
<dependency>
- <groupId>org.nuiton.i18n</groupId>
- <artifactId>nuiton-i18n</artifactId>
- <version>${nuitonI18nVersion}</version>
- <scope>compile</scope>
+ <groupId>com.fifesoft</groupId>
+ <artifactId>rsyntaxtextarea</artifactId>
+ <version>2.5.0</version>
+ <scope>compile</scope>
</dependency>
</dependencies>
</plugin>
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2014-08-21 15:44:13 UTC (rev 4098)
@@ -128,7 +128,7 @@
* migration de donnees demande automatiquement un changement de version
* d'application.
*/
- protected final static Version version = new Version(4, 3, 1, 1);
+ protected final static Version version = new Version(4, 3, 2, 0);
protected final static Version majorVersion = new Version(version.getNumber(0));
protected final static Version databaseVersion = new Version(
@@ -188,15 +188,6 @@
public IsisConfig() {
- // fix missing converter for locale
- try {
- ConverterUtil.registerConverter(Locale.class);
- } catch (Exception ex) {
- if (log.isWarnEnabled()) {
- log.warn("Can't register locale converter", ex);
- }
- }
-
for (Option o : Option.values()) {
if (o.defaultValue != null) {
setDefaultOption(o.key, o.defaultValue);
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java 2014-08-21 15:44:13 UTC (rev 4098)
@@ -58,7 +58,7 @@
public double getAge() {
double result = 0;
if (getPopulation() != null && getPopulation().getSpecies() != null) {
- if (getPopulation().getSpecies().getAgeGroupType()) {
+ if (getPopulation().getSpecies().isAgeGroupType()) {
result = super.getAge();
} else {
result = getPopulation().getAge(getLength(), this)
@@ -75,7 +75,7 @@
public double getLength() {
double result = 0.0;
if (getPopulation() != null && getPopulation().getSpecies() != null) {
- if (!getPopulation().getSpecies().getAgeGroupType()) {
+ if (!getPopulation().getSpecies().isAgeGroupType()) {
result = (getMinLength() + getMaxLength()) / 2.0;
} else {
result = getPopulation().getLength(
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationSeasonInfoImpl.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationSeasonInfoImpl.java 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationSeasonInfoImpl.java 2014-08-21 15:44:13 UTC (rev 4098)
@@ -423,24 +423,24 @@
if (log.isDebugEnabled()) {
log.debug("pop: " + pop + " AgeGroup: "
- + pop.getSpecies().getAgeGroupType() + " groupChange: "
- + getGroupChange() + " month: " + month + " firstMonth: "
+ + pop.getSpecies().isAgeGroupType() + " groupChange: "
+ + isGroupChange() + " month: " + month + " firstMonth: "
+ getFirstMonth());
}
// si en longueur
- if (!pop.getSpecies().getAgeGroupType()) {
- if (getSimpleLengthChangeMatrix()) {
+ if (!pop.getSpecies().isAgeGroupType()) {
+ if (isSimpleLengthChangeMatrix()) {
return spacializeLengthChangeMatrix(getLengthChangeMatrix());
} else {
return getLengthChangeMatrix();
}
- } else if (getGroupChange()
+ } else if (isGroupChange()
&& month.getMonthNumber() == getFirstMonth().getMonthNumber()) {
// create identity matrix with special 1 for plus group if necessary
int nbrAge = pop.sizePopulationGroup();
int nbrZone = pop.sizePopulationZone();
- boolean groupplus = pop.getPlusGroup();
+ boolean groupplus = pop.isPlusGroup();
MatrixND result = createSpacializedChangeGroupMatrix();
for (MatrixIterator mi = result.iterator(); mi.next();) {
@@ -496,7 +496,7 @@
mat = createSpacializedChangeGroupMatrix();
MatrixHelper.convertToId(mat);
- if (getUseEquationMigration()) {
+ if (isUseEquationMigration()) {
// on commence par faire une copie pour ne pas modifier N
MatrixND N = MatrixFactory.getInstance().create(aN);
@@ -590,7 +590,7 @@
mat = createSpacializedChangeGroupMatrix();
- if (getUseEquationMigration()) {
+ if (isUseEquationMigration()) {
// on commence par faire une copie pour ne pas modifier N
MatrixND N = MatrixFactory.getInstance().create(aN);
@@ -659,7 +659,7 @@
mat = MatrixFactory.getInstance().create(
new int[] { groups.size() * nbSecteur });
- if (getUseEquationMigration()) {
+ if (isUseEquationMigration()) {
// on commence par faire une copie pour ne pas modifier N
MatrixND N = MatrixFactory.getInstance().create(aN);
@@ -819,7 +819,7 @@
// on commence par faire une copie pour ne pas modifier N
MatrixND N = aN.copy();
- if (getReproduction()) {
+ if (isReproduction()) {
//recuperation de l'equation de reproduction
Equation e = pop.getReproductionEquation();
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/StrategyImpl.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/StrategyImpl.java 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/StrategyImpl.java 2014-08-21 15:44:13 UTC (rev 4098)
@@ -156,7 +156,7 @@
double result = 0;
StrategyMonthInfo info = getStrategyMonthInfo(month);
- if (!getInactivityEquationUsed()) {
+ if (!isInactivityEquationUsed()) {
result = info.getMinInactivityDays();
} else {
try {
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/TargetSpeciesImpl.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/TargetSpeciesImpl.java 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/TargetSpeciesImpl.java 2014-08-21 15:44:13 UTC (rev 4098)
@@ -143,7 +143,7 @@
Equation eq = getTargetFactorEquation();
Species species = getSpecies();
MetierSeasonInfo msi = getMetierSeasonInfo();
- boolean primaryCatch = getPrimaryCatch();
+ boolean primaryCatch = isPrimaryCatch();
result = eq.evaluate("group", group, "species", species,
"infoMetier", msi, "primaryCatch", primaryCatch);
} catch (Exception eee) {
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java 2014-08-21 15:44:13 UTC (rev 4098)
@@ -145,7 +145,7 @@
(float) cell.getLongitude(), (float) cell.getLatitude(),
(float) (cell.getLongitude() + pasMailleLongitude),
OMGraphic.LINETYPE_STRAIGHT);
- if (cell.getLand()) {
+ if (cell.isLand()) {
omrect.setLinePaint(new Color(Color.red.getRed(), Color.red
.getGreen(), Color.red.getBlue(), 0));//completement transparent
} else {
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2014-08-21 15:44:13 UTC (rev 4098)
@@ -286,7 +286,7 @@
}
}
- if (pop.getSpecies().getAgeGroupType()) {
+ if (pop.getSpecies().isAgeGroupType()) {
// conversion et retour de la matrice en vecteur
MatrixND N = pop.N2DToN1D(result);
// on applique les migrations et le changement d'age sur le resultat
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx 2014-08-21 15:44:13 UTC (rev 4098)
@@ -170,7 +170,7 @@
<JLabel text="isisfish.cell.land" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JCheckBox id="fieldCellLand" onActionPerformed='getBean().setLand(fieldCellLand.isSelected())' enabled='{isActive()}' selected='{getBean().getLand()}' decorator='boxed'/>
+ <JCheckBox id="fieldCellLand" onActionPerformed='getBean().setLand(fieldCellLand.isSelected())' enabled='{isActive()}' selected='{getBean().isLand()}' decorator='boxed'/>
</cell>
</row>
<row>
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx 2014-08-21 15:44:13 UTC (rev 4098)
@@ -94,7 +94,7 @@
wizardFrame.add(wizard, BorderLayout.CENTER);
wizardFrame.setTitle(t("isisfish.wizardGroupCreation.title"));
Species species = getBean().getSpecies();
- wizard.setAgeType(species.getAgeGroupType());
+ wizard.setAgeType(species.isAgeGroupType());
if (wizard.isAgeType()) {
wizard.setCard("singleGroupAge");
} else {
@@ -179,7 +179,7 @@
<cell fill='horizontal'>
<JCheckBox id="fieldPopulationBasicsPlusGroup" text="isisfish.populationBasics.plusGroup"
toolTipText="isisfish.populationBasics.plusGroupTip"
- selected='{getBean().getPlusGroup()}'
+ selected='{getBean().isPlusGroup()}'
onActionPerformed='getBean().setPlusGroup(fieldPopulationBasicsPlusGroup.isSelected())'
enabled='{isActive()}' decorator='boxed' _sensitivityBean='{Population.class}' _sensitivityMethod='"PlusGroup"'/>
</cell>
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx 2014-08-21 15:44:13 UTC (rev 4098)
@@ -122,7 +122,7 @@
}
protected void refreshHidablePanel() {
if (getPopInfo() != null) {
- if (getPopInfo().getUseEquationMigration()) {
+ if (getPopInfo().isUseEquationMigration()) {
fieldUseEquationMigration.setSelected(true);
((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseEquation");
}
@@ -155,7 +155,7 @@
</row>
<row>
<cell columns='2' anchor='west'>
- <JCheckBox id="fieldUseEquationMigration" selected='{getPopInfo().getUseEquationMigration()}'
+ <JCheckBox id="fieldUseEquationMigration" selected='{getPopInfo().isUseEquationMigration()}'
text="isisfish.populationMigration.useEquation" onActionPerformed='useEquationChanged()'
enabled='{getPopInfo() != null}' decorator='boxed'/>
</cell>
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx 2014-08-21 15:44:13 UTC (rev 4098)
@@ -66,7 +66,7 @@
try {
MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix();
if (lengthChangeMatrix != null) {
- if (popInfo.getSimpleLengthChangeMatrix()) {
+ if (popInfo.isSimpleLengthChangeMatrix()) {
lengthChangeMatrix = popInfo.unspacializeLengthChangeMatrix(lengthChangeMatrix);
} else {
lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
@@ -85,7 +85,7 @@
protected void computeMatrixChangeOfGroup() {
PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
MatrixND lengthChangeMatrix = popInfo.computeLengthChangeMatrix();
- if (!popInfo.getSimpleLengthChangeMatrix()){
+ if (!popInfo.isSimpleLengthChangeMatrix()){
lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
}
popInfo.setLengthChangeMatrix(lengthChangeMatrix);
@@ -94,7 +94,7 @@
protected void showSpacializedMatrixChangeOfGroup() {
PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix();
- if (popInfo.getSimpleLengthChangeMatrix()) {
+ if (popInfo.isSimpleLengthChangeMatrix()) {
lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
}
MatrixPanelEditor panel = new MatrixPanelEditor(false, 800, 300);
@@ -112,7 +112,7 @@
<cell fill='horizontal' weightx='0.5'>
<JRadioButton id="radioPopulationSeasonGroupChangeLengthNoSpacialized"
buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup"
- selected='{getPopulationSeasonInfo().getSimpleLengthChangeMatrix()}'
+ selected='{getPopulationSeasonInfo().isSimpleLengthChangeMatrix()}'
enabled='{getPopulationSeasonInfo() != null}'
text="isisfish.populationSeasons.noSpacialized" onActionPerformed='spacializedActionPerformed()'
visible='{isAgeGroupType()}' decorator='boxed' />
@@ -120,7 +120,7 @@
<cell fill='horizontal' weightx='0.5'>
<JRadioButton id="radioPopulationSeasonGroupChangeLengthSpacialized"
buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup"
- selected='{!getPopulationSeasonInfo().getSimpleLengthChangeMatrix()}'
+ selected='{!getPopulationSeasonInfo().isSimpleLengthChangeMatrix()}'
enabled='{getPopulationSeasonInfo() != null}'
text="isisfish.populationSeasons.spacialized" onActionPerformed='spacializedActionPerformed()'
visible='{isAgeGroupType()}' decorator='boxed' />
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx 2014-08-21 15:44:13 UTC (rev 4098)
@@ -282,16 +282,16 @@
<JPanel/>
</cell>
<cell fill='both' weightx='1.0'>
- <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup" selected='{getPopulationSeasonInfo().getGroupChange()}'
+ <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup" selected='{getPopulationSeasonInfo().isGroupChange()}'
decorator='boxed' _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"GroupChange"'
- onActionPerformed='seasonGroupChanged()' enabled='{getPopulationSeasonInfo() != null}' visible='{isAgeGroupType(getPopulationSeasonInfo().getPopulation().getSpecies().getAgeGroupType())}'/>
+ onActionPerformed='seasonGroupChanged()' enabled='{getPopulationSeasonInfo() != null}' visible='{isAgeGroupType(getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/>
</cell>
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.6'>
<PopulationSeasonSpacializedUI id='populationSeasonSpecializedUI' constructorParams='this' bean='{getBean()}'
populationSeasonInfo='{getPopulationSeasonInfo()}'
- ageGroupType='{isAgeGroupType(!getPopulationSeasonInfo().getPopulation().getSpecies().getAgeGroupType())}'/>
+ ageGroupType='{isAgeGroupType(!getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/>
</cell>
</row>
<row>
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesStructuredUI.jaxx
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesStructuredUI.jaxx 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesStructuredUI.jaxx 2014-08-21 15:44:13 UTC (rev 4098)
@@ -38,11 +38,11 @@
<Table>
<row>
<cell fill='horizontal' weightx='0.5'>
- <JRadioButton id="fieldSpeciesDynamicAge" text="isisfish.species.age" selected='{getBean().getAgeGroupType()}'
+ <JRadioButton id="fieldSpeciesDynamicAge" text="isisfish.species.age" selected='{getBean().isAgeGroupType()}'
buttonGroup="structuredGroup" onItemStateChanged='dynamicChanged()' enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JRadioButton id="fieldSpeciesDynamicLength" text="isisfish.species.length" selected='{!getBean().getAgeGroupType()}'
+ <JRadioButton id="fieldSpeciesDynamicLength" text="isisfish.species.length" selected='{!getBean().isAgeGroupType()}'
buttonGroup="structuredGroup" enabled='{isActive()}'/>
</cell>
</row>
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx 2014-08-21 15:44:13 UTC (rev 4098)
@@ -74,7 +74,7 @@
//fieldStrategyProportionSetOfVessels.init();
// code to replace bindings :
- strategyInactivity.setActive(isActive() && getBean().getInactivityEquationUsed());
+ strategyInactivity.setActive(isActive() && getBean().isInactivityEquationUsed());
//getSaveVerifier().addCurrentPanel(strategyInactivity);
}
@@ -144,7 +144,7 @@
<JPanel/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JCheckBox id="fieldUseEquationInactivity" selected='{getBean().getInactivityEquationUsed()}'
+ <JCheckBox id="fieldUseEquationInactivity" selected='{getBean().isInactivityEquationUsed()}'
text="isisfish.strategy.inactivityEquationUsed"
onActionPerformed='getBean().setInactivityEquationUsed(fieldUseEquationInactivity.isSelected())' enabled='{isActive()}' decorator='boxed'/>
</cell>
@@ -153,10 +153,10 @@
<cell columns="2" fill='both' weightx='1.0' weighty='0.5'>
<InputOneEquationUI id="strategyInactivity" constructorParams='this'
text='isisfish.strategy.inactivity'
- active="{isActive() && getBean() != null && bean.getInactivityEquationUsed()}"
+ active="{isActive() && getBean() != null && bean.isInactivityEquationUsed()}"
bean='{getBean()}' formuleCategory='Inactivity' beanProperty='InactivityEquation'
clazz='{fr.ifremer.isisfish.equation.StrategyInactivityEquation.class}'
- decorator='boxed' _sensitivityBean='{Strategy.class}' _sensitivityMethod='"Inactivity"'/> <!-- bindings not work well actif='{getBean().getInactivityEquationUsed()}' -->
+ decorator='boxed' _sensitivityBean='{Strategy.class}' _sensitivityMethod='"Inactivity"'/> <!-- bindings not work well actif='{getBean().isInactivityEquationUsed()}' -->
</cell>
</row>
<row>
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckRegion.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckRegion.java 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckRegion.java 2014-08-21 15:44:13 UTC (rev 4098)
@@ -189,7 +189,7 @@
}
static public void check(PopulationSeasonInfo infoSaisonPop, CheckResult result){
- if (infoSaisonPop.getUseEquationMigration()) {
+ if (infoSaisonPop.isUseEquationMigration()) {
check(infoSaisonPop, "MigrationEquation", infoSaisonPop.getMigrationEquation(), result);
check(infoSaisonPop, "EmigrationEquation", infoSaisonPop.getEmigrationEquation(), result);
check(infoSaisonPop, "ImmigrationEquation", infoSaisonPop.getImmigrationEquation(), result);
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java 2014-08-21 15:44:13 UTC (rev 4098)
@@ -140,7 +140,7 @@
result = targetSpecies.getTargetFactorEquation();
break;
case 2:
- result = targetSpecies.getPrimaryCatch();
+ result = targetSpecies.isPrimaryCatch();
break;
default:
throw new IndexOutOfBoundsException("No such column " + columnIndex);
Deleted: branches/4.3.0-log4j2/src/main/resources/log4j.properties
===================================================================
--- branches/4.3.0-log4j2/src/main/resources/log4j.properties 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/resources/log4j.properties 2014-08-21 15:44:13 UTC (rev 4098)
@@ -1,45 +0,0 @@
-###
-# #%L
-# IsisFish
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2005 - 2013 Ifremer, CodeLutin, Chatellier Eric
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/gpl-3.0.html>.
-# #L%
-###
-# Global logging configuration
-log4j.rootLogger=ERROR, stdout
-
-# Console output...
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-
-# package level
-log4j.logger.fr.ifremer.isisfish=INFO
-log4j.logger.org.nuiton=WARN
-log4j.logger.exports=INFO
-log4j.logger.formules=INFO
-log4j.logger.objectives=INFO
-log4j.logger.optimizations=INFO
-log4j.logger.rules=INFO
-log4j.logger.scripts=INFO
-log4j.logger.sensitivityanalysis=INFO
-log4j.logger.sensitivityexports=INFO
-log4j.logger.simulationplans=INFO
-log4j.logger.simulators=INFO
Modified: branches/4.3.0-log4j2/src/main/resources/log4j2.xml
===================================================================
(Binary files differ)
Modified: branches/4.3.0-log4j2/src/main/resources/sensitivity.properties
===================================================================
--- branches/4.3.0-log4j2/src/main/resources/sensitivity.properties 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/resources/sensitivity.properties 2014-08-21 15:44:13 UTC (rev 4098)
@@ -5,7 +5,7 @@
# $Id$
# $HeadURL$
# %%
-# Copyright (C) 2009 - 2011 Ifremer, CodeLutin, Chatellier Eric
+# Copyright (C) 2009 - 2014 Ifremer, CodeLutin, Chatellier Eric
# %%
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
Modified: branches/4.3.0-log4j2/src/main/xmi/isis-fish.properties
===================================================================
--- branches/4.3.0-log4j2/src/main/xmi/isis-fish.properties 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/main/xmi/isis-fish.properties 2014-08-21 15:44:13 UTC (rev 4098)
@@ -32,7 +32,6 @@
model.tagvalue.hibernateProxyInterface=none
model.tagvalue.constantPrefix=PROPERTY_
model.tagvalue.useEnumerationName=true
-model.tagvalue.doNotGenerateBooleanGetMethods=false
model.tagvalue.notGenerateReadListeners=true
fr.ifremer.isisfish.entities.ActiveRule.class.tagvalue.contextable=true
fr.ifremer.isisfish.entities.Cell.class.tagvalue.contextable=true
Modified: branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java
===================================================================
--- branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java 2014-08-21 15:44:13 UTC (rev 4098)
@@ -86,6 +86,9 @@
@BeforeClass
public static void init() throws Exception {
+ // TODO as of 20140720, hibernate fails to detect log4j 2.0, force slf4j
+ System.setProperty("org.jboss.logging.provider", "slf4j");
+
File mavenTestDir = getTestDirectory();
dirIsisBase = FileUtil.createTempDirectory("isisdbtest", "", mavenTestDir);
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/rules/TACpoids.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/rules/TACpoids.java 2014-08-21 14:25:44 UTC (rev 4097)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/rules/TACpoids.java 2014-08-21 15:44:13 UTC (rev 4098)
@@ -183,7 +183,7 @@
log.info(" TAC atteint [TAC] preAction for: " + metier);
TargetSpecies ts = metier.getMetierSeasonInfo(step.getMonth())
.getSpeciesTargetSpecies(param_species);
- if (ts != null && ts.getPrimaryCatch()) {
+ if (ts != null && ts.isPrimaryCatch()) {
// recupere tous les metiers qui ont l'espece en capture principale =>metiers vises
// aimedMetiers ne fonctionne pas je ne sais pas pourquoi ! mais au final forbiddenMetier aura le meme effet
1
0
r4097 - in branches/4.3.0-log4j2: . src/main/java/fr/ifremer/isisfish/datastore src/main/java/fr/ifremer/isisfish/logging src/main/java/fr/ifremer/isisfish/logging/console src/main/java/fr/ifremer/isisfish/simulator/launcher src/main/java/fr/ifremer/isisfish/ui/result src/main/resources src/test/java/fr/ifremer/isisfish/logging src/test/resources
by echatellier@users.forge.codelutin.com 21 Aug '14
by echatellier@users.forge.codelutin.com 21 Aug '14
21 Aug '14
Author: echatellier
Date: 2014-08-21 16:25:44 +0200 (Thu, 21 Aug 2014)
New Revision: 4097
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4097
Log:
Move logger to log4j2
Added:
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/NullAppender.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/SimulationThresholdFilter.java
Removed:
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/ThreadFilter.java
branches/4.3.0-log4j2/src/test/resources/VCSConfig-junit_CVS.properties
branches/4.3.0-log4j2/src/test/resources/VCSConfig-junit_SVN.properties
branches/4.3.0-log4j2/src/test/resources/isis-database-3_cvs.zip
Modified:
branches/4.3.0-log4j2/pom.xml
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/console/LogConsole.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx
branches/4.3.0-log4j2/src/main/resources/log4j2.xml
branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java
Modified: branches/4.3.0-log4j2/pom.xml
===================================================================
--- branches/4.3.0-log4j2/pom.xml 2014-08-20 09:48:07 UTC (rev 4096)
+++ branches/4.3.0-log4j2/pom.xml 2014-08-21 14:25:44 UTC (rev 4097)
@@ -235,21 +235,21 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
<scope>runtime</scope>
</dependency>
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2014-08-20 09:48:07 UTC (rev 4096)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2014-08-21 14:25:44 UTC (rev 4097)
@@ -53,7 +53,6 @@
import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.entities.FisheryRegion;
import fr.ifremer.isisfish.entities.FisheryRegionDAO;
-import fr.ifremer.isisfish.logging.SimulationLoggerUtil;
import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.SimulationParameterImpl;
@@ -871,62 +870,10 @@
}
/**
- * This method add logger for current simulation
- *
- * @param simulLogLevel required min level for simulator logger
- * @param threadName name of the thread to log (simulation thread)
- * @param scriptLogLevel required min level fro scripts logger
- * @param libLogLevel required min level for libraries logger
- */
- public void addSimulationLogger(String simulLogLevel,
- String scriptLogLevel, String libLogLevel, String threadName) {
-
- /*try {
- SimulationLoggerUtil.addSimulationAppender(getSimulationLogFile(),
- getAppenderId(), simulLogLevel, scriptLogLevel,
- libLogLevel, threadName);
- useLog = true;
- } catch (Exception eee) {
- useLog = false;
- log.warn(t("Can't create simulation logger", eee));
- // we do not throw any exception, this is a shame but not required
- }*/
-
- ThreadContext.put("contextId", name);
- ThreadContext.put("contextLogFile", getSimulationLogFile());
- ThreadContext.put("contextSimulLevel", simulLogLevel);
- ThreadContext.put("contextScriptLevel", scriptLogLevel);
- ThreadContext.put("contextLibLevel", libLogLevel);
- }
-
- /**
- * this method remove logger for the simulation
- */
- public void removeSimulationLogger() {
-
- /*try {
- String appenderId = getAppenderId();
- SimulationLoggerUtil.removeSimulationAppender(appenderId);
- } finally {
- useLog = false;
- }*/
- }
-
- /**
- * @return the appender id used for this simulation (simulation_name.hashcode())
- */
- protected String getAppenderId() {
- //TODO Perharps we could just use simulation name
- //TODO since it seems to be unique.
- return "simulation_" + Math.abs(hashCode());
- }
-
- /**
* @return the simulation log file
*/
public String getSimulationLogFile() {
File root = getSimulationDirectory(name);
- //TODO Should be IsisConfig.DEFAULT_SIMULATION_LOGFILE ?
return root + File.separator + "simulation.log";
}
Added: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/NullAppender.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/NullAppender.java (rev 0)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/NullAppender.java 2014-08-21 14:25:44 UTC (rev 4097)
@@ -0,0 +1,62 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2014 Ifremer, Code Lutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package fr.ifremer.isisfish.logging;
+
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+
+/**
+ * This Appender allows the logging event to be manipulated before it is processed by other Appenders.
+ */
+@Plugin(name = "Null", category = "Core", elementType = "appender", printObject = true)
+public final class NullAppender extends AbstractAppender {
+
+ private NullAppender(final String name) {
+ super(name, null, null, true);
+ }
+
+ /**
+ * Modify the event and pass to the subordinate Appenders.
+ * @param event The LogEvent.
+ */
+ @Override
+ public void append(LogEvent event) {
+
+ }
+
+ /**
+ * Create a RewriteAppender.
+ * @param name The name of the Appender.
+ * @return The created RewriteAppender.
+ */
+ @PluginFactory
+ public static NullAppender createAppender(@PluginAttribute("name") final String name) {
+ return new NullAppender(name);
+ }
+}
+
Property changes on: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/NullAppender.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java 2014-08-20 09:48:07 UTC (rev 4096)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java 2014-08-21 14:25:44 UTC (rev 4097)
@@ -29,24 +29,11 @@
import java.io.File;
import java.io.IOException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.FileAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.DefaultConfiguration;
-import org.apache.logging.log4j.core.layout.PatternLayout;
import fr.ifremer.isisfish.IsisFish;
-import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.logging.console.LogConsole;
@@ -76,121 +63,10 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(SimulationLoggerUtil.class);
- static private Map<String, Level> simulLevelKeeper = null;
- static private Map<String, Level> scriptLevelKeeper = null;
- static private Map<String, Level> libLevelKeeper = null;
-
/** pattern to use for simulation appender */
public static final String LOG_PATTERN = "%p|%d{ABSOLUTE}|%F|%L|%M|%m%n";
- /** les catégories rattachées au logger de simulation. */
- private static final String[] simulLoggerToChange = {
- "fr.ifremer.isisfish",
- };
-
- /** les catégories rattachées au logger de script. */
- private static final String[] scriptLoggerToChange = {
- "exports",
- "formules",
- "rules",
- "scripts",
- "simulators",
- "sensitivityexports"
- };
-
- /** les catégories rattachées au logger de librairies. */
- private static final String[] libLoggerToChange = {
- "org.nuiton"
- };
-
/**
- * Add a simple {@link FileAppender} for a given simulation id.
- *
- * @param filename the filename where appender store logs
- * @param appenderId the id of appender to add
- * @param simulLogLevel simulator logger level
- * @param libLogLevel libraries logger level
- * @param scriptLogLevel scripts logger level
- * @param threadName the thread to exclude (if null don't use it)
- * @throws IsisFishException if we could not create appender
- */
- public static void addSimulationAppender(String filename,
- String appenderId,
- String simulLogLevel,
- String scriptLogLevel,
- String libLogLevel,
- String threadName)
- throws IsisFishException {
- PatternLayout layout = PatternLayout.newBuilder()
- .withPattern(LOG_PATTERN)
- .build();
-
- ThreadFilter filter = new ThreadFilter(threadName);
-
- simulLevelKeeper = prepareLogger(simulLogLevel, simulLoggerToChange);
- scriptLevelKeeper = prepareLogger(scriptLogLevel, scriptLoggerToChange);
- libLevelKeeper = prepareLogger(libLogLevel, libLoggerToChange);
-
- Configuration configuration = new DefaultConfiguration();
- //try {
- //FileAppender appender = new FileAppender(layout, filename, false);
- FileAppender appender = FileAppender.createAppender(filename,
- "false" /*append*/,
- "false" /*locking*/,
- threadName /*name*/,
- "true" /*immediateFlush*/,
- "true" /*ignore*/,
- "true" /*bufferedIo*/,
- "8192" /*bufferSizeStr*/,
- layout,
- filter,
- "false" /*advertise*/,
- threadName /*advertiseUri*/,
- configuration);
-
- //appender.setName(appenderId);
-
- // thread filter come first
- //appender.addFilter(filter);
-
- // add the appender to the root appender
- //Logger.getRootLogger().addAppender(appender);
- configuration.addAppender(appender);
-
- LoggerContext context = (LoggerContext) LogManager.getContext();
- context.start(configuration);
- context.updateLoggers();
-
- if (log.isDebugEnabled()) {
- log.debug(t("isisfish.log.addAppender", appenderId));
- }
- /*} catch (IOException ex) {
- log.error(t("isisfish.error.log.createAppender", appenderId, ex.getMessage()));
- throw new IsisFishException("Can't add appender", ex);
- }*/
-
- }
-
- /**
- * Remove the appender used for simulation, add restore level to logger.
- *
- * @param appenderId the appender id to remove
- */
- public static void removeSimulationAppender(String appenderId) {
- if (log.isDebugEnabled()) {
- log.debug(t("isisfish.log.removeAppender", appenderId));
- }
- removeAppender(null, appenderId);
- // push back to original levels
- retablishLogger(simulLevelKeeper);
- simulLevelKeeper = null;
- retablishLogger(scriptLevelKeeper);
- scriptLevelKeeper = null;
- retablishLogger(libLevelKeeper);
- libLevelKeeper = null;
- }
-
- /**
* Open a new log console for the given simulation
*
* @param simulationName name of the simulation to use
@@ -215,91 +91,4 @@
log.info(t("isisfish.simulation.log.showConsole", simulationName));
}
}
-
- /**
- * Find categories instanciated keep their level and swap to new
- * required level.
- * <p/>
- * Return the dico produced to be resotre later {@link #retablishLogger(java.util.Map)}
- *
- * @param logLevel the required level
- * @param categoriesToChange list of categories
- * @return the dico of matching categories with their orginal level
- */
- static Map<String, Level> prepareLogger(String logLevel, String[] categoriesToChange) {
- Map<String, Level> result = new HashMap<String, Level>();
- /*Enumeration enumeration;
-
- Level level = Level.toLevel(logLevel);
-
- enumeration = Logger.getRootLogger().getLoggerRepository().getCurrentLoggers();
- while (enumeration.hasMoreElements()) {
- Object o = enumeration.nextElement();
- if (o instanceof Logger) {
- Logger logger = (Logger) o;
- String loggerName = logger.getName();
- for (String category : categoriesToChange) {
- if (loggerName.startsWith(category)) {
- // we found a logger to keep at his level
- result.put(logger.getName(), logger.getLevel());
- if (log.isDebugEnabled()) {
- log.debug(t("isisfish.log.swapLogLevel", loggerName, logger.getLevel(), logLevel));
- }
- // change to new level
- logger.setLevel(level);
- break;
- }
- }
- }
- }*/
- return result;
- }
-
- /**
- * Restore for the given categories, the associated level store in dico.
- *
- * @param levelKeeper the dico of categories to swap back to original levels
- */
- static void retablishLogger(Map<String, Level> levelKeeper) {
- /*Logger rootLogger = Logger.getRootLogger();
- for (Map.Entry<String, Level> entry : levelKeeper.entrySet()) {
- Logger logger = rootLogger.getLoggerRepository().getLogger(entry.getKey());
- if (logger != null) {
- Level oldLevel = entry.getValue();
- if (log.isDebugEnabled()) {
- log.debug(t("isisfish.log.restoreLogLevel", logger.getName(), logger.getLevel(), oldLevel));
- }
- logger.setLevel(oldLevel);
- }
- }
- levelKeeper.clear();*/
- }
-
- /**
- * Remove a Log4J appender given his name for a given category.
- * <p/>
- * It category is null, we use the rootLogger.
- *
- * @param category category of appender to remove, it null use rootLogger
- * @param name name of appender to remove
- */
- static void removeAppender(String category, String name) {
- // get logger for the category
- /*Logger logger = category == null ? Logger.getRootLogger() : Logger.getLogger(category);
- if (logger == null) {
- Logger.getRootLogger().warn(t("isisfish.error.log.closeAppender", name, category));
- return;
- }
- // get the required appender
- Appender app = logger.getAppender(name);
- if (app == null) {
- logger.warn(t("isisfish.error.log.foundAppender", name, category));
- return;
- }
- logger.info(t("isisfish.log.closeAppender", name, category));
- // close appender
- app.close();
- // and remove it from the logger
- logger.removeAppender(app);*/
- }
}
Added: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/SimulationThresholdFilter.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/SimulationThresholdFilter.java (rev 0)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/SimulationThresholdFilter.java 2014-08-21 14:25:44 UTC (rev 4097)
@@ -0,0 +1,149 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2014 Ifremer, Code Lutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.logging;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.ThreadContext;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.core.filter.AbstractFilter;
+import org.apache.logging.log4j.message.Message;
+
+import fr.ifremer.isisfish.datastore.ExportStorage;
+import fr.ifremer.isisfish.datastore.FormuleStorage;
+import fr.ifremer.isisfish.datastore.ObjectiveStorage;
+import fr.ifremer.isisfish.datastore.OptimizationStorage;
+import fr.ifremer.isisfish.datastore.RuleStorage;
+import fr.ifremer.isisfish.datastore.ScriptStorage;
+import fr.ifremer.isisfish.datastore.SensitivityAnalysisStorage;
+import fr.ifremer.isisfish.datastore.SensitivityExportStorage;
+import fr.ifremer.isisfish.datastore.SimulationPlanStorage;
+import fr.ifremer.isisfish.datastore.SimulatorStorage;
+
+/**
+ * Filter always available in log4j configuration that filter simulation log depending of simulation
+ * log level configuration.
+ */
+@Plugin(name = "SimulationThresholdFilter", category = "Core", elementType = "filter", printObject = true)
+public final class SimulationThresholdFilter extends AbstractFilter {
+ private Level defaultThreshold = Level.ERROR;
+
+ /** Simulation id. Present in MDC context only if a simulation is running. */
+ public static final String SIMULATION_ID = "simulationId";
+ /** Simulation log file for lof4j file appender (only if simulationId is defined) */
+ public static final String SIMULATION_LOG_FILE = "simulationLogFile";
+ /** {@code fr.ifremer.isisfish} package log level. */
+ public static final String SIMUALTION_APPLICATION_LEVEL = "simulationApplicationLevel";
+ /** {@code org.nuiton} package log level. */
+ public static final String SIMULATION_LIB_LEVEL = "simulationLibLevel";
+ /** Script log level. */
+ public static final String SIMULATION_SCRIPT_LEVEL = "simulationScriptLevel";
+
+ private SimulationThresholdFilter(final Level defaultLevel, final Result onMatch, final Result onMismatch) {
+ super(onMatch, onMismatch);
+ this.defaultThreshold = defaultLevel;
+ }
+
+ @Override
+ public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+ final Object... params) {
+ return filter(logger.getName(), level);
+ }
+
+ @Override
+ public Result filter(final Logger logger, final Level level, final Marker marker, final Object msg,
+ final Throwable t) {
+ return filter(logger.getName(), level);
+ }
+
+ @Override
+ public Result filter(final Logger logger, final Level level, final Marker marker, final Message msg,
+ final Throwable t) {
+ return filter(logger.getName(), level);
+ }
+
+ @Override
+ public Result filter(final LogEvent event) {
+ return filter(event.getLoggerFqcn(), event.getLevel());
+ }
+
+ private Result filter(final String loggerFqcn, final Level level) {
+
+ String simulationId = ThreadContext.get("simulationId");
+
+ Result result;
+
+ // so simulation, no filtering
+ if (simulationId == null) {
+ result = Result.NEUTRAL;
+ } else {
+ Level ctxLevel = defaultThreshold;
+
+ if (loggerFqcn.startsWith("fr.ifremer.isisfish")) {
+ ctxLevel = Level.getLevel(ThreadContext.get("simulationApplicationLevel"));
+ } else if (loggerFqcn.startsWith("org.nuiton")) {
+ ctxLevel = Level.getLevel(ThreadContext.get("simulationLibLevel"));
+ } else if (StringUtils.startsWithAny(loggerFqcn,
+ ExportStorage.EXPORT_PATH,
+ FormuleStorage.FORMULE_PATH,
+ ObjectiveStorage.OBJECTIVE_PATH,
+ OptimizationStorage.OPTIMIZATION_PATH,
+ RuleStorage.RULE_PATH,
+ ScriptStorage.SCRIPT_PATH,
+ SensitivityAnalysisStorage.SENSITIVITY_ANALYSIS_PATH,
+ SensitivityExportStorage.SENSITIVITY_EXPORT_PATH,
+ SimulationPlanStorage.SIMULATION_PLAN_PATH,
+ SimulatorStorage.SIMULATOR_PATH)) {
+ ctxLevel = Level.getLevel(ThreadContext.get("simulationScriptLevel"));
+ }
+
+ result = level.isMoreSpecificThan(ctxLevel) ? onMatch : onMismatch;
+ }
+
+ return result;
+ }
+
+ /**
+ * Create the DynamicThresholdFilter.
+ * @param defaultThreshold The default Level.
+ * @param onMatch The action to perform if a match occurs.
+ * @param onMismatch The action to perform if no match occurs.
+ * @return The DynamicThresholdFilter.
+ */
+ @PluginFactory
+ public static SimulationThresholdFilter createFilter(
+ @PluginAttribute("defaultThreshold") final Level defaultThreshold,
+ @PluginAttribute("onMatch") final Result onMatch,
+ @PluginAttribute("onMismatch") final Result onMismatch) {
+ final Level level = defaultThreshold == null ? Level.ERROR : defaultThreshold;
+ return new SimulationThresholdFilter(level, onMatch, onMismatch);
+ }
+}
Property changes on: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/SimulationThresholdFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/ThreadFilter.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/ThreadFilter.java 2014-08-20 09:48:07 UTC (rev 4096)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/ThreadFilter.java 2014-08-21 14:25:44 UTC (rev 4097)
@@ -1,69 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2002 - 2014 Ifremer, Code Lutin, Benjamin Poussin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.logging;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.filter.AbstractFilter;
-import org.apache.logging.log4j.message.Message;
-
-/**
- * this class is Log4J filter to accept only incoming log events from a unique thread.
- * it retains all logEvent coming from other threads (compare with given thread name).
- *
- * @author chemit
- */
-public class ThreadFilter extends AbstractFilter {
-
- /** the name of the only thread to accept */
- protected String threadName;
-
- public ThreadFilter(String threadName) {
- this.threadName = threadName;
- }
-
- @Override
- public Result filter(LogEvent event) {
- return event.getThreadName().equals(threadName) ? Result.ACCEPT : Result.DENY;
- }
-
- @Override
- public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
- throw new UnsupportedOperationException("filter");
- }
-
- @Override
- public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
- throw new UnsupportedOperationException("filter");
- }
-
- @Override
- public Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) {
- throw new UnsupportedOperationException("filter");
- }
-}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/console/LogConsole.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/console/LogConsole.java 2014-08-20 09:48:07 UTC (rev 4096)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/console/LogConsole.java 2014-08-21 14:25:44 UTC (rev 4097)
@@ -319,16 +319,4 @@
});
}
}
-
- public static void IsisStart() {
-
- try {
- IsisFish.init();
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't init isis", e);
- }
- }
-
- }
}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2014-08-20 09:48:07 UTC (rev 4096)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2014-08-21 14:25:44 UTC (rev 4097)
@@ -41,6 +41,8 @@
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.ThreadContext;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.event.TopiaTransactionEvent;
@@ -59,6 +61,7 @@
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.datastore.SimulatorStorage;
+import fr.ifremer.isisfish.logging.SimulationThresholdFilter;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.SimulationException;
@@ -70,6 +73,7 @@
import fr.ifremer.isisfish.types.Month;
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.CompileHelper;
+
import org.nuiton.math.matrix.MatrixFactory;
/**
@@ -220,39 +224,15 @@
protected SimulationStorage localSimulate(SimulationControl control,
SimulationStorage simulation) {
SimThread simThread = new SimThread(control, simulation);
- // add simulation logger, we can't make it before since we need thread name
- // anyway since if accept only log from simThread, no need to init it before
- String simulLogLevel = simulation.getParameter().getSimulLogLevel();
- String scriptLogLevel = simulation.getParameter().getScriptLogLevel();
- String libLogLevel = simulation.getParameter().getLibLogLevel();
- /*try {
- simulation.addSimulationLogger(simulLogLevel, scriptLogLevel,
- libLogLevel, simThread.getName());
- } catch (Exception e) {
+ simThread.start();
+ try {
+ simThread.join();
+ } catch (InterruptedException eee) {
if (log.isWarnEnabled()) {
- log.warn(t("isisfish.error.add.logger.simulation", e));
+ log.warn(t("isisfish.error.wait.simThread"), eee);
}
- }*/
- try {
- simThread.start();
- try {
- simThread.join();
- } catch (InterruptedException eee) {
- if (log.isWarnEnabled()) {
- log.warn(t("isisfish.error.wait.simThread"), eee);
- }
- }
- } finally {
- try {
- // remove simulation logger (no more need since thread is dead)
- simulation.removeSimulationLogger();
- } catch (Exception ex) {
- if (log.isDebugEnabled()) {
- log.debug("Can't restore logger configuration", ex);
- }
- // FIXME echatellier 20140729 remove this with log4j 2
- }
}
+
return simulation;
}
@@ -268,13 +248,22 @@
@Override
public void run() {
-
+
+ // logger configuration can only be changed with log4j MDC using thread local
String simulLogLevel = simulation.getParameter().getSimulLogLevel();
String scriptLogLevel = simulation.getParameter().getScriptLogLevel();
String libLogLevel = simulation.getParameter().getLibLogLevel();
- simulation.addSimulationLogger(simulLogLevel, scriptLogLevel,
- libLogLevel, getName());
-
+
+ String standardSimulLogLevel = Level.toLevel(simulLogLevel, Level.INFO).name();
+ String standardLibLogLevel = Level.toLevel(libLogLevel, Level.INFO).name();
+ String standardScriptLogLevel = Level.toLevel(scriptLogLevel, Level.WARN).name();
+
+ ThreadContext.put(SimulationThresholdFilter.SIMULATION_ID, simulation.getName());
+ ThreadContext.put(SimulationThresholdFilter.SIMULATION_LOG_FILE, simulation.getSimulationLogFile());
+ ThreadContext.put(SimulationThresholdFilter.SIMUALTION_APPLICATION_LEVEL, standardSimulLogLevel);
+ ThreadContext.put(SimulationThresholdFilter.SIMULATION_SCRIPT_LEVEL, standardLibLogLevel);
+ ThreadContext.put(SimulationThresholdFilter.SIMULATION_LIB_LEVEL, standardScriptLogLevel);
+
simulation = localSimulateSameThread(control, simulation);
}
}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java 2014-08-20 09:48:07 UTC (rev 4096)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java 2014-08-21 14:25:44 UTC (rev 4097)
@@ -35,12 +35,15 @@
import java.io.File;
import java.io.FileWriter;
import java.io.Writer;
+import java.util.List;
+import javax.swing.JFrame;
import javax.swing.JMenuItem;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.viewer.MatrixViewerPanel;
import org.nuiton.math.matrix.viewer.renderer.MatrixChartRenderer;
@@ -108,10 +111,10 @@
* @param resultUI resultUI
*/
protected void initSimulationList(ResultUI resultUI) {
- java.util.List<String> value = SimulationStorage.getSimulationNames();
+ List<String> value = SimulationStorage.getSimulationNames();
//resultUI.getSimulationComboBox().setEditable(false);
- GenericComboModel model = new GenericComboModel(value);
+ GenericComboModel<String> model = new GenericComboModel<String>(value);
resultUI.getSimulationComboBox().setModel(model);
resultUI.getSimulationComboBox().setSelectedItem(null);
}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx 2014-08-20 09:48:07 UTC (rev 4096)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx 2014-08-21 14:25:44 UTC (rev 4097)
@@ -37,7 +37,7 @@
<JLabel text="isisfish.result.choose.simulation"/>
</cell>
<cell fill="horizontal" weightx="1">
- <fr.ifremer.isisfish.ui.widget.FilterableComboBox id="simulationComboBox"
+ <fr.ifremer.isisfish.ui.widget.FilterableComboBox id="simulationComboBox" genericType="String"
onActionPerformed="openButton.setEnabled(getSimulationComboBox().getSelectedItem() != null);removeButton.setEnabled(getSimulationComboBox().getSelectedItem() != null);logButton.setEnabled(getSimulationComboBox().getSelectedItem() != null);"/>
</cell>
<cell>
Modified: branches/4.3.0-log4j2/src/main/resources/log4j2.xml
===================================================================
(Binary files differ)
Modified: branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java
===================================================================
--- branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java 2014-08-20 09:48:07 UTC (rev 4096)
+++ branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java 2014-08-21 14:25:44 UTC (rev 4097)
@@ -36,10 +36,12 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Assert;
+import org.junit.Ignore;
import org.junit.Test;
import fr.ifremer.isisfish.AbstractIsisFishTest;
+@Ignore
public class SimulationLoggerUtilTest extends AbstractIsisFishTest {
static private final String category = "fr.ifremer.isisfish.logging";
@@ -61,27 +63,13 @@
logInfo(logInit2, "before new config", null, null);
logInfo(log, "before new config", null, null);
- String threadName = Thread.currentThread().getName();
-
// use a logger we know to be scan as been keep for original level
Logger hibernatelog = LogManager.getLogger("org.hibernate");
Level hibernateLogLevel = hibernatelog.getLevel();
-
String loggerFile = new File(getTestDirectory(), SimulationLoggerUtilTest.class.getSimpleName() + "_" + System.nanoTime() + ".log").getAbsolutePath();
- System.out.println(">>>> loggerFile " + loggerFile);
- // todo do a test for addSimulationAppender too!
- SimulationLoggerUtil.addSimulationAppender(
- loggerFile,
- appenderId,
- "INFO",
- "INFO",
- "INFO",
- threadName
- );
-
// check hibernate level was not changed
Assert.assertEquals(hibernateLogLevel, LogManager.getLogger("org.hibernate").getLevel());
final Log logger = LogFactory.getLog(appenderId);
@@ -118,7 +106,6 @@
// means nothing!!!
t.join();
Assert.assertTrue(!t.isAlive());
- SimulationLoggerUtil.removeSimulationAppender(appenderId);
message = "appender was destoyed WE MUST NOT SEE this message in simulation log file!!!";
logInit.info(message);
@@ -166,8 +153,6 @@
logDebug(logInit2, "before new config", null);
logDebug(log, "before new config", null);
- String threadName = Thread.currentThread().getName();
-
// use a logger we know to be scan as been keep for original level
Logger hibernatelog = LogManager.getLogger("org.hibernate");
@@ -175,15 +160,6 @@
String loggerFile = "testLog.log";
- // todo do a test for addSimulationAppender too!
- SimulationLoggerUtil.addSimulationAppender(
- loggerFile,
- appenderId,
- "DEBUG",
- "DEBUG",
- "DEBUG",
- threadName
- );
// check hibernate level was not changed
Assert.assertEquals(hibernateLogLevel, LogManager.getLogger("org.hibernate").getLevel());
@@ -221,7 +197,6 @@
// means nothing!!!
t.join();
Assert.assertTrue(!t.isAlive());
- SimulationLoggerUtil.removeSimulationAppender(appenderId);
message = "appender was destoyed WE MUST NOT SEE this message in simulation log file!!!";
logInit.info(message);
Deleted: branches/4.3.0-log4j2/src/test/resources/VCSConfig-junit_CVS.properties
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/VCSConfig-junit_CVS.properties 2014-08-20 09:48:07 UTC (rev 4096)
+++ branches/4.3.0-log4j2/src/test/resources/VCSConfig-junit_CVS.properties 2014-08-21 14:25:44 UTC (rev 4097)
@@ -1,30 +0,0 @@
-###
-# #%L
-# IsisFish
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2009 - 2010 Ifremer, Code Lutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/gpl-3.0.html>.
-# #L%
-###
-vcs.username=anonymous
-vcs.hostname=cvs.labs.libre-entreprise.org
-vcs.remote.path=/cvsroot/isis-fish
-vcs.remote.database=isis-fish-vcs-test_junit
-vcs.local.database=isis-vcs-test_junit_SVN
-vcs.ssh2.connexion=false
Deleted: branches/4.3.0-log4j2/src/test/resources/VCSConfig-junit_SVN.properties
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/VCSConfig-junit_SVN.properties 2014-08-20 09:48:07 UTC (rev 4096)
+++ branches/4.3.0-log4j2/src/test/resources/VCSConfig-junit_SVN.properties 2014-08-21 14:25:44 UTC (rev 4097)
@@ -1,31 +0,0 @@
-###
-# #%L
-# IsisFish
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2009 - 2010 Ifremer, Code Lutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/gpl-3.0.html>.
-# #L%
-###
-vcs.username=anonymous
-vcs.typeRepo=TAG
-vcs.hostname=labs.libre-entreprise.org
-vcs.remote.path=svnroot/isis-fish-data
-vcs.ssh2.connexion=false
-vcs.remote.database=isis-fish-vcs-test_junit
-vcs.local.database=isis-vcs-test_junit_SVN
Deleted: branches/4.3.0-log4j2/src/test/resources/isis-database-3_cvs.zip
===================================================================
(Binary files differ)
1
0
20 Aug '14
Author: echatellier
Date: 2014-08-20 11:48:07 +0200 (Wed, 20 Aug 2014)
New Revision: 4096
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4096
Log:
Merge of r4048 through r4095 into '.'
Added:
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesNombreStrategies.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesPoidsStrategies.java
branches/4.3.0-log4j2/src/test/resources/test-database/objectives/
branches/4.3.0-log4j2/src/test/resources/test-database/optimizations/
branches/4.3.0-log4j2/src/test/resources/test-database/scripts/MinimisationUtil.java
branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ObjectiveFunction.java
branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ObjectiveFunctionBaranov.java
branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/RecuitSimuleSimulateur.java
branches/4.3.0-log4j2/src/test/resources/test-database/simulators/SimulatorEffortByCell.java
Modified:
branches/4.3.0-log4j2/
branches/4.3.0-log4j2/pom.xml
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageAbstract.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/SimulationInformation.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/StrategyMonthInfoImpl.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationPlanPrepareJob.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/MatrixSummaryRenderer.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/ContinuousDistributionPanel.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/util/ErrorHelper.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/widget/FilterableComboBox.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/EvaluatorHelper.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/SimpleParser.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/StringConverter.java
branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/TopiaEntityConverter.java
branches/4.3.0-log4j2/src/main/resources/i18n/isis-fish_en_GB.properties
branches/4.3.0-log4j2/src/main/resources/i18n/isis-fish_fr_FR.properties
branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java
branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/Abundances.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/Biomasses.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesNombre.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesPoids.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/CellsDefinition.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/EffortsMetier.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/MetierZone.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/NonActivite.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/OwnerMargin.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/RegionDefinition.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/RejetsNombre.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/RejetsPoids.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/VesselMargin.java
branches/4.3.0-log4j2/src/test/resources/test-database/exports/ZonesDefinition.java
branches/4.3.0-log4j2/src/test/resources/test-database/rules/Cantonnement.java
branches/4.3.0-log4j2/src/test/resources/test-database/rules/CantonnementPreSimu.java
branches/4.3.0-log4j2/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java
branches/4.3.0-log4j2/src/test/resources/test-database/rules/EffortReduction.java
branches/4.3.0-log4j2/src/test/resources/test-database/rules/GraviteVPUE1.java
branches/4.3.0-log4j2/src/test/resources/test-database/rules/InterdictionEngin.java
branches/4.3.0-log4j2/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java
branches/4.3.0-log4j2/src/test/resources/test-database/rules/TACpoids.java
branches/4.3.0-log4j2/src/test/resources/test-database/rules/TailleMin.java
branches/4.3.0-log4j2/src/test/resources/test-database/rules/TotalClosure.java
branches/4.3.0-log4j2/src/test/resources/test-database/scripts/GravityModel.java
branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ResultName.java
branches/4.3.0-log4j2/src/test/resources/test-database/scripts/RuleUtil.java
branches/4.3.0-log4j2/src/test/resources/test-database/scripts/SiMatrix.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java
branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java
branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java
branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/SimulationNumberRestriction.java
branches/4.3.0-log4j2/src/test/resources/test-database/simulators/DefaultSimulator.java
Property changes on: branches/4.3.0-log4j2
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/4.0.0-svnkit:3665-3698
/branches/4.0.1:3616-3968
/branches/4.1:3601-3670
+ /branches/4.0.0-svnkit:3665-3698
/branches/4.0.1:3616-3968
/branches/4.1:3601-3670
/trunk:4048-4095
Modified: branches/4.3.0-log4j2/pom.xml
===================================================================
--- branches/4.3.0-log4j2/pom.xml 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/pom.xml 2014-08-20 09:48:07 UTC (rev 4096)
@@ -6,12 +6,12 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>5.0.9</version>
+ <version>5.1</version>
</parent>
<groupId>fr.ifremer</groupId>
<artifactId>isis-fish</artifactId>
- <version>4.3.1.0-SNAPSHOT</version>
+ <version>4.3.1.1-SNAPSHOT</version>
<!-- POM Relationships : Inheritance : Dependencies -->
<dependencies>
@@ -26,8 +26,15 @@
<dependency>
<groupId>org.nuiton</groupId>
+ <artifactId>nuiton-converter</artifactId>
+ <version>1.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
<artifactId>nuiton-config</artifactId>
- <version>3.0-SNAPSHOT</version>
+ <version>3.0-alpha-3</version>
<scope>compile</scope>
</dependency>
@@ -81,21 +88,21 @@
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-profiling</artifactId>
- <version>3.0-SNAPSHOT</version>
+ <version>3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.nuiton.matrix</groupId>
<artifactId>nuiton-matrix</artifactId>
- <version>2.5-SNAPSHOT</version>
+ <version>2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.nuiton.matrix</groupId>
<artifactId>nuiton-matrix-gui</artifactId>
- <version>2.5-SNAPSHOT</version>
+ <version>2.5</version>
<scope>compile</scope>
</dependency>
@@ -228,21 +235,21 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
- <version>2.0</version>
+ <version>2.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
- <version>2.0</version>
+ <version>2.0.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
- <version>2.0</version>
+ <version>2.0.1</version>
<scope>runtime</scope>
</dependency>
@@ -480,6 +487,7 @@
<projectId>isis-fish</projectId>
<platform>codelutin.com</platform>
<siteLocales>fr,en</siteLocales>
+ <siteDeployClassifier />
<maven.jar.main.class>fr.ifremer.isisfish.IsisFish</maven.jar.main.class>
<license.licenseName>gpl_v3</license.licenseName>
<license.organizationName>Ifremer, Codelutin</license.organizationName>
@@ -493,7 +501,7 @@
<eugeneVersion>2.7.4</eugeneVersion>
<topiaVersion>2.9.1</topiaVersion>
<hibernateVersion>4.3.6.Final</hibernateVersion>
- <nuitonI18nVersion>3.1</nuitonI18nVersion>
+ <nuitonI18nVersion>3.2</nuitonI18nVersion>
<nuitonWidgetsVersion>1.1.1</nuitonWidgetsVersion>
<redmine.releaseFiles>target/isis-fish-${project.version}-bin.zip</redmine.releaseFiles>
@@ -512,8 +520,8 @@
<distributionManagement>
<site>
- <id>doc.${platform}</id>
- <url>${our.site.repository}/isis-fish</url>
+ <id>${siteDeployId}</id>
+ <url>${siteDeployUrl}</url>
</site>
</distributionManagement>
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -25,8 +25,8 @@
package fr.ifremer.isisfish;
+import static org.nuiton.i18n.I18n.n;
import static org.nuiton.i18n.I18n.t;
-import static org.nuiton.i18n.I18n.n;
import java.io.File;
import java.net.MalformedURLException;
@@ -40,12 +40,15 @@
import java.util.Locale;
import java.util.Map;
-import fr.ifremer.isisfish.actions.ValidateSimulationAction;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
-import org.nuiton.math.matrix.DoubleBigVector;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.config.ApplicationConfig;
import org.nuiton.config.ConfigOptionDef;
+import org.nuiton.converter.ConverterUtil;
+import org.nuiton.math.matrix.DoubleBigVector;
+import org.nuiton.math.matrix.DoubleSparseHashVector;
import org.nuiton.util.StringUtil;
import org.nuiton.util.Version;
@@ -54,6 +57,7 @@
import fr.ifremer.isisfish.actions.OtherAction;
import fr.ifremer.isisfish.actions.SimulationAction;
import fr.ifremer.isisfish.actions.VCSAction;
+import fr.ifremer.isisfish.actions.ValidateSimulationAction;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.launcher.InProcessSimulatorLauncher;
@@ -63,7 +67,6 @@
import fr.ifremer.isisfish.util.IsisCacheBackend;
import fr.ifremer.isisfish.util.IsisCacheBackendOnGuava;
import fr.ifremer.isisfish.vcs.VCS;
-import org.nuiton.math.matrix.DoubleSparseHashVector;
/**
* Isis fish configuration.
@@ -75,7 +78,10 @@
* by : $Author: bpoussin $
*/
public class IsisConfig extends ApplicationConfig {
-
+
+ /** Class logger. */
+ static private Log log = LogFactory.getLog(IsisConfig.class);
+
/**
* Config step after init.
*
@@ -122,7 +128,7 @@
* migration de donnees demande automatiquement un changement de version
* d'application.
*/
- protected final static Version version = new Version(4, 3, 1, 0);
+ protected final static Version version = new Version(4, 3, 1, 1);
protected final static Version majorVersion = new Version(version.getNumber(0));
protected final static Version databaseVersion = new Version(
@@ -181,7 +187,16 @@
protected long startingTime = System.currentTimeMillis();
public IsisConfig() {
-
+
+ // fix missing converter for locale
+ try {
+ ConverterUtil.registerConverter(Locale.class);
+ } catch (Exception ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't register locale converter", ex);
+ }
+ }
+
for (Option o : Option.values()) {
if (o.defaultValue != null) {
setDefaultOption(o.key, o.defaultValue);
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageAbstract.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageAbstract.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageAbstract.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -207,6 +207,7 @@
* return list of all result name available
* @return
*/
+ @Override
abstract public List<String> getResultName();
/**
@@ -558,6 +559,11 @@
}
}
+ // s'il n'y pas de resultat, on retourne null
+ if (sample == null) {
+ return null;
+ }
+
// creation des dimensions
String[] dimNames = new String[1 + sample.getDimCount()];
dimNames[0] = t("isisfish.common.date");
@@ -670,6 +676,11 @@
*/
protected TopiaContext getTx(TopiaContext tx) {
TopiaContext result = tx;
+
+ // FIXME echatellier 20140811 : when reruninig again export outside of simulation
+ // no simulation is registred into SimulationContext thread local, so this
+ // method return no transaction
+
if (tx == null) {
// si on a pas de tx, on recherche si on est dans une simulation
// pour recuperer la tx de la simulation
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/SimulationInformation.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/SimulationInformation.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/SimulationInformation.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -43,6 +43,7 @@
import java.util.Set;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -175,14 +176,14 @@
// general information
String info = getInformation();
- if (info != null && !"".equals(info)) {
- result += "Information:\n" + info + "\n";
+ if (StringUtils.isNotBlank(info)) {
+ result += "\nInformation:\n\t" + info + "\n";
}
// Statistic
String v = getStatistic();
if (v != null) {
- result += "Statistic:\n" + v + "\n";
+ result += "\nStatistic:\n" + v + "\n";
}
// Optimisation usage
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -35,6 +35,9 @@
import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.util.ConverterUtil;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETER_KEY;
+
/**
* Helper used to populate and extract instance parameters
* from simulation.
@@ -65,7 +68,7 @@
//ConvertUtilsBean beanUtils = ConverterUtil.getConverter(region
// .getStorage());
String exportName = JavaSourceStorage.getName(instance);
- String paramTag = propPrefix + "." + instanceIndex + ".parameter.";
+ String paramTag = propPrefix + "." + instanceIndex + DOT + PARAMETER_KEY + DOT;
for (Map.Entry<String, Class<?>> entry : JavaSourceStorage.getParameterNames(instance).entrySet()) {
String propName = entry.getKey();
@@ -120,7 +123,8 @@
Object value = RuleStorage.getParameterValue(instance, paramName);
paramValueString = beanUtils.convert(value);
if (paramValueString != null) {
- result.setProperty(propPrefix + "." + instanceIndex + ".parameter." + paramName, paramValueString);
+ result.setProperty(propPrefix + DOT + instanceIndex
+ + DOT + PARAMETER_KEY + DOT + paramName, paramValueString);
}
} catch (IsisFishException eee) {
if (log.isWarnEnabled()) {
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -209,7 +209,7 @@
// return t("isisfish.populationGroup.toString", this.getPopulation(),
// this.getId());
if (toStringCache == null) {
- toStringCache = this.getPopulation().toString() + " Group " + this.getId();
+ toStringCache = this.getPopulation() + " Group " + this.getId();
}
return toStringCache;
}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/StrategyMonthInfoImpl.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/StrategyMonthInfoImpl.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/entities/StrategyMonthInfoImpl.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -39,6 +39,7 @@
import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.datastore.RegionStorage;
import fr.ifremer.isisfish.datastore.StorageException;
+import java.util.Collections;
import org.nuiton.math.matrix.MatrixIterator;
/**
@@ -72,10 +73,15 @@
@Override
public List<Metier> getMetierWithProportion() {
- MatrixND mat = super.getProportionMetier();
- List<Metier> result = new ArrayList<Metier>(mat.getDim(0));
- for (MatrixIterator i = mat.iteratorNotZero(); i.next();) {
- result.add((Metier)i.getSemanticsCoordinates()[0]);
+ MatrixND mat = getProportionMetier();
+ List<Metier> result;
+ if (mat == null) {
+ result = Collections.EMPTY_LIST;
+ } else {
+ result = new ArrayList<Metier>(mat.getDim(0));
+ for (MatrixIterator i=mat.iteratorNotZero(); i.next();) {
+ result.add((Metier)i.getSemanticsCoordinates()[0]);
+ }
}
return result;
}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -40,6 +40,7 @@
import fr.ifremer.isisfish.datastore.ExportStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.datastore.StorageHelper;
+import fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper;
/**
* Helper for exports manipulation.
@@ -131,7 +132,8 @@
*/
public static void populateSensitivityExport(int exportIndex, TopiaContext context,
SensitivityExport export, Properties props) {
- populateStorageParams(exportIndex, context, export, props, "sensitivityexport");
+ populateStorageParams(exportIndex, context, export, props,
+ SimulationParameterPropertiesHelper.SENSITIVITY_EXPORT_KEY);
}
/**
@@ -146,6 +148,7 @@
*/
public static Properties getSensitivityExportAsProperties(
int sensitivityExportIndex, TopiaContext context, SensitivityExport sensitivityExport) {
- return getParamsAsProperties(sensitivityExportIndex, context, sensitivityExport, "sensitivityexport");
+ return getParamsAsProperties(sensitivityExportIndex, context, sensitivityExport,
+ SimulationParameterPropertiesHelper.SENSITIVITY_EXPORT_KEY);
}
}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -333,14 +333,14 @@
MatrixND holdCatch = holdCatchs.get(pop);
if (holdCatch == null) {
- holdCatch = MatrixFactory.getInstance().create(catchPerStrategyMet);
+ holdCatch = catchPerStrategyMet.copy();
holdCatchs.put(pop, holdCatch);
} else {
holdCatch.add(catchPerStrategyMet);
}
// compute total
- for (MatrixIterator i = catchPerStrategyMet.iterator(); i.next();) {
+ for (MatrixIterator i = catchPerStrategyMet.iteratorNotZero(); i.next();) {
this.totalHoldCatch += i.getValue();
}
// this.totalHoldCatch += catchPerStrategyMet.sumAll();
@@ -402,7 +402,7 @@
// seul le discard de l'annee en cours est disponible, sinon on doit
// aller le chercher dans les resultats
Map.Entry<TimeStep, MatrixND> discard = discards.get(pop);
- if (discard != null && discard.getValue().equals(step)) {
+ if (discard != null && discard.getKey().equals(step)) {
result = discard.getValue();
}
return result;
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2006 - 2014 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -44,10 +44,10 @@
*/
public class RuleMonitor {
- protected MultiKeyMap evalutionCondition = new MultiKeyMap();
+ protected MultiKeyMap<Object, Boolean> evalutionCondition = new MultiKeyMap<Object, Boolean>();
public boolean getEvalutionCondition(TimeStep step, Rule rule, Metier metier) {
- return (Boolean) this.evalutionCondition.get(step, rule, metier);
+ return this.evalutionCondition.get(step, rule, metier);
}
public void setEvaluationCondition(TimeStep step, Rule rule, Metier metier,
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -26,6 +26,8 @@
package fr.ifremer.isisfish.simulator;
import fr.ifremer.isisfish.IsisFish;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+
import java.io.File;
import java.util.HashMap;
import java.util.LinkedHashSet;
@@ -39,11 +41,14 @@
import org.nuiton.topia.persistence.TopiaEntity;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.*;
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityUtils;
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.IsisCache;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+
import org.nuiton.config.ApplicationConfig;
import org.nuiton.config.OverwriteApplicationConfig;
import org.nuiton.math.matrix.MatrixFactory;
@@ -540,4 +545,301 @@
}
return v;
}
+
+ /**
+ * Rollback region database transaction.
+ *
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public void rollbackRuleChanges() throws TopiaException {
+ TopiaContext tx = getDB();
+ tx.rollbackTransaction();
+ }
+
+ /**
+ * Commit result storage transaction.
+ *
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public void commitResults() throws TopiaException {
+ TopiaContext tx = getDbResult();
+ tx.commitTransaction();
+ }
+
+ /**
+ * Get {@link ActiveRuleDAO} on region database.
+ *
+ * @return ActiveRuleDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public ActiveRuleDAO getActiveRuleDAO() throws TopiaException {
+ return IsisFishDAOHelper.getActiveRuleDAO(getDB());
+ }
+
+ /**
+ * Get {@link CellDAO} on region database.
+ *
+ * @return CellDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public CellDAO getCellDAO() throws TopiaException {
+ return IsisFishDAOHelper.getCellDAO(getDB());
+ }
+
+ /**
+ * Get {@link EffortDescriptionDAO} on region database.
+ *
+ * @return EffortDescriptionDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public EffortDescriptionDAO getEffortDescriptionDAO() throws TopiaException {
+ return IsisFishDAOHelper.getEffortDescriptionDAO(getDB());
+ }
+
+ /**
+ * Get {@link EquationDAO} on region database.
+ *
+ * @return EquationDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public EquationDAO getEquationDAO() throws TopiaException {
+ return IsisFishDAOHelper.getEquationDAO(getDB());
+ }
+
+ /**
+ * Get {@link FisheryRegionDAO} on region database.
+ *
+ * @return FisheryRegionDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public FisheryRegionDAO getFisheryRegionDAO() throws TopiaException {
+ return IsisFishDAOHelper.getFisheryRegionDAO(getDB());
+ }
+
+ /**
+ * Get {@link GearDAO} on region database.
+ *
+ * @return GearDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public GearDAO getGearDAO() throws TopiaException {
+ return IsisFishDAOHelper.getGearDAO(getDB());
+ }
+
+ /**
+ * Get {@link MetierDAO} on region database.
+ *
+ * @return MetierDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public MetierDAO getMetierDAO() throws TopiaException {
+ return IsisFishDAOHelper.getMetierDAO(getDB());
+ }
+
+ /**
+ * Get {@link MetierSeasonInfoDAO} on region database.
+ *
+ * @return MetierSeasonInfoDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public MetierSeasonInfoDAO getMetierSeasonInfoDAO() throws TopiaException {
+ return IsisFishDAOHelper.getMetierSeasonInfoDAO(getDB());
+ }
+
+ /**
+ * Get {@link ObservationDAO} on region database.
+ *
+ * @return ObservationDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public ObservationDAO getObservationDAO() throws TopiaException {
+ return IsisFishDAOHelper.getObservationDAO(getDB());
+ }
+
+ /**
+ * Get {@link PopulationDAO} on region database.
+ *
+ * @return PopulationDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public PopulationDAO getPopulationDAO() throws TopiaException {
+ return IsisFishDAOHelper.getPopulationDAO(getDB());
+ }
+
+ /**
+ * Get {@link PopulationGroupDAO} on region database.
+ *
+ * @return PopulationGroupDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public PopulationGroupDAO getPopulationGroupDAO() throws TopiaException {
+ return IsisFishDAOHelper.getPopulationGroupDAO(getDB());
+ }
+
+ /**
+ * Get {@link PopulationSeasonInfoDAO} on region database.
+ *
+ * @return PopulationSeasonInfoDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public PopulationSeasonInfoDAO getPopulationSeasonInfoDAO() throws TopiaException {
+ return IsisFishDAOHelper.getPopulationSeasonInfoDAO(getDB());
+ }
+
+ /**
+ * Get {@link PortDAO} on region database.
+ *
+ * @return PortDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public PortDAO getPortDAO() throws TopiaException {
+ return IsisFishDAOHelper.getPortDAO(getDB());
+ }
+
+ /**
+ * Get {@link ResultDAO} on region database.
+ *
+ * @return ResultDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public ResultDAO getResultDAO() throws TopiaException {
+ return IsisFishDAOHelper.getResultDAO(getDB());
+ }
+
+ /**
+ * Get {@link SeasonDAO} on region database.
+ *
+ * @return SeasonDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public SeasonDAO getSeasonDAO() throws TopiaException {
+ return IsisFishDAOHelper.getSeasonDAO(getDB());
+ }
+
+ /**
+ * Get {@link SelectivityDAO} on region database.
+ *
+ * @return SelectivityDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public SelectivityDAO getSelectivityDAO() throws TopiaException {
+ return IsisFishDAOHelper.getSelectivityDAO(getDB());
+ }
+
+ /**
+ * Get {@link SetOfVesselsDAO} on region database.
+ *
+ * @return SetOfVesselsDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public SetOfVesselsDAO getSetOfVesselsDAO() throws TopiaException {
+ return IsisFishDAOHelper.getSetOfVesselsDAO(getDB());
+ }
+
+ /**
+ * Get {@link SpeciesDAO} on region database.
+ *
+ * @return SpeciesDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public SpeciesDAO getSpeciesDAO() throws TopiaException {
+ return IsisFishDAOHelper.getSpeciesDAO(getDB());
+ }
+
+ /**
+ * Get {@link StrategyDAO} on region database.
+ *
+ * @return StrategyDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public StrategyDAO getStrategyDAO() throws TopiaException {
+ return IsisFishDAOHelper.getStrategyDAO(getDB());
+ }
+
+ /**
+ * Get {@link StrategyMonthInfoDAO} on region database.
+ *
+ * @return StrategyMonthInfoDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public StrategyMonthInfoDAO getStrategyMonthInfoDAO() throws TopiaException {
+ return IsisFishDAOHelper.getStrategyMonthInfoDAO(getDB());
+ }
+
+ /**
+ * Get {@link TargetSpeciesDAO} on region database.
+ *
+ * @return TargetSpeciesDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public TargetSpeciesDAO getTargetSpeciesDAO() throws TopiaException {
+ return IsisFishDAOHelper.getTargetSpeciesDAO(getDB());
+ }
+
+ /**
+ * Get {@link TripTypeDAO} on region database.
+ *
+ * @return TripTypeDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public TripTypeDAO getTripTypeDAO() throws TopiaException {
+ return IsisFishDAOHelper.getTripTypeDAO(getDB());
+ }
+
+ /**
+ * Get {@link VariableDAO} on region database.
+ *
+ * @return VariableDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public VariableDAO getVariableDAO() throws TopiaException {
+ return IsisFishDAOHelper.getVariableDAO(getDB());
+ }
+
+ /**
+ * Get {@link VesselTypeDAO} on region database.
+ *
+ * @return VesselTypeDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public VesselTypeDAO getVesselTypeDAO() throws TopiaException {
+ return IsisFishDAOHelper.getVesselTypeDAO(getDB());
+ }
+
+ /**
+ * Get {@link ZoneDAO} on region database.
+ *
+ * @return ZoneDAO
+ * @throws TopiaException
+ * @since 4.3.1.0
+ */
+ public ZoneDAO getZoneDAO() throws TopiaException {
+ return IsisFishDAOHelper.getZoneDAO(getDB());
+ }
}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -54,7 +54,6 @@
import fr.ifremer.isisfish.IsisConfig;
import fr.ifremer.isisfish.IsisFishDAOHelper;
-import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.datastore.ExportStorage;
import fr.ifremer.isisfish.datastore.ObjectiveStorage;
import fr.ifremer.isisfish.datastore.OptimizationStorage;
@@ -75,9 +74,15 @@
import fr.ifremer.isisfish.rule.Rule;
import fr.ifremer.isisfish.rule.RuleHelper;
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityAnalysis;
+import fr.ifremer.isisfish.util.ConverterUtil;
+import java.util.Collections;
+import org.apache.commons.beanutils.ConvertUtilsBean;
import static org.nuiton.i18n.I18n.n;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.LIST_SEPARATOR;
+
/**
* Real {@link SimulationParameter} implementation.
*
@@ -90,7 +95,7 @@
public class SimulationParameterImpl implements SimulationParameter {
/** Logger for this class. */
- private static Log log = LogFactory.getLog(SimulationParameterImpl.class);
+ final private static Log log = LogFactory.getLog(SimulationParameterImpl.class);
/** Remember last read properties. */
protected Properties propertiesParameters;
@@ -236,7 +241,7 @@
// if not already set
if (isisFishVersion == null) {
if (propertiesParameters != null) {
- isisFishVersion = propertiesParameters.getProperty("isisFishVersion", "");
+ isisFishVersion = SimulationParameterPropertiesHelper.getIsisFishVersion(propertiesParameters);
} else {
// default value
isisFishVersion = IsisConfig.getVersion();
@@ -261,7 +266,8 @@
if (description == null) {
if (propertiesParameters != null) {
- description = propertiesParameters.getProperty("description", "");
+ description = SimulationParameterPropertiesHelper
+ .getDescription(propertiesParameters);
} else {
// default value
description = "";
@@ -310,10 +316,10 @@
List groups = pop.getPopulationGroup();
List zones = pop.getPopulationZone();
- if (groups.size() == 0) {
+ if (groups.isEmpty()) {
groups.add("No group");
}
- if (zones.size() == 0) {
+ if (zones.isEmpty()) {
zones.add("No zone");
}
List[] semantics = new List[] { groups, zones };
@@ -373,16 +379,15 @@
PopulationDAO populationDAO = IsisFishDAOHelper
.getPopulationDAO(tx);
- String[] populationList = propertiesParameters.getProperty(
- "populations", "").split(",");
+ String[] populationList = SimulationParameterPropertiesHelper
+ .getPopulationNames(propertiesParameters);
for (String name : populationList) {
- if (name != null && !"".equals(name)) {
+ if (StringUtils.isNotEmpty(name)) {
try {
Population population = populationDAO.findByName(name);
populations.add(population);
- String numberAsString = propertiesParameters.getProperty("population." + name + ".number");
- List number = MatrixHelper.convertStringToList(numberAsString);
+ List number = SimulationParameterPropertiesHelper.getPopulationNumbers(propertiesParameters, name);
MatrixND mat = getNumberOf(population);
mat.fromList(number);
} catch (TopiaException eee) {
@@ -448,9 +453,10 @@
}
StrategyDAO strategyDAO = IsisFishDAOHelper.getStrategyDAO(tx);
- String[] strategyList = propertiesParameters.getProperty("strategies", "").split(",");
+ String[] strategyList = SimulationParameterPropertiesHelper
+ .getStrategieNames(propertiesParameters);
for (String name : strategyList) {
- if (name != null && !"".equals(name)) {
+ if (StringUtils.isNotEmpty(name)) {
try {
Strategy str = strategyDAO.findByName(name);
strategies.add(str);
@@ -516,20 +522,21 @@
if (propertiesParameters != null) {
// simulation plan
- String[] planList = propertiesParameters.getProperty("plans",
- "").split(",");
+ String[] planList = SimulationParameterPropertiesHelper
+ .getSimulationPlanNames(propertiesParameters);
int planIndex = 0;
for (String name : planList) {
- if (name != null && !"".equals(name)) {
+ if (StringUtils.isNotEmpty(name)) {
try {
SimulationPlanStorage planStorage = SimulationPlanStorage.getSimulationPlan(name);
if (planStorage != null) { // since 4.0.0.3 can return null
SimulationPlan plan = planStorage.getNewInstance();
StorageHelper.populateStorageParams(planIndex++,
- getRegion().getStorage(), plan, propertiesParameters, "plan");
+ getRegion().getStorage(), plan, propertiesParameters,
+ SimulationParameterPropertiesHelper.PLAN_KEY);
simulationPlans.add(plan);
}
- } catch (IsisFishException eee) {
+ } catch (Exception eee) {
if (log.isWarnEnabled()) {
log.warn("Can't find plan: " + name, eee);
}
@@ -617,15 +624,16 @@
}
// rules
- String[] ruleList = propertiesParameters.getProperty("rules", "").split(",");
+ String[] ruleList = SimulationParameterPropertiesHelper
+ .getRuleNames(propertiesParameters);
int ruleIndex = 0;
for (String name : ruleList) {
- if (name != null && !"".equals(name)) {
+ if (StringUtils.isNotEmpty(name)) {
try {
Rule rule = RuleStorage.getRule(name).getNewInstance();
RuleHelper.populateRule(ruleIndex++, tx, rule, propertiesParameters);
rules.add(rule);
- } catch (IsisFishException eee) {
+ } catch (Exception eee) {
if (log.isWarnEnabled()) {
log.warn("Can't find rule: " + name, eee);
}
@@ -677,15 +685,17 @@
// en version < 4.3, le parametre était nommé 'useOptimization'
// qualifiait le cache, il été renommé ensuite
if (VersionUtil.smallerThan(getIsisFishVersion(), "4.3.0.0")) {
- useCache = Boolean.valueOf(propertiesParameters.getProperty("useOptimization", "true"));
+ useCache = Boolean.valueOf(propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.USE_OPTIMIZATION_KEY, "true"));
} else {
- useCache = Boolean.valueOf(propertiesParameters.getProperty("useCache", "true"));
+ useCache = Boolean.valueOf(propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.USE_CACHE_KEY, "true"));
}
} else {
useCache = Boolean.TRUE;
}
}
- return useCache.booleanValue();
+ return useCache;
}
@Override
@@ -701,7 +711,7 @@
if (useStatistic == null) {
if (propertiesParameters != null) {
- useStatistic = Boolean.valueOf(propertiesParameters.getProperty("useStatistic", "false"));
+ useStatistic = SimulationParameterPropertiesHelper.getUseStatistic(propertiesParameters);
} else {
useStatistic = Boolean.FALSE;
}
@@ -727,9 +737,9 @@
if (propertiesParameters != null) {
// exports
- String[] exportList = propertiesParameters.getProperty("exports", "").split(",");
+ String[] exportList = SimulationParameterPropertiesHelper.getExportNames(propertiesParameters);
for (String name : exportList) {
- if (name != null && !"".equals(name)) {
+ if (StringUtils.isNotEmpty(name)) {
exportNames.add(name);
}
}
@@ -755,14 +765,14 @@
if (numberOfSensitivitySimulation == null) {
if (propertiesParameters != null) {
- numberOfSensitivitySimulation = Integer.valueOf(propertiesParameters.getProperty(
- "numberOfSensitivitySimulation", "-1"));
+ numberOfSensitivitySimulation =
+ SimulationParameterPropertiesHelper.getNumberOfSensitivitySimulation(propertiesParameters);
} else {
- numberOfSensitivitySimulation = Integer.valueOf(-1);
+ numberOfSensitivitySimulation = -1;
}
}
- return numberOfSensitivitySimulation.intValue();
+ return numberOfSensitivitySimulation;
}
/*
@@ -782,16 +792,17 @@
if (sensitivityAnalysis == null) {
if (propertiesParameters != null) {
- String analysisName = propertiesParameters
- .getProperty("sensitivityanalysis");
- if (!StringUtils.isEmpty(analysisName)) {
+ String analysisName = SimulationParameterPropertiesHelper
+ .getSensitivityAnalysis(propertiesParameters);
+ if (StringUtils.isNotEmpty(analysisName)) {
try {
SensitivityAnalysisStorage sensitivityStorage = SensitivityAnalysisStorage.getSensitivityAnalysis(analysisName);
sensitivityAnalysis = sensitivityStorage.getNewInstance();
// 0 = only single sensitivity
- StorageHelper.populateStorageParams(0, getRegion().getStorage(), sensitivityAnalysis,
- propertiesParameters, "sensitivity");
- } catch (IsisFishException eee) {
+ StorageHelper.populateStorageParams(0, getRegion().getStorage(),
+ sensitivityAnalysis, propertiesParameters,
+ SimulationParameterPropertiesHelper.SENSITIVITY_KEY);
+ } catch (Exception eee) {
sensitivityAnalysis = null;
if (log.isWarnEnabled()) {
log.warn("Can't find sensitivity: " + sensitivityAnalysis, eee);
@@ -836,8 +847,8 @@
}
// sensitivity export
- String[] sensitivityExportList = propertiesParameters
- .getProperty("sensitivityexports", "").split(",");
+ String[] sensitivityExportList = SimulationParameterPropertiesHelper
+ .getSensitivityExportNames(propertiesParameters);
int sensitivityExportIndex = 0;
for (String name : sensitivityExportList) {
try {
@@ -851,7 +862,7 @@
propertiesParameters);
sensitivityExports.add(sensitivityExport);
}
- } catch (IsisFishException eee) {
+ } catch (Exception eee) {
if (log.isWarnEnabled()) {
log.warn("Can't find SensitivityExport: " + name, eee);
}
@@ -889,15 +900,18 @@
public Optimization getOptimization() {
if (optimization == null) {
if (propertiesParameters != null) {
- String optimizationName = propertiesParameters.getProperty("optimization");
+ String optimizationName = SimulationParameterPropertiesHelper
+ .getOptimizationName(propertiesParameters);
if (!StringUtils.isEmpty(optimizationName)) {
try {
- OptimizationStorage optimizationStorage = OptimizationStorage.getOptimization(optimizationName);
+ OptimizationStorage optimizationStorage =
+ OptimizationStorage.getOptimization(optimizationName);
optimization = optimizationStorage.getNewInstance();
// 0 = only single optimization
- StorageHelper.populateStorageParams(0, getRegion().getStorage(), optimization,
- propertiesParameters, "optimization");
- } catch (IsisFishException eee) {
+ StorageHelper.populateStorageParams(0, getRegion().getStorage(),
+ optimization, propertiesParameters,
+ SimulationParameterPropertiesHelper.OPTIMIZATION_KEY);
+ } catch (Exception eee) {
optimization = null;
if (log.isWarnEnabled()) {
log.warn("Can't find optimization: " + optimization, eee);
@@ -919,13 +933,14 @@
if (VersionUtil.smallerThan(getIsisFishVersion(), "4.3.0.0")) {
useOptimization = Boolean.FALSE;
} else {
- useOptimization = Boolean.valueOf(propertiesParameters.getProperty("useOptimization", "false"));
+ useOptimization = Boolean.valueOf(propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.USE_OPTIMIZATION_KEY, "false"));
}
} else {
useOptimization = Boolean.FALSE;
}
}
- return useOptimization.booleanValue();
+ return useOptimization;
}
@Override
@@ -942,15 +957,18 @@
public Objective getObjective() {
if (objective == null) {
if (propertiesParameters != null) {
- String objectiveName = propertiesParameters.getProperty("objective");
+ String objectiveName = SimulationParameterPropertiesHelper
+ .getObjectiveName(propertiesParameters);
if (!StringUtils.isEmpty(objectiveName)) {
try {
- ObjectiveStorage objectiveStorage = ObjectiveStorage.getObjective(objectiveName);
+ ObjectiveStorage objectiveStorage =
+ ObjectiveStorage.getObjective(objectiveName);
objective = objectiveStorage.getNewInstance();
// 0 = only single objective
- StorageHelper.populateStorageParams(0, getRegion().getStorage(), objective,
- propertiesParameters, "objective");
- } catch (IsisFishException eee) {
+ StorageHelper.populateStorageParams(0, getRegion().getStorage(),
+ objective, propertiesParameters,
+ SimulationParameterPropertiesHelper.OBJECTIVE_KEY);
+ } catch (Exception eee) {
objective = null;
if (log.isWarnEnabled()) {
log.warn("Can't find objective: " + objective, eee);
@@ -976,7 +994,7 @@
if (propertiesParameters != null) {
try {
// On verifie tout d'abord que l'on ai pas dans une simulation
- // si on y es, on utilise le context static non null du thread local
+ // si on y est, on utilise le context static non null du thread local
// Resoud les lazy exceptions des parametres des regles
boolean mustClose = false;
TopiaContext tx = SimulationContext.get().getDB();
@@ -988,19 +1006,24 @@
}
// rules
- String[] optimizationExportList = propertiesParameters.getProperty("optimizationexports", "").split(",");
+ String[] optimizationExportList = SimulationParameterPropertiesHelper
+ .getOptimizationExportNames(propertiesParameters);
+ ConvertUtilsBean beanUtils = ConverterUtil.getConverter(tx);
int optimizationExportIndex = 0;
for (String name : optimizationExportList) {
- if (name != null && !"".equals(name)) {
+ if (StringUtils.isNotBlank(name)) {
try {
Export export = ExportStorage.getExport(name).getNewInstance();
Observation observation = null;
- String observationId = propertiesParameters.getProperty("optimizationobservation." + optimizationExportIndex);
+ String observationId = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.
+ OPTIMIZATION_OBSERVATION_KEY
+ + DOT + optimizationExportIndex);
if (StringUtils.isNotBlank(observationId)) {
- observation = (Observation)tx.findByTopiaId(observationId);
+ observation = (Observation)beanUtils.convert(observationId, TopiaEntity.class);
}
optimizationExportsObservations.put(export, observation);
- } catch (IsisFishException eee) {
+ } catch (Exception eee) {
if (log.isWarnEnabled()) {
log.warn("Can't find rule: " + name, eee);
}
@@ -1039,7 +1062,7 @@
if (useSimulationPlan == null) {
if (propertiesParameters != null) {
- useSimulationPlan = Boolean.valueOf(propertiesParameters.getProperty("useSimulationPlan", "false"));
+ useSimulationPlan = SimulationParameterPropertiesHelper.getUseSimulationPlan(propertiesParameters);
} else {
useSimulationPlan = Boolean.FALSE;
}
@@ -1064,13 +1087,13 @@
if (simulationPlanNumber == null) {
if (propertiesParameters != null) {
- simulationPlanNumber = Integer.valueOf(propertiesParameters.getProperty("simulationPlanNumber", "-1"));
+ simulationPlanNumber = SimulationParameterPropertiesHelper.getSimulationPlanNumber(propertiesParameters);
} else {
- simulationPlanNumber = Integer.valueOf(-1);
+ simulationPlanNumber = -1;
}
}
- return simulationPlanNumber.intValue();
+ return simulationPlanNumber;
}
/*
@@ -1086,13 +1109,13 @@
if (sensitivityAnalysisOnlyKeepFirst == null) {
if (propertiesParameters != null) {
- sensitivityAnalysisOnlyKeepFirst = Boolean.valueOf(propertiesParameters.getProperty("sensitivityAnalysisOnlyKeepFirst", "-1"));
+ sensitivityAnalysisOnlyKeepFirst = SimulationParameterPropertiesHelper.isSensitivityAnalysisOnlyKeepFirst(propertiesParameters);
} else {
sensitivityAnalysisOnlyKeepFirst = Boolean.FALSE;
}
}
- return sensitivityAnalysisOnlyKeepFirst.booleanValue();
+ return sensitivityAnalysisOnlyKeepFirst;
}
@Override
@@ -1109,12 +1132,13 @@
if (numberOfYear == null) {
if (propertiesParameters != null) {
- numberOfYear = Integer.valueOf(propertiesParameters.getProperty("numberOfYear", "1"));
+ numberOfYear = SimulationParameterPropertiesHelper
+ .getNumberOfYear(propertiesParameters);
} else {
- numberOfYear = Integer.valueOf(1);
+ numberOfYear = 1;
}
}
- return numberOfYear.intValue();
+ return numberOfYear;
}
/*
@@ -1134,13 +1158,13 @@
if (usePreScript == null) {
if (propertiesParameters != null) {
- usePreScript = Boolean.valueOf(propertiesParameters.getProperty("usePreScript", "false"));
+ usePreScript = SimulationParameterPropertiesHelper.getUsePreScript(propertiesParameters);
} else {
usePreScript = Boolean.FALSE;
}
}
- return usePreScript.booleanValue();
+ return usePreScript;
}
/*
@@ -1160,7 +1184,7 @@
if (preScript == null) {
if (propertiesParameters != null) {
- preScript = propertiesParameters.getProperty("preScript", "");
+ preScript = SimulationParameterPropertiesHelper.getPreScript(propertiesParameters);
} else {
preScript = "";
}
@@ -1183,7 +1207,8 @@
if (generatedPreScript == null) {
if (propertiesParameters != null) {
- generatedPreScript = propertiesParameters.getProperty("generatedPreScript", "");
+ generatedPreScript = SimulationParameterPropertiesHelper
+ .getGeneratedPreScript(propertiesParameters);
} else {
generatedPreScript = "";
}
@@ -1205,7 +1230,8 @@
if (regionName == null) {
if (propertiesParameters != null) {
- regionName = propertiesParameters.getProperty("regionName", "");
+ regionName = SimulationParameterPropertiesHelper
+ .getRegionName(propertiesParameters);
} else {
// defaut value
regionName = "";
@@ -1231,8 +1257,8 @@
if (simulatorName == null) {
if (propertiesParameters != null) {
- simulatorName = propertiesParameters.getProperty(
- "simulatorName", "DefaultSimulator.java");
+ simulatorName = SimulationParameterPropertiesHelper
+ .getSimulatorName(propertiesParameters);
} else {
simulatorName = "DefaultSimulator.java";
}
@@ -1259,12 +1285,9 @@
resultEnabled = new LinkedList<String>();
if (propertiesParameters != null) {
- String[] resultList = propertiesParameters.getProperty("resultNames", "").split(",");
- for (String name : resultList) {
- if (name != null && !"".equals(name)) {
- resultEnabled.add(name);
- }
- }
+ String[] resultList =
+ SimulationParameterPropertiesHelper.getResultNames(propertiesParameters);
+ Collections.addAll(resultEnabled, resultList);
}
}
return resultEnabled;
@@ -1285,16 +1308,10 @@
public Map<String, String> getTagValue() {
if (tagValue == null) {
- tagValue = new LinkedHashMap<String, String>();
-
if (propertiesParameters != null) {
- for (Object k : propertiesParameters.keySet()) {
- if (k.toString().startsWith("tagValue.")) {
- String key = k.toString().substring("tagValue.".length());
- String value = propertiesParameters.getProperty(k.toString());
- getTagValue().put(key, value);
- }
- }
+ tagValue = SimulationParameterPropertiesHelper.getTagValue(propertiesParameters);
+ } else {
+ tagValue = new LinkedHashMap<String, String>();
}
}
@@ -1318,7 +1335,8 @@
if (simulLogLevel == null) {
if (propertiesParameters != null) {
- simulLogLevel = propertiesParameters.getProperty("simulLogLevel", "info");
+ simulLogLevel = SimulationParameterPropertiesHelper
+ .getSimulLogLevel(propertiesParameters);
} else {
simulLogLevel = "info";
}
@@ -1347,8 +1365,8 @@
if (scriptLogLevel == null) {
if (propertiesParameters != null) {
- scriptLogLevel = propertiesParameters.getProperty(
- "scriptLogLevel", "info");
+ scriptLogLevel = SimulationParameterPropertiesHelper
+ .getScriptLogLevel(propertiesParameters);
} else {
scriptLogLevel = "info";
}
@@ -1376,7 +1394,8 @@
public String getLibLogLevel() {
if (libLogLevel == null) {
if (propertiesParameters != null) {
- libLogLevel = propertiesParameters.getProperty("libLogLevel", "error");
+ libLogLevel = SimulationParameterPropertiesHelper
+ .getLibLogLevel(propertiesParameters);
} else {
libLogLevel = "error";
}
@@ -1596,157 +1615,8 @@
*/
@Override
public String toString() {
- StringBuffer result = new StringBuffer();
- result.append(
- t("isisfish.params.toString.simulation.done",
- getIsisFishVersion())).append('\n');
- result.append("--------------------\n");
- result.append(getDescription()).append('\n');
- result.append("--------------------\n");
-
- if (getUseSimulationPlan()) {
- result.append(t("isisfish.params.toString.plan.number",
- getSimulationPlanNumber()));
- }
-
- if (getUseCache()) {
- result.append(t("isisfish.params.toString.use.cache",
- getUseCache()));
- }
-
- RegionStorage region = getRegion();
- result.append(t("isisfish.params.toString.fishery", region.getName()));
- result.append(t("isisfish.params.toString.number.years",
- getNumberOfYear()));
-
- // startegies
- List<Strategy> strs = getStrategies();
- result.append(t("isisfish.params.toString.strategies"));
- String sep = "";
- for (Strategy str : strs) {
- result.append(sep).append(str.getName());
- sep = ",";
- }
- result.append("\n\n");
-
- // populations
- result.append(t("isisfish.params.toString.populations"));
- sep = "";
- for (Population pop : getPopulations()) {
- result.append(sep).append(pop.getName());
- sep = ",";
- }
- result.append("\n\n");
-
- // rules
- for (Rule rule : getRules()) {
- String name = RuleStorage.getName(rule);
- String param = "";
- try {
- param = RuleStorage.getParamAsString(rule);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert rule parameter to string for "
- + name, eee);
- }
- }
- result.append(t("isisfish.params.toString.rule", name));
- result.append('\n');
- result.append(param);
- result.append("\n");
-
- }
- result.append("\n\n");
-
- // simulation plans
- for (SimulationPlan plan : getSimulationPlans()) {
- String name = SimulationPlanStorage.getName(plan);
- String param = "";
- try {
- param = SimulationPlanStorage.getParamAsString(plan);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert plan parameter to string for "
- + name, eee);
- }
- }
- result.append(t("isisfish.params.toString.plan", name));
- result.append('\n');
- result.append(param);
- result.append('\n');
-
- }
-
- if (getUseOptimization()) {
- result.append(t("isisfish.params.toString.use.optimization",
- getUseOptimization()));
- }
- if (objective != null) {
- String name = ObjectiveStorage.getName(objective);
- String param = "";
- try {
- param = ObjectiveStorage.getParamAsString(objective);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert objective parameter to string for "
- + name, eee);
- }
- }
- result.append(t("isisfish.params.toString.objective", name));
- result.append('\n');
- result.append(param);
- result.append('\n');
- }
-
- if (optimization != null) {
- String name = OptimizationStorage.getName(optimization);
- String param = "";
- try {
- param = OptimizationStorage.getParamAsString(optimization);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert optimization parameter to string for "
- + name, eee);
- }
- }
- result.append(t("isisfish.params.toString.optimization", name));
- result.append('\n');
- result.append(param);
- result.append('\n');
- }
-
- for (Map.Entry<Export, Observation> exportObservationEntry : getOptimizationExportsObservations().entrySet()) {
- Export export = exportObservationEntry.getKey();
- Observation observation = exportObservationEntry.getValue();
-
- String name = ExportStorage.getName(export);
- result.append(t("isisfish.params.toString.optimizationExport", name));
- result.append('\n');
- if (observation != null) {
- result.append(t("isisfish.params.toString.optimizationObservation", observation.getName()));
- result.append('\n');
- }
- }
-
- result.append('\n');
- result.append(t("isisfish.params.toString.script.generatedpresimulation"))
- .append(":\n");
- result.append(getGeneratedPreScript());
- result.append('\n');
- result.append(t("isisfish.params.toString.script.presimulation"))
- .append(":\n");
- result.append(getPreScript());
- result.append('\n');
- result.append(t("isisfish.params.toString.simul.logger.level",
- simulLogLevel));
- result.append('\n');
- result.append(t("isisfish.params.toString.script.logger.level",
- scriptLogLevel));
- result.append('\n');
- result.append(t("isisfish.params.toString.lib.logger.level",
- libLogLevel));
- result.append('\n');
- return result.toString();
+ Properties prop = toProperties();
+ return SimulationParameterPropertiesHelper.toString(prop);
}
/*
@@ -1756,25 +1626,29 @@
public Properties toProperties() {
Properties result = new SortedProperties();
- result.setProperty("isisFishVersion", getIsisFishVersion());
- result.setProperty("description", getDescription());
- result.setProperty("regionName", getRegionName());
- result.setProperty("numberOfYear", String.valueOf(getNumberOfYear()));
- result.setProperty("simulatorName", getSimulatorName());
- result.setProperty("useCache", String.valueOf(getUseCache()));
- result.setProperty("useStatistic", String.valueOf(getUseStatistic()));
+ result.setProperty(SimulationParameterPropertiesHelper.ISIS_FISH_VERSION_KEY, getIsisFishVersion());
+ result.setProperty(SimulationParameterPropertiesHelper.DESCRIPTION_KEY, getDescription());
+ result.setProperty(SimulationParameterPropertiesHelper.REGION_NAME_KEY, getRegionName());
+ result.setProperty(SimulationParameterPropertiesHelper.NUMBER_OF_YEAR_KEY, String.valueOf(getNumberOfYear()));
+ result.setProperty(SimulationParameterPropertiesHelper.SIMULATOR_NAME_KEY, getSimulatorName());
+ result.setProperty(SimulationParameterPropertiesHelper.USE_CACHE_KEY, String.valueOf(getUseCache()));
+ result.setProperty(SimulationParameterPropertiesHelper.USE_STATISTIC_KEY, String.valueOf(getUseStatistic()));
// strategies
if (strategies != null) {
String strategyList = "";
for (Strategy str : getStrategies()) {
- strategyList += str.getName() + ",";
+ strategyList += str.getName() + SimulationParameterPropertiesHelper.LIST_SEPARATOR;
}
- result.setProperty("strategies", StringUtil.substring(strategyList, 0, -1));
+ result.setProperty(SimulationParameterPropertiesHelper.STRATEGIES_KEY,
+ StringUtil.substring(strategyList, 0, -1));
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("strategies")) {
- result.setProperty("strategies", propertiesParameters.getProperty("strategies"));
+ if (propertiesParameters != null) {
+ String strs = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.STRATEGIES_KEY);
+ if (strs != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.STRATEGIES_KEY, strs);
+ }
}
}
@@ -1782,21 +1656,23 @@
if (populations != null) {
String populationList = "";
for (Population pop : getPopulations()) {
- populationList += pop.getName() + ",";
+ populationList += pop.getName() + LIST_SEPARATOR;
MatrixND number = getNumberOf(pop);
String numberAsString = String.valueOf(number.toList());
- result.setProperty("population." + pop.getName() + ".number", numberAsString);
+ result.setProperty(
+ SimulationParameterPropertiesHelper.POPULATION_KEY+ DOT + pop.getName()
+ + DOT + SimulationParameterPropertiesHelper.NUMBER_KEY, numberAsString);
}
- result.setProperty("populations", StringUtil.substring(
- populationList, 0, -1));
+ result.setProperty(SimulationParameterPropertiesHelper.POPULATIONS_KEY,
+ StringUtil.substring(populationList, 0, -1));
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("populations")) {
- result.setProperty("populations", propertiesParameters.getProperty("populations"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("population.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String pops = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.POPULATIONS_KEY);
+ if (pops != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.POPULATIONS_KEY, pops);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.POPULATION_KEY + DOT);
}
}
}
@@ -1806,21 +1682,20 @@
String ruleList = "";
int ruleIndex = 0;
for (Rule rule : getRules()) {
- ruleList += RuleStorage.getName(rule) + ",";
- Properties ruleProp = RuleHelper.getRuleAsProperties(ruleIndex++, getRegion().getStorage(), rule);
+ ruleList += RuleStorage.getName(rule) + LIST_SEPARATOR;
+ Properties ruleProp = RuleHelper.getRuleAsProperties(
+ ruleIndex++, getRegion().getStorage(), rule);
result.putAll(ruleProp);
}
- result.setProperty("rules", ruleList);
+ result.setProperty(SimulationParameterPropertiesHelper.RULES_KEY, ruleList);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("rules")) {
- result.setProperty("rules", propertiesParameters
- .getProperty("rules"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("rule.")) {
- result.setProperty(key, propertiesParameters
- .getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String rules = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.RULES_KEY);
+ if (rules != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.RULES_KEY, rules);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.RULE_KEY + DOT);
}
}
}
@@ -1830,21 +1705,20 @@
String planList = "";
int planIndex = 0;
for (SimulationPlan plan : getSimulationPlans()) {
- planList += SimulationPlanStorage.getName(plan) + ",";
+ planList += SimulationPlanStorage.getName(plan) + LIST_SEPARATOR;
Properties planProp = StorageHelper.getParamsAsProperties(planIndex++,
- getRegion().getStorage(), plan, "plan");
+ getRegion().getStorage(), plan, SimulationParameterPropertiesHelper.PLAN_KEY);
result.putAll(planProp);
}
- result.setProperty("plans", planList);
+ result.setProperty(SimulationParameterPropertiesHelper.PLANS_KEY, planList);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("plans")) {
- result.setProperty("plans", propertiesParameters
- .getProperty("plans"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("plan.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String plans = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.PLANS_KEY);
+ if (plans != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.PLANS_KEY, plans);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.PLAN_KEY + DOT);
}
}
}
@@ -1853,19 +1727,25 @@
if (objective != null) {
String objectiveName = ObjectiveStorage.getName(objective);
Properties objectiveProp = StorageHelper.getParamsAsProperties(0,
- getRegion().getStorage(), objective, "objective");
+ getRegion().getStorage(), objective,
+ SimulationParameterPropertiesHelper.OBJECTIVE_KEY);
result.putAll(objectiveProp);
- result.setProperty("objective", objectiveName);
+ result.setProperty(SimulationParameterPropertiesHelper.OBJECTIVE_KEY,
+ objectiveName);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("objective")) {
- result.setProperty("objective", propertiesParameters
- .getProperty("objective"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("objective.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
+ if (propertiesParameters != null) {
+ String objective = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.OBJECTIVE_KEY);
+ if (objective != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.OBJECTIVE_KEY, objective);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.OBJECTIVE_KEY + DOT);
+ } for (String key : propertiesParameters.stringPropertyNames()) {
+ if (key.startsWith(SimulationParameterPropertiesHelper.OBJECTIVE_KEY + DOT)) {
+ result.setProperty(key, propertiesParameters.getProperty(key));
+ }
}
- }
+
}
}
@@ -1873,18 +1753,19 @@
if (optimization != null) {
String optimizationName = ObjectiveStorage.getName(optimization);
Properties optimizationProp = StorageHelper.getParamsAsProperties(0,
- getRegion().getStorage(), optimization, "optimization");
+ getRegion().getStorage(), optimization,
+ SimulationParameterPropertiesHelper.OPTIMIZATION_KEY);
result.putAll(optimizationProp);
- result.setProperty("optimization", optimizationName);
+ result.setProperty(SimulationParameterPropertiesHelper.OPTIMIZATION_KEY,
+ optimizationName);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("optimization")) {
- result.setProperty("optimization", propertiesParameters
- .getProperty("optimization"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("optimization.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String optimization = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.OPTIMIZATION_KEY);
+ if (optimization != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.OPTIMIZATION_KEY, optimization);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.OPTIMIZATION_KEY + DOT);
}
}
}
@@ -1893,62 +1774,65 @@
if (optimizationExportsObservations != null) {
String optimizationExportsList = "";
int optimizationExportIndex = 0;
+ ConvertUtilsBean beanUtils = ConverterUtil.getConverter(null);
for (Map.Entry<Export, Observation> exportObservationEntry : optimizationExportsObservations.entrySet()) {
Export export = exportObservationEntry.getKey();
- optimizationExportsList += ExportStorage.getName(export) + ",";
+ optimizationExportsList += ExportStorage.getName(export) + LIST_SEPARATOR;
// add in props observation id export index
Observation observation = exportObservationEntry.getValue();
if (observation != null) {
- result.setProperty("optimizationobservation." + optimizationExportIndex, observation.getTopiaId());
+ result.setProperty(
+ SimulationParameterPropertiesHelper.OPTIMIZATION_OBSERVATION_KEY + DOT
+ + optimizationExportIndex,
+ beanUtils.convert(observation));
}
optimizationExportIndex++;
}
- result.setProperty("optimizationexports", optimizationExportsList);
+ result.setProperty(SimulationParameterPropertiesHelper.OPTIMIZATION_EXPORTS_KEY,
+ optimizationExportsList);
} else {
if (propertiesParameters != null) {
- if (propertiesParameters.containsKey("optimizationexports")) {
- result.setProperty("optimizationexports", propertiesParameters.getProperty("optimizationexports"));
+ String optimizationExports = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.OPTIMIZATION_EXPORTS_KEY);
+ if (optimizationExports != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.OPTIMIZATION_EXPORTS_KEY,
+ optimizationExports);
}
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("optimizationobservation.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
- }
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.OPTIMIZATION_OBSERVATION_KEY + DOT);
}
}
// export names
- String exportList = "";
- for (String export : getExportNames()) {
- exportList += export + ",";
+ String exportList = StringUtils.join(getExportNames(), LIST_SEPARATOR);
+ result.setProperty(SimulationParameterPropertiesHelper.EXPORTS_KEY, exportList);
- }
- result.setProperty("exports", exportList);
-
// number of sensitivity simulation
- result.setProperty("numberOfSensitivitySimulation", String
- .valueOf(getNumberOfSensitivitySimulation()));
+ result.setProperty(SimulationParameterPropertiesHelper.NUMBER_OF_SENSITIVITY_SIMULATION_KEY,
+ String.valueOf(getNumberOfSensitivitySimulation()));
// analysis name
if (sensitivityAnalysis != null) {
String analysisName = SensitivityAnalysisStorage
.getName(getSensitivityAnalysis());
- result.setProperty("sensitivityanalysis", analysisName);
+ result.setProperty(SimulationParameterPropertiesHelper.SENSITIVITY_ANALYSIS_KEY,
+ analysisName);
// analysis parameter
Properties analysisParams = StorageHelper.getParamsAsProperties(0,
- getRegion().getStorage(), getSensitivityAnalysis(), "sensitivity");
+ getRegion().getStorage(), getSensitivityAnalysis(),
+ SimulationParameterPropertiesHelper.SENSITIVITY_KEY);
result.putAll(analysisParams);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("sensitivityanalysis")) {
- result.setProperty("sensitivityanalysis",
- propertiesParameters.getProperty("sensitivityanalysis"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("sensitivity.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String sensitivityanalysis = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.SENSITIVITY_ANALYSIS_KEY);
+ if (sensitivityanalysis != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.SENSITIVITY_ANALYSIS_KEY,
+ sensitivityanalysis);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.SENSITIVITY_KEY + DOT);
}
}
}
@@ -1959,48 +1843,58 @@
int sensitivityExportIndex = 0;
for (SensitivityExport sensitivityExport : getSensitivityExport()) {
sensitivityExportList += SensitivityExportStorage
- .getName(sensitivityExport) + ",";
+ .getName(sensitivityExport) + LIST_SEPARATOR;
Properties exportProp = ExportHelper.getSensitivityExportAsProperties(
sensitivityExportIndex++, getRegion().getStorage(), sensitivityExport);
result.putAll(exportProp);
}
- result.setProperty("sensitivityexports", sensitivityExportList);
+ result.setProperty(SimulationParameterPropertiesHelper.SENSITIVITY_EXPORTS_KEY,
+ sensitivityExportList);
} else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("sensitivityexports")) {
- result.setProperty("sensitivityexports", propertiesParameters
- .getProperty("sensitivityexports"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("sensitivityexport.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
+ if (propertiesParameters != null) {
+ String sensitivityexports = propertiesParameters.getProperty(
+ SimulationParameterPropertiesHelper.SENSITIVITY_EXPORTS_KEY);
+ if (sensitivityexports != null) {
+ result.setProperty(SimulationParameterPropertiesHelper.SENSITIVITY_EXPORTS_KEY,
+ sensitivityexports);
+ SimulationParameterPropertiesHelper.copy(propertiesParameters, result,
+ SimulationParameterPropertiesHelper.SENSITIVITY_EXPORTS_KEY + DOT);
}
}
}
// sensitivity params
- result.setProperty("sensitivityAnalysisOnlyKeepFirst", String.valueOf(isSensitivityAnalysisOnlyKeepFirst()));
+ result.setProperty(SimulationParameterPropertiesHelper.SENSITIVITY_ANALYSIS_ONLY_KEEP_FIRST_KEY,
+ String.valueOf(isSensitivityAnalysisOnlyKeepFirst()));
- result.setProperty("generatedPreScript", getGeneratedPreScript());
- result.setProperty("usePreScript", String.valueOf(getUsePreScript()));
- result.setProperty("preScript", getPreScript());
- result.setProperty("useSimulationPlan", String.valueOf(getUseSimulationPlan()));
- result.setProperty("simulationPlanNumber", String.valueOf(getSimulationPlanNumber()));
- result.setProperty("useOptimization", String.valueOf(getUseOptimization()));
+ result.setProperty(SimulationParameterPropertiesHelper.GENERATED_PRE_SCRIPT_KEY,
+ getGeneratedPreScript());
+ result.setProperty(SimulationParameterPropertiesHelper.USE_PRE_SCRIPT_KEY,
+ String.valueOf(getUsePreScript()));
+ result.setProperty(SimulationParameterPropertiesHelper.PRE_SCRIPT_KEY,
+ getPreScript());
+ result.setProperty(SimulationParameterPropertiesHelper.USE_SIMULATION_PLAN_KEY,
+ String.valueOf(getUseSimulationPlan()));
+ result.setProperty(SimulationParameterPropertiesHelper.SIMULATION_PLAN_NUMBER_KEY,
+ String.valueOf(getSimulationPlanNumber()));
+ result.setProperty(SimulationParameterPropertiesHelper.USE_OPTIMIZATION_KEY,
+ String.valueOf(getUseOptimization()));
- String resultList = "";
- for (String r : getResultEnabled()) {
- resultList += r + ",";
- }
- result.setProperty("resultNames", resultList);
+ String resultList = StringUtils.join(getResultEnabled(),
+ SimulationParameterPropertiesHelper.LIST_SEPARATOR);
+ result.setProperty(SimulationParameterPropertiesHelper.RESULT_NAMES_KEY, resultList);
for (Map.Entry<String, String> e : getTagValue().entrySet()) {
- result.setProperty("tagValue." + e.getKey(), e.getValue());
+ result.setProperty(SimulationParameterPropertiesHelper.TAG_VALUE_KEY+ DOT
+ + e.getKey(), e.getValue());
}
- result.setProperty("simulLogLevel", getSimulLogLevel());
- result.setProperty("scriptLogLevel", getScriptLogLevel());
- result.setProperty("libLogLevel", getLibLogLevel());
+ result.setProperty(SimulationParameterPropertiesHelper.SIMUL_LOG_LEVEL_KEY,
+ getSimulLogLevel());
+ result.setProperty(SimulationParameterPropertiesHelper.SCRIPT_LOG_LEVEL_KEY,
+ getScriptLogLevel());
+ result.setProperty(SimulationParameterPropertiesHelper.LIB_LOG_LEVEL_KEY,
+ getLibLogLevel());
return result;
}
Copied: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java (from rev 4095, trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java)
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java (rev 0)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterPropertiesHelper.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -0,0 +1,483 @@
+package fr.ifremer.isisfish.simulator;
+
+/*
+ * #%L
+ * IsisFish
+ * %%
+ * Copyright (C) 2014 Ifremer, Codelutin, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixHelper;
+import org.nuiton.util.VersionUtil;
+
+import static org.nuiton.i18n.I18n.t;
+
+/**
+ * Class utilitaire permettant de travailler avec les parametres sous forme de
+ * properties
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class SimulationParameterPropertiesHelper {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ final static private Log log = LogFactory.getLog(SimulationParameterPropertiesHelper.class);
+
+ final public static String DOT = ".";
+ final public static String LIST_SEPARATOR = ",";
+
+ final public static String ISIS_FISH_VERSION_KEY = "isisFishVersion";
+ final public static String SIMULATOR_NAME_KEY = "simulatorName";
+ final public static String POPULATIONS_KEY = "populations";
+ final public static String RULES_KEY = "rules";
+ final public static String RULE_KEY = "rule";
+ final public static String RESULT_NAMES_KEY = "resultNames";
+ final public static String EXPORTS_KEY = "exports";
+ final public static String PLANS_KEY = "plans";
+ final public static String PLAN_KEY = "plan";
+ final public static String STRATEGIES_KEY = "strategies";
+ final public static String DESCRIPTION_KEY = "description";
+ final public static String REGION_NAME_KEY = "regionName";
+ final public static String USE_SIMULATION_PLAN_KEY = "useSimulationPlan";
+ final public static String SIMULATION_PLAN_NUMBER_KEY = "simulationPlanNumber";
+ final public static String USE_OPTIMIZATION_KEY = "useOptimization";
+ final public static String OPTIMIZATION_KEY = "optimization";
+ final public static String OBJECTIVE_KEY = "objective";
+ final public static String OPTIMIZATION_EXPORTS_KEY = "optimizationexports";
+ final public static String OPTIMIZATION_OBSERVATION_KEY = "optimizationobservation";
+ final public static String USE_CACHE_KEY = "useCache";
+ final public static String USE_STATISTIC_KEY = "useStatistic";
+ final public static String NUMBER_OF_YEAR_KEY = "numberOfYear";
+ final public static String GENERATED_PRE_SCRIPT_KEY = "generatedPreScript";
+ final public static String USE_PRE_SCRIPT_KEY = "usePreScript";
+ final public static String PRE_SCRIPT_KEY = "preScript";
+ final public static String SIMUL_LOG_LEVEL_KEY = "simulLogLevel";
+ final public static String SCRIPT_LOG_LEVEL_KEY = "scriptLogLevel";
+ final public static String LIB_LOG_LEVEL_KEY = "libLogLevel";
+ final public static String SENSITIVITY_ANALYSIS_KEY = "sensitivityanalysis";
+ final public static String SENSITIVITY_KEY = "sensitivity";
+ final public static String SENSITIVITY_EXPORTS_KEY = "sensitivityexports";
+ final public static String SENSITIVITY_EXPORT_KEY = "sensitivityexport";
+ final public static String POPULATION_KEY = "population";
+ final public static String NUMBER_KEY = "number";
+ final public static String NUMBER_OF_SENSITIVITY_SIMULATION_KEY = "numberOfSensitivitySimulation";
+ final public static String SENSITIVITY_ANALYSIS_ONLY_KEEP_FIRST_KEY = "sensitivityAnalysisOnlyKeepFirst";
+ final public static String TAG_VALUE_KEY = "tagValue";
+ final public static String PARAMETERS_KEY = "parameters";
+ final public static String PARAMETER_KEY = "parameter";
+
+ public static String getIsisFishVersion(Properties prop) {
+ String result = prop.getProperty(ISIS_FISH_VERSION_KEY, "");
+ return result;
+ }
+
+ public static String getSimulatorName(Properties prop) {
+ String result = prop.getProperty(SIMULATOR_NAME_KEY, "DefaultSimulator.java");
+ return result;
+ }
+
+ public static String getDescription(Properties prop) {
+ String result = prop.getProperty(DESCRIPTION_KEY, "");
+ return result;
+ }
+
+ public static boolean getUseSimulationPlan(Properties prop) {
+ boolean result = Boolean.valueOf(prop.getProperty(USE_SIMULATION_PLAN_KEY, "false"));
+ return result;
+ }
+
+ public static int getSimulationPlanNumber(Properties prop) {
+ int result = Integer.valueOf(prop.getProperty(SIMULATION_PLAN_NUMBER_KEY, "-1"));
+ return result;
+ }
+
+ public static boolean getUseCache(Properties prop) {
+ boolean result;
+ if (VersionUtil.smallerThan(getIsisFishVersion(prop), "4.3.0.0")) {
+ result = Boolean.valueOf(prop.getProperty(USE_OPTIMIZATION_KEY, "true"));
+ } else {
+ result = Boolean.valueOf(prop.getProperty(USE_CACHE_KEY, "true"));
+ }
+ return result;
+ }
+
+ public static int getNumberOfYear(Properties prop) {
+ int result = Integer.valueOf(prop.getProperty(NUMBER_OF_YEAR_KEY, "1"));
+ return result;
+ }
+
+ public static String getRegionName(Properties prop) {
+ String result = prop.getProperty(REGION_NAME_KEY, "");
+ return result;
+ }
+
+ public static String[] getPopulationNames(Properties prop) {
+ String[] result = StringUtils.split(prop.getProperty(POPULATIONS_KEY, ""), LIST_SEPARATOR);
+ return result;
+ }
+
+ /**
+ * Retourne les effectifs sous forme d'une liste de liste de double
+ * [[2, 3, 4], [5, 6, 7]]
+ *
+ * @param prop
+ * @param popName nom de la population dont on souhaite les effectifs
+ * @return
+ */
+ public static List getPopulationNumbers(Properties prop, String popName) {
+ String numberAsString = prop.getProperty(
+ POPULATION_KEY + DOT + popName + DOT + NUMBER_KEY);
+ List result = MatrixHelper.convertStringToList(numberAsString);
+ return result;
+ }
+
+ public static String[] getStrategieNames(Properties prop) {
+ String[] result = StringUtils.split(prop.getProperty(STRATEGIES_KEY, ""), LIST_SEPARATOR);
+ return result;
+ }
+
+ public static String[] getRuleNames(Properties prop) {
+ String[] result = StringUtils.split(prop.getProperty(RULES_KEY, ""), LIST_SEPARATOR);
+ return result;
+ }
+
+ public static String[] getResultNames(Properties prop) {
+ String[] result = StringUtils.split(prop.getProperty(RESULT_NAMES_KEY, ""), LIST_SEPARATOR);
+ return result;
+ }
+
+ public static String[] getExportNames(Properties prop) {
+ String[] result = StringUtils.split(prop.getProperty(EXPORTS_KEY, ""), LIST_SEPARATOR);
+ return result;
+ }
+
+ public static String[] getSimulationPlanNames(Properties prop) {
+ String[] result = StringUtils.split(prop.getProperty(PLANS_KEY, ""), LIST_SEPARATOR);
+ return result;
+ }
+
+ public static boolean getUseOptimization(Properties prop) {
+ boolean result;
+ // en version < 4.3, le parametre était nommé 'useOptimization'
+ // qualifiant le cache, il a été renommé ensuite
+ if (VersionUtil.smallerThan(getIsisFishVersion(prop), "4.3.0.0")) {
+ result = Boolean.FALSE;
+ } else {
+ result = Boolean.valueOf(prop.getProperty(USE_OPTIMIZATION_KEY, "false"));
+ }
+ return result;
+ }
+
+ public static String getOptimizationName(Properties prop) {
+ String result = prop.getProperty(OPTIMIZATION_KEY, "");
+ return result;
+ }
+
+ public static String getObjectiveName(Properties prop) {
+ String result = prop.getProperty(OBJECTIVE_KEY, "");
+ return result;
+ }
+
+ public static String[] getOptimizationExportNames(Properties prop) {
+ String[] result = StringUtils.split(prop.getProperty(OPTIMIZATION_EXPORTS_KEY, ""), LIST_SEPARATOR);
+ return result;
+ }
+
+ public static String getOptimizationObservationName(Properties prop, int index) {
+ String result = prop.getProperty(OPTIMIZATION_OBSERVATION_KEY + DOT + index, "");
+ if (result.matches("[\\w.]+#[\\d.]+#[\\d.]+:(.+)")) {
+ result = result.replaceFirst("[\\w.]+#[\\d.]+#[\\d.]+:(.+)", "$1");
+ }
+
+ return result;
+ }
+
+ public static String getSensitivityAnalysis(Properties prop) {
+ String result = prop.getProperty(SENSITIVITY_ANALYSIS_KEY);
+ return result;
+ }
+
+ public static String[] getSensitivityExportNames(Properties prop) {
+ String[] result = StringUtils.split(prop.getProperty(SENSITIVITY_EXPORTS_KEY, ""), LIST_SEPARATOR);
+ return result;
+ }
+
+ public static int getNumberOfSensitivitySimulation(Properties prop) {
+ int result = Integer.valueOf(prop.getProperty(
+ NUMBER_OF_SENSITIVITY_SIMULATION_KEY, "-1"));
+ return result;
+ }
+
+ public static boolean isSensitivityAnalysisOnlyKeepFirst(Properties prop) {
+ boolean result = Boolean.valueOf(prop.getProperty(
+ SENSITIVITY_ANALYSIS_ONLY_KEEP_FIRST_KEY, "-1"));
+ return result;
+ }
+
+
+ public static String getGeneratedPreScript(Properties prop) {
+ String result = prop.getProperty(GENERATED_PRE_SCRIPT_KEY, "");
+ return result;
+ }
+
+ public static boolean getUsePreScript(Properties prop) {
+ boolean result = Boolean.valueOf(prop.getProperty(USE_PRE_SCRIPT_KEY, "false"));
+ return result;
+ }
+
+ public static String getPreScript(Properties prop) {
+ String result = prop.getProperty(PRE_SCRIPT_KEY, "");
+ return result;
+ }
+
+ public static boolean getUseStatistic(Properties prop) {
+ boolean result = Boolean.valueOf(prop.getProperty(USE_STATISTIC_KEY, "false"));
+ return result;
+ }
+
+ public static String getSimulLogLevel(Properties prop) {
+ String result = prop.getProperty(SIMUL_LOG_LEVEL_KEY, "info");
+ return result;
+ }
+
+ public static String getScriptLogLevel(Properties prop) {
+ String result = prop.getProperty(SCRIPT_LOG_LEVEL_KEY, "info");
+ return result;
+ }
+
+ public static String getLibLogLevel(Properties prop) {
+ String result = prop.getProperty(LIB_LOG_LEVEL_KEY, "info");
+ return result;
+ }
+
+ public static Map<String, String> getTagValue(Properties prop) {
+ int tagValueLength = (TAG_VALUE_KEY + DOT).length();
+ // preserve order
+ Map<String, String> result = new LinkedHashMap<String, String>();
+ for (String k : prop.stringPropertyNames()) {
+ if (k.startsWith(TAG_VALUE_KEY + DOT)) {
+ String key = k.substring(tagValueLength);
+ String value = prop.getProperty(k);
+ result.put(key, value);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Retourne les parametres sous forme de String pour une regles. Les regles
+ * sont numeroter dans l'ordre dans lequel on les recupere via #getRuleNames().
+ *
+ * @param prop
+ * @param prefix can be 'rule', or other
+ * @param index l'indice de la regle dont on veut les parametre en String
+ * @return
+ */
+ public static Map<String, String> getParamAsString(Properties prop, String prefix, int index) {
+ Map<String, String> result = new HashMap<String, String>();
+ if (prop != null) {
+ String paramTag = prefix + DOT + index + DOT + PARAMETER_KEY + DOT;
+ int paramTagLength = paramTag.length();
+
+ for (String key : prop.stringPropertyNames()) {
+ if (StringUtils.startsWith(key, paramTag)) {
+ String paramName = key.substring(paramTagLength);
+ String value = prop.getProperty(key);
+ // get only string representation of entities
+ if (value.matches("[\\w.]+#[\\d.]+#[\\d.]+:(.+)")) {
+ value = value.replaceFirst("[\\w.]+#[\\d.]+#[\\d.]+:(.+)", "$1");
+ }
+ result.put(paramName, value);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Copy all entry beginning with prefix from source to target
+ *
+ * @param source
+ * @param target
+ * @param prefix
+ */
+ public static void copy(Properties source, Properties target, String prefix) {
+ for (String key : source.stringPropertyNames()) {
+ if (StringUtils.startsWith(key, prefix)) {
+ target.setProperty(key, source.getProperty(key));
+ }
+ }
+ }
+
+ public static String toString(Properties prop) {
+ StringBuilder result = new StringBuilder();
+ result.append(
+ t("isisfish.params.toString.simulation.done",
+ getIsisFishVersion(prop))).append(" (").append(getSimulatorName(prop)).append(")").append('\n');
+ result.append("--------------------\n");
+ result.append(getDescription(prop)).append('\n');
+ result.append("--------------------\n");
+
+ if (getUseSimulationPlan(prop)) {
+ result.append(t("isisfish.params.toString.plan.number",
+ getSimulationPlanNumber(prop)));
+ result.append("\n");
+ }
+
+ result.append("\n");
+
+ boolean useCache = getUseCache(prop);
+ if (useCache) {
+ result.append(t("isisfish.params.toString.use.cache",
+ useCache));
+ result.append("\n");
+ }
+
+ result.append(t("isisfish.params.toString.fishery", getRegionName(prop)));
+ result.append("\n\n");
+ result.append(t("isisfish.params.toString.number.years",
+ getNumberOfYear(prop)));
+ result.append("\n\n");
+
+ // startegies
+ String[] strs = getStrategieNames(prop);
+ result.append(t("isisfish.params.toString.strategies"));
+ String sep = "";
+ for (String str : strs) {
+ result.append(sep).append(str);
+ sep = LIST_SEPARATOR;
+ }
+ result.append("\n\n");
+
+ // populations
+ result.append(t("isisfish.params.toString.populations"));
+ sep = "";
+ for (String pop : getPopulationNames(prop)) {
+ result.append(sep).append(pop);
+ sep = LIST_SEPARATOR;
+ }
+ result.append("\n\n");
+
+ // rules
+ int cpt = 0;
+ for (String name : getRuleNames(prop)) {
+ result.append(t("isisfish.params.toString.rule", name));
+ result.append('\n');
+ for (Map.Entry<String, String> e : getParamAsString(prop, RULE_KEY, cpt++).entrySet()) {
+ result.append("\t").append(e.getKey()).append(" : ").append(e.getValue()).append("\n");
+ }
+ result.append("\n");
+
+ }
+ result.append("\n\n");
+
+ // simulation plans
+ cpt = 0;
+ for (String plan : getSimulationPlanNames(prop)) {
+ result.append(t("isisfish.params.toString.plan", plan));
+ result.append('\n');
+ for (Map.Entry<String, String> e : getParamAsString(prop, PLAN_KEY, cpt++).entrySet()) {
+ result.append("\t").append(e.getKey()).append(" : ").append(e.getValue()).append("\n");
+ }
+ result.append('\n');
+
+ }
+
+ boolean useOptimization = getUseOptimization(prop);
+
+ if (useOptimization) {
+ result.append(t("isisfish.params.toString.use.optimization",
+ useOptimization));
+
+ String objective = getObjectiveName(prop);
+ if (StringUtils.isNotBlank(objective)) {
+ result.append(t("isisfish.params.toString.objective", objective));
+ result.append('\n');
+ for (Map.Entry<String, String> e : getParamAsString(prop, OBJECTIVE_KEY, 0).entrySet()) {
+ result.append("\t").append(e.getKey()).append(" : ").append(e.getValue()).append("\n");
+ }
+ result.append('\n');
+ }
+
+ String optimization = getOptimizationName(prop);
+ if (StringUtils.isNotBlank(optimization)) {
+ result.append(t("isisfish.params.toString.optimization", optimization));
+ result.append('\n');
+ for (Map.Entry<String, String> e : getParamAsString(prop, OPTIMIZATION_KEY, 0).entrySet()) {
+ result.append("\t").append(e.getKey()).append(" : ").append(e.getValue()).append("\n");
+ }
+ result.append('\n');
+ }
+
+ cpt = 0;
+ for (String export : getOptimizationExportNames(prop)) {
+ String observation = getOptimizationObservationName(prop, cpt++);
+
+ result.append(t("isisfish.params.toString.optimizationExport", export));
+ if (StringUtils.isNotBlank(observation)) {
+ result.append("\t->").append(t("isisfish.params.toString.optimizationObservation", observation));
+ }
+ result.append('\n');
+ }
+ }
+
+ String genScript = getGeneratedPreScript(prop);
+ if (StringUtils.isNotBlank(genScript)) {
+ result.append('\n');
+ result.append(t("isisfish.params.toString.script.generatedpresimulation"))
+ .append(":\n");
+ result.append(genScript);
+ }
+ if (getUsePreScript(prop)) {
+ String prescript = getPreScript(prop);
+ if (StringUtils.isNotBlank(prescript)) {
+ result.append('\n');
+ result.append(t("isisfish.params.toString.script.presimulation"))
+ .append(":\n");
+ result.append(prescript);
+ }
+ }
+
+ result.append('\n');
+ result.append(t("isisfish.params.toString.simul.logger.level",
+ getSimulLogLevel(prop)));
+ result.append('\n');
+ result.append(t("isisfish.params.toString.script.logger.level",
+ getScriptLogLevel(prop)));
+ result.append('\n');
+ result.append(t("isisfish.params.toString.lib.logger.level",
+ getLibLogLevel(prop)));
+ result.append('\n');
+ return result.toString();
+ }
+
+}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -89,9 +89,7 @@
protected SimulationStorage simulation;
- /**
- * {@inheritDoc}
- */
+ @Override
public void simulate(SimulationService simulationService,
SimulationItem simulationItem) throws RemoteException {
@@ -245,8 +243,15 @@
}
}
} finally {
- // remove simulation logger (no more need since thread is dead)
- simulation.removeSimulationLogger();
+ try {
+ // remove simulation logger (no more need since thread is dead)
+ simulation.removeSimulationLogger();
+ } catch (Exception ex) {
+ if (log.isDebugEnabled()) {
+ log.debug("Can't restore logger configuration", ex);
+ }
+ // FIXME echatellier 20140729 remove this with log4j 2
+ }
}
return simulation;
}
@@ -362,8 +367,9 @@
//
SimulationContext context = SimulationContext.get();
- context.setSimulationControl(control != null ? control
- : new SimulationControl(simulation.getName()));
+ control = control != null ? control
+ : new SimulationControl(simulation.getName());
+ context.setSimulationControl(control);
// make compile directory outside getCompileDirectory() to improve performance
File compileDirectory = IsisFish.config.getCompileDirectory();
@@ -444,6 +450,11 @@
simulation.getInformation().addInformation(
context.getTimeStepStat().exportText(null).toString());
+ // on ajoute les info sur le resultStorage avant les exports qui
+ // peuvent changer les stats
+ ResultStorage resultStorage = simulation.getResultStorage();
+ simulation.getInformation().addInformation(resultStorage.getInfo());
+
//
// Ajout des nouveaux objets créés durant la simulation
//
@@ -464,22 +475,12 @@
//
context.fireAfterSimulation();
- message(control, t("isisfish.message.simulation.ended"));
-
- simulation.getInformation().setSimulationEnd(new java.util.Date());
-
- // la simulation est termine on avance la progress au dernier cran
- // attention on utilise ca aussi pour detecter la fin d'une simulation
- // quand date =progressMax
- control.setProgress(control.getProgress() + 1);
-
// suppression des résultats si l'utilisateur a demande à ne conserver
// que les resultats de seulement la première simulation d'une AS
- ResultStorage resultStorage = simulation.getResultStorage();
if (parameters.isSensitivityAnalysisOnlyKeepFirst() && !control.getId().endsWith("_0")) {
resultStorage.delete();
}
- simulation.getInformation().addInformation(resultStorage.getInfo());
+
resultStorage.close();
} catch (OutOfMemoryError eee) {
@@ -542,6 +543,17 @@
}
FileUtils.deleteQuietly(simulationBuildDirectory);
+
+ simulation.getInformation().setSimulationEnd(new java.util.Date());
+
+ // la simulation est termine on avance la progress au dernier cran
+ // attention on utilise ca aussi pour detecter la fin d'une simulation
+ // quand date =progressMax
+ control.setProgress(control.getProgress() + 1);
+
+ message(control, t("isisfish.message.simulation.ended"));
+ control.stopSimulation();
+
// context is used in TraceAspect.printStatistiqueAndClear()
SimulationContext.remove();
}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -535,22 +535,21 @@
// and set by end of
// fr.ifremer.isisfish.simulator.launcher.InProcessSimulatorLauncher#localSimulateSameThread(SimulationControl, SimulationStorage)
- File localControlFile = SimulationStorage.getSimulationControlFile(control.getId());
+ File simulationRoot = SimulationStorage.getSimulationDirectory(control.getId());
+ File localInformationFile = SimulationStorage.getSimulationInformationFile(simulationRoot);
// si la simulation n'est pas localement presente, c'est pas fini
// la simulation peut être finie, mais non téléchargées
- // en testant le fichier de controle, on s'assure que la simulation est physiquement
+ // en testant le fichier d'information, on s'assure que la simulation est physiquement
// présente en local
- if (localControlFile.isFile()) {
+ if (localInformationFile.isFile()) {
// cas d'une simulation terminée
if (control.getProgress() > 0 &&
control.getProgress() >= control.getProgressMax()) {
simulationEnded = true;
} else {
// cas d'une simulation arretee par exception
- File simulationRoot = SimulationStorage.getSimulationDirectory(control.getId());
- File informationFile = SimulationStorage.getSimulationInformationFile(simulationRoot);
- SimulationInformation information = new SimulationInformation(informationFile);
+ SimulationInformation information = new SimulationInformation(localInformationFile);
if (StringUtils.isNotEmpty(information.getException())) {
if (log.isWarnEnabled()) {
log.warn("Simulation exception : " + information.getException());
@@ -633,6 +632,11 @@
}
try {
+ // FIXME poussin 20140729 je pense que ca pose probleme qu'un
+ // thread autre que le thread de simulation ferme les storages
+ // surtout que la condition est stopRequest (simulation pas forcement fini)
+ // ca ne poserait pas de probleme si la condition etait isRunning() == false
+ // Et surtout c'est tres bizarre que ce soit le travail d'un Monitor :(
simulation.closeStorage();
simulation.closeMemStorage();
} catch (TopiaException ex) {
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationPlanPrepareJob.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationPlanPrepareJob.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationPlanPrepareJob.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -222,7 +222,7 @@
}
return result;
} catch (Exception eee) {
- throw new IsisFishRuntimeException(I18n._("isisfish.error.evalute.plan.script"), eee);
+ throw new IsisFishRuntimeException(I18n.t("isisfish.error.evalute.plan.script"), eee);
}
}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/MatrixSummaryRenderer.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/MatrixSummaryRenderer.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/MatrixSummaryRenderer.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -27,7 +27,6 @@
import static org.nuiton.i18n.I18n.n;
import java.awt.Component;
-import java.util.Iterator;
import javax.swing.Icon;
import javax.swing.JScrollPane;
@@ -40,7 +39,9 @@
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper;
import fr.ifremer.isisfish.types.TimeStep;
+import java.util.Properties;
/**
* Simulation summary renderer.
@@ -79,11 +80,12 @@
if (cachedComponent == null) {
SimulationParameter sp = simulationStorage.getParameter();
- StringBuffer resume = new StringBuffer(sp.toString());
+ Properties prop = sp.toProperties();
+ String params = SimulationParameterPropertiesHelper.toString(prop);
+ StringBuilder resume = new StringBuilder(params);
resume.append("\n");
- for(Iterator<String> i = resultStorage.getResultName().iterator(); i.hasNext();) {
- String name = (String)i.next();
+ for(String name : resultStorage.getResultName()) {
try {
// TODO EC20090717 ca marche plus ca
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -218,6 +218,10 @@
resultSimulationFrame.getMatrixViewerContainer().add(matrixViewerPanel, BorderLayout.CENTER);
if (model.getSize() > 0) {
+ // FIXME poussin 20140721 est-ce bien intelligent de forcer l'ouverture
+ // du 1er resultat trouver. On prend du temps pour ca, alors que l'utilisateur
+ // veut potentiellement regarder autre chose. Demander au utilisateur si on peut
+ // ne pas ouvrir de resultat par defaut.
model.setSelectedItem(model.getElementAt(0));
}
} catch (TopiaException ex) {
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2014-08-20 09:48:07 UTC (rev 4096)
@@ -48,6 +48,7 @@
@Override
public void refresh() {
paramsUI.refresh();
+ advancedParamsUI.refresh();
}
@Override
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/ContinuousDistributionPanel.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/ContinuousDistributionPanel.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/ContinuousDistributionPanel.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -1,25 +1,23 @@
/*
* #%L
- *
- *
* $Id$
* $HeadURL$
* %%
* Copyright (C) 2012 - 2014 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
+ * You should have received a copy of the GNU General Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2014-08-20 09:48:07 UTC (rev 4096)
@@ -120,7 +120,12 @@
@Override
public void run() {
simulAction.regionChange(ParamsUI.this, selected);
- getParentContainer(SimulUI.class).refresh();
+ // FIXME fix this
+ if (!isSensitivity()) {
+ getParentContainer(SimulUI.class).refresh();
+ } else {
+ getParentContainer(SensitivityUI.class).refresh();
+ }
setSensitivityTabRegion();
getParentContainer(WelcomePanelUI.class).setStatusMessage(t("isisfish.message.region.loaded"));
}
@@ -190,7 +195,12 @@
simulAction.loadOldSimulation(selected);
fieldSimulParamsRegion.setSelectedItem(getContextValue(SimulAction.class).getSimulationParameter().getRegionName());
- getParentContainer(SimulUI.class).refresh();
+ // FIXME fix this
+ if (!isSensitivity()) {
+ getParentContainer(SimulUI.class).refresh();
+ } else {
+ getParentContainer(SensitivityUI.class).refresh();
+ }
// mise a jour des années
fieldSimulParamsNbAnnees.setText(String.valueOf(simulAction.getNumberOfYear()));
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -102,6 +102,14 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.NUMBER_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETER_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETERS_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.POPULATION_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULES_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULE_KEY;
+
/**
* SimulAction.
*
@@ -351,7 +359,8 @@
preRemoveRule((FactorGroup)factor, ruleIndex);
}
else {
- Pattern factorPathPattern = Pattern.compile("^(parameters\\.rule\\.)(\\d+)(.*)$");
+ Pattern factorPathPattern = Pattern.compile(
+ "^(" +PARAMETERS_KEY + "\\" + DOT + RULE_KEY + "\\" + DOT + ")(\\d+)(.*)$");
Matcher factorPathMatcher = factorPathPattern.matcher(factor.getPath());
if (factorPathMatcher.find()) {
Integer index = Integer.parseInt(factorPathMatcher.group(2));
@@ -1247,7 +1256,7 @@
// new factor with rule domain
if (source instanceof RuleChooser) {
- String factorPath = "parameters.rules";
+ String factorPath = PARAMETERS_KEY + DOT + RULES_KEY;
selectedFactor = getFactor(factorPath);
if (selectedFactor == null) {
selectedFactor = new Factor(t("isisfish.sensitivity.rulesfactorname"));
@@ -1259,7 +1268,7 @@
// new factor with matrix continous domain
else if (source instanceof MatrixPanelEditor) {
Population population = (Population)source.getClientProperty("sensitivityPopulation");
- String factorPath = "parameters.population." + population.getName() + ".number";
+ String factorPath = PARAMETERS_KEY + DOT + POPULATION_KEY + DOT + population.getName() + DOT + NUMBER_KEY;
selectedFactor = getFactor(factorPath);
if (selectedFactor == null) {
selectedFactor = new Factor(t("isisfish.sensitivity.populationfactorname", population.getName()));
@@ -1301,7 +1310,8 @@
// with rule list, if a rule is deleted, factor on it must
// be deleted too, et next factor must be renamed
int index = ruleChooser.getRulesList().indexOf(rule);
- String factorPath = "parameters.rule." + index + ".parameter." + paramName;
+ String factorPath = PARAMETERS_KEY + DOT + RULE_KEY + DOT + index + DOT
+ + PARAMETER_KEY + DOT + paramName;
//try {
/*// on a besoin de la valeur pour savoir s'il peut être continue
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/util/ErrorHelper.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/util/ErrorHelper.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/util/ErrorHelper.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -68,8 +68,11 @@
public static void showErrorDialog(Component parent, String message,
Throwable cause) {
JXErrorPane pane = new JXErrorPane();
+
+ String details = "<pre>\n" + getDetails(cause) + "\n</pre>";
+
ErrorInfo info = new ErrorInfo(t("isisfish.error.errorpane.title"),
- t("isisfish.error.errorpane.htmlmessage", message), null, null,
+ t("isisfish.error.errorpane.htmlmessage", message), details, null,
cause, null, null);
pane.setErrorInfo(info);
if (cause != null) {
@@ -97,6 +100,18 @@
showErrorDialog(null, message, cause);
}
+ private static String getDetails(Throwable cause) {
+ String result = "";
+ if (cause != null) {
+ StringWriter out = new StringWriter();
+ PrintWriter writer = new PrintWriter(out);
+ cause.printStackTrace(writer);
+ out.flush();
+ result = out.toString();
+ }
+ return result;
+ }
+
/*
* @see org.jdesktop.swingx.error.ErrorReporter#reportError(org.jdesktop.swingx.error.ErrorInfo)
*/
@@ -137,10 +152,7 @@
}
// message exception
- StringWriter out = new StringWriter();
- PrintWriter writer = new PrintWriter(out);
- errorInfo.getErrorException().printStackTrace(writer);
- message += formatMessage("Exception", out.toString());
+ message += formatMessage("Exception", getDetails(errorInfo.getErrorException()));
// TODO i18n files are iso encoded :(
email.setContent(message, "text/plain; charset=ISO-8859-9");
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/widget/FilterableComboBox.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/widget/FilterableComboBox.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/ui/widget/FilterableComboBox.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -125,13 +125,14 @@
}
// filter list
- realIndexes.clear();
+ List<Integer> newRealIndexes = new ArrayList<Integer>();
for (int i = 0; i < model.getSize(); ++i) {
Object element = model.getElementAt(i);
if (element.toString().contains(filterField.getText())) {
- realIndexes.add(i);
+ newRealIndexes.add(i);
}
}
+ realIndexes = newRealIndexes; // prevent thread concurrency
fireIntervalRemoved(this, 0, model.getSize());
fireIntervalAdded(this, 0, realIndexes.size());
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/EvaluatorHelper.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/EvaluatorHelper.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/EvaluatorHelper.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -143,13 +143,12 @@
*/
public static int check(Class javaInterface, String script, PrintWriter out) {
try {
- File src = File.createTempFile("check", "equation");
- src.deleteOnExit();
+ File src = File.createTempFile("check" + javaInterface.getSimpleName(), "Equation");
+ src.delete(); // delete now, we don't need file, just name to create java file
String packageName = null;
String className = normalizeClassName(src.getName());
-
+
src = new File(src.getParentFile(), className + ".java");
- src.deleteOnExit();
// recherche la methode de l'interface
Method [] methods = javaInterface.getDeclaredMethods();
@@ -161,8 +160,11 @@
int compileResult = CompileHelper.compile(src.getParentFile(), src, src.getParentFile(), out);
File dest = new File(src.getParentFile(), className + ".class");
- dest.deleteOnExit();
+ // no more need file .java and .class remove them now
+ src.delete();
+ dest.delete();
+
return compileResult;
} catch (Exception eee) {
@@ -184,9 +186,11 @@
*/
public static Object evaluate(String packageName, String className,
Class javaInterface, String script, Object... args) {
- className = normalizeClassName(className);
+ // ajout du nom de l'interface dans le nom de la classe pour retrouver
+ // plus facilement a quelle equation correspond les fichiers sur disque.
+ className = javaInterface.getSimpleName() + normalizeClassName(className);
- Object result = null;
+ Object result;
Class clazz = null;
// recherche la methode de l'interface
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -59,7 +59,7 @@
/** number of time steps to cache by interpolating from the first step*/
// perhaps allow the configuration
- static public double CACHE_STEP = 1.3; // between 2 step, cache size is very close: 1.3 seem correct
+ static public double CACHE_STEP = 2; // between 2 step, cache size is very close: 2 seem correct
static public class IsisCacheBackendOnGuavaFactory implements IsisCacheBackend.Factory {
@Override
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/SimpleParser.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/SimpleParser.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/SimpleParser.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -43,6 +43,9 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(SimpleParser.class);
+ // MARK_SIZE = 1 doesn't work when EOF is reached
+ static final private int MARK_SIZE = 2;
+
protected boolean intern;
protected BufferedReader in;
protected StringBuilder sb = new StringBuilder();
@@ -83,7 +86,7 @@
char c = (char)i;
if (c == '\r') {
// try to eat \n after \r
- in.mark(1);
+ in.mark(MARK_SIZE);
c = (char)in.read();
if (c != '\n') {
in.reset();
@@ -102,7 +105,7 @@
if (i != -1) {
// test if not eof
- in.mark(1);
+ in.mark(MARK_SIZE);
i = in.read();
in.reset();
}
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/StringConverter.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/StringConverter.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/StringConverter.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -58,7 +58,8 @@
Object result = null;
if (o != null) {
if (o instanceof TopiaEntity) {
- result = ((TopiaEntity) o).getTopiaId();
+ // put after ':' string entity representation
+ result = ((TopiaEntity) o).getTopiaId() + ":" + o.toString();
} else if (o instanceof TimeStep) {
result = String.valueOf(((TimeStep) o).getStep());
} else if (o instanceof Month) {
Modified: branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/TopiaEntityConverter.java
===================================================================
--- branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/TopiaEntityConverter.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/TopiaEntityConverter.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -29,6 +29,7 @@
import org.apache.commons.beanutils.ConversionException;
import org.apache.commons.beanutils.Converter;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
@@ -69,6 +70,8 @@
if (value instanceof TopiaEntity) {
result = value;
} else if (value instanceof String) {
+ // after ':' is entity string representation
+ value = StringUtils.substringBefore((String)value, ":");
result = getTopiaEntity((String) value);
} else {
throw new ConversionException("Can't convert '" + value + "' to " + type.getName());
Modified: branches/4.3.0-log4j2/src/main/resources/i18n/isis-fish_en_GB.properties
===================================================================
--- branches/4.3.0-log4j2/src/main/resources/i18n/isis-fish_en_GB.properties 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/resources/i18n/isis-fish_en_GB.properties 2014-08-20 09:48:07 UTC (rev 4096)
@@ -69,7 +69,7 @@
Use\ branches,\ switch\ not\ needed=
User\ restart\ simulation\ %s=
User\ stop\ simulation\ %s=
-Zones=
+Zones=Zones
an\ alternative\ way\ to\ specify\ the\ scale.=
could\ not\ close\ reader\ %1$s=could not close reader %1$s
could\ not\ found\ %s=
@@ -697,20 +697,20 @@
isisfish.params.simulationName=Simulation name
isisfish.params.stategiesAndPopulations=Strategies and populations
isisfish.params.title=Parameters
-isisfish.params.toString.fishery=Fishery\: %1$s\n\n
+isisfish.params.toString.fishery=Fishery\: %1$s
isisfish.params.toString.lib.logger.level=Level of libraries' logger \: %1$s
-isisfish.params.toString.number.years=Number of years\: %1$s\n\n
+isisfish.params.toString.number.years=Number of years\: %1$s
isisfish.params.toString.objective=
isisfish.params.toString.optimization=
isisfish.params.toString.optimizationExport=
isisfish.params.toString.optimizationObservation=
isisfish.params.toString.plan=Plan\: %1$s
-isisfish.params.toString.plan.number=Simulation plan sequence number\: %1$s\n\n
+isisfish.params.toString.plan.number=Simulation plan sequence number\: %1$s
isisfish.params.toString.populations=Populations \:
isisfish.params.toString.rule=Rule\: %1$s
-isisfish.params.toString.script.generatedpresimulation=
+isisfish.params.toString.script.generatedpresimulation=Generated script
isisfish.params.toString.script.logger.level=Level of scripts' logger \: %1$s
-isisfish.params.toString.script.presimulation=Script de presimulation
+isisfish.params.toString.script.presimulation=Pre-simulation script
isisfish.params.toString.simul.logger.level=Level of simulator's logger \: %1$s
isisfish.params.toString.simulation.done=Simulation done with \: %1$s
isisfish.params.toString.strategies=Strategies \:
Modified: branches/4.3.0-log4j2/src/main/resources/i18n/isis-fish_fr_FR.properties
===================================================================
--- branches/4.3.0-log4j2/src/main/resources/i18n/isis-fish_fr_FR.properties 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/main/resources/i18n/isis-fish_fr_FR.properties 2014-08-20 09:48:07 UTC (rev 4096)
@@ -69,7 +69,7 @@
Use\ branches,\ switch\ not\ needed=
User\ restart\ simulation\ %s=
User\ stop\ simulation\ %s=
-Zones=
+Zones=Zones
an\ alternative\ way\ to\ specify\ the\ scale.=
could\ not\ close\ reader\ %1$s=could not close reader %1$s
could\ not\ found\ %s=
@@ -230,13 +230,13 @@
isisfish.config.main.subSimulator.description=Nom du simulateur en sous processus
isisfish.config.main.userMail.description=le courriel de l'utilisateur
isisfish.config.main.userName.description=le nom - prénom de l'utilisateur
-isisfish.config.mapped.result.matrix.vector.class.description=
-isisfish.config.simulation.matrix.threshold.use.sparse.class.description=
-isisfish.config.simulation.matrix.use.lazy.vector.description=
-isisfish.config.simulation.matrix.vector.class.description=
-isisfish.config.simulation.matrix.vector.sparse.class.description=
-isisfish.config.simulation.store.result.cachestep.description=
-isisfish.config.simulation.store.result.ondisk.description=
+isisfish.config.mapped.result.matrix.vector.class.description=(OBSOLETE) Type de matrice à utiliser pour la lecture des résultats du fichier results.mapped
+isisfish.config.simulation.matrix.threshold.use.sparse.class.description=seuil d'utilisation des matrices dense/creuse. Sous ce seuil, des matrices denses sont utilisé (matrix.vector.class), au dessu de ce seuil des matrices creusent sont utilisées (matrice.vector.sparse.class)
+isisfish.config.simulation.matrix.use.lazy.vector.description=indique si l'on utilise ou non le copy-on-write. La copie de matrice est alors à coût nul tant qu'on ecrit pas sur une des deux matrices. Il est recommandé de laissé à la valeur par défaut.
+isisfish.config.simulation.matrix.vector.class.description=Type de matrice à utiliser pour les matrices denses.
+isisfish.config.simulation.matrix.vector.sparse.class.description=Type de matrice à utiliser pour les matrices creuses.
+isisfish.config.simulation.store.result.cachestep.description=Nombre de pas de temps gardé en mémoire durant la simulation. Si le résultat n'est plus en mémoire, il est alors relu sur le disque s'il existe, ce qui est un peu plus coûteux.
+isisfish.config.simulation.store.result.ondisk.description=Nombre de résultat à conserver sur disque. Lorsque vous faites des simulations distantes pour un plan d'analyse et que vous souhaitez travailler sur les résultats des simulations après la simulation, il faut que les résultats soient stockés sur disque.
isisfish.config.ssh.key.file=Clé SSH
isisfish.config.ssh.key.file.description=Emplacement de la clé privée SSH
isisfish.config.title=Préférences
@@ -692,18 +692,18 @@
isisfish.params.simulationName=Nom de la simulation
isisfish.params.stategiesAndPopulations=Stratégies et populations
isisfish.params.title=Paramètres
-isisfish.params.toString.fishery=Pêcherie\: %s\n\n
+isisfish.params.toString.fishery=Pêcherie\: %s
isisfish.params.toString.lib.logger.level=niveau du logger de librairies \: %s
-isisfish.params.toString.number.years=Nombre d'années \: %s\n\n
+isisfish.params.toString.number.years=Nombre d'années \: %s
isisfish.params.toString.objective=Fonction d'objectif \: %s
isisfish.params.toString.optimization=Méthode d'optimisation \: %s
isisfish.params.toString.optimizationExport=Export d'optimisation \: %s
isisfish.params.toString.optimizationObservation=Observation d'optimisation \: %s
isisfish.params.toString.plan=Plan\: %s
-isisfish.params.toString.plan.number=Numéro de séquence dans le plan \: %s\n\n
+isisfish.params.toString.plan.number=Numéro de séquence dans le plan \: %s
isisfish.params.toString.populations=Populations \:
isisfish.params.toString.rule=Règle\: %s
-isisfish.params.toString.script.generatedpresimulation=
+isisfish.params.toString.script.generatedpresimulation=Script généré
isisfish.params.toString.script.logger.level=niveau du logger de scripts \: %1$s
isisfish.params.toString.script.presimulation=Script de presimulation
isisfish.params.toString.simul.logger.level=niveau du logger de simulateur \: %1$s
Modified: branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java
===================================================================
--- branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -319,9 +319,11 @@
@Test
public void testExportImport() throws IOException, IsisFishException, TopiaException {
+ Date date = new Date();
+
// first export
DesignPlan testDesignPlan = getTestDesignPlan(false, false);
- String xml1 = MexicoHelper.getDesignPlanAsXML(testDesignPlan);
+ String xml1 = MexicoHelper.getDesignPlanAsXML(testDesignPlan, "date", date.toString());
if (log.isDebugEnabled()) {
log.debug("xml 1 = " + xml1);
}
@@ -332,7 +334,7 @@
// topia context can be null in tests
DesignPlan plan = MexicoHelper.getDesignPlanFromXML(testFile, regionContext);
- String xml2 = MexicoHelper.getDesignPlanAsXML(plan);
+ String xml2 = MexicoHelper.getDesignPlanAsXML(plan, "date", date.toString());
if (log.isDebugEnabled()) {
log.debug("xml 2 = " + xml2);
}
@@ -364,12 +366,12 @@
Assert.assertTrue(xml.indexOf("<feature name=\"grouptype\">continuous") != -1);
Assert.assertTrue(xml.indexOf("<feature name=\"group\">discretegrp") != -1);
Assert.assertTrue(xml.indexOf("<feature name=\"group\">discrete") != -1);
-
+
// factor 6
Assert.assertTrue(xml.indexOf("<rule name=\"TACpoids\">") != -1);
Assert.assertTrue(xml.indexOf("<rule name=\"TailleMin\">") != -1);
Assert.assertTrue(xml.indexOf("<param key=\"rule.0.parameter.propSurvie\">42.0</param>") != -1);
- Assert.assertTrue(xml.indexOf("<param key=\"rule.0.parameter.species\">fr.ifremer.isisfish.entities.Species#1169028645830#0.022262364425031378</param>") != -1);
+ Assert.assertTrue(xml.indexOf("<param key=\"rule.0.parameter.species\">fr.ifremer.isisfish.entities.Species#1169028645830#0.022262364425031378:EngEnc</param>") != -1);
}
/**
Modified: branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java
===================================================================
--- branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -402,10 +402,10 @@
// generate prescript for that wonderfull scenario
String preScriptContent = FactorHelper.generatePreScript(scenario1);
- //log.info("Script = " + preScriptContent);
+ log.info("Script = " + preScriptContent);
Assert.assertTrue(preScriptContent.contains("params.setProperty(\"population.xxx.number\""));
- Assert.assertTrue(preScriptContent.contains("params.setProperty(\"rule.0.parameter.species\",\"fr.ifremer.isisfish.entities.Species#1169028645830#0.022262364425031378\");"));
+ Assert.assertTrue(preScriptContent.contains("params.setProperty(\"rule.0.parameter.species\",\"fr.ifremer.isisfish.entities.Species#1169028645830#0.022262364425031378:EngEnc\");"));
Assert.assertTrue(preScriptContent.contains("params.setProperty(\"rule.1.parameter.propSurvie\",\"42.0\");"));
Assert.assertTrue(preScriptContent.contains("rules\",\"TACpoids,TailleMin\")"));
}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/Abundances.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/Abundances.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/Abundances.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -26,7 +26,6 @@
import java.io.Writer;
-import static org.nuiton.i18n.I18n._;
import org.nuiton.math.matrix.*;
import scripts.ResultName;
@@ -37,7 +36,7 @@
import fr.ifremer.isisfish.datastore.SimulationStorage;
/**
- * Abundance.java
+ * Abundances.java
*
* Created: 1 septembre 2006
*
@@ -52,8 +51,8 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(Abundances.class);
- protected String [] necessaryResult = {
- ResultName.MATRIX_ABUNDANCE
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_ABUNDANCE
};
@Override
@@ -73,22 +72,22 @@
@Override
public String getDescription() {
- return _("Exporte les abondances en nombre tableau avec des lignes pop;id;zone;date;nombre.");
+ return "Exporte les abondances en nombre tableau avec des lignes pop;id;zone;date;nombre.";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
for (Population pop : simulation.getParameter().getPopulations()) {
MatrixND mat = simulation.getResultStorage().getMatrix(pop, ResultName.MATRIX_ABUNDANCE);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
- Object [] sems = i.getSemanticsCoordinates();
- TimeStep step = (TimeStep)sems[0];
- PopulationGroup group = (PopulationGroup)sems[1];
- Zone zone = (Zone)sems[2];
+ Object[] sems = i.getSemanticsCoordinates();
+ TimeStep step = (TimeStep) sems[0];
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Zone zone = (Zone) sems[2];
double val = i.getValue();
- out.write(pop.getName() +";"+ group.getId() +";"+ zone.getName() +";"+ step.getStep() +";"+ val +"\n");
+ out.write(pop.getName() + ";" + group.getId() + ";" + zone.getName() + ";" + step.getStep() + ";" + val + "\n");
}
}
}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/Biomasses.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/Biomasses.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/Biomasses.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -53,8 +51,8 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(Biomasses.class);
- protected String [] necessaryResult = {
- ResultName.MATRIX_BIOMASS
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_BIOMASS
};
@Override
@@ -74,22 +72,22 @@
@Override
public String getDescription() {
- return _("Exporte les biomasses tableau avec des lignes pop;id;zone;date;nombre");
+ return "Exporte les biomasses tableau avec des lignes pop;id;zone;date;nombre";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
for (Population pop : simulation.getParameter().getPopulations()) {
MatrixND mat = simulation.getResultStorage().getMatrix(pop, ResultName.MATRIX_BIOMASS);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
- Object [] sems = i.getSemanticsCoordinates();
- TimeStep step = (TimeStep)sems[0];
- PopulationGroup group = (PopulationGroup)sems[1];
- Zone zone = (Zone)sems[2];
-
+ Object[] sems = i.getSemanticsCoordinates();
+ TimeStep step = (TimeStep) sems[0];
+ PopulationGroup group = (PopulationGroup) sems[1];
+ Zone zone = (Zone) sems[2];
+
double val = i.getValue();
- out.write(pop.getName() +";"+ group.getId() +";"+ zone.getName() +";"+ step.getStep() +";"+ val +"\n");
+ out.write(pop.getName() + ";" + group.getId() + ";" + zone.getName() + ";" + step.getStep() + ";" + val + "\n");
}
}
}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesNombre.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesNombre.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesNombre.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,16 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixIterator;
-import org.nuiton.math.matrix.MatrixND;
-
-import scripts.ResultName;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Metier;
import fr.ifremer.isisfish.entities.Population;
@@ -38,12 +28,20 @@
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.export.Export;
import fr.ifremer.isisfish.types.TimeStep;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+import java.io.Writer;
+
/**
* CapturesNombre.java
*
- * Created: 23 novembre 2006
- *
+ * Export des captures en nombre de la forme :
+ * Population ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur
+ *
* @author anonymous <anonymous(a)labs.libre-entreprise.org>
* @version $Revision: 1.4 $
*
@@ -54,7 +52,9 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(CapturesNombre.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP
+ };
@Override
public String[] getNecessaryResult() {
@@ -73,7 +73,7 @@
@Override
public String getDescription() {
- return _("Export les captures en nombre de la simulation. tableau pop;metier;id;zone;nombre");
+ return "Export les captures en nombre de la simulation. tableau pop;metier;id;zone;nombre";
}
@Override
@@ -82,8 +82,7 @@
TimeStep lastStep = simulation.getResultStorage().getLastStep();
for (Population pop : simulation.getParameter().getPopulations()) {
- for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step
- .next()) {
+ for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step.next()) {
MatrixND mat = simulation.getResultStorage().getMatrix(step,
pop, ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP);
if (mat != null) { // can be null if simulation is stopped before last year simulation
Copied: branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesNombreStrategies.java (from rev 4095, trunk/src/test/resources/test-database/exports/CapturesNombreStrategies.java)
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesNombreStrategies.java (rev 0)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesNombreStrategies.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -0,0 +1,109 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package exports;
+
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.export.Export;
+import fr.ifremer.isisfish.types.TimeStep;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+
+import java.io.Writer;
+
+/**
+ * CapturesNombreStrategies.java
+ *
+ * Export des captures en nombre de la forme :
+ * Population ; Stratégie ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur
+ *
+ * @author anonymous <anonymous(a)labs.libre-entreprise.org>
+ * @version $Revision$
+ *
+ * Last update: $Date$ by : $Author$
+ */
+public class CapturesNombreStrategies implements Export {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(CapturesNombreStrategies.class);
+
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP
+ };
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "CapturesNombreStrategies";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Export les captures en nombre de la simulation. tableau pop;strategie;metier;id;zone;nombre";
+ }
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out) throws Exception {
+ TimeStep lastStep = simulation.getResultStorage().getLastStep();
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step
+ .next()) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(step,
+ pop, ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP);
+ if (mat != null) { // can be null if simulation is stopped before last year simulation
+ //mat = mat.sumOverDim(0); //sum on strategy
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Metier metier = (Metier) sems[1];
+ PopulationGroup group = (PopulationGroup) sems[2];
+ Zone zone = (Zone) sems[3];
+ Strategy strategy = (Strategy) sems[0];
+
+ double val = i.getValue();
+ out.write(pop.getName() + ";" + strategy.getName() + ";"
+ + metier.getName() + ";" + group.getId() + ";"
+ + zone.getName() + ";" + step.getStep() + ";"
+ + val + "\n");
+ }
+ }
+ }
+ }
+ }
+}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesPoids.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesPoids.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesPoids.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,16 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixIterator;
-import org.nuiton.math.matrix.MatrixND;
-
-import scripts.ResultName;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Metier;
import fr.ifremer.isisfish.entities.Population;
@@ -38,11 +28,19 @@
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.export.Export;
import fr.ifremer.isisfish.types.TimeStep;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+import java.io.Writer;
+
/**
* CapturesPoids.java
*
- * Created: 23 novembre 2006
+ * Export des captures en poids de la forme :
+ * Population ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur
*
* @author anonymous <anonymous(a)labs.libre-entreprise.org>
* @version $Revision: 1.4 $
@@ -54,7 +52,9 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(CapturesPoids.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
@Override
public String[] getNecessaryResult() {
@@ -73,7 +73,7 @@
@Override
public String getDescription() {
- return _("Export les captures en poids de la simulation. tableau pop;metier;id;zone;nombre");
+ return "Export les captures en poids de la simulation. tableau pop;metier;id;zone;nombre";
}
@Override
Copied: branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesPoidsStrategies.java (from rev 4095, trunk/src/test/resources/test-database/exports/CapturesPoidsStrategies.java)
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesPoidsStrategies.java (rev 0)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/CapturesPoidsStrategies.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -0,0 +1,110 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package exports;
+
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.export.Export;
+import fr.ifremer.isisfish.types.TimeStep;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+
+import java.io.Writer;
+
+/**
+ * CapturesPoidsStrategies.java
+ *
+ * Export des captures en poids de la forme :
+ * Population ; Stratégie ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur
+ *
+ * @author anonymous <anonymous(a)labs.libre-entreprise.org>
+ * @version $Revision$
+ *
+ * Last update: $Date$ by : $Author$
+ */
+public class CapturesPoidsStrategies implements Export {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(CapturesPoidsStrategies.class);
+
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
+
+ @Override
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+ @Override
+ public String getExportFilename() {
+ return "CapturesPoidsStrategies";
+ }
+
+ @Override
+ public String getExtensionFilename() {
+ return ".csv";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Export les captures en poids de la simulation. tableau pop;strategie;metier;id;zone;nombre";
+ }
+
+ @Override
+ public void export(SimulationStorage simulation, Writer out)
+ throws Exception {
+ TimeStep lastStep = simulation.getResultStorage().getLastStep();
+
+ for (Population pop : simulation.getParameter().getPopulations()) {
+ for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step
+ .next()) {
+ MatrixND mat = simulation.getResultStorage().getMatrix(step,
+ pop, ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ if (mat != null) { // can be null if simulation is stopped before last year simulation
+ //mat = mat.sumOverDim(0); //sum on strategy
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sems = i.getSemanticsCoordinates();
+ Metier metier = (Metier) sems[1];
+ PopulationGroup group = (PopulationGroup) sems[2];
+ Zone zone = (Zone) sems[3];
+ Strategy strategy = (Strategy) sems[0];
+
+ double val = i.getValue();
+ out.write(pop.getName() + ";" + strategy.getName() + ";"
+ + metier.getName() + ";" + group.getId() + ";"
+ + zone.getName() + ";" + step.getStep() + ";"
+ + val + "\n");
+ }
+ }
+ }
+ }
+ }
+}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/CellsDefinition.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/CellsDefinition.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/CellsDefinition.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import java.util.List;
@@ -50,11 +48,11 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(CellsDefinition.class);
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -74,7 +72,7 @@
@Override
public String getDescription() {
- return _("Export cell's position(longitute/latitute)");
+ return "Export cell's position(longitute/latitute)";
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/EffortsMetier.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/EffortsMetier.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/EffortsMetier.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,7 +52,7 @@
static private Log log = LogFactory.getLog(EffortsMetier.class);
protected String [] necessaryResult = {
- ResultName.MATRIX_EFFORT_PER_STRATEGY_MET
+ ResultName.MATRIX_EFFORT_PER_STRATEGY_MET
};
@Override
@@ -74,13 +72,13 @@
@Override
public String getDescription() {
- return _("retourne un tableau strategie;metier;date;effort");
+ return "retourne un tableau strategie;metier;date;effort";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
MatrixND mat = simulation.getResultStorage().getMatrix(ResultName.MATRIX_EFFORT_PER_STRATEGY_MET);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
Object [] sems = i.getSemanticsCoordinates();
TimeStep step = (TimeStep)sems[0];
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/MetierZone.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/MetierZone.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/MetierZone.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -26,7 +26,6 @@
import java.io.Writer;
-import static org.nuiton.i18n.I18n._;
import org.nuiton.math.matrix.*;
import scripts.ResultName;
@@ -51,8 +50,8 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(MetierZone.class);
- public String [] necessaryResult = {
- ResultName.MATRIX_METIER_ZONE,
+ protected String [] necessaryResult = {
+ ResultName.MATRIX_METIER_ZONE,
};
@Override
@@ -72,7 +71,7 @@
@Override
public String getDescription() {
- return _("Export zone used by metier during simulation");
+ return "Export zone used by metier during simulation";
}
@Override
@@ -82,7 +81,7 @@
for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step.next() ) {
MatrixND mat = simulation.getResultStorage().getMatrix(step, ResultName.MATRIX_METIER_ZONE);
if (mat != null) { // can be null if simulation is stopped before last year simulation
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
if (i.getValue() == 1) {
Object metier = i.getSemanticsCoordinates()[0];
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/NonActivite.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/NonActivite.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/NonActivite.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,7 +52,7 @@
static private Log log = LogFactory.getLog(NonActivite.class);
protected String [] necessaryResult = {
- ResultName.MATRIX_NO_ACTIVITY
+ ResultName.MATRIX_NO_ACTIVITY
};
@Override
@@ -74,13 +72,13 @@
@Override
public String getDescription() {
- return _("retourne un tableau strategie;metier;date;proportion");
+ return "retourne un tableau strategie;metier;date;proportion";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
MatrixND mat = simulation.getResultStorage().getMatrix(ResultName.MATRIX_NO_ACTIVITY);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
Object [] sems = i.getSemanticsCoordinates();
TimeStep step = (TimeStep)sems[0];
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/OwnerMargin.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/OwnerMargin.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/OwnerMargin.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,7 +52,7 @@
static private Log log = LogFactory.getLog(OwnerMargin.class);
protected String [] necessaryResult = {
- ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL
+ ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL
};
@Override
@@ -74,15 +72,15 @@
@Override
public String getDescription() {
- return _("Exporte les profits du patrons, retourne un tableau strategy;date;value");
+ return "Exporte les profits du patrons, retourne un tableau strategy;date;value";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
MatrixND mat = simulation.getResultStorage().getMatrix(ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
- Object [] sems = i.getSemanticsCoordinates();
+ Object[] sems = i.getSemanticsCoordinates();
TimeStep step = (TimeStep)sems[0];
Strategy str = (Strategy)sems[1];
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/RegionDefinition.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/RegionDefinition.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/RegionDefinition.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -26,7 +26,6 @@
import java.io.Writer;
-import static org.nuiton.i18n.I18n._;
import org.nuiton.topia.TopiaContext;
import fr.ifremer.isisfish.entities.*;
@@ -49,11 +48,11 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(RegionDefinition.class);
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -73,7 +72,7 @@
@Override
public String getDescription() {
- return _("Export region description");
+ return "Export region description";
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/RejetsNombre.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/RejetsNombre.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/RejetsNombre.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -54,7 +52,9 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(RejetsNombre.class);
- protected String[] necessaryResult = { ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP
+ };
@Override
public String[] getNecessaryResult() {
@@ -73,7 +73,7 @@
@Override
public String getDescription() {
- return _("Export les rejets en nombre de la simulation. tableau pop;metier;id;zone;date;nombre");
+ return "Export les rejets en nombre de la simulation. tableau pop;metier;id;zone;date;nombre";
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/RejetsPoids.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/RejetsPoids.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/RejetsPoids.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -54,8 +52,8 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(RejetsPoids.class);
- protected String[] necessaryResult = { ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP
-
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP
};
@Override
@@ -75,7 +73,7 @@
@Override
public String getDescription() {
- return _("Export les rejets en poids de la simulation. tableau pop;metier;id;zone;date;nombre");
+ return "Export les rejets en poids de la simulation. tableau pop;metier;id;zone;date;nombre";
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/VesselMargin.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/VesselMargin.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/VesselMargin.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package exports;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,7 +52,7 @@
static private Log log = LogFactory.getLog(VesselMargin.class);
protected String [] necessaryResult = {
- ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL
+ ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL
};
@Override
@@ -74,13 +72,13 @@
@Override
public String getDescription() {
- return _("cvs out strategy;date;value");
+ return "cvs out strategy;date;value";
}
@Override
public void export(SimulationStorage simulation, Writer out) throws Exception {
MatrixND mat = simulation.getResultStorage().getMatrix(ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL);
- for (MatrixIterator i=mat.iterator(); i.hasNext();) {
+ for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
Object [] sems = i.getSemanticsCoordinates();
TimeStep step = (TimeStep)sems[0];
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/exports/ZonesDefinition.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/exports/ZonesDefinition.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/exports/ZonesDefinition.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -27,7 +27,6 @@
import java.io.Writer;
import java.util.List;
-import static org.nuiton.i18n.I18n._;
import org.nuiton.topia.TopiaContext;
import fr.ifremer.isisfish.entities.*;
@@ -51,11 +50,11 @@
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(ZonesDefinition.class);
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -75,7 +74,7 @@
@Override
public String getDescription() {
- return _("Export cell's zone constitution");
+ return "Export cell's zone constitution";
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/rules/Cantonnement.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/rules/Cantonnement.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/rules/Cantonnement.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -50,6 +48,8 @@
/**
* Cantonnement.java
*
+ * Remplace aussi Cantonnement Engin
+ *
* Created: 30 novembre 2006
*
* @author anonymous <anonymous(a)labs.libre-entreprise.org>
@@ -58,10 +58,6 @@
* Last update: $Date: 2007-11-02 17:41:41 $
* by : $Author: bpoussin $
*/
-
-/**
- * Remplace aussi Cantonnement Engin
- */
public class Cantonnement extends AbstractRule {
/** to use log facility, just put in your code: log.info("..."); */
@@ -80,12 +76,12 @@
@Doc(value="End month")
public Month param_endMonth = Month.DECEMBER;
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- ResultName.MATRIX_NO_ACTIVITY,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ ResultName.MATRIX_NO_ACTIVITY,
};
@Override
@@ -101,7 +97,7 @@
public String getDescription() throws Exception {
// fermeture saisiniere de zone qui peut être réduite à un engin
// et a certaines années de la simulation
- return _("Cantonnement: can be used to Cantonnement with gear if you put gear in parameter");
+ return "Cantonnement: can be used to Cantonnement with gear if you put gear in parameter";
}
/**
@@ -126,7 +122,7 @@
public boolean condition(SimulationContext context, TimeStep step, Metier metier) throws Exception {
if (step.before(param_beginStep)) {
return false;
- } else if(step.after(param_endStep)) {
+ } else if (step.after(param_endStep)) {
return false;
}
@@ -204,7 +200,7 @@
zoneCantonnement.addAllCell(tmpCells);
i.remove();
}
- List<Zone> newZone = new ArrayList<Zone>();
+ List<Zone> newZone = new ArrayList<>();
newZone.add(zoneCantonnement);
infoMetier.setZone(newZone);
} else {
@@ -219,10 +215,10 @@
metierMon.addforbiddenMetier(metier);
List<Strategy> strategies = siMatrix.getStrategies(step);
- for(Strategy str : strategies){
+ for (Strategy str : strategies) {
StrategyMonthInfo info = str.getStrategyMonthInfo(step.getMonth());
double prop = info.getProportionMetier(metier);
- if (prop != 0){
+ if (prop != 0) {
noActivity.setValue(str , metier, prop);
info.setProportionMetier(metier, 0);
}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/rules/CantonnementPreSimu.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/rules/CantonnementPreSimu.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/rules/CantonnementPreSimu.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,9 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n.n_;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -73,15 +70,15 @@
@Doc(value="End month")
public Month param_endMonth = Month.DECEMBER;
- protected Map<Month, MatrixND> tableNonActivite = new HashMap<Month, MatrixND>();
+ protected Map<Month, MatrixND> tableNonActivite = new HashMap<>();
protected boolean affectNonActivite = false;
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- ResultName.MATRIX_NO_ACTIVITY,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ ResultName.MATRIX_NO_ACTIVITY,
};
@Override
@@ -95,7 +92,7 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Cantonnement: can be used to Cantonnement with gear if you put gear in parameter");
+ return "Cantonnement: can be used to Cantonnement with gear if you put gear in parameter";
}
private void reportNonActivite(SimulationContext context,
@@ -107,7 +104,8 @@
if (effort != null){
for (Month month : chomageMonth) {
StrategyMonthInfo InfoMois = strategy.getStrategyMonthInfo(month);
-//this.p.tableNonActivite=Regle_action_lib.reportNonActivite(this.p.tableNonActivite, listestrategies.get(i), metier, mois, InfoMois.getProportionMetier(metier));
+ // this.p.tableNonActivite=Regle_action_lib.reportNonActivite(this.p.tableNonActivite,
+ // listestrategies.get(i), metier, mois, InfoMois.getProportionMetier(metier));
log.info("debut reportNonActivite");
// on regarde si on a déjà une entrée pour le mois courant
@@ -116,7 +114,7 @@
matNonActiviteMois = MatrixFactory.getInstance().create(
ResultName.MATRIX_NO_ACTIVITY,
new List[]{listestrategies, metiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ new String[]{"Strategies", "Metiers"});
tableNonActivite.put(month, matNonActiviteMois);
}
@@ -160,20 +158,20 @@
else {
log.info("l engin du métier est bien concerné");
List<MetierSeasonInfo> saisons = metier.getMetierSeasonInfo();
- for (MetierSeasonInfo saisonmetier: saisons){
+ for (MetierSeasonInfo saisonmetier : saisons){
int inter = siMatrix.nbCellInter(saisonmetier.getZone(), param_zone);
- if (inter != 0){
+ if (inter != 0) {
List<Cell> MailleMetier = siMatrix.getCells(saisonmetier.getZone());
// les mailles qui reste dans la zone metier
- List<Cell> newCellMetier = new ArrayList<Cell>(MailleMetier);
+ List<Cell> newCellMetier = new ArrayList<>(MailleMetier);
newCellMetier.removeAll(maillefermee);
- List<Month> saison=saisonmetier.getMonths();
+ List<Month> saison = saisonmetier.getMonths();
if (saison.containsAll(SaisonFermee)){
log.info("il y a bien intersection entre la zone métier et le cantonnement pour la saison "+saison.toString());
// calcule de la zone restante:
- boolean ToutFerme=false;
+ boolean ToutFerme;
boolean DebInclus=saison.contains(param_beginMonth);
boolean FinInclus=saison.contains(param_endMonth);
@@ -202,7 +200,7 @@
log.info("toute la saison metier est incluse dans la saison de fermeture");
//si tout est fermé, on met le metier au chômage
- if (ToutFerme==true) {
+ if (ToutFerme) {
log.info ("toute la zone est fermée, le metier passe donc à chômage pour cette saison");
reportNonActivite(context, listestrategies, metiers, metier, saison);
@@ -219,7 +217,7 @@
else if (DebInclus && ((!FinInclus) || param_endMonth.equals(saison.get(saison.size()-1)))) {
log.info ("il y a intersection de la saison de fermeture avec la saison métier de " + param_beginMonth + " à " + saison.get(saison.size()-1));
//si tout est fermé on met les proportions à 0 pour les mois fermes
- if (ToutFerme==true){
+ if (ToutFerme){
log.info ("toute la zone métier est fermée");
List<Month> chomageMonth = new ArrayList<Month>(SaisonFermee);
chomageMonth.retainAll(saison);
@@ -246,7 +244,7 @@
else if (((!DebInclus) || param_beginMonth.equals(saison.get(0))) && FinInclus) {
log.info ("il y a intersection de la saison de fermeture avec la saison métier de "+param_beginMonth+" à "+saison.get(saison.size()-1));
//si tout est fermé on met les proportions à 0 pour les mois fermes
- if (ToutFerme==true){
+ if (ToutFerme){
log.info ("toute la zone est fermee");
List<Month> chomageMonth = new ArrayList<Month>(SaisonFermee);
chomageMonth.retainAll(saison);
@@ -272,7 +270,7 @@
// dernier cas de figure: les deux sont inclus et sont différents des bornes
else {
//si tout est fermé on met les proportions à 0 pour les mois fermes
- if (ToutFerme==true){
+ if (ToutFerme){
log.info("toute la zone métier est fermée");
reportNonActivite(context, listestrategies, metiers, metier, SaisonFermee);
}
@@ -325,7 +323,7 @@
public boolean condition(SimulationContext context, TimeStep step, Metier metier) throws Exception {
boolean result = false;
MatrixND mat = tableNonActivite.get(step.getMonth());
- if (mat != null && affectNonActivite == false) {
+ if (mat != null && !affectNonActivite) {
result = true;
}
return result;
@@ -353,7 +351,7 @@
metierMon.setNoActivity(step, mat.copy());
}
else{
- noActivity = noActivity.add(mat);
+ noActivity.add(mat);
}
}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/rules/ChangementParamControlablePresimu.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import java.util.ArrayList;
import java.util.List;
@@ -77,11 +75,11 @@
@Doc(value="New param controlable value")
public String param_newParamValue = "80";
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -95,7 +93,7 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Change gear parameter value for all metier with this gear");
+ return "Change gear parameter value for all metier with this gear";
}
/**
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/rules/EffortReduction.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/rules/EffortReduction.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/rules/EffortReduction.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import java.util.List;
import org.apache.commons.logging.Log;
@@ -57,9 +55,13 @@
@Doc("Pourcentage de reduction d effort applique.")
public double param_PercentReduction = 0.5;
- boolean first = true;
+ protected boolean first = true;
- protected String[] necessaryResult = {};
+ protected String[] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ };
/**
* @return the necessaryResult
@@ -75,7 +77,7 @@
*/
@Override
public String getDescription() {
- return _("Reduce monthly effort of each strategy of the percent indicated");
+ return "Reduce monthly effort of each strategy of the percent indicated";
}
/**
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/rules/GraviteVPUE1.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/rules/GraviteVPUE1.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/rules/GraviteVPUE1.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -59,21 +57,20 @@
static private Log log = LogFactory.getLog(GraviteVPUE1.class);
/** stocke la somme des prop initiales [str x month] */
- private MatrixND SommePropInitial = null;
- /** stocke par strat*met, la dernière attractivite pour chaque mois [str x met x month] */
+ protected MatrixND SommePropInitial = null;
/** permet de stocker les CPUE nominales [str x met] */
- private MatrixND valuePerUnitOfEffort = null;
+ protected MatrixND valuePerUnitOfEffort = null;
- public String[] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- //ResultName.MATRIX_EFFORT_PER_STRATEGY_MET,
- ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET, // garder la ,
+ // Booleen permettant que ne boucler que sur un seul metier dans la preaction :
+ protected boolean first = true;
+ protected String[] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET
};
@Override
@@ -87,7 +84,7 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Calcule les proportion par métier chaque mois en fonction de la VPUE du métier l'année précédante");
+ return "Calcule les proportion par métier chaque mois en fonction de la VPUE du métier l'année précédante";
/*"HYPOTHESES GRAVITE"
" attention cette règle doit toujours être mise avant les mesures de gestion"+
" si pour un metier Effort (métier annee-1,mois) = 0 et propinitiale (métier, mois) !=0 (ie métier potentiellement pratiqué), alors "+
@@ -146,7 +143,6 @@
SommePropInitial.setValue(str, info.getMonth(), somme);
}
}
-
}
/**
@@ -164,8 +160,6 @@
return step.getYear() > 0;
}
- // Booleen permettant que ne boucler que sur un seul metier dans la preaction :
- boolean first = true;
/**
* Si la condition est vrai alors cette action est executee avant le pas
@@ -195,14 +189,14 @@
////////Initialisation des matrices qui resultent de la simulation////////////////////////////////////////////////////////////
//Calcul de l effort nominal par strategy met
- MatrixND EffortNominalPerStrMet = null;
+ MatrixND EffortNominalPerStrMet;
EffortNominalPerStrMet = resultmanager.getMatrix(step.previousYear(),
ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET);
//System.out.println("EffortNominalPerStrMet calculee "
// + EffortNominalPerStrMet);
//on commence par creer une matrice de valeurs (somme sur ttes les especes capturees) par strategie met
- MatrixND GrossValuePerStrMet = null;
+ MatrixND GrossValuePerStrMet;
GrossValuePerStrMet = resultmanager.getMatrix(step.previousYear(),
ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET);
@@ -246,7 +240,7 @@
//log.info("value/effort= " + vpue);
somme += value / effort;
} else if ((effort == 0)
- & (smi.getProportionMetier(strMetier) == 0)) {// n'a jamais pêche avec ce metier
+ && (smi.getProportionMetier(strMetier) == 0)) {// n'a jamais pêche avec ce metier
valuePerUnitOfEffort.setValue(str, strMetier, 0);
//log.info("n'a jamais pêche avec ce metier");
} else {// n'a pas peche au mois, annee -1, mais avait une prop d'effort non nul a l'annee=0
@@ -257,7 +251,7 @@
//log.info("testCondition pour str" + str.getName()
// + ":" + testCondition);
// A partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravité
- double newProp = 0;
+ double newProp;
//log.info("A partir des VPUE stockees dans valuePerUnitOfEffort, on calcule la gravité");
if (!testCondition) {
double SommeVPUEstrat = somme;
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/rules/InterdictionEngin.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/rules/InterdictionEngin.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/rules/InterdictionEngin.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -71,11 +69,11 @@
@Doc(value="do the doc of param endMonth")
public Month param_endMonth = Month.DECEMBER;
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -90,7 +88,7 @@
@Override
public String getDescription() throws Exception {
// interdiction des metiers utilisant cet engin
- return _("Prohibited gear");
+ return "Prohibited gear";
}
/**
@@ -167,7 +165,7 @@
// 1er cas:l'effort est reporte sur un metier de la meme strategie,
// n'ayant pas l'espece comme capture principale et pechant avec le meme engin
- List<EffortDescription> MetiersPossibles = new ArrayList<EffortDescription>(Strat.getSetOfVessels().getPossibleMetiers());
+ List<EffortDescription> MetiersPossibles = new ArrayList<>(Strat.getSetOfVessels().getPossibleMetiers());
// on verifie que les metiers sont bien pratiques au mois courant,
// qu'ils n'ont pas le meme engin et qu'ils ne sont pas
@@ -184,7 +182,7 @@
// on repartit maintenant l'effort entre les differents metiers
// possibles dans la meme strategie si un metier possible existe bien
- if (MetiersPossibles.size() != 0){
+ if (MetiersPossibles.size() != 0) {
int NbMetier=MetiersPossibles.size();
for (EffortDescription effort : MetiersPossibles) {
Metier met = effort.getPossibleMetiers();
@@ -203,7 +201,7 @@
siMatrix.getMetiers(step));
matNonActivite.setValue(Strat, metier,
StratMonthInfo.getProportionMetier(metier));
- StratMonthInfo.setProportionMetier(metier,0);
+ StratMonthInfo.setProportionMetier(metier, 0);
}
}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/rules/InterdictionEnginPreSimu.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,9 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.n_;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -70,14 +67,14 @@
@Doc(value="do the doc of param endMonth")
public Month param_endMonth = Month.DECEMBER;
- protected Map<Month, MatrixND> tableNonActivite = new HashMap<Month, MatrixND>();
+ protected Map<Month, MatrixND> tableNonActivite = new HashMap<>();
protected boolean affectNonActivite = false;
- public String [] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String [] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -91,7 +88,7 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Prohibited gear");
+ return "Prohibited gear";
}
/**
@@ -159,7 +156,7 @@
matNonActiviteMois = MatrixFactory.getInstance().create(
ResultName.MATRIX_NO_ACTIVITY,
new List[]{ListeStrat, ListeMetiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ new String[]{"Strategies", "Metiers"});
tableNonActivite.put(mois, matNonActiviteMois);
}
@@ -189,7 +186,7 @@
public boolean condition(SimulationContext context, TimeStep step, Metier metier) throws Exception {
boolean result = false;
MatrixND mat = tableNonActivite.get(step.getMonth());
- if (mat != null && affectNonActivite == false) {
+ if (mat != null && !affectNonActivite) {
result = true;
}
return result;
@@ -207,7 +204,7 @@
@Override
public void preAction(SimulationContext context, TimeStep step, Metier metier) throws Exception {
// on ne doit le faire qu'une seul fois quelque soit le nombre de metier
- affectNonActivite=true;
+ affectNonActivite = true;
MatrixND mat = tableNonActivite.get(step.getMonth());
MetierMonitor metierMon = context.getMetierMonitor();
@@ -215,10 +212,9 @@
if (noActivity == null) {
metierMon.setNoActivity(step, mat.copy());
+ } else {
+ noActivity.add(mat);
}
- else {
- noActivity = noActivity.add(mat);
- }
// fin
}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/rules/TACpoids.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/rules/TACpoids.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/rules/TACpoids.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import java.util.HashSet;
import java.util.Set;
@@ -87,13 +85,13 @@
@Doc("TAC in tons")
public double param_tacInTons = 900;
- boolean affectation = false;
+ protected boolean affectation = false;
protected String[] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
/**
@@ -111,7 +109,7 @@
*/
@Override
public String getDescription() {
- return _("TAC weight in tons.\nIf you want survival discard use propSurvie other than 0.\nIf you wish TAC computed as a proportion of the biomass use propTac other than 0.");
+ return "TAC weight in tons.\nIf you want survival discard use propSurvie other than 0.\nIf you wish TAC computed as a proportion of the biomass use propTac other than 0.";
}
/**
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/rules/TailleMin.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/rules/TailleMin.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/rules/TailleMin.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin, Stéphanie Mahevas, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,39 +21,41 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixIterator;
import org.nuiton.math.matrix.MatrixND;
import scripts.ResultName;
-import scripts.SiMatrix;
import fr.ifremer.isisfish.entities.Metier;
import fr.ifremer.isisfish.entities.MetierSeasonInfo;
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationGroup;
import fr.ifremer.isisfish.entities.Species;
import fr.ifremer.isisfish.entities.TargetSpecies;
+import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.rule.AbstractRule;
import fr.ifremer.isisfish.simulator.PopulationMonitor;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.Doc;
+import java.util.List;
/**
- * Cette methode remplace aussi TailleMinSurvieRejet si propSurvie est > 0
+ * Cette regles tient compte de la taille minimum des poissons capturable.
*
+ * Les captures ne sont pas impactées, mais des rejets sont générés si la
+ * taille des poissons est inférieures à TailleMin.
+ *
+ * En cas de propSurvie positif, la matrice d'effectif est modifié
+ * pour tenir compte de la partie de poisson rejeté qui survi.
+ *
* Created: 30 novembre 2006
- *
- * @author anonymous <anonymous(a)labs.libre-entreprise.org>
+ *
+ * @author smahevas
* @version $Revision: 1.1 $
- *
- * Last update: $Date: 2007-01-24 18:25:34 $
- * by : $Author: bpoussin $
+ *
+ * Last update: $Date: 2007-01-24 18:25:34 $ by : $Author: bpoussin $
*/
public class TailleMin extends AbstractRule {
@@ -74,12 +76,14 @@
@Doc(value = "Proportion de survie")
public double param_propSurvie = 0;
-
- public String[] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+
+ protected boolean affectation = true;
+
+ protected String[] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -94,19 +98,20 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Tous les poissons dont la taille est inférieure à TailleMin" +
- " ne seront pas capturés. Ils sont placés en rejets et rejetés" +
- " suivant la proportion de survie.");
+ return "Tous les poissons dont la taille est inférieure à TailleMin"
+ + " ne seront pas capturés. Ils sont placés en rejets et rejetés"
+ + " suivant la proportion de survie.";
}
/**
- * Appelé au démarrage de la simulation, cette méthode permet d'initialiser
- * des valeurs
+ * Appele au demarrage de la simulation, cette methode permet
+ * d'initialiser des valeurs de la règle.
*
- * @param context La simulation pour lequel on utilise cette regle
+ * @param context La simulation pour laquelle on utilise cette regle
*/
@Override
public void init(SimulationContext context) throws Exception {
+
}
/**
@@ -135,12 +140,12 @@
*
* @param context la simulation pour lequel on utilise cette regle
* @param step le pas de temps courant
- * @param metier le metier concerné
+ * @param metier le metier concerne
* @return vrai si on souhaite que les actions soit faites
*/
@Override
- public boolean condition(SimulationContext context, TimeStep step, Metier metier)
- throws Exception {
+ public boolean condition(SimulationContext context, TimeStep step,
+ Metier metier) throws Exception {
log.info("Recherche si la taille Minimale s'applique");
boolean result = true;
if (step.before(param_beginStep)) {
@@ -156,79 +161,92 @@
}
/**
- * Si la condition est vrai alors cette action est executee avant le pas
- * de temps de la simulation.
+ * Si la condition est vrai alors cette action est executee avant le pas de
+ * temps de la simulation.
*
* @param context la simulation pour lequel on utilise cette regle
* @param step le pas de temps courant
- * @param metier le metier concerné
+ * @param metier le metier concerne
*/
@Override
- public void preAction(SimulationContext context, TimeStep step, Metier metier)
- throws Exception {
- // nothing
+ public void preAction(SimulationContext context, TimeStep step,
+ Metier metier) throws Exception {
+
+ affectation = true; // pour que affectation soit vraie au debut de
+ // chaque pas de temps pour rentrer au moins une
+ // fois dans postaction
}
/**
- * Si la condition est vrai alors cette action est executée apres le pas
+ * Si la condition est vrai alors cette action est executee apres le pas
* de temps de la simulation.
*
* @param context La simulation pour lequel on utilise cette regle
* @param step le pas de temps courant
- * @param metier le metier concerné
+ * @param metier le metier concerne
*/
@Override
- public void postAction(SimulationContext context, TimeStep step, Metier metier)
- throws Exception {
- log.info("*$*$*$* TailleMin.actionApres:" + step + " metapop:" +
- param_species + " metier:" + metier);
+ public void postAction(SimulationContext context, TimeStep step,
+ Metier metier) throws Exception {
+ //log.info("*$*$*$* TailleMin.actionApres:" + step + " metapop:"
+ // + param_species + " metier:" + metier);
- if (isCaptureDate(step, param_species, metier)) {
- log.info(
- "*$*$*$* ok affecte capture infÃ?rieure Ã? TailleMin au rejet");
- // ATTENTION
- // les captures pour cette metapop ne sont plus du qu'au metier pour qui
- // l'espece est secondaire: elles sont affectees aux rejets
+ if (affectation) {
+ log.info("*$*$*$* ok affecte capture inferieure a TailleMin au rejet");
+ // ATTENTION
+ // les captures pour cette metapop ne sont plus du qu'au metier pour
+ // qui l'espece est secondaire: elles sont affectees aux rejets
- //pb : ne se fait pas par metier
- //il faut une matrice pour chaques pas de temps qui stocke les rejets
- //par metier, par metapop et par classes d'age (comme pour les captures)
- //////
- log.info("deb de affecterCaptureREJETTailleMin");
+ // pb : ne se fait pas par metier
+ // il faut une matrice pour chaques pas de temps qui stocke les
+ // rejets par metier, par metapop et par classes d'age (comme pour
+ // les captures)
+ //log.info("deb de affecterCaptureREJETTailleMin");
PopulationMonitor popMon = context.getPopulationMonitor();
- SiMatrix siMatrix = SiMatrix.getSiMatrix(context);
- List<Population> pops = siMatrix.getPopulations(step);
- for (Population pop : pops) {
- if (pop.getSpecies().equals(param_species)) {
- if (popMon.getDiscard(step, pop) == null) {
- MatrixND discard = popMon.getCatch(pop).copy();
- MatrixND eff = popMon.getN(pop);
+ int groupDim = 2;
+ int zoneDim = 3;
- for (MatrixIterator i = discard.iterator(); i.next();) {
- Object[] coordonnees = i.getSemanticsCoordinates();
- PopulationGroup group =
- (PopulationGroup) coordonnees[2];
- if (group.getLength() >= param_TailleMin) {
- i.setValue(0);
- } else if (param_propSurvie > 0) {
- eff.setValue(coordonnees[2], coordonnees[3],
- eff.getValue(coordonnees[2],
- coordonnees[3]) + i.getValue() *
- param_propSurvie);
- }
- }
- discard.setName(
- ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP);
- popMon.addDiscard(step, pop, discard);
+ for (Population pop : param_species.getPopulation()) {
+ MatrixND discard = popMon.getCatch(pop).copy();
+ discard.setName(ResultName.MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP);
+
+ MatrixND eff = popMon.getN(pop);
+
+ // collect les tailles des groupes pour eviter de multiples appels a la methode
+ // getLength dans la boucle
+ List<PopulationGroup> groups = (List<PopulationGroup>)discard.getSemantic(2);
+ double[] length = new double[groups.size()];
+ int cpt = 0;
+ for (PopulationGroup group : groups) {
+ length[cpt++] = group.getLength();
+ }
+
+ // on iter que sur les valeurs != 0, car si deja zero, ca ne
+ // sert a rien de le mettre a 0
+ for (MatrixIterator i = discard.iteratorNotZero(); i.next();) {
+ int[] pos = i.getCoordinates();
+ int groupIndex = pos[groupDim];
+ if (length[groupIndex] >= param_TailleMin) {
+ i.setValue(0);
+ } else if (param_propSurvie > 0) {
+ Object[] coordonnees = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) coordonnees[groupDim];
+ Zone zone = (Zone)coordonnees[zoneDim];
+ eff.setValue(group, zone,
+ eff.getValue(group, zone)
+ + i.getValue() * param_propSurvie);
}
}
+ popMon.addDiscard(step, pop, discard);
}
- log.info("fin de affecterCaptureRejetTailleMin");
+ //log.info("fin de affecterCaptureRejetTailleMin");
- //on a affecte une fois cette meta pop au rejet il ne faut pas le refaire
+ // on a affecte une fois cette meta pop au rejet il ne faut pas le
+ // refaire pour ce pas de temps
+ affectation = false;
}
}
}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/rules/TotalClosure.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/rules/TotalClosure.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/rules/TotalClosure.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package rules;
-import static org.nuiton.i18n.I18n._;
-
import java.util.List;
import org.apache.commons.logging.Log;
@@ -57,8 +55,8 @@
public Month param_beginMonth = Month.JANUARY;
public Month param_endMonth = Month.JANUARY;
- public String[] necessaryResult = {
- ResultName.MATRIX_NO_ACTIVITY
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_NO_ACTIVITY
};
@Override
@@ -68,7 +66,7 @@
@Override
public String getDescription() throws Exception {
- return _("Total closure of the fishery");
+ return "Total closure of the fishery";
}
/**
@@ -77,6 +75,7 @@
*/
@Override
public void init(SimulationContext context) throws Exception {
+
}
/**
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/scripts/GravityModel.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/scripts/GravityModel.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/scripts/GravityModel.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
+ * Copyright (C) 2006 - 2014 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -22,7 +22,7 @@
package scripts;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.n;
import java.util.Collection;
import java.util.List;
@@ -47,22 +47,22 @@
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.types.Month;
import fr.ifremer.isisfish.types.TimeUnit;
+import org.nuiton.math.matrix.MatrixIterator;
/**
- * GravityModel.java
- *
- * Created: 4 sept. 06 15:49:08
- *
+ * Gravity model calcul des resultats à basés sur des resultats provenant
+ * de SiMatrix ou des resultat précédement calculé disponible via le
+ * result manager.
+ *
+ * Cette classe sert a calculer des résultats economique (prix, resultat
+ * servant a optimiser des cout pour les pécheurs...).
+ *
* @author poussin
- * @version $Revision: 1.9 $
- *
- * Last update: $Date: 2007-03-01 17:16:12 $
- * by : $Author: bpoussin $
*/
public class GravityModel {
/** to use log facility, just put in your code: log.info("..."); */
- static private Log log = LogFactory.getLog(GravityModel.class);
+ final static private Log log = LogFactory.getLog(GravityModel.class);
protected SimulationContext context = null;
protected TopiaContext db = null;
@@ -112,7 +112,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_FISHING_TIME_PER_MONTH_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -157,7 +157,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_FUEL_COSTS_OF_TRAVEL_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -209,7 +209,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_COSTS_OF_FISHING_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -263,7 +263,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_FUEL_COSTS_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -307,15 +307,29 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_REPAIR_AND_MAINTENANCE_GEAR_COSTS_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
+ SetOfVessels sov = str.getSetOfVessels();
metiers = siMatrix.getMetiers(str, step);
for (int m = 0; m < metiers.size(); m++) {
Metier metier = metiers.get(m);
- double value = repairAndMaintenanceGearCostsPerVessel(str,
- metier, step);
+
+ double fishingTime = 0;
+ double repair = 0;
+
+ EffortDescription effort = sov.getPossibleMetiers(metier);
+ if (effort != null) {
+ repair = effort.getRepairAndMaintenanceGearCost();
+ }
+ if (repair != 0 ) {
+ fishingTimePerMonthPerVessel(str, metier, step);
+ }
+
+ // FIXME verifier qu'il faut bien retourner 0, si pas d'effort
+ double value = fishingTime * repair / TimeUnit.HOUR_PER_DAY;
+
result.setValue(str, metier, value);
}
}
@@ -341,21 +355,21 @@
* @param step
* @return
*/
- private double repairAndMaintenanceGearCostsPerVessel(Strategy str,
- Metier metier, TimeStep step) {
- double fishingTime = fishingTimePerMonthPerVessel(str, metier, step);
+// private double repairAndMaintenanceGearCostsPerVessel(Strategy str,
+// Metier metier, TimeStep step) {
+// double fishingTime = fishingTimePerMonthPerVessel(str, metier, step);
+//
+// EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+// metier);
+//
+// double repair = 0;
+// if (effort != null) {
+// repair = effort.getRepairAndMaintenanceGearCost();
+// }
+// // FIXME verifier qu'il faut bien retourner 0, si pas d'effort
+// return fishingTime * repair / TimeUnit.HOUR_PER_DAY;
+// }
- EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
- metier);
-
- double repair = 0;
- if (effort != null) {
- repair = effort.getRepairAndMaintenanceGearCost();
- }
- // FIXME verifier qu'il faut bien retourner 0, si pas d'effort
- return fishingTime * repair / TimeUnit.HOUR_PER_DAY;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixOtherRunningCostsPerVessel
//////////////////////////////////////////////////////////////////////
@@ -368,7 +382,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_OTHER_RUNNING_COSTS_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -421,7 +435,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_SHARED_NOT_FIXED_COSTS_PER_VESSEL,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -470,61 +484,117 @@
.create(
ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET,
new List[] { strategies, metiers, pops },
- new String[] { n_("Strategies"), n_("Metiers"),
- n_("Populations") });
+ new String[] { n("Strategies"), n("Metiers"),
+ n("Populations") });
+ // indice dans les matrices catch et discards
+ int strDim = 0;
+ int metierDim = 1;
+ int groupDim = 2;
+ int zoneDim = 3;
+
for (int p = 0; p < pops.size(); p++) {
Population pop = pops.get(p);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = grossValueOfLandingsPerSpeciesPerStrategyMet(
- str, metier, pop, step);
- result.setValue(str, metier, pop, value);
+ List<PopulationGroup> groups = pop.getPopulationGroup();
+ double[] prices = new double[groups.size()];
+ int cpt=0;
+ for (PopulationGroup group : groups) {
+ prices[cpt++] = group.getPrice();
+ }
+
+ MatrixND matCatch = getResult_MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP(step, pop);
+ MatrixND matDiscards = getResult_MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP(step, pop);
+
+ if (matCatch != null) {
+ for (MatrixIterator i=matCatch.iteratorNotZero(); i.next();){
+ int[] pos = i.getCoordinates();
+ double price = prices[pos[groupDim]];
+ if (price != 0) {
+ double value = result.getValue(pos[strDim], pos[metierDim], p) + price * i.getValue();
+ result.setValue(pos[strDim], pos[metierDim], p, value);
+ }
}
}
+ if (matDiscards != null) {
+ for (MatrixIterator i=matDiscards.iteratorNotZero(); i.next();){
+ int[] pos = i.getCoordinates();
+ double price = prices[pos[groupDim]];
+ if (price != 0) {
+ double value = result.getValue(pos[strDim], pos[metierDim], p) - price * i.getValue();
+ result.setValue(pos[strDim], pos[metierDim], p, value);
+ }
+ }
+ }
}
return result;
- }
- /**
- * implante suivant document ModifTable3PourBP25-07-2006.doc
- * GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month]=sum over
- * classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet
- * [str,met,pop,cl,month] ?DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
- * nth] GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month] =
- * sum over classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet
- * [str,met,pop,cl,month] -DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
- * nth])]
- *
- * @param str
- * @param metier
- * @param pop
- * @param step
- * @return
- */
- private double grossValueOfLandingsPerSpeciesPerStrategyMet(Strategy str,
- Metier metier, Population pop, TimeStep step) {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- double result = 0;
- for (PopulationGroup group : groups) {
- double price = group.getPrice();
- Collection<Zone> zones = pop.getPopulationZone();
- for (Zone zone : zones) {
- double catchWeight = getCatchWeightPerStrMetPerZonePop(str,
- metier, group, zone, step);
- double discardsWeight = getDiscardsWeightPerStrMet(str, metier,
- group, zone, step);
- // FIXME demander/verifier que ce le bon calcule
- result += price * (catchWeight - discardsWeight);
- }
- }
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+// List<Population> pops = siMatrix.getPopulations(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET,
+// new List[] { strategies, metiers, pops },
+// new String[] { n("Strategies"), n("Metiers"),
+// n("Populations") });
+//
+// for (int p = 0; p < pops.size(); p++) {
+// Population pop = pops.get(p);
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = grossValueOfLandingsPerSpeciesPerStrategyMet(
+// str, metier, pop, step);
+// result.setValue(str, metier, pop, value);
+// }
+// }
+// }
+//
+// return result;
}
+// /**
+// * implante suivant document ModifTable3PourBP25-07-2006.doc
+// * GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month]=sum over
+// * classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet
+// * [str,met,pop,cl,month] ?DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
+// * nth] GrossValueOfLandingsPerSpeciesPerStrategyMet[str,met,pop,month] =
+// * sum over classes_cl of [PricePerKg(pop,cl, t)* (CatchWeightPerStrategyMet
+// * [str,met,pop,cl,month] -DiscardsWeightPerStrategyMet [str,met,pop,cl,mo
+// * nth])]
+// *
+// * @param str
+// * @param metier
+// * @param pop
+// * @param step
+// * @return
+// */
+// private double grossValueOfLandingsPerSpeciesPerStrategyMet(Strategy str,
+// Metier metier, Population pop, TimeStep step) {
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// double result = 0;
+// for (PopulationGroup group : groups) {
+// double price = group.getPrice();
+// if (price != 0) {
+// Collection<Zone> zones = pop.getPopulationZone();
+// for (Zone zone : zones) {
+// double catchWeight = getCatchWeightPerStrMetPerZonePop(str,
+// metier, group, zone, step);
+// double discardsWeight = getDiscardsWeightPerStrMet(str, metier,
+// group, zone, step);
+// // FIXME demander/verifier que ce le bon calcule
+// result += price * (catchWeight - discardsWeight);
+// }
+// }
+// }
+// return result;
+// }
+
/**
* @param str
* @param metier
@@ -535,8 +605,7 @@
*/
private double getCatchWeightPerStrMetPerZonePop(Strategy str,
Metier metier, PopulationGroup group, Zone zone, TimeStep step) {
- MatrixND mat = resultManager.getMatrix(step, group.getPopulation(),
- ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ MatrixND mat = getResult_MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP(step, group.getPopulation());
double result = 0;
if (mat != null) {
result = mat.getValue(str, metier, group, zone);
@@ -544,6 +613,12 @@
return result;
}
+ private MatrixND getResult_MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP(TimeStep step, Population pop) {
+ MatrixND mat = resultManager.getMatrix(step, pop,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ return mat;
+ }
+
/**
* @param str
* @param metier
@@ -554,8 +629,7 @@
*/
private double getDiscardsWeightPerStrMet(Strategy str, Metier metier,
PopulationGroup group, Zone zone, TimeStep step) {
- MatrixND mat = resultManager.getMatrix(step, group.getPopulation(),
- ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
+ MatrixND mat = getResult_MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP(step, group.getPopulation());
double result = 0;
if (mat != null) {
result = mat.getValue(str, metier, group, zone);
@@ -563,81 +637,117 @@
return result;
}
+ private MatrixND getResult_MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP(TimeStep step, Population pop) {
+ MatrixND mat = resultManager.getMatrix(step, pop,
+ ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
+ return mat;
+ }
+
//////////////////////////////////////////////////////////////////////
// matrixGrossValueOfLandingsPerStrategyMet
//////////////////////////////////////////////////////////////////////
public MatrixND matrixGrossValueOfLandingsPerStrategyMet(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
-
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = grossValueOfLandingsPerStrategyMet(str, metier,
- step);
- result.setValue(str, metier, value);
- }
- }
-
+ MatrixND matPerSpecies = matrixGrossValueOfLandingsPerSpeciesPerStrategyMet(step);
+ // sum over pop
+ MatrixND result = matPerSpecies.sumOverDim(2).reduceDims(2);
+ result.setName(ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET);
return result;
- }
- /**
- * @param str
- * @param metier
- * @param step
- * @return
- * @throws TopiaException
- */
- private double grossValueOfLandingsPerStrategyMet(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- List<Population> pops = siMatrix.getPopulations(step);
- double result = 0;
- for (int i = 0; i < pops.size(); i++) {
- Population pop = (Population) pops.get(i);
- result += grossValueOfLandingsPerSpeciesPerStrategyMet(str, metier,
- pop, step);
- }
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = grossValueOfLandingsPerStrategyMet(str, metier,
+// step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
+// /**
+// * @param str
+// * @param metier
+// * @param step
+// * @return
+// * @throws TopiaException
+// */
+// private double grossValueOfLandingsPerStrategyMet(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// List<Population> pops = siMatrix.getPopulations(step);
+// double result = 0;
+// for (int i = 0; i < pops.size(); i++) {
+// Population pop = (Population) pops.get(i);
+// result += grossValueOfLandingsPerSpeciesPerStrategyMet(str, metier,
+// pop, step);
+// }
+// return result;
+// }
+
//////////////////////////////////////////////////////////////////////
// matrixGrossValueOfLandingsPerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixGrossValueOfLandingsPerStrategyMetPerVessel(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
+ MatrixND matGrossValue = matrixGrossValueOfLandingsPerStrategyMet(step);
+ MatrixND result = matGrossValue.copy();
+ result.setName(ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ for (MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = grossValueOfLandingsPerStrategyMetPerVessel(str,
- metier, step);
- result.setValue(str, metier, value);
- }
+ // FIXME verifier que c bien cette donn�e qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
+ double proportionSetOfVessels = str.getProportionSetOfVessels();
+ double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+
+ double grossValueOfLandingsOtherSpeciesPerStrategyMet =
+ grossValueOfLandingsOtherSpeciesPerStrategyMet(str, metier, step);
+
+ double value = (i.getValue() + grossValueOfLandingsOtherSpeciesPerStrategyMet)
+ / (proportionSetOfVessels * numberOfVessels);
+
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = grossValueOfLandingsPerStrategyMetPerVessel(str,
+// metier, step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -651,47 +761,74 @@
* @return
* @throws TopiaException
*/
- private double grossValueOfLandingsPerStrategyMetPerVessel(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- double grossValueOfLandingsPerStrategyMet = grossValueOfLandingsPerStrategyMet(
- str, metier, step);
- // FIXME verifier que c bien cette donn�e qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
- double proportionSetOfVessels = str.getProportionSetOfVessels();
- double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+// private double grossValueOfLandingsPerStrategyMetPerVessel(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// double grossValueOfLandingsPerStrategyMet = grossValueOfLandingsPerStrategyMet(
+// str, metier, step);
+// // FIXME verifier que c bien cette donn�e qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
+// double proportionSetOfVessels = str.getProportionSetOfVessels();
+// double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+//
+// double grossValueOfLandingsOtherSpeciesPerStrategyMet = grossValueOfLandingsOtherSpeciesPerStrategyMet(
+// str, metier, step);
+//
+// return (grossValueOfLandingsPerStrategyMet + grossValueOfLandingsOtherSpeciesPerStrategyMet)
+// / (proportionSetOfVessels * numberOfVessels);
+// }
- double grossValueOfLandingsOtherSpeciesPerStrategyMet = grossValueOfLandingsOtherSpeciesPerStrategyMet(
- str, metier, step);
-
- return (grossValueOfLandingsPerStrategyMet + grossValueOfLandingsOtherSpeciesPerStrategyMet)
- / (proportionSetOfVessels * numberOfVessels);
- }
-
//////////////////////////////////////////////////////////////////////
// matrixNetValueOfLandingsPerStrategyMet
//////////////////////////////////////////////////////////////////////
public MatrixND matrixNetValueOfLandingsPerStrategyMet(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ MatrixND result = matrixGrossValueOfLandingsPerStrategyMet(step).copy();
+ result.setName(ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET);
+
+ for (MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = netValueOfLandingsPerStrategyMet(str, metier,
- step);
- result.setValue(str, metier, value);
+ EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+ metier);
+ double landingCost = 1;
+ // FIXME demander si le metier n'a pas d'effort s'il faut que landingCost soit bien a 1
+ if (effort != null) {
+ landingCost -= effort.getLandingCosts();
}
+
+ double grossValueOfLandingsOtherSpeciesPerStrategyMet =
+ grossValueOfLandingsOtherSpeciesPerStrategyMet(str, metier, step);
+
+ double value = (i.getValue() + grossValueOfLandingsOtherSpeciesPerStrategyMet)
+ * landingCost;
+ i.setValue(value);
}
+ return result;
- return result;
+
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = netValueOfLandingsPerStrategyMet(str, metier,
+// step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -699,33 +836,33 @@
* NetValueOfLandingsPerStrategyMet[str,met,month] =
* GrossValueOfLandingsPerStrategyMet[str,met,month]
* (1-LandingCostRate[str,met])
- *
+ *
* @param str
* @param metier
* @param step
* @return
* @throws TopiaException
*/
- private double netValueOfLandingsPerStrategyMet(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- double grossValue = grossValueOfLandingsPerStrategyMet(str, metier,
- step);
- EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
- metier);
- double landingCost = 1;
- // FIXME demander si le metier n'a pas d'effort s'il faut que landingCost soit bien a 1
- if (effort != null) {
- landingCost -= effort.getLandingCosts();
- }
+// private double netValueOfLandingsPerStrategyMet(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// double grossValue = grossValueOfLandingsPerStrategyMet(str, metier,
+// step);
+// EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+// metier);
+// double landingCost = 1;
+// // FIXME demander si le metier n'a pas d'effort s'il faut que landingCost soit bien a 1
+// if (effort != null) {
+// landingCost -= effort.getLandingCosts();
+// }
+//
+// double grossValueOfLandingsOtherSpeciesPerStrategyMet =
+// grossValueOfLandingsOtherSpeciesPerStrategyMet(str, metier, step);
+//
+// double result = (grossValue + grossValueOfLandingsOtherSpeciesPerStrategyMet)
+// * landingCost;
+// return result;
+// }
- double grossValueOfLandingsOtherSpeciesPerStrategyMet = grossValueOfLandingsOtherSpeciesPerStrategyMet(
- str, metier, step);
-
- double result = (grossValue + grossValueOfLandingsOtherSpeciesPerStrategyMet)
- * landingCost;
- return result;
- }
-
private double grossValueOfLandingsOtherSpeciesPerStrategyMet(Strategy str,
Metier metier, TimeStep step) throws TopiaException {
// FIXME evaluer l'equation dans suivant le doc des equations
@@ -738,28 +875,51 @@
public MatrixND matrixNetValueOfLandingsPerStrategyMetPerVessel(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
+ MatrixND result = matrixNetValueOfLandingsPerStrategyMet(step).copy();
+ result.setName(ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ for(MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = netValueOfLandingsPerStrategyMetPerVessel(str,
- metier, step);
- result.setValue(str, metier, value);
+ // FIXME verifier que c bien cette donnée qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
+ double proportionSetOfVessels = str.getProportionSetOfVessels();
+ double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+
+ double div = proportionSetOfVessels * numberOfVessels;
+
+ if (div != 0) {
+ double value = i.getValue() / div;
+
+ i.setValue(value);
}
}
return result;
+
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = netValueOfLandingsPerStrategyMetPerVessel(str,
+// metier, step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -774,46 +934,65 @@
* @return
* @throws TopiaException
*/
- private double netValueOfLandingsPerStrategyMetPerVessel(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- double netValueOfLandingsPerStrategyMet = netValueOfLandingsPerStrategyMet(
- str, metier, step);
- // FIXME verifier que c bien cette donnée qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
- double proportionSetOfVessels = str.getProportionSetOfVessels();
- double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+// private double netValueOfLandingsPerStrategyMetPerVessel(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// double netValueOfLandingsPerStrategyMet = netValueOfLandingsPerStrategyMet(
+// str, metier, step);
+// // FIXME verifier que c bien cette donnée qu'il faut utiliser dans le doc: PropNbVessels(str, sov)
+// double proportionSetOfVessels = str.getProportionSetOfVessels();
+// double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+//
+// return netValueOfLandingsPerStrategyMet
+// / (proportionSetOfVessels * numberOfVessels);
+// }
- return netValueOfLandingsPerStrategyMet
- / (proportionSetOfVessels * numberOfVessels);
- }
-
//////////////////////////////////////////////////////////////////////
// matrixNetRenevueToSharePerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixNetRenevueToSharePerStrategyMetPerVessel(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ MatrixND result = matrixNetValueOfLandingsPerStrategyMetPerVessel(step).copy();
+ result.setName(ResultName.MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = netRenevueToSharePerStrategyMetPerVessel(str,
- metier, step);
- result.setValue(str, metier, value);
- }
+ for(MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
+
+ double sharedNotFixedCostsPerVessel = sharedNotFixedCostsPerVessel(str,
+ metier, step);
+ double propStr = str.getStrategyMonthInfo(step.getMonth())
+ .getProportionMetier(metier);
+
+ double value = i.getValue() - sharedNotFixedCostsPerVessel * propStr;
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = netRenevueToSharePerStrategyMetPerVessel(str,
+// metier, step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -829,46 +1008,68 @@
* @return
* @throws TopiaException
*/
- private double netRenevueToSharePerStrategyMetPerVessel(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- double netRenevueToSharePerStrategyMetPerVessel = netValueOfLandingsPerStrategyMetPerVessel(
- str, metier, step);
- double sharedNotFixedCostsPerVessel = sharedNotFixedCostsPerVessel(str,
- metier, step);
- double propStr = str.getStrategyMonthInfo(step.getMonth())
- .getProportionMetier(metier);
+// private double netRenevueToSharePerStrategyMetPerVessel(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// double netRenevueToSharePerStrategyMetPerVessel = netValueOfLandingsPerStrategyMetPerVessel(
+// str, metier, step);
+// double sharedNotFixedCostsPerVessel = sharedNotFixedCostsPerVessel(str,
+// metier, step);
+// double propStr = str.getStrategyMonthInfo(step.getMonth())
+// .getProportionMetier(metier);
+//
+// double result = netRenevueToSharePerStrategyMetPerVessel
+// - sharedNotFixedCostsPerVessel * propStr;
+// return result;
+// }
- double result = netRenevueToSharePerStrategyMetPerVessel
- - sharedNotFixedCostsPerVessel * propStr;
- return result;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixCrewSharePerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixCrewSharePerStrategyMetPerVessel(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ MatrixND result = matrixNetValueOfLandingsPerStrategyMetPerVessel(step).copy();
+ result.setName(ResultName.MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = crewSharePerStrategyMetPerVessel(str, metier,
- step);
- result.setValue(str, metier, value);
+ for(MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
+
+ EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+ metier);
+
+ double crewShareRate = 0;
+ if (effort != null) {
+ crewShareRate = effort.getCrewShareRate();
}
+ // FIXME verifier qu'il faut bien retourner 0, si pas d'effort
+ double value = i.getValue() * crewShareRate;
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = crewSharePerStrategyMetPerVessel(str, metier,
+// step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -882,50 +1083,79 @@
* @return
* @throws TopiaException
*/
- private double crewSharePerStrategyMetPerVessel(Strategy str,
- Metier metier, TimeStep step) throws TopiaException {
- double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
- str, metier, step);
+// private double crewSharePerStrategyMetPerVessel(Strategy str,
+// Metier metier, TimeStep step) throws TopiaException {
+// double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
+// str, metier, step);
+//
+// EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
+// metier);
+//
+// double crewShareRate = 0;
+// if (effort != null) {
+// crewShareRate = effort.getCrewShareRate();
+// }
+// // FIXME verifier qu'il faut bien retourner 0, si pas d'effort
+// return netRenevueToShare * crewShareRate;
+// }
- EffortDescription effort = str.getSetOfVessels().getPossibleMetiers(
- metier);
-
- double crewShareRate = 0;
- if (effort != null) {
- crewShareRate = effort.getCrewShareRate();
- }
- // FIXME verifier qu'il faut bien retourner 0, si pas d'effort
- return netRenevueToShare * crewShareRate;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel(
TimeStep step) throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ MatrixND matRepair = matrixRepairAndMaintenanceGearCostsPerVessel(step);
+ MatrixND matCrew = matrixCrewSharePerStrategyMetPerVessel(step);
+ MatrixND matRevenue = matrixNetRenevueToSharePerStrategyMetPerVessel(step);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = ownerMarginOverVariableCostsPerStrategyMetPerVessel(
- str, metier, step);
- result.setValue(str, metier, value);
+ MatrixND result = matRevenue.copy();
+ result.setName(ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL);
+
+ for(MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
+
+ double propStr = str.getStrategyMonthInfo(step.getMonth())
+ .getProportionMetier(metier);
+
+ double netRenevueToShare = i.getValue();
+ double crewShare = matCrew.getValue(str, metier);
+ double repair = 0;
+ if (propStr != 0) {
+ repair = matRepair.getValue(str, metier);
}
+
+ double value = netRenevueToShare - crewShare - repair * propStr;
+ i.setValue(value);
}
return result;
+
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = ownerMarginOverVariableCostsPerStrategyMetPerVessel(
+// str, metier, step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -942,47 +1172,71 @@
* @return
* @throws TopiaException
*/
- private double ownerMarginOverVariableCostsPerStrategyMetPerVessel(
- Strategy str, Metier metier, TimeStep step) throws TopiaException {
- double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
- str, metier, step);
- double crewShare = crewSharePerStrategyMetPerVessel(str, metier, step);
- double repair = repairAndMaintenanceGearCostsPerVessel(str, metier,
- step);
- double propStr = str.getStrategyMonthInfo(step.getMonth())
- .getProportionMetier(metier);
+// private double ownerMarginOverVariableCostsPerStrategyMetPerVessel(
+// Strategy str, Metier metier, TimeStep step) throws TopiaException {
+// double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
+// str, metier, step);
+// double crewShare = crewSharePerStrategyMetPerVessel(str, metier, step);
+// double repair = repairAndMaintenanceGearCostsPerVessel(str, metier,
+// step);
+// double propStr = str.getStrategyMonthInfo(step.getMonth())
+// .getProportionMetier(metier);
+//
+// return netRenevueToShare - crewShare - repair * propStr;
+// }
- return netRenevueToShare - crewShare - repair * propStr;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel(
TimeStep step) throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- List<Metier> metiers = siMatrix.getMetiers(step);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
- new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ MatrixND matRepair = matrixRepairAndMaintenanceGearCostsPerVessel(step);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = siMatrix.getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- double value = vesselMarginOverVariableCostsPerStrategyMetPerVessel(
- str, metier, step);
- result.setValue(str, metier, value);
+ MatrixND result = matrixNetValueOfLandingsPerStrategyMetPerVessel(step).copy();
+ result.setName(ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL);
+
+ for(MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+ Metier metier = (Metier)sems[1];
+
+ double repair = 0;
+ double propStr = str.getStrategyMonthInfo(step.getMonth())
+ .getProportionMetier(metier);
+ if (propStr != 0) {
+ // optimisation repair ne sert pas si propStr == 0, donc on va pas le chercher
+ repair = matRepair.getValue(str, metier);
}
+
+ double value = i.getValue() - repair * propStr;
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+// List<Metier> metiers = siMatrix.getMetiers(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL,
+// new List[] { strategies, metiers },
+// new String[] { n("Strategies"), n("Metiers") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = siMatrix.getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// double value = vesselMarginOverVariableCostsPerStrategyMetPerVessel(
+// str, metier, step);
+// result.setValue(str, metier, value);
+// }
+// }
+//
+// return result;
}
/**
@@ -998,41 +1252,67 @@
* @return
* @throws TopiaException
*/
- private double vesselMarginOverVariableCostsPerStrategyMetPerVessel(
- Strategy str, Metier metier, TimeStep step) throws TopiaException {
- double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
- str, metier, step);
- double repair = repairAndMaintenanceGearCostsPerVessel(str, metier,
- step);
- double propStr = str.getStrategyMonthInfo(step.getMonth())
- .getProportionMetier(metier);
+// private double vesselMarginOverVariableCostsPerStrategyMetPerVessel(
+// Strategy str, Metier metier, TimeStep step) throws TopiaException {
+// double netRenevueToShare = netRenevueToSharePerStrategyMetPerVessel(
+// str, metier, step);
+// double repair = repairAndMaintenanceGearCostsPerVessel(str, metier,
+// step);
+// double propStr = str.getStrategyMonthInfo(step.getMonth())
+// .getProportionMetier(metier);
+//
+// return netRenevueToShare - repair * propStr;
+// }
- return netRenevueToShare - repair * propStr;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixOwnerMarginOverVariableCostsPerStrategyPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixOwnerMarginOverVariableCostsPerStrategyPerVessel(
TimeStep step) throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
+ MatrixND matOwner = matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel(step);
MatrixND result = MatrixFactory
.getInstance()
.create(
ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
- new List[] { strategies },
- new String[] { n_("Strategies") });
+ new List[] { matOwner.getSemantic(0) },
+ new String[] { n("Strategies") });
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- double value = ownerMarginOverVariableCostsPerStrategyPerVessel(
- str, step);
- result.setValue(s, value);
+ for(MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+
+ SetOfVessels sov = str.getSetOfVessels();
+ Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+
+ double value = 0;
+
+ for (EffortDescription effort : efforts) {
+ Metier metier = effort.getPossibleMetiers();
+ value += matOwner.getValue(str, metier);
+ }
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
+// new List[] { strategies },
+// new String[] { n("Strategies") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// double value = ownerMarginOverVariableCostsPerStrategyPerVessel(
+// str, step);
+// result.setValue(s, value);
+// }
+//
+// return result;
}
/**
@@ -1046,43 +1326,58 @@
* @return
* @throws TopiaException
*/
- private double ownerMarginOverVariableCostsPerStrategyPerVessel(
- Strategy str, TimeStep step) throws TopiaException {
- SetOfVessels sov = str.getSetOfVessels();
- Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+// private double ownerMarginOverVariableCostsPerStrategyPerVessel(
+// Strategy str, TimeStep step) throws TopiaException {
+// SetOfVessels sov = str.getSetOfVessels();
+// Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+//
+// float result = 0;
+//
+// for (EffortDescription effort : efforts) {
+// Metier metier = effort.getPossibleMetiers();
+// result += ownerMarginOverVariableCostsPerStrategyMetPerVessel(str,
+// metier, step);
+// }
+// return result;
+// }
- float result = 0;
-
- for (EffortDescription effort : efforts) {
- Metier metier = effort.getPossibleMetiers();
- result += ownerMarginOverVariableCostsPerStrategyMetPerVessel(str,
- metier, step);
- }
- return result;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixOwnerMarginOverVariableCostsPerStrategy
//////////////////////////////////////////////////////////////////////
public MatrixND matrixOwnerMarginOverVariableCostsPerStrategy(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
+ MatrixND result = matrixOwnerMarginOverVariableCostsPerStrategyPerVessel(step).copy();
+ result.setName(ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
- new List[] { strategies },
- new String[] { n_("Strategies") });
+ for(MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- double value = ownerMarginOverVariableCostsPerStrategy(str, step);
- result.setValue(s, value);
+ double proportionSetOfVessels = str.getProportionSetOfVessels();
+ double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+
+ double value = i.getValue() * (proportionSetOfVessels * numberOfVessels);
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
+// new List[] { strategies },
+// new String[] { n("Strategies") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// double value = ownerMarginOverVariableCostsPerStrategy(str, step);
+// result.setValue(s, value);
+// }
+//
+// return result;
}
/**
@@ -1096,40 +1391,69 @@
* @return
* @throws TopiaException
*/
- private double ownerMarginOverVariableCostsPerStrategy(Strategy str,
- TimeStep step) throws TopiaException {
- double ownerMarginOverVariableCostsPerStrategyPerVessel = ownerMarginOverVariableCostsPerStrategyPerVessel(
- str, step);
- double proportionSetOfVessels = str.getProportionSetOfVessels();
- double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+// private double ownerMarginOverVariableCostsPerStrategy(Strategy str,
+// TimeStep step) throws TopiaException {
+// double ownerMarginOverVariableCostsPerStrategyPerVessel = ownerMarginOverVariableCostsPerStrategyPerVessel(
+// str, step);
+// double proportionSetOfVessels = str.getProportionSetOfVessels();
+// double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+//
+// return ownerMarginOverVariableCostsPerStrategyPerVessel
+// * (proportionSetOfVessels * numberOfVessels);
+// }
- return ownerMarginOverVariableCostsPerStrategyPerVessel
- * (proportionSetOfVessels * numberOfVessels);
- }
-
//////////////////////////////////////////////////////////////////////
// matrixVesselMarginOverVariableCostsPerStrategyPerVessel
//////////////////////////////////////////////////////////////////////
public MatrixND matrixVesselMarginOverVariableCostsPerStrategyPerVessel(
TimeStep step) throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
+ MatrixND matPerMet =
+ matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel(step);
MatrixND result = MatrixFactory
.getInstance()
.create(
ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
- new List[] { strategies },
- new String[] { n_("Strategies") });
+ new List[] { matPerMet.getSemantic(0) },
+ new String[] { n("Strategies") });
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- double value = vesselMarginOverVariableCostsPerStrategyPerVessel(
- str, step);
- result.setValue(s, value);
+ for(MatrixIterator i=result.iterator(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+
+ SetOfVessels sov = str.getSetOfVessels();
+ Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+
+ double value = 0;
+
+ for (EffortDescription effort : efforts) {
+ Metier metier = effort.getPossibleMetiers();
+ value += matPerMet.getValue(str, metier);
+ }
+
+ i.setValue(value);
}
+ return result;
- return result;
+
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL,
+// new List[] { strategies },
+// new String[] { n("Strategies") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// double value = vesselMarginOverVariableCostsPerStrategyPerVessel(
+// str, step);
+// result.setValue(s, value);
+// }
+//
+// return result;
}
/**
@@ -1143,43 +1467,59 @@
* @return
* @throws TopiaException
*/
- private double vesselMarginOverVariableCostsPerStrategyPerVessel(
- Strategy str, TimeStep step) throws TopiaException {
- SetOfVessels sov = str.getSetOfVessels();
- Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+// private double vesselMarginOverVariableCostsPerStrategyPerVessel(
+// Strategy str, TimeStep step) throws TopiaException {
+// SetOfVessels sov = str.getSetOfVessels();
+// Collection<EffortDescription> efforts = sov.getPossibleMetiers();
+//
+// float result = 0;
+//
+// for (EffortDescription effort : efforts) {
+// Metier metier = effort.getPossibleMetiers();
+// result += vesselMarginOverVariableCostsPerStrategyMetPerVessel(str,
+// metier, step);
+// }
+// return result;
+// }
- float result = 0;
-
- for (EffortDescription effort : efforts) {
- Metier metier = effort.getPossibleMetiers();
- result += vesselMarginOverVariableCostsPerStrategyMetPerVessel(str,
- metier, step);
- }
- return result;
- }
-
//////////////////////////////////////////////////////////////////////
// matrixVesselMarginOverVariableCostsPerStrategy
//////////////////////////////////////////////////////////////////////
public MatrixND matrixVesselMarginOverVariableCostsPerStrategy(TimeStep step)
throws TopiaException {
- List<Strategy> strategies = siMatrix.getStrategies(step);
- MatrixND result = MatrixFactory
- .getInstance()
- .create(
- ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
- new List[] { strategies },
- new String[] { n_("Strategies") });
+ MatrixND result = matrixVesselMarginOverVariableCostsPerStrategyPerVessel(step).copy();
+ result.setName(ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY);
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- double value = vesselMarginOverVariableCostsPerStrategy(str, step);
- result.setValue(s, value);
+ for(MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
+ Strategy str = (Strategy)sems[0];
+
+ double proportionSetOfVessels = str.getProportionSetOfVessels();
+ double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+
+ double value = i.getValue() * (proportionSetOfVessels * numberOfVessels);
+ i.setValue(value);
}
+ return result;
- return result;
+// List<Strategy> strategies = siMatrix.getStrategies(step);
+//
+// MatrixND result = MatrixFactory
+// .getInstance()
+// .create(
+// ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY,
+// new List[] { strategies },
+// new String[] { n("Strategies") });
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// double value = vesselMarginOverVariableCostsPerStrategy(str, step);
+// result.setValue(s, value);
+// }
+//
+// return result;
}
/**
@@ -1193,17 +1533,17 @@
* @return
* @throws TopiaException
*/
- private double vesselMarginOverVariableCostsPerStrategy(Strategy str,
- TimeStep step) throws TopiaException {
- double vesselMarginOverVariableCostsPerStrategyPerVessel = vesselMarginOverVariableCostsPerStrategyPerVessel(
- str, step);
- double proportionSetOfVessels = str.getProportionSetOfVessels();
- double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+// private double vesselMarginOverVariableCostsPerStrategy(Strategy str,
+// TimeStep step) throws TopiaException {
+// double vesselMarginOverVariableCostsPerStrategyPerVessel = vesselMarginOverVariableCostsPerStrategyPerVessel(
+// str, step);
+// double proportionSetOfVessels = str.getProportionSetOfVessels();
+// double numberOfVessels = str.getSetOfVessels().getNumberOfVessels();
+//
+// return vesselMarginOverVariableCostsPerStrategyPerVessel
+// * (proportionSetOfVessels * numberOfVessels);
+// }
- return vesselMarginOverVariableCostsPerStrategyPerVessel
- * (proportionSetOfVessels * numberOfVessels);
- }
-
///////////////////////////////////////////////////////////////////////////
//
// Methode non utilisee directement dans GravityModel, mais dans les rules
@@ -1216,28 +1556,27 @@
double result = 0;
- for (Population pop : pops) {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- Collection<Zone> zones = pop.getPopulationZone();
- for (PopulationGroup group : groups) {
- double price = group.getPrice();
- for (Zone zone : zones) {
- double catchValue = getCatchWeightPerStrMetPerZonePop(str,
- metier, group, zone, step);
- double discards = getDiscardsWeightPerStrMet(str, metier,
- group, zone, step);
- result += price * (catchValue - discards);
+ double effort = getEffortPerStrategyMet(str, metier, step);
+ if (effort != 0) {
+ for (Population pop : pops) {
+ List<PopulationGroup> groups = pop.getPopulationGroup();
+ for (PopulationGroup group : groups) {
+ double price = group.getPrice();
+ if (price != 0) {
+ Collection<Zone> zones = pop.getPopulationZone();
+ for (Zone zone : zones) {
+ double catchValue = getCatchWeightPerStrMetPerZonePop(str,
+ metier, group, zone, step);
+ double discards = getDiscardsWeightPerStrMet(str, metier,
+ group, zone, step);
+ result += price * (catchValue - discards);
+ }
+ }
}
}
+ result = result / effort;
}
- double effort = getEffortPerStrategyMet(str, metier, step);
-
- if (effort == 0) {
- result = 0;
- } else {
- result = result / effort;
- }
// FIXME verifier qu'il faut bien retourner 0, si pas d'effort
return result;
}
Copied: branches/4.3.0-log4j2/src/test/resources/test-database/scripts/MinimisationUtil.java (from rev 4095, trunk/src/test/resources/test-database/scripts/MinimisationUtil.java)
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/scripts/MinimisationUtil.java (rev 0)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/scripts/MinimisationUtil.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -0,0 +1,176 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2012, 2014 Ifremer, CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package scripts;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.util.Nocache;
+
+public class MinimisationUtil {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(MinimisationUtil.class);
+
+ /**
+ * Algo de minimisation de fmin(step, x,C,M,N) sur x.
+ *
+ * en prenant une valeur initiale de x dans [a,b] et une tolerance = tol
+ * Reference de l'algo : http://www1.fpl.fs.fed.us/optimization.html
+ * Algorithme de Brent qui approxime la fonction a minimiser par une
+ * parabole si possible et fait du "golden step" sinon
+ *
+ * @param a
+ * @param b
+ * @param tol tolérance
+ * @param f fonction d'objectif
+ * @return
+ */
+ @Nocache
+ public static double fmin(double a, double b, double tol, ObjectiveFunction f) {
+
+ double c, d, e, eps, xm, p, q, r, tol1, t2, u, v, w, fu, fv, fw, fx, x, tol3;
+
+ c = .5 * (3.0 - Math.sqrt(5.0));
+ d = 0.0;
+ eps = 1.2e-16; // 1.1102e-16 is machine precision
+ tol1 = eps + 1.0;
+ eps = Math.sqrt(eps);
+ v = a + c * (b - a);
+ // log.info("Finit=" + v);
+ w = v;
+ x = v;
+ e = 0.0;
+ fx = 0.0;
+ fu = 0.0;
+
+ fx = f.compute(x);
+ // log.info("fx= " + fx);
+
+ fv = fx;
+ fw = fx;
+ tol3 = tol / 3.0;
+ xm = .5 * (a + b);
+ tol1 = eps * Math.abs(x) + tol3;
+ t2 = 2.0 * tol1;
+
+ while (Math.abs(x - xm) > (t2 - .5 * (b - a))) { // main loop;
+ // ///// De là...
+ p = q = r = 0.0;
+ if (Math.abs(e) > tol1) { // fit the parabola;
+ r = (x - w) * (fx - fv);
+ q = (x - v) * (fx - fw);
+ p = (x - v) * q - (x - w) * r;
+ q = 2.0 * (q - r);
+ if (q > 0.0) {
+ p = -p;
+ } else {
+ q = -q;
+ }
+ r = e;
+ e = d;
+ }
+ if ((Math.abs(p) < Math.abs(.5 * q * r)) && (p > q * (a - x))
+ && (p < q * (b - x))) { // parabolic interpolation step;
+ d = p / q;
+ u = x + d;
+ if (((u - a) < t2) || ((b - u) < t2)) { // f must not be
+ // evaluated too close
+ // to a or b;
+ d = tol1;
+ if (x >= xm)
+ d = -d;
+ }
+ } else { // a golden-section step;
+ if (x < xm) {
+ e = b - x;
+ } else {
+ e = a - x;
+ }
+ d = c * e;
+ }
+ if (Math.abs(d) >= tol1) { // f must not be evaluated too close to x;
+ u = x + d;
+ } else {
+ if (d > 0.0) {
+ u = x + tol1;
+ } else {
+ u = x - tol1;
+ }
+ }
+ // ... à ici : ne sert qu'à calculer un u (selon 2 manières
+ // différentes) afin de comparer fx a fu
+ // --> On peut très bien prendre u à partir d'une autre simu a
+ // la place (?)
+
+ fu = f.compute(u);
+ //log.info("fu= " + fu);
+
+ // Update a, b, v, w, and x
+ if (fx <= fu) {
+ if (u < x) {
+ a = u;
+ } else {
+ b = u;
+ }
+ }
+ if (fu <= fx) {
+ if (u < x) {
+ b = x;
+ } else {
+ a = x;
+ }
+ v = w;
+ fv = fw;
+ w = x;
+ fw = fx;
+ x = u;
+ fx = fu;
+ xm = .5 * (a + b);
+ tol1 = eps * Math.abs(x) + tol3;
+ t2 = 2.0 * tol1;
+ } else {
+ if ((fu <= fw) || (w == x)) {
+ v = w;
+ fv = fw;
+ w = u;
+ fw = fu;
+ xm = .5 * (a + b);
+ tol1 = eps * Math.abs(x) + tol3;
+ t2 = 2.0 * tol1;
+ } else if ((fu > fv) && (v != x) && (v != w)) {
+ xm = .5 * (a + b);
+ tol1 = eps * Math.abs(x) + tol3;
+ t2 = 2.0 * tol1;
+ } else {
+ v = u;
+ fv = fu;
+ xm = .5 * (a + b);
+ tol1 = eps * Math.abs(x) + tol3;
+ t2 = 2.0 * tol1;
+ }
+ }
+ }
+ return x;
+ }
+}
Copied: branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ObjectiveFunction.java (from rev 4095, trunk/src/test/resources/test-database/scripts/ObjectiveFunction.java)
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ObjectiveFunction.java (rev 0)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ObjectiveFunction.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -0,0 +1,44 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2012, 2014 Ifremer, CodeLutin, lgasche
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package scripts;
+
+/**
+ * ObjectiveFunction.java
+ *
+ * Created: 10 aout 2012
+ *
+ * @author lgasche
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public abstract class ObjectiveFunction {
+
+ /**
+ * Compute value depending on objective function implementation
+ * @param x
+ * @return
+ */
+ public abstract double compute(double x);
+}
\ No newline at end of file
Copied: branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ObjectiveFunctionBaranov.java (from rev 4095, trunk/src/test/resources/test-database/scripts/ObjectiveFunctionBaranov.java)
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ObjectiveFunctionBaranov.java (rev 0)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ObjectiveFunctionBaranov.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -0,0 +1,53 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2012, 2014 Ifremer, CodeLutin, lgasche
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package scripts;
+
+import fr.ifremer.isisfish.util.Nocache;
+
+/**
+ * FonctionObjectif_Baranov.java
+ *
+ * Created: 10 aout 2012
+ *
+ * @author lgasche <user.name(a)vcs.hostName>
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+@Nocache
+public class ObjectiveFunctionBaranov extends ObjectiveFunction {
+
+ protected double C, M, N;
+
+ public ObjectiveFunctionBaranov(double C, double M, double N) { // step ??
+ this.C = C;
+ this.M = M;
+ this.N = N;
+ }
+
+ public double compute(double xx) {
+ double ff = Math.pow((C - (xx/(xx+M))*(1-Math.exp(-(xx+M)))*N),2);
+ return ff;
+ }
+}
\ No newline at end of file
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ResultName.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ResultName.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/scripts/ResultName.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin
+ * Copyright (C) 2006 - 2014 Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -22,7 +22,7 @@
package scripts;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.n;
import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605)
@@ -51,7 +51,7 @@
* Dimension 4 : Zone
*/
@Doc(value = "do the doc of Result matrixDiscardsWeightPerStrMet")
- static final public String MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP = n_("matrixDiscardsWeightPerStrMetPerZonePop");
+ static final public String MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP = n("matrixDiscardsWeightPerStrMetPerZonePop");
/**
* Matrix with five dimensions
@@ -62,7 +62,7 @@
* Dimension 5 : Zone
*/
@Doc(value = "do the doc of Result matrixDiscardsPerStrMet")
- static final public String MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP = n_("matrixDiscardsPerStrMetPerZonePop");
+ static final public String MATRIX_DISCARDS_PER_STR_MET_PER_ZONE_POP = n("matrixDiscardsPerStrMetPerZonePop");
/**
* Matrix with five dimensions
@@ -73,7 +73,7 @@
* Dimension 5 : Zone
*/
@Doc(value = "do the doc of Result matrixLandingPerMet")
- static final public String MATRIX_LANDING_PER_MET = n_("matrixLandingPerMet");
+ static final public String MATRIX_LANDING_PER_MET = n("matrixLandingPerMet");
/**
* Matrix with three dimensions
@@ -82,7 +82,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixEffortPerStrategyMet")
- static final public String MATRIX_EFFORT_PER_STRATEGY_MET = n_("matrixEffortPerStrategyMet");
+ static final public String MATRIX_EFFORT_PER_STRATEGY_MET = n("matrixEffortPerStrategyMet");
/**
* Matrix with three dimensions
@@ -91,7 +91,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixEffortNominalPerStrategyMet")
- static final public String MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET = n_("matrixEffortNominalPerStrategyMet");
+ static final public String MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET = n("matrixEffortNominalPerStrategyMet");
/**
* Matrix with five dimensions
@@ -102,7 +102,7 @@
* Dimension 5 : Zone
*/
@Doc(value = "Disponible uniquement avec les simulations par Zone. do the doc of Result matrixCatchRatePerStrategyMet")
- static final public String MATRIX_CATCH_RATE_PER_STRATEGY_MET_PER_ZONE_POP = n_("matrixCatchRatePerStrategyMet");
+ static final public String MATRIX_CATCH_RATE_PER_STRATEGY_MET_PER_ZONE_POP = n("matrixCatchRatePerStrategyMet");
/**
* Matrix with five dimensions
@@ -111,9 +111,12 @@
* Dimension 3 : Metier
* Dimension 4 : Group
* Dimension 5 : Zone
+ *
+ * N'est calculé que si l'effort est calculé par cellule et non par zone.
+ * @see simulators.SimulatorEffortByCell
*/
@Doc(value = "do the doc of Result matrixCatchPerStrategyMetPerZoneMet")
- static final public String MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_MET = n_("matrixCatchPerStrategyMetPerZoneMet");
+ static final public String MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_MET = n("matrixCatchPerStrategyMetPerZoneMet");
/**
* Matrix with five dimensions
@@ -124,7 +127,7 @@
* Dimension 5 : Zone
*/
@Doc(value = "do the doc of Result matrixCatchPerStrategyMetPerZonePop")
- static final public String MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP = n_("matrixCatchPerStrategyMetPerZonePop");
+ static final public String MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP = n("matrixCatchPerStrategyMetPerZonePop");
/**
* Matrix with five dimensions
@@ -133,9 +136,12 @@
* Dimension 3 : Metier
* Dimension 4 : Group
* Dimension 5 : Zone
+ *
+ * N'est calculé que si l'effort est calculé par cellule et non par zone.
+ * @see simulators.SimulatorEffortByCell
*/
@Doc(value = "do the doc of Result matrixCatchWeightPerStrategyMetPerZoneMet")
- static final public String MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_MET = n_("matrixCatchWeightPerStrategyMetPerZoneMet");
+ static final public String MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_MET = n("matrixCatchWeightPerStrategyMetPerZoneMet");
/**
* Matrix with five dimensions
@@ -146,7 +152,7 @@
* Dimension 5 : Zone
*/
@Doc(value = "do the doc of Result matrixCatchWeightPerStrategyMetPerZonePop")
- static final public String MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP = n_("matrixCatchWeightPerStrategyMetPerZonePop");
+ static final public String MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP = n("matrixCatchWeightPerStrategyMetPerZonePop");
/**
* Matrix with five dimensions
@@ -157,8 +163,23 @@
* Dimension 5 : Zone
*/
@Doc(value = "Disponible uniquement avec les simulations par Zone. do the doc of Result matrixFishingMortality")
- static final public String MATRIX_FISHING_MORTALITY = n_("matrixFishingMortality");
+ static final public String MATRIX_FISHING_MORTALITY = n("matrixFishingMortality");
+ /**
+ * Matrix with 1 dimension
+ * Dimension 1 : TimeStep
+ */
+ @Doc(value = "do the doc of Result matrixTotalFishingMortality")
+ static final public String MATRIX_TOTAL_FISHING_MORTALITY = n("matrixTotalFishingMortality");
+
+ /**
+ * Matrix with 2 dimensions
+ * Dimension 1 : TimeStep
+ * Dimension 2 : Group
+ */
+ @Doc(value = "do the doc of Result matrixFishingMortalityPerGroup")
+ static final public String MATRIX_FISHING_MORTALITY_PER_GROUP = n("matrixFishingMortalityPerGroup");
+
/**
* Matrix with three dimensions
* Dimension 1 : TimeStep
@@ -166,7 +187,7 @@
* Dimension 3 : Zone (semantics : Dimension 2)
*/
@Doc(value = "do the doc of Result matrixAbundance")
- static final public String MATRIX_ABUNDANCE = n_("matrixAbundance");
+ static final public String MATRIX_ABUNDANCE = n("matrixAbundance");
/**
* Matrix with three dimensions
@@ -175,7 +196,7 @@
* Dimension 3 : Zone
*/
@Doc(value = "do the doc of Result matrixAbundanceBeginMonth")
- static final public String MATRIX_ABUNDANCE_BEGIN_MONTH = n_("matrixAbundanceBeginMonth");
+ static final public String MATRIX_ABUNDANCE_BEGIN_MONTH = n("matrixAbundanceBeginMonth");
/**
* Matrix with three dimensions
@@ -184,7 +205,7 @@
* Dimension 3 : Zone
*/
@Doc(value = "do the doc of Result matrixBiomass")
- static final public String MATRIX_BIOMASS = n_("matrixBiomass");
+ static final public String MATRIX_BIOMASS = n("matrixBiomass");
/**
* Matrix with three dimensions
@@ -193,7 +214,7 @@
* Dimension 3 : Zone
*/
@Doc(value = "do the doc of Result matrixBiomassBeginMonth")
- static final public String MATRIX_BIOMASS_BEGIN_MONTH = n_("matrixBiomassBeginMonth");
+ static final public String MATRIX_BIOMASS_BEGIN_MONTH = n("matrixBiomassBeginMonth");
/**
* Matrix with three dimensions
@@ -202,7 +223,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixFishingTimePerMonthPerVessel")
- static final public String MATRIX_FISHING_TIME_PER_MONTH_PER_VESSEL = n_("matrixFishingTimePerMonthPerVessel");
+ static final public String MATRIX_FISHING_TIME_PER_MONTH_PER_VESSEL = n("matrixFishingTimePerMonthPerVessel");
/**
* Matrix with three dimensions
@@ -211,7 +232,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixFuelCostsOfTravelPerVessel")
- static final public String MATRIX_FUEL_COSTS_OF_TRAVEL_PER_VESSEL = n_("matrixFuelCostsOfTravelPerVessel");
+ static final public String MATRIX_FUEL_COSTS_OF_TRAVEL_PER_VESSEL = n("matrixFuelCostsOfTravelPerVessel");
/**
* Matrix with three dimensions
@@ -220,7 +241,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixCostsOfFishingPerVessel")
- static final public String MATRIX_COSTS_OF_FISHING_PER_VESSEL = n_("matrixCostsOfFishingPerVessel");
+ static final public String MATRIX_COSTS_OF_FISHING_PER_VESSEL = n("matrixCostsOfFishingPerVessel");
/**
* Matrix with three dimensions
@@ -229,7 +250,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixFuelCostsPerVessel")
- static final public String MATRIX_FUEL_COSTS_PER_VESSEL = n_("matrixFuelCostsPerVessel");
+ static final public String MATRIX_FUEL_COSTS_PER_VESSEL = n("matrixFuelCostsPerVessel");
/**
* Matrix with three dimensions
@@ -238,7 +259,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixRepairAndMaintenanceGearCostsPerVessel")
- static final public String MATRIX_REPAIR_AND_MAINTENANCE_GEAR_COSTS_PER_VESSEL = n_("matrixRepairAndMaintenanceGearCostsPerVessel");
+ static final public String MATRIX_REPAIR_AND_MAINTENANCE_GEAR_COSTS_PER_VESSEL = n("matrixRepairAndMaintenanceGearCostsPerVessel");
/**
* Matrix with three dimensions
@@ -247,7 +268,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixOtherRunningCostsPerVessel")
- static final public String MATRIX_OTHER_RUNNING_COSTS_PER_VESSEL = n_("matrixOtherRunningCostsPerVessel");
+ static final public String MATRIX_OTHER_RUNNING_COSTS_PER_VESSEL = n("matrixOtherRunningCostsPerVessel");
/**
* Matrix with three dimensions
@@ -256,7 +277,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixSharedNotFixedCostsPerVessel")
- static final public String MATRIX_SHARED_NOT_FIXED_COSTS_PER_VESSEL = n_("matrixSharedNotFixedCostsPerVessel");
+ static final public String MATRIX_SHARED_NOT_FIXED_COSTS_PER_VESSEL = n("matrixSharedNotFixedCostsPerVessel");
/**
* Matrix with four dimensions
@@ -266,7 +287,7 @@
* Dimension 4 : Population
*/
@Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerSpeciesPerStrategyMet")
- static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET = n_("matrixGrossValueOfLandingsPerSpeciesPerStrategyMet");
+ static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET = n("matrixGrossValueOfLandingsPerSpeciesPerStrategyMet");
/**
* Matrix with three dimensions
@@ -275,7 +296,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerStrategyMet")
- static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET = n_("matrixGrossValueOfLandingsPerStrategyMet");
+ static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET = n("matrixGrossValueOfLandingsPerStrategyMet");
/**
* Matrix with three dimensions
@@ -286,7 +307,7 @@
* Matrix calculated in the non generic Rule : GraviteVPUE1LangEtGrossValueOtherSpeciesECOMOD
*/
@Doc(value = "do the doc of Result matrixGrossValueOfLandingsOtherSpeciesPerStrategyMet")
- static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_OTHER_SPECIES_PER_STRATEGY_MET = n_("matrixGrossValueOfLandingsOtherSpeciesPerStrategyMet");
+ static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_OTHER_SPECIES_PER_STRATEGY_MET = n("matrixGrossValueOfLandingsOtherSpeciesPerStrategyMet");
/**
* Matrix with three dimensions
@@ -295,7 +316,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixGrossValueOfLandingsPerStrategyMetPerVessel")
- static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL = n_("matrixGrossValueOfLandingsPerStrategyMetPerVessel");
+ static final public String MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL = n("matrixGrossValueOfLandingsPerStrategyMetPerVessel");
/**
* Matrix with three dimensions
@@ -304,7 +325,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixNetValueOfLandingsPerStrategyMet")
- static final public String MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET = n_("matrixNetValueOfLandingsPerStrategyMet");
+ static final public String MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET = n("matrixNetValueOfLandingsPerStrategyMet");
/**
* Matrix with three dimensions
@@ -313,7 +334,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixNetValueOfLandingsPerStrategyMetPerVessel")
- static final public String MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL = n_("matrixNetValueOfLandingsPerStrategyMetPerVessel");
+ static final public String MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL = n("matrixNetValueOfLandingsPerStrategyMetPerVessel");
/**
* Matrix with three dimensions
@@ -322,7 +343,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixNetRenevueToSharePerStrategyMetPerVessel")
- static final public String MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL = n_("matrixNetRenevueToSharePerStrategyMetPerVessel");
+ static final public String MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL = n("matrixNetRenevueToSharePerStrategyMetPerVessel");
/**
* Matrix with three dimensions
@@ -331,7 +352,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixCrewSharePerStrategyPerVessel")
- static final public String MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL = n_("matrixCrewSharePerStrategyPerVessel");
+ static final public String MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL = n("matrixCrewSharePerStrategyPerVessel");
/**
* Matrix with three dimensions
@@ -340,7 +361,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel")
- static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL = n_("matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel");
+ static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL = n("matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel");
/**
* Matrix with three dimensions
@@ -349,7 +370,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel")
- static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL = n_("matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel");
+ static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL = n("matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel");
/**
* Matrix with three dimensions
@@ -358,7 +379,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixOwnerMarginOverVariableCostsPerStrategyPerVessel")
- static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL = n_("matrixOwnerMarginOverVariableCostsPerStrategyPerVessel");
+ static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL = n("matrixOwnerMarginOverVariableCostsPerStrategyPerVessel");
/**
* Matrix with two dimensions
@@ -366,7 +387,7 @@
* Dimension 2 : Strategy
*/
@Doc(value = "do the doc of Result matrixOwnerMarginOverVariableCostsPerStrategy")
- static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY = n_("matrixOwnerMarginOverVariableCostsPerStrategy");
+ static final public String MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY = n("matrixOwnerMarginOverVariableCostsPerStrategy");
/**
* Matrix with two dimensions
@@ -374,7 +395,7 @@
* Dimension 2 : Strategy
*/
@Doc(value = "do the doc of Result matrixVesselMarginOverVariableCostsPerStrategyPerVessel")
- static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL = n_("matrixVesselMarginOverVariableCostsPerStrategyPerVessel");
+ static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL = n("matrixVesselMarginOverVariableCostsPerStrategyPerVessel");
/**
* Matrix with two dimensions
@@ -382,7 +403,7 @@
* Dimension 2 : Strategy
*/
@Doc(value = "do the doc of Result matrixVesselMarginOverVariableCostsPerStrategy")
- static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY = n_("matrixVesselMarginOverVariableCostsPerStrategy");
+ static final public String MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY = n("matrixVesselMarginOverVariableCostsPerStrategy");
/**
* Matrix with three dimensions
@@ -391,7 +412,7 @@
* Dimension 3 : Metier
*/
@Doc(value = "do the doc of Result matrixNoActivity")
- static final public String MATRIX_NO_ACTIVITY = n_("matrixNoActivity");
+ static final public String MATRIX_NO_ACTIVITY = n("matrixNoActivity");
/**
* Matrix with three dimensions
@@ -400,7 +421,7 @@
* Dimension 3 : Zone
*/
@Doc(value = "do the doc of Result matrixMetierZone")
- static final public String MATRIX_METIER_ZONE = n_("matrixMetierZone");
+ static final public String MATRIX_METIER_ZONE = n("matrixMetierZone");
/**
* Matrix with two dimensions
@@ -408,5 +429,5 @@
* Dimension 2 : Group
*/
@Doc(value = "do the doc of Result matrixPrice")
- static final public String MATRIX_PRICE = n_("matrixPrice");
+ static final public String MATRIX_PRICE = n("matrixPrice");
}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/scripts/RuleUtil.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/scripts/RuleUtil.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/scripts/RuleUtil.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -25,9 +25,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.math.matrix.*;
-
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationGroup;
import fr.ifremer.isisfish.entities.Species;
@@ -53,7 +52,7 @@
/**
* @param context le context de simulation
* @param species l'espece sur lequel on souhaite le total
- * @param date la date pour laquel on veut le calcul, cet argument est
+ * @param step le pas de temps pour lequel on veut le calcul, cet argument est
* passe seulement pour que le cache ne retourne pas toujours la meme valeur
* @return total catch in tons
*/
@@ -78,4 +77,24 @@
}
return result;
}
+
+ public static double getTotalCatchTonsPop(SimulationContext context, Population pop, TimeStep step) {
+ double result = 0;
+ MatrixND mat = context.getPopulationMonitor().getHoldCatch(pop);
+ if (mat != null) {
+ mat = mat.copy();
+ mat = mat.sumOverDim(0); // sum over Strategies
+ mat = mat.sumOverDim(1); // sum over metiers
+ mat = mat.sumOverDim(3); // sum over zones
+
+ List<PopulationGroup> groups = pop.getPopulationGroup();
+
+ for (int c = 0; c < groups.size(); c++) {
+ PopulationGroup group = groups.get(c);
+ double weight = group.getMeanWeight();
+ result += mat.getValue(0, 0, c, 0) * weight / 1000.0;
+ }
+ }
+ return result;
+ }
}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/scripts/SiMatrix.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/scripts/SiMatrix.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/scripts/SiMatrix.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Benjamin Poussin
+ * Copyright (C) 2006 - 2014 Ifremer, Code Lutin, Benjamin Poussin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -22,10 +22,11 @@
package scripts;
-import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.n;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -57,6 +58,8 @@
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.types.Month;
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.util.Nocache;
/**
* SiMatrix.java
@@ -99,13 +102,9 @@
}
/**
- *
* @param context
- * Simulation context
- * @param db
- * TopiaContext with transaction opened. You must used this
- * TopiaContext and not used
- * SimulationContext.getSimulationStorage().getStorage()
+ * Simulation context transaction opened. You must used this
+ * TopiaContext and not used SimulationContext.getSimulationStorage().getStorage()
* @throws TopiaException
*/
public SiMatrix(SimulationContext context) throws TopiaException {
@@ -181,17 +180,19 @@
*/
public List<Metier> getMetiers(Strategy str, TimeStep step) {
StrategyMonthInfo info = str.getStrategyMonthInfo(step.getMonth());
- MatrixND props = info.getProportionMetier();
+ List<Metier> result = info.getMetierWithProportion();
- List<Metier> result = new ArrayList<Metier>();
-
- for (MatrixIterator i = props.iterator(); i.hasNext();) {
- i.next();
- if (i.getValue() != 0) {
- Metier metier = (Metier) i.getSemanticsCoordinates()[0];
- result.add(metier);
- }
- }
+// MatrixND props = info.getProportionMetier();
+//
+// List<Metier> result = new ArrayList<Metier>();
+//
+// for (MatrixIterator i = props.iterator(); i.hasNext();) {
+// i.next();
+// if (i.getValue() != 0) {
+// Metier metier = (Metier) i.getSemanticsCoordinates()[0];
+// result.add(metier);
+// }
+// }
return result;
}
@@ -211,7 +212,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_METIER_ZONE, new List[] { metiers, zones },
- new String[] { n_("Metiers"), n_("Zones") });
+ new String[] { n("Metiers"), n("Zones") });
for (Metier metier : metiers) {
Collection<Zone> zoneMetier = metier.getMetierSeasonInfo(
@@ -227,7 +228,7 @@
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_PRICE, new List[] { groups },
- new String[] { n_("PopulationGroup") });
+ new String[] { n("PopulationGroup") });
for (PopulationGroup group : groups) {
result.setValue(group, group.getPrice());
@@ -246,18 +247,23 @@
public MatrixND matrixCatchWeightPerStrategyMetPerZoneMet(TimeStep step,
Population pop, MatrixND matrixCatchPerStrategyMetPerZoneMet)
throws TopiaException, IsisFishException {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- MatrixND result = matrixCatchPerStrategyMetPerZoneMet.copy();
- result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_MET);
+ return matrixToWeightMatrix(step, 2,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_MET,
+ matrixCatchPerStrategyMetPerZoneMet);
- for (PopulationGroup group : groups) {
- MatrixND sub = result.getSubMatrix(2, group, 1);
- double meanWeight = group.getMeanWeight();
- sub.mults(meanWeight);
- }
-
- return result;
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+//
+// MatrixND result = matrixCatchPerStrategyMetPerZoneMet.copy();
+// result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_MET);
+//
+// for (PopulationGroup group : groups) {
+// MatrixND sub = result.getSubMatrix(2, group, 1);
+// double meanWeight = group.getMeanWeight();
+// sub.mults(meanWeight);
+// }
+//
+// return result;
}
public MatrixND matrixCatchPerStrategyMetPerZoneMet(MatrixND N,
@@ -282,8 +288,8 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_MET,
new List[] { strategies, metiers, groups, zones },
- new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
- n_("Zones") });
+ new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+ n("Zones") });
// matrice temporaire ou les zones pops sont sommees
MatrixND tmp = matrixCatchPerStrategyMetPerCell.sumOverDim(3);
@@ -293,8 +299,11 @@
Strategy str = strategies.get(s);
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
+ // on iter que sur les metiers qui ont une proportion non 0
+ // car la matrice pour les autres metiers, contient 0.
+ List<Metier> metiersNot0 = getMetiers(str, step);
+ for (int m = 0; m < metiersNot0.size(); m++) {
+ Metier metier = metiersNot0.get(m);
MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(step
.getMonth());
Collection<Zone> zoneMet = infoMet.getZone();
@@ -339,18 +348,23 @@
public MatrixND matrixCatchWeightPerStrategyMetPerZonePop(TimeStep step,
Population pop, MatrixND matrixCatchPerStrategyMetPerZonePop)
throws TopiaException, IsisFishException {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- MatrixND result = matrixCatchPerStrategyMetPerZonePop.copy();
- result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ return matrixToWeightMatrix(step, 2,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP,
+ matrixCatchPerStrategyMetPerZonePop);
- for (PopulationGroup group : groups) {
- MatrixND sub = result.getSubMatrix(2, group, 1);
- double meanWeight = group.getMeanWeight();
- sub.mults(meanWeight);
- }
-
- return result;
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+//
+// MatrixND result = matrixCatchPerStrategyMetPerZonePop.copy();
+// result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+//
+// for (PopulationGroup group : groups) {
+// MatrixND sub = result.getSubMatrix(2, group, 1);
+// double meanWeight = group.getMeanWeight();
+// sub.mults(meanWeight);
+// }
+//
+// return result;
}
/**
@@ -369,23 +383,36 @@
public MatrixND matrixCatchPerStrategyMetPerZone(MatrixND N,
Population pop, TimeStep step, MatrixND matrixCatchRatePerStrategyMet)
throws TopiaException, IsisFishException {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- List<Zone> zones = pop.getPopulationZone();
- // on le passe en argument ce qui evite de le calculer 2 fois
- // MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, step);
+ int dimGroup = 2;
+ int dimZone = 3;
+
MatrixND result = matrixCatchRatePerStrategyMet.copy();
result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP);
- for (PopulationGroup group : groups) {
- MatrixND sub = result.getSubMatrix(2, group, 1);
- for (Zone zone : zones) {
- MatrixND subsub = sub.getSubMatrix(3, zone, 1);
- double val = N.getValue(group, zone);
- subsub.mults(val);
- }
+ for (MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] posSem = i.getSemanticsCoordinates();
+ double val = i.getValue();
+ double n = N.getValue(posSem[dimGroup], posSem[dimZone]);
+ i.setValue(val * n);
}
+
return result;
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// List<Zone> zones = pop.getPopulationZone();
+//
+// MatrixND result = matrixCatchRatePerStrategyMet.copy();
+// result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP);
+//
+// for (PopulationGroup group : groups) {
+// MatrixND sub = result.getSubMatrix(2, group, 1);
+// for (Zone zone : zones) {
+// MatrixND subsub = sub.getSubMatrix(3, zone, 1);
+// double val = N.getValue(group, zone);
+// subsub.mults(val);
+// }
+// }
+// return result;
}
/**
@@ -410,18 +437,20 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_CATCH_RATE_PER_STRATEGY_MET_PER_ZONE_POP,
new List[] { strategies, metiers, groups, zones },
- new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
- n_("Zones") });
+ new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+ n("Zones") });
+ Month month = step.getMonth();
// Optimisation Hilaire
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = getMetiers(str, step);
for (int m = 0; m < metiers.size(); m++) {
Metier metier = metiers.get(m);
+ MetierSeasonInfo msi = metier.getMetierSeasonInfo(month);
for (int z = 0; z < zones.size(); z++) {
Zone zone = zones.get(z);
- double effort = effortPerZonePop(str, metier, step, zone);
+ double effort = effortPerZonePop(str, metier, msi, step, zone);
if (effort > 0) {
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -443,14 +472,13 @@
* @param zone
* @return
*/
- private double effortPerZonePop(Strategy str, Metier metier, TimeStep step,
+ private double effortPerZonePop(Strategy str, Metier metier, MetierSeasonInfo infoMet, TimeStep step,
Zone zonePop) {
- Month month = step.getMonth();
- Collection<Zone> zoneMet = metier.getMetierSeasonInfo(month).getZone();
+ Collection<Zone> zoneMet = infoMet.getZone();
double inter = nbCellInter(zoneMet, zonePop);
double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier,
- step);
+ infoMet, step);
if (log.isDebugEnabled()) {
log.debug(" strategy=" + str + " metier=" + metier + " inter="
@@ -539,9 +567,86 @@
return result;
}
+// /**
+// * Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop ]
+// *
+// * @param pop
+// * @param step
+// * @return
+// * @throws TopiaException
+// * @throws IsisFishException
+// */
+// public MatrixND matrixFishingMortality(TimeStep step, Population pop)
+// throws TopiaException, IsisFishException {
+// List<Strategy> strategies = getStrategies(step);
+// List<Metier> metiers = getMetiers(step);
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// List<Zone> zones = pop.getPopulationZone();
+//
+// // default value in matrix is 0
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_FISHING_MORTALITY,
+// new List[] { strategies, metiers, groups, zones },
+// new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+// n("Zones") });
+//
+// Month month = step.getMonth();
+// PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
+//
+// for (int g = 0; g < groups.size(); g++) {
+// PopulationGroup group = groups.get(g);
+//
+// // getCapturability is check matrix validity and create matrix if needed and get one value in
+// double capturability = infoPop.getCapturability(group);
+// if (capturability != 0) { // check 0, this prevent next call, for default value
+//
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+//
+// MetierSeasonInfo infoMet = metier
+// .getMetierSeasonInfo(month);
+// // getTargetFactor seem to be simple
+// double ciblage = infoMet.getTargetFactor(group);
+//
+// if (ciblage != 0) { // check 0, this prevent next call, for default value
+//
+// Gear gear = metier.getGear();
+// Selectivity selectivity = gear
+// .getPopulationSelectivity(pop);
+// if (selectivity != null) {
+//
+// // getCoefficient is equation evaluation
+// double coeff = selectivity.getCoefficient(pop,
+// group, metier);
+// if (coeff != 0) { // check 0, this prevent next call, for default value
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// for (int z = 0; z < zones.size(); z++) {
+// Zone zone = zones.get(z);
+// double effort = effortPerZonePop(str,
+// metier, infoMet, step, zone);
+// if (effort > 0) { // put value only if <> 0
+// double value = coeff
+// * capturability * ciblage
+// * effort;
+// result.setValue(str, metier, group,
+// zone, value);
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// return result;
+// }
+
/**
* Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop ]
- *
+ *
* @param pop
* @param step
* @return
@@ -559,51 +664,63 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_FISHING_MORTALITY,
new List[] { strategies, metiers, groups, zones },
- new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
- n_("Zones") });
+ new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+ n("Zones") });
Month month = step.getMonth();
PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
+
+ for (Strategy str : strategies) {
+ StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
+ double nbTrip = smi.getNumberOfTrips();
+ double propSetOfVessels = str.getProportionSetOfVessels();
+ int nbOfVessels = str.getSetOfVessels().getNumberOfVessels();
- for (int g = 0; g < groups.size(); g++) {
- PopulationGroup group = groups.get(g);
+ // dans le calcul de l'effort si une de ces donnees est 0
+ // alors le result dans la matrice est 0
+ // donc autant ne pas faire tous les autres calculs couteux
+ if (nbTrip * propSetOfVessels * nbOfVessels != 0) {
+ for (PopulationGroup group : groups) {
- // getCapturability is check matrix validity and create matrix if needed and get one value in
- double capturability = infoPop.getCapturability(group);
- if (capturability != 0) { // check 0, this prevent next call, for default value
+ // getCapturability is check matrix validity and create matrix if needed and get one value in
+ double capturability = infoPop.getCapturability(group);
+ if (capturability != 0) { // check 0, this prevent next call, for default value
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
+ // et de la meme facon si la proportion est 0 alors
+ // le resultat dans la matrice sera 0, donc on boucle que
+ // sur ceux qui ont une proportion
+ for (Metier metier : getMetiers(str, step)) {
- MetierSeasonInfo infoMet = metier
- .getMetierSeasonInfo(month);
- // getTargetFactor seem to be simple
- double ciblage = infoMet.getTargetFactor(group);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
- if (ciblage != 0) { // check 0, this prevent next call, for default value
+ MetierSeasonInfo infoMet = metier
+ .getMetierSeasonInfo(month);
+ // getTargetFactor seem to be simple
+ double ciblage = infoMet.getTargetFactor(group);
- Gear gear = metier.getGear();
- Selectivity selectivity = gear
- .getPopulationSelectivity(pop);
- if (selectivity != null) {
+ if (ciblage != 0) { // check 0, this prevent next call, for default value
- // getCoefficient is equation evaluation
- double coeff = selectivity.getCoefficient(pop,
- group, metier);
- if (coeff != 0) { // check 0, this prevent next call, for default value
+ Gear gear = metier.getGear();
+ Selectivity selectivity = gear
+ .getPopulationSelectivity(pop);
+ if (selectivity != null) {
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- for (int z = 0; z < zones.size(); z++) {
- Zone zone = zones.get(z);
- double effort = effortPerZonePop(str,
- metier, step, zone);
- if (effort > 0) { // put value only if <> 0
- double value = coeff
- * capturability * ciblage
- * effort;
- result.setValue(str, metier, group,
- zone, value);
+ // getCoefficient is equation evaluation
+ double coeff = selectivity.getCoefficient(pop,
+ group, metier);
+ if (coeff != 0) { // check 0, this prevent next call, for default value
+
+ for (Zone zone : zones) {
+ double effort = effortPerZonePop(str,
+ metier, infoMet, step, zone);
+ if (effort > 0) { // put value only if <> 0
+ double value = coeff
+ * capturability * ciblage
+ * effort;
+ result.setValue(str, metier, group,
+ zone, value);
+ }
}
}
}
@@ -616,6 +733,7 @@
return result;
}
+
/**
* Matrice des captures en nombre dim [ Strategy x Metier x Classe x zonePop ]
*
@@ -631,23 +749,80 @@
Population pop, TimeStep step,
MatrixND matrixCatchRatePerStrategyMetPerCell)
throws TopiaException, IsisFishException {
- List<PopulationGroup> groups = pop.getPopulationGroup();
- List<Zone> zones = pop.getPopulationZone();
+ int groupDim = 2;
+ int zoneDim = 3;
- // on le passe en argument ce qui evite de le calculer 2 fois
- // MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, step);
+ int NGroupDim = 0;
+ int NZoneDim = 1;
+
MatrixND result = matrixCatchRatePerStrategyMetPerCell.copy();
result.setName("matrixCatchPerStrategyMetPerCell");
- for (PopulationGroup group : groups) {
- MatrixND sub = result.getSubMatrix(2, group, 1);
- for (Zone zone : zones) {
- MatrixND subsub = sub.getSubMatrix(3, zone, 1);
- double val = N.getValue(group, zone) / (double) zone.sizeCell();
- subsub.mults(val);
+ List<PopulationGroup> groups = (List<PopulationGroup>)result.getSemantic(groupDim);
+ List<Zone> zones = (List<Zone>)result.getSemantic(zoneDim);
+
+ double[] sizeCell = new double[zones.size()];
+ int cpt = 0;
+ for (Zone z : zones) {
+ sizeCell[cpt++] = z.sizeCell();
+ }
+
+ // on suppose que les semantics de N et matrixCatchRatePerStrategyMetPerCell
+ // pour les PopulationGroup et Zone sont les memes
+ // mais on verifie tout de meme
+ if (groups.equals(N.getSemantic(NGroupDim)) &&
+ zones.equals(N.getSemantic(NZoneDim))) {
+
+ // on place les effectifs dans un tableau pour un acces rapide
+ // on divise directement par le nombre de cell de la zone pour eviter
+ // de le faire beaucoup plus souvent dans l'autre boucle
+ double[][] NArray = new double[groups.size()][zones.size()];
+ for (MatrixIterator i=N.iteratorNotZero(); i.next();) {
+ int[] pos = i.getCoordinates();
+ double val = i.getValue();
+
+ NArray[pos[NGroupDim]][pos[NZoneDim]] = val / sizeCell[pos[NZoneDim]];
}
+
+ // calcul de la matrice resultat
+ for (MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ int[] pos = i.getCoordinates();
+ double val = i.getValue();
+ val *= NArray[pos[groupDim]][pos[zoneDim]];
+ i.setValue(val);
+ }
+
+ } else {
+ // N et matrixCatchRatePerStrategyMetPerCell non pas les meme semantics
+ // on fait moins rapide
+ for (MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ int[] pos = i.getCoordinates();
+ Object[] sems = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup)sems[groupDim];
+ Zone zone = (Zone)sems[zoneDim];
+ double val = i.getValue();
+ val *= N.getValue(group, zone) / sizeCell[pos[zoneDim]];
+ i.setValue(val);
+ }
}
+
return result;
+
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// List<Zone> zones = pop.getPopulationZone();
+//
+// MatrixND result = matrixCatchRatePerStrategyMetPerCell.copy();
+// result.setName("matrixCatchPerStrategyMetPerCell");
+//
+// for (PopulationGroup group : groups) {
+// MatrixND sub = result.getSubMatrix(2, group, 1);
+// for (Zone zone : zones) {
+// MatrixND subsub = sub.getSubMatrix(3, zone, 1);
+// double val = N.getValue(group, zone) / (double) zone.sizeCell();
+// subsub.mults(val);
+// }
+// }
+// return result;
}
/**
@@ -662,103 +837,136 @@
private MatrixND matrixCatchRatePerStrategyMetPerCell(Population pop,
TimeStep step, MatrixND matrixFishingMortalityPerCell)
throws TopiaException, IsisFishException {
- List<Strategy> strategies = getStrategies(step);
- List<Metier> metiers = getMetiers(step);
- List<PopulationGroup> groups = pop.getPopulationGroup();
- List<Zone> zones = pop.getPopulationZone();
- List<Cell> cells = getCells(zones);
- MatrixND result = MatrixFactory.getInstance().create(
- "matrixCatchRatePerStrategyMetPerCell",
- new List[] { strategies, metiers, groups, zones, cells },
- new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
- n_("Zones"), n_("Cells") });
+ MatrixND totalFishingMortalityPerCell = totalFishingMortalityPerCell(
+ step, matrixFishingMortalityPerCell);
- // Optimisation Hilaire
- MatrixND matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCell
- .sumOverDim(2);
- matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCellSumOverGroup
- .reduceDims(2);
+ MatrixND result = matrixFishingMortalityPerCell.copy();
+ result.setName("matrixCatchRatePerStrategyMetPerCell");
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- metiers = getMetiers(str, step);
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
- for (int z = 0; z < zones.size(); z++) {
- Zone zone = zones.get(z);
- List<Cell> cellZones = zone.getCell();
- for (int c = 0; c < cellZones.size(); c++) {
- Cell cell = cellZones.get(c);
- double effort = matrixFishingMortalityPerCellSumOverGroup
- .getValue(str, metier, zone, cell);
- if (effort > 0) {
- for (int g = 0; g < groups.size(); g++) {
- PopulationGroup group = groups.get(g);
- double value = catchRatePerStrategyMetPerCell(
- str, metier, step, group, zone, cell,
- matrixFishingMortalityPerCell);
- result.setValue(new Object[] { str, metier,
- group, zone, cell }, value);
- }
- }
- }
- }
- }
- }
+ for (MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ Object[] sems = i.getSemanticsCoordinates();
- return result;
- }
+ PopulationGroup group = (PopulationGroup)sems[2];
+ Zone zone = (Zone)sems[3];
+ Cell cell = (Cell)sems[4];
- /**
- * catchRatePerStrategyMetPerCell.
- *
- * Optimisation Hilaire
- *
- * @param str
- * @param metier
- * @param step
- * @param group
- * @param zone
- * @param cell
- * @param matrixFishingMortalityPerCell
- * @return
- * @throws TopiaException
- * @throws IsisFishException
- */
- private double catchRatePerStrategyMetPerCell(Strategy str, Metier metier,
- TimeStep step, PopulationGroup group, Zone zone, Cell cell,
- MatrixND matrixFishingMortalityPerCell) throws TopiaException,
- IsisFishException {
+ double totalFishingMortality = totalFishingMortalityPerCell.getValue(
+ group, zone, cell);
- MatrixND totalFishingMortalityPerCell = totalFishingMortalityPerCell(
- step, matrixFishingMortalityPerCell);
- double totalFishingMortality = totalFishingMortalityPerCell.getValue(
- group, zone, cell);
+ if (totalFishingMortality != 0) {
- if (totalFishingMortality == 0) {
- if (log.isDebugEnabled()) {
- log.debug("pas de totalFishingMortality pour (" + group + ", "
- + zone + ")");
+ double fishingMortalityPerCell = i.getValue();
+ double totalCatchRatePerCell = totalCatchRatePerCell(step, group, zone,
+ totalFishingMortality);
+
+ double value = fishingMortalityPerCell / totalFishingMortality
+ * totalCatchRatePerCell;
+
+ i.setValue(value);
}
- return 0;
}
- double fishingMortalityPerCell = matrixFishingMortalityPerCell
- .getValue(new Object[] { str, metier, group, zone, cell });
- double totalCatchRatePerCell = totalCatchRatePerCell(step, group, zone,
- totalFishingMortality);
+ return result;
- if (log.isDebugEnabled()) {
- log.debug(" totalFishingMortality=" + totalFishingMortality
- + " fishingMortality=" + fishingMortalityPerCell
- + " totalCatchRate=" + totalCatchRatePerCell);
- }
- double result = fishingMortalityPerCell / totalFishingMortality
- * totalCatchRatePerCell;
- return result;
+// List<Strategy> strategies = getStrategies(step);
+// List<Metier> metiers = getMetiers(step);
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// List<Zone> zones = pop.getPopulationZone();
+// List<Cell> cells = getCells(zones);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// "matrixCatchRatePerStrategyMetPerCell",
+// new List[] { strategies, metiers, groups, zones, cells },
+// new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+// n("Zones"), n("Cells") });
+//
+// // Optimisation Hilaire
+// MatrixND matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCell
+// .sumOverDim(2);
+// matrixFishingMortalityPerCellSumOverGroup = matrixFishingMortalityPerCellSumOverGroup
+// .reduceDims(2);
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// metiers = getMetiers(str, step);
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+// for (int z = 0; z < zones.size(); z++) {
+// Zone zone = zones.get(z);
+// List<Cell> cellZones = zone.getCell();
+// for (int c = 0; c < cellZones.size(); c++) {
+// Cell cell = cellZones.get(c);
+// double effort = matrixFishingMortalityPerCellSumOverGroup
+// .getValue(str, metier, zone, cell);
+// if (effort > 0) {
+// for (int g = 0; g < groups.size(); g++) {
+// PopulationGroup group = groups.get(g);
+// double value = catchRatePerStrategyMetPerCell(
+// str, metier, step, group, zone, cell,
+// matrixFishingMortalityPerCell);
+// result.setValue(new Object[] { str, metier,
+// group, zone, cell }, value);
+// }
+// }
+// }
+// }
+// }
+// }
+//
+// return result;
}
+// directement dans matrixCatchRatePerStrategyMetPerCell pour pouvoir mieux optimiser
+// /**
+// * catchRatePerStrategyMetPerCell.
+// *
+// * Optimisation Hilaire
+// *
+// * @param str
+// * @param metier
+// * @param step
+// * @param group
+// * @param zone
+// * @param cell
+// * @param matrixFishingMortalityPerCell
+// * @return
+// * @throws TopiaException
+// * @throws IsisFishException
+// */
+// private double catchRatePerStrategyMetPerCell(Strategy str, Metier metier,
+// TimeStep step, PopulationGroup group, Zone zone, Cell cell,
+// MatrixND matrixFishingMortalityPerCell) throws TopiaException,
+// IsisFishException {
+//
+// MatrixND totalFishingMortalityPerCell = totalFishingMortalityPerCell(
+// step, matrixFishingMortalityPerCell);
+// double totalFishingMortality = totalFishingMortalityPerCell.getValue(
+// group, zone, cell);
+//
+// if (totalFishingMortality == 0) {
+// if (log.isDebugEnabled()) {
+// log.debug("pas de totalFishingMortality pour (" + group + ", "
+// + zone + ")");
+// }
+// return 0;
+// }
+//
+// double fishingMortalityPerCell = matrixFishingMortalityPerCell
+// .getValue(new Object[] { str, metier, group, zone, cell });
+// double totalCatchRatePerCell = totalCatchRatePerCell(step, group, zone,
+// totalFishingMortality);
+//
+// if (log.isDebugEnabled()) {
+// log.debug(" totalFishingMortality=" + totalFishingMortality
+// + " fishingMortality=" + fishingMortalityPerCell
+// + " totalCatchRate=" + totalCatchRatePerCell);
+// }
+// double result = fishingMortalityPerCell / totalFishingMortality
+// * totalCatchRatePerCell;
+//
+// return result;
+// }
/**
* @param step
@@ -791,7 +999,7 @@
/**
* Returne une matrice de mortalite group x zone, donc somme sur str et
* metier
- *
+ *
* @param step
* @param matrixFishingMortality
* @param group
@@ -806,12 +1014,101 @@
return result;
}
+// /**
+// * Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop x
+// * cellPop]
+// *
+// * Nouvelle implantation suite a demande Steph et Sigrid: 20080208 (NouvellesEquationsfev2008ParCelluleAvecAlgo.odt)
+// *
+// * @param pop
+// * @param step
+// * @return
+// * @throws TopiaException
+// * @throws IsisFishException
+// */
+// public MatrixND matrixFishingMortalityPerCell(TimeStep step, Population pop)
+// throws TopiaException, IsisFishException {
+// List<Strategy> strategies = getStrategies(step);
+// List<Metier> metiers = getMetiers(step);
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+// List<Zone> zones = pop.getPopulationZone();
+// List<Cell> cells = getCells(zones);
+//
+// // default value in matrix is 0
+// MatrixND result = MatrixFactory.getInstance().create(
+// "matrixFishingMortalityPerCell",
+// new List[] { strategies, metiers, groups, zones, cells },
+// new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+// n("Zones"), n("Cells") });
+//
+// Month month = step.getMonth();
+// PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
+//
+// for (int g = 0; g < groups.size(); g++) {
+// PopulationGroup group = groups.get(g);
+//
+// // getCapturability is check matrix validity and create matrix
+// // if needed and get one value in
+// double capturability = infoPop.getCapturability(group);
+// if (capturability != 0) { // check 0, this prevent next call, for default value
+// for (int m = 0; m < metiers.size(); m++) {
+// Metier metier = metiers.get(m);
+//
+// MetierSeasonInfo infoMet = metier
+// .getMetierSeasonInfo(month);
+// // getTargetFactor seem to be simple
+// double ciblage = infoMet.getTargetFactor(group);
+//
+// if (ciblage != 0) { // check 0, this prevent next call, for default value
+//
+// Gear gear = metier.getGear();
+// Selectivity selectivity = gear.getPopulationSelectivity(pop);
+// if (selectivity != null) {
+//
+// // getCoefficient is equation evaluation
+// double coeff = selectivity.getCoefficient(pop,group, metier);
+// if (coeff != 0) { // check 0, this prevent next call, for default value
+//
+// for (int s = 0; s < strategies.size(); s++) {
+// Strategy str = strategies.get(s);
+// // l'effort d'une cellule du metier
+// double effort = effortPerStrategyPerCell(
+// str, metier, infoMet, step);
+// if (effort > 0) { // put value only if <> 0
+// for (int z = 0; z < zones.size(); z++) {
+// Zone zone = zones.get(z);
+// Set<Cell> cellPops = new HashSet<Cell>(zone.getCell());
+// for (Cell cellMet : infoMet.getCells()) {
+// if (cellPops.contains(cellMet)) {
+// double value = coeff * capturability * ciblage * effort;
+// result.setValue(
+// new Object[] { str,
+// metier,
+// group,
+// zone,
+// cellMet },
+// value);
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// return result;
+// }
+//
+
/**
* Matrice fishing mortality dim [ Strategy x Metier x Classe x zonePop x
* cellPop]
- *
+ *
* Nouvelle implantation suite a demande Steph et Sigrid: 20080208 (NouvellesEquationsfev2008ParCelluleAvecAlgo.odt)
- *
+ *
* @param pop
* @param step
* @return
@@ -825,61 +1122,71 @@
List<PopulationGroup> groups = pop.getPopulationGroup();
List<Zone> zones = pop.getPopulationZone();
List<Cell> cells = getCells(zones);
-
+
// default value in matrix is 0
MatrixND result = MatrixFactory.getInstance().create(
"matrixFishingMortalityPerCell",
new List[] { strategies, metiers, groups, zones, cells },
- new String[] { n_("Strategies"), n_("Metiers"), n_("Groups"),
- n_("Zones"), n_("Cells") });
+ new String[] { n("Strategies"), n("Metiers"), n("Groups"),
+ n("Zones"), n("Cells") });
Month month = step.getMonth();
PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
- for (int g = 0; g < groups.size(); g++) {
- PopulationGroup group = groups.get(g);
+ for (Strategy str : strategies) {
+ StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
+ double nbTrip = smi.getNumberOfTrips();
+ double propSetOfVessels = str.getProportionSetOfVessels();
+ int nbOfVessels = str.getSetOfVessels().getNumberOfVessels();
- // getCapturability is check matrix validity and create matrix
- // if needed and get one value in
- double capturability = infoPop.getCapturability(group);
- if (capturability != 0) { // check 0, this prevent next call, for default value
- for (int m = 0; m < metiers.size(); m++) {
- Metier metier = metiers.get(m);
+ // dans le calcul de l'effort si une de ces donnees est 0
+ // alors le result dans la matrice est 0
+ // donc autant ne pas faire tous les autres calculs couteux
+ if (nbTrip * propSetOfVessels * nbOfVessels != 0) {
+ for (PopulationGroup group : groups) {
- MetierSeasonInfo infoMet = metier
- .getMetierSeasonInfo(month);
- // getTargetFactor seem to be simple
- double ciblage = infoMet.getTargetFactor(group);
+ // getCapturability is check matrix validity and create matrix if needed and get one value in
+ double capturability = infoPop.getCapturability(group);
+ if (capturability != 0) { // check 0, this prevent next call, for default value
- if (ciblage != 0) { // check 0, this prevent next call, for default value
+ // et de la meme facon si la proportion est 0 alors
+ // le resultat dans la matrice sera 0, donc on boucle que
+ // sur ceux qui ont une proportion
+ List<Metier> metiersNot0 = getMetiers(str, step);
+ for (Metier metier : metiersNot0) {
- Gear gear = metier.getGear();
- Selectivity selectivity = gear.getPopulationSelectivity(pop);
- if (selectivity != null) {
+ MetierSeasonInfo infoMet = metier
+ .getMetierSeasonInfo(month);
+ // getTargetFactor seem to be simple
+ double ciblage = infoMet.getTargetFactor(group);
- // getCoefficient is equation evaluation
- double coeff = selectivity.getCoefficient(pop,group, metier);
- if (coeff != 0) { // check 0, this prevent next call, for default value
+ if (ciblage != 0) { // check 0, this prevent next call, for default value
- for (int s = 0; s < strategies.size(); s++) {
- Strategy str = strategies.get(s);
- // l'effort d'une cellule du metier
- double effort = effortPerStrategyPerCell(
- str, metier, step);
- if (effort > 0) { // put value only if <> 0
- for (int z = 0; z < zones.size(); z++) {
- Zone zone = zones.get(z);
- Set<Cell> cellPops = new HashSet<Cell>(zone.getCell());
- for (Cell cellMet : infoMet.getCells()) {
- if (cellPops.contains(cellMet)) {
- double value = coeff * capturability * ciblage * effort;
- result.setValue(
- new Object[] { str,
+ Gear gear = metier.getGear();
+ Selectivity selectivity = gear.getPopulationSelectivity(pop);
+ if (selectivity != null) {
+
+ // getCoefficient is equation evaluation
+ double coeff = selectivity.getCoefficient(pop,group, metier);
+ if (coeff != 0) { // check 0, this prevent next call, for default value
+
+ // l'effort d'une cellule du metier
+ double effort = effortPerStrategyPerCell(
+ str, metier, infoMet, step);
+ if (effort > 0) { // put value only if <> 0
+ for (Zone zone : zones) {
+ Set<Cell> cellPops = new HashSet<Cell>(zone.getCell());
+ for (Cell cellMet : infoMet.getCells()) {
+ if (cellPops.contains(cellMet)) {
+ double value = coeff * capturability * ciblage * effort;
+ result.setValue(
+ new Object[] { str,
metier,
group,
zone,
cellMet },
- value);
+ value);
+ }
}
}
}
@@ -901,19 +1208,20 @@
* @return
*/
private double effortPerStrategyPerCell(Strategy str, Metier metier,
- TimeStep step) {
- Month month = step.getMonth();
+ MetierSeasonInfo infoMet, TimeStep step) {
//StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
- Collection<Zone> zones = metier.getMetierSeasonInfo(month).getZone();
+ Collection<Zone> zones = infoMet.getZone();
double nbCell = getCells(zones).size();
if (nbCell == 0) {
// normalement il devrait y avoir des mailles, mais pour les
// ancienne zone AuPort, il n'y en avait pas
- if (log.isWarnEnabled())
+ if (log.isWarnEnabled()) {
+ Month month = step.getMonth();
log.warn("Calcul d'une distance pour le metier " + metier
+ " pour le mois " + month
+ " avec une zone sans maille: " + zones);
+ }
return 0;
}
@@ -1078,8 +1386,8 @@
/**
*
- * @param setOfVessels
- * @param zone
+ * @param sov
+ * @param zoneMetier
* @return
*/
protected double travelTimePerTrip(SetOfVessels sov,
@@ -1255,7 +1563,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_ABUNDANCE + "_PER_CELL",
new List[] { groups, zones, allCells },
- new String[] { n_("Groups"), n_("Zones"), n_("Cells") });
+ new String[] { n("Groups"), n("Zones"), n("Cells") });
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -1320,7 +1628,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_ABUNDANCE, new List[] { groups, zones },
- new String[] { n_("Groups"), n_("Zones") });
+ new String[] { n("Groups"), n("Zones") });
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -1355,7 +1663,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_ABUNDANCE, new List[] { groups, zones },
- new String[] { n_("Groups"), n_("Zones") });
+ new String[] { n("Groups"), n("Zones") });
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -1386,8 +1694,8 @@
Zone zone, MatrixND matrixFishingMortality) throws TopiaException,
IsisFishException {
double F = totalFishingMortality(step, matrixFishingMortality)
- .getValue(group, zone); //totalFishingMortality(step, group, zone); // rem perf: totalFishingMortality a deja ete calcul�
- double M = group.getNaturalDeathRate(zone)
+ .getValue(group, zone); //totalFishingMortality(step, group, zone); // rem perf: totalFishingMortality a deja ete calcule
+ double M = group.getNaturalDeathRate(zone)
/ (double) Month.NUMBER_OF_MONTH;
double result = Math.exp(-(F + M));
@@ -1407,9 +1715,9 @@
throws TopiaException, IsisFishException {
double F = totalFishingMortalityPerCell(step,
- matrixFishingMortalityPerCell).getValue(group, zone, cell); //totalFishingMortality(step, group, zone); // rem perf: totalFishingMortality a deja ete calcul�
+ matrixFishingMortalityPerCell).getValue(group, zone, cell); //totalFishingMortality(step, group, zone); // rem perf: totalFishingMortality a deja ete calcule
double M = group.getNaturalDeathRate(zone)
- / (double) Month.NUMBER_OF_MONTH;
+ / (double) Month.NUMBER_OF_MONTH;
double result = (double) Math.exp(-(F + M));
return result;
@@ -1428,47 +1736,51 @@
* @return
*/
public MatrixND matrixBiomass(MatrixND N, Population pop, TimeStep step) {
- List<PopulationGroup> groups = (List<PopulationGroup>)N.getSemantic(0);
- List<Zone> zones = (List<Zone>)N.getSemantic(1);
-
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_BIOMASS, new List[] { groups, zones },
- new String[] { n_("Groups"), n_("Zones") });
-
- for (int g = 0; g < groups.size(); g++) {
- PopulationGroup group = groups.get(g);
- double meanWeight = group.getMeanWeight();
- for (int z = 0; z < zones.size(); z++) {
- Zone zone = zones.get(z);
- double n = N.getValue(group, zone);
- double value = n * meanWeight;
- result.setValue(group, zone, value);
- }
- }
-
- return result;
+ return matrixToWeightMatrix(step, 0, ResultName.MATRIX_BIOMASS, N);
+//
+// List<PopulationGroup> groups = (List<PopulationGroup>)N.getSemantic(0);
+// List<Zone> zones = (List<Zone>)N.getSemantic(1);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_BIOMASS, new List[] { groups, zones },
+// new String[] { n("Groups"), n("Zones") });
+//
+// for (int g = 0; g < groups.size(); g++) {
+// PopulationGroup group = groups.get(g);
+// double meanWeight = group.getMeanWeight();
+// for (int z = 0; z < zones.size(); z++) {
+// Zone zone = zones.get(z);
+// double n = N.getValue(group, zone);
+// double value = n * meanWeight;
+// result.setValue(group, zone, value);
+// }
+// }
+//
+// return result;
}
public MatrixND matrixBiomassBeginMonth(MatrixND N, Population pop,
TimeStep step) {
- List<PopulationGroup> groups = (List<PopulationGroup>)N.getSemantic(0);
- List<Zone> zones = (List<Zone>)N.getSemantic(1);
+ return matrixToWeightMatrix(step, 0, ResultName.MATRIX_BIOMASS_BEGIN_MONTH, N);
- MatrixND result = MatrixFactory.getInstance().create(
- ResultName.MATRIX_BIOMASS_BEGIN_MONTH, new List[] { groups, zones },
- new String[] { n_("Groups"), n_("Zones") });
-
- for (int g = 0; g < groups.size(); g++) {
- PopulationGroup group = groups.get(g);
- double meanWeight = group.getMeanWeight();
- for (int z = 0; z < zones.size(); z++) {
- Zone zone = zones.get(z);
- double n = N.getValue(group, zone);
- double value = n * meanWeight;
- result.setValue(group, zone, value);
- }
- }
- return result;
+// List<PopulationGroup> groups = (List<PopulationGroup>)N.getSemantic(0);
+// List<Zone> zones = (List<Zone>)N.getSemantic(1);
+//
+// MatrixND result = MatrixFactory.getInstance().create(
+// ResultName.MATRIX_BIOMASS_BEGIN_MONTH, new List[] { groups, zones },
+// new String[] { n("Groups"), n("Zones") });
+//
+// for (int g = 0; g < groups.size(); g++) {
+// PopulationGroup group = groups.get(g);
+// double meanWeight = group.getMeanWeight();
+// for (int z = 0; z < zones.size(); z++) {
+// Zone zone = zones.get(z);
+// double n = N.getValue(group, zone);
+// double value = n * meanWeight;
+// result.setValue(group, zone, value);
+// }
+// }
+// return result;
}
public MatrixND matrixAbondanceBeginMonth(MatrixND N, Population pop,
@@ -1478,7 +1790,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_ABUNDANCE_BEGIN_MONTH, new List[] { groups, zones },
- new String[] { n_("Groups"), n_("Zones") });
+ new String[] { n("Groups"), n("Zones") });
for (int g = 0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
@@ -1491,12 +1803,6 @@
return result;
}
- ///////////////////////////////////////////////////////////////////////////
- //
- //
- //
- ///////////////////////////////////////////////////////////////////////////
-
/**
* @param step
* @return
@@ -1509,7 +1815,7 @@
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_EFFORT_PER_STRATEGY_MET,
new List[] { strategies, metiers },
- new String[] { n_("Strategies"), n_("Metiers") });
+ new String[] { n("Strategies"), n("Metiers") });
for (int s = 0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -1524,12 +1830,6 @@
return result;
}
- ///////////////////////////////////////////////////////////////////////////
- //
- //
- //
- ///////////////////////////////////////////////////////////////////////////
-
/**
*
*
@@ -1540,34 +1840,33 @@
*/
public MatrixND matrixDiscardWeightPerStrategyMetPerZonePop(Population pop,
TimeStep step, MatrixND matrixDiscardPerStrategyMetPerZonePop) {
- List<PopulationGroup> groups = pop.getPopulationGroup();
+ return matrixToWeightMatrix(step, 2,
+ ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP,
+ matrixDiscardPerStrategyMetPerZonePop);
- MatrixND result = matrixDiscardPerStrategyMetPerZonePop.copy();
- result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
-
- for (PopulationGroup group : groups) {
- MatrixND sub = result.getSubMatrix(2, group, 1);
- double meanWeight = group.getMeanWeight();
- sub.mults(meanWeight);
- }
-
- return result;
+// List<PopulationGroup> groups = pop.getPopulationGroup();
+//
+// MatrixND result = matrixDiscardPerStrategyMetPerZonePop.copy();
+// result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET_PER_ZONE_POP);
+//
+// for (PopulationGroup group : groups) {
+// MatrixND sub = result.getSubMatrix(2, group, 1);
+// double meanWeight = group.getMeanWeight();
+// sub.mults(meanWeight);
+// }
+//
+// return result;
}
- ///////////////////////////////////////////////////////////////////////////
- //
- //
- //
- ///////////////////////////////////////////////////////////////////////////
- public MatrixND matrixEffortNominalPerStrategyMet(TimeStep step) throws TopiaException {
+ public MatrixND matrixEffortNominalPerStrategyMet(TimeStep step) throws TopiaException {
- List<Strategy> strategies = getStrategies(step);
+ List<Strategy> strategies = getStrategies(step);
List<Metier> metiers = getMetiers(step);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET,
new List[]{strategies, metiers},
- new String[]{n_("Strategies"), n_("Metiers")});
+ new String[]{n("Strategies"), n("Metiers")});
for (int s=0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
@@ -1581,4 +1880,153 @@
return result;
}
+
+ /**
+ * Ce morceau de script sert a calculer la mortalite par peche par espece et
+ * par groupe d'age sur l'ensemble de la zone d'etude,
+ * en minimisant la difference entre les captures d'ISIS et celles calculees
+ * a partir de l'equation de Baranov.
+ *
+ * @param step pas de temps
+ * @param pop population
+ * @return Fishing mortality per group per year (computed in December)
+ */
+ public MatrixND fishingMortalityPerGroup(TimeStep step, Population pop, ResultStorage resManager) throws TopiaException {
+ double Fgroup = 0;
+ double Cgroup = 0;
+ double Mgroup = 0;
+ double NgroupJan = 0;
+
+ List<Population> populations = Collections.singletonList(pop);
+ List<PopulationGroup> groups = pop.getPopulationGroup();
+
+ MatrixND tfgMatrix = MatrixFactory.getInstance().create(
+ ResultName.MATRIX_FISHING_MORTALITY_PER_GROUP,
+ new List[]{populations, groups}, // On travaille sur les pops ET les groupes
+ new String[]{n("Population"), n("Group")});
+
+ for (PopulationGroup group : groups) {
+
+ if (step.getMonth() == Month.DECEMBER) {
+
+ MatrixND catchPerStrategy = null;
+
+ for (TimeStep loopstep = new TimeStep(step.getYear() * 12); loopstep.beforeOrEquals(step); loopstep=loopstep.next()) {
+ // On fait cette boucle pour contourner les aspects de cache qui font que les resultats ne sont pas recuperes
+ //s'ils ont deja ete calcules une fois (meme s'ils ont change depuis)
+ // beforeOrEquals sert a bien prendre Decembre aussi
+
+ MatrixND catchPerStrategyTemp = resManager.getMatrix(loopstep, pop, ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP);
+ if (catchPerStrategy == null) {
+ catchPerStrategy = catchPerStrategyTemp.clone();
+ // On clone la matrice car si on fait les operations sur celle contenue dans le cache on la modifie et donc on recupere des resultats faux.
+ } else {
+ catchPerStrategy = catchPerStrategy.add(catchPerStrategyTemp); // Pour avoir la somme des captures sur les 12 mois
+ }
+ }
+
+ //log.info("catchPerStrategy = " + catchPerStrategy);
+ catchPerStrategy = catchPerStrategy.sumOverDim(0); // Strategy
+ catchPerStrategy = catchPerStrategy.sumOverDim(1); // Metier
+ catchPerStrategy = catchPerStrategy.sumOverDim(3); // Zone : une pop peut avoir plusieurs zonespop dans ISIS
+ List semgroup = catchPerStrategy.getSemantic(2);
+ catchPerStrategy = catchPerStrategy.reduce(); // Enleve les dimensions de taille 1
+ catchPerStrategy.setSemantic(0, semgroup); // Ne plait pas a Eric
+ Cgroup = catchPerStrategy.getValue(group);
+ //log.info("Cgroup = " + Cgroup + "Year=" + step.getYear());
+ //log.info("catchPerStrategy = " + catchPerStrategy + "Year=" + step.getYear());
+
+ MatrixND naturalDeathRatePop = pop.getNaturalDeathRateMatrix();
+ naturalDeathRatePop = naturalDeathRatePop.meanOverDim(1); // moyenne sur Zone
+ naturalDeathRatePop = naturalDeathRatePop.reduce(); // Enleve les dimensions de taille 1
+ Mgroup = naturalDeathRatePop.getValue(group);
+ //log.info("Mgroup= " + Mgroup + "Year=" + step.getYear());
+
+ MatrixND abundancePopJan = resManager.getMatrix(new TimeStep(12*step.getYear()), pop, ResultName.MATRIX_ABUNDANCE); // Le timestep 0 correspond a janvier de la premiere annee et les annees sont numerotees a partir de zero
+ abundancePopJan = abundancePopJan.sumOverDim(1); // somme sur Zone
+ abundancePopJan = abundancePopJan.reduce();
+ NgroupJan = abundancePopJan.getValue(group);
+ //log.info("NgroupJan = " + NgroupJan + "Year=" + step.getYear());
+
+ ObjectiveFunction f = new ObjectiveFunctionBaranov(Cgroup, Mgroup, NgroupJan);
+ Fgroup = MinimisationUtil.fmin(0.0,2.0,1.0e-10, f); // step ??
+
+ //log.info("Fgroup = " + Fgroup);
+
+ tfgMatrix.setValue(pop, group, Fgroup); // Bien faire attention a l'endroit ou on met cette etape (quelle boucle) ?
+
+ } else {
+ //Fgroup = 0; // Ce n'est plus une valeur unique mais une matrice, est-ce que cette notation peut fonctionner ?
+ tfgMatrix.setValue(pop, group, 0); // Bien faire attention a l'endroit ou on met cette etape (quelle boucle) ?
+ }
+ }
+
+ //log.info("tfgMatrix = " + tfgMatrix);
+ //log.info("tfg.DimensionNames = " + Arrays.toString(tfgMatrix.getDimensionNames()));
+ //log.info("tfg.Semantics = " + Arrays.toString(tfgMatrix.getSemantics()));
+
+ return tfgMatrix;
+ }
+
+ /**
+ * Ce morceau de script sert a calculer la mortalite par peche par espece et
+ * par groupe representatif a partir de la mortalite par peche par groupe
+ * calculee precedemment.
+ */
+ public MatrixND totalFishingMortality(TimeStep step, Population pop, MatrixND fishingMortalityPerGroup) throws TopiaException {
+ MatrixND tfmMatrix = fishingMortalityPerGroup.copy();
+ tfmMatrix.setName(ResultName.MATRIX_TOTAL_FISHING_MORTALITY);
+ //log.info("tfmMatrix = " + tfmMatrix);
+
+ List<PopulationGroup> groups = pop.getPopulationGroup();
+
+ int groupMin = pop.getGroupMin();
+ int groupMax = pop.getGroupMax();
+ int Nbre = (int)groupMax - (int)groupMin + 1;
+ //log.info("Nbre = " + Nbre);
+
+ for (PopulationGroup group : groups) {
+ if (group.getId() == groupMin) {
+ // MatrixND getSubMatrix(int dim, Object, int nb)
+ tfmMatrix = tfmMatrix.getSubMatrix(1, group, Nbre);
+ tfmMatrix = tfmMatrix.meanOverDim(1);
+ tfmMatrix = tfmMatrix.reduce();
+ //log.info("tfm.DimensionNames = " + Arrays.toString(tfmMatrix.getDimensionNames()));
+ //log.info("tfm.Semantics = " + Arrays.toString(tfmMatrix.getSemantics()));
+ }
+ }
+
+ return tfmMatrix;
+ }
+
+ /**
+ * Converti une matrix contenant des effectifs en une matrice en poids
+ *
+ * @param step
+ * @param dimGroup
+ * @param resultName
+ * @return
+ */
+ @Nocache // no need to cache it, because caller method is cached
+ public MatrixND matrixToWeightMatrix(TimeStep step, int dimGroup, String resultName,
+ MatrixND matrix) {
+
+ MatrixND result = matrix.copy();
+ result.setName(resultName);
+
+ List<PopulationGroup> groups = (List<PopulationGroup>)result.getSemantic(dimGroup);
+ double[] meanWeight = new double[groups.size()];
+ int cpt = 0;
+ for (PopulationGroup group : groups) {
+ meanWeight[cpt++] = group.getMeanWeight();
+ }
+
+ for (MatrixIterator i=result.iteratorNotZero(); i.next();) {
+ double val = i.getValue();
+ int[] pos = i.getCoordinates();
+ i.setValue(val * meanWeight[pos[dimGroup]]);
+ }
+
+ return result;
+ }
}
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassReferenceY9.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.File;
import java.io.Writer;
@@ -67,10 +65,10 @@
ReverseFileReader reader = new ReverseFileReader(referenceFile);
//read the last line of the file (should be empty)
- String line = reader.readLine();
+ reader.readLine();
//read the next line (the last written line)
- line = reader.readLine();
+ String line = reader.readLine();
String lastMonth="";
@@ -113,12 +111,12 @@
@Override
public String getDescription() {
- return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityBiomassReferenceY9";
+ return "SensitivityBiomassReferenceY9_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeReferenceY12.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.File;
import java.io.Writer;
@@ -71,10 +69,10 @@
ReverseFileReader reader = new ReverseFileReader(referenceFile);
//read the last line of the file (should be empty)
- String line = reader.readLine();
+ reader.readLine();
//read the next line (the last written line)
- line = reader.readLine();
+ String line = reader.readLine();
String lastMonth="";
@@ -121,12 +119,12 @@
@Override
public String getDescription() {
- return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityBiomassRelativeReferenceY12";
+ return "SensitivityBiomassRelativeReferenceY12_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassRelativeY6.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -77,12 +75,12 @@
@Override
public String getDescription() {
- return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityBiomassRelativeY6";
+ return "SensitivityBiomassRelativeY6_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityBiomassY3.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -67,12 +65,12 @@
@Override
public String getDescription() {
- return _("Biomass for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityBiomassY3";
+ return "SensitivityBiomassY3_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.File;
import java.io.Writer;
@@ -114,14 +112,14 @@
@Override
public String getDescription() {
- return _("Captures in weight for the last year for the popage " +
+ return "Captures in weight for the last year for the popage " +
"population. Captures is the sum of zones, groups, metiers " +
- "and strategies");
+ "and strategies";
}
@Override
public String getExportFilename() {
- return "SensitivityCapturesWeightReferenceY7";
+ return "SensitivityCapturesWeightReferenceY7_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.File;
import java.io.Writer;
@@ -39,14 +37,15 @@
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.Doc;
-public class SensitivityCatchWeightRelativeReferenceY10 implements
- SensitivityExport {
+public class SensitivityCatchWeightRelativeReferenceY10 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory
.getLog(SensitivityCatchWeightRelativeReferenceY10.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
@Doc("Population")
public Population param_pop;
@@ -129,12 +128,12 @@
@Override
public String getDescription() {
- return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies");
+ return "Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies";
}
@Override
public String getExportFilename() {
- return "SensitivityCapturesWeightRelativeReferenceY10";
+ return "SensitivityCapturesWeightRelativeReferenceY10_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -43,7 +41,9 @@
static private Log log = LogFactory
.getLog(SensitivityCatchWeightRelativeY4.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
@Doc("Population")
public Population param_pop;
@@ -85,12 +85,12 @@
@Override
public String getDescription() {
- return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies");
+ return "Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies";
}
@Override
public String getExportFilename() {
- return "SensitivityCapturesWeightRelativeY4";
+ return "SensitivityCapturesWeightRelativeY4_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
import java.io.Writer;
import org.apache.commons.logging.Log;
@@ -43,7 +41,9 @@
static private Log log = LogFactory
.getLog(SensitivityCatchWeightY1.class);
- protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
@Doc("Population")
public Population param_pop;
@@ -76,12 +76,12 @@
@Override
public String getDescription() {
- return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies");
+ return "Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies";
}
@Override
public String getExportFilename() {
- return "SensitivityCapturesWeightY1";
+ return "SensitivityCapturesWeightY1_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,43 +21,42 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.File;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.types.TimeStep;
+import fr.ifremer.isisfish.util.Doc;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixIterator;
import org.nuiton.math.matrix.MatrixND;
-
import org.nuiton.topia.TopiaContext;
import org.nuiton.util.ReverseFileReader;
import scripts.ResultName;
-import fr.ifremer.isisfish.datastore.ResultStorage;
-import fr.ifremer.isisfish.datastore.SimulationStorage;
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.entities.PopulationGroup;
-import fr.ifremer.isisfish.export.SensitivityExport;
-import fr.ifremer.isisfish.types.TimeStep;
-import fr.ifremer.isisfish.util.Doc;
+import java.io.File;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
public class SensitivitySpawningBiomassReferenceY8 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory
.getLog(SensitivitySpawningBiomassReferenceY8.class);
- protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_BIOMASS
+ };
@Doc("Population")
public Population param_pop;
@Doc("URL of the Biomasses.csv reference export file")
- public String param_referenceBiomassCSV ="";
+ public String param_referenceBiomassCSV = "";
@Override
public void export(SimulationStorage simulation, Writer out)
@@ -78,7 +77,7 @@
Map<Integer, Double> map =new HashMap<Integer,Double>();
for (PopulationGroup group:groups) {
- map.put(group.getId(),group.getReproductionRate());
+ map.put(group.getId(),group.getMaturityOgive());
}
tx.closeContext();
@@ -110,6 +109,7 @@
}
line = reader.readLine();
}
+ reader.close();
for (Population pop : simulation.getParameter().getPopulations()) {
if (pop.getName().equals(param_pop.getName())) {
@@ -123,22 +123,23 @@
PopulationGroup group = (PopulationGroup) sems[1];
TimeStep step = (TimeStep) sems[0];
if (step.equals(lastStep)) {
- biomass += i.getValue() * group.getReproductionRate();
+ biomass += i.getValue() * group.getMaturityOgive();
}
}
}
}
+
out.write(Double.toString(biomass / referenceBiomass));
}
@Override
public String getDescription() {
- return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivitySpawningBiomassReferenceY8";
+ return "SensitivitySpawningBiomassReferenceY8_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,22 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.File;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixIterator;
-import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.topia.TopiaContext;
-
-import org.nuiton.util.ReverseFileReader;
-import scripts.ResultName;
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Population;
@@ -44,7 +28,20 @@
import fr.ifremer.isisfish.export.SensitivityExport;
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.Doc;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.util.ReverseFileReader;
+import scripts.ResultName;
+import java.io.File;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
public class SensitivitySpawningBiomassRelativeReferenceY11 implements
SensitivityExport {
@@ -58,7 +55,7 @@
public Population param_pop;
@Doc("URL of the Biomasses.csv reference export file")
- public String param_referenceBiomassCSV ="";
+ public String param_referenceBiomassCSV = "";
@Override
public void export(SimulationStorage simulation, Writer out)
@@ -83,7 +80,7 @@
Map<Integer, Double> map =new HashMap<Integer,Double>();
for (PopulationGroup group:groups) {
- map.put(group.getId(),group.getReproductionRate());
+ map.put(group.getId(),group.getMaturityOgive());
}
tx.closeContext();
@@ -120,6 +117,7 @@
line = reader.readLine();
}
+ reader.close();
for (Population pop : simulation.getParameter().getPopulations()) {
if (pop.getName().equals(param_pop.getName())) {
@@ -134,7 +132,7 @@
TimeStep step = (TimeStep) sems[0];
if (step.equals(firstStep)) {
firstbiomass += i.getValue()
- * group.getReproductionRate();
+ * group.getMaturityOgive();
}
}
@@ -148,23 +146,24 @@
TimeStep step = (TimeStep) sems[0];
if (step.equals(lastStep)) {
biomass = biomass + i.getValue()
- * group.getReproductionRate();
+ * group.getMaturityOgive();
}
}
}
}
+
out.write(Double.toString((biomass / firstbiomass)
/ (biomassReference / firstBiomassReference)));
}
@Override
public String getDescription() {
- return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivitySpawningBiomassRelativeReferenceY11";
+ return "SensitivitySpawningBiomassRelativeReferenceY11_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,16 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixIterator;
-import org.nuiton.math.matrix.MatrixND;
-
-import scripts.ResultName;
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Population;
@@ -38,14 +28,24 @@
import fr.ifremer.isisfish.export.SensitivityExport;
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.Doc;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+
+import java.io.Writer;
+
public class SensitivitySpawningBiomassRelativeY5 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory
.getLog(SensitivitySpawningBiomassRelativeY5.class);
- protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_BIOMASS
+ };
@Doc("Population")
public Population param_pop;
@@ -72,7 +72,7 @@
TimeStep step = (TimeStep) sems[0];
if (step.equals(firstStep)) {
firstbiomass += i.getValue()
- * group.getReproductionRate();
+ * group.getMaturityOgive();
}
}
@@ -85,7 +85,7 @@
PopulationGroup group = (PopulationGroup) sems[1];
TimeStep step = (TimeStep) sems[0];
if (step.equals(lastStep))
- biomass += i.getValue() * group.getReproductionRate();
+ biomass += i.getValue() * group.getMaturityOgive();
}
}
}
@@ -94,12 +94,12 @@
@Override
public String getDescription() {
- return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityGenitorBiomassRelativeY5";
+ return "SensitivityGenitorBiomassRelativeY5_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Jean Couteau, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,16 +21,6 @@
*/
package sensitivityexports;
-import static org.nuiton.i18n.I18n._;
-
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixIterator;
-import org.nuiton.math.matrix.MatrixND;
-
-import scripts.ResultName;
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Population;
@@ -38,14 +28,24 @@
import fr.ifremer.isisfish.export.SensitivityExport;
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.util.Doc;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import scripts.ResultName;
+
+import java.io.Writer;
+
public class SensitivitySpawningBiomassY2 implements SensitivityExport {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory
.getLog(SensitivitySpawningBiomassY2.class);
- protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS };
+ protected String[] necessaryResult = {
+ ResultName.MATRIX_BIOMASS
+ };
@Doc("Population")
public Population param_pop;
@@ -69,7 +69,7 @@
TimeStep step = (TimeStep) sems[0];
PopulationGroup group = (PopulationGroup) sems[1];
if (step.equals(lastStep)) {
- biomass += i.getValue() * group.getReproductionRate();
+ biomass += i.getValue() * group.getMaturityOgive();
}
}
}
@@ -79,12 +79,12 @@
@Override
public String getDescription() {
- return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones");
+ return "Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones";
}
@Override
public String getExportFilename() {
- return "SensitivityGenitorBiomassY2";
+ return "SensitivityGenitorBiomassY2_" + param_pop.getName();
}
@Override
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/CalibrationSimplexePasVariable2Capturabilite.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2007 - 2011 Ifremer, CodeLutin, Sigrid Lehuta
+ * Copyright (C) 2007 - 2014 Ifremer, CodeLutin, Sigrid Lehuta
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,15 +21,12 @@
*/
package simulationplans;
-import static org.nuiton.i18n.I18n._;
-
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import fr.ifremer.isisfish.util.ScriptUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixIterator;
@@ -38,16 +35,16 @@
import org.nuiton.util.FileUtil;
import org.nuiton.util.StringUtil;
+import scripts.ResultName;
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationGroup;
-import fr.ifremer.isisfish.simulator.SimulationPlanContext;
import fr.ifremer.isisfish.simulator.SimulationPlan;
+import fr.ifremer.isisfish.simulator.SimulationPlanContext;
import fr.ifremer.isisfish.util.Doc;
+import fr.ifremer.isisfish.util.ScriptUtil;
-import scripts.ResultName;
-
/**
* CalibrationSimplexePasVariable2Capturabilite.
*
@@ -111,7 +108,7 @@
//*** write the name of the simulated matrix that contains the data corresponding
// to your observations (here MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP)
- public String[] necessaryResult = {
+ protected String[] necessaryResult = {
ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
};
@@ -124,9 +121,9 @@
* @return L'aide ou la description du plan
*/
public String getDescription() throws Exception {
- return _("Calibration using variable step Simplex method (Walters): user" +
+ return "Calibration using variable step Simplex method (Walters): user" +
"gives a file of observations (here catches)(.csv), simulated output" +
- "will try to approach oservations by changing the values of catchability");
+ "will try to approach oservations by changing the values of catchability";
}
/**
@@ -156,7 +153,8 @@
double worst2;
/**
- * Call before each simulation
+ * Call before each simulation.
+ *
* @param context plan context
* @param nextSimulation storage used for next simulation
* @return true if we must do next simulation, false to stop plan
@@ -483,4 +481,4 @@
}
}
-}
+}
\ No newline at end of file
Copied: branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/RecuitSimuleSimulateur.java (from rev 4095, trunk/src/test/resources/test-database/simulationplans/RecuitSimuleSimulateur.java)
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/RecuitSimuleSimulateur.java (rev 0)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/RecuitSimuleSimulateur.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -0,0 +1,638 @@
+package simulationplans;
+
+/*
+ * #%L
+ * IsisFish
+ * %%
+ * Copyright (C) 1999 - 2014 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import static org.nuiton.i18n.I18n._;
+
+import java.io.File;
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixIterator;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.StringUtil;
+
+import fr.ifremer.isisfish.datastore.ResultStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.simulator.SimulationException;
+import fr.ifremer.isisfish.simulator.SimulationPlanContext;
+import fr.ifremer.isisfish.simulator.SimulationPlan;
+import fr.ifremer.isisfish.util.Doc;
+
+import scripts.ResultName;
+
+/**
+ * RecuitSimule.
+ *
+ * Created:
+ *
+ * @author
+ * @version
+ *
+ * Last update:
+ * by :
+ */
+
+// ////////////////////////////////////////////////////////////////////////
+// USER GUIDE
+//-------------------------------------------------------------------------
+// Script must be adapted to the case study (calibration data, catchability assumptions)
+// Script won't compile as it stands
+// Comments preceeded by /////*** explain where and how to adapt the script
+// Access to the APIs is free
+// ////////////////////////////////////////////////////////////////////////
+
+// ***You can modify class name if you want
+// ***BUT attention : file name and class name must be the same (without the extention ".java"),
+// ie here : "RecuitSimule"
+
+public class RecuitSimuleSimulateur implements SimulationPlan {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory
+ .getLog(RecuitSimuleSimulateur.class);
+
+ /////***here must appear the path to export the historic file ("Historic.csv")
+ //in which all information about each simulation is stored
+ /////***Attention : before beginning a new calibration rename any potential
+ //old Historic.csv files or they will be lost
+ protected File exportHistoric = new File("Historic.csv");
+
+ protected String exportHisto = "";
+
+ @Doc("Population which parameters are calibrated")
+ public Population param_Population = null;
+ @Doc("Lower values of parameters, separated with semicolons: de la forme(\"xx1;xx2;xx3\")")
+ public String param_borneInf = "2.42e-5;2.11e-6";// devient un parametre du plan d analyse/// Rentrer ici les bornes inférieruers de chaque paramètre.
+ @Doc("Upper values of parameters, separated with semicolons: de la forme(\"xx1;xx2;xx3\"); Keep the order used to fill borneInf.")
+ public String param_borneSup = "2.42e-5;2.11e-6";// devient un parametre du plan d analyse/// Rentrer ici les bornes supérieruers de chaque paramètre.
+ @Doc("Cooling schedule : choose between \"Van Laarhoven\", \"Huang\", \"Triki\", \"Geometric\", \"Lundy\", \"Constant\" and \"Linear\".")
+ public String param_coolingSchedule = "Triki"; // Attention aux méthodes à valeurs à fixer par l'utilisateur.
+ //public long param_seed = 1;
+
+ String [] borneInf;
+ String [] borneSup;
+ int taille;
+
+ int current;
+ int compteurSimus;
+ int compteurTemperature;
+ int compteurAccept;
+ double deltaEnergy;
+ SecureRandom random;
+ double rhoValue;
+ boolean bool;
+ double obj;
+
+ /////***hasard1,2,3, etc => des méthodes de hasard à déterminer, à placer en début de script. Pour le moment, elles ne font que de l'uniforme, à nous de voir ce qui est le mieux et pourquoi
+ public int hasard1(){
+ int result = random.nextInt(taille);
+ return result;
+ }
+ public int hasard2(){
+ int result = random.nextInt();
+ return result;
+ }
+ public double hasard3(){
+ double result = random.nextDouble();
+ return result;
+ }
+ public double hasardUniforme(){
+ double result = random.nextDouble();
+ return result;
+ }
+
+ //int seuilTemperature=5;// Laissés au choix de l'utilisateur. Dans l'interface, proposer des méthodes pour faire évoluer les seuils?
+ //int seuilAcceptance=3;
+ double seuilArret=0.01; //Sera utilisé en fonction du critèe d'arrêt utilisé...son cas est encore à trancher.
+
+ // ***put here the path and name of the file containing the data used to calibrate
+ // your fishery ( here observed landings per season and age groups)
+ @Doc(value = "file name and path of observed landings")
+ public String param_nomfichier_debarquements = "Observedlandings2001-2003.csv";
+ protected File debarquementsObserves;
+ protected MatrixND matrixDebarquement;
+
+ ArrayList<Experience> historique = new ArrayList<Experience>(); //historique va contenir tout l'historique de l'algorithme, c'est un ArrayList d'Experience.
+ //*** double temperature=???; //Initialisation de la température. Pour le moment, à l'utilisateur de remplacer ??? par un double dans le script.
+
+ //*** write the name of the simulated matrix that contains the data corresponding
+ // to your observations (here MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP)
+ public String[] necessaryResult = {
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP
+ };
+
+ public String[] getNecessaryResult() {
+ return this.necessaryResult;
+ }
+
+ /**
+ * Permet d'afficher a l'utilisateur une aide sur le plan.
+ * @return L'aide ou la description du plan
+ */
+ public String getDescription() throws Exception {
+ return _("Calibration using simulated annealing: user" +
+ "gives a file of observations (here catches)(.csv), simulated output" +
+ "will try to approach oservations by changing the values of catchability");
+ }
+
+
+ /**
+ * Appele au demarrage de la simulation, cette methode permet d'initialiser
+ * des valeurs
+ * @param context La simulation pour lequel on utilise cette regle
+ */
+ public void init(SimulationPlanContext context) throws Exception {
+ random = new SecureRandom();
+ //random.setSeed(param_seed);
+
+ if (param_nomfichier_debarquements == null
+ || "".equals(param_nomfichier_debarquements)) {
+ debarquementsObserves = FileUtil.getFile(".*.csv",
+ "fichier csv separateur ';'");
+ } else {
+ debarquementsObserves = new File(param_nomfichier_debarquements);
+ }
+
+ // ***Create the matrix named matrixDebarquement that will contain your observed landings
+ // method: MatrixFactory.getInstance().create()
+ // ***Then import your file in it
+ // method : matrixDebarquement.importCSV();
+ log.info("MatrixDebarquement : " + matrixDebarquement);
+
+ borneInf=param_borneInf.split(";");
+ borneSup=param_borneSup.split(";");
+ taille=borneInf.length;
+
+ }
+
+ /**
+ *Crée (*@see createExperience) une nouvelle expérience (le contructeur modifie la paramétrisation parente ou en initialise une si c'est la première), baisse la température si nécessaire(*@see baisse), modifie la base de données(*@see changeDB).
+ *@param context plan context
+ *@param nextSimulation storage for the next simulation
+ *@return true if we must do next simulation, false to stop plan
+ *@throws Exception
+ */
+
+ public boolean beforeSimulation(SimulationPlanContext context,
+ SimulationStorage nextSimulation) throws Exception {//Dans le before, on modifie la paramétrisation actuelle, on enregistre cette modification, on change la base de données.
+ compteurSimus=getIteration(nextSimulation); //numéro de la simulation à venir
+ Experience expCurrent;
+
+ if (compteurSimus==0){//En considérant que la numérotation des simulations commence à 0, on traite ici la premièe simulation.
+ expCurrent = createExperience(compteurSimus, null);
+ expCurrent.accepted = true;
+ }
+ else {
+ Experience expPrev = historique.get(compteurSimus - 1);
+ expCurrent = createExperience(compteurSimus, expPrev);
+ expCurrent.temperature = baisse(expCurrent);
+ }
+
+ changeDB(expCurrent, nextSimulation);
+ return true;
+ }
+
+ /**
+ *Récupère les résultats de la simulation, calcule la fonction d'objectif(*@see calculFonctionObjectif), accepte ou non la nouvelle paramétrisation et décide la paramétrisation parente(*@see acceptationSolution) et vérifie le critère d'arrêt(*@see isCritereArretAtteint).
+ *@param context plan context
+ *@param lastSimulation storage for the next simulation
+ *@return true if we must do next simulation, false to stop plan
+ *@throws Exception
+ *@see getIteration
+ */
+ public boolean afterSimulation(SimulationPlanContext context,
+ SimulationStorage lastSimulation) throws Exception{//Dans l'after, on évalue la nouvelle paramétrisation, on met en compétition cette paramétrisation
+ //avec celle de référence (celle de l'itération current), on modifie la température, on vérifie que le
+ //critèe d'arrêt de l'algorithme n'est pas atteint, on enregistre toutes les modifications dans la table historique.
+ ResultStorage result = lastSimulation.getResultStorage();
+ boolean bool=true;
+ compteurSimus=getIteration(lastSimulation); //numéro de la simulation qui vient de se terminer
+ Experience expCurrent = historique.get(compteurSimus);
+ double obj=calculFonctionObjectif(result);
+ expCurrent.objective = obj;
+
+ if (compteurSimus > 0){
+ if (obj < expCurrent.best.objective){//On compare la nouvelle paramétrisation à la meilleure paramétrisation
+ expCurrent.best = expCurrent;
+ }
+ acceptationSolution(expCurrent);//On compare la nouvelle paramétrisation à la paramétrisation courante et on décide qui sera la courante.
+ //if (isModifierTemperature()){//Pour le moment, les méthodes proposées modifient la température à chaque fois. On intégrera un système de phase et de vérification de critère de température plus tard, si besoin.
+ /*}
+ else{
+ historique.get(compteurSimus).temperature = getExperience(compteurSimus-1).temperature;
+ }*/
+ bool=isCritereArretAtteint(expCurrent);
+ }
+ return bool;
+ }
+
+////////////////////
+////////////////////
+/// ///
+///AUTRES CLASSES///
+/// ///
+////////////////////
+////////////////////
+
+ protected Parameter[] copyM1(Parameter[]M1){
+ Parameter[] result = new Parameter[M1.length];
+ for (int i=0,maxi=M1.length; i<maxi; i++) {
+ result[i] = M1[i].copy();
+ }
+ return result;
+ }
+
+ class Parameter {
+ double value;
+ double inf;
+ double sup;
+
+ public Parameter (double valeur, double borneinf, double bornesup){
+ /*if (borneinf >= bornesup) {
+ throws SimulationException(String.format("Error: inf(%s) >= sup(%s)", borneinf, bornesup));
+ }*/
+ value=valeur;
+ inf=borneinf;
+ sup=bornesup;
+ }
+
+ public Parameter copy() {
+ return new Parameter(value, inf, sup);
+ }
+ }
+
+ class Experience{// 1 objet Experience contient toutes les informations sur la passage de l'état current à l'état suivant.
+ public int id;
+ public Experience parent;
+ public Experience best;
+ public boolean accepted;
+
+ public double rho;
+ public double rand;
+ public Parameter[] parametrisation; //On enregistre la paramétrisation et les bornes, tout est nécessaire en cas de ré-utilisation.
+ public double objective;
+ public double temperature;
+
+ public Experience(int id, Experience parent) {
+ this.id = id;
+ this.parent = parent;
+
+ if (parent == null) {
+ best = this;
+ parametrisation = initM1();
+ } else {
+ best = parent.best;
+
+ Parameter[] M1=copyM1(parent.getParametrisation());
+ modif(M1);
+ parametrisation = M1;
+ }
+ }
+
+ /**
+ * recherche de la 1ere experience accepte et retourne parametrisation
+ */
+ public Parameter[] getParametrisation() {
+ Parameter[] result = parametrisation;
+ if (!accepted) {
+ result = parent.getParametrisation();
+ }
+ return result;
+ }
+
+ /*public String toCSV() {
+ String sep = ";";
+ String result = "";
+
+ result += id + sep;
+ result += accepted + sep;
+ result += rand + sep;
+ result += rho + sep;
+ result += objective + sep;
+ result += temperature + sep;
+ result += parametrisation.value + sep;
+ result += parent.id + sep;
+ result += best.id + sep;
+
+ return result;
+ }*/
+ }
+
+////////////////////
+////////////////////
+/// ///
+/// METHODES ///
+/// ///
+////////////////////
+////////////////////
+
+ /**
+ *Retourne l'experience à l'index i dans la table historique, crée l'experience si elle n'existe pas encore.
+ *@param i l'index de l'Experience demandée
+ *@return l'Experience i
+ */
+
+ public Experience createExperience(int id, Experience parent){
+ Experience result = new Experience(id, parent);
+ historique.add(result);
+ return result;
+ }
+
+ /**
+ *Baisse la température selon une certaine méthode. Appellé par @see modifierTemperature
+ *@param compteurSimus la simulation qui vient de s'achever
+ *@return la température baissée
+ */
+ //En faire une fonction de compteurSimus pour que toutes les méthdoes marchaent!
+ public double baisse(Experience expCurrent){
+ double temperature = expCurrent.temperature;
+ double result=0;
+ //Méthode pour faire baisser la température. Il peut y en avoir plusieurs, l'idée étant de pouvoir basculer d'une méthode à l'autre pendant l'algorithme;
+
+ //Van Laarhoven et al. (1987)
+ if (param_coolingSchedule.equals("Van Laarhoven")){
+ double delta=0.001;// Valeur à fixer par l'utilisateur
+ double obj = expCurrent.objective;
+ double sigmasquare=(obj*obj-obj)*(obj*obj-obj);
+ double sigma=Math.sqrt(sigmasquare);
+ result = temperature*(1/(1+(Math.log(1+delta))*temperature/(3*sigma)));
+ }
+ //Huang et al. (1986)
+ if (param_coolingSchedule.equals("Huang")){
+ double lambda =0.5;// 0<lambda<=1 à fixer par l'utilisateur
+ double obj = expCurrent.objective;
+ double sigmasquare=(obj*obj-obj)*(obj*obj-obj);
+ double sigma=Math.sqrt(sigmasquare);
+ result=temperature*Math.exp(-lambda*temperature/sigma);
+ }
+ // Triki et al. (2005)
+ if (param_coolingSchedule.equals("Triki")){
+ double obj = expCurrent.objective;
+ double objCurrent=historique.get(expCurrent.parent.id).objective;
+ double delta=obj-objCurrent;
+ double sigmasquare=(obj*obj-obj)*(obj*obj-obj);
+ result= temperature*(1-temperature*delta/sigmasquare);
+ }
+ // Géométrique (décrit dans Triki et al. (2005))
+ if (param_coolingSchedule.equals("Geometric")){
+ double alpha =0.5; // 0<alpha<1 à fixer par l'utilisateur
+ result=alpha*temperature;
+ }
+ // Lundy et al. (1986)
+ if (param_coolingSchedule.equals("Lundy")){
+ //double beta=???; // Voir à quoi ça correspond
+ //result= temperature*(1/(1+beta*temperature));
+ }
+ // Fixe
+ if (param_coolingSchedule.equals("Constant")){
+ result=temperature; //Il faut fixer une bonne température, voir Cohn et Connolly pour plus de renseignements.
+ }
+ //Linéaire
+ if (param_coolingSchedule.equals("Linear")){
+ //double baisse =???// A fixer par l'utilisateur
+ //result=temperature-baisse;
+ }
+ return result;
+ }
+
+ /**
+ *Initialise une paramétrisation avant la première simulation à partir des bornes de chaque paramètre selon une loi uniforme
+ *@return la paramétrisation initialisée.
+ */
+ public Parameter[] initM1(){
+ //Méthode 1 : initialisation selon une loi uniforme entre les bornes de chaque paramètre.
+ Parameter M1[] = new Parameter[taille];
+ for (int i=0; i<taille; i++){
+ double uni=hasardUniforme();
+ double inf = Double.parseDouble(borneInf[i]);
+ double sup = Double.parseDouble(borneSup[i]);
+ double val= inf+uni*(sup-inf);
+ Parameter param = new Parameter(val, inf, sup);
+ M1[i]=param;
+ }
+
+ //Méthode 2 => On peut proposer plusieurs méthodes d'initiation dans l'interface? Lois de Poisson, Gauss, etc.
+ //etc.
+ return M1;
+ }
+
+ /**
+ * Modify nextSimulation database with parameters in Experience exp.
+ * @param exp the Experience in process
+ * @param nextSimulation storage for the next simulation
+ * @throws Exception
+ */
+ protected void changeDB(Experience exp, SimulationStorage nextSimulation)
+ throws Exception {
+ // methode appelee dans before simualtion
+ TopiaContext db = nextSimulation.getStorage().beginTransaction();//ouvrir un context pour modifier les donnees
+ Population pop = (Population) db.findByTopiaId(param_Population.getTopiaId()); //reccupere la pop ciblee
+ MatrixND c = pop.getCapturability(); // reccupere la matrice de capturabilité
+
+ // *** that is where you explain how to fill the catchability matrix with q1 and q2
+ for (MatrixIterator i = c.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sem = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup) sem[0];
+
+ // *** exemple when q2 corresponds to the 12 first groups (groups 0 to 11)
+ if (group.getId() < 12) {
+ i.setValue(exp.parametrisation[1].value);
+ } else {
+ i.setValue(exp.parametrisation[0].value);
+ }
+
+ // *** exemple when it depends on seasons and groups
+ /*PopulationSeasonInfo season = (PopulationSeasonInfo) sem[1];
+ if (season.getFirstMonth().after(Month.JULY) && group.getId() >=18){ //month >= aout && groupID >= 18
+ i.setValue(exp.q2);
+ } else {
+ i.setValue(exp.q1);
+ } */
+ }//fin du for
+
+ db.commitTransaction(); // effectue la modification
+ db.closeContext(); // ferme le context
+ }
+
+ /**
+ *Modifie une paramétrisation, utilise une méthode pour modifier paramètre par paramètre
+ *@param M1 la paramétrisation à modifier
+ *@see modifParameter
+ */
+ public void modif(Parameter[] M1){
+ double nbModif=hasard1(); //Une méthode de tirage aléatoire à coder dans une autre méthode (type getPoisson), on la mettre au début du script,
+ while (nbModif >= 0){ //où plusieurs possibilités de tirages sont proposées. L'utilisateur peut y rajouter les siennes.
+ int num=M1.length*hasard2(); //On tire au hasard entre 0 et M1.length-1 une position sur M1.
+ modifParameter(num, M1); //Modification du paramètre
+ nbModif-=1;
+ }
+ }
+
+ /**
+ *Modifie un paramètre selon une certaine méthode, appellée par @see modif
+ *@param num la position dans la paramétrisation du paramètre à modifier
+ */
+ public void modifParameter(int num, Parameter[] M1){
+ //Méthode 1
+ double amplitude = hasard3();
+ double valeur=M1[num].value;
+ M1[num].value=amplitude*valeur;
+ int MAX = 10000;
+ while (MAX > 0 && (M1[num].value<M1[num].inf || M1[num].value>M1[num].sup)){ //Tant qu'on est en dehors du domaine de définiton du paramètre, on modifie la valeur
+ amplitude = hasard3();
+ M1[num].value=amplitude*valeur;
+ MAX--;
+ }
+ /*
+ if (MAX <= 0) {
+ throws SimulationException("Can't find new value");
+ }*/
+ //Méthode 2
+ //etc. L'idée est de faire varier la manièe de faire varier delta en fcontion de l'avancement de l'algorithme.
+ }
+
+ /**
+ *Met en compétition la nouvelle solution et la solution courante (calcul de la "probabilité" d'acceptation) et décide de qui sera la solution courante, le renseigne dans l'historique des simulations.
+ *@param compteurSimus le numéro de la simulation qui vient de s'achever.
+ *@see getProba
+ */
+ public void acceptationSolution(Experience expCurrent){// Mise en compétition de l'état current et du nouvel état
+
+ deltaEnergy= expCurrent.objective - expCurrent.parent.objective;//Valeur absolue
+ double rhoValue = getProba(expCurrent, deltaEnergy);
+ expCurrent.rho = rhoValue;
+ double randValue;
+ if (rhoValue>1){
+ expCurrent.rand = 0;// rand n'a pas été tiré à cette itération.
+ expCurrent.accepted = true;
+ }else{
+ randValue=hasardUniforme();
+ if (randValue<rhoValue){
+ expCurrent.rand = randValue;
+ expCurrent.accepted = true;
+ }
+ else{
+ expCurrent.accepted = false;
+ }
+ }
+ }
+
+ /**
+ *Calcule la valeur de la fonction d'objectif de la paramétrisation utilisée pour la simulation qui vient de s'achever.
+ *@param result le numéro de la simulation venant de s'achever
+ *@return la valeur de fonction d'objectif
+ */
+ public double calculFonctionObjectif(ResultStorage result){//Inclut l'import des données, des résultats de la simulation et le calcul de la fonction d'objectif;
+ /////***import the matrix of simulated data (here landings) from the simulation result
+ MatrixND L = result.getMatrix(param_Population,
+ ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
+ /////*** extract, sum, etc to obtain the same format/data as your observation matrix
+ // useful methods to work on matrix : sumOverDim(), getSubMatrix(), reduce()
+
+ ///////////////////Calcul du critere//////////////////
+ log.info("calcul de la fonction objectif");
+ log.info("dim de L" + " " + Arrays.toString(L.getDim()));
+ log.info("dim de obs" + " "
+ + Arrays.toString(matrixDebarquement.getDim()));
+
+ double obj = 0;
+ // *** using the matrixIterator assumes that the observation and simulated
+ // matrix are organised in the exact same way ( columns and rows corresponding in each of them)
+ for (MatrixIterator g = L.iterator(); g.hasNext();) {
+ g.next();
+ int[] dim = g.getCoordinates();
+ double obs = matrixDebarquement.getValue(dim);
+ double simules = g.getValue();
+ obj += Math.pow(obs - simules, 2);
+ }
+ return obj;
+ }
+
+ /**
+ *Vérifie si le critère d'arrêt de l'algorithme est atteint, les critères pouvant changer selon les préférences de l'utilisateur.
+ *@param compteurSimus le numéro de la simulation qui vient de s'achever
+ *@return true si le critère est atteint, false sinon.
+ */
+ public boolean isCritereArretAtteint(Experience expCurrent){// Critèe à choisir? A rendre variable au cours de l'algorithme? (autant sur le critèe d'une méthode que sur la méthode employée?)
+ //Méthode 1
+ double deltaEnergy = expCurrent.objective - expCurrent.parent.objective;
+ boolean bool = deltaEnergy < seuilArret; //seuil à déterminer
+
+ /*
+ if (temperature<seuilArret) //seuil à déterminer
+ double temperature = getExperience(compteurSimus).temperature
+ bool=true;
+
+ if (compteurSimus>seuilArret) //seuil à déterminer
+ bool=true;
+
+ //Méthode 4 numéro de phase...vraiment?
+ */
+ //etc.
+ return bool;
+ }
+
+ /**
+ *Calcule ce qu'on appelle (abusivement) la probabilité d'accepter la nouvelle paramétrisation, appelée par @see acceptationSolution
+ *@param deltaEnergy la différence de fonction d'objectif entre la nouvelle paramétrisation et la paramétrisation courante
+ *@return la "probabilité"
+ */
+ public double getProba(Experience expCurrent, double deltaEnergy){
+ double temp = expCurrent.temperature;
+ double proba = Math.exp(deltaEnergy/temp);
+ return proba;
+ }
+ /*
+ /**
+ *Vérifie si le critère de modification de la température est atteint, les critères pouvant varier selon les préférences de l'utilisateur.
+ *@return true s'il faut modifier la température (@see modifierTemperature), false sinon.
+ *:/
+ public boolean isModifierTemperature(){//Renvoie un booléen qui indique s'il faut changer ou non la température.
+ boolean bool=false;
+ if (compteurTemperature>seuilTemperature || compteurAccept>seuilAcceptance){//seuils à fixer/déterminer
+ bool=true;
+ }
+ return bool;
+ }
+ */
+
+ /**
+ *Récupère le numéro de la simulation renseignée
+ *@param simulation storage de la simulationr enseignée
+ *@return numéro de la simulation renseignée
+ */
+ public int getIteration(SimulationStorage simulation){ //Il n'y a pas de setIteration
+ return simulation.getParameter().getSimulationPlanNumber();
+ }
+}
\ No newline at end of file
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/SimulationNumberRestriction.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/SimulationNumberRestriction.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/simulationplans/SimulationNumberRestriction.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, CodeLutin
+ * Copyright (C) 2006 - 2014 Ifremer, CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -21,8 +21,6 @@
*/
package simulationplans;
-import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,11 +47,11 @@
@Doc(value = "do the doc of param max")
public int param_max = 10;
- public String[] necessaryResult = {
- // put here all necessary result for this rule
- // example:
- // ResultName.MATRIX_BIOMASS,
- // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
+ protected String[] necessaryResult = {
+ // put here all necessary result for this rule
+ // example:
+ // ResultName.MATRIX_BIOMASS,
+ // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
};
@Override
@@ -68,7 +66,7 @@
*/
@Override
public String getDescription() throws Exception {
- return _("Permit to specify maximum simulation numbers");
+ return "Permit to specify maximum simulation numbers";
}
/**
@@ -85,10 +83,8 @@
/**
* Call before each simulation
*
- * @param context
- * plan context
- * @param nextSimulation
- * storage used for next simulation
+ * @param context plan context
+ * @param nextSimulation storage used for next simulation
* @return true if we must do next simulation, false to stop plan
* @throws Exception
*/
@@ -102,8 +98,7 @@
/**
* Call after each simulation
*
- * @param context
- * plan context
+ * @param context plan context
* @param lastSimulation storage used for last simulation
* @return true if we must do next simulation, false to stop plan
* @throws Exception
Modified: branches/4.3.0-log4j2/src/test/resources/test-database/simulators/DefaultSimulator.java
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/simulators/DefaultSimulator.java 2014-08-11 13:49:52 UTC (rev 4095)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/simulators/DefaultSimulator.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -2,7 +2,7 @@
* #%L
* IsisFish data
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
+ * Copyright (C) 2006 - 2014 Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -19,24 +19,8 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
-
package simulators;
-import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.n_;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixFactory;
-import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-
-import scripts.GravityModel;
-import scripts.ResultName;
-import scripts.SiMatrix;
import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.entities.Metier;
@@ -51,13 +35,27 @@
import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.Simulator;
+import fr.ifremer.isisfish.types.Month;
import fr.ifremer.isisfish.types.TimeStep;
-import fr.ifremer.isisfish.types.Month;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixFactory;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import scripts.GravityModel;
+import scripts.ResultName;
+import scripts.SiMatrix;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.t;
+import static org.nuiton.i18n.I18n.n;
+
/**
* DefaultSimulator.java
*
- * Created: 21 août 2006 10:57:46
+ * Created: 21 aout 2006 10:57:46
*
* @author poussin
* @version $Revision: 1.19 $
@@ -134,12 +132,12 @@
control.setStep(step);
control.setProgress(step.getStep());
- control.setText(_("begin step " + step));
+ control.setText(t("begin step " + step));
//
// Reload parameters for current step
//
- control.setText(_("Reloading parameters"));
+ control.setText(t("Reloading parameters"));
// reload context parameters with db.rollbackTransaction() context
param.reloadContextParameters();
rules = param.getRules();
@@ -217,11 +215,12 @@
for (Population pop : siMatrix.getPopulations(step)) {
computeMonth(context, siMatrix, step, pop);
}
-
+
//
// Add some result not population dependante
//
+
// only if there are one or more strategy
if (siMatrix.getStrategies(step).size() > 0) {
@@ -288,9 +287,9 @@
siMatrix.getMetiers(step),
pop.getPopulationGroup(),
pop.getPopulationZone() },
- new String[] { n_("Strategies"),
- n_("Metiers"), n_("Groups"),
- n_("Zones") });
+ new String[] { n("Strategies"),
+ n("Metiers"), n("Groups"),
+ n("Zones") });
}
resManager.addResult(step, pop, discard);
@@ -309,12 +308,11 @@
// add landing result
//
if (resManager.isEnabled(ResultName.MATRIX_LANDING_PER_MET)) {
- MatrixND landing = MatrixFactory.getInstance().create(
- populationMonitor.getCatch(pop));
+ MatrixND landing = populationMonitor.getCatch(pop).copy();
+ landing.setName(ResultName.MATRIX_LANDING_PER_MET);
if (discard != null) {
landing = landing.minus(discard);
}
- landing.setName(ResultName.MATRIX_LANDING_PER_MET);
resManager.addResult(step, pop, landing);
}
}
@@ -338,6 +336,7 @@
//
step = step.next();
}
+
}
protected boolean isEffortByCell(SimulationContext context) {
@@ -375,7 +374,7 @@
PopulationSeasonInfo info = pop.getPopulationSeasonInfo(month);
// group change
- MatrixND CA = null;
+ MatrixND CA;
if (step.getStep() == 0) {
CA = MatrixFactory.getInstance().matrixId(
pop.sizePopulationGroup() * pop.sizePopulationZone());
@@ -411,7 +410,7 @@
log.debug("N after mig: " + N);
- //Recrutement
+ // reproduction
MatrixND R = info.getReproductionMatrix(month, N);
log.debug("R: " + R);
@@ -440,7 +439,7 @@
resManager.addResult(step, pop, biomassBM);
}
- MatrixND abundance = N;
+ MatrixND abundance;
// compute fishing matrix only if there are one or more strategy
if (siMatrix.getStrategies(step).size() > 0) {
// compute some Matrix and add result
@@ -481,7 +480,7 @@
.matrixCatchWeightPerStrategyMetPerZonePop(step, pop,
catchPerStrategyMetPerZonePop);
resManager.addResult(step, pop, catchWeightPerStrategyMet);
- }
+ }
if (isEffortByCell(context)) {
MatrixND catchPerStrategyMetPerZoneMet = siMatrix
@@ -497,6 +496,21 @@
}
}
+ if (resManager.isEnabled(ResultName.MATRIX_FISHING_MORTALITY_PER_GROUP) ||
+ resManager.isEnabled(ResultName.MATRIX_TOTAL_FISHING_MORTALITY)) {
+ MatrixND fishingMortalityPerGroup = siMatrix.fishingMortalityPerGroup(step,
+ pop, context.getSimulationStorage().getResultStorage());
+
+ if (resManager.isEnabled(ResultName.MATRIX_FISHING_MORTALITY_PER_GROUP)) {
+ resManager.addResult(step, pop, fishingMortalityPerGroup);
+ }
+
+ if (resManager.isEnabled(ResultName.MATRIX_TOTAL_FISHING_MORTALITY)) {
+ MatrixND totalFishingMortality = siMatrix.totalFishingMortality(step, pop, fishingMortalityPerGroup);
+ resManager.addResult(step, pop, totalFishingMortality);
+ }
+ }
+
} else { // no strategies
// compute only if fishing mortality =0 to apply Natural Mortality
abundance = siMatrix.matrixAbundanceSsF(N, pop, step);
@@ -512,7 +526,7 @@
}
/**
- * @param date
+ * @param step
* @param resManager
* @throws IsisFishException
* @throws TopiaException
@@ -555,10 +569,6 @@
.matrixSharedNotFixedCostsPerVessel(step);
resManager.addResult(step, mat);
}
- // if (resManager.isEnabled(ResultName.MATRIX_SHARED_FIXED_COSTS_PER_VESSEL_PER_MET)) {
- // MatrixND mat = gravityModel.matrixSharedFixedCostsPerVesselPerMet(date);
- // resManager.addResult(date, mat);
- // }
if (resManager
.isEnabled(ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_SPECIES_PER_STRATEGY_MET)) {
MatrixND mat = gravityModel
Copied: branches/4.3.0-log4j2/src/test/resources/test-database/simulators/SimulatorEffortByCell.java (from rev 4095, trunk/src/test/resources/test-database/simulators/SimulatorEffortByCell.java)
===================================================================
--- branches/4.3.0-log4j2/src/test/resources/test-database/simulators/SimulatorEffortByCell.java (rev 0)
+++ branches/4.3.0-log4j2/src/test/resources/test-database/simulators/SimulatorEffortByCell.java 2014-08-20 09:48:07 UTC (rev 4096)
@@ -0,0 +1,54 @@
+/*
+ * #%L
+ * IsisFish data
+ * %%
+ * Copyright (C) 2009 - 2014 Ifremer, Code Lutin, Benjamin Poussin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package simulators;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.simulator.SimulationContext;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.Simulator;
+
+/**
+ * Simulateur qui fixe la valeur de effortByCell a true pour force
+ * l'utilisation des calculs par cellule plutot que par zone.
+ *
+ * @author poussin
+ */
+public class SimulatorEffortByCell implements Simulator {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(SimulatorEffortByCell.class);
+
+ /**
+ * Called by isis don't modify signature
+ */
+ public void simulate(SimulationContext context) throws Exception {
+ SimulationParameter param = context.getSimulationStorage().getParameter();
+ param.getTagValue().put("effortByCell", "true");
+
+ DefaultSimulator simulator = new DefaultSimulator();
+ simulator.simulate(context);
+ }
+
+}
1
0
r4095 - trunk/src/main/java/fr/ifremer/isisfish/datastore
by echatellier@users.forge.codelutin.com 11 Aug '14
by echatellier@users.forge.codelutin.com 11 Aug '14
11 Aug '14
Author: echatellier
Date: 2014-08-11 15:49:52 +0200 (Mon, 11 Aug 2014)
New Revision: 4095
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4095
Log:
Add fixme
Modified:
trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageAbstract.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageAbstract.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageAbstract.java 2014-08-11 13:49:24 UTC (rev 4094)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageAbstract.java 2014-08-11 13:49:52 UTC (rev 4095)
@@ -679,7 +679,7 @@
// FIXME echatellier 20140811 : when reruninig again export outside of simulation
// no simulation is registred into SimulationContext thread local, so this
- // metod return no simulation
+ // method return no transaction
if (tx == null) {
// si on a pas de tx, on recherche si on est dans une simulation
1
0