public override String GetValueText(Vector value = null) { if (value == null) { value = Value; } if (value == null) { return(""); } Receptor receptor = (Receptor)net["_" + this.Gene.Name]; return(receptor.GetValueText(value)); }
/// <summary> /// 生成的测试集第一个是本能动作,第二个是方向不变动作,然后逐渐向两边增大 /// </summary> /// <param name="instinctActions"></param> /// <returns></returns> private List <List <double> > CreateTestActionSet(List <double> instinctActions) { List <List <double> > r = new List <List <double> >(); Receptor receptor = (Receptor)this.net["_a2"]; int count = receptor.getGene().SampleCount; double unit = receptor.getGene().LevelUnitDistance; double[] values = receptor.GetSampleValues(); if (values != null) { int minIndex = values.ToList().ConvertAll(v => Math.Abs(v - instinctActions[0])).argmin(); instinctActions[0] = values[minIndex]; if (_cached_ActionSet.ContainsKey(instinctActions[0])) { return(_cached_ActionSet[instinctActions[0]]); } r.Add(instinctActions); int index = 1; while (r.Count < count) { int t = (minIndex + index) % (values.Length); r.Add(new double[] { values[t] }.ToList()); if (r.Count >= count) { break; } t = minIndex - index; if (t < 0) { t = values.Length - 1; } r.Add(new double[] { values[t] }.ToList()); index += 1; } _cached_ActionSet.Add(instinctActions[0], r); return(r); } r.Add(instinctActions); int i = 1; while (r.Count < count) { double temp = instinctActions[0] + i * unit; if (temp < 0) { temp = 1.0 + unit + temp; } else if (temp > 1) { temp = temp - 1.0 - unit; } if (temp <= 0.0000001) { temp = 0; } r.Add((new double[] { temp }).ToList()); if (r.Count >= count) { break; } temp = instinctActions[0] - i * unit; if (temp < 0) { temp = 1.0 + unit + temp; } else if (temp > 1) { temp = temp - 1.0 - unit; } if (temp <= 0.0000001) { temp = 0; } r.Add((new double[] { temp }).ToList()); i++; } return(r); }