hello, vous pouvez m'expliquer ?
MERCI
C:\Documents and
Settings\slehuta\isis-database-3\rules\FrRuleBMPARumMultiCost_Anchois.java:614:
incompatible types
found : java.util.List<capture#229 of ?>
required: java.util.List<fr.ifremer.isisfish.entities.Strategy>
List<Strategy> strategies = currentMatrixVar.getSemantics(0);
^
C:\Documents and
Settings\slehuta\isis-database-3\rules\FrRuleBMPARumMultiCost_Anchois.java:615:
incompatible types
found : java.util.List<capture#212 of ?>
required: java.util.List<fr.ifremer.isisfish.entities.Metier>
List<Metier> metiers = currentMatrixVar.getSemantic(1);
--
Sigrid LEHUTA
~ ><> ~
Doctorante
Département Ecologie et Modèles pour l'Halieutique
IFREMER, rue de l'ile d'Yeu BP 21105
44311 Nantes Cedex 03
Tél : +33 (0)2 40 37 41 23 (interne : 8123)
package rules;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import static org.nuiton.i18n.I18n._;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.*;
import scripts.ResultName;
import scripts.RuleUtil;
import scripts.SiMatrix;
import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.entities.*;
import fr.ifremer.isisfish.rule.AbstractRule;
import fr.ifremer.isisfish.simulator.MetierMonitor;
import fr.ifremer.isisfish.simulator.PopulationMonitor;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.simulator.SimulationContext;
import fr.ifremer.isisfish.types.Date;
import fr.ifremer.isisfish.types.Month;
import org.nuiton.topia.*;// pour pouvoir utiliser la methode StringUtil.toDouble()
import org.nuiton.util.*;// pour pouvoir utiliser la methode StringUtil.toDouble()
import scripts.ResultName;
import java.io.*;
import java.util.*;
import org.nuiton.math.matrix.*;
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.SimulationParameter;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.datastore.ResultStorage;
/**
*based on TACMPARUMMultiCosts.java
*
* Created: 14 01 2010
*
* @author anonymous <anonymous(a)labs.libre-entreprise.org>
* @version $Revision: 1.3 $
*
* Last update: $Date: 2007/01/24 18:25:34 $
* by : $Author: bpoussin $
*/
/**
*
*/
public class FrTACMPARumMultiCost_Anchois extends AbstractRule {
/** to use log facility, just put in your code: log.info("..."); */
static private Log log = LogFactory.getLog(FrTACMPARumMultiCost_Anchois.class);
/** public : **/
public Population param_pop = null ;
public Double param_fuelprice = 0.3411;
public Month param_beginMonth = Month.JULY;
public Month param_endMonth = Month.JUNE;
public Date param_beginDateTAC = new Date(6);
public Date param_endDateTAC = new Date(500);
public double param_tacInTons = 13200;
public double param_SSBmay = 0;
public Zone param_zoneMPA = null;
public Date param_beginDateMPA = new Date(12); // obligatoire de commencer l'anne 1 pour pouvoir appliquer le RUM
public Date param_endDateMPA = new Date(500);
public Month param_beginMonthMPA = Month.APRIL;
public Month param_endMonthMPA = Month.JULY;
/** matrix of coefficients of rum**/
String param_nomfichier_coeffRUM0 = "Inputs_Anchois/CoeffRumMultiCost/CoeffRum0.csv";//0=str_bolbasques
String param_nomfichier_coeffRUM1 = "Inputs_Anchois/CoeffRumMultiCost/CoeffRum1.csv";//1=str_bolbretons
String param_nomfichier_coeffRUM2 = "Inputs_Anchois/CoeffRumMultiCost/CoeffRum2.csv";//2=str_pelprofil1
String param_nomfichier_coeffRUM3 = "Inputs_Anchois/CoeffRumMultiCost/CoeffRum3.csv";//3=str_pelprofil2
/**matrix of coefficients of relations Effort - Value others met other et anchovy et anchovy met other **/
String param_nomfichier_coeffOthers0 = "Inputs_Anchois/CoeffOthers_ssIntercept/CoeffOthers0.csv";
String param_nomfichier_coeffOthers1 = "Inputs_Anchois/CoeffOthers_ssIntercept/CoeffOthers1.csv";
String param_nomfichier_coeffOthers2 = "Inputs_Anchois/CoeffOthers_ssIntercept/CoeffOthers2.csv";
String param_nomfichier_coeffOthers3 = "Inputs_Anchois/CoeffOthers_ssIntercept/CoeffOthers3.csv";
/**matrix of mean VPUE over 2000-2004 per french strategie an species**/
String param_nomfichier_VPUE0_A = "Inputs_Anchois/VPUEMoyen20002004/VPUEMoy0_A.csv";
String param_nomfichier_VPUE1_A = "Inputs_Anchois/VPUEMoyen20002004/VPUEMoy1_A.csv";//yv
String param_nomfichier_VPUE2_A = "Inputs_Anchois/VPUEMoyen20002004/VPUEMoy2_A.csv";//yv
String param_nomfichier_VPUE3_A = "Inputs_Anchois/VPUEMoyen20002004/VPUEMoy3_A.csv";//yv
String param_nomfichier_VPUE0_O = "Inputs_Anchois/VPUEMoyen20002004/VPUEMoy0_O.csv";
String param_nomfichier_VPUE1_O = "Inputs_Anchois/VPUEMoyen20002004/VPUEMoy1_O.csv";//yv
String param_nomfichier_VPUE2_O = "Inputs_Anchois/VPUEMoyen20002004/VPUEMoy2_O.csv";//yv
String param_nomfichier_VPUE3_O = "Inputs_Anchois/VPUEMoyen20002004/VPUEMoy3_O.csv";//yv
/**matrix o distances**/
String param_nomfichier_distances0 = "Inputs_Anchois/CoeffRumMultiCost/Distances0.csv";
String param_nomfichier_distances1 = "inputs_Anchois/CoeffRumMultiCost/Distances1.csv";
String param_nomfichier_distances2 = "Inputs_Anchois/CoeffRumMultiCost/Distances2.csv";
String param_nomfichier_distances3 = "Inputs_Anchois/CoeffRumMultiCost/Distances3.csv";
/** protected RUM**/
static final protected String VPUE_O = "LandingsValueOther";
static final protected String VPUE_A = "LandingsValueAnchovy";
static final protected String INTERCEPT = "Intercept";
static final protected String EFFORT_PY = "EffortPY";
static final protected String EFFORT_PM = "EffortPM";
static final protected String EFFORT = "Effort";
static final protected String LVALUE_O = "LandingsValueOther";
static final protected String LVALUE_A = "LandingsValueAnchovy";
static final protected String BETA_O = "BetaOthers";
static final protected String BETA_A = "BetaAnchovy";
static final protected String ALPHA_O = "AlphaOthers";
static final protected String ALPHA_A = "AlphaAnchovy";
static final protected String COST = "Cost";
protected File CoeffRum0;
protected File CoeffRum1;
protected File CoeffRum2;
protected File CoeffRum3;
protected File CoeffOthers0;
protected File CoeffOthers1;
protected File CoeffOthers2;
protected File CoeffOthers3;
protected File VPUE0_A;
protected File VPUE1_A;
protected File VPUE2_A;
protected File VPUE3_A;
protected File VPUE0_O;
protected File VPUE1_O;
protected File VPUE2_O;
protected File VPUE3_O;
protected File Distances0;
protected File Distances1;
protected File Distances2;
protected File Distances3;
protected MatrixND matrixCoeffRUM;
protected MatrixND matrixCoeffOthers;
protected MatrixND matrixAverageVPUE_A;
protected MatrixND matrixAverageVPUE_O;
protected MatrixND matrixVar;
protected MatrixND matrixDistances;
protected MatrixND vectorTACPresenceAbsence; // vector TAC reached last year
protected MatrixND matMPAPresenceAbsence; // matrice strategy x metier x mois de presence absence MPA totale
/** To keep and export %effort / metier date**/
File exportEffort = new File ("Effort.csv");//yv
protected List<Metier> metiers;
protected Map<String , Strategy> mesStrategies;
protected boolean first = true;
protected String [] necessaryResult = {
ResultName.MATRIX_BIOMASS,
ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET,
ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP,
ResultName.MATRIX_EFFORT_PER_STRATEGY_MET,
ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET,
};
/**
* @return the necessaryResult
*/
public String[] getNecessaryResult() {
return this.necessaryResult;
}
/**
* Permet d'afficher a l'utilisateur une aide sur la regle.
* @return L'aide ou la description de la regle
*/
public String getDescription() {
return _("TAC RULE B gamma = 40% partage a 50% entre les espagnols et les francais /"+
"MPA sur tous les engins"+
"et calcul le temps passe sur chaque metier possible a l aide des RUM / "+
"necessite au moins 2 annes de simulation / "+
"attend une matrice de coefficients du RUM / "+
"une matrice de coeff pour le calcul des valeurs des especes non decrites / "+
"exporte les pourcentages et valeurs calculees chaque mois");
}
/**
* Appelthode permet d'initialiser
* des valeurs
* @param simulation La simulation pour lequel on utilise cette regle
*/
public void init(SimulationContext context) throws Exception {
//System.out.println("est ce qu il passe dans le init ?");
/** load coefficients of rum file in a matrix**/
if (param_nomfichier_coeffRUM0==null || "".equals(param_nomfichier_coeffRUM0)){
CoeffRum0 = FileUtil.getFile(".*.csv", "fichierRum 0 csv separateur ';'");
CoeffRum1 = FileUtil.getFile(".*.csv", "fichierRum 1 csv sparateur ';'");
CoeffRum2 = FileUtil.getFile(".*.csv", "fichierRum 2 csv sparateur ';'");
CoeffRum3 = FileUtil.getFile(".*.csv", "fichierRum 3 csv sparateur ';'");
} else {
CoeffRum0 = new File(param_nomfichier_coeffRUM0);
CoeffRum1 = new File(param_nomfichier_coeffRUM1);
CoeffRum2 = new File(param_nomfichier_coeffRUM2);
CoeffRum3 = new File(param_nomfichier_coeffRUM3);
}
/** load coefficients of relation others file in a matrix**/
if (param_nomfichier_coeffOthers0==null || "".equals(param_nomfichier_coeffOthers0)){
CoeffOthers0 = FileUtil.getFile(".*.csv", "fichierOthers 0 csv sparateur ';'");
CoeffOthers1 = FileUtil.getFile(".*.csv", "fichierOthers 1 csv sparateur ';'");
CoeffOthers2 = FileUtil.getFile(".*.csv", "fichierOthers 2 csv sparateur ';'");
CoeffOthers3 = FileUtil.getFile(".*.csv", "fichierOthers 3 csv sparateur ';'");
} else {
CoeffOthers0 = new File(param_nomfichier_coeffOthers0);
CoeffOthers1 = new File(param_nomfichier_coeffOthers1);
CoeffOthers2 = new File(param_nomfichier_coeffOthers2);
CoeffOthers3 = new File(param_nomfichier_coeffOthers3);
}
/**load mean VPUE per French strategy*coeff*metier*month**/
if (param_nomfichier_VPUE0_A==null || "".equals(param_nomfichier_VPUE0_A)){
VPUE0_A = FileUtil.getFile(".*.csv", "fichierAverageVPUE_A 0 csv parateur ';'");
VPUE1_A = FileUtil.getFile(".*.csv", "fichierAverageVPUE_A 1 csv sparateur ';'");
VPUE2_A = FileUtil.getFile(".*.csv", "fichierAverageVPUE_A 2 csv sparateur ';'");
VPUE3_A = FileUtil.getFile(".*.csv", "fichierAverageVPUE_A 3 csv sparateur ';'");
VPUE0_O = FileUtil.getFile(".*.csv", "fichierAverageVPUE_O 0 csv sparateur ';'");
VPUE1_O = FileUtil.getFile(".*.csv", "fichierAverageVPUE_O 1 csv sparateur ';'");
VPUE2_O = FileUtil.getFile(".*.csv", "fichierAverageVPUE_O 2 csv sparateur ';'");
VPUE3_O = FileUtil.getFile(".*.csv", "fichierAverageVPUE_O 3 csv sparateur ';'");
} else {
VPUE0_A = new File(param_nomfichier_VPUE0_A);
VPUE1_A = new File(param_nomfichier_VPUE1_A);
VPUE2_A = new File(param_nomfichier_VPUE2_A);
VPUE3_A = new File(param_nomfichier_VPUE3_A);
VPUE0_O = new File(param_nomfichier_VPUE0_O);
VPUE1_O = new File(param_nomfichier_VPUE1_O);
VPUE2_O = new File(param_nomfichier_VPUE2_O);
VPUE3_O = new File(param_nomfichier_VPUE3_O);
}
//Load file of distances
Distances0 = new File(param_nomfichier_distances0);
Distances1 = new File(param_nomfichier_distances1);
Distances2 = new File(param_nomfichier_distances2);
Distances3 = new File(param_nomfichier_distances3);
/** reccuperation des metiers et strategies**/
SiMatrix siMatrix = SiMatrix.getSiMatrix(context);
metiers = siMatrix.getMetiers(new Date(0));
List<Strategy> allStrategies = siMatrix.getStrategies(new Date(0));
List <String> coeffs = Arrays.asList(new String[]{ALPHA_O,BETA_O,ALPHA_A,BETA_A});
List <String> coeffRum = Arrays.asList(new String[]{INTERCEPT, EFFORT_PY, EFFORT_PM, VPUE_O ,VPUE_A, COST});
List <Month> months = Month.getMonths(Month.JANUARY,Month.DECEMBER);
//System.out.println("liste mois: " + months);
// creation de mes strategies qui ne contient pas les espagnols
mesStrategies = new HashMap<String, Strategy>();
for(Strategy str : allStrategies) {
mesStrategies.put(str.getName(), str);
}
mesStrategies.remove("Espagnols");
//// import des fichiers de coeff des rum [1 par strategie, metier*coeff]
MatrixND matCoeffRum0 = MatrixFactory.getInstance().create(
"matCoeffRum0",
new List[]{ metiers,coeffRum},
new String[]{"Metiers","Coeff"});
MatrixND matCoeffRum1 = MatrixFactory.getInstance().create(
"matCoeffRum1",
new List[]{ metiers,coeffRum},
new String[]{"Metiers","Coeff"});
MatrixND matCoeffRum2 = MatrixFactory.getInstance().create(
"matCoeffORum2",
new List[]{metiers,coeffRum},
new String[]{"Metiers","Coeff"});
MatrixND matCoeffRum3 = MatrixFactory.getInstance().create(
"matCoeffRum3",
new List[]{metiers,coeffRum},
new String[]{"Metiers","Coeff"});
matCoeffRum0.importCSV(new FileReader(CoeffRum0),new int []{0,0});
matCoeffRum1.importCSV(new FileReader(CoeffRum1),new int []{0,0});
matCoeffRum2.importCSV(new FileReader(CoeffRum2),new int []{0,0});
matCoeffRum3.importCSV(new FileReader(CoeffRum3),new int []{0,0});
//// import des fichiers de coeff pour le calcul des valeurs non simulees [1 par strategie, metier*coeff]
MatrixND matCoeffOthers0 = MatrixFactory.getInstance().create(
"matCoeffOthers0",
new List[]{metiers,coeffs},
new String[]{"Metiers","Coeff"});
MatrixND matCoeffOthers1 = MatrixFactory.getInstance().create(
"matCoeffOthers1",
new List[]{ metiers,coeffs},
new String[]{"Metiers","Coeff"});
MatrixND matCoeffOthers2 = MatrixFactory.getInstance().create(
"matCoeffOthers2",
new List[]{metiers,coeffs},
new String[]{"Metiers","Coeff"});
MatrixND matCoeffOthers3 = MatrixFactory.getInstance().create(
"matCoeffOthers3",
new List[]{metiers,coeffs},
new String[]{"Metiers","Coeff"});
matCoeffOthers0.importCSV(new FileReader(CoeffOthers0),new int []{0,0});
matCoeffOthers1.importCSV(new FileReader(CoeffOthers1),new int []{0,0});
matCoeffOthers2.importCSV(new FileReader(CoeffOthers2),new int []{0,0});
matCoeffOthers3.importCSV(new FileReader(CoeffOthers3),new int []{0,0});
//// import des fichiers de VPUE moyenne [1 par strategie, metier*mois pour l anchois]
MatrixND matAverageVPUE0_A = MatrixFactory.getInstance().create(
"matAverageFishingEffort0_A",
new List[]{metiers,months},
new String[]{"Metiers","Months"});
MatrixND matAverageVPUE1_A = MatrixFactory.getInstance().create(
"matAverageFishingEffort1_A",
new List[]{ metiers,months},
new String[]{"Metiers","Months"});
MatrixND matAverageVPUE2_A = MatrixFactory.getInstance().create(
"matAverageFishingEffort2_A",
new List[]{metiers,months},
new String[]{"Metiers","Months"});
MatrixND matAverageVPUE3_A = MatrixFactory.getInstance().create(
"matAverageFishingEffort3_A",
new List[]{metiers,months},
new String[]{"Metiers","Months"});
matAverageVPUE0_A.importCSV(new FileReader(VPUE0_A),new int []{0,0});
matAverageVPUE1_A.importCSV(new FileReader(VPUE1_A),new int []{0,0});
matAverageVPUE2_A.importCSV(new FileReader(VPUE2_A),new int []{0,0});
matAverageVPUE3_A.importCSV(new FileReader(VPUE3_A),new int []{0,0});
//// import des fichiers de VPUE moyenne [1 par strategie, metier*mois pour other]
MatrixND matAverageVPUE0_O = MatrixFactory.getInstance().create(
"matAverageFishingEffort0_O",
new List[]{metiers,months},
new String[]{"Metiers","Months"});
MatrixND matAverageVPUE1_O = MatrixFactory.getInstance().create(
"matAverageFishingEffort1_O",
new List[]{metiers,months},
new String[]{"Metiers","Months"});
MatrixND matAverageVPUE2_O = MatrixFactory.getInstance().create(
"matAverageFishingEffort2_O",
new List[]{metiers,months},
new String[]{"Metiers","Months"});
MatrixND matAverageVPUE3_O = MatrixFactory.getInstance().create(
"matAverageFishingEffort3_O",
new List[]{metiers,months},
new String[]{"Metiers","Months"});
matAverageVPUE0_O.importCSV(new FileReader(VPUE0_O),new int []{0,0});
matAverageVPUE1_O.importCSV(new FileReader(VPUE1_O),new int []{0,0});
matAverageVPUE2_O.importCSV(new FileReader(VPUE2_O),new int []{0,0});
matAverageVPUE3_O.importCSV(new FileReader(VPUE3_O),new int []{0,0});
//// import des distances parcourues
MatrixND matDistances0 = MatrixFactory.getInstance().create(
"matDistances0",
new List[]{metiers,months},
new String[]{"Metiers","Month"});
MatrixND matDistances1 = MatrixFactory.getInstance().create(
"matDistances1",
new List[]{metiers,months},
new String[]{"Metiers","Month"});
MatrixND matDistances2 = MatrixFactory.getInstance().create(
"matDistances2",
new List[]{metiers,months},
new String[]{"Metiers","Month"});
MatrixND matDistances3 = MatrixFactory.getInstance().create(
"matDistances3",
new List[]{metiers,months},
new String[]{"Metiers","Month"});
matDistances0.importCSV(new FileReader(Distances0),new int []{0,0});
matDistances1.importCSV(new FileReader(Distances1),new int []{0,0});
matDistances2.importCSV(new FileReader(Distances2),new int []{0,0});
matDistances3.importCSV(new FileReader(Distances3),new int []{0,0});
//creation et import des matrices des coeff
// RUM
matrixCoeffRUM = MatrixFactory.getInstance().create(
"matrixCoeffRUM",
new List[]{new ArrayList(mesStrategies.values()), metiers, coeffRum},
new String[]{"Strategies","Metiers","Coeff"});
MatrixND matImportRum = MatrixFactory.getInstance().create(new int[]{14,2});
for(Strategy str : mesStrategies.values()){
for(Metier met : metiers){
for(String coeff : coeffRum){
if ("BolBasques".equals(str.getName())) {
matImportRum = matCoeffRum0;
}else if ("BolBretons".equals(str.getName())) {
matImportRum = matCoeffRum1;
}else if ("PelProfil1".equals(str.getName())) {
matImportRum = matCoeffRum2;
}else if ("PelProfil2".equals(str.getName())) {
matImportRum = matCoeffRum3;}
matrixCoeffRUM.setValue(str,met, coeff, matImportRum.getValue(met,coeff));
}// fin de for coeff
}// fin de for met
}// fin de for strategy
//System.out.println("coeff RUM: " + matrixCoeffRUM);
// captures non simulees
matrixCoeffOthers = MatrixFactory.getInstance().create(
"matrixCoeffOthers",
new List[]{new ArrayList(mesStrategies.values()), metiers, coeffs},
new String[]{"Strategies","Metiers","Coeff"});
MatrixND matImport = MatrixFactory.getInstance().create(new int[]{14,2});
for(Strategy str : mesStrategies.values()){
for(Metier met : metiers){
for(String coeff : coeffs){
if ("BolBasques".equals(str.getName())) {
matImport = matCoeffOthers0;
}else if ("BolBretons".equals(str.getName())) {
matImport = matCoeffOthers1;
}else if ("PelProfil1".equals(str.getName())) {
matImport = matCoeffOthers2;
}else if ("PelProfil2".equals(str.getName())) {
matImport = matCoeffOthers3;}
matrixCoeffOthers.setValue(str, met, coeff, matImport.getValue(met,coeff));
}// fin de for coeff
}// fin de for met
}// fin de for strategy
//System.out.println("matrixCoeffOthers : "+matrixCoeffOthers);
matrixAverageVPUE_A = MatrixFactory.getInstance().create(
"matrixAverageVPUEA",
new List[]{new ArrayList(mesStrategies.values()), metiers, months},
new String[]{"Strategies","Metiers","Months"});
matImport = MatrixFactory.getInstance().create(new int[]{14,12});
for(Strategy str : mesStrategies.values()){//System.out.println("str : " +str.getName());
for(Metier met : metiers){
for(Month month : months){
if ("BolBasques".equals(str.getName())) {
matImport = matAverageVPUE0_A;
}else if ("BolBretons".equals(str.getName())) {
matImport = matAverageVPUE1_A;
}else if ("PelProfil1".equals(str.getName())) {
matImport = matAverageVPUE2_A;
}else if ("PelProfil2".equals(str.getName())) {
matImport = matAverageVPUE3_A;}
double coeffval = matImport.getValue(met,month);
matrixAverageVPUE_A.setValue(str, met, month,coeffval);
}// fin de for month
}// fin de for met
}// fin de for strategy
//System.out.println("matrixAverageVPUE : "+matrixAverageVPUE_A);
matrixAverageVPUE_O = MatrixFactory.getInstance().create(
"matrixAverageVPUEO",
new List[]{new ArrayList(mesStrategies.values()), metiers, months},
new String[]{"Strategies","Metiers","Months"});
matImport = MatrixFactory.getInstance().create(new int[]{14,12});
for(Strategy str : mesStrategies.values()){//System.out.println("str : " +str.getName());
for(Metier met : metiers){
for(Month month : months){
if ("BolBasques".equals(str.getName())) {
matImport = matAverageVPUE0_O;
}else if ("BolBretons".equals(str.getName())) {
matImport = matAverageVPUE1_O;
}else if ("PelProfil1".equals(str.getName())) {
matImport = matAverageVPUE2_O;
}else if ("PelProfil2".equals(str.getName())) {
matImport = matAverageVPUE3_O;}
double coeffval = matImport.getValue(met,month);
matrixAverageVPUE_O.setValue(str, met, month,coeffval);
}// fin de for month
}// fin de for met
}// fin de for strategy
//System.out.println("matrixAverageVPUE : "+matrixAverageVPUE_O);
//// Matrice des distances parcourues
matrixDistances = MatrixFactory.getInstance().create(
"matrixDistances",
new List[]{metiers,new ArrayList(mesStrategies.values()),months},
new String[]{"Metiers","Strategies","Month"});
MatrixND matImportDist = MatrixFactory.getInstance().create(new int[]{14,12});
for(Strategy str : mesStrategies.values()){
for(Metier met : metiers){
for(Month mois : months){
if ("BolBasques".equals(str.getName())) {
matImportDist = matDistances0;
}else if ("BolBretons".equals(str.getName())) {
matImportDist = matDistances1;
}else if ("PelProfil1".equals(str.getName())) {
matImportDist = matDistances2;
}else if ("PelProfil2".equals(str.getName())) {
matImportDist = matDistances3;}
matrixDistances.setValue(met, str, mois, matImportDist.getValue(met,mois));
}// fin de for months
}// fin de for met
}// fin de for strategy
// initialisation of a TACPresenceAbsence vector of size 12 (nb of months within a year) = 0 (memoire de l année -1)
// 0 = TAC pas atteint
// 1 = TAC atteint
// initialisation a 0
//System.out.println("liste de mois pour creer le vecteur"+months);
vectorTACPresenceAbsence = MatrixFactory.getInstance().create(
"vectorTACPresenceAbsence",
new List[]{ months},
new String[]{"Months"});
//vectorTACPresenceAbsence = MatrixFactory.createVector(12);
//System.out.println("vectorTACPresenceAbsence :" +vectorTACPresenceAbsence);
// initialisation de matMPAPresenceAbsence matrice mois x strategies x metiers l année en cours
// 0= mpa totale sur le metier
// 1= pas de mpa ou mpa partielle sur le metier
matMPAPresenceAbsence = MatrixFactory.getInstance().create(
"matMPAPresenceAbsence",
new List[]{new ArrayList(mesStrategies.values()), metiers, months},
new String[]{"Strategies", "Metiers","Months"});
//System.out.println("matMPAPresenceAbsence :" +matMPAPresenceAbsence);
}// fin de init
protected Map<Date, MatrixND> allMatrixVar = new HashMap<Date, MatrixND>();
protected MatrixND getMatrixVar(Date askedDate) {
MatrixND result = allMatrixVar.get(askedDate);
// si on demande on matrice qui n existe pas encore : on la cree
if (result == null) {
MatrixND matrixVar = createMatrixVar();
allMatrixVar.put(askedDate, matrixVar);
result = matrixVar;
}
return result;
}
protected MatrixND createMatrixVar (){
// Creation d'une nouvelle matrix qui n'existe pas encore ...
MatrixND matrixVar = MatrixFactory.getInstance().create(
"matrixVar",
new List[]{new ArrayList(mesStrategies.values()), metiers, Arrays.asList(new String[]{EFFORT, LVALUE_O, LVALUE_A})},
new String[]{"Strategies","Metiers","Variables"});
return matrixVar ;
}
/**
* ajoute a file le contenu de la matrice pour la date donnee
*/
protected void exportEffort(File file, Date date) throws Exception {
if(date.getDate() > 0){
MatrixND mat = allMatrixVar.get(date.previous());
//mat = mat.getSubMatrix(2, EFFORT);
//mat = mat.reduceDims(2);
BufferedWriter out = new BufferedWriter(new FileWriter(file, true));
int d = date.previous().getDate();
/*for (MatrixIterator i = mat.iterator(); i.hasNext();) {
i.next();
Object str = i.getSemanticsCoordinates()[0];
Object met = i.getSemanticsCoordinates()[1];
Object var = i.getSemanticsCoordinates()[2];
double value = i.getValue();
out.write(d + ";" + str + ";" + met + ";"+ var +";" + value);
out.newLine();
}*/
List <Strategy> str = mat.getSemantics()[0];
List <Metier> met = mat.getSemantics()[1];
for(Strategy s : str){
for(Metier m : met){
double val1 = mat.getValue(s,m,0);
double val2 = mat.getValue(s,m,1);
double val3 = mat.getValue(s,m,2);
out.write(d + ";" + s + ";" + m + ";" + val1 +";" + val2 + ";" + val3);
out.newLine();
}
}
out.close();
}
}
/**
* La condition qui doit etre vrai pour faire les actions
* @param simulation La simulation pour lequel on utilise cette regle
* @return vrai si on souhaite que les actions soit faites
*/
public boolean condition(SimulationContext context, Date date, Metier metier) throws Exception {
boolean result = true;
return result;
}
/**
* Si la condition est vrai alors cette action est execute avant le pas
* de temps de la simulation.
* @param simulation La simulation pour lequel on utilise cette regle
*/
public void preAction(SimulationContext context, Date date, Metier metier) throws Exception {
// la praction n est realisee qu une seule fois pour tous les metiers
if (first == true){
TopiaContext tx = context.getDB();
String id = param_zoneMPA.getTopiaId();
param_zoneMPA = ((Zone)tx.findByTopiaId(id));
first = false ; // pour ne passer qu'une seule fois
//initialisation
SiMatrix siMatrix = SiMatrix.getSiMatrix(context);
ResultStorage Result = context.getSimulationStorage().getResultStorage();
MatrixND currentMatrixVar = getMatrixVar(date);
List<Strategy> strategies = currentMatrixVar.getSemantics(0);
List<Metier> metiers = currentMatrixVar.getSemantic(1);
// est-ce que le TAC est atteint?
boolean testTAC = false;
if(date.before(param_beginDateTAC)) {
testTAC= false;
} else if(date.after(param_endDateTAC)) {
testTAC= false;
} else {
Species sp = param_pop.getSpecies();
TargetSpecies ts = metier.getMetierSeasonInfo(date.getMonth()).getSpeciesTargetSpecies(sp);
if (ts != null) {
int ny = date.getYear() ;
boolean firstSemester = date.getMonth().before(param_beginMonth);
ResultStorage matResult = context.getSimulationStorage().getResultStorage();
//year in which to consider biomass in may ?
int year = 0;
if(firstSemester & ny > 0) year = ny - 1;
else year = ny ;
// computing proportionnal TAC value :
// Biomass in may
for (Date dat = new Date(0); dat.before(date); dat = dat.next()) {
if (dat.getYear() == year & dat.getMonth().equals(Month.JUNE)){
MatrixND matB = matResult.getMatrix(dat, param_pop, ResultName.MATRIX_BIOMASS);
param_SSBmay = matB.sumAll();
}
}
/** Rule B :
* | 0 if SSB y-1 <= 21000t
* TAC y = | gamma*(SSB y-1 - Blim)/(Bpa-Blim)*SSBy-1 if 21000t < SSB y-1 < 33000t
* | gamma*SSB y-1 if SSB y-1 >= 33000t
**/
if(param_SSBmay < 21000000) {
param_tacInTons = 0 ;
}else if(param_SSBmay >= 33000000){
param_tacInTons = 0.4 * param_SSBmay /1000 ;
}else {
param_tacInTons = 0.4 * param_SSBmay * (param_SSBmay-21000000)/12000000/1000;
}
// le tac le doit pas depasser le niveau historique
if (param_tacInTons > 33000000){
param_tacInTons = 33000000;
}
double CatchFraTot = 0;
for (Date dat = new Date(0); dat.before(date); dat = dat.next()) {
if( (dat.getYear() == year & dat.getMonth().after(param_endMonth)) ||
(firstSemester & dat.getYear() == ny) ){
//System.out.println("date de la boucle : "+ dat);
MatrixND mat = matResult.getMatrix(dat, param_pop,
ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP);
if (mat == null) {
//System.out.println("**** ERROR mat catch: null");
}
for(Strategy str : strategies){
if(!"Espagnols".equals(str.getName())){
//System.out.println("strategie de la boucle:"+str.getName());
// A MODIFIER SELON ORDRE des strategies francaises ici elles sont de 1 a 4
MatrixND Fra1 = mat.copy().getSubMatrix(0,str);
Fra1 = Fra1.sumOverDim(0); // sum strategy
Fra1 = Fra1.sumOverDim(1); // sum metiers
Fra1 = Fra1.sumOverDim(2); // sum groups
Fra1 = Fra1.sumOverDim(3); // sum zones
Fra1 = Fra1.reduce();
double CatchFra1 = Fra1.getValue(0);
CatchFraTot += CatchFra1 ;
}
}
}
}
if (CatchFraTot >= param_tacInTons*0.5){
testTAC = true ;
//System.out.println("CAPTURE DEPASSEE");
}
}
}
// fin de test TAC
//System.out.println("TAC atteint?: " + testTAC);
/** Algorithme :
A- if TAC atteint
a. E = 0
B- else TAC pas atteint
a. if TAC atteint l annee precedente & on est en juillet
E= EmoyJuillet(2000-2004) // rien  faire
b. else if TAC atteint l annee à cette date
E=EmoyMois(2000-2004) // rien a faire
c. else TAC pas atteint l annee precedente a cette date
i. if date <11
1. on fait rien // effort = effort initial
ii. else date >11
E est calcule par le RUM et
1. If MPA ne concerne pas le metier
indiceUtilite = 1
2. Else if MPA concerne le metier
indiceUtilite = 1
3. Else MPA interdit la pratique du metier
indiceUtilite = 0
**/
//System.out.println("test TAC " + testTAC);
if(testTAC){ // TAC atteint E=0
//System.out.println("Tac atteint, E=0");
for(Strategy strIndex : strategies){
//System.out.println("str :"+ strIndex.getName());
Strategy str = (Strategy)context.getDB().findByTopiaId(strIndex.getTopiaId());
StrategyMonthInfo smi = str.getStrategyMonthInfo(date.getMonth());
Collection<EffortDescription> strMet = str.getSetOfVessels().getPossibleMetiers() ;
for (EffortDescription effort : strMet){
Metier met = effort.getPossibleMetiers() ;
double percent = 0;
// attribution de la nouvelle prop pour le mois
if (!(met.getName().equals("Autre")) & !context.getMetierMonitor().getForbiddenMetier().contains(met)) {
smi.setProportionMetier(met,percent);
System.out.println("smi set " + smi.getProportionMetier(met));
} else {
smi.setProportionMetier(met,1);
}
}// fin de boucle sur les metiers de la strategie
}// fin de boucle sur la strategie
}else{ // TAC pas encore atteint
//System.out.println("Vector TAC :"+vectorTACPresenceAbsence);
if (vectorTACPresenceAbsence.getValue(5)==1 & Month.JULY.equals(date.getMonth())){ // TAC atteint l'an d'avant & juillet -> E = Emoy
/**On ne change rien E = effort moyen**/
//System.out.println("juillet, vectorTACPresenceAbsence : " + vectorTACPresenceAbsence);
}else if(vectorTACPresenceAbsence.getValue(5)==1 &
vectorTACPresenceAbsence.getValue(date.getMonth().getMonthNumber())== 1){
// TAC atteint l'an d'avant & deja atteint a cette date (on a pas d effort (t-12)) -> E=Emoy
/**On ne change rien E = effort moyen**/
//System.out.println("mois : + "+date.getMonth()+" vectorTACPresenceAbsence : " + vectorTACPresenceAbsence);
}else {//TAC pas encore atteint l'anne d'avant ou pas encore a cette date (=on a un effort(t-12)) -> RUM
//System.out.println("TAC pas encore atteint l'anne d'avant ou pas encore a cette date (=on a un effort(t-12)) -> RUM!");
if(date.getDate() <12){
/**On fait rien E = E initial**/
//System.out.println("date if a 12 on change rien c est effort.init qui s applique");
}else{ // date > 11
//System.out.println("date >12");
// condition MPA
//System.out.println("MPA ?");
boolean result;
if(date.before(param_beginDateMPA)) {
result = false;
} else if(date.after(param_endDateMPA)) {
result = false;
} else if (date.getMonth().before(param_beginMonthMPA)) {
result = false;
} else if (date.getMonth().after(param_endMonthMPA)) {
result = false;
}else { // est ce que la MPA concerne le metier ???
//System.out.println("on est dans les dates de MPA");
MetierMonitor metierMon = context.getMetierMonitor();
for(Strategy strIndex : strategies){
Strategy str = (Strategy)context.getDB().findByTopiaId(strIndex.getTopiaId());
StrategyMonthInfo smi = str.getStrategyMonthInfo(date.getMonth());
Collection<EffortDescription> strMet = str.getSetOfVessels().getPossibleMetiers() ;
for (EffortDescription effort : strMet){
Metier met = effort.getPossibleMetiers() ;
//System.out.println("boucle sur les metiers pour test MPA?:"+met.getName());
List<Cell> cellMetiers = met.getMetierSeasonInfo(date.getMonth()).getCells();
//System.out.println("cellMetiers "+cellMetiers);
List<Cell> cells = param_zoneMPA.getCell();
//System.out.println("cells "+cells);
result = !Collections.disjoint(cellMetiers, cells);
if (!result){ // result = false : la MPA ne concerne pas le mtier -> RUM
matMPAPresenceAbsence.setValue(strIndex,met,date.getMonth(),0);
//System.out.println("ma MPA ne s applique pas a ce metier");
}else{ // result = true
//System.out.println("condition "+met.getName()+result);
//System.out.println("la MPA concerne le mtier : "+ met.getName());
// MPA partielle -> RUM ou totale -> E=0 ???
MetierSeasonInfo infoMetier = met.getMetierSeasonInfo(date.getMonth());
int tailleZoneMetierInitiale = cellMetiers.size();
cellMetiers.removeAll(cells);
int tailleZoneMetierNew = cellMetiers.size();
//System.out.println("taille de la zone restante "+tailleZoneMetierNew);
if (cellMetiers.size() == 0) { // MPA totale
//System.out.println("MPAtotale = metier interdit");
MatrixND noActivity = metierMon.getOrCreateNoActivity(date,
ResultName.MATRIX_NO_ACTIVITY,
siMatrix.getStrategies(date),
siMatrix.getMetiers(date));
metierMon.addforbiddenMetier(met);
matMPAPresenceAbsence.setValue(strIndex,met,date.getMonth(),1);
smi.setProportionMetier(met, 0);
//System.out.println("mat presence absence MPA date : "+ matMPAPresenceAbsence.getValue(strIndex,met,date.getMonth()));
//System.out.println("mat presence absence MPA date.prev : "+ matMPAPresenceAbsence.getValue(strIndex,met,date.previous().getMonth()));
}else{ // MPA partielle
// on rtier
//System.out.println("intersection non nulle");
ZoneDAO dao = IsisFishDAOHelper.getZoneDAO(context.getDB());
//System.out.println("MPA partielle utilittier calculee");
// Create new empty zone for cantonnement
String name = "ZoneCantonnement-" + metier.getName()+ "-" + date.getDate();
Zone zoneCantonnement = dao.findByName(name);
int cpt=0;
while (zoneCantonnement != null) {
cpt++;
zoneCantonnement = dao.findByName(name + "-" + cpt);
}
zoneCantonnement = dao.create();
if (cpt > 0) {
name += "-" + cpt;
}
zoneCantonnement.setName(name);
// Remove prohibited zone and add not prohibited cell to zoneCantonnement
Collection<Zone> zoneMetiers = infoMetier.getZone();
for (Iterator<Zone> i=zoneMetiers.iterator(); i.hasNext();) {
Zone zone = i.next();
// copy list cell to not modify original zone
List<Cell> tmpCells = new ArrayList<Cell>(zone.getCell());
int originalSize = tmpCells.size();
tmpCells.removeAll(param_zoneMPA.getCell());
int tmpSize = tmpCells.size();
//System.out.println("taille new zoen"+tmpCells.size());
zoneCantonnement.addAllCell(tmpCells);
//System.out.println("taille de zone cantonnement"+zoneCantonnement.getCell().size());
i.remove();
}
//System.out.println("taille de zone cantonnement final"+zoneCantonnement.getCell().size());
ArrayList<Zone> newZone = new ArrayList<Zone>();
newZone.add(zoneCantonnement);
infoMetier.setZone(newZone);
matMPAPresenceAbsence.setValue(strIndex,met,date.getMonth(),0);
//System.out.println("MPA partielle mat presence absence MPA date : "+ matMPAPresenceAbsence.getValue(strIndex,met,date.getMonth()));
//System.out.println("MPA partielle mat presence absence MPA date.prev : "+ matMPAPresenceAbsence.getValue(strIndex,met,date.previous().getMonth()));
}// MPA partielle
}// result = true
}// for met
} //for str
} // est ce que la MPA concerne le metier ?
// 1) reccupere les landings values en anchois des metiers anchois le mois precedent
MatrixND valueMat = Result.getMatrix(date.previous(),
ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_PER_STRATEGY_MET);
MatrixND valuePerMet =
valueMat.getSubMatrix(0, new ArrayList(mesStrategies.values()).toArray());
for(Strategy strIndex : strategies){
for(Metier metIndex : metiers){
getMatrixVar(date.previous()).setValue(strIndex,metIndex,LVALUE_A,valuePerMet.getValue(strIndex,metIndex));
}
}
// Calcul des valeurs non simulees au pas de temps precedant
MatrixND EffortNominalPerStrMet_pm = null;
//reccupere de l effort nominal par strategy met du pas de temps precedant
EffortNominalPerStrMet_pm = Result.getMatrix(
date.previous(),
ResultName.MATRIX_EFFORT_NOMINAL_PER_STRATEGY_MET);
//System.out.println("EffortNominalPerStrMet_pm "+EffortNominalPerStrMet_pm);
int comp = 0 ;
for(Strategy strIndex : strategies){
comp += 1;
//System.out.println("boucle strategie "+strIndex.getName()+" - "+comp);
// interdit de faire des set sur les strategies de la semantique de la matrice, il faut recuperer les strategies de la date courante
Strategy str = (Strategy)context.getDB().findByTopiaId(strIndex.getTopiaId());
StrategyMonthInfo smi = str.getStrategyMonthInfo(date.getMonth());
Collection<EffortDescription> strMet = str.getSetOfVessels().getPossibleMetiers() ;
double effortTotStr = 0 ;
if (date.getDate() != 0){
effortTotStr = EffortNominalPerStrMet_pm.getSubMatrix(0,str,1).sumOverDim(1).reduce().getValue(0);
}
//System.out.println("effort total strategie"+ str.getName() + effortTotStr);
//2) calcul les valeurs non simulees du mois précédant et des proportions d effort
for (EffortDescription effort : strMet){
Metier met = effort.getPossibleMetiers() ;
//System.out.println("Boucle metier 1, metier possible: "+met.getName());
double eff = EffortNominalPerStrMet_pm.getValue(str,met);
if(effortTotStr != 0){
getMatrixVar(date.previous()).setValue(str,met,EFFORT,eff / effortTotStr);
} else {
getMatrixVar(date.previous()).setValue(str,met,EFFORT,0);
}
//System.out.println("effort str"+str.getName()+met.getName()+" : "+eff);
//System.out.println("effortTotStr = "+ effortTotStr);
//System.out.println("propMet = "+ getMatrixVar(date.previous()).getValue(str,met,EFFORT));
double valOtherMetOther = 0; //yv
double valAnchovyMetOther = 0; //yv
double valOtherMetAnchovy = 0;//yv
if ("Autre".equals(met.getName())){
if (eff != 0) {
valOtherMetOther = matrixCoeffOthers.getValue(str,met,ALPHA_O) +
matrixCoeffOthers.getValue(str,met,BETA_O)*eff;
valAnchovyMetOther = matrixCoeffOthers.getValue(str,met,ALPHA_A) +
matrixCoeffOthers.getValue(str,met,BETA_A)*eff;
}
getMatrixVar(date.previous()).setValue(str,met,LVALUE_O,valOtherMetOther);
getMatrixVar(date.previous()).setValue(str,met,LVALUE_A,valAnchovyMetOther);
//System.out.println("LVALUE_O, metOther :"+getMatrixVar(date.previous()).getValue(str,met,LVALUE_O));
//System.out.println("LVALUE_A, metOther :"+getMatrixVar(date.previous()).getValue(str,met,LVALUE_A));
}else {
if (eff != 0) {
valOtherMetAnchovy = matrixCoeffOthers.getValue(str,met,ALPHA_O) +
matrixCoeffOthers.getValue(str,met,BETA_O)*eff;
}
getMatrixVar(date.previous()).setValue(str,met,LVALUE_O,valOtherMetAnchovy);
//System.out.println("LVALUE_O, metAnchovy :"+getMatrixVar(date.previous()).getValue(str,met,LVALUE_O));
} // fin du else met == Autre
} // fin de boucle sur les metiers
// 3) calcul des pourcentages d effort
// a) %Effort pour la premiere année : reccuperation des pourcentages d effort du pas de temps dans la database
// map temporaire de stoquage des valeurs de sum cum calculees pour les met de la strategie.
Map<Metier, Double> tmp = new HashMap<Metier, Double>();
double tot = 0;
List<Double> fuelprice ;
fuelprice = (List<Double>)context.getValue("fuelPrice");
if (fuelprice == null){
fuelprice= new ArrayList<Double>();
fuelprice.add(0,param_fuelprice);
}
// boucle sur les met de la str
for (EffortDescription effort : strMet){
Metier met = effort.getPossibleMetiers();
if (matMPAPresenceAbsence.getValue(str,met,date.getMonth()) == 0){
//System.out.println("pas de MPA sur le metier" + met.getName());
// pas de MPA sur le métier
Date previousDate = date.previous();
Date previousYear = date.previousYear();
MatrixND matrixVarPreviousMonth = getMatrixVar(previousDate);
MatrixND matrixVarPreviousYear = getMatrixVar(previousYear) ;
double FuelPrice;
if(fuelprice.size() == 1){
FuelPrice = fuelprice.get(0);
}else { FuelPrice = fuelprice.get(date.getYear());
}
double peff_pm = matrixVarPreviousMonth.getValue(str,met,EFFORT);
double peff_py = matrixVarPreviousYear.getValue(str,met,EFFORT);
// pour savoir si un des metiers de la strategie a ete interdit au mois precedant
/*MatrixND interdit = matMPAPresenceAbsence.copy().getSubMatrix(0,str);
MatrixND interdit_pm = interdit.getSubMatrix(2,date.previous().getMonth());
MatrixND interdit_m = interdit.getSubMatrix(2,date.getMonth());
double nbInterdit_pm = interdit_pm.sumOverDim(1).reduce().getValue(0);
double nbInterdit_m = interdit_m.sumOverDim(1).reduce().getValue(0);
System.out.println("nbInterdit pm:" + nbInterdit_pm);
System.out.println("nbInterdit m:" + nbInterdit_m);*/
// calcul des vpue t-1
double Vpue_O = 0;
double Vpue_A = 0;
/**exemple de cas de fermeture reouverture pour verifier la condition
t t+1 t+2 t+3 t+4
met1 0 1 1 0 0 met1 0 0 0 0 0
met2 0 0 0 0 0 met2 0 1 1 1 0
met3 0 0 0 0 0 met3 0 0 1 0 0
nbinterdit 0 1 1 0 0 nb interdit 0 1 2 1 0
sim sim sim moy sim sim sim sim moy moy
mais attention cas non couvert :
met1 0 0 0 0 0
met2 0 1 1 0 0
met3 0 0 0 1 0
nb interdit 0 1 1 1 0
sim sim sim moy moy
*/
int reouv = 0;
for (EffortDescription effBoucle : strMet){
Metier metBoucle = effBoucle.getPossibleMetiers();
//System.out.println("boucle pour la reouverture : "+metBoucle.getName());
if (matMPAPresenceAbsence.getValue(str, metBoucle,date.getMonth()) <
matMPAPresenceAbsence.getValue(str, metBoucle,date.previous().getMonth())){
//System.out.println("réouverture");
reouv += 1;
}//else //System.out.println("pas de reouverture pour ce metier");
}
//System.out.println("reouverture pour la strategie ? : "+reouv);
//if(nbInterdit_m < nbInterdit_pm){// reouverture de zone : si au moins un metier est reouvert on ne sait pas comment faire-> moyen
if(reouv > 0){
//System.out.println("reouv > 0");
Vpue_O = matrixAverageVPUE_O.getValue(strIndex,met,previousDate.getMonth());
Vpue_A = matrixAverageVPUE_A.getValue(strIndex,met,previousDate.getMonth());
}else{ // si on a le meme nb de metier que le mois precedant ou qu'un/plusieurs metier(s) vient d etre fermé on utilise les vpue calculées
double val_O = matrixVarPreviousMonth.getValue(str,met,LVALUE_O);
double val_A = matrixVarPreviousMonth.getValue(str,met,LVALUE_A);
double eff_pm = EffortNominalPerStrMet_pm.getValue(str,met);
if(eff_pm != 0){
Vpue_O = val_O / eff_pm;
//System.out.println("vpue o :"+Vpue_O);
Vpue_A = val_A / eff_pm;
//System.out.println("vpue a:"+ Vpue_A);
}
}
double utilite = matrixCoeffRUM.getValue(str,met,INTERCEPT)
+ peff_pm * matrixCoeffRUM.getValue(str,met,EFFORT_PM)*100 //pas utilis 0
+ peff_py * matrixCoeffRUM.getValue(str,met,EFFORT_PY)*100
+ Vpue_O * matrixCoeffRUM.getValue(str,met,VPUE_O)
+ Vpue_A * matrixCoeffRUM.getValue(str,met,VPUE_A)
+ FuelPrice * matrixDistances.getValue(met,str,date.getMonth())* matrixCoeffRUM.getValue(str,met,COST);
//System.out.println("tout pour le calcul peff_pm : " + peff_pm + "peff_py : "+peff_py);
//System.out.println("tout pour le calcul coeffs : intercept " + matrixCoeffRUM.getValue(str,met,INTERCEPT) + "pm : "+matrixCoeffRUM.getValue(str,met,EFFORT_PM) + "py : "+matrixCoeffRUM.getValue(str,met,EFFORT_PY) + "VPUEO : "+matrixCoeffRUM.getValue(str,met,VPUE_O) + "VPUEA : "+matrixCoeffRUM.getValue(str,met,VPUE_A));
//System.out.println("sumCum :"+utilite);
tot += Math.exp(utilite);
tmp.put(met,Math.exp(utilite));
}else { // metier interdit
double expUtilite = 0;
tmp.put(met,expUtilite);
}
}// fin de boucle sur les metiers pour le calcul utilite
// nouvelle boucle sur les metiers de la strategie
for (EffortDescription effort : strMet){
Metier met = effort.getPossibleMetiers() ;
double percent = 0;
if(tot != 0){
percent = tmp.get(met)/tot;
}
////System.out.println("tmp.get(met):"+tmp.get(met)+" tot : "+tot);
// attribution de la nouvelle prop pour le mois
if (!context.getMetierMonitor().getForbiddenMetier().contains(met)) {
smi.setProportionMetier(met,percent);
//System.out.println("smi set " + met.getName()+ smi.getProportionMetier(met));
}
}// for met
}// fin de boucle sur les strategies
}// date > 11
}//TAC pas encore atteint l'anne d'avant ou pas encore a cette date (=on a un effort(t-12)) -> RUM
}// else TAC pas encore atteint
double val = 0;
if(testTAC) val = 1;
vectorTACPresenceAbsence.setValue(date.getMonth().getMonthNumber(),val);
}//first = false
}
/**
* Si la condition est vrai alors cette action est execute apres le pas
* de temps de la simulation.
* @param simulation La simulation pour lequel on utilise cette regle
*/
public void postAction(SimulationContext context, Date date, Metier metier) throws Exception {
first = true;// pour pouvoir passer dans la preaction au prochain pas de temps
}
}