本文整理汇总了C#中Problem.Evaluate方法的典型用法代码示例。如果您正苦于以下问题:C# Problem.Evaluate方法的具体用法?C# Problem.Evaluate怎么用?C# Problem.Evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Problem
的用法示例。
在下文中一共展示了Problem.Evaluate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Confinement
public void Confinement(
Problem.IProblem pb)
{
// Confinement and evaluation
// Note: the two are together, for depending on the clamping option
// there may be no evaluation at all
// Set to the bounds, and v to zero
for (int d = 0; d < pb.SwarmSize.D; d++)
{
if (x.x[d] < pb.SwarmSize.minS[d])
{
x.x[d] = pb.SwarmSize.minS[d];
v.V[d] = 0;
}
if (x.x[d] > pb.SwarmSize.maxS[d])
{
x.x[d] = pb.SwarmSize.maxS[d];
v.V[d] = 0;
}
}
if (pb.Constraint != 0)
{
Fitness ff = Position.Constraint(x, pb);
for (int i = 1; i < ff.size; i++)
{
if (ff.f[i] <= 0) continue;
// If a constraint is not respected the velocity is decreased
// and the position moved accordingly in th HOPE that the new position will be OK
// (but we don't check it)
for (int d = 0; d < pb.SwarmSize.D; d++)
{
v.V[d] = v.V[d]/2;
x.x[d] = x.x[d] - v.V[d];
}
}
}
x = Position.Quantis(x, pb.SwarmSize);
// Evaluation
x.f = pb.Evaluate(x);
}