public WavePropagator(PatternModel model, Topology topology, bool backtrack = false, IWaveConstraint[] constraints = null, Random random = null, bool clear = true) { this.propagator = model.Propagator; this.patternCount = model.PatternCount; this.frequencies = model.Frequencies; this.width = topology.Width; this.height = topology.Height; this.depth = topology.Depth; this.indices = width * height * depth; this.periodicX = topology.PeriodicX; this.periodicY = topology.PeriodicY; this.periodicZ = topology.PeriodicZ; this.backtrack = backtrack; this.constraints = constraints ?? new IWaveConstraint[0]; this.topology = topology; this.random = random ?? new Random(); directionsCount = topology.Directions.Count; this.toPropagate = new Stack <PropagateItem>(); if (clear) { Clear(); } }
public WavePropagator( PatternModel model, ITopology topology, int backtrackDepth = 0, IWaveConstraint[] constraints = null, Func <double> randomDouble = null, FrequencySet[] frequencySets = null, bool clear = true) { this.patternCount = model.PatternCount; this.frequencies = model.Frequencies; this.indexCount = topology.IndexCount; this.backtrack = backtrackDepth != 0; this.backtrackDepth = backtrackDepth; this.constraints = constraints ?? new IWaveConstraint[0]; this.topology = topology; this.randomDouble = randomDouble ?? new Random().NextDouble; this.frequencySets = frequencySets; directionsCount = topology.DirectionsCount; patternModelConstraint = new PatternModelConstraint(this, model); if (clear) { Clear(); } }
public PatternModelConstraint(WavePropagator propagator, PatternModel model) { this.toPropagate = new Stack <IndexPatternItem>(); this.propagator = propagator; this.propagatorArray = model.Propagator; this.patternCount = model.PatternCount; this.topology = propagator.Topology; this.indexCount = topology.IndexCount; this.directionsCount = topology.DirectionsCount; }
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(); } }
public OneStepPatternModelConstraint(WavePropagator propagator, PatternModel model) { this.propagatorArray = model.Propagator; this.propagator = propagator; this.topology = propagator.Topology; this.directionsCount = propagator.Topology.DirectionsCount; this.patternCount = model.PatternCount; this.propagatorArrayDense = model.Propagator.Select(a1 => a1.Select(x => { var dense = new BitArray(patternCount); foreach (var p in x) { dense[p] = true; } return(dense); }).ToArray()).ToArray(); toPropagate = new Stack <IndexPatternItem>(); }
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(); } }
public WavePropagator( PatternModel model, ITopology topology, int backtrackDepth = 0, IWaveConstraint[] constraints = null, Func <double> randomDouble = null, Func <WavePropagator, IPickHeuristic> pickHeuristicFactory = null, bool clear = true) { this.patternCount = model.PatternCount; this.frequencies = model.Frequencies; this.indexCount = topology.IndexCount; this.backtrack = backtrackDepth != 0; this.backtrackDepth = backtrackDepth; this.constraints = constraints ?? new IWaveConstraint[0]; this.topology = topology; this.randomDouble = randomDouble ?? new Random().NextDouble; directionsCount = topology.DirectionsCount; this.pickHeuristicFactory = 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)); }; } patternModelConstraint = new PatternModelConstraint(this, model); if (clear) { Clear(); } }