List of usage examples for java.util Arrays fill
public static void fill(Object[] a, Object val)
From source file:edu.utexas.cs.tactex.tariffoptimization.OptimizerWrapperApacheBOBYQA.java
@Override public TreeMap<Double, TariffSpecification> findOptimum(TariffUtilityEstimate tariffUtilityEstimate, int NUM_RATES, int numEval) { double[] startingVertex = new double[NUM_RATES]; // start from the fixed-rate tariff's offset Arrays.fill(startingVertex, 0.0); //Arrays.fill(startingVertex, 0.5 * INITIAL_TRUST_REGION_RADIUS); //Arrays.fill(startingVertex, 1 * INITIAL_TRUST_REGION_RADIUS); final int numIterpolationPoints = 2 * NUM_RATES + 1; // BOBYQA recommends 2n+1 points BOBYQAOptimizer optimizer = new BOBYQAOptimizer(numIterpolationPoints, INITIAL_TRUST_REGION_RADIUS, STOPPING_TRUST_REGION_RADIUS); // needed since one optimization found positive // charges (paying customer to consume...) double[][] boundaries = createBoundaries(NUM_RATES); final PointValuePair optimum = optimizer.optimize(new MaxEval(numEval), new ObjectiveFunction(new OptimizerWrapperApacheObjective(tariffUtilityEstimate)), GoalType.MAXIMIZE, new InitialGuess(startingVertex), //new SimpleBounds(boundaries[0], boundaries[1])); SimpleBounds.unbounded(NUM_RATES)); TreeMap<Double, TariffSpecification> eval2TOUTariff = new TreeMap<Double, TariffSpecification>(); eval2TOUTariff.put(optimum.getValue(), tariffUtilityEstimate.getCorrespondingSpec(optimum.getKey())); return eval2TOUTariff; }
From source file:de.qaware.chronix.solr.query.analysis.functions.transformation.Vectorization.java
/** * Todo: Describe the algorithm, a bit.// w w w . ja va2 s.c o m * <p> * Note: The transformation changes the values of the time series! * Further analyses such as aggregations uses the transformed values for the calculation. * * @param timeSeries the time series that is transformed */ @Override public void transform(MetricTimeSeries timeSeries) { //we need a sorted time series timeSeries.sort(); int size = timeSeries.size(); //do not simplify if there are insufficient data points if (size <= 3) { return; } byte[] usePoint = new byte[size]; Arrays.fill(usePoint, (byte) 1); long[] rawTimeStamps = timeSeries.getTimestampsAsArray(); double[] rawValues = timeSeries.getValuesAsArray(); //Clear the original time series timeSeries.clear(); compute(rawTimeStamps, rawValues, usePoint, tolerance); for (int i = 0; i < size; i++) { if (usePoint[i] == 1) { timeSeries.add(rawTimeStamps[i], rawValues[i]); } } }
From source file:br.ufc.mdcc.mpos.net.profile.PersistenceTcpServer.java
@Override public void clientRequest(Socket connection) throws IOException { OutputStream output = connection.getOutputStream(); InputStream input = connection.getInputStream(); byte tempBuffer[] = new byte[1024 * 4]; while (input.read(tempBuffer) != -1) { String data = new String(tempBuffer); if (data != null && data.contains("date")) { persistence(data, connection.getInetAddress().toString()); String resp = "ok"; output.write(resp.getBytes(), 0, resp.length()); output.flush();// w w w . ja va 2 s . co m } Arrays.fill(tempBuffer, (byte) 0); } close(input); close(output); }
From source file:org.smigo.log.JdbcLogDao.java
@Override public void log(Log req) { String sql = "INSERT INTO visitlog (sessionage,httpstatus,username,requestedurl,locales,useragent,referer,sessionid,method,xforwardedfor,host,querystring) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"; Object[] args = { req.getSessionAge(), req.getHttpStatus(), req.getRemoteUser(), req.getUrl(), req.getLocales(), req.getUseragent(), req.getReferer(), req.getSessionid(), req.getMethod(), req.getIp(), req.getHost(), req.getQueryString() }; int[] types = new int[args.length]; Arrays.fill(types, Types.VARCHAR); types[0] = Types.INTEGER;/* w ww . j av a2s . co m*/ types[1] = Types.INTEGER; jdbcTemplate.update(sql, args, types); }
From source file:de.qaware.chronix.solr.type.metric.functions.transformation.Vectorization.java
/** * Todo: Describe the algorithm, a bit./*from w ww . jav a2 s . c o m*/ * <p> * Note: The transformation changes the values of the time series! * Further analyses such as aggregations uses the transformed values for the calculation. * * @param timeSeries the time series that is transformed */ @Override public void execute(MetricTimeSeries timeSeries, FunctionValueMap functionValueMap) { //we need a sorted time series timeSeries.sort(); int size = timeSeries.size(); //do not simplify if there are insufficient data points if (size <= 3) { return; } byte[] usePoint = new byte[size]; Arrays.fill(usePoint, (byte) 1); long[] rawTimeStamps = timeSeries.getTimestampsAsArray(); double[] rawValues = timeSeries.getValuesAsArray(); //Clear the original time series timeSeries.clear(); compute(rawTimeStamps, rawValues, usePoint, tolerance); for (int i = 0; i < size; i++) { if (usePoint[i] == 1) { timeSeries.add(rawTimeStamps[i], rawValues[i]); } } functionValueMap.add(this); }
From source file:kieker.tools.opad.timeseries.forecast.mean.MeanForecasterJava.java
/** * @param numForecastSteps/*from w w w. ja va 2s .c om*/ * number of values the forecaster is going to forecast * * @return Forecast Result */ @Override public IForecastResult forecast(final int numForecastSteps) { final ITimeSeries<Double> history = this.getTsOriginal(); final ITimeSeries<Double> tsFC = this.prepareForecastTS(); final List<Double> allHistory = new ArrayList<Double>(history.getValues()); final Double[] histValuesNotNull = MeanForecasterJava.removeNullValues(allHistory); final double mean = StatUtils.mean(ArrayUtils.toPrimitive(histValuesNotNull)); final Double[] forecastValues = new Double[numForecastSteps]; Arrays.fill(forecastValues, mean); tsFC.appendAll(forecastValues); return new ForecastResult(tsFC, this.getTsOriginal(), ForecastMethod.MEAN); }
From source file:org.zkybase.cmdb.connector.impl.ApplicationTemplateTestCase.java
private void setUpTestObjects() { this.applications = new Application[NUM_APPS]; Arrays.fill(applications, application); this.locations = asList(SOME_LOCATION); }
From source file:com.analog.lyric.dimple.solvers.core.parameterizedMessages.DirichletParameters.java
public DirichletParameters(int length, double alphaMinusOne) { _alphaMinusOne = new double[length]; Arrays.fill(_alphaMinusOne, alphaMinusOne); _symmetric = 1;/*from www . java 2s . com*/ }
From source file:hivemall.io.SpaceEfficientDenseModel.java
public SpaceEfficientDenseModel(int ndims, boolean withCovar) { super();/*from w ww .ja va2 s. co m*/ int size = ndims + 1; this.size = size; this.weights = new short[size]; if (withCovar) { short[] covars = new short[size]; Arrays.fill(covars, HalfFloat.ONE); this.covars = covars; } else { this.covars = null; } this.sum_of_squared_gradients = null; this.sum_of_squared_delta_x = null; this.sum_of_gradients = null; this.clocks = null; this.deltaUpdates = null; }
From source file:com.acciente.oacc.sql.internal.StrongCleanablePasswordEncryptor.java
private byte[] getCleanedBytes(char[] password) { final ByteBuffer byteBuffer = StandardCharsets.UTF_8 .encode(CharBuffer.wrap(Normalizer.normalizeToNfc(password))); final byte[] byteArray = new byte[byteBuffer.remaining()]; byteBuffer.get(byteArray);/*from ww w. j av a 2s. c om*/ Arrays.fill(byteBuffer.array(), (byte) 0); return byteArray; }