public UnemploymentBasedWageAskAlgorithm( double initialLabourWage, double wageAdaptationRate, double minimumWage, EmploymentProportionCallback employmentProportionCallback ) { super(initGuard(initialLabourWage)); if(employmentProportionCallback == null) throw new NullArgumentException(); this.wagePerturbation = wageAdaptationRate * initialLabourWage; this.dice = new Random( Simulation.getSimState().random.nextLong()); this.employmentPropCallback = employmentProportionCallback; this.wageConfidence = new CircularFifoBuffer<Double>(5); this.minimumWage = minimumWage; wageConfidence.add(0.0); }
public GenericTALibAggregatorFunction(Method function, int inputParamCount, int lookbackPeriod, List<Object> optInputParams, Map<String, Object> outputParams, Class<?> outputClass) { super(); this.function = function; this.outputClass = outputClass; this.optInputParams = optInputParams; this.outputParams = outputParams; this.inputParams = new ArrayList<CircularFifoBuffer<Number>>(); for (int i = 0; i < inputParamCount; i++) { this.inputParams.add(new CircularFifoBuffer<Number>(lookbackPeriod)); } }
public void enableHistoryTracking() { if (this.history == null) { synchronized (this) { if (this.history == null) { this.history = new CircularFifoBuffer<Long>(10000); } } // SYNCH if (debug.val) LOG.debug("Enabled history tracking in " + this); } }
/** * Create a {@link MedianOverHistoryStockReturnExpectationFunction} * object with a custom memory length (as specified by the argument). * * @param The {@link StockReturnExpectationFunction} to which to * apply the moving median. * @param sizeOfMemory * The length of the circular buffer over which to compute * moving median returns. This argument should be strictly * positive. */ @Inject public MedianOverHistoryStockReturnExpectationFunction( @Named("MEDIAN_OVER_HISTORY_PRIMITIVE_STOCK_RETURN_EXPECTATION_FUNCTION") StockReturnExpectationFunction expectationFunction, @Named("MEDIAN_OVER_HISTORY_STOCK_RETURN_EXPECTATION_FUNCTION_MEMORY_LENGTH") final int sizeOfMemory ) { Preconditions.checkNotNull(expectationFunction); Preconditions.checkArgument(sizeOfMemory > 0); this.expectationFunction = expectationFunction; this.memory = new HashMap<String, CircularFifoBuffer<Double>>(); this.sizeOfMemory = sizeOfMemory; }
@Override public double computeExpectedReturn(final String stockName) { if(!memory.containsKey(stockName)) memory.put( stockName, new CircularFifoBuffer<Double>(sizeOfMemory) ); final double returnEstimate = expectationFunction.computeExpectedReturn(stockName); memory.get(stockName).add(returnEstimate); return medianOfSeries( ArrayUtils.asDouble(memory.get(stockName).toArray(new Double[0])) ); }
public GenericTALibFunction() { super(); this.inputParamCount = 0; this.inputParams = new ArrayList<CircularFifoBuffer<Number>>(); this.optInputParams = new ArrayList<Object>(); this.outputParams = new HashMap<String, Object>(); }
@Override public void enter(Object obj) { Object[] params = (Object[]) obj; // add all inputs to the correct buffers int paramCount = 1; for (CircularFifoBuffer<Number> buffer : this.inputParams) { Number value = (Number) params[paramCount]; buffer.add(value); paramCount++; } }
@Override public void leave(Object obj) { // Remove the last element of each buffer for (CircularFifoBuffer<Number> buffer : this.inputParams) { if (buffer.contains(obj)) { buffer.remove(obj); } } }
@Override public void clear() { // clear all elements from the buffers for (CircularFifoBuffer<Number> buffer : this.inputParams) { buffer.clear(); } }
public ProfiSounderLogAppender(int logBufferSize) { if (logBufferSize < 1 || logBufferSize > MAX_BUFFERSIZE) throw new IllegalArgumentException("logBufferSize must be between 1 and " + MAX_BUFFERSIZE + "!"); PersistentNotifications.setConsumer(this); logBuffer = new CircularFifoBuffer<>(logBufferSize); }
public EmpiricalDistribution(int memoryLength) { m_dataStream = new CircularFifoBuffer<Double>(memoryLength); m_sortedData = new TreeSet<EmpiricalDistribution.SortedDatum>(); lastValueInserted = Double.NaN; }