gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-schemafuzz] branch master updated (286021a -> 6767c5


From: gnunet
Subject: [GNUnet-SVN] [taler-schemafuzz] branch master updated (286021a -> 6767c53)
Date: Thu, 17 May 2018 12:19:31 +0200

This is an automated email from the git hooks/post-receive script.

erwan-ulrich pushed a change to branch master
in repository schemafuzz.

    from 286021a  finished implementing weight
     new 66a1ea5  working on the weight picking patern
     new db0aa61  still working on choosing patern
     new 6767c53  still working on weight based choosing

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                                         |   7 +-
 .gitignore.swp                                     | Bin 12288 -> 0 bytes
 buildNumber.properties                             |   3 -
 src/main/java/org/schemaspy/DBFuzzer.java          |  20 ++--
 src/main/java/org/schemaspy/model/GenericTree.java |  34 ++-----
 .../java/org/schemaspy/model/GenericTreeNode.java  | 107 +++++++++++++++++----
 6 files changed, 109 insertions(+), 62 deletions(-)
 delete mode 100644 .gitignore.swp
 delete mode 100644 buildNumber.properties

diff --git a/.gitignore b/.gitignore
index 7359190..11ffcfb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,7 @@
-
+./buildNumber.properties
+./target/classes
+./target/test-classes
+./target/surefire-reports
+./target/generated-sources
+./target/generated-test-sources
 ./Work_time.ods
diff --git a/.gitignore.swp b/.gitignore.swp
deleted file mode 100644
index 30eb779..0000000
Binary files a/.gitignore.swp and /dev/null differ
diff --git a/buildNumber.properties b/buildNumber.properties
deleted file mode 100644
index ebf5af4..0000000
--- a/buildNumber.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-#maven.buildNumber.plugin properties file
-#Wed May 09 18:06:58 CEST 2018
-buildNumber=784
diff --git a/src/main/java/org/schemaspy/DBFuzzer.java 
b/src/main/java/org/schemaspy/DBFuzzer.java
index 33f27f0..eefdc9e 100644
--- a/src/main/java/org/schemaspy/DBFuzzer.java
+++ b/src/main/java/org/schemaspy/DBFuzzer.java
@@ -49,7 +49,6 @@ public class DBFuzzer
 
         Row randomRow = pickRandomRow();
         GenericTreeNode currentMutation = new 
GenericTreeNode(randomRow,nextId());
-        
currentMutation.initPotential_changes(currentMutation.discoverMutationPossibilities(analyzer.getDb()));
         
currentMutation.setChosenChange(currentMutation.getPotential_changes().get(0));
         mutationTree.setRoot(currentMutation);
 
@@ -85,9 +84,10 @@ public class DBFuzzer
             Process evaluatorProcess = new ProcessBuilder("/bin/bash", 
"./evaluator.sh").start();
             mark = Integer.parseInt(getEvaluatorResponse(evaluatorProcess));
             currentMutation.setInterest_mark(mark);
-            currentMutation.initWeight();
-            System.out.println("Weight for currentMut 
"+currentMutation.getWeight());
+            currentMutation.setWeight(mark);
             System.out.println("marking here : "+mark);
+            System.out.println("Weight for currentMut 
"+currentMutation.getWeight());
+            mutationTree.printTree(0);
           }
           catch(Exception e)
           {
@@ -256,7 +256,8 @@ public class DBFuzzer
       int markingDiff = previousMutation.getInterest_mark();
       Random rand = new Random();
 
-      if(mutationTree.getNumberOfNodes() > 1)
+
+      if(mutationTree.getNumberOfNodes() > 2)
       {
         markingDiff = 
previousMutation.getInterest_mark()-mutationTree.find(mutationTree.getLastId()).getInterest_mark();
       }
@@ -265,19 +266,16 @@ public class DBFuzzer
       {
         if(markingDiff > 0)
         {
-            
previousMutation.initPotential_changes(previousMutation.discoverMutationPossibilities(analyzer.getDb()));
             int randNumber = 
rand.nextInt(previousMutation.getPotential_changes().size());
             nextMut = new 
GenericTreeNode(previousMutation.getPost_change_row(),nextId(),mutationTree.getRoot(),previousMutation);
-            
nextMut.initPotential_changes(nextMut.discoverMutationPossibilities(analyzer.getDb()));
             
nextMut.setChosenChange(previousMutation.getPotential_changes().get(randNumber));
         }
         else if(markingDiff == 0 || markingDiff < 0)
         {
-            GenericTreeNode randMutation =  
mutationTree.pickMutationBasedOnWeight(mutationTree.mutationsBasedOnWeight());
-            int randChange = 
rand.nextInt(randMutation.getPotential_changes().size());
-            nextMut = new 
GenericTreeNode(mutationTree.findFirstMutationWithout(mutationTree.getRoot(),randMutation.getChosenChange()).getPost_change_row(),nextId(),mutationTree.getRoot(),mutationTree.findFirstMutationWithout(mutationTree.getRoot(),randMutation.getChosenChange()));
-            
nextMut.initPotential_changes(nextMut.discoverMutationPossibilities(analyzer.getDb()));
-            
nextMut.setChosenChange(randMutation.getPotential_changes().get(randChange));
+
+            SingleChange tmp = 
mutationTree.getRoot().singleChangeBasedOnWeight();
+            nextMut = new 
GenericTreeNode(tmp.getattachedToMutation().getPost_change_row(),nextId(),mutationTree.getRoot(),tmp.getattachedToMutation());
+            nextMut.setChosenChange(tmp);
         }
         else
         {
diff --git a/src/main/java/org/schemaspy/model/GenericTree.java 
b/src/main/java/org/schemaspy/model/GenericTree.java
index 63674fc..8197726 100644
--- a/src/main/java/org/schemaspy/model/GenericTree.java
+++ b/src/main/java/org/schemaspy/model/GenericTree.java
@@ -192,9 +192,6 @@ public class GenericTree {
 
     public void addToTree(GenericTreeNode currentMutation)
     {
-      System.out.println(currentMutation);
-      
currentMutation.setParent(findFirstMutationWithout(root,currentMutation.getChosenChange()));
-      currentMutation.getChosenChange().setAttachedToMutation(currentMutation);
       currentMutation.getParent().addChild(currentMutation);
     }
 
@@ -225,35 +222,18 @@ public class GenericTree {
         return res; // should never be null unless the algorithm is not 
looking for something precise
     }
 
-    public ArrayList<GenericTreeNode> mutationsBasedOnWeight()
+    public void printTree(int tabs)
     {
-      ArrayList<GenericTreeNode> mutationsBasedOnWeight = new 
ArrayList<GenericTreeNode>();
-      GenericTreeNode currentMutation;
-
-      for(int i = 1; i <= getNumberOfNodes();i++)
+      for(int i = 1; i <= getNumberOfNodes(); i++)
       {
-        currentMutation = find(i);
-        for(int j = 0; j < currentMutation.getWeight();j++)
+        for(int j = 0; j < tabs ; j++)
         {
-          mutationsBasedOnWeight.add(currentMutation);
+          System.out.println("   ");
         }
+        System.out.println(find(i));
+        if(find(i).getChildren().size() != 0)
+          printTree(find(i).getDepth());
       }
-      return mutationsBasedOnWeight;
-    }
-
-    public GenericTreeNode 
pickMutationBasedOnWeight(ArrayList<GenericTreeNode> mutationsBasedOnWeight)
-    {
-      int randNumber = 0;
-      Random rand = new Random();
-      if(mutationsBasedOnWeight.size() > 0)
-      {
-        System.out.println(" size "+mutationsBasedOnWeight.size());
-        randNumber = rand.nextInt(mutationsBasedOnWeight.size());
-        System.out.println(" size "+mutationsBasedOnWeight.size());
-      }
-
-      return mutationsBasedOnWeight.get(randNumber);
     }
 
-
 }
diff --git a/src/main/java/org/schemaspy/model/GenericTreeNode.java 
b/src/main/java/org/schemaspy/model/GenericTreeNode.java
index 49c30b0..71345e5 100644
--- a/src/main/java/org/schemaspy/model/GenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/GenericTreeNode.java
@@ -1,6 +1,5 @@
+package org.schemaspy.model;
 
-
-import 
com.sun.org.apache.xml.internal.security.keys.storage.implementations.SingleCertificateResolver;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.util.*;
@@ -10,8 +9,6 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import org.schemaspy.*;
-package org.schemaspy.model;
-
 import java.util.*;
 import java.util.ArrayList;
 import java.util.regex.Matcher;
@@ -24,13 +21,13 @@ public class GenericTreeNode {
     private GenericTreeNode rootMutation;
     private Integer interest_mark;
     private Integer weight;
-    private Integer subtree_weight;
+    private Integer subTreeWeight;
     private final Row initial_state_row;
     private Row post_change_row;
-    private final ArrayList<SingleChange> potential_changes = new 
ArrayList<SingleChange>();
-    private final ArrayList<SingleChange> cascadeFK = new 
ArrayList<SingleChange>(); // a integrer
+    private ArrayList<SingleChange> potential_changes = new 
ArrayList<SingleChange>();
+    private ArrayList<SingleChange> cascadeFK = new ArrayList<SingleChange>(); 
// a integrer
     private SingleChange chosenChange;
-    private final ArrayList<GenericTreeNode> children = new 
ArrayList<GenericTreeNode>();
+    private ArrayList<GenericTreeNode> children = new 
ArrayList<GenericTreeNode>();
     private GenericTreeNode parent;
     private boolean cascadingFK;
     private final int depth;
@@ -41,6 +38,10 @@ public class GenericTreeNode {
       this.id = id;
       this.initial_state_row = initial_state_row;
       this.cascadingFK = false;
+      this.potential_changes = discoverMutationPossibilities();
+      this.weight = 1;
+      this.subTreeWeight = 0;
+      this.depth = 0;
     }
 
     public GenericTreeNode(Row initial_state_row,int id, GenericTreeNode 
rootMutation, GenericTreeNode parentMutation) {
@@ -48,46 +49,61 @@ public class GenericTreeNode {
       this.initial_state_row = initial_state_row;
       this.cascadingFK = false;
       this.rootMutation = rootMutation;
-      this.parent = parentMutation;Error
-      if(this.getParent() == null)
-        this.depth = 0;
-      else
-        this.depth = this.getParent().getDepth()+1;
+      this.parent = parentMutation;
+      int cpt = 0;
+      GenericTreeNode tmp = this;
+      while(tmp.getParent() != null)
+      {
+        cpt++;
+        tmp = this.getParent();
+      }
+
+      this.depth = cpt;
+      this.potential_changes = discoverMutationPossibilities();
+      this.weight = 1;
+      this.subTreeWeight = 0;
     }
 
     public Integer getId() {
       return id;
     }
 
+
     public Integer getWeight()
     {
       return this.weight;
     }
 
+    public void addToSubTreeWeight(int childWeight)
+    {
+      this.subTreeWeight += childWeight;
+    }
+
     public void setWeight(Integer weight)
     {
       this.weight = weight;
-      parent.subtree_weight += weight;
+      propagateWeight();
     }
 
     private static final Random r = new Random();
     /**
     *
     */
-    public SingleChange select_weighted_random_change ()
+    public SingleChange singleChangeBasedOnWeight ()
     {
       if (this.potential_changes.isEmpty())
         throw new Error("This should be impossible to reach");
-      int rnd = r.nextInt(subtree_weight + potential_changes.size());
+
+      int rnd = r.nextInt(subTreeWeight + potential_changes.size());
       assert (rnd >= 0);
       if (rnd < potential_changes.size())
-        return potential_changes.remove (rnd);      
+        return potential_changes.remove (rnd);
       rnd -= potential_changes.size();
       for (GenericTreeNode n : children)
         {
-          int w = n.getChangeWeight();
+          int w = n.getSubTreeWeight();
           if (rnd < w)
-            return n.select_weighted_random_change();
+            return n.singleChangeBasedOnWeight();
           rnd -= w;
         }
        throw new Error("This should be impossible to reach");
@@ -113,6 +129,11 @@ public class GenericTreeNode {
       return chosenChange;
     }
 
+    public int getSubTreeWeight()
+    {
+      return this.subTreeWeight;
+    }
+
 
     public Row getInitial_state_row() {
       return initial_state_row;
@@ -178,7 +199,7 @@ public class GenericTreeNode {
       return children.get(index);
     }
 
-    public ArrayList<SingleChange> discoverMutationPossibilities(Database db)
+    public ArrayList<SingleChange> discoverMutationPossibilities()
     {
 
       int i;
@@ -534,5 +555,51 @@ public class GenericTreeNode {
       }
       return true;
     }
+    //
+    // public SingleChange singleChangeBasedOnWeight()
+    // {
+    //   Random r = new Random();
+    //   if (this.potential_changes.isEmpty())
+    //     throw new Error("This should be impossible to reach");
+    //
+    //     System.err.println("subtreeweight = "+subTreeWeight);
+    //
+    //     int total = 0;
+    //     for (GenericTreeNode n : children)
+    //       {
+    //         total += n.getSubTreeWeight();
+    //       }
+    //     if (total != subTreeWeight)
+    //       System.out.println("keep your objects consistent in the setter 
functions");
+    //
+    //   int rnd = r.nextInt(subTreeWeight + potential_changes.size());
+    //   if (rnd < potential_changes.size())
+    //   {
+    //     this.subTreeWeight -= 1;
+    //     return potential_changes.remove (rnd);
+    //   }
+    //   System.out.println("ici");
+    //   rnd -= potential_changes.size();
+    //   System.err.println("rnd = "+rnd);
+    //   for (GenericTreeNode n : children)
+    //     {
+    //       int w = n.getSubTreeWeight();
+    //       System.out.println("w = "+w);
+    //       if (rnd < w)
+    //         return n.singleChangeBasedOnWeight();
+    //       rnd -= w;
+    //     }
+    //   System.out.println("ici2");
+    //   throw new Error("This should be impossible to reach");
+    // }
+
+    public void propagateWeight()
+    {
+      if(this.getParent() != null)
+      {
+        this.getParent().addToSubTreeWeight(this.getWeight());
+        this.getParent().propagateWeight();
+      }
+    }
 
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]