Repository: bigtop
Updated Branches:
  refs/heads/master 9e0cbe595 -> 6aea780a2


BIGTOP-1932. [BigPetStore] Add larger product collection


Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/6aea780a
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/6aea780a
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/6aea780a

Branch: refs/heads/master
Commit: 6aea780a2c6bcf7de518294641de13b6c105e327
Parents: 9e0cbe5
Author: RJ Nowling <[email protected]>
Authored: Mon Jul 13 19:56:51 2015 -0500
Committer: RJ Nowling <[email protected]>
Committed: Tue Jul 14 21:58:57 2015 -0500

----------------------------------------------------------------------
 .../bigpetstore/datagenerator/Constants.java    |  27 +-
 .../datagenerator/ProductGenerator.java         |  19 +-
 .../bigpetstore/datagenerator/cli/Driver.java   |   4 +-
 .../framework/pdfs/DiscretePDF.java             |  52 ----
 .../framework/pdfs/MultinomialPDF.java          |  57 ++++
 .../BoundedMultiModalGaussianSampler.java       |  25 +-
 .../samplers/RouletteWheelSampler.java          |   4 +-
 .../collections/MediumProductCollection.java    | 275 +++++++++++++++++++
 .../purchase/MultinomialPurchasingModel.java    |  12 +-
 .../MultinomialPurchasingModelSampler.java      |  93 ++++---
 .../framework/pdfs/TestMultinomialPDF.java      |  41 +++
 .../cartesian/TestCartesianProductBase.java     |  15 +
 .../cartesian/TestCartesianProductField.java    |  15 +
 .../products/rules/TestAlwaysTrueRule.java      |  30 ++
 .../generators/products/rules/TestAndRule.java  |  51 ++++
 .../products/rules/TestFieldPredicate.java      |  42 +++
 .../generators/products/rules/TestNotRule.java  |  36 +++
 .../generators/products/rules/TestOrRule.java   |  51 ++++
 18 files changed, 724 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/Constants.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/Constants.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/Constants.java
index c719054..be7b6a9 100644
--- 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/Constants.java
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/Constants.java
@@ -17,10 +17,12 @@ package org.apache.bigtop.bigpetstore.datagenerator;
 
 import java.io.File;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
 
 public class Constants
 {
@@ -30,13 +32,19 @@ public class Constants
                MARKOV;
        }
        
+       public static enum ProductsCollectionSize
+       {
+               SMALL,
+               MEDIUM;
+       }
+       
        public static final File COORDINATES_FILE = new File("zips.csv");
        public static final File INCOMES_FILE = new 
File("ACS_12_5YR_S1903/ACS_12_5YR_S1903_with_ann.csv");
        public static final File POPULATION_FILE = new 
File("population_data.csv");
        
        public static final File NAMEDB_FILE = new File("namedb/data/data.dat");
        
-       public static final String PRODUCTS_COLLECTION = "small";
+       public static final ProductsCollectionSize PRODUCTS_COLLECTION = 
ProductsCollectionSize.MEDIUM;
        
        public static final double INCOME_SCALING_FACTOR = 100.0;
        
@@ -68,17 +76,24 @@ public class Constants
        public static final double PRODUCT_MSM_LOOPBACK_WEIGHT_LOWERBOUND = 
0.05;
        public static final double PRODUCT_MSM_LOOPBACK_WEIGHT_UPPERBOUND = 
0.95;
        
-       public static final double PRODUCT_MULTINOMIAL_HIGH_WEIGHT = 10.0;
+       public static final double PRODUCT_MULTINOMIAL_POSITIVE_WEIGHT = 10.0;
        public static final double PRODUCT_MULTINOMIAL_NEUTRAL_WEIGHT = 1.0;
-       public static final double PRODUCT_MULTINOMIAL_LOW_WEIGHT = 0.1;
-       public static final double PRODUCT_MULTINOMIAL_MIN_PERCENT = 0.01; // 1%
-       public static final int PRODUCT_MULTINOMIAL_MIN_COUNT = 2;
-       public static final double PRODUCT_MULTINOMIAL_MAX_PERCENT = 0.1; // 10%
+       public static final double PRODUCT_MULTINOMIAL_NEGATIVE_WEIGHT = 0.1;
+       public static final int PRODUCT_MULTINOMIAL_POSITIVE_COUNT_MIN = 1;
+       public static final double PRODUCT_MULTINOMIAL_POSITIVE_FREQUENCY = 
0.1; // 10%
        
        public static final String PRODUCT_QUANTITY = "quantity";
        public static final String PRODUCT_CATEGORY = "category";
        public static final String PRODUCT_UNIT_PRICE = "unitPrice";
        public static final String PRODUCT_PRICE = "price";
        
+       /*
+        *  Until we have a more intelligent way (e.g., based on range) of 
dealing with prices,
+        *  let's exclude them.
+        */
+       public static final Set<String> PRODUCT_MODEL_EXCLUDED_FIELDS = 
ImmutableSet.of(PRODUCT_CATEGORY,
+                       PRODUCT_UNIT_PRICE,
+                       PRODUCT_PRICE);
+       
        public static final double STOP_CATEGORY_WEIGHT = 0.01;
 }

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/ProductGenerator.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/ProductGenerator.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/ProductGenerator.java
index fb3e068..cd008ac 100644
--- 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/ProductGenerator.java
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/ProductGenerator.java
@@ -17,22 +17,33 @@ package org.apache.bigtop.bigpetstore.datagenerator;
 
 import java.util.List;
 
+import 
org.apache.bigtop.bigpetstore.datagenerator.Constants.ProductsCollectionSize;
 import 
org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
+import 
org.apache.bigtop.bigpetstore.datagenerator.generators.products.collections.MediumProductCollection;
 import 
org.apache.bigtop.bigpetstore.datagenerator.generators.products.collections.SmallProductCollection;
 
 public class ProductGenerator
 {
-       String collection;
+       ProductsCollectionSize collection;
 
-       public ProductGenerator(String collection)
+       public ProductGenerator(ProductsCollectionSize collection)
        {
                this.collection = collection;
        }
 
        public List<ProductCategory> generate()
        {
-               SmallProductCollection collection = new 
SmallProductCollection();
-               List<ProductCategory> categories = 
collection.generateProductCategory();
+               List<ProductCategory> categories;
+               
+               if(collection.equals(ProductsCollectionSize.SMALL))
+               {
+                       SmallProductCollection collection = new 
SmallProductCollection();
+                       categories = collection.generateProductCategory();
+               } else
+               {
+                       MediumProductCollection collection = new 
MediumProductCollection();
+                       categories = collection.generateProductCategory();
+               }
 
                return categories;
        }

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/cli/Driver.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/cli/Driver.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/cli/Driver.java
index 435b620..5b222cc 100644
--- 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/cli/Driver.java
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/cli/Driver.java
@@ -245,9 +245,7 @@ public class Driver
                        for(PurchasingModel model : profiles)
                        {
                                Object productModel = 
model.getProfile(category.getCategoryLabel());
-                               String record = category.getCategoryLabel() + 
",";
-                               record += i + ",";
-                               record += productModel.toString() + "\n";
+                               String record = productModel.toString();
 
                                outputStream.write(record.getBytes());
 

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/DiscretePDF.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/DiscretePDF.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/DiscretePDF.java
deleted file mode 100644
index 190aca3..0000000
--- 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/DiscretePDF.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs;
-
-import java.util.Map;
-import java.util.Set;
-
-import com.google.common.collect.ImmutableMap;
-
-public class DiscretePDF<T> implements ProbabilityDensityFunction<T>
-{
-       private final ImmutableMap<T, Double> probabilities;
-       
-       public DiscretePDF(Map<T, Double> probabilities)
-       {
-               this.probabilities = ImmutableMap.copyOf(probabilities);
-       }
-       
-       public Set<T> getData()
-       {
-               return probabilities.keySet();
-       }
-       
-       public double probability(T value)
-       {
-               if(probabilities.containsKey(value))
-               {
-                       return probabilities.get(value);
-               }
-               
-               return 0.0;
-       }
-
-       @Override
-       public String toString()
-       {
-               return "DiscretePDF(" + probabilities.toString() +")";
-       }
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/MultinomialPDF.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/MultinomialPDF.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/MultinomialPDF.java
new file mode 100644
index 0000000..7605156
--- /dev/null
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/MultinomialPDF.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs;
+
+import java.util.Map;
+import java.util.Set;
+
+import com.google.common.collect.ImmutableMap;
+
+public class MultinomialPDF<T> implements ProbabilityDensityFunction<T>
+{
+       private final ImmutableMap<T, Double> probabilities;
+       
+       public MultinomialPDF(Map<T, Double> probabilities)
+       {
+               this.probabilities = ImmutableMap.copyOf(probabilities);
+       }
+       
+       public Set<T> getData()
+       {
+               return probabilities.keySet();
+       }
+       
+       public double probability(T value)
+       {
+               if(probabilities.containsKey(value))
+               {
+                       return probabilities.get(value);
+               }
+               
+               return 0.0;
+       }
+
+       @Override
+       public String toString()
+       {
+               String str = "";
+               for(Map.Entry<T, Double> entry: probabilities.entrySet())
+               {
+                       str += entry.getValue() + "," + entry.getKey() + "\n";
+               }
+               return str;
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/BoundedMultiModalGaussianSampler.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/BoundedMultiModalGaussianSampler.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/BoundedMultiModalGaussianSampler.java
index 475b24d..83ec666 100644
--- 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/BoundedMultiModalGaussianSampler.java
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/BoundedMultiModalGaussianSampler.java
@@ -42,17 +42,20 @@ public class BoundedMultiModalGaussianSampler implements 
Sampler<Double>
        
        public Double sample()
        {
-               int idx = rng.nextInt(distributions.size());
-               
-               double mean = distributions.get(idx).getFirst();
-               double std = distributions.get(idx).getSecond();
-               
-               double value = mean + rng.nextGaussian() * std;
-               
-               value = Math.min(value, this.max);
-               value = Math.max(value, this.min);
-               
-               return value;
+               while(true)
+               {
+                       int idx = rng.nextInt(distributions.size());
+                       
+                       double mean = distributions.get(idx).getFirst();
+                       double std = distributions.get(idx).getSecond();
+                       
+                       double value = mean + rng.nextGaussian() * std;
+                       
+                       if (value >= this.min && value <= this.max)
+                       {
+                               return value;
+                       }
+               }
        }
 
 }

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/RouletteWheelSampler.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/RouletteWheelSampler.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/RouletteWheelSampler.java
index 72681f8..0537966 100644
--- 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/RouletteWheelSampler.java
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/RouletteWheelSampler.java
@@ -21,7 +21,7 @@ import java.util.Random;
 
 import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair;
 import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.DiscretePDF;
+import 
org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.MultinomialPDF;
 import 
org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.ProbabilityDensityFunction;
 
 import com.google.common.collect.ImmutableList;
@@ -37,7 +37,7 @@ public class RouletteWheelSampler<T> implements Sampler<T>
                return new RouletteWheelSampler<T>(domainWeights, factory);
        }
        
-       public static <T> RouletteWheelSampler<T> create(DiscretePDF<T> pdf, 
SeedFactory factory)
+       public static <T> RouletteWheelSampler<T> create(MultinomialPDF<T> pdf, 
SeedFactory factory)
        {
                return new RouletteWheelSampler<T>(pdf.getData(), pdf, factory);
        }

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/MediumProductCollection.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/MediumProductCollection.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/MediumProductCollection.java
new file mode 100644
index 0000000..2ec72d1
--- /dev/null
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/MediumProductCollection.java
@@ -0,0 +1,275 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 
org.apache.bigtop.bigpetstore.datagenerator.generators.products.collections;
+
+import java.util.List;
+
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
+import 
org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
+import 
org.apache.bigtop.bigpetstore.datagenerator.generators.products.ProductCategoryBuilder;
+import 
org.apache.bigtop.bigpetstore.datagenerator.generators.products.ProductFieldValue;
+import 
org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules.AndRule;
+import 
org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules.FieldPredicate;
+import 
org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules.NotRule;
+import 
org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules.OrRule;
+
+import com.google.common.collect.Lists;
+
+public class MediumProductCollection
+{
+       private ProductCategory createDogFood()
+       {
+               ProductCategoryBuilder builder = new ProductCategoryBuilder();
+
+               builder.addApplicableSpecies(PetSpecies.DOG);
+               builder.setCategory("dry dog food");
+               builder.setTriggerTransaction(true);
+               builder.setDailyUsageRate(2.0);
+               builder.setAmountUsedPetPetAverage(0.25);
+               builder.setAmountUsedPetPetVariance(0.1);
+               builder.setTriggerTransactionRate(2.0);
+               builder.setTriggerPurchaseRate(7.0);
+               builder.setBasePrice(2.0);
+
+               builder.addPropertyValues("brand",
+                               new ProductFieldValue("Wellfed", 0.67, 1.0),
+                               new ProductFieldValue("Happy Pup", 0.67, 1.0),
+                               new ProductFieldValue("Dog Days", 1.0, 1.0),
+                               new ProductFieldValue("Chef Corgi", 0.0, 1.0));
+
+               builder.addPropertyValues("meat",
+                               new ProductFieldValue("Chicken", 0.0, 1.0),
+                               new ProductFieldValue("Pork", 0.0, 1.0),
+                               new ProductFieldValue("Lamb", 0.1, 1.0),
+                               new ProductFieldValue("Salmon", 0.25, 1.0),
+                               new ProductFieldValue("Venison", 0.5, 1.0),
+                               new ProductFieldValue("Rabbit", 0.5, 1.0),
+                               new ProductFieldValue("Vegetarian", 0.0, 1.0));
+               
+               builder.addPropertyValues("grain",
+                               new ProductFieldValue("Corn", 0.0, 1.0),
+                               new ProductFieldValue("Potatoes", 0.1, 1.0),
+                               new ProductFieldValue("Barley", 0.1, 1.0),
+                               new ProductFieldValue("Rice", 0.0, 1.0),
+                               new ProductFieldValue("Soy", 0.1, 1.0));
+               
+               builder.addPropertyValues("lifestage",
+                               new ProductFieldValue("Senior", 0.0, 1.0),
+                               new ProductFieldValue("Puppy", 0.0, 1.0),
+                               new ProductFieldValue("Adult", 0.0, 1.0));
+               
+               builder.addPropertyValues("organic",
+                               new ProductFieldValue("false", 0.0, 1.0),
+                               new ProductFieldValue("true", 0.0, 1.1));
+
+               builder.addPropertyValues("quantity",
+                               new ProductFieldValue(4.5, 0.0, 4.5),
+                               new ProductFieldValue(15.0, 0.0, 15.0),
+                               new ProductFieldValue(30.0, 0.0, 30.0));
+               
+               builder.addExclusionRule(new AndRule(
+                               new FieldPredicate("brand", "Chef Corgi"),
+                               new FieldPredicate("organic", "true")));
+               
+               builder.addExclusionRule(new AndRule(
+                               new FieldPredicate("brand", "Chef Corgi"),
+                               new FieldPredicate("meat", "Vegetarian")));
+               
+               builder.addExclusionRule(new AndRule(
+                               new FieldPredicate("brand", "Dog Days"),
+                               new FieldPredicate("organic", "false")));
+               
+               builder.addExclusionRule(new AndRule(
+                               new FieldPredicate("grain", "Corn"),
+                               new OrRule(
+                                               new FieldPredicate("organic", 
"true"),
+                                               new FieldPredicate("meat", 
"Venison"),
+                                               new FieldPredicate("meat", 
"Rabbit"),
+                                               new FieldPredicate("meat", 
"Lamb"),
+                                               new FieldPredicate("meat", 
"Salmon"))));
+               
+               builder.addExclusionRule(new AndRule(
+                               new FieldPredicate("organic", "true"),
+                               new FieldPredicate("meat", "Pork")));
+               
+               builder.addExclusionRule(new AndRule(
+                               new NotRule(new FieldPredicate("grain", 
"Corn")),
+                               new FieldPredicate("meat", "Pork")));
+               
+               builder.addExclusionRule(new AndRule(
+                               new OrRule(
+                                               new FieldPredicate("brand", 
"Chef Corgi"),
+                                               new FieldPredicate("brand", 
"Happy Pup")),
+                               new OrRule(
+                                               new FieldPredicate("meat", 
"Rabbit"),
+                                               new FieldPredicate("meat", 
"Venison"))
+                                               ));
+
+               return builder.build();
+       }
+
+       private ProductCategory createCatFood()
+       {
+               ProductCategoryBuilder builder = new ProductCategoryBuilder();
+
+               builder.addApplicableSpecies(PetSpecies.CAT);
+               builder.setCategory("dry cat food");
+               builder.setTriggerTransaction(true);
+               builder.setDailyUsageRate(2.0);
+               builder.setAmountUsedPetPetAverage(0.1);
+               builder.setAmountUsedPetPetVariance(0.05);
+               builder.setTriggerTransactionRate(2.0);
+               builder.setTriggerPurchaseRate(7.0);
+               builder.setBasePrice(2.14);
+
+               builder.addPropertyValues("brand",
+                               new ProductFieldValue("Wellfed", 0.67, 1.0),
+                               new ProductFieldValue("Feisty Feline", 0.72, 
1.0),
+                               new ProductFieldValue("Pretty Cat", 0.0, 1.0));
+
+               builder.addPropertyValues("meat",
+                               new ProductFieldValue("Tuna", 0.0, 1.0),
+                               new ProductFieldValue("Chicken", 0.0, 1.0),
+                               new ProductFieldValue("Turkey", 0.0, 1.0),
+                               new ProductFieldValue("Salmon", 0.1, 1.0));
+               
+               builder.addPropertyValues("lifestyle",
+                               new ProductFieldValue("Indoor", 0.0, 1.0),
+                               new ProductFieldValue("Outdoor", 0.0, 1.0),
+                               new ProductFieldValue("Weight Management", 0.1, 
1.0));
+               
+               builder.addPropertyValues("lifestage",
+                               new ProductFieldValue("Senior", 0.0, 1.0),
+                               new ProductFieldValue("Kitten", 0.0, 1.0),
+                               new ProductFieldValue("Adult", 0.0, 1.0));
+               
+               builder.addPropertyValues("organic",
+                               new ProductFieldValue("true", 0.0, 1.1),
+                               new ProductFieldValue("false", 0.0, 1.0));
+
+               builder.addPropertyValues("quantity",
+                               new ProductFieldValue(7.0, 0.0, 7.0),
+                               new ProductFieldValue(15.0, 0.0, 15.0));
+
+               builder.addPropertyValues("hairball management",
+                               new ProductFieldValue("true", 0.1, 1.0),
+                               new ProductFieldValue("false", 0.0, 1.0));
+               
+               builder.addExclusionRule(new AndRule(
+                                       new FieldPredicate("brand", "Pretty 
Cat"),
+                                       new FieldPredicate("organic", "true")));
+               
+               builder.addExclusionRule(new AndRule(
+                               new FieldPredicate("brand", "Feisty Feline"),
+                               new FieldPredicate("organic", "false")));
+
+               return builder.build();
+       }
+
+       private ProductCategory createKittyLitter()
+       {
+               ProductCategoryBuilder builder = new ProductCategoryBuilder();
+
+               builder.addApplicableSpecies(PetSpecies.CAT);
+               builder.setCategory("kitty litter");
+               builder.setTriggerTransaction(true);
+               builder.setDailyUsageRate(1.0);
+               builder.setAmountUsedPetPetAverage(0.1);
+               builder.setAmountUsedPetPetVariance(0.05);
+               builder.setTriggerTransactionRate(2.0);
+               builder.setTriggerPurchaseRate(7.0);
+               builder.setBasePrice(1.43);
+
+               builder.addPropertyValues("brand",
+                               new ProductFieldValue("Pretty Cat", 0.0, 1.0),
+                               new ProductFieldValue("Feisty Feline", 0.1, 
1.0));
+
+               builder.addPropertyValues("material",
+                               new ProductFieldValue("clay", 0.0, 1.0),
+                               new ProductFieldValue("pellets", 0.1, 1.0));
+               
+               builder.addPropertyValues("clumping",
+                               new ProductFieldValue("true", 0.0, 1.0),
+                               new ProductFieldValue("false", 0.0, 1.0));
+               
+               builder.addPropertyValues("odor control",
+                               new ProductFieldValue("true", 0.1, 1.0),
+                               new ProductFieldValue("false", 0.0, 1.0));
+               
+               builder.addPropertyValues("quantity",
+                               new ProductFieldValue(7.0, 0.0, 7.0),
+                               new ProductFieldValue(14.0, 0.0, 14.0),
+                               new ProductFieldValue(28.0, 0.0, 28.0));
+
+               return builder.build();
+       }
+
+       private ProductCategory createPoopBags()
+       {
+               ProductCategoryBuilder builder = new ProductCategoryBuilder();
+
+               builder.addApplicableSpecies(PetSpecies.DOG);
+               builder.setCategory("poop bags");
+               builder.setTriggerTransaction(true);
+               builder.setDailyUsageRate(2.0);
+               builder.setAmountUsedPetPetAverage(1.0);
+               builder.setAmountUsedPetPetVariance(0.5);
+               builder.setTriggerTransactionRate(2.0);
+               builder.setTriggerPurchaseRate(7.0);
+               builder.setBasePrice(0.17);
+
+               builder.addPropertyValues("brand",
+                               new ProductFieldValue("Chef Corgi", 0.0, 1.0),
+                               new ProductFieldValue("Happy Pup", 0.67, 1.0),
+                               new ProductFieldValue("Dog Days", 1.0, 1.0));
+
+               builder.addPropertyValues("color",
+                               new ProductFieldValue("blue", 0.0, 1.0),
+                               new ProductFieldValue("multicolor (pastels)", 
0.0, 1.0),
+                               new ProductFieldValue("multicolor (solids)", 
0.0, 1.0),
+                               new ProductFieldValue("designs", 0.0, 1.0));
+               
+               builder.addPropertyValues("recycled material",
+                               new ProductFieldValue("false", 0.0, 60.0),
+                               new ProductFieldValue("true", 0.1, 120.0));
+
+               builder.addPropertyValues("quantity",
+                               new ProductFieldValue(60.0, 0.0, 60.0),
+                               new ProductFieldValue(120.0, 0.0, 120.0));
+               
+               builder.addExclusionRule(new AndRule(
+                               new FieldPredicate("brand", "Chef Corgi"),
+                               new FieldPredicate("recycled material", 
"true")));
+               
+               builder.addExclusionRule(new AndRule(
+                               new FieldPredicate("brand", "Dog Days"),
+                               new FieldPredicate("recycled material", 
"false")));
+
+               return builder.build();
+       }
+
+       public List<ProductCategory> generateProductCategory()
+       {
+               List<ProductCategory> productCategories = Lists.newArrayList();
+
+               productCategories.add(this.createDogFood());
+               productCategories.add(this.createCatFood());
+               productCategories.add(this.createKittyLitter());
+               productCategories.add(this.createPoopBags());
+
+               return productCategories;
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModel.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModel.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModel.java
index 1adb5bd..336a898 100644
--- 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModel.java
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModel.java
@@ -19,7 +19,7 @@ import java.util.Map;
 
 import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
 import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.DiscretePDF;
+import 
org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.MultinomialPDF;
 import 
org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.RouletteWheelSampler;
 import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
 
@@ -27,14 +27,14 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Maps;
 
-public class MultinomialPurchasingModel implements 
PurchasingModel<DiscretePDF<Product>>
+public class MultinomialPurchasingModel implements 
PurchasingModel<MultinomialPDF<Product>>
 {
 
        private static final long serialVersionUID = 5863830733003282570L;
 
-       private final ImmutableMap<String, DiscretePDF<Product>> productPDFs;
+       private final ImmutableMap<String, MultinomialPDF<Product>> productPDFs;
 
-       public MultinomialPurchasingModel(Map<String, DiscretePDF<Product>> 
productPDFs)
+       public MultinomialPurchasingModel(Map<String, MultinomialPDF<Product>> 
productPDFs)
        {
                this.productPDFs = ImmutableMap.copyOf(productPDFs);
        }
@@ -46,7 +46,7 @@ public class MultinomialPurchasingModel implements 
PurchasingModel<DiscretePDF<P
        }
 
        @Override
-       public DiscretePDF<Product> getProfile(String category)
+       public MultinomialPDF<Product> getProfile(String category)
        {
                return productPDFs.get(category);
        }
@@ -57,7 +57,7 @@ public class MultinomialPurchasingModel implements 
PurchasingModel<DiscretePDF<P
                Map<String, Sampler<Product>> processes = Maps.newHashMap();
                for(String category : getProductCategories())
                {
-                       DiscretePDF<Product> pdf = productPDFs.get(category);
+                       MultinomialPDF<Product> pdf = productPDFs.get(category);
                        processes.put(category, 
RouletteWheelSampler.create(pdf, seedFactory));
                }
 

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java
index 55fef69..bea39ba 100644
--- 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java
@@ -16,8 +16,8 @@
 package org.apache.bigtop.bigpetstore.datagenerator.generators.purchase;
 
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.Vector;
 
 import org.apache.bigtop.bigpetstore.datagenerator.Constants;
@@ -25,12 +25,15 @@ import 
org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair;
 import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
 import 
org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
 import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.DiscretePDF;
+import 
org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.MultinomialPDF;
 import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
 import 
org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.UniformIntSampler;
+import 
org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.UniformSampler;
 
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
+import com.google.common.collect.Multimap;
 
 public class MultinomialPurchasingModelSampler implements 
Sampler<MultinomialPurchasingModel>
 {
@@ -43,59 +46,64 @@ public class MultinomialPurchasingModelSampler implements 
Sampler<MultinomialPur
                this.productCategories = productCategories;
        }
 
-       protected void shuffle(Vector<Pair<String, Object>> input) throws 
Exception
+       protected <T> List<T> shuffle(Collection<T> input) throws Exception
        {
+               Vector<T> shuffled = new Vector<>(input);
                for(int i = 0; i < input.size() - 1; i++)
                {
                        int swapIdx = new UniformIntSampler(i, input.size() - 
1, seedFactory).sample();
-                       Pair<String, Object> tmp = input.get(i);
-                       input.set(i, input.get(swapIdx));
-                       input.set(swapIdx, tmp);
+                       T tmp = shuffled.get(i);
+                       shuffled.set(i, shuffled.get(swapIdx));
+                       shuffled.set(swapIdx, tmp);
                }
+               
+               return shuffled;
        }
 
        protected Map<Pair<String, Object>, Double> 
generateFieldValueWeights(ProductCategory productCategory) throws Exception
        {
-               Set<Pair<String, Object>> fieldValuesSet = Sets.newHashSet();
+               // Get all values for each field by iterating over all products
+               Multimap<String, Object> allFieldValues = HashMultimap.create();
                for(String fieldName : productCategory.getFieldNames())
                {
-                       for(Product p : productCategory.getProducts())
+                       
if(!Constants.PRODUCT_MODEL_EXCLUDED_FIELDS.contains(fieldName))
                        {
-                               Object fieldValue = p.getFieldValue(fieldName);
-                               fieldValuesSet.add(Pair.create(fieldName, 
fieldValue));
+                               for(Product p : productCategory.getProducts())
+                               {
+                                       Object fieldValue = 
p.getFieldValue(fieldName);
+                                       allFieldValues.put(fieldName, 
fieldValue);
+                               }
                        }
                }
-
-               Vector<Pair<String, Object>> fieldValues = new 
Vector<Pair<String, Object>>(fieldValuesSet);
-               shuffle(fieldValues);
-
-               int lowerbound = 
Math.max(Constants.PRODUCT_MULTINOMIAL_MIN_COUNT,
-                               (int) Math.ceil(fieldValues.size() * 
Constants.PRODUCT_MULTINOMIAL_MIN_PERCENT));
-               int upperbound = 
Math.max(Constants.PRODUCT_MULTINOMIAL_MIN_COUNT + 1,
-                               (int) Math.floor(fieldValues.size() * 
Constants.PRODUCT_MULTINOMIAL_MAX_PERCENT));
-
-               Sampler<Integer> countSampler = new 
UniformIntSampler(lowerbound, upperbound, seedFactory);
-               int highWeightCount = countSampler.sample();
-               int lowWeightCount = countSampler.sample();
-
+               
+               Sampler<Double> sampler = new UniformSampler(seedFactory);
+               
+               // shuffle field values
                Map<Pair<String, Object>, Double> fieldValueWeights = 
Maps.newHashMap();
-               for(int i = 0; i < fieldValues.size(); i++)
+               for(Map.Entry<String, Collection<Object>> entry : 
allFieldValues.asMap().entrySet())
                {
-                       if(i < highWeightCount)
-                       {
-                               fieldValueWeights.put(fieldValues.get(i), 
Constants.PRODUCT_MULTINOMIAL_HIGH_WEIGHT);
-                       }
-                       else if(i >= highWeightCount && i < (lowWeightCount + 
highWeightCount))
-                       {
-                               fieldValueWeights.put(fieldValues.get(i), 
Constants.PRODUCT_MULTINOMIAL_LOW_WEIGHT);
-                       }
-                       else
+                       String fieldName = entry.getKey();
+                       List<Object> shuffled = shuffle(entry.getValue());
+                       
+                       for(int i = 0; i < shuffled.size(); i++)
                        {
-                               fieldValueWeights.put(fieldValues.get(i), 
Constants.PRODUCT_MULTINOMIAL_NEUTRAL_WEIGHT);
+                               double weight = 
Constants.PRODUCT_MULTINOMIAL_POSITIVE_WEIGHT;
+                               if ((i + 1) > 
Constants.PRODUCT_MULTINOMIAL_POSITIVE_COUNT_MIN)
+                               {
+                                       double r = sampler.sample();
+                                       if (r >= 
Constants.PRODUCT_MULTINOMIAL_POSITIVE_FREQUENCY)
+                                       {
+                                               weight = 
Constants.PRODUCT_MULTINOMIAL_NEGATIVE_WEIGHT;
+                                       }
+                               }
+                               
+                               Object fieldValue = shuffled.get(i);
+                               fieldValueWeights.put(new 
Pair<String,Object>(fieldName, fieldValue), weight);
                        }
                }
+               
 
-               return fieldValueWeights;
+               return ImmutableMap.copyOf(fieldValueWeights);
        }
 
        protected Map<Product, Double> generateProductWeights(Map<Pair<String, 
Object>, Double> fieldValueWeights,
@@ -107,9 +115,12 @@ public class MultinomialPurchasingModelSampler implements 
Sampler<MultinomialPur
                        double weight = 1.0;
                        for(String fieldName : productCategory.getFieldNames())
                        {
-                               Object fieldValue = p.getFieldValue(fieldName);
-                               Pair<String, Object> key = 
Pair.create(fieldName, fieldValue);
-                               weight *= fieldValueWeights.get(key);
+                               
if(!Constants.PRODUCT_MODEL_EXCLUDED_FIELDS.contains(fieldName))
+                               {
+                                       Object fieldValue = 
p.getFieldValue(fieldName);
+                                       Pair<String, Object> key = 
Pair.create(fieldName, fieldValue);
+                                       weight *= fieldValueWeights.get(key);
+                               }
                        }
                        productWeights.put(p, weight);
                }
@@ -119,12 +130,12 @@ public class MultinomialPurchasingModelSampler implements 
Sampler<MultinomialPur
 
        public MultinomialPurchasingModel sample() throws Exception
        {
-               Map<String, DiscretePDF<Product>> pdfs = Maps.newHashMap();
+               Map<String, MultinomialPDF<Product>> pdfs = Maps.newHashMap();
                for(ProductCategory productCategory : productCategories)
                {
                        Map<Pair<String, Object>, Double> fieldWeights = 
this.generateFieldValueWeights(productCategory);
                        Map<Product, Double> productWeights = 
this.generateProductWeights(fieldWeights, productCategory);
-                       pdfs.put(productCategory.getCategoryLabel(), new 
DiscretePDF<Product>(productWeights));
+                       pdfs.put(productCategory.getCategoryLabel(), new 
MultinomialPDF<Product>(productWeights));
                }
 
                return new MultinomialPurchasingModel(pdfs);

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/TestMultinomialPDF.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/TestMultinomialPDF.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/TestMultinomialPDF.java
new file mode 100644
index 0000000..8952389
--- /dev/null
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/pdfs/TestMultinomialPDF.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Sets;
+
+public class TestMultinomialPDF
+{
+
+       @Test
+       public void testToString()
+       {
+               Map<String, Double> objects = ImmutableMap.of("A", 0.1, "B", 
0.3, "C", 0.5);
+               MultinomialPDF<String> pdf = new 
MultinomialPDF<String>(objects);
+               String string = pdf.toString();
+               Set<String> observed = Sets.newHashSet(string.split("\n"));
+               Set<String> expected = Sets.newHashSet("0.1,A", "0.3,B", 
"0.5,C");
+               
+               Assert.assertEquals(expected, observed);
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/TestCartesianProductBase.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/TestCartesianProductBase.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/TestCartesianProductBase.java
index f171980..3b7c2e8 100644
--- 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/TestCartesianProductBase.java
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/TestCartesianProductBase.java
@@ -1,3 +1,18 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package 
org.apache.bigtop.bigpetstore.datagenerator.generators.products.cartesian;
 
 import java.util.Arrays;

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/TestCartesianProductField.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/TestCartesianProductField.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/TestCartesianProductField.java
index 42d62c7..5071a54 100644
--- 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/TestCartesianProductField.java
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/TestCartesianProductField.java
@@ -1,3 +1,18 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package 
org.apache.bigtop.bigpetstore.datagenerator.generators.products.cartesian;
 
 import java.util.Arrays;

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestAlwaysTrueRule.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestAlwaysTrueRule.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestAlwaysTrueRule.java
new file mode 100644
index 0000000..c32fa1b
--- /dev/null
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestAlwaysTrueRule.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestAlwaysTrueRule
+{
+
+       @Test
+       public void testRuleMatches()
+       {
+               Rule rule = new AlwaysTrueRule();
+               Assert.assertTrue(rule.ruleMatches(null));
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestAndRule.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestAndRule.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestAndRule.java
new file mode 100644
index 0000000..b930c38
--- /dev/null
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestAndRule.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestAndRule
+{
+
+       @Test
+       public void testRuleMatches()
+       {
+               Rule rule = new AndRule(
+                               new AlwaysTrueRule(),
+                               new AlwaysTrueRule());
+               Assert.assertTrue(rule.ruleMatches(null));
+               
+               rule = new AndRule(
+                               new AlwaysTrueRule(),
+                               new NotRule(
+                                               new AlwaysTrueRule()));
+               Assert.assertFalse(rule.ruleMatches(null));
+               
+               rule = new AndRule(
+                               new NotRule(
+                                               new AlwaysTrueRule()),
+                               new AlwaysTrueRule());
+               Assert.assertFalse(rule.ruleMatches(null));
+               
+               rule = new AndRule(
+                               new NotRule(
+                                               new AlwaysTrueRule()),
+                               new NotRule(
+                                               new AlwaysTrueRule()));
+               Assert.assertFalse(rule.ruleMatches(null));
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestFieldPredicate.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestFieldPredicate.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestFieldPredicate.java
new file mode 100644
index 0000000..88cae45
--- /dev/null
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestFieldPredicate.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules;
+
+import java.util.Map;
+
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+public class TestFieldPredicate
+{
+
+       @Test
+       public void testRuleMatches()
+       {
+               Map<String, Object> fields = ImmutableMap.of("brand", (Object) 
"Chef Corgi",
+                               "flavor", (Object) "chicken");
+               Product product = new Product(fields);
+               
+               Rule rule = new FieldPredicate("brand", "Chef Corgi");
+               Assert.assertTrue(rule.ruleMatches(product));
+               
+               rule = new FieldPredicate("brand", "Happy Pup");
+               Assert.assertFalse(rule.ruleMatches(product));
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestNotRule.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestNotRule.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestNotRule.java
new file mode 100644
index 0000000..ee284af
--- /dev/null
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestNotRule.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestNotRule
+{
+
+       @Test
+       public void testRuleMatches()
+       {
+               Rule rule = new NotRule(
+                               new AlwaysTrueRule());
+               Assert.assertFalse(rule.ruleMatches(null));
+               
+               rule = new NotRule(
+                               new NotRule(
+                                               new AlwaysTrueRule()));
+               Assert.assertTrue(rule.ruleMatches(null));
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/6aea780a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestOrRule.java
----------------------------------------------------------------------
diff --git 
a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestOrRule.java
 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestOrRule.java
new file mode 100644
index 0000000..fd6f817
--- /dev/null
+++ 
b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/TestOrRule.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestOrRule
+{
+
+       @Test
+       public void testRuleMatches()
+       {
+               Rule rule = new OrRule(
+                               new AlwaysTrueRule(),
+                               new AlwaysTrueRule());
+               Assert.assertTrue(rule.ruleMatches(null));
+               
+               rule = new OrRule(
+                               new AlwaysTrueRule(),
+                               new NotRule(
+                                               new AlwaysTrueRule()));
+               Assert.assertTrue(rule.ruleMatches(null));
+               
+               rule = new OrRule(
+                               new NotRule(
+                                               new AlwaysTrueRule()),
+                               new AlwaysTrueRule());
+               Assert.assertTrue(rule.ruleMatches(null));
+               
+               rule = new OrRule(
+                               new NotRule(
+                                               new AlwaysTrueRule()),
+                               new NotRule(
+                                               new AlwaysTrueRule()));
+               Assert.assertFalse(rule.ruleMatches(null));
+       }
+}

Reply via email to