List of usage examples for java.lang Double POSITIVE_INFINITY
double POSITIVE_INFINITY
To view the source code for java.lang Double POSITIVE_INFINITY.
Click Source Link
From source file:org.jfree.experimental.chart.renderer.xy.VectorRenderer.java
/** * Returns the range of values the renderer requires to display all the * items from the specified dataset./*from w w w.j av a2 s . c o m*/ * * @param dataset the dataset (<code>null</code> permitted). * * @return The range (<code>null</code> if the dataset is <code>null</code> * or empty). */ public Range findRangeBounds(XYDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); double lvalue; double uvalue; if (dataset instanceof VectorXYDataset) { VectorXYDataset vdataset = (VectorXYDataset) dataset; for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double delta = vdataset.getDeltaYValue(series, item); if (delta < 0.0) { uvalue = vdataset.getYValue(series, item); lvalue = uvalue + delta; } else { lvalue = vdataset.getYValue(series, item); uvalue = lvalue + delta; } minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, uvalue); } } } else { for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { lvalue = dataset.getYValue(series, item); uvalue = lvalue; minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, uvalue); } } } if (minimum > maximum) { return null; } else { return new Range(minimum, maximum); } }
From source file:com.rapidminer.gui.plotter.charts.BubbleChartPlotter.java
private void prepareNumericalData() { DataTable dataTable = getDataTable(); this.nominal = false; xyzDataSet = new DefaultXYZDataset(); if (axis[X_AXIS] >= 0 && axis[Y_AXIS] >= 0 && axis[BUBBLE_SIZE_AXIS] >= 0) { this.bubbleSizeMin = Double.POSITIVE_INFINITY; this.bubbleSizeMax = Double.NEGATIVE_INFINITY; this.xAxisMin = Double.POSITIVE_INFINITY; this.xAxisMax = Double.NEGATIVE_INFINITY; this.yAxisMin = Double.POSITIVE_INFINITY; this.yAxisMax = Double.NEGATIVE_INFINITY; this.minColor = Double.POSITIVE_INFINITY; this.maxColor = Double.NEGATIVE_INFINITY; List<double[]> dataList = new LinkedList<>(); synchronized (dataTable) { Iterator<DataTableRow> i = dataTable.iterator(); while (i.hasNext()) { DataTableRow row = i.next(); double xValue = row.getValue(axis[X_AXIS]); double yValue = row.getValue(axis[Y_AXIS]); double bubbleSizeValue = row.getValue(axis[BUBBLE_SIZE_AXIS]); double colorValue = Double.NaN; if (colorColumn >= 0) { colorValue = row.getValue(colorColumn); }/*from w ww . ja va 2s . c om*/ if (!Double.isNaN(xValue) && !Double.isNaN(yValue) && !Double.isNaN(bubbleSizeValue)) { double[] data = new double[4]; data[X_AXIS] = xValue; data[Y_AXIS] = yValue; data[BUBBLE_SIZE_AXIS] = bubbleSizeValue; data[3] = colorValue; this.bubbleSizeMin = MathFunctions.robustMin(this.bubbleSizeMin, bubbleSizeValue); this.bubbleSizeMax = MathFunctions.robustMax(this.bubbleSizeMax, bubbleSizeValue); this.xAxisMin = MathFunctions.robustMin(this.xAxisMin, xValue); this.yAxisMin = MathFunctions.robustMin(this.yAxisMin, yValue); this.xAxisMax = MathFunctions.robustMax(this.xAxisMax, xValue); this.yAxisMax = MathFunctions.robustMax(this.yAxisMax, yValue); this.minColor = MathFunctions.robustMin(this.minColor, colorValue); this.maxColor = MathFunctions.robustMax(this.maxColor, colorValue); dataList.add(data); } } } double[][] data = new double[3][dataList.size()]; this.colors = new double[dataList.size()]; int index = 0; double scaleFactor = Math.min(this.xAxisMax - this.xAxisMin, this.yAxisMax - this.yAxisMin) / 4.0d; for (double[] d : dataList) { data[X_AXIS][index] = d[X_AXIS]; data[Y_AXIS][index] = d[Y_AXIS]; data[BUBBLE_SIZE_AXIS][index] = ((d[BUBBLE_SIZE_AXIS] - bubbleSizeMin) / (bubbleSizeMax - bubbleSizeMin) + 0.1) * scaleFactor; this.colors[index] = d[3]; index++; } xyzDataSet.addSeries("All", data); } }
From source file:com.fay.statics.SummaryStat.java
public void clear() { valSum = sumSquare = 0.0d; numObs = 0; weightSum = 0.0d; min = Double.POSITIVE_INFINITY; max = Double.NEGATIVE_INFINITY; }
From source file:com.opengamma.analytics.financial.model.finitedifference.PeacemanRachfordFiniteDifference2D.java
@Override public double[][] solve(final ConvectionDiffusion2DPDEDataBundle pdeData, final int tSteps, final int xSteps, final int ySteps, final double tMax, final BoundaryCondition2D xLowerBoundary, final BoundaryCondition2D xUpperBoundary, final BoundaryCondition2D yLowerBoundary, final BoundaryCondition2D yUpperBoundary, final Cube<Double, Double, Double, Double> freeBoundary) { final double dt = tMax / (tSteps); final double dx = (xUpperBoundary.getLevel() - xLowerBoundary.getLevel()) / (xSteps); final double dy = (yUpperBoundary.getLevel() - yLowerBoundary.getLevel()) / (ySteps); final double dtdx2 = dt / dx / dx; final double dtdx = dt / dx; final double dtdy2 = dt / dy / dy; final double dtdy = dt / dy; final double[][] v = new double[xSteps + 1][ySteps + 1]; final double[][] vRight = new double[xSteps + 1][ySteps + 1]; final double[] x = new double[xSteps + 1]; final double[] y = new double[ySteps + 1]; final double[] q = new double[xSteps + 1]; final double[] r = new double[ySteps + 1]; final double[][] mx = new double[xSteps + 1][xSteps + 1]; final double[][] my = new double[ySteps + 1][ySteps + 1]; double currentX = 0; double currentY = 0; for (int j = 0; j <= ySteps; j++) { currentY = yLowerBoundary.getLevel() + j * dy; y[j] = currentY;//from www . j a v a2 s . c o m } for (int i = 0; i <= xSteps; i++) { currentX = xLowerBoundary.getLevel() + i * dx; x[i] = currentX; for (int j = 0; j <= ySteps; j++) { v[i][j] = pdeData.getInitialValue(x[i], y[j]); } } double t = 0.0; double a, b, c, d, f; for (int n = 0; n < tSteps; n++) { // t += dt / 2; // stag 1 Explicit in y, implicit in x for (int i = 1; i < xSteps; i++) { for (int j = 1; j < ySteps; j++) { c = pdeData.getC(t, x[i], y[j]); d = pdeData.getD(t, x[i], y[j]); f = pdeData.getF(t, x[i], y[j]); vRight[i][j] = (1 - 0.25 * dt * c) * v[i][j]; vRight[i][j] -= 0.5 * dtdy2 * d * (v[i][j + 1] + v[i][j - 1] - 2 * v[i][j]); vRight[i][j] -= 0.25 * dtdy * f * (v[i][j + 1] - v[i][j - 1]); } } t += dt / 2; for (int j = 1; j < ySteps; j++) { for (int i = 1; i < xSteps; i++) { a = pdeData.getA(t, x[i], y[j]); b = pdeData.getB(t, x[i], y[j]); c = pdeData.getC(t, x[i], y[j]); mx[i][i - 1] = 0.5 * (dtdx2 * a - 0.5 * dtdx * b); mx[i][i] = 1 + 0.5 * (-2 * dtdx2 * a + 0.5 * dt * c); mx[i][i + 1] = 0.5 * (dtdx2 * a + 0.5 * dtdx * b); q[i] = vRight[i][j]; } double[] temp = xLowerBoundary.getLeftMatrixCondition(t, y[j]); for (int k = 0; k < temp.length; k++) { mx[0][k] = temp[k]; } temp = xUpperBoundary.getLeftMatrixCondition(t, y[j]); for (int k = 0; k < temp.length; k++) { mx[xSteps][xSteps - k] = temp[k]; } temp = xLowerBoundary.getRightMatrixCondition(t, y[j]); double sum = 0; for (int k = 0; k < temp.length; k++) { sum += temp[k] * v[k][j]; } q[0] = sum + xLowerBoundary.getConstant(t, y[j], dx); temp = xUpperBoundary.getRightMatrixCondition(t, y[j]); sum = 0; for (int k = 0; k < temp.length; k++) { sum += temp[k] * v[xSteps - k][j]; } q[xSteps] = sum + xUpperBoundary.getConstant(t, y[j], dx); // SOR final double omega = 1.5; double scale = 1.0; double errorSqr = Double.POSITIVE_INFINITY; int min, max; int count = 0; while (errorSqr / (scale + 1e-10) > 1e-18 && count < 1000) { errorSqr = 0.0; scale = 0.0; for (int l = 0; l <= xSteps; l++) { min = (l == xSteps ? 0 : Math.max(0, l - 1)); max = (l == 0 ? xSteps : Math.min(xSteps, l + 1)); sum = 0; // for (int k = 0; k <= xSteps; k++) { for (int k = min; k <= max; k++) { // mx is tri-diagonal so only need 3 steps here sum += mx[l][k] * v[k][j]; } final double correction = omega / mx[l][l] * (q[l] - sum); // if (freeBoundary != null) { // correction = Math.max(correction, freeBoundary.getZValue(t, x[j]) - f[j]); // } errorSqr += correction * correction; v[l][j] += correction; scale += v[l][j] * v[l][j]; } count++; } Validate.isTrue(count < 1000, "SOR exceeded max interations"); } // get the y = 0 and y = yStep boundaries for (int i = 0; i <= xSteps; i++) { double[] temp = yLowerBoundary.getRightMatrixCondition(t, x[i]); double sum = 0; for (int k = 0; k < temp.length; k++) { sum += temp[k] * v[i][k]; // TODO this should be vold } sum += yLowerBoundary.getConstant(t, x[i], dy); temp = yLowerBoundary.getLeftMatrixCondition(t, x[i]); for (int k = 1; k < temp.length; k++) { sum -= temp[k] * v[i][k]; } v[i][0] = sum / temp[0]; temp = yUpperBoundary.getRightMatrixCondition(t, x[i]); sum = 0; for (int k = 0; k < temp.length; k++) { sum += temp[k] * v[i][ySteps - k]; } sum += yUpperBoundary.getConstant(t, x[i], dy); temp = yUpperBoundary.getLeftMatrixCondition(t, x[i]); for (int k = 1; k < temp.length; k++) { sum -= temp[k] * v[i][ySteps - k]; } v[i][ySteps] = sum / temp[0]; } // // copy the boundary points from the previous level // for (int i = 0; i <= xSteps; i++) { // vStar[i][0] = v[i][0]; // vStar[i][ySteps] = v[i][ySteps]; // } // stag 2 explicit in x, implicit in y for (int j = 1; j < ySteps; j++) { for (int i = 1; i < xSteps; i++) { a = pdeData.getA(t, x[i], y[j]); b = pdeData.getB(t, x[i], y[j]); c = pdeData.getC(t, x[i], y[j]); vRight[i][j] = (1 - 0.25 * dt * c) * v[i][j]; vRight[i][j] -= 0.5 * dtdx2 * a * (v[i + 1][j] + v[i - 1][j] - 2 * v[i][j]); vRight[i][j] -= 0.25 * dtdx * b * (v[i + 1][j] - v[i - 1][j]); } } t += dt / 2; for (int i = 1; i < xSteps; i++) { for (int j = 1; j < ySteps; j++) { c = pdeData.getC(t, x[i], y[j]); d = pdeData.getD(t, x[i], y[j]); f = pdeData.getF(t, x[i], y[j]); my[j][j - 1] = 0.5 * (dtdy2 * d - 0.5 * dtdy * f); my[j][j] = 1 + 0.5 * (-2 * dtdy2 * d + 0.5 * dt * c); my[j][j + 1] = 0.5 * (dtdy2 * d + 0.5 * dtdy * f); r[j] = vRight[i][j]; } double[] temp = yLowerBoundary.getLeftMatrixCondition(t, x[i]); for (int k = 0; k < temp.length; k++) { my[0][k] = temp[k]; } temp = yUpperBoundary.getLeftMatrixCondition(t, x[i]); for (int k = 0; k < temp.length; k++) { my[ySteps][ySteps - k] = temp[k]; } temp = yLowerBoundary.getRightMatrixCondition(t, x[i]); double sum = 0; for (int k = 0; k < temp.length; k++) { sum += temp[k] * v[i][k]; } r[0] = sum + yLowerBoundary.getConstant(t, x[i], dy); temp = yUpperBoundary.getRightMatrixCondition(t, x[i]); sum = 0; for (int k = 0; k < temp.length; k++) { sum += temp[k] * v[i][ySteps - k]; } r[ySteps] = sum + yUpperBoundary.getConstant(t, x[i], dy); // SOR final double omega = 1.5; double scale = 1.0; double errorSqr = Double.POSITIVE_INFINITY; int count = 0; while (errorSqr / (scale + 1e-10) > 1e-18 && count < 1000) { errorSqr = 0.0; scale = 0.0; int min, max; for (int l = 0; l <= ySteps; l++) { min = (l == ySteps ? 0 : Math.max(0, l - 1)); max = (l == 0 ? ySteps : Math.min(ySteps, l + 1)); sum = 0; // for (int k = 0; k <= ySteps; k++) { for (int k = min; k <= max; k++) { sum += my[l][k] * v[i][k]; } final double correction = omega / my[l][l] * (r[l] - sum); // if (freeBoundary != null) { // correction = Math.max(correction, freeBoundary.getZValue(t, x[j]) - f[j]); // } errorSqr += correction * correction; v[i][l] += correction; scale += v[i][l] * v[i][l]; } count++; } Validate.isTrue(count < 1000, "SOR exceeded max interations"); } // still have to handle the i = 0 and i = xSteps boundary for (int j = 0; j <= ySteps; j++) { double[] temp = xLowerBoundary.getRightMatrixCondition(t, y[j]); double sum = 0; for (int k = 0; k < temp.length; k++) { sum += temp[k] * v[k][j]; // TODO this should be vold } sum += xLowerBoundary.getConstant(t, y[j], dx); temp = xLowerBoundary.getLeftMatrixCondition(t, y[j]); for (int k = 1; k < temp.length; k++) { sum -= temp[k] * v[k][j]; } v[0][j] = sum / temp[0]; temp = xUpperBoundary.getRightMatrixCondition(t, y[j]); sum = 0; for (int k = 0; k < temp.length; k++) { sum += temp[k] * v[xSteps - k][j]; } sum += xUpperBoundary.getConstant(t, y[j], dx); temp = xUpperBoundary.getLeftMatrixCondition(t, y[j]); for (int k = 1; k < temp.length; k++) { sum -= temp[k] * v[xSteps - k][j]; } v[xSteps][j] = sum / temp[0]; } } // time loop return v; }
From source file:de.bund.bfr.knime.nls.chart.ChartCreator.java
public JFreeChart createChart() throws ParseException { if (varX == null || varY == null) { return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, new XYPlot(), showLegend); }// w w w. j a v a 2s. c om List<String> idsToPaint; if (selectAll) { idsToPaint = new ArrayList<>(plotables.keySet()); } else { idsToPaint = selectedIds; } NumberAxis xAxis = new NumberAxis(transformX.getName(varX)); NumberAxis yAxis = new NumberAxis(transformY.getName(varY)); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); double usedMinX = Double.POSITIVE_INFINITY; double usedMaxX = Double.NEGATIVE_INFINITY; int index = 0; List<Color> defaultColors = ChartUtils.createColorList(idsToPaint.size()); List<NamedShape> defaultShapes = ChartUtils.createShapeList(idsToPaint.size()); for (String id : idsToPaint) { Plotable plotable = plotables.get(id); if (plotable == null) { continue; } if (plotable.isDataType()) { double[][] points = plotable.getDataPoints(varX, varY, transformX, transformY); if (points != null) { for (int i = 0; i < points[0].length; i++) { usedMinX = Math.min(usedMinX, points[0][i]); usedMaxX = Math.max(usedMaxX, points[0][i]); } } } if (plotable.isParamType()) { double minArg = transformX.to(MathUtils.nullToNan(plotable.getMinValues().get(varX))); double maxArg = transformX.to(MathUtils.nullToNan(plotable.getMaxValues().get(varX))); if (Double.isFinite(minArg)) { usedMinX = Math.min(usedMinX, minArg); } if (Double.isFinite(maxArg)) { usedMaxX = Math.max(usedMaxX, maxArg); } } } if (!Double.isFinite(usedMinX)) { usedMinX = 0.0; } if (!Double.isFinite(usedMaxX)) { usedMaxX = 100.0; } xAxis.setAutoRangeIncludesZero(false); yAxis.setAutoRangeIncludesZero(false); if (usedMinX == usedMaxX) { usedMinX -= 1.0; usedMaxX += 1.0; } if (useManualRange && minX < maxX && minY < maxY) { usedMinX = minX; usedMaxX = maxX; xAxis.setRange(new Range(minX, maxX)); yAxis.setRange(new Range(minY, maxY)); } for (String id : idsToPaint) { Plotable plotable = plotables.get(id); if (plotable == null) { continue; } plotable.setFunctionSteps(resolution); plotable.setInterpolator(interpolator); switch (plotable.getType()) { case DATA: plotData(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index)); break; case FUNCTION: plotFunction(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; case DATA_FUNCTION: plotDataFunction(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; case DIFF: plotDiff(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; case DATA_DIFF: plotDataDiff(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; default: throw new RuntimeException("Unknown type of plotable: " + plotable.getType()); } index++; } if (minToZero && !useManualRange) { Range xRange = xAxis.getRange(); Range yRange = yAxis.getRange(); if (xRange.getUpperBound() <= 0.0 || yRange.getUpperBound() <= 0.0) { return null; } xAxis.setRange(new Range(0.0, xRange.getUpperBound())); yAxis.setRange(new Range(0.0, yRange.getUpperBound())); } return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend); }
From source file:eu.cassandra.utils.Utils.java
/** * This function is used for the detection of reduction points following a * rising point, so that there is a possibility they can be connected as a * pair//from w w w . j a v a 2 s .co m * * @param index * The index of the rising point of interest. * @param pois * The list of points of interest under examination. * @return an array of indices that contain possible combinatorial reduction * points of interest. */ public static Integer[] findRedPoints(int index, ArrayList<PointOfInterest> pois) { ArrayList<Integer> temp = new ArrayList<Integer>(); double limit = pairingLimit(pois.get(index).getPDiff()); double timeLimit = Double.POSITIVE_INFINITY; if (Constants.SIMPLE_TIME_COMPLEXITY == true) timeLimit = pois.get(index).getMinute() + Constants.TEMPORAL_THRESHOLD; for (int i = index + 1; i < pois.size(); i++) if (pois.get(i).getRising() == false && pois.get(i).getMinute() <= timeLimit && limit > -pois.get(i).getPDiff()) temp.add(i); Integer[] result = new Integer[temp.size()]; for (int i = 0; i < temp.size(); i++) result[i] = temp.get(i); return result; }
From source file:master.model.Model.java
public double getNextReactionChangeTime(double t) { int idx;//from www. ja v a 2 s . com for (idx = 0; idx < getReactionChangeTimes().size(); idx++) { if (getReactionChangeTimes().get(idx) > t) break; } if (idx == getReactionChangeTimes().size()) return Double.POSITIVE_INFINITY; return getReactionChangeTimes().get(idx); }
From source file:net.sourceforge.jabm.learning.QLearner.java
public int worstAction(int state) { int result = 0; double min = Double.POSITIVE_INFINITY; for (int a = 0; a < numActions; a++) { if (q[state][a] > min) { min = q[state][a];//w w w . j a va2s .com } } return result; }
From source file:egat.replicatordynamics.SymmetricConstrainedAmoebaSearch.java
public Strategy run(SymmetricGame game, Strategy initialStrategy, Set<Action> restrictedActions, boolean randomize) { Action[] actions = game.getActions().toArray(new Action[0]); boolean[] mask = new boolean[actions.length]; int restrictedCount = 0; for (int i = 0; i < actions.length; i++) { mask[i] = restrictedActions.contains(actions[i]); if (mask[i]) { restrictedCount++;/* w ww . j av a2 s . co m*/ } } int[] restricted = new int[restrictedCount]; for (int i = 0, restrictedIndex = 0; i < actions.length; i++) { if (mask[i]) { restricted[restrictedIndex++] = i; } } Player[] players = game.players().toArray(new Player[0]); PayoffMatrix pm = createPayoffMatrix(game, players, actions); // Normalize to a uniform distribution double[] distribution = new double[actions.length]; double[] bestDist = new double[actions.length]; if (initialStrategy == null) { double sum = 0.0; for (int i = 0; i < bestDist.length; i++) { if (mask[i]) { bestDist[i] = Math.random(); sum += bestDist[i]; } } for (int i = 0; i < bestDist.length; i++) { if (mask[i]) { bestDist[i] /= sum; } } } else { for (int i = 0; i < actions.length; i++) { if (mask[i]) { bestDist[i] = initialStrategy.getProbability(actions[i]).doubleValue(); } } } double bestRegret = pm.regret(bestDist); // Initialize current strategy Strategy currentStrategy = buildStrategy(actions, bestDist, restricted); fireUpdatedStrategy(currentStrategy, 0, Double.NaN); int SIMPLICES = restricted.length; double[][] X = new double[SIMPLICES][SIMPLICES - 1]; double[] centroid = new double[SIMPLICES - 1]; double[] reflect = new double[SIMPLICES - 1]; double[] expand = new double[SIMPLICES - 1]; double[] contract = new double[SIMPLICES - 1]; double[] V = new double[SIMPLICES]; double[] cur = distribution.clone(); if (!randomize) { for (int r = 0, n = SIMPLICES - 1; r < n; r++) { X[0][r] = 0.0; } V[0] = calculateObjective(pm, X[0], restricted, distribution); for (int s = 1; s < SIMPLICES; s++) { System.arraycopy(X[0], 0, X[s], 0, SIMPLICES - 1); X[s][s - 1] = 1.0; V[s] = calculateObjective(pm, X[s], restricted, distribution); } } else { for (int s = 0; s < SIMPLICES; s++) { generateSimplex(X[s]); V[s] = calculateObjective(pm, X[s], restricted, distribution); } } int highest = -1; int lowest = -1; int second = -1; for (int s = 0; s < SIMPLICES; s++) { if (lowest < 0 || V[s] < V[lowest]) { lowest = s; } if (second < 0 || V[s] > V[second]) { if (highest < 0 || V[s] > V[highest]) { second = highest; highest = s; } else { second = s; } } } double curRegret = Double.POSITIVE_INFINITY; loop: for (int iteration = 1; SIMPLICES > 1; iteration++) { generateCentroid(centroid, X, SIMPLICES, highest); generateTowards(reflect, centroid, X[highest], 1.0); double reflectV = calculateObjective(pm, reflect, restricted, distribution); // Reflect if (V[lowest] <= reflectV && reflectV < V[second]) { replaceHighest(reflect, reflectV, X, V, highest); // Expand } else if (reflectV < V[lowest]) { generateTowards(expand, centroid, X[highest], 2.0); double expandV = calculateObjective(pm, expand, restricted, distribution); if (expandV < reflectV) { replaceHighest(expand, expandV, X, V, highest); } else { replaceHighest(reflect, reflectV, X, V, highest); } // Contract } else { generateAway(contract, X[highest], centroid, 0.5); double contractV = calculateObjective(pm, contract, restricted, distribution); if (contractV < V[highest]) { replaceHighest(contract, contractV, X, V, highest); // Reduction } else { for (int s = 0; s < SIMPLICES; s++) { if (s != lowest) { generateAway(X[s], X[lowest], X[s], 0.5); V[s] = calculateObjective(pm, X[s], restricted, distribution); } } } } highest = -1; lowest = -1; second = -1; for (int s = 0; s < SIMPLICES; s++) { if (lowest < 0 || V[s] < V[lowest]) { lowest = s; } if (second < 0 || V[s] > V[second]) { if (highest < 0 || V[s] > V[highest]) { second = highest; highest = s; } else { second = s; } } } Arrays.fill(cur, 0.0); double sum = 0.0; for (int r = 0; r < restricted.length - 1; r++) { cur[restricted[r]] = Math.max(0, X[lowest][r]); sum += cur[restricted[r]]; } cur[restricted[restricted.length - 1]] = Math.max(0.0, 1 - sum); sum += cur[restricted[restricted.length - 1]]; for (int r = 0; r < restricted.length; r++) { cur[restricted[r]] /= sum; } curRegret = pm.regret(cur); if (curRegret < bestRegret) { System.arraycopy(cur, 0, bestDist, 0, cur.length); bestRegret = curRegret; } // Build the new strategy currentStrategy = buildStrategy(actions, bestDist, restricted); fireUpdatedStrategy(currentStrategy, iteration, bestRegret); // Calculate the norm double norm = V[highest] - V[lowest]; // Check termination condition if (terminate(norm, iteration)) break; } return currentStrategy; }
From source file:com.rapidminer.operator.preprocessing.discretization.MinMaxBinDiscretization.java
@Override public List<ParameterType> getParameterTypes() { List<ParameterType> types = super.getParameterTypes(); ParameterType type = new ParameterTypeInt(PARAMETER_NUMBER_OF_BINS, "Defines the number of bins which should be used for each attribute.", 2, Integer.MAX_VALUE, 2); type.setExpert(false);/*w ww .ja va 2 s . c o m*/ types.add(type); types.add(new ParameterTypeDouble(PARAMETER_MIN_VALUE, "The minimum value for the binning range.", Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false)); types.add(new ParameterTypeDouble(PARAMETER_MAX_VALUE, "The maximum value for the binning range.", Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false)); types.add(new ParameterTypeCategory(PARAMETER_RANGE_NAME_TYPE, "Indicates if long range names including the limits should be used.", DiscretizationModel.RANGE_NAME_TYPES, DiscretizationModel.RANGE_NAME_LONG)); type = new ParameterTypeBoolean(PARAMETER_AUTOMATIC_NUMBER_OF_DIGITS, "Indicates if the number of digits should be automatically determined for the range names.", true); type.registerDependencyCondition(new EqualTypeCondition(this, PARAMETER_RANGE_NAME_TYPE, DiscretizationModel.RANGE_NAME_TYPES, false, DiscretizationModel.RANGE_NAME_INTERVAL)); types.add(type); type = new ParameterTypeInt(PARAMETER_NUMBER_OF_DIGITS, "The minimum number of digits used for the interval names (-1: determine minimal number automatically).", -1, Integer.MAX_VALUE, -1); type.registerDependencyCondition( new BooleanParameterCondition(this, PARAMETER_AUTOMATIC_NUMBER_OF_DIGITS, false, false)); types.add(type); return types; }