Util.cs
(完整代码) 1KB
using System.Collections.Generic;
namespace 城市天然气管道风险管理与决策系统
{
internal class Util
{
public static string ParseScore(int a, int b)
{
return "(" + a.ToString() + "," + b.ToString() + "]";
}
public static double RankSum(int n, int i)
{
return (double)(2 * n + 1 - i) / (n * (n + 1));
}
public static double PR(int n, int i)
{
double tmp = 0.0;
for (int j = 1; j <= n; j++)
{
tmp += (double)(1.0 / j);
}
return (double)(1.0 / i) / tmp;
}
public static double RankOrderCentroid(int n, int i)
{
double tmp = 0.0;
for (int j = 1; j <= n; j++)
{
tmp += (double)(1.0 / i);
}
return (double)(1.0 / n) * tmp;
}
public static List<double> SortByOrder(List<int> order, List<double> to_be_sorted)
{
List<double> res = new List<double>();
foreach (int i in order)
{
res.Add(to_be_sorted[i]);
}
return res;
}
public static double ComputeUtility(List<double> utis, List<double> weights)
{
int count = utis.Count;
if (count != weights.Count) return -1;
double res = 0.0;
for(int i = 0; i < count; i++)
{
res += utis[i] * weights[i];
}
return res;
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
