Calculate facets rank

@param facets

@return
557608
@Override
    public Collection<FacetRank> calculateRank(@NotNull Collection<Facet> facets) {
        return rankingAlgorithm.calculate(facets);
    }
961651
public static <FACETTYPE extends Facet<?>> Set<Class<FACETTYPE>> getOptionalFacets(final Class<?> inspectedType)
   {
      return getRelatedFacets(inspectedType, FacetConstraintType.OPTIONAL);
   }
96901
private String buildFacetString(List<String> facetNames, List<String>facetValues ) {
		
		StringBuilder builder = new StringBuilder();

		if( facetNames != null && facetValues != null ) 
		{
			int pairsCount = -1;
			if( facetNames.size() != facetValues.size() ) {
				pairsCount = facetNames.size() > facetValues.size() ? facetValues.size() : facetNames.size();
				log.warn( "facetNames and facetValues lists were of different sizes, your query may not be accurate" );
			} else {
				pairsCount = facetNames.size();
			}
			for( int i=0; i < pairsCount; i++ ) {
				try {
					builder.append( "&facets[").append( facetNames.get( i )).append( "][]=" )
						.append( URLEncoder.encode( facetValues.get( i ), "UTF-8" ));
				} catch (UnsupportedEncodingException ignore) {
				}
			}

		} else {
			log.error( "facetNames or facetValues was null, you are defaulting to a regular query using no facet matching" );
		}

		return builder.toString();
	}
728147
public static double[] toPreds(double in[], float[] out, double[] preds,
                          int nclasses, double[] priorClassDistrib, double defaultThreshold) {
    if (nclasses > 2) {
      for (int i = 0; i < out.length; ++i)
        preds[1 + i] = out[i];
      preds[0] = GenModel.getPrediction(preds, priorClassDistrib, in, defaultThreshold);
    } else if (nclasses==2){
      preds[1] = 1f - out[0];
      preds[2] = out[0];
      preds[0] = GenModel.getPrediction(preds, priorClassDistrib, in, defaultThreshold);
    } else {
      preds[0] = out[0];
    }
    return preds;
  }
953081
public int rank() {
        if (rows == 0 || columns == 0) {
            return 0;
        }

        // TODO:
        // handle small (1x1, 1xn, nx1, 2x2, 2xn, nx2, 3x3, 3xn, nx3)
        // matrices without SVD

        MatrixDecompositor decompositor = withDecompositor(LinearAlgebra.SVD);
        Matrix[] usv = decompositor.decompose();
        // TODO: Where is my pattern matching?
        Matrix s = usv[1];
        double tolerance = Math.max(rows, columns) * s.get(0, 0) * Matrices.EPS;

        int result = 0;
        for (int i = 0; i < s.rows(); i++) {
            if (s.get(i, i) > tolerance) {
                result++;
            }
        }

        return result;
    }
171128
def facets_normal(self):
        
        if len(self.facets) == 0:
            return np.array([])

        area_faces = self.area_faces
        # sum the area of each group of faces represented by facets

        # the face index of the first face in each facet
        index = np.array([i[area_faces[i].argmax()]
                          for i in self.facets])
        # (n,3) float, unit normal vectors of facet plane
        normals = self.face_normals[index]
        # (n,3) float, points on facet plane
        origins = self.vertices[self.faces[:, 0][index]]
        # save origins in cache
        self._cache['facets_origin'] = origins

        return normals
13712
public int[][] getSets() {
        int n = 0;
        for (int i = 0; i < forest.length; i++) {
            if (forest[i] < 0) {
                n++;
            }
        }
        int[][] sets = new int[n][];
        int currentSet = 0;
        for (int i = 0; i < forest.length; i++) {
            if (forest[i] < 0) {
                int setSize = 1 - forest[i] - 1;
                sets[currentSet] = new int[setSize];
                int currentIndex = 0;
                for (int element = 0; element < forest.length; element++) {
                    if (getRoot(element) == i) {
                        sets[currentSet][currentIndex] = element;
                        currentIndex++;
                    }
                }
                currentSet++;
            }
        }
        return sets;
    }
108275
private Set<String> getLeastUbique(Collection<String> ids)
	{
		Set<String> select = new HashSet<String>();

		int s = getLeastScore(ids);

		for (String id : ids)
		{
			if (score.get(id) == s) select.add(id);
		}

		return select;
	}
952812
def get_available_facets(self):
        
        result = []
        for k, v in list(self.properties.items()):
            if isinstance(v, DateField):
                if not v.tokenize:
                    result.append((k, "date"))
            elif isinstance(v, NumericFieldAbstract):
                result.append((k, "numeric"))
            elif isinstance(v, StringField):
                if not v.tokenize:
                    result.append((k, "term"))
            elif isinstance(v, GeoPointField):
                if not v.tokenize:
                    result.append((k, "geo"))
            elif isinstance(v, ObjectField):
                for n, t in self.get_available_facets():
                    result.append((self.name + "." + k, t))
        return result
778860
public List<StorageTierView> getTierViewsBelow(String tierAlias) {
    int ordinal = getTierView(tierAlias).getTierViewOrdinal();
    return mTierViews.subList(ordinal + 1, mTierViews.size());
  }
705675
private double calculatePartitionQuality (ArrayList<Instance>[] docs,
			HashSparseVector[] centroid) {
		double quality = 0.0;

		for (int i = 0; i < docs.length; ++i) {
			quality += this.calculateClusterQuality(docs[i], centroid[i]);
		}
		return quality;
	}
1034460
public CharTrieIndex index(int maxLevels, int minWeight) {
    
    AtomicInteger numberSplit = new AtomicInteger(0);
    int depth = -1;
    do {
      numberSplit.set(0);
      if (0 == ++depth) {
        numberSplit.incrementAndGet();
        root().split();
      }
      else {
        root().streamDecendents(depth).forEach(node -> {
          TrieNode godparent = node.godparent();
          if (node.getDepth() < maxLevels) {
            if (null == godparent || godparent.getCursorCount() > minWeight) {
              if (node.getChar() != NodewalkerCodec.END_OF_STRING || node.getDepth() == 0) {
                ((IndexNode) node).split();
                numberSplit.incrementAndGet();
              }
            }
          }
        });
      }
    } while (numberSplit.get() > 0);
    return this;
  }
1117366
public void setFacetNames(java.util.Collection<String> facetNames) {
        if (facetNames == null) {
            this.facetNames = null;
            return;
        }

        this.facetNames = new java.util.ArrayList<String>(facetNames);
    }
1254203
public final FacetOptions addFacetOnFlieldnames(Collection<String> fieldnames) {
		Assert.notNull(fieldnames, "Fieldnames must not be null!");

		for (String fieldname : fieldnames) {
			addFacetOnField(fieldname);
		}
		return this;
	}
334192
public SortedSet<String> fields() {
		// Optimization: Materialize the fields set
		if (myFieldSet == null)
			myFieldSet = new TreeSet<String>(fields.keySet());
		return myFieldSet;
	}
1206644
public void computeIndicatorValuesHD(List<S> solutionSet, double[] maximumValues,
      double[] minimumValues) {
    List<S> A, B;
    // Initialize the structures
    indicatorValues = new ArrayList<List<Double>>();
    maxIndicatorValue = -Double.MAX_VALUE;

    for (int j = 0; j < solutionSet.size(); j++) {
      A = new ArrayList<>(1);
      A.add(solutionSet.get(j));

      List<Double> aux = new ArrayList<Double>();
      for (S solution : solutionSet) {
        B = new ArrayList<>(1);
        B.add(solution);

        int flag = (new DominanceComparator<S>()).compare(A.get(0), B.get(0));

        double value;
        if (flag == -1) {
          value =
              -calculateHypervolumeIndicator(A.get(0), B.get(0), problem.getNumberOfObjectives(),
                  maximumValues, minimumValues);
        } else {
          value = calculateHypervolumeIndicator(B.get(0), A.get(0), problem.getNumberOfObjectives(),
              maximumValues, minimumValues);
        }

        //Update the max value of the indicator
        if (Math.abs(value) > maxIndicatorValue) {
          maxIndicatorValue = Math.abs(value);
        }
        aux.add(value);
      }
      indicatorValues.add(aux);
    }
  }
1042304
public Set<T> dfs(Set<T> roots) {
        Deque<T> deque = new LinkedList<>(roots);
        Set<T> visited = new HashSet<>();
        while (!deque.isEmpty()) {
            T u = deque.pop();
            if (!visited.contains(u)) {
                visited.add(u);
                if (contains(u)) {
                    adjacentNodes(u).stream()
                        .filter(v -> !visited.contains(v))
                        .forEach(deque::push);
                }
            }
        }
        return visited;
    }