Beispiel #1
0
            private static IEnumerable <IExampleSpace <ContextualValue <TProjection, TContext> > > ContextualizedUnfoldSubspaceInternal <TAccumulator, TContext, TProjection>(
                TContext context,
                IEnumerable <TAccumulator> accumulators,
                ContextualizedUnfoldFunctions <TAccumulator, TContext, TProjection> functions)
            {
                IExampleSpace <ContextualValue <TProjection, TContext> > GenerateNextExampleSpace(
                    TAccumulator accumulator,
                    TContext context0)
                {
                    return(UnfoldInternal(accumulator, context0, functions));
                }

                return(TraverseUnencountered(accumulators, context, functions.NextContext, GenerateNextExampleSpace).Select(exampleSpace =>
                {
                    var currentExample = exampleSpace.Current;
                    var context0 = functions.NextContext(currentExample.Value.Value, currentExample.Value.Context);

                    var exampleWithMoreContext = new Example <ContextualValue <TProjection, TContext> >(
                        currentExample.Id,
                        new ContextualValue <TProjection, TContext>(currentExample.Value.Value, context0),
                        currentExample.Distance);

                    return new ExampleSpace <ContextualValue <TProjection, TContext> >(
                        exampleWithMoreContext,
                        exampleSpace.Subspace);
                }));
            }
Beispiel #2
0
            public static IExampleSpace <ContextualValue <TProjection, TContext> > UnfoldInternal <TAccumulator, TContext, TProjection>(
                TAccumulator accumulator,
                TContext context,
                ContextualizedUnfoldFunctions <TAccumulator, TContext, TProjection> functions)
            {
                var example = CreateExample(accumulator, context, functions);

                var context0 = functions.NextContext(example.Value.Value, context);

                var(context1, shrinks) = functions.Shrink(accumulator, context0);

                var subspace = ContextualizedUnfoldSubspaceInternal(context1, shrinks, functions);

                return(new ExampleSpace <ContextualValue <TProjection, TContext> >(example, subspace));
            }