private static void ExtractFeatureInformation(object featuredObject, int iiLen, int oiLen, out FeatureDescription[] descriptions, out Strings inIDs, out Strings outIDs)
        {
            var ofo = featuredObject as IFeaturedInputOutput;
            if (ofo != null)
            {
                inIDs = ofo.InputFeatureIDs;
                outIDs = ofo.OutputFeatureIDs;
                descriptions = ofo.FeatureDescriptions.ToArray();
                return;
            }

            var ifo = featuredObject as IFeaturedInput;
            if (ifo != null)
            {
                inIDs = ifo.InputFeatureIDs;
                var set = ifo.FeatureDescriptions; // Mutable.
                outIDs = GenerateFeatureDescriptions(set, oiLen);
                descriptions = set.ToArray();
                return;
            }

            var newSet = new FeatureDescriptionSet();
            inIDs = GenerateFeatureDescriptions(newSet, iiLen);
            outIDs = GenerateFeatureDescriptions(newSet, oiLen);
            descriptions = newSet.ToArray();
        }
        private void Initialize()
        {
            var set = new FeatureDescriptionSet(desc);
            FeatureDescriptionSet inputSet = null;
            FeatureDescriptionSet outputSet = null;

            try
            {
                inputSet = set.GetSubset(InputFeatureIDs);
                outputSet = set.GetSubset(OutputFeatureIDs);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Cannot generate feature subset. See inner exception for details.", ex);
            }
            
            inputVectorizer = new FeatureSetVectorizer(inputSet);
            outputVectorizer = new FeatureSetVectorizer(outputSet);

            if (inputVectorizer.FeatureDescriptions.Sum(d => d.FeatureValueCount) != Unit.InputInterface.Length)
            {
                throw new InvalidOperationException("Invalid number of input features.");
            }

            if (outputVectorizer.FeatureDescriptions.Sum(d => d.FeatureValueCount) != Unit.OutputInterface.Length)
            {
                throw new InvalidOperationException("Invalid number of output features.");
            }

            inputIDLookup = CreateLookup(InputFeatureIDs);

            if (InputFeatureIDs.Count + OutputFeatureIDs.Count < set.Count)
            {
                desc = Cut(set, InputFeatureIDs.Concat(OutputFeatureIDs));
            }

            computation = new Learningutation<double>(NumberOfIterations);
        }
 private FeatureDescription[] Cut(FeatureDescriptionSet set, IEnumerable<string> exceptIDs)
 {
     return exceptIDs.Select(id => set[id]).ToArray();
 }
 private static Strings GenerateFeatureDescriptions(FeatureDescriptionSet set, int count)
 {
     string[] ids = new string[count];
     for (int idx = 0; idx < count; idx++)
     {
         string fid = "Port_" + idx;
         ids[idx] = fid;
         set.Add(new ValueFeatureDescription(fid, new DoubleRange(0.0, 1.0)));
     }
     return new Strings(ids);
 }