Isis-fish-devel
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
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
May 2007
- 4 participants
- 10 discussions
je disais je joints le script...
--
Sigrid LEHUTA
stagiaire Master 2
Ecologie et Modèles pour l'Halieutique
IFREMer, rue de l'ile d'Yeu BP 21105
44311 Nantes Cedex 03
package analyseplans;
import static org.codelutin.i18n.I18n._;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import scripts.ResultName;
import java.io.*;
import java.util.*;
import org.codelutin.math.matrix.*;
import org.codelutin.topia.*;// pour pouvoir utiliser la methode StringUtil.toDouble()
import org.codelutin.util.*;// pour pouvoir utiliser la methode StringUtil.toDouble()
import fr.ifremer.isisfish.*;
import fr.ifremer.isisfish.types.*;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.Date;
import fr.ifremer.isisfish.entities.*;
import fr.ifremer.isisfish.simulator.AnalysePlan;
import fr.ifremer.isisfish.simulator.AnalysePlanContext;
import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.datastore.ResultStorage;
/**
* CalibrationAnchois.java
*
* Created: 8 mars 2007
*
* @author <>
* @version $Revision: 1.1 $
*
* Last update: $Date: 2007/03/09 15:27:21 $
* by : $Author: bpoussin $
*/
public class CalibrationAnchois3 implements AnalysePlan {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(CalibrationAnchois3.class);
enum State {STATE_INIT, STATE_0, STATE_1, STATE_2, STATE_3, STATE_4};
//parametres de la simu 3 points initiaux d un simplex d ordre 2
public Population param_Population = null;
public String param_M1 = "2.42e-5;2.11e-6";// devient un parametre du plan d analyse
public String param_M2 = "2.34e-5;2.59e-6";// devient un parametre du plan d analyse
public String param_M3 = "2.59e-5;2.41e-6";// devient un parametre du plan d analyse
public String param_pas = "1e-5";// devient un parametre du plan d analyse
public String param_nomfichier_debarquements = "";//nom + chemin du fichier contenant les debarquements observes par groupe pour la derniere annee
protected File debarquementsObserves;
protected MatrixND matrixDebarquement;
protected State state = State.STATE_INIT;
protected Experiences experiences = new Experiences();
public String [] necessaryResult = {
ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET
};
public String[] getNecessaryResult() {
return this.necessaryResult;
}
/**
* Permet d'afficher a l'utilisateur une aide sur le plan.
* @return L'aide ou la description du plan
*/
public String getDescription() throws Exception {
return _("Simplexe_methode2 avec simu inutiles evitées");
}
/**
* Appele au demarrage de la simulation, cette methode permet d'initialiser
* des valeurs
* @param simulation La simulation pour lequel on utilise cette regle
*/
public void init(AnalysePlanContext context) throws Exception {
if (param_nomfichier_debarquements==null || "".equals(param_nomfichier_debarquements)){
debarquementsObserves = FileUtil.getFile(".*.csv", "fichier csv séparateur ';'");
} else {
debarquementsObserves = new File(param_nomfichier_debarquements);
}
int nbYear = context.getParam().getNumberOfYear();
TopiaContext db = context.getParam().getRegion().getStorage().beginTransaction();
Population pop = (Population)db.findByTopiaId(param_Population.getTopiaId());
int nbGroup = 4 ;//pop.sizePopulationGroup();
int nbTrim = nbYear * 4;
log.info("nbTrim" + nbTrim);
int [] dimMatrix = {nbTrim,nbGroup};
matrixDebarquement = MatrixFactory.getInstance().create(dimMatrix);
//matrixDebarquement = MatrixFactory.getInstance().create(new int[]{nbGroup});
// List<PopulationGroup> groups = pop.getPopulationGroup();
// matrixDebarquement = MatrixFactory.getInstance().create(new List[]{groups});
matrixDebarquement.importCSV(new FileReader(debarquementsObserves),new int []{0,0});
db.closeContext();
}
/**
* Call before each simulation
* @param context plan context
* @param nextSimulation storage used for next simulation
* @return true if we must do next simulation, false to stop plan
* @throws Exception
*/
double g1;
double g2;
double worst1;
double worst2;
public boolean beforeSimulation(AnalysePlanContext context, SimulationStorage nextSimulation) throws Exception {
boolean doNext = true;
boolean doBoucle = true;
log.info("before simulation");
int number = context.getNumber();
if (number <3) {
log.info("number<3");
String [] M1 = param_M1.split(";");
String [] M2 = param_M2.split(";");
String [] M3 = param_M3.split(";");
double [] q1 = StringUtil.toArrayDouble(M1[0], M2[0], M3[0]);
double [] q2 = StringUtil.toArrayDouble(M1[1], M2[1], M3[1]);
experiences.getExperience(number).q1 = q1[number];
experiences.getExperience(number).q2 = q2[number];
changeDB(experiences.getExperience(number), nextSimulation);
} else {
double q1 = 1000;
double q2 = 1000;
double lastCritere = experiences.getExperience(number-1).criteria;
while (doBoucle){
doBoucle = false;
if (state == State.STATE_INIT) {
doBoucle = false ;
log.info("state init");
Collections.sort(experiences.current);
log.info("current 0 = " + experiences.current.get(0).criteria + "current 1 = " + experiences.current.get(1).criteria + "current 2 = " + experiences.current.get(2).criteria );
double g1 = (experiences.current.get(0).q1 + experiences.current.get(1).q1) / 2.0;
double g2 = (experiences.current.get(0).q2 + experiences.current.get(1).q2) / 2.0;
double worst1 = experiences.current.get(2).q1;
double worst2 = experiences.current.get(2).q2;
// on fait la 4eme simulation dans tous les cas
state = State.STATE_0;
q1 = 2 * g1 - worst1;
q2 = 2 * g2 - worst2;
} else if (state == State.STATE_0) {
doBoucle = false;
log.info("state 0");
log.info("current 0 = " + experiences.current.get(0).criteria + "current 1 = " + experiences.current.get(1).criteria + "current 2 = " + experiences.current.get(2).criteria );
// on fait la 5eme avec des q qui dependent de la 4eme dans le dernier cas
//log.info("g1 = " + g1 + " " + "g2 = " + g2);
//log.info("worst1 = " + worst1 + " " + "worst2 = " + worst2);
if (lastCritere > experiences.current.get(2).criteria) {
log.info("State 0 : lastCtritere > current2");
state = State.STATE_1;
q1 = ((experiences.current.get(0).q1 + experiences.current.get(1).q1) / 2.0) - ( ((experiences.current.get(0).q1 + experiences.current.get(1).q1) / 2.0) - experiences.current.get(2).q1 ) / 2.0;
q2 = ((experiences.current.get(0).q2 + experiences.current.get(1).q2) / 2.0) - ( ((experiences.current.get(0).q2 + experiences.current.get(1).q2) / 2.0) - experiences.current.get(2).q2 ) / 2.0;
log.info("Q1 = " + q1 + "Q2 = " + q2);
} else if (lastCritere > experiences.current.get(1).criteria) {
log.info("State 0 : lastCritere > current 1");
state = State.STATE_2;
q1 = ((experiences.current.get(0).q1 + experiences.current.get(1).q1) / 2.0) + ( ((experiences.current.get(0).q1 + experiences.current.get(1).q1) / 2.0) - experiences.current.get(2).q1 ) / 2.0;
q2 = ((experiences.current.get(0).q2 + experiences.current.get(1).q2) / 2.0) + ( ((experiences.current.get(0).q2 + experiences.current.get(1).q2) / 2.0) - experiences.current.get(2).q2 ) / 2.0;
log.info("Q1 = " + q1 + "Q2 = " + q2);
} else if (lastCritere > experiences.current.get(0).criteria) {
log.info("State 0 : lastCritere > current0");
state = State.STATE_INIT;
experiences.current.remove(2);//remove(3)avant
doBoucle = true;
log.info("remove(2)");
} else { // dernier cas possible: if (lastCritere < experiences.current.get(0).critere) {
log.info("State 0 : lastCritere < current 0");
state = State.STATE_4;
log.info("current 3 : " + experiences.current.get(3).q1);
q1 = experiences.getExperience(number-1).q1 + (experiences.current.get(0).q1 + experiences.current.get(1).q1) / 2.0 - experiences.current.get(2).q1;
q2 = experiences.getExperience(number-1).q2 + (experiences.current.get(0).q2 + experiences.current.get(1).q2) / 2.0 - experiences.current.get(2).q2;
//q1 = experiences.current.get(3).q1 + (experiences.current.get(0).q1 + experiences.current.get(1).q1) / 2.0 - experiences.current.get(2).q1;
//q2 = experiences.current.get(3).q2 + (experiences.current.get(0).q2 + experiences.current.get(1).q2) / 2.0 - experiences.current.get(2).q2;
log.info("Q1 = " + q1 + "Q2 = " + q2);
}
} else if (state == State.STATE_1) {
log.info("state 1");
experiences.current.remove(3);
experiences.current.remove(2);
state = State.STATE_INIT;
doBoucle = true;
} else if (state == State.STATE_2) {
log.info("state 2");
experiences.current.remove(3);
experiences.current.remove(2);
state = State.STATE_INIT;
doBoucle = true;
} else if (state == State.STATE_4) {
log.info("state 4");
doBoucle = true;
if (lastCritere < experiences.current.get(3).criteria) {
log.info("remove 2 et 3");
experiences.current.remove(3);
experiences.current.remove(2);
} else {
log.info("remove 2 et 4");
experiences.current.remove(2);
experiences.current.remove(4);
}
state = State.STATE_INIT;
}
}//fin du while
//on remplit la table experiences
experiences.getExperience(number).q1 = q1;
experiences.getExperience(number).q2 = q2;
log.info("finalement Q1 = " + q1 + " " + "Q2 = " + q2);
// on change la valeur de q dans la DB
changeDB(experiences.getExperience(number), nextSimulation);
}
return doNext;
}
/**
* Call after each simulation, compute criteria for last simulation
* @param context plan context
* @param nextSimulation storage used for next simulation
* @return true if we must do next simulation, false to stop plan
* @throws Exception
*/
public boolean afterSimulation(AnalysePlanContext context, SimulationStorage lastSimulation) throws Exception {
boolean doNext = true;
log.info("after simulation");
int number = context.getNumber();
ResultStorage result = lastSimulation.getResultStorage();
// Pour sommer sur certaines classes les resultats :
MatrixND L = result.getMatrix(param_Population, ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET);
//MatrixND L = L2.getSubMatrix(1,1,4).copy(); //on ne prend que les 5 premieres strategies (pas live bait)
//log.info("sous matrice extraite");
L = L.sumOverDim(1);// sum sur les strategies
L = L.sumOverDim(2);// sum sur les metiers
L = L.sumOverDim(4);// sum sur les zones
log.info("somme sur les strategies, metiers zones faites");
int [] dims = new int[]{L.getDim(0), L.getDim(1), L.getDim(2), 4, L.getDim(4)}; // matrice a 5 dimension
MatrixND tmp = MatrixFactory.getInstance().create(L.getName(), dims);
int [] origin = new int[5]; // on initialise l'origine a [0,0,0,0,0]
log.info("Début de la boucle while");
while (origin[0] < dims[0]-1){ //origin commence à 0 tandis que dim[0] commence a 1
Date date = new Date(origin[0]);
MatrixND age = L.getSubMatrix(0,origin[0],1).copy();
if (date.getMonth().before(Month.JULY)) { //origin[0] >= i*12 && origin[0]<= 5+i*12 )
age = age.sumOverDim(3,0,5);
age = age.sumOverDim(3,1,10);
age = age.sumOverDim(3,2,1);
age = age.sumOverDim(3,3,2);
}else if (date.getMonth().equals(Month.JULY) || date.getMonth().equals(Month.AUGUST)) { //origin[0] >= 6+i*12 && origin[0]<= 7+i*12 ){
age = age.sumOverDim(3,0,5);
age = age.sumOverDim(3,1,11);
age = age.sumOverDim(3,2,1);
age = age.sumOverDim(3,3,1);
} else { // apres aout //(origin[0] >= 8+i*12 && origin[0]<= 11+i*12 )
age = age.sumOverDim(3,0,15);
age = age.sumOverDim(3,1,1);
age = age.sumOverDim(3,2,1);
age = age.sumOverDim(3,3,1);
}//fin du else
tmp.paste (origin, age);
origin[0]++;
}//fin du while
log.info("fin du while");
L = tmp.sumOverDim(0,3);
L = L.reduce();
log.info("calcul du critere");
log.info("dim de L" + " " + Arrays.toString(L.getDim()));
log.info("dim de obs" + " " + Arrays.toString(matrixDebarquement.getDim()));
double crit = 0;
for ( MatrixIterator g = L.iterator(); g.hasNext();){
g.next();
int [] dim = g.getCoordinates();
double obs = matrixDebarquement.getValue(dim);
double simules = g.getValue();
crit += Math.pow(obs-simules, 2);
}// fin du for
log.info("critere = " + crit );
experiences.getExperience(number).criteria = crit;
return doNext;
}// fin du after simulation
/**
* Modify nextSimulation database with q1 and q2 in exp.
* @param exp
* @param nextSimulation
* @throws Exception
*/
protected void changeDB(Experience exp, SimulationStorage nextSimulation) throws Exception {
TopiaContext db = nextSimulation.getStorage().beginTransaction();//ouvrir un context pour modifier les donnees
Population pop = (Population)db.findByTopiaId(param_Population.getTopiaId());
// autre solution moins efficace:
// PopulationDAO popDAO = IsisFishDAOHelper.getPopulationDAO(db);
// Population Nephrops = dao.findByName(param_Population.getName());
MatrixND c = pop.getCapturability();
log.info("q1 = " + exp.q1 + ";" + "q2 = " + exp.q2 );
for (MatrixIterator i = c.iterator(); i.hasNext();){
i.next();
Object [] sem = i.getSemanticsCoordinates();
PopulationGroup group = (PopulationGroup)sem[0];
PopulationSeasonInfo season = (PopulationSeasonInfo)sem[1];
if (group.getId() < 12){
i.setValue(exp.q2);
}else {
i.setValue(exp.q1);
}
}//fin du for
db.commitTransaction();
db.closeContext();
}
class Experiences {
/** contains last simplex and potentialy 2 more simulation */
protected List<Experience> current = new ArrayList<Experience>();
/** contains all experience done */
protected List<Experience> history = new ArrayList<Experience>();
/**
* return experience requested, if this experience doesn't exist
* create it.
*
* @param i simulation number
* @return experience with simulation number fixed if new experience
* is returned
*/
public Experience getExperience(int i) {
Experience result;
if (i<history.size()) {
result = history.get(i);
} else {
result = new Experience();
result.simNumber = i;
history.add(i, result);
current.add(result);
}
return result;
}
}
/**
* Use to keep q1, q2 and criteria of simulation
* @author poussin
*/
class Experience implements Comparable {
public int simNumber;
public double criteria;
public double q1;
public double q2;
/**
* Permit to order experience, first is experience with smallest criteria
*/
public int compareTo(Object arg0) {
Experience other = (Experience)arg0;
int result = Double.compare(this.criteria, other.criteria);
return result;
}
}
}
1
0
Salut Benjamin,
Je voulais savoir comment réccupérer la table Experiences que l on cree
dans le plan d analyse calibration ??
je joints le script
merci !
--
Sigrid LEHUTA
stagiaire Master 2
Ecologie et Modèles pour l'Halieutique
IFREMer, rue de l'ile d'Yeu BP 21105
44311 Nantes Cedex 03
1
0
Salut,
Après de nouveaux tests, il semble bien que le simatrix.java que j'ai
envoyé avant-hier améliore les performances d'environ 40%. Par contre le
defaultsimulator n'améliore pas.
D'autres personnes peuvent essayer?
A+
Hilaire
--
Hilaire Drouineau
IFREMER, département EMH
Centre de Nantes - BP 21105 - 44311 Nantes Cedex 3
tel : +33 (0)2 40 37 42 12 - fax : +33 (0)2 40 37 40 75
email : hilaire.drouineau(a)ifremer.fr - web : http://www.ifremer.fr/emh
**********************************************************************
1
0
Re-salut,
Dans mon mail précédent, il y avait apparemment un problème avec les
pièces jointes. Je remets donc les fichiers.
A+
Hilaire
--
Hilaire Drouineau
IFREMER, département EMH
Centre de Nantes - BP 21105 - 44311 Nantes Cedex 3
tel : +33 (0)2 40 37 42 12 - fax : +33 (0)2 40 37 40 75
email : hilaire.drouineau(a)ifremer.fr - web : http://www.ifremer.fr/emh
**********************************************************************
/* *##%
* Copyright (C) 2006
* 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 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.
*##%*/
/* *
* SiMatrix.java
*
* Created: 21 août 2006 15:53:01
*
* @author poussin
* @version $Revision: 1.14 $
*
* Last update: $Date: 2007/05/25 13:03:28 $
* by : $Author: bpoussin $
*/
package scripts;
import static org.codelutin.i18n.I18n._;
import static org.codelutin.i18n.I18n.n_;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.math.matrix.MatrixFactory;
import org.codelutin.math.matrix.MatrixIterator;
import org.codelutin.math.matrix.MatrixND;
import org.codelutin.topia.TopiaContext;
import org.codelutin.topia.TopiaException;
import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.entities.Cell;
import fr.ifremer.isisfish.entities.EffortDescription;
import fr.ifremer.isisfish.entities.Gear;
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.PopulationSeasonInfo;
import fr.ifremer.isisfish.entities.Selectivity;
import fr.ifremer.isisfish.entities.SetOfVessels;
import fr.ifremer.isisfish.entities.Strategy;
import fr.ifremer.isisfish.entities.StrategyMonthInfo;
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.entities.ZoneDAO;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.Date;
import fr.ifremer.isisfish.types.Month;
/**
* @author poussin
*
*/
public class SiMatrix {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(SiMatrix.class);
protected SimulationContext context = null;
protected TopiaContext db = null;
/**
* Method used to get SiMatrix used for simulation
* @param context context simulation
* @return SiMatrix or null if no SiMatrix created for simulation
*/
public static SiMatrix getSiMatrix(SimulationContext context) {
SiMatrix result = (SiMatrix)context.getValue(SiMatrix.class.getName());
return result;
}
private static void setSiMatrix(SimulationContext context, SiMatrix siMatrix) {
context.setValue(SiMatrix.class.getName(), siMatrix);
}
/**
*
* @param context Simulation context
* @param db TopiaContext with transaction opened. You must used this
* TopiaContext and not used
* SimulationContext.getSimulationStorage().getStorage()
* @throws TopiaException
*/
public SiMatrix(SimulationContext context) throws TopiaException {
this.context = context;
this.db = context.getDB();
setSiMatrix(context, this);
}
/**
* @return
* @throws TopiaException
*/
public List<Zone> getZones(Date date) throws TopiaException {
ZoneDAO dao = IsisFishDAOHelper.getZoneDAO(db);
List<Zone> result = dao.findAll();
return result;
}
/**
* @return
* @throws TopiaException
*/
public List<Population> getPopulations(Date date) throws TopiaException {
List<Population> populations = new ArrayList<Population>();
for (Population pop : context.getSimulationStorage().getParameter().getPopulations()) {
Population tmp = (Population)db.findByTopiaId(pop.getTopiaId());
populations.add(tmp);
}
return populations;
}
/**
* @return
* @throws TopiaException
*/
public List<Strategy> getStrategies(Date date) throws TopiaException {
// if (strategies == null) {
List<Strategy> strategies = new ArrayList<Strategy>();
for (Strategy str : context.getSimulationStorage().getParameter().getStrategies()) {
Strategy tmp = (Strategy)db.findByTopiaId(str.getTopiaId());
strategies.add(tmp);
}
// }
return strategies;
}
public List<Metier> getMetiers(Date date) throws TopiaException {
// if (metiers == null) {
List<Metier> metiers = new ArrayList<Metier>();
HashSet<Metier> tmp = new HashSet<Metier>();
for (Strategy str : getStrategies(date)) {
SetOfVessels sov = str.getSetOfVessels();
for (EffortDescription effort : sov.getPossibleMetiers()) {
Metier metier = effort.getPossibleMetiers();
if (tmp.add(metier)) {
metiers.add(metier);
}
}
}
// }
return metiers;
}
/**
* Retourne les metiers pratiqués par une Strategie à une date donnée
* Un metier est pratiqué si le PropStrMet est différent de 0
*
* @param str
* @param date
* @return
*/
public List<Metier> getMetiers(Strategy str, Date date) {
StrategyMonthInfo info = str.getStrategyMonthInfo(date.getMonth());
MatrixND props = info.getProportionMetier();
List<Metier> result = new ArrayList<Metier>();
for (MatrixIterator i=props.iterator(); i.hasNext();) {
i.next();
if (i.getValue() != 0) {
Metier metier = (Metier)i.getSemanticsCoordinates()[0];
result.add(metier);
}
}
return result;
}
/**
* Retourne la matrix Metier x Zone qui correspond au zone utilisé par
* un métier pour une date donnée. Si la valeur de la matrice est 1 alors
* la zone est utilisé par le métier, si elle vaut 0 alors elle n'est pas
* utilisée.
*
* @param date
* @return
* @throws TopiaException
*/
public MatrixND getMetierZone(Date date) throws TopiaException {
List<Metier> metiers = getMetiers(date);
List<Zone> zones = getZones(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_METIER_ZONE,
new List[]{metiers, zones},
new String[]{n_("Metiers"), n_("Zones")});
for (Metier metier : metiers) {
Collection<Zone> zoneMetier = metier.getMetierSeasonInfo(date.getMonth()).getZone();
for (Zone zone : zoneMetier) {
result.setValue(metier, zone, 1);
}
}
return result;
}
public MatrixND matrixPrice(Date date, Population pop) {
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_PRICE,
new List[]{groups},
new String[]{n_("PopulationGroup")});
for (PopulationGroup group : groups) {
result.setValue(group, group.getPrice());
}
return result;
}
///////////////////////////////////////////////////////////////////////////
//
// Toutes les methodes suivantes ne sont utiles que pour
// matrixCatchPerStrategyMet
//
///////////////////////////////////////////////////////////////////////////
/**
* Matrice des captures en nombre
* dim [ Strategy x Metier x Classe x zonePop ]
*
* @param N l'abondance sous forme de matrice 2D [class x zone]
* @param pop
* @param date
* @return
* @throws TopiaException
* @throws IsisFishException
*/
public MatrixND matrixCatchPerStrategyMet(MatrixND N, Population pop,
Date date, MatrixND matrixCatchRatePerStrategyMet) throws TopiaException, IsisFishException {
List<PopulationGroup> groups = pop.getPopulationGroup();
List<Zone> zones = pop.getPopulationZone();
// on le passe en argument ce qui evite de le calculer 2 fois
// MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, date);
MatrixND result = matrixCatchRatePerStrategyMet.copy();
result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET);
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;
}
/**
* Matrice des captures en poids
* dim [ Strategy x Metier x Classe x zonePop ]
*
* @param pop
* @param date
* @return
* @throws TopiaException
* @throws IsisFishException
*/
public MatrixND matrixCatchRatePerStrategyMet(Population pop, Date date) throws TopiaException, IsisFishException {
List<Strategy> strategies = getStrategies(date);
List<Metier> metiers = getMetiers(date);
List<PopulationGroup> groups = pop.getPopulationGroup();
List<Zone> zones = pop.getPopulationZone();
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_CATCH_RATE_PER_STRATEGY_MET,
new List[]{strategies, metiers, groups, zones},
new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")});
// for (int s=0; s < strategies.size(); s++) {
// Strategy str = strategies.get(s);
// metiers = getMetiers(str, date);
// for (int m=0; m < metiers.size(); m++) {
// Metier metier = metiers.get(m);
// for (int g=0; g < groups.size(); g++) {
// PopulationGroup group = groups.get(g);
// for (int z=0; z < zones.size(); z++) {
// Zone zone = zones.get(z);
// double value = catchRatePerStrategyMet(str, metier, date, group, zone);
// result.setValue(str, metier, group, zone, value);
// }
// }
// }
// }
// Optimisation Hilaire
for (int s=0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = getMetiers(str, date);
for (int m=0; m < metiers.size(); m++) {
Metier metier = metiers.get(m);
for (int z=0; z < zones.size(); z++) {
Zone zone = zones.get(z);
double effort = effortPerZonePop(str,metier,date,zone);
if (effort > 0){
for (int g=0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
double value = catchRatePerStrategyMet(str, metier, date, group, zone/*, effort*/);
result.setValue(str, metier, group, zone, value);
}
}
else {
for (int g=0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
result.setValue(str, metier, group, zone, 0);
}
}
}
}
}
// for (Strategy str : strategies) {
// List<Metier> metierStr = getMetiers(str, date);
// for (Metier metier : metierStr) {
// for (PopulationGroup group : groups) {
// for (Zone zone : zones) {
// double val = catchRatePerStrategyMet(str, metier, date, group, zone);
// result.setValue(str, metier, group, zone, val);
// }
// }
// }
// }
return result;
}
/**
* @param str
* @param metier
* @param date
* @param group
* @param zone
* @return
* @throws TopiaException
* @throws IsisFishException
*/
// private double catchRatePerStrategyMet(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException {
// double totalFishingMortality = totalFishingMortality(date, group, zone);
//
// if(totalFishingMortality == 0){
// if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + group + ", " + zone +")");}
// return 0;
// }
//
// double fishingMortality = fishingMortality(str, metier, date, group, zone);
// double totalCatchRate = totalCatchRate(date, group, zone, totalFishingMortality);
//
// if(log.isDebugEnabled()) {
// log.debug(
// " totalFishingMortality=" + totalFishingMortality +
// " fishingMortality=" + fishingMortality +
// " totalCatchRate=" + totalCatchRate);
// }
// double result = fishingMortality / totalFishingMortality * totalCatchRate;
//
// return result;
// }
// Optimisation Hilaire
private double catchRatePerStrategyMet(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone/*, double effort*/) throws TopiaException, IsisFishException {
double totalFishingMortality = totalFishingMortality(date, group, zone);
if(totalFishingMortality == 0){
if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + group + ", " + zone +")");}
return 0;
}
double fishingMortality = fishingMortality(str, metier, date, group, zone/*, effort*/);
double totalCatchRate = totalCatchRate(date, group, zone, totalFishingMortality);
if(log.isDebugEnabled()) {
log.debug(
" totalFishingMortality=" + totalFishingMortality +
" fishingMortality=" + fishingMortality +
" totalCatchRate=" + totalCatchRate);
}
double result = fishingMortality / totalFishingMortality * totalCatchRate;
return result;
}
/**
* @param date
* @param group
* @param zone
* @param totalFishingMortality
* @return
* @throws TopiaException
*/
private double totalCatchRate(Date date, PopulationGroup group,
Zone zone, double totalFishingMortality) throws TopiaException {
double M = group.getNaturalDeathRate(zone) / Month.NUMBER_OF_MONTH;
if(M == 0){
// normalement il devrait y avoir de la mortalite naturelle
if (log.isWarnEnabled()) {
log.warn("Pas de mortalité naturelle pour: " + group);
}
}
double F = totalFishingMortality;
double result = 0;
if( M != 0 || F != 0){
result = F/(F+M) * (1 - Math.exp(-(F+M)));
}
return result;
}
/**
* @param date
* @param group
* @param zone
* @return
* @throws TopiaException
* @throws IsisFishException
*/
private double totalFishingMortality(Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException {
List<Strategy> strategies = getStrategies(date);
float result = 0;
// for(Strategy str : strategies){
// List<Metier> metierStr = getMetiers(str, date);
// for (Metier metier : metierStr) {
// // TODO peut etre ne pas le faire si classe.pop n'est pas
// /// peche par le metier
// result += fishingMortality(str, metier, date, group, zone);
// }
// }
// Optimisation Hilaire
for(Strategy str : strategies){
List<Metier> metierStr = getMetiers(str, date);
for (Metier metier : metierStr) {
double effort=effortPerZonePop(str,metier,date,zone);
if (effort>0)
result += fishingMortality(str, metier, date, group, zone/*, effort*/);
}
}
return result;
}
/**
* @param str
* @param metier
* @param date
* @param group
* @param zone
* @return
* @throws IsisFishException
*/
private double fishingMortality(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone/*, double effort*/) throws IsisFishException {
Month month = date.getMonth();
Population pop = group.getPopulation();
Gear gear = metier.getGear();
Selectivity selectivity = gear.getPopulationSelectivity(pop);
double result = 0;
if (selectivity != null) {
MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month);
double ciblage = infoMet.getTargetFactor(group);
PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
double capturability = infoPop.getCapturability(group);
double coeff = selectivity.getCoefficient(pop, group, metier);
// Optimisation Hilaire
double effort = effortPerZonePop(str, metier, date, zone);
if(log.isDebugEnabled()) {
log.debug(
" strategy=" + str +
" metier=" + metier +
" ciblage=" + ciblage +
" capturabilite=" + capturability +
" selectivity=" + coeff +
" effort=" + effort);
}
result = coeff * capturability * ciblage * effort;
}
return result;
}
/**
* @param str
* @param metier
* @param date
* @param zone
* @return
*/
private double effortPerZonePop(Strategy str, Metier metier, Date date, Zone zonePop) {
Month month = date.getMonth();
Collection<Zone> zoneMet = metier.getMetierSeasonInfo(month).getZone();
double inter = nbCellInter(zoneMet, zonePop);
double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier, date);
if(log.isDebugEnabled()) {
log.debug(
" strategy=" + str +
" metier=" + metier +
" inter=" + inter +
" effortPerStrategyPerCell=" + effortPerStrategyPerCell
);
}
double result = effortPerStrategyPerCell * inter;
return result;
}
/**
* @param str
* @param metier
* @param date
* @return
*/
private double effortPerStrategyPerCell(Strategy str, Metier metier, Date date) {
Month month = date.getMonth();
StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
Collection<Zone> zones = metier.getMetierSeasonInfo(month).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()) log.warn("Calcul d'une distance avec une zone sans maille");
return 0;
}
double effortPerStrategy = effortPerStrategyMet(str, metier, date);
if(log.isDebugEnabled()) {
log.debug(
" strategy=" + str +
" metier=" + metier +
" nbCell=" + nbCell +
" effortPerStrategy=" + effortPerStrategy
);
}
double result = effortPerStrategy/nbCell;
return result;
}
/**
* @param str
* @param metier
* @param date
* @return
*/
private double effortPerStrategyMet(Strategy str, Metier metier, Date date) {
Month month = date.getMonth();
StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
double propSetOfVessels = str.getProportionSetOfVessels();
int nbOfVessels = str.getSetOfVessels().getNumberOfVessels();
double propStrMet = smi.getProportionMetier(metier);
double effortPerVessel = effortPerStrategyPerVessel(str, metier, date);
if(log.isDebugEnabled()) {
log.debug(
" strategy=" + str +
" metier=" + metier +
" propSetOfVessels=" + propSetOfVessels +
" nbOfVessels=" + nbOfVessels +
" propStrMet=" + propStrMet +
" effortPerVessel=" + effortPerVessel
);
}
double result = propSetOfVessels * nbOfVessels * propStrMet * effortPerVessel;
return result;
}
/**
* @param str
* @param metier
* @param date
* @return
*/
private double effortPerStrategyPerVessel(Strategy str, Metier metier, Date date) {
Month month = date.getMonth();
StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
int nbTrips = smi.getNumberOfTrips();
double fishingTime = fishingTimePerTrip(str, metier, date);
double stdEffortPerHour = stdEffortPerHour(str.getSetOfVessels(), metier);
if(log.isDebugEnabled()) {
log.debug(
" strategy=" + str +
" metier=" + metier +
" nbTrips=" + nbTrips +
" fishingTime=" + fishingTime +
" stdEffortPerHour=" + stdEffortPerHour
);
}
double result = nbTrips * fishingTime * stdEffortPerHour;
return result;
}
/**
* Used in GravityModel too
*
* @param str
* @param metier
* @param date
* @return
*/
protected double fishingTimePerTrip(Strategy str, Metier metier, Date date) {
Month month = date.getMonth();
StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
Collection<Zone> zone = metier.getMetierSeasonInfo(month).getZone();
if (zone == null) {
if(log.isWarnEnabled()) log.warn(
"missing zone for metier =" + metier +
" for month" + month
);
}
double tripDuration = smi.getTripType().getTripDuration().getHour();
double travelTime = travelTimePerTrip(str.getSetOfVessels(), zone);
double result = tripDuration - travelTime;
if (result < 0 ) {
if(log.isWarnEnabled()) log.warn(
" strategy=" + str +
" metier=" + metier +
" tripDuration=" + tripDuration +
" travelTime=" + travelTime
);
}
return result;
}
/**
*
* @param setOfVessels
* @param zone
* @return
*/
protected double travelTimePerTrip(SetOfVessels sov, Collection<Zone> zoneMetier) {
Cell maille = sov.getPort().getCell();
double result =
2 * distance(zoneMetier, maille) / sov.getVesselType().getSpeed();
return result;
}
/**
* @param zoneMetier
* @param maille
* @return
*/
private double distance(Collection<Zone> zones, Cell cell) {
double result = 0;
List<Cell> cells = getCells(zones);
if(cells.size() == 0){
// normalement il devrait y avoir des mailles, mais pour les
// ancienne zone AuPort, il n'y en avait pas
if(log.isWarnEnabled()) {
log.warn("Calcul d'une distance avec une zone sans maille");
}
return 0;
}
for(Cell c : cells){
result += distance(c, cell);
}
if(log.isDebugEnabled()) {
log.debug(" result=" + result + " nbMaille="+cells.size());
}
result = result / (double)cells.size();
return result;
}
/**
* @param c
* @param cell
* @return
*/
private double distance(Cell m1, Cell m2) {
double earthRadius = 6378.388;
double p = 180/Math.PI;
if(log.isDebugEnabled()) log.debug("p: " + p);
double m1lat = m1.getLatitude();
double m2lat = m2.getLatitude();
double m1lon = m1.getLongitude();
double m2lon = m2.getLongitude();
if(log.isDebugEnabled()) log.debug(
" m1lat=" + m1lat +
" m2lat=" + m2lat +
" m1lon=" + m1lon +
" m2lonx=" + m2lon
);
double m1lat_div_p = m1lat/p;
double m2lat_div_p = m2lat/p;
double m1lon_div_p = m1lon/p;
double m2lon_div_p = m2lon/p;
if(log.isDebugEnabled()) log.debug(
" m1lat_div_p=" + m1lat_div_p +
" m2lat_div_p=" + m2lat_div_p +
" m1lon_div_p=" + m1lon_div_p +
" m2lon_div_p=" + m2lon_div_p
);
double sin_m1lat_div_p = Math.sin(m1lat_div_p);
double sin_m2lat_div_p = Math.sin(m2lat_div_p);
double cos_m1lat_div_p = Math.cos(m1lat_div_p);
double cos_m2lat_div_p = Math.cos(m2lat_div_p);
if(log.isDebugEnabled()) log.debug(
" sin_m1lat_div_p=" + sin_m1lat_div_p +
" sin_m2lat_div_p=" + sin_m2lat_div_p +
" cos_m1lat_div_p=" + cos_m1lat_div_p +
" cos_m2lat_div_p=" + cos_m2lat_div_p
);
double cos_m1lon_div_p_minus_m2lon_div_p = Math.cos(m1lon_div_p - m2lon_div_p);
if(log.isDebugEnabled()) log.debug(
" cos_m1lon_div_p_minus_m2lon_div_p=" + cos_m1lon_div_p_minus_m2lon_div_p);
double acos = Math.acos(
sin_m1lat_div_p
* sin_m2lat_div_p
+
cos_m1lat_div_p
* cos_m2lat_div_p
* cos_m1lon_div_p_minus_m2lon_div_p
);
if(log.isDebugEnabled()) log.debug(" acos=" + acos);
double result = earthRadius * acos;
return result;
}
/**
* @param setOfVessels
* @param metier
* @return
*/
private double stdEffortPerHour(SetOfVessels sov, Metier metier) {
double result = 0;
EffortDescription ed = sov.getPossibleMetiers(metier);
if(ed != null){
double fstd = metier.getGear().getStandardisationFactor();
double val = fstd * ed.getFishingOperation() * ed.getGearsNumberPerOperation();
result = val;
}
result = result/24; // 24 heures
return result;
}
/**
* used here and in Rule (CantonnementPreSimu)
*
* @param zones
* @return
*/
public List<Cell> getCells(Collection<Zone> zones) {
List<Cell> result = new ArrayList<Cell>();
for (Zone zone : zones) {
result.addAll(zone.getCell());
}
return result;
}
/**
* used here and in Rule (CantonnementPreSimu)
*
* @param zoneMet
* @param zonePop
* @return
*/
public int nbCellInter(Collection<Zone> zoneMet, Zone zonePop) {
List<Cell> cells = getCells(zoneMet);
List<Cell> tmp = new ArrayList<Cell>(cells);
tmp.retainAll(zonePop.getCell());
return tmp.size();
}
///////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////
/**
* @param N
* @param pop
* @param date
* @return
* @throws IsisFishException
* @throws TopiaException
*/
public MatrixND matrixAbundance(MatrixND N, Population pop, Date date) throws TopiaException, IsisFishException {
List<PopulationGroup> groups = pop.getPopulationGroup();
List<Zone> zones = pop.getPopulationZone();
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_ABUNDANCE,
new List[]{groups, zones},
new String[]{n_("Groups"), n_("Zones")});
for (int g=0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
for (int z=0; z < zones.size(); z++) {
Zone zone = zones.get(z);
double value = survivalRate(date, group, zone);
double n = N.getValue(g, z);
value *= n;
result.setValue(g, z, value);
}
}
// for(PopulationGroup group : groups){
// for(Zone zone : zones){
// double val = survivalRate(date, group, zone);
// val *= N.getValue(group, zone);
// result.setValue(group, zone, val);
// }
// }
return result;
}
/**
* @param date
* @param group
* @param zone
* @return
* @throws IsisFishException
* @throws TopiaException
*/
private double survivalRate(Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException {
double F = totalFishingMortality(date, group, zone); // rem perf: totalFishingMortality a deja ete calculé
double M = group.getNaturalDeathRate(zone)/(double)Month.NUMBER_OF_MONTH;
double result = (double)Math.exp(-(F+M));
return result;
}
///////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////
/**
* @param n
* @param pop
* @param date
* @return
*/
public MatrixND matrixBiomass(MatrixND N, Population pop, Date date) {
List<PopulationGroup> groups = N.getSemantics(0);
List<Zone> zones = N.getSemantics(1);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_BIOMASS,
new List[]{groups, zones},
new String[]{n_("Groups"), n_("Zones")});
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);
}
}
// for(PopulationGroup group : groups){
// double meanWeight = group.getMeanWeight();
// for(Zone zone : zones){
// double val = N.getValue(group, zone) * meanWeight;
// result.setValue(group, zone, val);
// }
// }
return result;
}
///////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////
/**
* @param date
* @return
* @throws TopiaException
*/
public MatrixND matrixEffortPerStrategyMet(Date date) throws TopiaException {
List<Strategy> strategies = getStrategies(date);
List<Metier> metiers = getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_EFFORT_PER_STRATEGY_MET,
new List[]{strategies, metiers},
new String[]{n_("Strategies"), n_("Metiers")});
for (int s=0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = getMetiers(str, date);
for (int m=0; m < metiers.size(); m++) {
Metier metier = metiers.get(m);
double value = effortPerStrategyMet(str, metier, date);
result.setValue(str, metier, value);
}
}
// for(Strategy str : strategies){
// List<Metier> metierStr = getMetiers(str, date);
// for(Metier metier : metierStr) {
// double val = effortPerStrategyMet(str, metier, date); // rem perf: effortPerStrategyMet a deja ete calculé
// result.setValue(str, metier, val);
// }
// }
return result;
}
///////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////
/**
* @param pop
* @param date
* @return
*/
public MatrixND matrixCatchWeightPerStrategyMet(Population pop,
Date date, MatrixND matrixCatchPerStrategyMet) {
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = matrixCatchPerStrategyMet.copy();
result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET);
for(PopulationGroup group : groups){
MatrixND sub = result.getSubMatrix(2, group, 1);
double meanWeight = group.getMeanWeight();
sub.mults(meanWeight);
}
return result;
}
/**
* @param pop
* @param date
* @return
*/
public MatrixND matrixDiscardWeightPerStrategyMet(Population pop,
Date date, MatrixND matrixDiscardPerStrategyMet) {
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = matrixDiscardPerStrategyMet.copy();
result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET);
for(PopulationGroup group : groups){
MatrixND sub = result.getSubMatrix(2, group, 1);
double meanWeight = group.getMeanWeight();
sub.mults(meanWeight);
}
return result;
}
}
/* *##%
* Copyright (C) 2006
* Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* 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.
*##%*/
/* *
* DefaultSimulator.java
*
* Created: 21 août 2006 10:57:46
*
* @author poussin
* @version $Revision: 1.15 $
*
* Last update: $Date: 2007/03/01 17:16:12 $
* by : $Author: bpoussin $
*/
package simulators;
import static org.codelutin.i18n.I18n._;
import static org.codelutin.i18n.I18n.n_;
import java.util.Collection;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.math.matrix.MatrixFactory;
import org.codelutin.math.matrix.MatrixND;
import org.codelutin.topia.TopiaContext;
import org.codelutin.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;
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.rule.Rule;
import fr.ifremer.isisfish.simulator.MetierMonitor;
import fr.ifremer.isisfish.simulator.PopulationMonitor;
import fr.ifremer.isisfish.simulator.RuleMonitor;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.SimulationParameter;
import fr.ifremer.isisfish.simulator.Simulator;
import fr.ifremer.isisfish.types.Date;
import fr.ifremer.isisfish.types.Month;
/**
* @author poussin
*
*/
public class DefaultSimulator implements Simulator {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(DefaultSimulator.class);
/**
* Called by isis don't modify signature
*/
public void simulate(SimulationContext context) throws Exception {
SimulationParameter param = context.getSimulationStorage().getParameter();
SimulationControl control = context.getSimulationControl();
int lastYear = param.getNumberOfYear();
int lastDate = lastYear * Month.NUMBER_OF_MONTH;
Date date = control.getDate();
control.setProgressMax(lastDate);
ResultStorage resManager = context.getSimulationStorage().getResultStorage();
TopiaContext db = context.getDB();
SiMatrix siMatrix = new SiMatrix(context);
GravityModel gravityModel = new GravityModel(context, siMatrix);
PopulationMonitor populationMonitor = context.getPopulationMonitor();
MetierMonitor metierMonitor = context.getMetierMonitor();
RuleMonitor ruleMonitor = context.getRuleMonitor();
for (Population pop : siMatrix.getPopulations(date)) {
MatrixND N = param.getNumberOf(pop);
N.setName(ResultName.MATRIX_ABUNDANCE);
populationMonitor.setN(pop, N);
}
//
// Rule initialisation
//
List<Rule> rules = param.getRules();
control.setText("Rules initialisation");
for (Rule rule : rules) {
rule.init(context);
}
//
// Commit all change done un init rules methods.
//
context.getDB().commitTransaction();
//
// Simulation loop
//
while (date.getDate() < lastDate) {
//
// if user stop simulation before last year
//
if (control.isStopSimulationRequest()) {
break;
}
control.setDate(date);
control.setProgress(date.getDate());
control.setText(_("begin step " + date));
// raz des metiers interdits et des licences
metierMonitor.clear();
if (date.getMonth().equals(Month.JANUARY)) {
populationMonitor.clearCatch();
}
if (resManager.isEnabled(ResultName.MATRIX_NO_ACTIVITY)) {
MatrixND mat = metierMonitor.getOrCreateNoActivity(date,
ResultName.MATRIX_NO_ACTIVITY,
siMatrix.getStrategies(date),
siMatrix.getMetiers(date));
resManager.addResult(date, mat);
}
//
// Rule condition evaluation
//
control.setText("Evalute Rules conditions");
for (Rule rule : rules) {
for (Metier metier : siMatrix.getMetiers(date)) {
boolean active = false;
try {
active = rule.condition(context, date, metier);
} catch (Exception eee) {
if (log.isWarnEnabled()) {
log.warn("Can't evaluate rule condition for: " + rule, eee);
}
}
ruleMonitor.setEvaluationCondition(date, metier, active);
if (active) {
resManager.addActiveRule(date, rule);
}
}
}
//
// Rule pre action
//
control.setText("Do pre action Rules");
for (Rule rule : rules) {
for (Metier metier : siMatrix.getMetiers(date)) {
boolean condition = ruleMonitor.getEvalutionCondition(date, metier);
if (condition) {
rule.preAction(context, date, metier);
}
}
}
//
// Keep modification's information done in rule
//
if (resManager.isEnabled(ResultName.MATRIX_METIER_ZONE)) {
MatrixND metierZone = siMatrix.getMetierZone(date);
resManager.addResult(date, metierZone);
}
//
// Simulate one step for all pop
//
control.setText("Simulate one month");
for (Population pop : siMatrix.getPopulations(date)) {
computeMonth(context, siMatrix, date, pop);
}
//
// Add some result not population dependante
//
control.setText("Add some results");
if (resManager.isEnabled(ResultName.MATRIX_EFFORT_PER_STRATEGY_MET)) {
MatrixND effortPerStrategyMet = siMatrix.matrixEffortPerStrategyMet(date);
resManager.addResult(date, effortPerStrategyMet);
}
if (resManager.isEnabled(ResultName.MATRIX_STD_TRAVEL_EFFORT_PER_STRATEGY_MET)) {
MatrixND stdTravelEffortPerStrategyMet = siMatrix.matrixEffortPerStrategyMet(date);
resManager.addResult(date, stdTravelEffortPerStrategyMet);
}
if (resManager.isEnabled(ResultName.MATRIX_EFFORT_PER_ZONE_POP)) {
MatrixND effortPerZonePop = siMatrix.matrixEffortPerStrategyMet(date);
resManager.addResult(date, effortPerZonePop);
}
//
// Add economics results
//
if (resManager.isEnabled(ResultName.MATRIX_PRICE)) {
for (Population pop : siMatrix.getPopulations(date)) {
MatrixND matPrice = siMatrix.matrixPrice(date, pop);
resManager.addResult(date, pop, matPrice);
}
}
if (!"false".equalsIgnoreCase(param.getTagValue().get("ecoResult"))) {
control.setText("Add economics results");
saveGravityModel(date, resManager, gravityModel);
}
//
// Rule post action
//
control.setText("Do post action Rules");
for (Rule rule : rules) {
for (Metier metier : siMatrix.getMetiers(date)) {
if (ruleMonitor.getEvalutionCondition(date, metier)) {
rule.postAction(context, date, metier);
}
}
}
// discard and landing must be done after post action rules
control.setText("Compute discard and landing");
for (Population pop : siMatrix.getPopulations(date)) {
//
// discard computation
//
MatrixND discard = populationMonitor.getDiscard(date, pop);
if (discard != null || date.getDate() == 0) { // force discard for the first month to have discard in result
if (discard == null) {
discard = MatrixFactory.getInstance().create(ResultName.MATRIX_DISCARDS_PER_STR_MET,
new List[]{siMatrix.getStrategies(date),
siMatrix.getMetiers(date),
pop.getPopulationGroup(),
pop.getPopulationZone()},
new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")});
}
resManager.addResult(date, pop, discard);
if (resManager.isEnabled(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET)) {
MatrixND discardWeightPerStrategyMet = siMatrix.matrixDiscardWeightPerStrategyMet(pop, date, discard);
resManager.addResult(date, pop, discardWeightPerStrategyMet);
}
}
//
// add landing result
//
if (resManager.isEnabled(ResultName.MATRIX_LANDING_PER_MET)) {
MatrixND landing = MatrixFactory.getInstance().create(populationMonitor.getCatch(pop));
if (discard != null) {
landing = landing.minus(discard);
}
landing.setName(ResultName.MATRIX_LANDING_PER_MET);
resManager.addResult(date, pop, landing);
}
}
//
// revert modification for next step
//
control.setText("Rollback rules changes");
db.rollbackTransaction();
//
// commit result
//
control.setText("Commit results");
TopiaContext tx = context.getDbResult();
tx.commitTransaction();
//
// Go next step
//
date = date.next();
}
}
protected void computeMonth(SimulationContext context, SiMatrix siMatrix, Date date, Population pop) throws IsisFishException, TopiaException {
// to add result
ResultStorage resManager = context.getSimulationStorage().getResultStorage();
PopulationMonitor popMon = context.getPopulationMonitor();
MatrixND N = popMon.getN(pop);
if (log.isInfoEnabled()) {
log.info("====================== begin "+ date + " - " + pop +" ===========================");
log.info("N: " + N);
}
// add N and biomass result now, before computation
// N is reassigned during computation
resManager.addResult(date, pop, N);
if (resManager.isEnabled(ResultName.MATRIX_BIOMASS)) {
MatrixND biomass = siMatrix.matrixBiomass(N, pop, date);
resManager.addResult(date, pop, biomass);
}
Month month = date.getMonth();
PopulationSeasonInfo info = pop.getPopulationSeasonInfo(month);
// group change
MatrixND CA = null;
if (date.getDate() == 0) {
CA = MatrixFactory.getInstance().matrixId(pop.sizePopulationGroup()*pop.sizePopulationZone());
} else {
CA = info.getGroupChangeMatrix(month);
}
log.debug("CA: " + CA);
//migration
MatrixND M = info.getMigrationMatrix(month, N);
log.debug("M: " + M);
//emigration
MatrixND EM = info.getEmigrationMatrix(month, N);
log.debug("EM: " + EM);
//immigration
MatrixND IM = info.getImmigrationMatrix(month, N).transpose();
log.debug("IM: " + IM);
// pour les premiers calculs on met N en une matrice 1D
MatrixND N1D = pop.N2DToN1D(N);
log.debug("N1D: " + N1D);
MatrixND tmp0 = N1D.mult(CA);
MatrixND tmp1 = M.minus(EM);
MatrixND tmp2 = tmp0.mult(tmp1);
MatrixND tmp3 = tmp2.add(IM);
log.debug("N1D after mig: " + tmp3);
// On reconvertie en une matrice Semantique
N = pop.split2D(tmp3);
log.debug("N after mig: " + N);
//Recrutement
MatrixND R = info.getReproductionMatrix(month, N);
log.debug("R: " + R);
// ajout de la matrice R dans le suivi de la pop comme etant
// la reproduction pour le mois courant.
popMon.setReproduction(date, pop, R);
// recrutement
MatrixND recruitment = popMon.getRecruitment(date, pop);
log.debug("recruitment: " + recruitment);
// mortalite de la reproduction
popMon.applyReproductionMortality(pop);
N = N.add(recruitment);
log.debug("N after recru: " + N);
// this matrix is necessary for matrixCatchPerStrategyMet
MatrixND catchRatePerStrategyMet = siMatrix.matrixCatchRatePerStrategyMet(pop, date);
resManager.addResult(date, pop, catchRatePerStrategyMet);
// compute some Matrix and add result
MatrixND abundance = siMatrix.matrixAbundance(N, pop, date);
// this matrix is necessary for PopulationMonitor.holdCatch (reused in rule)
MatrixND catchPerStrategyMet = siMatrix.matrixCatchPerStrategyMet(N, pop, date, catchRatePerStrategyMet);
popMon.holdCatch(pop, catchPerStrategyMet);
resManager.addResult(date, pop, catchPerStrategyMet);
if (resManager.isEnabled(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET)) {
MatrixND catchWeightPerStrategyMet = siMatrix.matrixCatchWeightPerStrategyMet(pop, date, catchPerStrategyMet);
resManager.addResult(date, pop, catchWeightPerStrategyMet);
}
log.debug("abundance: " + abundance);
// Keep new N
popMon.setN(pop, abundance);
log.debug("====================== end " + date + " - " + pop +" ===========================");
}
/**
* @param date
* @param resManager
* @throws IsisFishException
* @throws TopiaException
*/
private void saveGravityModel(Date date, ResultStorage resManager, GravityModel gravityModel) throws IsisFishException, TopiaException {
if (resManager.isEnabled(ResultName.MATRIX_FISHING_TIME_PER_MONTH_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixFishingTimePerMonthPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_FUEL_COSTS_OF_TRAVEL_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixFuelCostsOfTravelPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_COSTS_OF_FISHING_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixCostsOfFishingPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_FUEL_COSTS_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixFuelCostsOfTravelPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_REPAIR_AND_MAINTENANCE_GEAR_COSTS_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixRepairAndMaintenanceGearCostsPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_OTHER_RUNNING_COSTS_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixOtherRunningCostsPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_SHARED_NOT_FIXED_COSTS_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixSharedNotFixedCostsPerVessel(date);
resManager.addResult(date, 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.matrixGrossValueOfLandingsPerSpeciesPerStrategyMet(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET)) {
MatrixND mat = gravityModel.matrixGrossValueOfLandingsPerStrategyMet(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixGrossValueOfLandingsPerStrategyMetPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET)) {
MatrixND mat = gravityModel.matrixNetValueOfLandingsPerStrategyMet(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixNetValueOfLandingsPerStrategyMetPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_NET_RENEVUE_TO_SHARE_PER_STRATEGY_MET_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixNetRenevueToSharePerStrategyMetPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_CREW_SHARE_PER_STRATEGY_MET_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixCrewSharePerStrategyMetPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixOwnerMarginOverVariableCostsPerStrategyMetPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_MET_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixVesselMarginOverVariableCostsPerStrategyMetPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixOwnerMarginOverVariableCostsPerStrategyPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_OWNER_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY)) {
MatrixND mat = gravityModel.matrixOwnerMarginOverVariableCostsPerStrategy(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY_PER_VESSEL)) {
MatrixND mat = gravityModel.matrixVesselMarginOverVariableCostsPerStrategyPerVessel(date);
resManager.addResult(date, mat);
}
if (resManager.isEnabled(ResultName.MATRIX_VESSEL_MARGIN_OVER_VARIABLE_COSTS_PER_STRATEGY)) {
MatrixND mat = gravityModel.matrixVesselMarginOverVariableCostsPerStrategy(date);
resManager.addResult(date, mat);
}
}
}
1
0
Salut Benjamin,
J'ai retouché un peu les modifs que j'avais fait à simatrix. Sur la base
de Steph 26min au lieu de 41. Cela dit ça me parait bizarre de tant
gagner (je serai parti dans le swap que ça m'étonnerait pas...).
En fait dans mes modifs, je passais un argument double effort à
catchrateperstrategymet et fishingmortality. Le problème est que du coup
le cache "ne fonctionnait pas" et que les calculs étaient refaits à
chaque fois :-(
Sinon, j'ai aussi essayé de modifier le defaultsimulator. En changeant
l'ordre de calcul de la survie et du taux de captures je pensais
économiser un peu, mais là le gain a l'air plus négligeable (30sec sur
26 min)
A+
Hilaire
[Pièce jointe retirée : type d'origine de la pièce jointe: "text/x-java", nom: "SiMatrix.java"]
[Pièce jointe retirée : type d'origine de la pièce jointe: "text/x-java", nom: "DefaultSimulator.java"]
1
0
Bonjour,
Une nouvelle version d'isis-fish vient d'être mise en place :
http://isis-fish.labs.libre-entreprise.org/download/version3/isis-fish-3.0.…
pour savoir comment installer et lancer isis-fish
http://isis-fish.labs.libre-entreprise.org/v3/user/Installation.html
changelog isis-fish (3.0.18) stable; urgency=low
* bug go.bat have correct DOS end of line
* improve build-release.sh to send email to user and devel list after deploy
* bug correction in delete simulation, remove close context at begin of
clear method
* bug permit simulation without SimulationControl
* bug in queue model test if no more simulation to prevent Index Out of
bound Exception
--
Benjamin
--------------------
tél: +33 (0) 2 40 50 29 28
email: poussin(a)codelutin.com () campagne du ruban ascii
http://www.codelutin.com /\ pour les mails en ascii
1
0
Salut Benjamin,
J'ai essayé de triturer deux ou 3 trucs sur le scipt simatrix. Ca gagne un peu de temps sur la base de Sigrid (4min contre 5min30), mais j'ai pas vérifié les résultats ( :-) ). Si ça t'intéresse je te joins le script. En gros l'astuce consiste à tester (dans totalFishingMortality et CatchRatePerStrategyMet) si effortPerZonePop est non nul avant de lancer FishingMortality donc la boucle sur les groups sautent et on évite de refaire le calcul pleins de fois de l'effort (même si le résultat doit être dans le cache)
A+
Hilaire
--
Hilaire Drouineau
IFREMER, département EMH
Centre de Nantes - BP 21105 - 44311 Nantes Cedex 3
tel : +33 (0)2 40 37 42 12 - fax : +33 (0)2 40 37 40 75
email : hilaire.drouineau(a)ifremer.fr - web : http://www.ifremer.fr/emh
**********************************************************************
/* *##%
* Copyright (C) 2006
* 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 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.
*##%*/
/* *
* SiMatrix.java
*
* Created: 21 août 2006 15:53:01
*
* @author poussin
* @version $Revision: 1.13 $
*
* Last update: $Date: 2007/03/01 17:16:12 $
* by : $Author: bpoussin $
*/
package scripts;
import static org.codelutin.i18n.I18n._;
import static org.codelutin.i18n.I18n.n_;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.math.matrix.MatrixFactory;
import org.codelutin.math.matrix.MatrixIterator;
import org.codelutin.math.matrix.MatrixND;
import org.codelutin.topia.TopiaContext;
import org.codelutin.topia.TopiaException;
import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.entities.Cell;
import fr.ifremer.isisfish.entities.EffortDescription;
import fr.ifremer.isisfish.entities.Gear;
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.PopulationSeasonInfo;
import fr.ifremer.isisfish.entities.Selectivity;
import fr.ifremer.isisfish.entities.SetOfVessels;
import fr.ifremer.isisfish.entities.Strategy;
import fr.ifremer.isisfish.entities.StrategyMonthInfo;
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.entities.ZoneDAO;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.Date;
import fr.ifremer.isisfish.types.Month;
/**
* @author poussin
*
*/
public class SiMatrix {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(SiMatrix.class);
protected SimulationContext context = null;
protected TopiaContext db = null;
/**
* Method used to get SiMatrix used for simulation
* @param context context simulation
* @return SiMatrix or null if no SiMatrix created for simulation
*/
public static SiMatrix getSiMatrix(SimulationContext context) {
SiMatrix result = (SiMatrix)context.getValue(SiMatrix.class.getName());
return result;
}
private static void setSiMatrix(SimulationContext context, SiMatrix siMatrix) {
context.setValue(SiMatrix.class.getName(), siMatrix);
}
/**
*
* @param context Simulation context
* @param db TopiaContext with transaction opened. You must used this
* TopiaContext and not used
* SimulationContext.getSimulationStorage().getStorage()
* @throws TopiaException
*/
public SiMatrix(SimulationContext context) throws TopiaException {
this.context = context;
this.db = context.getDB();
setSiMatrix(context, this);
}
/**
* @return
* @throws TopiaException
*/
public List<Zone> getZones(Date date) throws TopiaException {
ZoneDAO dao = IsisFishDAOHelper.getZoneDAO(db);
List<Zone> result = dao.findAll();
return result;
}
/**
* @return
* @throws TopiaException
*/
public List<Population> getPopulations(Date date) throws TopiaException {
List<Population> populations = new ArrayList<Population>();
for (Population pop : context.getSimulationStorage().getParameter().getPopulations()) {
Population tmp = (Population)db.findByTopiaId(pop.getTopiaId());
populations.add(tmp);
}
return populations;
}
/**
* @return
* @throws TopiaException
*/
public List<Strategy> getStrategies(Date date) throws TopiaException {
// if (strategies == null) {
List<Strategy> strategies = new ArrayList<Strategy>();
for (Strategy str : context.getSimulationStorage().getParameter().getStrategies()) {
Strategy tmp = (Strategy)db.findByTopiaId(str.getTopiaId());
strategies.add(tmp);
}
// }
return strategies;
}
public List<Metier> getMetiers(Date date) throws TopiaException {
// if (metiers == null) {
List<Metier> metiers = new ArrayList<Metier>();
HashSet<Metier> tmp = new HashSet<Metier>();
for (Strategy str : getStrategies(date)) {
SetOfVessels sov = str.getSetOfVessels();
for (EffortDescription effort : sov.getPossibleMetiers()) {
Metier metier = effort.getPossibleMetiers();
if (tmp.add(metier)) {
metiers.add(metier);
}
}
}
// }
return metiers;
}
/**
* Retourne les metiers pratiqués par une Strategie à une date donnée
* Un metier est pratiqué si le PropStrMet est différent de 0
*
* @param str
* @param date
* @return
*/
public List<Metier> getMetiers(Strategy str, Date date) {
StrategyMonthInfo info = str.getStrategyMonthInfo(date.getMonth());
MatrixND props = info.getProportionMetier();
List<Metier> result = new ArrayList<Metier>();
for (MatrixIterator i=props.iterator(); i.hasNext();) {
i.next();
if (i.getValue() != 0) {
Metier metier = (Metier)i.getSemanticsCoordinates()[0];
result.add(metier);
}
}
return result;
}
/**
* Retourne la matrix Metier x Zone qui correspond au zone utilisé par
* un métier pour une date donnée. Si la valeur de la matrice est 1 alors
* la zone est utilisé par le métier, si elle vaut 0 alors elle n'est pas
* utilisée.
*
* @param date
* @return
* @throws TopiaException
*/
public MatrixND getMetierZone(Date date) throws TopiaException {
List<Metier> metiers = getMetiers(date);
List<Zone> zones = getZones(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_METIER_ZONE,
new List[]{metiers, zones},
new String[]{n_("Metiers"), n_("Zones")});
for (Metier metier : metiers) {
Collection<Zone> zoneMetier = metier.getMetierSeasonInfo(date.getMonth()).getZone();
for (Zone zone : zoneMetier) {
result.setValue(metier, zone, 1);
}
}
return result;
}
public MatrixND matrixPrice(Date date, Population pop) {
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_PRICE,
new List[]{groups},
new String[]{n_("PopulationGroup")});
for (PopulationGroup group : groups) {
result.setValue(group, group.getPrice());
}
return result;
}
///////////////////////////////////////////////////////////////////////////
//
// Toutes les methodes suivantes ne sont utiles que pour
// matrixCatchPerStrategyMet
//
///////////////////////////////////////////////////////////////////////////
/**
* Matrice des captures en nombre
* dim [ Strategy x Metier x Classe x zonePop ]
*
* @param N l'abondance sous forme de matrice 2D [class x zone]
* @param pop
* @param date
* @return
* @throws TopiaException
* @throws IsisFishException
*/
public MatrixND matrixCatchPerStrategyMet(MatrixND N, Population pop,
Date date, MatrixND matrixCatchRatePerStrategyMet) throws TopiaException, IsisFishException {
List<PopulationGroup> groups = pop.getPopulationGroup();
List<Zone> zones = pop.getPopulationZone();
// on le passe en argument ce qui evite de le calculer 2 fois
// MatrixND matrixCatchRatePerStrategyMet = matrixCatchRatePerStrategyMet(pop, date);
MatrixND result = matrixCatchRatePerStrategyMet.copy();
result.setName(ResultName.MATRIX_CATCH_PER_STRATEGY_MET);
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;
}
/**
* Matrice des captures en poids
* dim [ Strategy x Metier x Classe x zonePop ]
*
* @param pop
* @param date
* @return
* @throws TopiaException
* @throws IsisFishException
*/
public MatrixND matrixCatchRatePerStrategyMet(Population pop, Date date) throws TopiaException, IsisFishException {
List<Strategy> strategies = getStrategies(date);
List<Metier> metiers = getMetiers(date);
List<PopulationGroup> groups = pop.getPopulationGroup();
List<Zone> zones = pop.getPopulationZone();
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_CATCH_RATE_PER_STRATEGY_MET,
new List[]{strategies, metiers, groups, zones},
new String[]{n_("Strategies"), n_("Metiers"), n_("Groups"), n_("Zones")});
for (int s=0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = getMetiers(str, date);
for (int m=0; m < metiers.size(); m++) {
Metier metier = metiers.get(m);
for (int z=0; z < zones.size(); z++) {
Zone zone = zones.get(z);
double effort=effortPerZonePop(str,metier,date,zone);
if (effort>0){
for (int g=0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
double value = catchRatePerStrategyMet(str, metier, date, group, zone,effort);
result.setValue(str, metier, group, zone, value);
}
}
else {
for (int g=0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
result.setValue(str, metier, group, zone, 0);
}
}
}
}
}
// for (Strategy str : strategies) {
// List<Metier> metierStr = getMetiers(str, date);
// for (Metier metier : metierStr) {
// for (PopulationGroup group : groups) {
// for (Zone zone : zones) {
// double val = catchRatePerStrategyMet(str, metier, date, group, zone);
// result.setValue(str, metier, group, zone, val);
// }
// }
// }
// }
return result;
}
/**
* @param str
* @param metier
* @param date
* @param group
* @param zone
* @return
* @throws TopiaException
* @throws IsisFishException
*/
private double catchRatePerStrategyMet(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone,double effort) throws TopiaException, IsisFishException {
double totalFishingMortality = totalFishingMortality(date, group, zone);
if(totalFishingMortality == 0){
if(log.isDebugEnabled()) {log.debug("pas de totalFishingMortality pour (" + group + ", " + zone +")");}
return 0;
}
double fishingMortality = fishingMortality(str, metier, date, group, zone,effort);
double totalCatchRate = totalCatchRate(date, group, zone, totalFishingMortality);
if(log.isDebugEnabled()) {
log.debug(
" totalFishingMortality=" + totalFishingMortality +
" fishingMortality=" + fishingMortality +
" totalCatchRate=" + totalCatchRate);
}
double result = fishingMortality / totalFishingMortality * totalCatchRate;
return result;
}
/**
* @param date
* @param group
* @param zone
* @param totalFishingMortality
* @return
* @throws TopiaException
*/
private double totalCatchRate(Date date, PopulationGroup group,
Zone zone, double totalFishingMortality) throws TopiaException {
double M = group.getNaturalDeathRate(zone) / Month.NUMBER_OF_MONTH;
if(M == 0){
// normalement il devrait y avoir de la mortalite naturelle
if (log.isWarnEnabled()) {
log.warn("Pas de mortalité naturelle pour: " + group);
}
}
double F = totalFishingMortality;
double result = 0;
if( M != 0 || F != 0){
result = F/(F+M) * (1 - Math.exp(-(F+M)));
}
return result;
}
/**
* @param date
* @param group
* @param zone
* @return
* @throws TopiaException
* @throws IsisFishException
*/
private double totalFishingMortality(Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException {
List<Strategy> strategies = getStrategies(date);
float result = 0;
for(Strategy str : strategies){
List<Metier> metierStr = getMetiers(str, date);
for (Metier metier : metierStr) {
double effort=effortPerZonePop(str,metier,date,zone);
// TODO peut etre ne pas le faire si classe.pop n'est pas
/// peche par le metier
if (effort>0)
result += fishingMortality(str, metier, date, group, zone,effort);
}
}
return result;
}
/**
* @param str
* @param metier
* @param date
* @param group
* @param zone
* @return
* @throws IsisFishException
*/
private double fishingMortality(Strategy str, Metier metier, Date date, PopulationGroup group, Zone zone,double effort) throws IsisFishException {
Month month = date.getMonth();
Population pop = group.getPopulation();
Gear gear = metier.getGear();
Selectivity selectivity = gear.getPopulationSelectivity(pop);
double result = 0;
if (selectivity != null) {
MetierSeasonInfo infoMet = metier.getMetierSeasonInfo(month);
double ciblage = infoMet.getTargetFactor(group);
PopulationSeasonInfo infoPop = pop.getPopulationSeasonInfo(month);
double capturability = infoPop.getCapturability(group);
double coeff = selectivity.getCoefficient(pop, group, metier);
if(log.isDebugEnabled()) {
log.debug(
" strategy=" + str +
" metier=" + metier +
" ciblage=" + ciblage +
" capturabilite=" + capturability +
" selectivity=" + coeff +
" effort=" + effort);
}
result = coeff * capturability * ciblage * effort;
}
return result;
}
/**
* @param str
* @param metier
* @param date
* @param zone
* @return
*/
private double effortPerZonePop(Strategy str, Metier metier, Date date, Zone zonePop) {
Month month = date.getMonth();
Collection<Zone> zoneMet = metier.getMetierSeasonInfo(month).getZone();
double inter = nbCellInter(zoneMet, zonePop);
double effortPerStrategyPerCell = effortPerStrategyPerCell(str, metier, date);
if(log.isDebugEnabled()) {
log.debug(
" strategy=" + str +
" metier=" + metier +
" inter=" + inter +
" effortPerStrategyPerCell=" + effortPerStrategyPerCell
);
}
double result = effortPerStrategyPerCell * inter;
return result;
}
/**
* @param str
* @param metier
* @param date
* @return
*/
private double effortPerStrategyPerCell(Strategy str, Metier metier, Date date) {
Month month = date.getMonth();
StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
Collection<Zone> zones = metier.getMetierSeasonInfo(month).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()) log.warn("Calcul d'une distance avec une zone sans maille");
return 0;
}
double effortPerStrategy = effortPerStrategyMet(str, metier, date);
if(log.isDebugEnabled()) {
log.debug(
" strategy=" + str +
" metier=" + metier +
" nbCell=" + nbCell +
" effortPerStrategy=" + effortPerStrategy
);
}
double result = effortPerStrategy/nbCell;
return result;
}
/**
* @param str
* @param metier
* @param date
* @return
*/
private double effortPerStrategyMet(Strategy str, Metier metier, Date date) {
Month month = date.getMonth();
StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
double propSetOfVessels = str.getProportionSetOfVessels();
int nbOfVessels = str.getSetOfVessels().getNumberOfVessels();
double propStrMet = smi.getProportionMetier(metier);
double effortPerVessel = effortPerStrategyPerVessel(str, metier, date);
if(log.isDebugEnabled()) {
log.debug(
" strategy=" + str +
" metier=" + metier +
" propSetOfVessels=" + propSetOfVessels +
" nbOfVessels=" + nbOfVessels +
" propStrMet=" + propStrMet +
" effortPerVessel=" + effortPerVessel
);
}
double result = propSetOfVessels * nbOfVessels * propStrMet * effortPerVessel;
return result;
}
/**
* @param str
* @param metier
* @param date
* @return
*/
private double effortPerStrategyPerVessel(Strategy str, Metier metier, Date date) {
Month month = date.getMonth();
StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
int nbTrips = smi.getNumberOfTrips();
double fishingTime = fishingTimePerTrip(str, metier, date);
double stdEffortPerHour = stdEffortPerHour(str.getSetOfVessels(), metier);
if(log.isDebugEnabled()) {
log.debug(
" strategy=" + str +
" metier=" + metier +
" nbTrips=" + nbTrips +
" fishingTime=" + fishingTime +
" stdEffortPerHour=" + stdEffortPerHour
);
}
double result = nbTrips * fishingTime * stdEffortPerHour;
return result;
}
/**
* Used in GravityModel too
*
* @param str
* @param metier
* @param date
* @return
*/
protected double fishingTimePerTrip(Strategy str, Metier metier, Date date) {
Month month = date.getMonth();
StrategyMonthInfo smi = str.getStrategyMonthInfo(month);
Collection<Zone> zone = metier.getMetierSeasonInfo(month).getZone();
if (zone == null) {
if(log.isWarnEnabled()) log.warn(
"missing zone for metier =" + metier +
" for month" + month
);
}
double tripDuration = smi.getTripType().getTripDuration().getHour();
double travelTime = travelTimePerTrip(str.getSetOfVessels(), zone);
double result = tripDuration - travelTime;
if (result < 0 ) {
if(log.isWarnEnabled()) log.warn(
" strategy=" + str +
" metier=" + metier +
" tripDuration=" + tripDuration +
" travelTime=" + travelTime
);
}
return result;
}
/**
*
* @param setOfVessels
* @param zone
* @return
*/
protected double travelTimePerTrip(SetOfVessels sov, Collection<Zone> zoneMetier) {
Cell maille = sov.getPort().getCell();
double result =
2 * distance(zoneMetier, maille) / sov.getVesselType().getSpeed();
return result;
}
/**
* @param zoneMetier
* @param maille
* @return
*/
private double distance(Collection<Zone> zones, Cell cell) {
double result = 0;
List<Cell> cells = getCells(zones);
if(cells.size() == 0){
// normalement il devrait y avoir des mailles, mais pour les
// ancienne zone AuPort, il n'y en avait pas
if(log.isWarnEnabled()) {
log.warn("Calcul d'une distance avec une zone sans maille");
}
return 0;
}
for(Cell c : cells){
result += distance(c, cell);
}
if(log.isDebugEnabled()) {
log.debug(" result=" + result + " nbMaille="+cells.size());
}
result = result / (double)cells.size();
return result;
}
/**
* @param c
* @param cell
* @return
*/
private double distance(Cell m1, Cell m2) {
double earthRadius = 6378.388;
double p = 180/Math.PI;
if(log.isDebugEnabled()) log.debug("p: " + p);
double m1lat = m1.getLatitude();
double m2lat = m2.getLatitude();
double m1lon = m1.getLongitude();
double m2lon = m2.getLongitude();
if(log.isDebugEnabled()) log.debug(
" m1lat=" + m1lat +
" m2lat=" + m2lat +
" m1lon=" + m1lon +
" m2lonx=" + m2lon
);
double m1lat_div_p = m1lat/p;
double m2lat_div_p = m2lat/p;
double m1lon_div_p = m1lon/p;
double m2lon_div_p = m2lon/p;
if(log.isDebugEnabled()) log.debug(
" m1lat_div_p=" + m1lat_div_p +
" m2lat_div_p=" + m2lat_div_p +
" m1lon_div_p=" + m1lon_div_p +
" m2lon_div_p=" + m2lon_div_p
);
double sin_m1lat_div_p = Math.sin(m1lat_div_p);
double sin_m2lat_div_p = Math.sin(m2lat_div_p);
double cos_m1lat_div_p = Math.cos(m1lat_div_p);
double cos_m2lat_div_p = Math.cos(m2lat_div_p);
if(log.isDebugEnabled()) log.debug(
" sin_m1lat_div_p=" + sin_m1lat_div_p +
" sin_m2lat_div_p=" + sin_m2lat_div_p +
" cos_m1lat_div_p=" + cos_m1lat_div_p +
" cos_m2lat_div_p=" + cos_m2lat_div_p
);
double cos_m1lon_div_p_minus_m2lon_div_p = Math.cos(m1lon_div_p - m2lon_div_p);
if(log.isDebugEnabled()) log.debug(
" cos_m1lon_div_p_minus_m2lon_div_p=" + cos_m1lon_div_p_minus_m2lon_div_p);
double acos = Math.acos(
sin_m1lat_div_p
* sin_m2lat_div_p
+
cos_m1lat_div_p
* cos_m2lat_div_p
* cos_m1lon_div_p_minus_m2lon_div_p
);
if(log.isDebugEnabled()) log.debug(" acos=" + acos);
double result = earthRadius * acos;
return result;
}
/**
* @param setOfVessels
* @param metier
* @return
*/
private double stdEffortPerHour(SetOfVessels sov, Metier metier) {
double result = 0;
EffortDescription ed = sov.getPossibleMetiers(metier);
if(ed != null){
double fstd = metier.getGear().getStandardisationFactor();
double val = fstd * ed.getFishingOperation() * ed.getGearsNumberPerOperation();
result = val;
}
result = result/24; // 24 heures
return result;
}
/**
* used here and in Rule (CantonnementPreSimu)
*
* @param zones
* @return
*/
public List<Cell> getCells(Collection<Zone> zones) {
List<Cell> result = new ArrayList<Cell>();
for (Zone zone : zones) {
result.addAll(zone.getCell());
}
return result;
}
/**
* used here and in Rule (CantonnementPreSimu)
*
* @param zoneMet
* @param zonePop
* @return
*/
public int nbCellInter(Collection<Zone> zoneMet, Zone zonePop) {
List<Cell> cells = getCells(zoneMet);
List<Cell> tmp = new ArrayList<Cell>(cells);
tmp.retainAll(zonePop.getCell());
return tmp.size();
}
///////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////
/**
* @param N
* @param pop
* @param date
* @return
* @throws IsisFishException
* @throws TopiaException
*/
public MatrixND matrixAbundance(MatrixND N, Population pop, Date date) throws TopiaException, IsisFishException {
List<PopulationGroup> groups = pop.getPopulationGroup();
List<Zone> zones = pop.getPopulationZone();
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_ABUNDANCE,
new List[]{groups, zones},
new String[]{n_("Groups"), n_("Zones")});
for (int g=0; g < groups.size(); g++) {
PopulationGroup group = groups.get(g);
for (int z=0; z < zones.size(); z++) {
Zone zone = zones.get(z);
double value = survivalRate(date, group, zone);
double n = N.getValue(g, z);
value *= n;
result.setValue(g, z, value);
}
}
// for(PopulationGroup group : groups){
// for(Zone zone : zones){
// double val = survivalRate(date, group, zone);
// val *= N.getValue(group, zone);
// result.setValue(group, zone, val);
// }
// }
return result;
}
/**
* @param date
* @param group
* @param zone
* @return
* @throws IsisFishException
* @throws TopiaException
*/
private double survivalRate(Date date, PopulationGroup group, Zone zone) throws TopiaException, IsisFishException {
double F = totalFishingMortality(date, group, zone); // rem perf: totalFishingMortality a deja ete calculé
double M = group.getNaturalDeathRate(zone)/(double)Month.NUMBER_OF_MONTH;
double result = (double)Math.exp(-(F+M));
return result;
}
///////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////
/**
* @param n
* @param pop
* @param date
* @return
*/
public MatrixND matrixBiomass(MatrixND N, Population pop, Date date) {
List<PopulationGroup> groups = N.getSemantics(0);
List<Zone> zones = N.getSemantics(1);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_BIOMASS,
new List[]{groups, zones},
new String[]{n_("Groups"), n_("Zones")});
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);
}
}
// for(PopulationGroup group : groups){
// double meanWeight = group.getMeanWeight();
// for(Zone zone : zones){
// double val = N.getValue(group, zone) * meanWeight;
// result.setValue(group, zone, val);
// }
// }
return result;
}
///////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////
/**
* @param date
* @return
* @throws TopiaException
*/
public MatrixND matrixEffortPerStrategyMet(Date date) throws TopiaException {
List<Strategy> strategies = getStrategies(date);
List<Metier> metiers = getMetiers(date);
MatrixND result = MatrixFactory.getInstance().create(
ResultName.MATRIX_EFFORT_PER_STRATEGY_MET,
new List[]{strategies, metiers},
new String[]{n_("Strategies"), n_("Metiers")});
for (int s=0; s < strategies.size(); s++) {
Strategy str = strategies.get(s);
metiers = getMetiers(str, date);
for (int m=0; m < metiers.size(); m++) {
Metier metier = metiers.get(m);
double value = effortPerStrategyMet(str, metier, date);
result.setValue(str, metier, value);
}
}
// for(Strategy str : strategies){
// List<Metier> metierStr = getMetiers(str, date);
// for(Metier metier : metierStr) {
// double val = effortPerStrategyMet(str, metier, date); // rem perf: effortPerStrategyMet a deja ete calculé
// result.setValue(str, metier, val);
// }
// }
return result;
}
///////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////
/**
* @param pop
* @param date
* @return
*/
public MatrixND matrixCatchWeightPerStrategyMet(Population pop,
Date date, MatrixND matrixCatchPerStrategyMet) {
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = matrixCatchPerStrategyMet.copy();
result.setName(ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET);
for(PopulationGroup group : groups){
MatrixND sub = result.getSubMatrix(2, group, 1);
double meanWeight = group.getMeanWeight();
sub.mults(meanWeight);
}
return result;
}
/**
* @param pop
* @param date
* @return
*/
public MatrixND matrixDiscardWeightPerStrategyMet(Population pop,
Date date, MatrixND matrixDiscardPerStrategyMet) {
List<PopulationGroup> groups = pop.getPopulationGroup();
MatrixND result = matrixDiscardPerStrategyMet.copy();
result.setName(ResultName.MATRIX_DISCARDS_WEIGHT_PER_STR_MET);
for(PopulationGroup group : groups){
MatrixND sub = result.getSubMatrix(2, group, 1);
double meanWeight = group.getMeanWeight();
sub.mults(meanWeight);
}
return result;
}
}
3
3
Bonjour,
Une nouvelle version d'isis-fish vient d'être mise en place :
http://isis-fish.labs.libre-entreprise.org/download/version3/isis-fish-3.0.…
pour savoir comment installer et lancer isis-fish
http://isis-fish.labs.libre-entreprise.org/v3/user/Installation.html
changelog isis-fish (3.0.17) stable; urgency=low
* add support for filename and extension in export script
Pensez a mettre a jour vos scripts d'export
menu file->server synchro
selectionnez tous les scripts d'export et validez
--
Benjamin
--------------------
tél: +33 (0) 2 40 50 29 28
email: poussin(a)codelutin.com () campagne du ruban ascii
http://www.codelutin.com /\ pour les mails en ascii
1
0
Bonjour,
Une nouvelle version d'isis-fish vient d'être mise en place :
http://isis-fish.labs.libre-entreprise.org/download/version3/isis-fish-3.0.…
pour savoir comment installer et lancer isis-fish
http://isis-fish.labs.libre-entreprise.org/v3/user/Installation.html
changelog
ver-3.0.16 poussin 20070521
* add ssj jar to have random library
* add support to auto upgrade database (topia migration service)
* bug force reload parameter in thread simulation to prevent class
cast exception because same class is loaded in two different classloader
Le plus important est la presence des classes ssj () et la correction
d'un problème de class cast exception dans les regles du a
l'utilisation de deux classloader different.
--
Benjamin
--------------------
tél: +33 (0) 2 40 50 29 28
email: poussin(a)codelutin.com () campagne du ruban ascii
http://www.codelutin.com /\ pour les mails en ascii
2
4
Rebonjour Benjamin
travaillant sur les graphes d'ISIS avec IsisGraph et IsisMap, je
m'apercois que la terminaison des fichiers d'export n'est plus la meme.
Peux-tu remettre .csv a la fin des fichiers d'export?
je suis allee voir dans les scripts d'export mais je ne vois pas le nom
du fichier d'export. est-ce simplement le meme nom que celui de la methode?
merci
stephanie
--
......................................................................
Stephanie MAHEVAS (Stephanie.Mahevas(a)ifremer.fr)
IFREMER/EMH (Ecologie et Modèles pour l'Halieutique)
Tel: 02 40 37 41 81 Fax: 02 40 37 40 75
o \ o / _ o __| \ / |__ o _ \ o / o
/|\ | /\ ___\o \o | o/ o/__ /\ | /|\
/ \ / \ | \ /) | ( \ /o\ / ) | (\ / | / \ / \
......................................................................
2
2