import fr.ifremer.isisfish.annotations.Doc; import fr.ifremer.isisfish.simulator.*; //SimulationParameter; import org.nuiton.math.matrix.MatrixFactory; import org.nuiton.math.matrix.MatrixND; import rules.EffortReduction_Fermetures_PreSimu_Delmoges; import fr.ifremer.isisfish.types.Month; import java.util.*; import java.io.*; import java.util.regex.*; SimulationContext context; //recup num de simu String simu = context.getSimulationControl().getId(); java.util.regex.Pattern simulNamePattern = java.util.regex.Pattern.compile("^.+_(\\d+)$"); // pour un nom de simu du type ?? java.util.regex.Matcher matcher = simulNamePattern.matcher(simu); matcher.find(); int numero = Integer.parseInt(matcher.group(1)); SimulationParameter parameter = context.getSimulationStorage().getParameter(); // parameter.clearRules(); // suppresison des regles deja existante ? non il y aura le forcage d effort a laisser // read matrice d'experience matExp // [simu x rules] contient les modalités String param_pathExpMatrix = "" ; int matrix_length = 47; int parameterNumber = 9; MatrixND matrix = MatrixFactory.getInstance().create(new int[]{matrix_length, parameterNumber}); matrix.importCSV(new FileReader(new File(param_pathExpMatrix)), new int[]{0,0}); List dim0 = new ArrayList(); for (int i=0; i < matrix_length; i++) { dim0.add(i); } matrix.setSemantic(0, dim0); matrix.setSemantic(1, Arrays.asList( new String[]{"simu","ferm1startMonth","ferm1duree","ferm1endMonth","ferm2startMonth","txReduction", "Realloc","txRealloc","txNavAQuai"})); System.out.println("plan d'exp :"+matrix); ///////////////////////////////////////////////////////////////////////////// // Read matrix values double txNavQuai = matExp.getValue(numero,navQuai); double txRed = matExp.getValue(numero,txReduction); double txRealloc = matExp.getValue(numero,txRealloc); int Realloc = matExp.getValue(numero,Realloc); int deb1 = matExp.getValue(numero,ferm1starMonth); int fin1 = matExp.getValue(numero,ferm1endMonth); int deb2 = matExp.getValue(numero,ferm2starMonth); List months = Month.getMonths(Month.JANUARY,Month.DECEMBER); Boolean Brealloc = true; if(Realloc ==0) Brealloc = false; // ajout regle 1 EffortReduction_Fermetures_PreSimu_Delmoges ruleDelmoges = new EffortReduction_Fermetures_PreSimu_Delmoges(); ruleDelmoges.param_beginMonthFermeture = months.get(deb1); ruleDelmoges.param_endMonthFermeture = months.get(fin1); ruleDelmoges.param_txReduction = txRed; ruleDelmoges.param_reallocation = Brealloc; ruleDelmoges.param_txReallocation = txRealloc; ruleDelmoges.param_txAquai = txNavQuai; // ajoute regle 2 : fermeture ete si besoin if (deb2 != 13)){ // remettre les 2 memes pour l'ete } EffortReduction_Fermetures_PreSimu_Delmoges ferm2 = new EffortReduction_Fermetures_PreSimu_Delmoges(); ferm2.param_beginMonthFermeture = months.get(deb2); ferm2.param_endMonthFermeture = months.get(deb2); ruleDelmoges.param_txReduction = 0; ruleDelmoges.param_reallocation = Brealloc; ruleDelmoges.param_txReallocation = txRealloc; ruleDelmoges.param_txAquai = txNavQuai; /* rules : navires a quai : change str prop fermeture engins a risque : interdiction engin avec report proportionnel reduction effort engin a risque avec report : a ecrire (cf med) fermeture zone avec report : existe deja defipel ? changement engin filets polyvalents : fermeture engin filet avec report et exclusifs au port changement engin exclusifs : fermeture engin filet avec report et aug nb de nav de la strategie avec les exclusifs meme taille et proches */ // populate params /*Properties prop = new Properties(); prop.load(new BufferedReader(new FileReader(new File("/home/.../dir", "file-" + numero + ".txt")))); GravityModelMixChannel regle1 = new GravityModelMixChannel(); RuleHelper.populateRule(modFerm1, db, regle1, prop); parameter.addRule(regle1); regle1.param_behaviorBalance = 0.7; regle1.param_beginDate = new TimeStep(12); parameter.addRule(regle1); // populate params Properties prop = new Properties(); prop.load(new BufferedReader(new FileReader(new File("/home/.../dir", "file-" + numero + ".txt")))); GravityModelMixChannel regle2 = new GravityModelMixChannel(); RuleHelper.populateRule(0, db, regle2, prop); parameter.addRule(regle2); if (numero == 42) { // cas specifique ... }*/