本文整理汇总了C#中Element.IsInInterval方法的典型用法代码示例。如果您正苦于以下问题:C# Element.IsInInterval方法的具体用法?C# Element.IsInInterval怎么用?C# Element.IsInInterval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element.IsInInterval方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public override List<Element> Run(List<Element> population, Lib.func f, bool integer)
{
if (ps["Migration"] <= 0)
return population;
//krizeni smeruje potomky
//t = krok = 0 (while t<pathlen)
//
Element leader = population[0];
Element worst = population[0];
foreach (Element e in population)
{
if (e.Z < leader.Z)
leader = e;
if (e.Z > worst.Z)
worst = e;
}
if (worst.Z - leader.Z < ps["MinDiv"])
return population;
Random r = new Random();
List<Element> result = new List<Element>();
for (int k = 0; k < population.Count; k++)
{
Element e = population[k];
if (e == leader)
{
result.Add(e);
continue;
}
List<Element> jumps = new List<Element>();
for (int i = 0; i < ps["PathLength"] / ps["Step"]; i++)
{
List<int> prtv = GetPRTVector(2, r);
Element leaderdiff = new Element(leader.X - e.X, leader.Y - e.Y, 0);
Element onejump = new Element(e.X + leaderdiff.X * i * ps["Step"] * prtv[0], e.Y + leaderdiff.Y * i * ps["Step"] * prtv[1], f);
if (onejump.IsInInterval())
jumps.Add(onejump);
}
int bestindex = -1;
for (int j = 0; j < jumps.Count; j++)
{
if (jumps[j].Z < e.Z)
bestindex = j;
}
result.Add((bestindex == -1) ? population[k] : jumps[bestindex]);
}
ps["Migration"]--;
return result;
}