PowerVmSelectionPolicyMaximumCorrelation extends PowerVmSelectionPolicy { protected List<Double> getCorrelationCoefficients(final double[][] data) { int n = data.length; int m = data[0].length; List<Double> correlationCoefficients = new LinkedList<Double>(); for (int i = 0; i < n; i++) { double[][] x = new double[n - 1][m]; int k = 0; for (int j = 0; j < n; j++) { if (j != i) { x[k++] = data[j]; } } double[][] xT = new Array2DRowRealMatrix(x).transpose().getData(); correlationCoefficients.add(MathUtil.createLinearRegression(xT, data[i]).calculateRSquared()); } return correlationCoefficients; } PowerVmSelectionPolicyMaximumCorrelation(final PowerVmSelectionPolicy fallbackPolicy); @Override Vm getVmToMigrate(final PowerHost host); PowerVmSelectionPolicy getFallbackPolicy(); void setFallbackPolicy(final PowerVmSelectionPolicy fallbackPolicy);  }
@Test public void testGetPowerModel() { List<Double> result = vmSelectionPolicyMaximumCorrelation.getCorrelationCoefficients(DATA); for (int i = 0; i < result.size(); i++) { assertEquals(CORRELATION[i], result.get(i), 0.00001); } }