public void Visit <T1>(RandomPrimitive <T1> erp) { if (erp is Constant <T1> ) { // do not add to trace as we do not want to // resample constants this.sample = new Weighted <T1>(erp.Sample(-1)); return; } var prev = FindChoice(this.oldTrace, this.stack, erp); var reuse = prev.HasValue && ((RandomPrimitive)prev.Value.Erp).ForceRegen == false; if (reuse) { var entry = prev.Value; this.sample = new Weighted <T1>((T1)entry.Sample); entry.Reused = true; this.trace.Add(entry); } else { var sample = erp.Sample(this.generation); var score = Math.Log(erp.Score(sample)); this.sample = new Weighted <T1>(sample); var entry = new TraceEntry(this.stack, erp, sample, score, false); this.trace.Add(entry); // keep from forcing a regeneration of this RandomPrimitive // either on this iteration (i.e., because of a programmer // induced dependence) or in future iterations. ((RandomPrimitive)erp).ForceRegen = false; } }
public void Visit <T>(RandomPrimitive <T> erp) { this.Sample = erp.Sample(-1); }
public void Visit <T1>(RandomPrimitive <T1> erp) { var sample = erp.Sample(this.generation); this.sample = new Weighted <T1>(sample); }