bigtop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnowl...@apache.org
Subject [08/11] bigtop git commit: BIGTOP-1984. Extract samplers library from BigPetStore data generator
Date Tue, 25 Aug 2015 14:21:42 GMT
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CategoryWeightFunction.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CategoryWeightFunction.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CategoryWeightFunction.java
deleted file mode 100644
index 09b7327..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CategoryWeightFunction.java
+++ /dev/null
@@ -1,39 +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.generators.transaction;
-
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.ExponentialPDF;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.ProbabilityDensityFunction;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.wfs.ConditionalWeightFunction;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.wfs.WeightFunction;
-
-public class CategoryWeightFunction implements ConditionalWeightFunction<Double, Double>
-{
-	private final ProbabilityDensityFunction<Double> pdf;
-	
-	public CategoryWeightFunction(double averagePurchaseTriggerTime)
-	{
-		double lambda = 1.0 / averagePurchaseTriggerTime;
-		pdf = new ExponentialPDF(lambda);
-	}
-	
-	@Override
-	public double weight(Double exhaustionTime, Double transactionTime)
-	{
-		double remainingTime = Math.max(0.0, exhaustionTime - transactionTime);
-		return pdf.probability(remainingTime);
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerInventory.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerInventory.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerInventory.java
deleted file mode 100644
index f0f538a..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerInventory.java
+++ /dev/null
@@ -1,65 +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.generators.transaction;
-
-import java.util.Map;
-
-import org.apache.bigtop.bigpetstore.datagenerator.Constants;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-
-public class CustomerInventory
-{
-	final private ImmutableMap<String, ProductCategoryInventory> productCategoryInventories;
-	
-	public CustomerInventory(Map<String, ProductCategoryInventory> productCategoryInventories)
-	{
-		this.productCategoryInventories = ImmutableMap.copyOf(productCategoryInventories);
-	}
-	
-	public void simulatePurchase(double time, Product product) throws Exception
-	{
-		String category = product.getFieldValueAsString(Constants.PRODUCT_CATEGORY);
-		ProductCategoryInventory inventory = productCategoryInventories.get(category);
-		inventory.simulatePurchase(time, product);
-	}
-	
-	public ImmutableMap<String, Double> getInventoryAmounts(double time)
-	{
-		Map<String, Double> amounts = Maps.newHashMap();
-		for(String category : productCategoryInventories.keySet())
-		{
-			double amount = productCategoryInventories.get(category).findRemainingAmount(time);
-			amounts.put(category, amount);
-		}
-		
-		return ImmutableMap.copyOf(amounts);
-	}
-	
-	public ImmutableMap<String, Double> getExhaustionTimes()
-	{
-		Map<String, Double> times = Maps.newHashMap();
-		for(String category : productCategoryInventories.keySet())
-		{
-			double time = productCategoryInventories.get(category).findExhaustionTime();
-			times.put(category, time);
-		}
-		
-		return ImmutableMap.copyOf(times);
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerInventoryBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerInventoryBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerInventoryBuilder.java
deleted file mode 100644
index 80ed944..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerInventoryBuilder.java
+++ /dev/null
@@ -1,69 +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.generators.transaction;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-public class CustomerInventoryBuilder
-{
-	final private List<ProductCategory> productCategories;
-	final private SeedFactory seedFactory;
-	final private CustomerTransactionParameters parameters;
-	
-	public CustomerInventoryBuilder(CustomerTransactionParameters parameters,
-			SeedFactory seedFactory)
-	{
-		productCategories = Lists.newArrayList();
-		this.seedFactory = seedFactory;
-		this.parameters = parameters;
-	}
-	
-	public void addProductCategory(ProductCategory productCategory)
-	{
-		this.productCategories.add(productCategory);
-	}
-	
-	public void addAllProductCategories(Collection<ProductCategory> productCategories)
-	{
-		this.productCategories.addAll(productCategories);
-	}
-	
-	public CustomerInventory build()
-	{
-		Map<String, ProductCategoryInventory> inventories = Maps.newHashMap();
-		for(ProductCategory productCategory : productCategories)
-		{
-			if(parameters.countPetsBySpecies(productCategory.getApplicableSpecies()) > 0)
-			{
-				ProductCategoryInventory inventory = new ProductCategoryInventory(productCategory,
-					parameters, seedFactory);
-				inventories.put(productCategory.getCategoryLabel(), inventory);
-			}
-		}
-		
-		return new CustomerInventory(inventories);
-	}
-}
-
-

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParameters.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParameters.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParameters.java
deleted file mode 100644
index 9267635..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParameters.java
+++ /dev/null
@@ -1,73 +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.generators.transaction;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
-
-import com.google.common.collect.ImmutableMultiset;
-import com.google.common.collect.Multiset;
-import com.google.common.collect.Sets;
-
-public class CustomerTransactionParameters
-{
-	final ImmutableMultiset<PetSpecies> petCounts;
-	final double averageTransactionTriggerTime;
-	final double averagePurchaseTriggerTime;
-	
-	public CustomerTransactionParameters(Multiset<PetSpecies> petCounts,
-			double averageTransactionTriggerTime, double averagePurchaseTriggerTime)
-	{
-		this.petCounts = ImmutableMultiset.copyOf(petCounts);
-		this.averageTransactionTriggerTime = averageTransactionTriggerTime;
-		this.averagePurchaseTriggerTime = averagePurchaseTriggerTime;
-	}
-
-	public double getAverageTransactionTriggerTime()
-	{
-		return averageTransactionTriggerTime;
-	}
-
-	public double getAveragePurchaseTriggerTime()
-	{
-		return averagePurchaseTriggerTime;
-	}
-	
-	public int countPetsBySpecies(PetSpecies species)
-	{
-		return petCounts.count(species);
-	}
-	
-	public int countPetsBySpecies(Collection<PetSpecies> allSpecies)
-	{
-		int count = 0;
-		Set<PetSpecies> speciesSet = Sets.newHashSet(allSpecies);
-		for(PetSpecies species : speciesSet)
-		{
-			count += countPetsBySpecies(species);
-		}
-		
-		return count;
-	}
-	
-	public int countPets()
-	{
-		return petCounts.size();
-	}
-	
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersBuilder.java
deleted file mode 100644
index 9adfa4c..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersBuilder.java
+++ /dev/null
@@ -1,58 +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.generators.transaction;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
-
-import com.google.common.collect.HashMultiset;
-import com.google.common.collect.Multiset;
-
-public class CustomerTransactionParametersBuilder
-{
-	private Multiset<PetSpecies> petCounts;
-	private double averageTransactionTriggerTime;
-	private double averagePurchaseTriggerTime;
-	
-	public CustomerTransactionParametersBuilder()
-	{
-		this.petCounts = HashMultiset.create();
-		this.averagePurchaseTriggerTime = 0.0;
-		this.averageTransactionTriggerTime = 0.0;
-	}
-	
-	public void addPet(PetSpecies species)
-	{
-		this.petCounts.add(species);
-	}
-
-	public void setAverageTransactionTriggerTime(
-			double averageTransactionTriggerTime)
-	{
-		this.averageTransactionTriggerTime = averageTransactionTriggerTime;
-	}
-
-	public void setAveragePurchaseTriggerTime(double averagePurchaseTriggerTime)
-	{
-		this.averagePurchaseTriggerTime = averagePurchaseTriggerTime;
-	}
-	
-	public CustomerTransactionParameters build()
-	{
-		return new CustomerTransactionParameters(this.petCounts,
-				this.averageTransactionTriggerTime,
-				this.averagePurchaseTriggerTime);
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersSampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersSampler.java
deleted file mode 100644
index 8495fd9..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersSampler.java
+++ /dev/null
@@ -1,61 +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.generators.transaction;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-
-public class CustomerTransactionParametersSampler implements Sampler<CustomerTransactionParameters>
-{
-	final private Sampler<Integer> nPetsSampler;
-	final private Sampler<PetSpecies> petSpeciesSampler;
-	final private Sampler<Double> purchaseTriggerTimeSampler;
-	final private Sampler<Double> transactionTriggerTimeSampler;
-
-	public CustomerTransactionParametersSampler(Sampler<Integer> nPetsSampler,
-			Sampler<PetSpecies> petSpeciesSampler, 
-			Sampler<Double> purchaseTriggerTimeSampler,
-			Sampler<Double> transactionTriggerTimeSampler)
-	{
-
-		this.nPetsSampler = nPetsSampler;
-		this.petSpeciesSampler = petSpeciesSampler;
-		this.purchaseTriggerTimeSampler = purchaseTriggerTimeSampler;
-		this.transactionTriggerTimeSampler = transactionTriggerTimeSampler;
-	}
-	
-	protected void generatePets(CustomerTransactionParametersBuilder builder) throws Exception
-	{
-		int nPets = this.nPetsSampler.sample();
-		
-		for(int i = 0; i < nPets; i++)
-		{
-			PetSpecies species = this.petSpeciesSampler.sample();
-			builder.addPet(species);	
-		}
-	}
-	
-	public CustomerTransactionParameters sample() throws Exception
-	{
-		CustomerTransactionParametersBuilder builder = new CustomerTransactionParametersBuilder();
-		
-		this.generatePets(builder);
-		builder.setAveragePurchaseTriggerTime(this.purchaseTriggerTimeSampler.sample());
-		builder.setAverageTransactionTriggerTime(this.transactionTriggerTimeSampler.sample());
-		
-		return builder.build();
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersSamplerBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersSamplerBuilder.java
deleted file mode 100644
index 249a456..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/CustomerTransactionParametersSamplerBuilder.java
+++ /dev/null
@@ -1,55 +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.generators.transaction;
-
-import java.util.Arrays;
-
-import org.apache.bigtop.bigpetstore.datagenerator.Constants;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.BoundedMultiModalGaussianSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.RouletteWheelSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.UniformIntSampler;
-
-public class CustomerTransactionParametersSamplerBuilder
-{
-	final private SeedFactory seedFactory;
-
-	public CustomerTransactionParametersSamplerBuilder(SeedFactory seedFactory)
-	{
-		this.seedFactory = seedFactory;
-	}
-	
-	public Sampler<CustomerTransactionParameters> build()
-	{
-		Sampler<Integer> nPetsSampler = new UniformIntSampler(Constants.MIN_PETS, Constants.MAX_PETS, seedFactory);
-		
-		Sampler<PetSpecies> petSpeciesSampler = RouletteWheelSampler.createUniform(Arrays.asList(PetSpecies.values()), seedFactory);
-		
-		Sampler<Double> transactionTriggerTimeSampler = new BoundedMultiModalGaussianSampler(Constants.TRANSACTION_TRIGGER_TIME_GAUSSIANS,
-					Constants.TRANSACTION_TRIGGER_TIME_MIN, Constants.TRANSACTION_TRIGGER_TIME_MAX,
-					seedFactory);
-		
-		Sampler<Double> purchaseTriggerTimeSampler = new BoundedMultiModalGaussianSampler(Constants.PURCHASE_TRIGGER_TIME_GAUSSIANS,
-				Constants.PURCHASE_TRIGGER_TIME_MIN, Constants.PURCHASE_TRIGGER_TIME_MAX,
-				seedFactory);
-		
-		return new CustomerTransactionParametersSampler(nPetsSampler, petSpeciesSampler,
-				transactionTriggerTimeSampler, purchaseTriggerTimeSampler);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryInventory.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryInventory.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryInventory.java
deleted file mode 100644
index 8d43b82..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryInventory.java
+++ /dev/null
@@ -1,58 +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.generators.transaction;
-
-import org.apache.bigtop.bigpetstore.datagenerator.Constants;
-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;
-
-public class ProductCategoryInventory
-{	
-	private ProductCategoryUsageTrajectory trajectory;
-	private ProductCategoryUsageSimulator simulator;
-	
-	public ProductCategoryInventory(ProductCategory productCategory, CustomerTransactionParameters parameters,
-			SeedFactory seedFactory)
-	{
-		
-		double amountUsedAverage = productCategory.getBaseAmountUsedAverage() * parameters.countPetsBySpecies(productCategory.getApplicableSpecies());
-		double amountUsedVariance = productCategory.getBaseAmountUsedVariance() * parameters.countPetsBySpecies(productCategory.getApplicableSpecies());		
-		
-		trajectory = new ProductCategoryUsageTrajectory(0.0, 0.0);
-		simulator = new ProductCategoryUsageSimulator(productCategory.getDailyUsageRate(),
-				amountUsedAverage, amountUsedVariance, seedFactory);
-	}
-	
-	public void simulatePurchase(double time, Product product) throws Exception
-	{
-		double amountPurchased = product.getFieldValueAsDouble(Constants.PRODUCT_QUANTITY);
-		
-		double amountRemainingBeforePurchase = trajectory.amountAtTime(time);
-		
-		trajectory = simulator.simulate(time, amountRemainingBeforePurchase + amountPurchased);
-	}
-	
-	public double findExhaustionTime()
-	{
-		return trajectory.getLastTime();
-	}
-	
-	public double findRemainingAmount(double time)
-	{
-		return trajectory.amountAtTime(time);
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageSimulator.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageSimulator.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageSimulator.java
deleted file mode 100644
index b09d395..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageSimulator.java
+++ /dev/null
@@ -1,72 +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.generators.transaction;
-
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.ExponentialSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.GaussianSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-
-public class ProductCategoryUsageSimulator
-{
-	final private double amountUsedAverage;
-	final private double amountUsedVariance;
-	
-	final private Sampler<Double> timestepSampler;
-	final private Sampler<Double> R;
-	
-	public ProductCategoryUsageSimulator(double dailyUsageRate, double amountUsedAverage,
-			double amountUsedVariance, SeedFactory seedFactory)
-	{
-		this.amountUsedAverage = amountUsedAverage;
-		this.amountUsedVariance = amountUsedVariance;
-		
-		timestepSampler = new ExponentialSampler(dailyUsageRate, seedFactory);
-		R = new GaussianSampler(0.0, 1.0, seedFactory);
-	}
-	
-	private void step(ProductCategoryUsageTrajectory trajectory) throws Exception
-	{
-		// given in days since last usage
-		double timestep = timestepSampler.sample();
-		
-		double r = R.sample();
-		
-		// given in units per day
-		double usageAmount = this.amountUsedAverage * timestep + 
-				Math.sqrt(this.amountUsedVariance * timestep) * r;
-		
-		// can't use a negative amount
-		usageAmount = Math.max(usageAmount, 0.0);
-		
-		double remainingAmount = Math.max(0.0, trajectory.getLastAmount() - usageAmount);
-		double time = trajectory.getLastTime() + timestep;
-		
-		trajectory.append(time, remainingAmount);
-	}
-	
-	public ProductCategoryUsageTrajectory simulate(double initialTime, double initialAmount) throws Exception
-	{
-		ProductCategoryUsageTrajectory trajectory = new ProductCategoryUsageTrajectory(initialTime, initialAmount);
-		
-		while(trajectory.getLastAmount() > 0.0)
-		{
-			step(trajectory);
-		}
-		
-		return trajectory;
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageTrajectory.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageTrajectory.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageTrajectory.java
deleted file mode 100644
index f3c20c7..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageTrajectory.java
+++ /dev/null
@@ -1,74 +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.generators.transaction;
-
-import java.util.List;
-
-import org.apache.commons.lang3.tuple.Pair;
-
-import com.google.common.collect.Lists;
-
-public class ProductCategoryUsageTrajectory
-{
-	final private List<Pair<Double, Double>> trajectory;
-	
-	public ProductCategoryUsageTrajectory(double initialTime, double initialAmount)
-	{
-		trajectory = Lists.newArrayList();
-		this.append(initialTime, initialAmount);
-	}
-	
-	public void append(double time, double amount)
-	{
-		trajectory.add(Pair.of(time, amount));
-	}
-	
-	public double getLastAmount()
-	{
-		return trajectory.get(trajectory.size() - 1).getValue();
-	}
-	
-	public double getLastTime()
-	{
-		return trajectory.get(trajectory.size() - 1).getKey();
-	}
-	
-	public double amountAtTime(double time)
-	{
-		Pair<Double, Double> previous = null;
-		for(Pair<Double, Double> entry : trajectory)
-		{
-			if(entry.getKey() > time)
-				break;
-			previous = entry;
-		}
-		
-		if(previous == null)
-			return 0.0;
-		
-		return previous.getValue();
-	}
-	
-	public Pair<Double, Double> getStep(int idx)
-	{
-		return trajectory.get(idx);
-	}
-	
-	public int size()
-	{
-		return trajectory.size();
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProposedPurchaseTimeSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProposedPurchaseTimeSampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProposedPurchaseTimeSampler.java
deleted file mode 100644
index 3fa2ef9..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProposedPurchaseTimeSampler.java
+++ /dev/null
@@ -1,49 +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.generators.transaction;
-
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-
-public class ProposedPurchaseTimeSampler implements Sampler<Double>
-{
-	final CustomerInventory customerInventory;
-	final Sampler<Double> arrivalTimeSampler;
-	
-	public ProposedPurchaseTimeSampler(CustomerInventory customerInventory,
-			Sampler<Double> arrivalTimeSampler)
-	{
-		this.customerInventory = customerInventory;
-		this.arrivalTimeSampler = arrivalTimeSampler;
-	}
-	
-	protected double categoryProposedTime(double exhaustionTime) throws Exception
-	{
-		return Math.max(exhaustionTime - arrivalTimeSampler.sample(), 0.0);
-	}
-	
-	public Double sample() throws Exception
-	{
-		double minProposedTime = Double.MAX_VALUE;
-		for(Double exhaustionTime : this.customerInventory.getExhaustionTimes().values())
-		{
-			double proposedTime = this.categoryProposedTime(exhaustionTime);
-			minProposedTime = Math.min(proposedTime, minProposedTime);
-		}
-		
-		return minProposedTime;
-	}
-	
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionPurchasesHiddenMarkovModel.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionPurchasesHiddenMarkovModel.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionPurchasesHiddenMarkovModel.java
deleted file mode 100644
index 83924e3..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionPurchasesHiddenMarkovModel.java
+++ /dev/null
@@ -1,108 +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.generators.transaction;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.bigtop.bigpetstore.datagenerator.Constants;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.ConditionalSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.RouletteWheelSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.wfs.ConditionalWeightFunction;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-public class TransactionPurchasesHiddenMarkovModel implements ConditionalSampler<List<Product>, Double>
-{
-	
-	protected final static String STOP_STATE = "STOP";
-	
-	final ConditionalSampler<Product, String> purchasingProcesses;
-	final ConditionalWeightFunction<Double, Double> categoryWF;
-	final CustomerInventory inventory;
-	
-	final SeedFactory seedFactory;
-	
-	public TransactionPurchasesHiddenMarkovModel(ConditionalSampler<Product, String> purchasingProcesses,
-			ConditionalWeightFunction<Double, Double> categoryWF, CustomerInventory inventory,
-				SeedFactory seedFactory)
-	{
-		this.purchasingProcesses = purchasingProcesses;
-		this.inventory = inventory;
-		this.categoryWF = categoryWF;
-		
-		this.seedFactory = seedFactory;
-	}
-	
-	protected String chooseCategory(double transactionTime, int numPurchases) throws Exception
-	{
-		ImmutableMap<String, Double> exhaustionTimes = this.inventory.getExhaustionTimes();
-		Map<String, Double> weights = Maps.newHashMap();
-		
-		for(Map.Entry<String, Double> entry : exhaustionTimes.entrySet())
-		{
-			String category = entry.getKey();
-			double weight = this.categoryWF.weight(entry.getValue(), transactionTime);
-			weights.put(category, weight);
-		}
-		
-		if(numPurchases > 0)
-		{
-			weights.put(STOP_STATE, Constants.STOP_CATEGORY_WEIGHT);
-		}
-		
-		Sampler<String> sampler = RouletteWheelSampler.create(weights, seedFactory);
-		
-		return sampler.sample();
-	}
-	
-	protected Product chooseProduct(String category) throws Exception
-	{
-		return this.purchasingProcesses.sample(category);
-	}
-
-	public List<Product> sample(Double transactionTime) throws Exception
-	{
-		int numPurchases = 0;
-		
-		List<Product> purchasedProducts = Lists.newArrayList();
-		
-		String category;
-		while(true)
-		{
-			category = this.chooseCategory(transactionTime, numPurchases);
-			
-			if(category.equals(STOP_STATE))
-			{
-				break;
-			}
-			
-			Product product = this.chooseProduct(category);
-			
-			purchasedProducts.add(product);
-			
-			this.inventory.simulatePurchase(transactionTime, product);
-			numPurchases += 1;
-		}
-		
-		return purchasedProducts;
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionPurchasesSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionPurchasesSamplerBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionPurchasesSamplerBuilder.java
deleted file mode 100644
index 4400151..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionPurchasesSamplerBuilder.java
+++ /dev/null
@@ -1,70 +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.generators.transaction;
-
-import java.util.Collection;
-import java.util.List;
-
-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.samplers.ConditionalSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.wfs.ConditionalWeightFunction;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.purchase.PurchasingModel;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.purchase.PurchasingProcesses;
-
-public class TransactionPurchasesSamplerBuilder
-{
-	final SeedFactory seedFactory;
-	final Collection<ProductCategory> productCategories;
-	final PurchasingModel purchasingProfile;
-	
-	protected CustomerTransactionParameters transactionParameters;
-	protected CustomerInventory inventory;
-	
-	public TransactionPurchasesSamplerBuilder(Collection<ProductCategory> productCategories,
-			PurchasingModel purchasingProfile,
-			SeedFactory seedFactory)
-	{
-		this.seedFactory = seedFactory;
-		this.productCategories = productCategories;
-		this.purchasingProfile = purchasingProfile;
-	}
-	
-	public void setTransactionParameters(
-			CustomerTransactionParameters transactionParameters)
-	{
-		this.transactionParameters = transactionParameters;
-	}
-
-	public void setInventory(CustomerInventory inventory)
-	{
-		this.inventory = inventory;
-	}
-
-	public ConditionalSampler<List<Product>, Double> build() throws Exception
-	{
-		PurchasingProcesses processes = purchasingProfile.buildProcesses(seedFactory);
-		
-		ConditionalWeightFunction<Double, Double> categoryWF =
-				new CategoryWeightFunction(transactionParameters.getAveragePurchaseTriggerTime());
-		
-		ConditionalSampler<List<Product>, Double> sampler = new TransactionPurchasesHiddenMarkovModel(processes,
-				categoryWF, inventory, this.seedFactory);
-		
-		return sampler;
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionSampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionSampler.java
deleted file mode 100644
index b19ae38..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionSampler.java
+++ /dev/null
@@ -1,56 +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.generators.transaction;
-
-import java.util.List;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Customer;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Transaction;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.ConditionalSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-
-public class TransactionSampler implements Sampler<Transaction>
-{
-	private final Sampler<Double> timeSampler;
-	private final ConditionalSampler<List<Product>, Double> purchasesSampler;
-	private final Sampler<Integer> idSampler;
-	private final Customer customer;
-	
-	public TransactionSampler(Customer customer, Sampler<Double> timeSampler,
-			ConditionalSampler<List<Product>, Double> purchasesSampler,
-			Sampler<Integer> idSampler)
-	{
-		this.timeSampler = timeSampler;
-		this.customer = customer;
-		this.purchasesSampler = purchasesSampler;
-		this.idSampler = idSampler;
-	}
-	
-	
-	public Transaction sample() throws Exception
-	{	
-		Double transactionTime = timeSampler.sample();
-		List<Product> purchase = purchasesSampler.sample(transactionTime);
-		Integer id = idSampler.sample();
-			
-		Transaction transaction = new Transaction(id, customer, customer.getStore(),
-				transactionTime, purchase);
-		
-		return transaction;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionSamplerBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionSamplerBuilder.java
deleted file mode 100644
index 748b4db..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionSamplerBuilder.java
+++ /dev/null
@@ -1,95 +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.generators.transaction;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Customer;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Transaction;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.ConditionalSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.SequenceSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.purchase.PurchasingModel;
-
-public class TransactionSamplerBuilder
-{
-	private final Collection<ProductCategory> productCategories;
-	private final Customer customer;
-	private final PurchasingModel purchasingProfile;
-	private final SeedFactory seedFactory;
-	
-	CustomerTransactionParameters parameters;
-	CustomerInventory inventory;
-	
-	public TransactionSamplerBuilder(Collection<ProductCategory> productCategories, 
-			Customer customer,
-			PurchasingModel purchasingProfile,
-			SeedFactory seedFactory) throws Exception
-	{
-		this.customer = customer;
-		this.seedFactory = seedFactory;
-		this.purchasingProfile = purchasingProfile;
-		this.productCategories = productCategories;	
-	}
-	
-	protected void buildParameters() throws Exception
-	{
-		CustomerTransactionParametersSamplerBuilder builder = new CustomerTransactionParametersSamplerBuilder(seedFactory);
-		parameters = builder.build().sample();
-	}
-	
-	protected ConditionalSampler<List<Product>, Double> buildPurchasesSampler() throws Exception
-	{
-		TransactionPurchasesSamplerBuilder builder = new TransactionPurchasesSamplerBuilder(productCategories,
-				purchasingProfile, seedFactory);
-		
-		builder.setTransactionParameters(parameters);
-		builder.setInventory(inventory);
-	
-		return builder.build();
-	}
-	
-	protected Sampler<Double> buildTimeSampler()
-	{
-		TransactionTimeSamplerBuilder builder = new TransactionTimeSamplerBuilder(seedFactory);
-		builder.setCustomerTransactionParameters(parameters);
-		builder.setCustomerInventory(inventory);
-		
-		return builder.build();
-	}
-	
-	protected void buildCustomerInventory()
-	{
-		CustomerInventoryBuilder inventoryBuilder = new CustomerInventoryBuilder(parameters,
-				seedFactory);
-		inventoryBuilder.addAllProductCategories(productCategories);
-		inventory = inventoryBuilder.build();
-	}
-	
-	public Sampler<Transaction> build() throws Exception
-	{
-		buildParameters();
-		buildCustomerInventory();
-		
-		Sampler<Double> timeSampler = buildTimeSampler();
-		
-		return new TransactionSampler(customer, timeSampler, buildPurchasesSampler(), new SequenceSampler());
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionTimePDF.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionTimePDF.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionTimePDF.java
deleted file mode 100644
index b2b284f..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionTimePDF.java
+++ /dev/null
@@ -1,31 +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.generators.transaction;
-
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.ConditionalProbabilityDensityFunction;
-
-public class TransactionTimePDF implements ConditionalProbabilityDensityFunction<Double, Double>
-{	
-	public double probability(Double proposedTime, Double lastTransactionTime)
-	{
-		if(proposedTime >= lastTransactionTime)
-		{
-			return 1.0;
-		}
-
-		return 0.0;
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionTimeSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionTimeSamplerBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionTimeSamplerBuilder.java
deleted file mode 100644
index 261d5a3..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TransactionTimeSamplerBuilder.java
+++ /dev/null
@@ -1,56 +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.generators.transaction;
-
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.ExponentialSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.StatefulMonteCarloSampler;
-
-public class TransactionTimeSamplerBuilder
-{
-	private final SeedFactory seedFactory;
-	private CustomerInventory customerInventory;
-	private CustomerTransactionParameters transactionParameters;
-	
-	public TransactionTimeSamplerBuilder(SeedFactory seedFactory)
-	{
-		this.seedFactory = seedFactory;
-	}
-	
-	public void setCustomerInventory(CustomerInventory inventory)
-	{
-		this.customerInventory = inventory;
-	}
-	
-	public void setCustomerTransactionParameters(CustomerTransactionParameters parameters)
-	{
-		this.transactionParameters = parameters;
-	}
-	
-	public Sampler<Double> build()
-	{
-		double lambda = 1.0 / transactionParameters.getAverageTransactionTriggerTime();
-		Sampler<Double> arrivalTimeSampler = new ExponentialSampler(lambda, seedFactory);
-		Sampler<Double> proposedTimeSampler = new ProposedPurchaseTimeSampler(customerInventory,
-				arrivalTimeSampler);
-		
-		return new StatefulMonteCarloSampler<Double>(proposedTimeSampler, 
-				new TransactionTimePDF(),
-				0.0,
-				seedFactory);
-	}
-}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/Constants.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/Constants.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/Constants.java
new file mode 100644
index 0000000..21827d5
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/Constants.java
@@ -0,0 +1,99 @@
+/**
+ * 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.datagenerators.bigpetstore;
+
+import java.io.File;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.lang3.tuple.Pair;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
+public class Constants
+{
+	public static enum PurchasingModelType
+	{
+		MULTINOMIAL,
+		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 ProductsCollectionSize PRODUCTS_COLLECTION = ProductsCollectionSize.MEDIUM;
+
+	public static final double INCOME_SCALING_FACTOR = 100.0;
+
+	public static final int MIN_PETS = 1;
+	public static final int MAX_PETS = 10;
+
+	public static final List<Pair<Double, Double>> TRANSACTION_TRIGGER_TIME_GAUSSIANS = ImmutableList.of(Pair.of(5.0, 2.0));
+	public static final List<Pair<Double, Double>> PURCHASE_TRIGGER_TIME_GAUSSIANS = ImmutableList.of(Pair.of(10.0, 4.0));
+
+	public static final double TRANSACTION_TRIGGER_TIME_MAX = 10.0;
+	public static final double TRANSACTION_TRIGGER_TIME_MIN = 1.0;
+
+	public static final double PURCHASE_TRIGGER_TIME_MAX = 20.0;
+	public static final double PURCHASE_TRIGGER_TIME_MIN = 1.0;
+
+	public static final double AVERAGE_CUSTOMER_STORE_DISTANCE = 5.0; // miles
+
+	public static final PurchasingModelType PURCHASING_MODEL_TYPE = PurchasingModelType.MULTINOMIAL;
+
+	public static final List<Pair<Double, Double>> PRODUCT_MSM_FIELD_WEIGHT_GAUSSIANS = ImmutableList.of(Pair.of(0.15, 0.1), Pair.of(0.85, 0.1));
+	public static final double PRODUCT_MSM_FIELD_WEIGHT_LOWERBOUND = 0.05;
+	public static final double PRODUCT_MSM_FIELD_WEIGHT_UPPERBOUND = 0.95;
+
+	public static final List<Pair<Double, Double>> PRODUCT_MSM_FIELD_SIMILARITY_WEIGHT_GAUSSIANS = ImmutableList.of(Pair.of(0.15, 0.1), Pair.of(0.85, 0.1));
+	public static final double PRODUCT_MSM_FIELD_SIMILARITY_WEIGHT_LOWERBOUND = 0.05;
+	public static final double PRODUCT_MSM_FIELD_SIMILARITY_WEIGHT_UPPERBOUND = 0.95;
+
+	public static final List<Pair<Double, Double>> PRODUCT_MSM_LOOPBACK_WEIGHT_GAUSSIANS = ImmutableList.of(Pair.of(0.25, 0.1), Pair.of(0.75, 0.1));
+	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_POSITIVE_WEIGHT = 10.0;
+	public static final double PRODUCT_MULTINOMIAL_NEUTRAL_WEIGHT = 1.0;
+	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/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/CustomerGenerator.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/CustomerGenerator.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/CustomerGenerator.java
new file mode 100644
index 0000000..7fc2cbe
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/CustomerGenerator.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.datagenerators.bigpetstore;
+
+import java.util.List;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Customer;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.InputData;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.customer.CustomerSamplerBuilder;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+
+public class CustomerGenerator
+{
+	final Sampler<Customer> sampler;
+
+	public CustomerGenerator(InputData inputData, List<Store> stores, SeedFactory seedFactory)
+	{
+		CustomerSamplerBuilder builder = new CustomerSamplerBuilder(stores, inputData, seedFactory);
+		sampler = builder.build();
+	}
+
+	public Customer generate() throws Exception
+	{
+		return sampler.sample();
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/DataLoader.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/DataLoader.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/DataLoader.java
new file mode 100644
index 0000000..d3393fe
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/DataLoader.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.datagenerators.bigpetstore;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.InputData;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.Names;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.datagenerators.bigpetstore.datareaders.NameReader;
+import org.apache.bigtop.datagenerators.bigpetstore.datareaders.ZipcodeReader;
+
+public class DataLoader
+{
+	private InputStream getResource(File filename) throws Exception
+	{
+		InputStream stream = getClass().getResourceAsStream("/input_data/" + filename);
+		return new BufferedInputStream(stream);
+	}
+
+	public InputData loadData() throws Exception
+	{
+
+		System.out.println("Reading zipcode data");
+		ZipcodeReader zipcodeReader = new ZipcodeReader();
+		zipcodeReader.setCoordinatesFile(getResource(Constants.COORDINATES_FILE));
+		zipcodeReader.setIncomesFile(getResource(Constants.INCOMES_FILE));
+		zipcodeReader.setPopulationFile(getResource(Constants.POPULATION_FILE));
+		List<ZipcodeRecord> zipcodeTable = zipcodeReader.readData();
+		System.out.println("Read " + zipcodeTable.size() + " zipcode entries");
+
+		System.out.println("Reading name data");
+		NameReader nameReader = new NameReader(getResource(Constants.NAMEDB_FILE));
+		Names names = nameReader.readData();
+		System.out.println("Read " + names.getFirstNames().size() + " first names and " + names.getLastNames().size() + " last names");
+
+		InputData inputData = new InputData(zipcodeTable, names);
+
+		return inputData;
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/ProductGenerator.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/ProductGenerator.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/ProductGenerator.java
new file mode 100644
index 0000000..d6a0412
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/ProductGenerator.java
@@ -0,0 +1,50 @@
+/**
+ * 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.datagenerators.bigpetstore;
+
+import java.util.List;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants.ProductsCollectionSize;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.collections.MediumProductCollection;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.collections.SmallProductCollection;
+
+public class ProductGenerator
+{
+	ProductsCollectionSize collection;
+
+	public ProductGenerator(ProductsCollectionSize collection)
+	{
+		this.collection = collection;
+	}
+
+	public List<ProductCategory> generate()
+	{
+		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/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/PurchasingModelGenerator.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/PurchasingModelGenerator.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/PurchasingModelGenerator.java
new file mode 100644
index 0000000..21f82a5
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/PurchasingModelGenerator.java
@@ -0,0 +1,40 @@
+/**
+ * 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.datagenerators.bigpetstore;
+
+import java.util.Collection;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.purchase.PurchasingModel;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.purchase.PurchasingModelSamplerBuilder;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+
+public class PurchasingModelGenerator
+{
+	final Sampler<? extends PurchasingModel> sampler;
+
+	public PurchasingModelGenerator(Collection<ProductCategory> productCategories, SeedFactory seedFactory) throws Exception
+	{
+		PurchasingModelSamplerBuilder builder = new PurchasingModelSamplerBuilder(productCategories, seedFactory);
+		sampler = builder.build();
+	}
+
+	public PurchasingModel generate() throws Exception
+	{
+		return sampler.sample();
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/StoreGenerator.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/StoreGenerator.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/StoreGenerator.java
new file mode 100644
index 0000000..60a150e
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/StoreGenerator.java
@@ -0,0 +1,38 @@
+/**
+ * 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.datagenerators.bigpetstore;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.InputData;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.store.StoreSamplerBuilder;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+
+public class StoreGenerator
+{
+	final Sampler<Store> sampler;
+
+	public StoreGenerator(InputData inputData, SeedFactory seedFactory)
+	{
+		StoreSamplerBuilder builder = new StoreSamplerBuilder(inputData.getZipcodeTable(), seedFactory);
+		sampler = builder.build();
+	}
+
+	public Store generate() throws Exception
+	{
+		return sampler.sample();
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/TransactionGenerator.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/TransactionGenerator.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/TransactionGenerator.java
new file mode 100644
index 0000000..7f56093
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/TransactionGenerator.java
@@ -0,0 +1,43 @@
+/**
+ * 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.datagenerators.bigpetstore;
+
+import java.util.Collection;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Customer;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Transaction;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.purchase.PurchasingModel;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.TransactionSamplerBuilder;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+
+public class TransactionGenerator
+{
+	Sampler<Transaction> sampler;
+
+	public TransactionGenerator(Customer customer, PurchasingModel profile,
+			Collection<ProductCategory> productCategories, SeedFactory seedFactory) throws Exception
+	{
+		sampler = new TransactionSamplerBuilder(productCategories,
+				customer, profile, seedFactory).build();
+	}
+
+	public Transaction generate() throws Exception
+	{
+		return sampler.sample();
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/cli/Driver.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/cli/Driver.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/cli/Driver.java
new file mode 100644
index 0000000..623b947
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/cli/Driver.java
@@ -0,0 +1,315 @@
+/**
+ * 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.datagenerators.bigpetstore.cli;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.bigtop.datagenerators.bigpetstore.DataLoader;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Customer;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Transaction;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.InputData;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.purchase.PurchasingModel;
+import org.apache.commons.lang3.tuple.Pair;
+
+
+public class Driver
+{
+	int nStores;
+	int nCustomers;
+	int nPurchasingModels;
+	double simulationTime;
+	long seed;
+	File outputDir;
+
+	static final int NPARAMS = 6;
+
+	private void printUsage()
+	{
+		String usage = "BigPetStore Data Generator\n" +
+				"\n" +
+				"Usage: java -jar bps-data-generator-v0.2.java outputDir nStores nCustomers nPurchasingModels simulationLength seed\n" +
+				"\n" +
+				"outputDir - (string) directory to write files\n" +
+				"nStores - (int) number of stores to generate\n" +
+				"nCustomers - (int) number of customers to generate\n" +
+				"nPurchasingModels - (int) number of purchasing models to generate\n" +
+				"simulationLength - (float) number of days to simulate\n" +
+				"seed - (long) seed for RNG. If not given, one is reandomly generated.\n";
+
+		System.out.println(usage);
+	}
+
+	public void parseArgs(String[] args)
+	{
+		if(args.length != NPARAMS && args.length != (NPARAMS - 1))
+		{
+			printUsage();
+			System.exit(1);
+		}
+
+		int i = -1;
+
+		outputDir = new File(args[++i]);
+		if(! outputDir.exists())
+		{
+			System.err.println("Given path (" + args[i] + ") does not exist.\n");
+			printUsage();
+			System.exit(1);
+		}
+
+		if(! outputDir.isDirectory())
+		{
+			System.err.println("Given path (" + args[i] + ") is not a directory.\n");
+			printUsage();
+			System.exit(1);
+		}
+
+		try
+		{
+			nStores = Integer.parseInt(args[++i]);
+		}
+		catch(Exception e)
+		{
+			System.err.println("Unable to parse '" + args[i] + "' as an integer for nStores.\n");
+			printUsage();
+			System.exit(1);
+		}
+
+		try
+		{
+			nCustomers = Integer.parseInt(args[++i]);
+		}
+		catch(Exception e)
+		{
+			System.err.println("Unable to parse '" + args[i] + "' as an integer for nCustomers.\n");
+			printUsage();
+			System.exit(1);
+		}
+
+		try
+		{
+			nPurchasingModels = Integer.parseInt(args[++i]);
+		}
+		catch(Exception e)
+		{
+			System.err.println("Unable to parse '" + args[i] + "' as an integer for nPurchasingModels.\n");
+			printUsage();
+			System.exit(1);
+		}
+
+		try
+		{
+			simulationTime = Double.parseDouble(args[++i]);
+		}
+		catch(Exception e)
+		{
+			System.err.println("Unable to parse '" + args[i] + "' as a float for simulationLength.\n");
+			printUsage();
+			System.exit(1);
+		}
+
+		try
+		{
+			seed = Long.parseLong(args[++i]);
+		}
+		catch(Exception e)
+		{
+			System.err.println("Unable to parse '" + args[i] + "' as a long for the seed.\n");
+			printUsage();
+			System.exit(1);
+		}
+	}
+
+	private void writeTransactions(Collection<Transaction> transactions) throws Exception
+	{
+		File outputFile = new File(outputDir.toString() + File.separator + "transactions.txt");
+		System.out.println(outputFile.toString());
+		OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
+
+		for(Transaction transaction : transactions)
+		{
+			for(Product product : transaction.getProducts())
+			{
+				String record = transaction.getId() + ",";
+				record += transaction.getDateTime() + ",";
+				record += transaction.getStore().getId() + ",";
+				record += transaction.getStore().getLocation().getZipcode() + ",";
+				record += transaction.getStore().getLocation().getCity() + ",";
+				record += transaction.getStore().getLocation().getState() + ",";
+				record += transaction.getCustomer().getId() + ",";
+				Pair<String, String> name = transaction.getCustomer().getName();
+				record += name.getLeft() + " " + name.getRight() + ",";
+				record += transaction.getCustomer().getLocation().getZipcode() + ",";
+				record += transaction.getCustomer().getLocation().getCity() + ",";
+				record += transaction.getCustomer().getLocation().getState() + ",";
+				record += product.toString() + "\n";
+
+				outputStream.write(record.getBytes());
+			}
+		}
+
+		outputStream.close();
+	}
+
+	private void writeCustomers(Collection<Customer> customers) throws Exception
+	{
+		File outputFile = new File(outputDir.toString() + File.separator + "customers.txt");
+		System.out.println(outputFile.toString());
+		OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
+
+		for(Customer customer : customers)
+		{
+			String record = customer.getId() + ",";
+			Pair<String, String> name = customer.getName();
+			record += name.getLeft() + "," + name.getRight() + ",";
+			record += customer.getLocation().getZipcode() + ",";
+			record += customer.getLocation().getCity() + ",";
+			record += customer.getLocation().getState() + "\n";
+
+			outputStream.write(record.getBytes());
+		}
+
+		outputStream.close();
+	}
+
+	private void writeStores(Collection<Store> stores) throws Exception
+	{
+		File outputFile = new File(outputDir.toString() + File.separator + "stores.txt");
+		System.out.println(outputFile.toString());
+		OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
+
+		for(Store store : stores)
+		{
+			String record = store.getId() + ",";
+			record += store.getLocation().getZipcode() + ",";
+			record += store.getLocation().getCity() + ",";
+			record += store.getLocation().getState() + "\n";
+
+			outputStream.write(record.getBytes());
+		}
+
+		outputStream.close();
+	}
+
+	private void writeProducts(Collection<ProductCategory> productCategories) throws Exception
+	{
+		File outputFile = new File(outputDir.toString() + File.separator + "products.txt");
+		System.out.println(outputFile.toString());
+		OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
+
+		for(ProductCategory category : productCategories)
+		{
+
+			for(Product product : category.getProducts())
+			{
+				String record = category.getCategoryLabel() + ",";
+				record += product.toString() + "\n";
+
+				outputStream.write(record.getBytes());
+			}
+		}
+
+		outputStream.close();
+	}
+
+	private void writePurchasingProfiles(List<ProductCategory> productCategories, List<PurchasingModel> profiles) throws Exception
+	{
+		File outputFile = new File(outputDir.toString() + File.separator + "purchasing_profiles.txt");
+		System.out.println(outputFile.toString());
+		OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
+
+		for(ProductCategory category : productCategories)
+		{
+			int i = 0;
+			for(PurchasingModel model : profiles)
+			{
+				Object productModel = model.getProfile(category.getCategoryLabel());
+				String record = productModel.toString();
+
+				outputStream.write(record.getBytes());
+
+				i += 1;
+			}
+		}
+
+		outputStream.close();
+	}
+
+	public Simulation buildSimulation(InputData inputData)
+	{
+		return new Simulation(inputData, nStores, nCustomers, nPurchasingModels, simulationTime, seed);
+	}
+
+	private void run(InputData inputData) throws Exception
+	{
+		Simulation simulation = buildSimulation(inputData);
+
+		simulation.simulate();
+
+		writeStores(simulation.getStores());
+		writeCustomers(simulation.getCustomers());
+		writeProducts(simulation.getProductCategories());
+		writePurchasingProfiles(simulation.getProductCategories(), simulation.getPurchasingProfiles());
+		writeTransactions(simulation.getTransactions());
+	}
+	public void run(String[] args) throws Exception
+	{
+		parseArgs(args);
+
+		InputData inputData = (new DataLoader()).loadData();
+
+		run(inputData);
+	}
+
+	public static void main(String[] args) throws Exception
+	{
+		Driver driver = new Driver();
+		driver.run(args);
+	}
+
+	public Double getSimulationLength()
+	{
+		return simulationTime;
+	}
+
+	public int getNCustomers()
+	{
+		return nCustomers;
+	}
+
+	public long getSeed()
+	{
+		return seed;
+	}
+
+	public int getNStores()
+	{
+		return nStores;
+	}
+
+	public File getOutputDir()
+	{
+		return outputDir;
+	}
+}


Mime
View raw message