<commit_before>package org.powertac.visualizer.statistical;

import java.util.concurrent.ConcurrentHashMap;

import org.powertac.common.CustomerInfo;
import org.powertac.common.TariffSpecification;
import org.powertac.common.TariffTransaction;
import org.powertac.visualizer.Helper;
import org.powertac.visualizer.domain.broker.BrokerModel;
import org.powertac.visualizer.domain.broker.CustomerTariffData;
import org.powertac.visualizer.domain.broker.TariffData;
import org.powertac.visualizer.domain.broker.TariffDynamicData;

/**
 * This performance category holds tariff related info for one broker.
 * 
 * @author <NAME>
 * 
 */
public class TariffCategory extends AbstractPerformanceCategory implements
		PerformanceCategory {

	private int customerCount;
	private TariffDynamicData lastTariffDynamicData;

	// key: postedTime
	private ConcurrentHashMap<Integer, TariffDynamicData> tariffDynamicDataMap;
	private ConcurrentHashMap<CustomerInfo, CustomerTariffData> customerTariffData;
	private ConcurrentHashMap<TariffSpecification, TariffData> tariffData;

	public TariffCategory(BrokerModel broker) {
		super(broker);
		lastTariffDynamicData = new TariffDynamicData(0, 0, 0, 0);
		tariffDynamicDataMap = new ConcurrentHashMap<Integer, TariffDynamicData>(
				1000, 0.75f, 1);
		customerTariffData = new ConcurrentHashMap<CustomerInfo, CustomerTariffData>(
				20, 0.75f, 1);
		tariffData = new ConcurrentHashMap<TariffSpecification, TariffData>(20,
				0.75f, 1);
	}

	public void processTariffSpecification(TariffSpecification ts) {
		tariffData.putIfAbsent(ts, new TariffData(ts, this.getBroker()));
	}

	public int getCustomerCount() {
		return customerCount;
	}

	public ConcurrentHashMap<Integer, TariffDynamicData> getTariffDynamicDataMap() {
		return tariffDynamicDataMap;
	}

	/**
	 * @return Info about broker's transactions related to one customer model.
	 */
	public ConcurrentHashMap<CustomerInfo, CustomerTariffData> getCustomerTariffData() {
		return customerTariffData;
	}

	/**
	 * @return Info about broker's tariff related to one customer model.
	 */
	public ConcurrentHashMap<TariffSpecification, TariffData> getTariffData() {
		return tariffData;
	}

	public void update(int tsIndex, double energy, double cash,
			int customerDelta) {
		customerCount += customerDelta;
		tariffDynamicDataMap.get(tsIndex).update(
				energy, cash, customerDelta);
		update(tsIndex,energy, cash);
	}

	public void addTariffDynamicData(TariffDynamicData tdd) {
		lastTariffDynamicData = tdd;
		tariffDynamicDataMap.put(tdd.getDynamicData().getTsIndex(), tdd);

	}

	public TariffDynamicData getLastTariffDynamicData() {
		return lastTariffDynamicData;
	}

}
<commit_msg>bugfix for tariff graphs<commit_after>package org.powertac.visualizer.statistical;

import java.util.concurrent.ConcurrentHashMap;

import org.powertac.common.CustomerInfo;
import org.powertac.common.TariffSpecification;
import org.powertac.common.TariffTransaction;
import org.powertac.visualizer.Helper;
import org.powertac.visualizer.domain.broker.BrokerModel;
import org.powertac.visualizer.domain.broker.CustomerTariffData;
import org.powertac.visualizer.domain.broker.TariffData;
import org.powertac.visualizer.domain.broker.TariffDynamicData;

/**
 * This performance category holds tariff related info for one broker.
 * 
 * @author <NAME>
 * 
 */
public class TariffCategory extends AbstractPerformanceCategory implements
		PerformanceCategory {

	private int customerCount;
	private TariffDynamicData lastTariffDynamicData;

	// key: postedTime
	private ConcurrentHashMap<Integer, TariffDynamicData> tariffDynamicDataMap;
	private ConcurrentHashMap<CustomerInfo, CustomerTariffData> customerTariffData;
	private ConcurrentHashMap<TariffSpecification, TariffData> tariffData;

	public TariffCategory(BrokerModel broker) {
		super(broker);
		lastTariffDynamicData = new TariffDynamicData(0, 0, 0, 0);
		tariffDynamicDataMap = new ConcurrentHashMap<Integer, TariffDynamicData>(
				1000, 0.75f, 1);
		customerTariffData = new ConcurrentHashMap<CustomerInfo, CustomerTariffData>(
				20, 0.75f, 1);
		tariffData = new ConcurrentHashMap<TariffSpecification, TariffData>(20,
				0.75f, 1);
	}

	public void processTariffSpecification(TariffSpecification ts) {
		tariffData.putIfAbsent(ts, new TariffData(ts, this.getBroker()));
	}

	public int getCustomerCount() {
		return customerCount;
	}

	public ConcurrentHashMap<Integer, TariffDynamicData> getTariffDynamicDataMap() {
		return tariffDynamicDataMap;
	}

	/**
	 * @return Info about broker's transactions related to one customer model.
	 */
	public ConcurrentHashMap<CustomerInfo, CustomerTariffData> getCustomerTariffData() {
		return customerTariffData;
	}

	/**
	 * @return Info about broker's tariff related to one customer model.
	 */
	public ConcurrentHashMap<TariffSpecification, TariffData> getTariffData() {
		return tariffData;
	}

	public void update(int tsIndex, double energy, double cash,
			int customerDelta) {
		customerCount += customerDelta;
		tariffDynamicDataMap.get(tsIndex).update(
				cash, energy, customerDelta);
		update(tsIndex,energy, cash);
	}

	public void addTariffDynamicData(TariffDynamicData tdd) {
		lastTariffDynamicData = tdd;
		tariffDynamicDataMap.put(tdd.getDynamicData().getTsIndex(), tdd);

	}

	public TariffDynamicData getLastTariffDynamicData() {
		return lastTariffDynamicData;
	}

}

{'fraction_non_alphanumeric': 0.08753957906500279, 'fraction_numerical': 0.008940212330042838, 'mean_word_length': 6.047244094488189, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1891489', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1670, 'n_words': 345}