예제 #1
0
 void genvalueset(StringBuilder buf, BaseType lhsvar) {
   // Decide if this will be a multi-valued rhs
   boolean issingleton = (random.nextDouble() >= NVALUESPROB);
   if (issingleton) {
     genvalue(buf, lhsvar, false);
   } else {
     // Determine the number of of elements in the rhs set (> 1)
     int setsize = random.nextInt(MAXRHSSIZE) + 1; // 1..MAXRHSSIZE
     while (setsize < 2) setsize = random.nextInt(MAXRHSSIZE) + 1; // 1..MAXRHSSIZE
     buf.append("{");
     for (int i = 0; i < setsize; i++) {
       if (i > 0) buf.append(",");
       genvalue(buf, lhsvar, false);
     }
     buf.append("}");
   }
 }
예제 #2
0
 void genconstraint(StringBuilder buf) {
   int nprojections = random.nextInt(NPROJECTIONS);
   int nselections = random.nextInt(NSELECTIONS);
   if (nprojections + nselections == 0) nprojections++; // guarantee non-null constraint
   projections = new ArrayList<BaseType>();
   // generate candidate projection list
   while (projections.size() < nprojections) {
     BaseType node = choose(allnodes);
     // check for conflicts
     if (projections.contains(node)) continue; // no duplicates
     if (containsChild(node, projections)) continue; // child => !parent
     BaseType parent = containsParent(node, projections);
     if (parent != null) projections.remove(parent); // parent && child => !parent
     projections.add(node);
   }
   projections = sort(projections); // sort
   for (int i = 0; i < projections.size(); i++) {
     BaseType node = projections.get(i);
     if (i > 0) buf.append(",");
     genprojection(node, buf);
   }
   selections = new ArrayList<BaseType>();
   valuelist = new ArrayList<BaseType>();
   // generate candidate selection list
   while (selections.size() < nselections) {
     BaseType node = choose(leaves);
     if (selections.contains(node)) continue; // no duplicates
     // conflict avoidance
     if (projections.contains(node)) continue; // no duplicates with projection list
     if (containsChild(node, projections)) continue; // child => !parent wrt projection list
     BaseType parent = containsParent(node, projections);
     if (parent != null) continue; // project parent && select child => remove child
     selections.add(node);
   }
   for (int i = 0; i < nselections; i++) {
     BaseType node = selections.get(i);
     buf.append("&");
     genselection(node, buf);
   }
 }
예제 #3
0
 void gendimrange(List<BaseType> path, StringBuilder buf) {
   for (int i = 0; i < path.size(); i++) {
     BaseType bt = path.get(i);
     int rank = 0;
     if (bt.getParent() instanceof DArray) rank = ((DArray) (bt.getParent())).numDimensions();
     if (i > 0) buf.append('.');
     buf.append(bt.getEncodedName());
     for (int j = 0; j < rank; j++) {
       String dimprojection = dimrangeset[random.nextInt(dimrangeset.length)];
       buf.append(dimprojection);
     }
   }
 }
예제 #4
0
 void genselection(BaseType lhsvar, StringBuilder buf) {
   gendimpoint(getPath(lhsvar), buf);
   String operator = opset[random.nextInt(opset.length)];
   buf.append(operator);
   genvalueset(buf, lhsvar);
 }
예제 #5
0
 BaseType choose(List<BaseType> nodeset) {
   // choose a random DDS node from a given nodeset
   int choice = random.nextInt(nodeset.size()); // 0..|nodeset|-1
   return nodeset.get(choice);
 }