Author: chatellier Date: 2009-02-24 09:59:44 +0000 (Tue, 24 Feb 2009) New Revision: 1864 Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/ContinuousDomain.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/DiscreteDomain.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Domain.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityScenarios.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 isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityCalculator.java Log: Update factors classes. Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/ContinuousDomain.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/ContinuousDomain.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/ContinuousDomain.java 2009-02-24 09:59:44 UTC (rev 1864) @@ -0,0 +1,90 @@ +/* *##% + * 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; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Domaine continu. + * + * Composé d'un borne min et max. + * + * @param <E> type des valeurs gérées par le domaine + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 24 févr. 2009 $ + * By : $Author: chatellier $ + */ +public class ContinuousDomain<E extends Serializable> implements Domain<E> { + + /** serialVersionUID. */ + private static final long serialVersionUID = -2037768174807839046L; + + /** Borne inférieure */ + protected E minBound; + + /** Borne supérieure */ + protected E maxBound; + + /** + * Empty constructor. + */ + public ContinuousDomain() { + + } + + /** + * Constructor with bounds. + * + * @param minBound min bound + * @param maxBound max bound + */ + public ContinuousDomain(E minBound, E maxBound) { + this(); + this.minBound = minBound; + this.maxBound = maxBound; + } + + /** + * {@inheritDoc}. + * + * In continuous domain, just return identifier + */ + public E getValueForIdentifier(Serializable identifier) { + // FIXME test cast + return (E)identifier; + } + + /* + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + + ToStringBuilder builder = new ToStringBuilder(this); + builder.append(minBound); + builder.append(minBound); + + return builder.toString(); + } +} 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 23:14:43 UTC (rev 1863) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/DesignPlan.java 2009-02-24 09:59:44 UTC (rev 1864) @@ -22,13 +22,10 @@ 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. - * - * @param <E> type des valeurs gérées par le plan * * @author chatellier * @version $Revision: 1.0 $ @@ -36,13 +33,13 @@ * Last update : $Date: 19 févr. 2009 $ * By : $Author: chatellier $ */ -public class DesignPlan<E extends Serializable> implements Serializable { +public class DesignPlan implements Serializable { /** serialVersionUID. */ private static final long serialVersionUID = 977975461743758075L; /** Liste des facteurs a utiliser */ - protected List<Factor<E>> factors; + protected List<Factor<? extends Serializable>> factors; /** * Constructor. @@ -56,7 +53,7 @@ * * @return factors list */ - public List<Factor<E>> getFactors() { + public List<Factor<? extends Serializable>> getFactors() { return factors; } @@ -65,7 +62,7 @@ * * @param factors the factors list to set */ - public void setFactors(List<Factor<E>> factors) { + public void setFactors(List<Factor<? extends Serializable>> factors) { this.factors = factors; } @@ -75,7 +72,7 @@ @Override public String toString() { - ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); + ToStringBuilder builder = new ToStringBuilder(this); builder.append(factors); return builder.toString(); Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/DiscreteDomain.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/DiscreteDomain.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/DiscreteDomain.java 2009-02-24 09:59:44 UTC (rev 1864) @@ -0,0 +1,101 @@ +/* *##% + * 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; +import java.util.SortedMap; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Domain discret. + * + * Ensemble de valeurs. + * + * @param <E> type des valeurs gérées par le domaine + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 24 févr. 2009 $ + * By : $Author: chatellier $ + */ +public class DiscreteDomain<E extends Serializable> implements Domain<E> { + + /** serialVersionUID. */ + private static final long serialVersionUID = -192647757737396585L; + + /** + * Value for this domain. + * + * Each "E" values is identified by a Serializable identifier. + */ + protected SortedMap<Serializable, E> values; + + /** + * Contructor. + */ + public DiscreteDomain() { + + } + + /** + * Get domaine values. + * + * @return the values + */ + public SortedMap<Serializable, E> getValues() { + return values; + } + + /** + * Set domain values. + * + * @param values the values + */ + public void setValues(SortedMap<Serializable, E> values) { + this.values = values; + } + + /** + * {@inheritDoc}. + * + * @throws IllegalArgumentException if identifier is not a valid key + */ + public E getValueForIdentifier(Serializable identifier) throws IllegalArgumentException{ + + if( values == null || !values.containsKey(identifier)) { + throw new IllegalArgumentException("Can't get value for identifier " + identifier); + } + + return values.get(identifier); + } + + /* + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + + ToStringBuilder builder = new ToStringBuilder(this); + builder.append(values); + + return builder.toString(); + } +} Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Domain.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Domain.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Domain.java 2009-02-24 09:59:44 UTC (rev 1864) @@ -0,0 +1,53 @@ +/* *##% + * 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; + +/** + * Domaine du facteur. + * + * Ensemble des valeurs possibles a prendre en compte. + * La clé est un label qui permet d'identifier la valeur. + * + * Le domain peut etre : + * - discret : i.e un ensemble de valeurs + * - continu : i.e, une borne min, max + * + * @param <E> type des valeurs gérées par le domaine + * + * @see DiscreteDomain + * @see ContinuousDomain + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 24 févr. 2009 $ + * By : $Author: chatellier $ + */ +public interface Domain<E extends Serializable> extends Serializable { + + /** + * Return value associated to identifier. + * + * @param identifier + * @return found value or <tt>null</tt> if not found + */ + E getValueForIdentifier(Serializable identifier); +} 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 23:14:43 UTC (rev 1863) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Factor.java 2009-02-24 09:59:44 UTC (rev 1864) @@ -19,11 +19,8 @@ package fr.ifremer.isisfish.simulator.factors; import java.io.Serializable; -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. @@ -50,7 +47,7 @@ protected String name; /** - * Domain du facteur. + * Domaine du facteur. * * Ensemble des valeurs possibles a prendre en compte. * La clé est un label qui permet d'identifier la valeur. @@ -58,20 +55,16 @@ * Le domain peut etre : * - discret : i.e un ensemble de valeurs * - continu : i.e, une borne min, max - * - * FIXME min et max pour un domain continu ? - * FIXME domain.size() = 2 ? + * + * @see ContinuousDomain + * @see DiscreteDomain */ - protected Map<String, E> domain; + protected Domain<E> domain; /** - * Label de la valeur par defaut. - * - * Utilisation différente suivant le cas : - * - avant envoie vers R : valeur par défaut - * - apres, valeur a prendre en compte + * Factor value. */ - protected String valueLabel; + protected E value; /** * Path permettant d'identifier l'objet et @@ -91,8 +84,7 @@ * Protected, name is mandatory. */ protected Factor() { - // impl must be Serializable - domain = new HashMap<String, E>(); + } /** @@ -128,7 +120,7 @@ * * @return the domain */ - public Map<String, E> getDomain() { + public Domain<E> getDomain() { return domain; } @@ -137,27 +129,36 @@ * * @param domain the domain to set */ - public void setDomain(Map<String, E> domain) { + public void setDomain(Domain<E> domain) { this.domain = domain; } /** - * Get value label. + * Get value. * - * @return the valueLabel + * @return the value */ - public String getValueLabel() { - return valueLabel; + public E getValue() { + return value; } /** - * Set value label. + * Set value. * - * @param valueLabel the valueLabel to set + * @param value new value */ - public void setValueLabel(String valueLabel) { - this.valueLabel = valueLabel; + public void setValue(E value) { + this.value = value; } + + /** + * Set value for label. + * + * @param valueIdentifier new value identifier to get + */ + public void setValueForIdentifier(Serializable valueIdentifier) { + value = domain.getValueForIdentifier(valueIdentifier); + } /** * Get path. @@ -183,10 +184,10 @@ @Override public String toString() { - ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); + ToStringBuilder builder = new ToStringBuilder(this); builder.append(name); builder.append(domain); - builder.append(valueLabel); + builder.append(value); 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 23:14:43 UTC (rev 1863) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/Scenario.java 2009-02-24 09:59:44 UTC (rev 1864) @@ -20,15 +20,11 @@ import java.io.Serializable; 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. - * - * @param <E> type des valeurs gérées par le scenario * * @author chatellier * @version $Revision: 1.0 $ @@ -36,20 +32,17 @@ * Last update : $Date: 19 févr. 2009 $ * By : $Author: chatellier $ */ -public class Scenario<E extends Serializable> implements Serializable { +public class Scenario implements Serializable { /** serialVersionUID. */ private static final long serialVersionUID = 4953721873692486687L; /** - * Ensemble des simulations a executer. + * Ensemble des factors a prendre en compte. * - * Chaque simulation a un nom, et une liste de facteur. - * - * Chaque facteur a la {@link fr.ifremer.isisfish.simulator.factors.Factor#valueLabel} - * a prendre en compte pour la simulation. + * Chaque facteur a la {@link Factor#value} a prendre en compte pour la simulation. */ - protected Map<String, List<Factor<E>>> simulationsFactors; + protected List<Factor<? extends Serializable>> factors; /** * Constructeur. @@ -63,17 +56,17 @@ * * @return the simulations */ - public Map<String, List<Factor<E>>> getSimulationsFactors() { - return simulationsFactors; + public List<Factor<? extends Serializable>> getFactors() { + return factors; } /** * Set simulation factors. * - * @param simulationsFactors the simulations factors to set + * @param factors the simulations factors to set */ - public void setSimulationsFactors(Map<String, List<Factor<E>>> simulationsFactors) { - this.simulationsFactors = simulationsFactors; + public void setSimulationsFactors(List<Factor<? extends Serializable>> factors) { + this.factors = factors; } /* @@ -82,8 +75,8 @@ @Override public String toString() { - ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); - builder.append(simulationsFactors); + ToStringBuilder builder = new ToStringBuilder(this); + builder.append(factors); return builder.toString(); } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityCalculator.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityCalculator.java 2009-02-23 23:14:43 UTC (rev 1863) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityCalculator.java 2009-02-24 09:59:44 UTC (rev 1864) @@ -18,11 +18,14 @@ package fr.ifremer.isisfish.simulator.factors; -import java.io.Serializable; - /** - * Interface vers le calculateur statistique. + * Interface commune à toutes implémentation + * de calcul de sensibilité. * + * Les implémentations peuvent contenir des paramètres + * nommé "param_xx" (pour le paramètre xx) qui + * seront injecté par Isis. + * * @author chatellier * @version $Revision: 1.0 $ * @@ -33,22 +36,27 @@ /** * Envoi un plan a faire analyser par l'outils - * statistique. - + * d'analyse de sensibilité. + * + * Retourne un {@link SensitivityScenarios} qui + * représente l'ensemble des scenarios à prendre + * en compte pour les simulations. + * * @param plan plan a analyser - * @param <E> type des données du scenario et du plan * - * @return un Scenario + * @return un {@link SensitivityScenarios} + * * @see DesignPlan * @see Scenario + * @see SensitivityScenarios */ - <E extends Serializable> Scenario<E> getScenario(DesignPlan<E> plan); + SensitivityScenarios compute(DesignPlan plan); /** - * Ajoute un paramètre pour l'outils statistique. + * Permet de renvoyer les resultats de simulations + * à l'outils de d'analyse de sensibilité. * - * @param key nom du parametre - * @param value valeur du parametre + * @param sensitivityScenarios résultats de scenarios */ - void setParameter(String key, String value); + void analyzeResult(SensitivityScenarios sensitivityScenarios); } Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityScenarios.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityScenarios.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/factors/SensitivityScenarios.java 2009-02-24 09:59:44 UTC (rev 1864) @@ -0,0 +1,80 @@ +/* *##% + * 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.util.List; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Ensemble de {@link Scenario}. + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 24 févr. 2009 $ + * By : $Author: chatellier $ + */ +public class SensitivityScenarios { + + /** serialVersionUID. */ + private static final long serialVersionUID = 4953721873692486687L; + + /** + * Ensemble des scenarios. + */ + protected List<Scenario> scenarios; + + /** + * Constructeur. + */ + public SensitivityScenarios() { + + } + + /** + * Get scenarios. + * + * @return the scenarios + */ + public List<Scenario> getScenarios() { + return scenarios; + } + + /** + * Set scenarios. + * + * @param scenarios the scenarios + */ + public void setScenarios(List<Scenario> scenarios) { + this.scenarios = scenarios; + } + + /* + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + + ToStringBuilder builder = new ToStringBuilder(this); + builder.append(scenarios); + + return builder.toString(); + } +}