<commit_before>package tlc2.tool.distributed.selector;

import tlc2.tool.distributed.TLCServer;
import tlc2.tool.distributed.TLCWorkerSmartProxy;
import tlc2.tool.distributed.TLCWorkerRMI;

public class StatisticalBlockSelector extends LimitingBlockSelector {

	/**
	 * Maximum total network overhead we are willing to take
	 */
	private final double networkOverheadLimit;

	/**
	 * @param aTLCServer
	 */
	public StatisticalBlockSelector(final TLCServer aTLCServer) {
		super(aTLCServer);
		this.networkOverheadLimit = 2.5 / 100d; 
	}

	/**
	 * @param size
	 *            The current size of the state queue.
	 * @return The intended block size
	 */
	protected int getBlockSize(final int size, final TLCWorkerRMI aWorker) {
		// has to be correct type and statistics have to be available
		if(aWorker instanceof TLCWorkerSmartProxy) {
			final TLCWorkerSmartProxy proxy = (TLCWorkerSmartProxy) aWorker;
			int blockSize = (int) Math.floor(size * (proxy.getNetworkOverhead() / networkOverheadLimit));
			return blockSize;
		}
		
		// default return value
		return super.getBlockSize(size, aWorker);
	}
}<commit_msg>RESOLVED - bug 171: Assign block size (=new states) dynamically  http://bugzilla.tlaplus.net/show_bug.cgi?id=171 - do not return 0 when state queue size is small<commit_after>package tlc2.tool.distributed.selector;

import tlc2.tool.distributed.TLCServer;
import tlc2.tool.distributed.TLCWorkerSmartProxy;
import tlc2.tool.distributed.TLCWorkerRMI;

public class StatisticalBlockSelector extends LimitingBlockSelector {

	/**
	 * Maximum total network overhead we are willing to take
	 */
	private final double networkOverheadLimit;

	/**
	 * @param aTLCServer
	 */
	public StatisticalBlockSelector(final TLCServer aTLCServer) {
		super(aTLCServer);
		this.networkOverheadLimit = 2.5 / 100d; 
	}

	/**
	 * @param size
	 *            The current size of the state queue.
	 * @return The intended block size
	 */
	protected int getBlockSize(final int size, final TLCWorkerRMI aWorker) {
		// has to be correct type and statistics have to be available
		if(aWorker instanceof TLCWorkerSmartProxy) {
			final TLCWorkerSmartProxy proxy = (TLCWorkerSmartProxy) aWorker;
			int blockSize = (int) Math.ceil(size * (proxy.getNetworkOverhead() / networkOverheadLimit));
			return blockSize;
		}
		
		// default return value
		return super.getBlockSize(size, aWorker);
	}
}
{'fraction_non_alphanumeric': 0.08624316365166176, 'fraction_numerical': 0.01051745898190997, 'mean_word_length': 4.180827886710239, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4557463', 'n_tokens_mistral': 799, 'n_tokens_neox': 697, 'n_words': 201}