[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-schemafuzz] branch master updated: Finishing up weig
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-schemafuzz] branch master updated: Finishing up weight |
Date: |
Tue, 15 May 2018 11:09:21 +0200 |
This is an automated email from the git hooks/post-receive script.
erwan-ulrich pushed a commit to branch master
in repository schemafuzz.
The following commit(s) were added to refs/heads/master by this push:
new f91fa27 Finishing up weight
f91fa27 is described below
commit f91fa27ae434e6cb672c4353f0e21d5fdfe5b573
Author: Feideus <address@hidden>
AuthorDate: Tue May 15 11:08:57 2018 +0200
Finishing up weight
---
src/main/java/org/schemaspy/DBFuzzer.java | 18 +++---
src/main/java/org/schemaspy/model/GenericTree.java | 67 +++++++++++++++-------
.../java/org/schemaspy/model/GenericTreeNode.java | 30 ++++++++++
3 files changed, 83 insertions(+), 32 deletions(-)
diff --git a/src/main/java/org/schemaspy/DBFuzzer.java
b/src/main/java/org/schemaspy/DBFuzzer.java
index 3c9ebc8..04b4aad 100644
--- a/src/main/java/org/schemaspy/DBFuzzer.java
+++ b/src/main/java/org/schemaspy/DBFuzzer.java
@@ -85,7 +85,9 @@ public class DBFuzzer
Process evaluatorProcess = new ProcessBuilder("/bin/bash",
"./evaluator.sh").start();
mark = Integer.parseInt(getEvaluatorResponse(evaluatorProcess));
currentMutation.setInterest_mark(mark);
- System.out.println("marking : "+mark);
+ currentMutation.initWeight();
+ System.out.println("Weight for currentMut
"+currentMutation.getWeight());
+ System.out.println("marking here : "+mark);
}
catch(Exception e)
{
@@ -93,7 +95,6 @@ public class DBFuzzer
System.out.println("error while recovering marking"+e);
}
-
// CHOOSINGNEXT GenericTreeNode AND SETTING UP FOR NEXT ITERATION
currentMutation = chooseNextMutation();
while(!this.isNewMutation(currentMutation))
@@ -101,7 +102,6 @@ public class DBFuzzer
System.out.println("this GenericTreeNode has already been tried ");
currentMutation = chooseNextMutation();
}
- //System.out.println(currentMutation.toString());
if(!currentMutation.getParent().compare(mutationTree.getLastMutation()))
{
@@ -270,15 +270,11 @@ public class DBFuzzer
}
else if(markingDiff == 0 || markingDiff < 0)
{
- int randNumber = rand.nextInt(mutationTree.getNumberOfNodes())+1;
- while(mutationTree.find(randNumber).getPotential_changes().size()
== 0)
- {
- randNumber = rand.nextInt(mutationTree.getNumberOfNodes())+1;
- }
- int randMutation =
rand.nextInt(mutationTree.find(randNumber).getPotential_changes().size());
- nextMut = new
GenericTreeNode(mutationTree.findFirstMutationWithout(mutationTree.getRoot(),mutationTree.find(randNumber).getChosenChange()).getPost_change_row(),nextId(),mutationTree.getRoot(),mutationTree.findFirstMutationWithout(mutationTree.getRoot(),mutationTree.find(randNumber).getChosenChange()));
+ 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(mutationTree.find(randNumber).getPotential_changes().get(randMutation));
+
nextMut.setChosenChange(randMutation.getPotential_changes().get(randChange));
}
else
{
diff --git a/src/main/java/org/schemaspy/model/GenericTree.java
b/src/main/java/org/schemaspy/model/GenericTree.java
index d52f8c3..40c7392 100644
--- a/src/main/java/org/schemaspy/model/GenericTree.java
+++ b/src/main/java/org/schemaspy/model/GenericTree.java
@@ -46,32 +46,26 @@ public class GenericTree {
}
public GenericTreeNode find(Integer id) {
- GenericTreeNode returnNode = null;
-
- if(root != null) {
- returnNode = auxiliaryFind(root, id);
+ if(root == null)
+ {
+ return null;
}
-
- return returnNode;
+ return auxiliaryFind(root, id);
}
private GenericTreeNode auxiliaryFind(GenericTreeNode currentNode, Integer
id) {
- GenericTreeNode returnNode = null;
- int i = 1;
-
- if (currentNode.getId().equals(id)) {
- returnNode = currentNode;
- }
-
- else if(currentNode.hasChildren()) {
- i = 0;
- while(returnNode == null && i < currentNode.getNumberOfChildren())
{
- returnNode = auxiliaryFind(currentNode.getChildAt(i), id);
- i++;
- }
+ if (currentNode.getId().equals(id))
+ return currentNode;
+ if (! currentNode.hasChildren())
+ return null;
+ for (GenericTreeNode child : currentNode.getChildren())
+ {
+ GenericTreeNode returnNode = auxiliaryFind(child, id);
+ if (null != returnNode)
+ return returnNode;
}
-
- return returnNode;
+ System.out.println("null ici ");
+ return null;
}
public boolean isEmpty() {
@@ -231,4 +225,35 @@ public class GenericTree {
}
return res; // should never be null unless the algorithm is not
looking for something precise
}
+
+ public ArrayList<GenericTreeNode> mutationsBasedOnWeight()
+ {
+ ArrayList<GenericTreeNode> mutationsBasedOnWeight = new
ArrayList<GenericTreeNode>();
+ GenericTreeNode currentMutation;
+
+ System.out.println("nb nodes "+getNumberOfNodes());
+ for(int i = 1; i <= getNumberOfNodes();i++)
+ {
+ currentMutation = find(i);
+ System.out.println("ICI mutation N "+currentMutation.getId());
+ for(int j = 0; j < currentMutation.getWeight();j++)
+ {
+ System.out.println("COOUCOU");
+ System.out.println("added once "+currentMutation.getId());
+ mutationsBasedOnWeight.add(find(i));
+ }
+ }
+ System.out.println("Weight "+mutationsBasedOnWeight);
+ return mutationsBasedOnWeight;
+ }
+
+ public GenericTreeNode
pickMutationBasedOnWeight(ArrayList<GenericTreeNode> mutationsBasedOnWeight)
+ {
+ int randNumber = 0;
+ Random rand = new Random();
+ if(mutationsBasedOnWeight.size() > 0)
+ randNumber = rand.nextInt(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 0e15787..a6ee52a 100644
--- a/src/main/java/org/schemaspy/model/GenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/GenericTreeNode.java
@@ -17,6 +17,7 @@ public class GenericTreeNode {
private final Integer id;
private GenericTreeNode rootMutation;
private Integer interest_mark;
+ private Integer weight;
private final Row initial_state_row;
private Row post_change_row;
private ArrayList<SingleChange> potential_changes = new
ArrayList<SingleChange>();
@@ -48,6 +49,16 @@ public class GenericTreeNode {
return id;
}
+ public Integer getWeight()
+ {
+ return this.weight;
+ }
+
+ public void setWeight(Integer weight)
+ {
+ this.weight = weight;
+ }
+
public void initDepth()
{
if(this.getParent() == null)
@@ -479,4 +490,23 @@ public class GenericTreeNode {
}
+ public void initWeight() // Modify euristic here when refining the
choosing patern
+ {
+ switch (this.interest_mark)
+ {
+ case 0 :
+ this.weight = 1;
+ break;
+ case 10 :
+ this.weight = 5;
+ break;
+ case 20 :
+ this.weight = 25;
+ break;
+ default :
+ this.weight = 1;
+ break;
+ }
+ }
+
}
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-schemafuzz] branch master updated: Finishing up weight,
gnunet <=