private static IntPair pickFirstTwo(Matrix dataPoints,
SimilarityFunction simFunc,
int[] weights, double[] inverseSimilarities) {
double OPT_1 = 0; // optimal 1-means cost.
DoubleVector centerOfMass = new DenseVector(dataPoints.columns());
double sum = 0d;
int rows = dataPoints.rows();
int cols = dataPoints.columns();
double[] probs = new double[rows];
int totalWeight = 0;
for (int i = 0; i < rows; i++) {
DoubleVector v = dataPoints.getRowVector(i);
int weight = weights[i];
// Update the center of mass for the entire solution based
VectorMath.add(centerOfMass, new ScaledDoubleVector(v, weight));
totalWeight += weight;
}
// Then rescale the center of mass based on the total weight
for (int j = 0; j < cols; j++)
centerOfMass.set(j, centerOfMass.get(j) / totalWeight);
for (int i = 0; i < rows; i++) {
double sim = simFunc.sim(centerOfMass, dataPoints.getRowVector(i));
sim = invertSim(sim);