r1861 - in isis-fish/trunk/src: main/java/fr/ifremer/isisfish/simulator/factors test/java/fr/ifremer/isisfish/simulator test/java/fr/ifremer/isisfish/simulator/factors
Author: chatellier Date: 2009-02-23 15:26:14 +0000 (Mon, 23 Feb 2009) New Revision: 1861 Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityCalculator.java isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/factors/ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/factors/FactorTest.java Removed: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/StatisticsCalculator.java Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/DesignPlan.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Factor.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Scenario.java Log: Improve factors, add test. Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/DesignPlan.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/DesignPlan.java 2009-02-23 10:30:42 UTC (rev 1860) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/DesignPlan.java 2009-02-23 15:26:14 UTC (rev 1861) @@ -21,6 +21,9 @@ import java.io.Serializable; import java.util.List; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + /** * Design plan contenant toutes les * valeur de facteur possible. @@ -65,6 +68,16 @@ public void setFactors(List<Factor<E>> factors) { this.factors = factors; } - - + + /* + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + + ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); + builder.append(factors); + + return builder.toString(); + } } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Factor.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Factor.java 2009-02-23 10:30:42 UTC (rev 1860) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Factor.java 2009-02-23 15:26:14 UTC (rev 1861) @@ -22,6 +22,9 @@ import java.util.HashMap; import java.util.Map; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + /** * Facteur de variation des parametres de simulation. * @@ -101,4 +104,91 @@ this(); this.name = name; } + + /** + * Get name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Set name. + * + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get domain. + * + * @return the domain + */ + public Map<String, E> getDomain() { + return domain; + } + + /** + * Set domain. + * + * @param domain the domain to set + */ + public void setDomain(Map<String, E> domain) { + this.domain = domain; + } + + /** + * Get value label. + * + * @return the valueLabel + */ + public String getValueLabel() { + return valueLabel; + } + + /** + * Set value label. + * + * @param valueLabel the valueLabel to set + */ + public void setValueLabel(String valueLabel) { + this.valueLabel = valueLabel; + } + + /** + * Get path. + * + * @return the path + */ + public String getPath() { + return path; + } + + /** + * Set path. + * + * @param path the path to set + */ + public void setPath(String path) { + this.path = path; + } + + /* + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + + ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); + builder.append(name); + builder.append(domain); + builder.append(valueLabel); + builder.append(path); + + return builder.toString(); + } } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Scenario.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Scenario.java 2009-02-23 10:30:42 UTC (rev 1860) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Scenario.java 2009-02-23 15:26:14 UTC (rev 1861) @@ -22,6 +22,9 @@ import java.util.List; import java.util.Map; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + /** * Scenario d'execution de simulation. * @@ -73,4 +76,15 @@ this.simulationsFactors = simulationsFactors; } + /* + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + + ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); + builder.append(simulationsFactors); + + return builder.toString(); + } } Copied: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityCalculator.java (from rev 1857, isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/StatisticsCalculator.java) =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityCalculator.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityCalculator.java 2009-02-23 15:26:14 UTC (rev 1861) @@ -0,0 +1,54 @@ +/* *##% + * Copyright (C) 2009 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package fr.ifremer.isisfish.simulator.factors; + +import java.io.Serializable; + +/** + * Interface vers le calculateur statistique. + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 19 févr. 2009 $ + * By : $Author: chatellier $ + */ +public interface SensitivityCalculator { + + /** + * Envoi un plan a faire analyser par l'outils + * statistique. + + * @param plan plan a analyser + * @param <E> type des données du scenario et du plan + * + * @return un Scenario + * @see DesignPlan + * @see Scenario + */ + <E extends Serializable> Scenario<E> getScenario(DesignPlan<E> plan); + + /** + * Ajoute un paramètre pour l'outils statistique. + * + * @param key nom du parametre + * @param value valeur du parametre + */ + void setParameter(String key, String value); +} Deleted: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/StatisticsCalculator.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/StatisticsCalculator.java 2009-02-23 10:30:42 UTC (rev 1860) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/StatisticsCalculator.java 2009-02-23 15:26:14 UTC (rev 1861) @@ -1,54 +0,0 @@ -/* *##% - * Copyright (C) 2009 Code Lutin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *##%*/ - -package fr.ifremer.isisfish.simulator.factors; - -import java.io.Serializable; - -/** - * Interface vers le calculateur statistique. - * - * @author chatellier - * @version $Revision: 1.0 $ - * - * Last update : $Date: 19 févr. 2009 $ - * By : $Author: chatellier $ - */ -public interface StatisticsCalculator { - - /** - * Envoi un plan a faire analyser par l'outils - * statistique. - - * @param plan plan a analyser - * @param <E> type des données du scenario et du plan - * - * @return un Scenario - * @see DesignPlan - * @see Scenario - */ - <E extends Serializable> Scenario<E> getScenario(DesignPlan<E> plan); - - /** - * Ajoute un paramètre pour l'outils statistique. - * - * @param key nom du parametre - * @param value valeur du parametre - */ - void setParameter(String key, String value); -} Added: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/factors/FactorTest.java =================================================================== --- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/factors/FactorTest.java (rev 0) +++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/factors/FactorTest.java 2009-02-23 15:26:14 UTC (rev 1861) @@ -0,0 +1,99 @@ +/* *##% + * Copyright (C) 2009 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package fr.ifremer.isisfish.simulator.factors; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.math.matrix.MatrixFactory; +import org.codelutin.math.matrix.MatrixND; +import org.junit.Test; + + +/** + * Factors test. + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 23 févr. 2009 $ + * By : $Author: chatellier $ + */ +public class FactorTest { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static Log log = LogFactory.getLog(FactorTest.class); + + /** + * Test to build new factors with int values. + */ + @Test + public void testIntFactor() { + + Factor<Integer> factor = new Factor<Integer>("testint"); + factor.getDomain().put("i1", 0); + factor.getDomain().put("i2", 1); + factor.getDomain().put("i3", 2); + factor.getDomain().put("i4", 3); + factor.getDomain().put("i5", 4); + factor.setPath("org.codelutin.factor#1234567890#0.12242345354#name"); + factor.setValueLabel("i3"); + + if (log.isInfoEnabled()) { + log.info("factor#toString() = " + factor); + } + } + + /** + * Test factor with matrix. + * + * @see MatrixND + */ + @Test + public void testMatrixFactor() { + + // matrix 1 + MatrixND matrix1 = MatrixFactory.getInstance().create("test1", new int[] {3,2}, new String[]{"col1", "col2"}); + matrix1.setValue(new int[]{0,0}, 13); + matrix1.setValue(new int[]{0,1}, -14); + matrix1.setValue(new int[]{1,0}, 21); + matrix1.setValue(new int[]{1,1}, 2); + matrix1.setValue(new int[]{2,0}, 12); + matrix1.setValue(new int[]{2,1}, -1); + + // matrix 2 + MatrixND matrix2 = MatrixFactory.getInstance().create("test2", new int[] {2,3}, new String[]{"col1", "col2"}); + matrix2.setValue(new int[]{0,0}, 9999); + matrix2.setValue(new int[]{0,1}, 15000); + matrix2.setValue(new int[]{0,2}, -40000); + matrix2.setValue(new int[]{1,0}, 21345); + matrix2.setValue(new int[]{1,1}, 81000); + matrix2.setValue(new int[]{1,2}, -13000); + + // factor + Factor<MatrixND> factor = new Factor<MatrixND>("testmatrix"); + factor.getDomain().put("m1", matrix1); + factor.getDomain().put("m2", matrix2); + factor.setPath("org.codelutin.math.matrix.MatrixND#563456293453#2.456347646#dim"); + factor.setValueLabel("m2"); + + if (log.isInfoEnabled()) { + log.info("factor#toString() = " + factor); + } + } +}
participants (1)
-
chatellier@users.labs.libre-entreprise.org