Exemplo n.º 1
0
        public WavePropagator(
            PatternModel model,
            ITopology topology,
            WavePropagatorOptions options)
        {
            this.patternCount = model.PatternCount;
            this.frequencies  = model.Frequencies;

            this.indexCount           = topology.IndexCount;
            this.backtrack            = options.BackTrackDepth != 0;
            this.backtrackDepth       = options.BackTrackDepth;
            this.constraints          = options.Constraints ?? new IWaveConstraint[0];
            this.topology             = topology;
            this.randomDouble         = options.RandomDouble ?? new Random().NextDouble;
            directionsCount           = topology.DirectionsCount;
            this.pickHeuristicFactory = options.PickHeuristicFactory;

            if (this.pickHeuristicFactory == null)
            {
                this.pickHeuristicFactory = (wavePropagator) =>
                {
                    var entropyTracker = new EntropyTracker(wavePropagator.Wave, wavePropagator.Frequencies, wavePropagator.Topology.Mask);
                    entropyTracker.Reset();
                    wavePropagator.AddTracker(entropyTracker);
                    return(new RandomPickerHeuristic(entropyTracker, this.randomDouble));
                };
            }

            switch (options.ModelConstraintAlgorithm)
            {
            case ModelConstraintAlgorithm.OneStep:
                patternModelConstraint = new OneStepPatternModelConstraint(this, model);
                break;

            case ModelConstraintAlgorithm.Default:
            case ModelConstraintAlgorithm.Ac4:
                patternModelConstraint = new Ac4PatternModelConstraint(this, model);
                break;

            case ModelConstraintAlgorithm.Ac3:
                patternModelConstraint = new Ac3PatternModelConstraint(this, model);
                break;

            default:
                throw new Exception();
            }

            if (options.Clear)
            {
                Clear();
            }
        }
Exemplo n.º 2
0
        public WavePropagator(
            PatternModel model,
            ITopology topology,
            WavePropagatorOptions options)
        {
            this.patternCount = model.PatternCount;
            this.frequencies  = model.Frequencies;

            this.indexCount        = topology.IndexCount;
            this.backtrack         = options.BacktrackPolicy != null;
            this.backtrackPolicy   = options.BacktrackPolicy;
            this.maxBacktrackDepth = options.MaxBacktrackDepth;
            this.constraints       = options.Constraints ?? new IWaveConstraint[0];
            this.topology          = topology;
            this.randomDouble      = options.RandomDouble ?? new Random().NextDouble;
            directionsCount        = topology.DirectionsCount;
            this.indexPicker       = options.IndexPicker ?? new EntropyTracker();
            this.patternPicker     = options.PatternPicker ?? new WeightedRandomPatternPicker();

            switch (options.ModelConstraintAlgorithm)
            {
            case ModelConstraintAlgorithm.OneStep:
                patternModelConstraint = new OneStepPatternModelConstraint(this, model);
                break;

            case ModelConstraintAlgorithm.Default:
            case ModelConstraintAlgorithm.Ac4:
                patternModelConstraint = new Ac4PatternModelConstraint(this, model);
                break;

            case ModelConstraintAlgorithm.Ac3:
                patternModelConstraint = new Ac3PatternModelConstraint(this, model);
                break;

            default:
                throw new Exception();
            }

            if (options.Clear)
            {
                Clear();
            }
        }