[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-schemafuzz] 03/03: still working on weight based cho
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-schemafuzz] 03/03: still working on weight based choosing |
Date: |
Thu, 17 May 2018 12:19:34 +0200 |
This is an automated email from the git hooks/post-receive script.
erwan-ulrich pushed a commit to branch master
in repository schemafuzz.
commit 6767c53e698c18923f82f8b5cd4a48901fdbddbd
Author: Feideus <address@hidden>
AuthorDate: Thu May 17 12:19:08 2018 +0200
still working on weight based choosing
---
.gitignore | 7 +-
.gitignore.swp | Bin 12288 -> 0 bytes
buildNumber.properties | 3 -
src/main/java/org/schemaspy/DBFuzzer.java | 4 +-
src/main/java/org/schemaspy/model/GenericTree.java | 3 -
.../java/org/schemaspy/model/GenericTreeNode.java | 114 +++++++++++----------
6 files changed, 66 insertions(+), 65 deletions(-)
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 d8d50ae..0000000
--- a/buildNumber.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-#maven.buildNumber.plugin properties file
-#Wed May 16 18:55:45 CEST 2018
-buildNumber=806
diff --git a/src/main/java/org/schemaspy/DBFuzzer.java
b/src/main/java/org/schemaspy/DBFuzzer.java
index 3ab194f..eefdc9e 100644
--- a/src/main/java/org/schemaspy/DBFuzzer.java
+++ b/src/main/java/org/schemaspy/DBFuzzer.java
@@ -268,14 +268,12 @@ public class DBFuzzer
{
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)
{
- System.err.println("Hey");
+
SingleChange tmp =
mutationTree.getRoot().singleChangeBasedOnWeight();
- System.out.println("chosen change = "+tmp);
nextMut = new
GenericTreeNode(tmp.getattachedToMutation().getPost_change_row(),nextId(),mutationTree.getRoot(),tmp.getattachedToMutation());
nextMut.setChosenChange(tmp);
}
diff --git a/src/main/java/org/schemaspy/model/GenericTree.java
b/src/main/java/org/schemaspy/model/GenericTree.java
index 947c35f..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);
}
diff --git a/src/main/java/org/schemaspy/model/GenericTreeNode.java
b/src/main/java/org/schemaspy/model/GenericTreeNode.java
index da41697..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,17 +21,13 @@ public class GenericTreeNode {
private GenericTreeNode rootMutation;
private Integer interest_mark;
private Integer weight;
-<<<<<<< 286021abc272ba0295d224f298bac82861a7c4e0
- private Integer subtree_weight;
-=======
private Integer subTreeWeight;
->>>>>>> working on the weight picking patern
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;
@@ -47,7 +40,8 @@ public class GenericTreeNode {
this.cascadingFK = false;
this.potential_changes = discoverMutationPossibilities();
this.weight = 1;
- this.subTreeWeight = this.getPotential_changes().size();
+ this.subTreeWeight = 0;
+ this.depth = 0;
}
public GenericTreeNode(Row initial_state_row,int id, GenericTreeNode
rootMutation, GenericTreeNode parentMutation) {
@@ -56,16 +50,25 @@ public class GenericTreeNode {
this.cascadingFK = false;
this.rootMutation = rootMutation;
this.parent = parentMutation;
- initDepth();
+ 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 = this.getPotential_changes().size();
+ this.subTreeWeight = 0;
}
public Integer getId() {
return id;
}
+
public Integer getWeight()
{
return this.weight;
@@ -86,20 +89,21 @@ public class GenericTreeNode {
/**
*
*/
- 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);
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");
@@ -551,43 +555,43 @@ 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 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()
{
--
To stop receiving notification emails like this one, please contact
address@hidden