Estimate the weight of each VMs with regards to multiple dimensions.
In practice, it sums the normalised size of each VM against the total capacity

@param rp  the problem to solve
@param rcs the resources to consider
@return a weight per VM
557277
public static TObjectIntMap<VM> getWeights(ReconfigurationProblem rp, List<CShareableResource> rcs) {
        Model mo = rp.getSourceModel();

        int[] capa = new int[rcs.size()];
        int[] cons = new int[rcs.size()];
        TObjectIntMap<VM> cost = new TObjectIntHashMap<>();
        for (Node n : mo.getMapping().getAllNodes()) {
            for (int i = 0; i < rcs.size(); i++) {
                capa[i] += rcs.get(i).virtRcUsage.get(rp.getNode(n)).getUB() * rcs.get(i).ratios.get(rp.getNode(n))/*.getLB()*/;
            }
        }

        for (VM v : mo.getMapping().getAllVMs()) {
            for (int i = 0; i < rcs.size(); i++) {
                cons[i] += rcs.get(i).getVMAllocation(rp.getVM(v));
            }
        }

        for (VM v : mo.getMapping().getAllVMs()) {
            double sum = 0;
            for (int i = 0; i < rcs.size(); i++) {
                double ratio = 0;
                if (cons[i] > 0) {
                    ratio = 1.0 * rcs.get(i).getVMAllocation(rp.getVM(v)) / capa[i];
                }
                sum += ratio;
            }
            cost.put(v, (int) (sum * 10000));
        }
        return cost;
    }
871522
public VirtualResourcePoolUsage getVRPUsage(String vrpId) throws InvalidState, NotFound, RuntimeFault, RemoteException {
        return getVimService().getVRPUsage(getMOR(), vrpId);
    }
740761
public VMConsumptionComparator append(ShareableResource r, boolean asc) {
        rcs.add(r);
        ascs.add(asc ? 1 : -1);
        return this;
    }
300051
def _compute_distance_scaling(self, rup, dists, C):
        
        Mref = 4.5
        Rref = 1.0
        R = np.sqrt(dists.rjb ** 2 + C['h'] ** 2)
        return (C['c1'] + C['c2'] * (rup.mag - Mref)) * np.log(R / Rref) + \
            C['c3'] * (R - Rref)
1291382
def _compute_magnitude_scaling(self, rup, C):
        
        U, SS, NS, RS = self._get_fault_type_dummy_variables(rup)
        if rup.mag <= C['Mh']:
            return C['e1'] * U + C['e2'] * SS + C['e3'] * NS + C['e4'] * RS + \
                C['e5'] * (rup.mag - C['Mh']) + \
                C['e6'] * (rup.mag - C['Mh']) ** 2
        else:
            return C['e1'] * U + C['e2'] * SS + C['e3'] * NS + C['e4'] * RS + \
                C['e7'] * (rup.mag - C['Mh'])
887730
def mass_3d(self, R, Rs, rho0):
        
        Rs = float(Rs)
        m_3d = 4. * np.pi * rho0 * Rs**3 *(np.log((Rs + R)/Rs) - R/(Rs + R))
        return m_3d
464326
public double regress(DataPoint dp)
    {
        TreeNodeVisitor node = this;
        while(!node.isLeaf())
        {
            int path = node.getPath(dp);
            if(path < 0 )//missing value case
            {
                double sum = 0;
                double resultSum = 0;
                for(int child = 0; child < childrenCount(); child++)
                {
                    if(node.isPathDisabled(child))
                        continue;
                    double child_result = node.getChild(child).regress(dp);
                    sum += node.getPathWeight(child);
                    resultSum += node.getPathWeight(child)*child_result;
                }
                
                if(sum == 0)//all paths disabled?
                    break;//break out and do local classify
                if(sum < 1.0-1e-5)//re-normalize our result
                    resultSum /= (sum+1e-6);
                
                return resultSum;
            }
            if(node.isPathDisabled(path))//if missing value makes path < 0, return local regression dec
                break;
            node = node.getChild(path);
        }
        return node.localRegress(dp);
    }
1168653
private RPCParameters packageParams(Object... params) {
        if (params == null) {
            return null;
        }
        
        if (params.length == 1 && params[0] instanceof RPCParameters) {
            return (RPCParameters) params[0];
        }
        
        return new RPCParameters(params);
    }
827141
def eval(*pars)
		raise ArgumentError("wrong number of points") if pars.size != @dim
# 			p vals
		pars = GSL::Vector.alloc(pars)
		return @npoints.times.inject(0.0) do |sum, i|
# 			sum + function(radius(vals, @gridpoints.row(i)))*@weights[i]
			sum + function(pars, @gridpoints.row(i))*@weights[i]
		end
	end
1135017
def _compute_weight(powers, wg):
    """"""
    # split
    pow1 = (powers[0], 0)
    pow2 = (0, powers[1])

    cal1 = _compute_value(pow1, wg)
    cal2 = _compute_value(pow2, wg)

    return cal1 * cal2
279498
public static double computeSvf(Point pt, Geometry geoms, double distance, int rayCount) {
        return computeSvf(pt, geoms, distance, rayCount, RAY_STEP_LENGTH);
    }
638931
public static Map<IntVar, VM> makePlacementMap(ReconfigurationProblem rp) {
        Map<IntVar, VM> m = new HashMap<>(rp.getFutureRunningVMs().size());
        for (VM vm : rp.getFutureRunningVMs()) {
            IntVar v = rp.getVMAction(vm).getDSlice().getHoster();
            m.put(v, vm);
        }
        return m;
    }
347146
public static int nvgraphSrSpmv(
        nvgraphHandle handle, 
        nvgraphGraphDescr descrG, 
        long weight_index, 
        Pointer alpha, 
        long x_index, 
        Pointer beta, 
        long y_index, 
        int SR)
    {
        return checkResult(nvgraphSrSpmvNative(handle, descrG, weight_index, alpha, x_index, beta, y_index, SR));
    }
155904
public static double weightedCoefficient(NumberVector x, NumberVector y, double[] weights) {
    final int xdim = x.getDimensionality();
    final int ydim = y.getDimensionality();
    if(xdim != ydim) {
      throw new IllegalArgumentException("Invalid arguments: number vectors differ in dimensionality.");
    }
    if(xdim != weights.length) {
      throw new IllegalArgumentException("Dimensionality doesn't agree to weights.");
    }
    if(xdim == 0) {
      throw new IllegalArgumentException("Empty vector.");
    }
    // Inlined computation of Pearson correlation, to avoid allocating objects!
    // This is a numerically stabilized version, avoiding sum-of-squares.
    double sumXX = 0., sumYY = 0., sumXY = 0., sumWe = weights[0];
    double sumX = x.doubleValue(0) * sumWe, sumY = y.doubleValue(0) * sumWe;
    for(int i = 1; i < xdim; ++i) {
      final double xv = x.doubleValue(i), yv = y.doubleValue(i), w = weights[i];
      // Delta to previous mean
      final double deltaX = xv * sumWe - sumX;
      final double deltaY = yv * sumWe - sumY;
      // Increment count first
      final double oldWe = sumWe; // Convert to double!
      sumWe += w;
      final double f = w / (sumWe * oldWe);
      // Update
      sumXX += f * deltaX * deltaX;
      sumYY += f * deltaY * deltaY;
      // should equal deltaY * neltaX!
      sumXY += f * deltaX * deltaY;
      // Update sums
      sumX += xv * w;
      sumY += yv * w;
    }
    // One or both series were constant:
    if(!(sumXX > 0. && sumYY > 0.)) {
      return (sumXX == sumYY) ? 1. : 0.;
    }
    return sumXY / FastMath.sqrt(sumXX * sumYY);
  }
794862
public double getRmsd() {

		if (alignment == null)
			return -1.0;
		if (alignment.getScore(MultipleAlignmentScorer.RMSD) == null)
			return MultipleAlignmentScorer.getRMSD(alignment);

		return alignment.getScore(MultipleAlignmentScorer.RMSD);
	}
510387
public static float[] vLerp(float[] verts, int v1, int v2, float t) {
        float[] dest = new float[3];
        dest[0] = verts[v1 + 0] + (verts[v2 + 0] - verts[v1 + 0]) * t;
        dest[1] = verts[v1 + 1] + (verts[v2 + 1] - verts[v1 + 1]) * t;
        dest[2] = verts[v1 + 2] + (verts[v2 + 2] - verts[v1 + 2]) * t;
        return dest;
    }
1212995
@Override
  public double getWeight(double distance, double max, double stddev) {
    if(stddev <= 0) {
      return 1;
    }
    return NormalDistribution.erfc(MathUtil.SQRTHALF * distance / stddev);
  }