public override void Solve(Model model) { if (Distribution == null) throw new ArgumentNullException("Input distribution has not been initialized"); Output = Distribution; }
public void ConstantTest() { var in1 = new ModelInput("in1") { Distribution = Distribution.InitGaussian(10, 0.31) }; var op1 = new ModelFormula("op1") { Formula = "in1 * 3" }; var model = new Model(); model.Add(in1, op1); model.Solve(); Utils.AssertIsInRange(op1.Output.GetMean(), 30, 0.5); }
public static void Main(string[] args) { var in1 = new ModelInput("in1") { Distribution = Distribution.InitGaussian(10, 0.31) }; var in2 = new ModelInput("in2") { Distribution = Distribution.InitGaussian(3, 0.31) }; var in3 = new ModelInput("in3") { Distribution = Distribution.InitGaussian(5, 0.61) }; var in4 = new ModelInput("c") { Distribution = Distribution.InitConstant(10) }; var op1 = new ModelFormula("op1") { Formula = "in1 * in2" }; var op2 = new ModelFormula("op2") { Formula = "op1 * in3 * c" }; var model = new Model(); model.Add(in1, in2, op1, in3, in4, op2); model.Solve(); Console.WriteLine("Result: mean: {0} stddev: {1}", op2.Output.GetMean(), op2.Output.GetStdDeviation()); Console.WriteLine("Result histogram:"); PrintDistroChart(op2.Output.RawItems); }
public override void Solve(Model model) { if (mInputs == null) GetNeededInputs(); var e = new Expression(Formula, EvaluateOptions.IterateParameters | EvaluateOptions.IgnoreCase); foreach (var inputName in mInputs) { var objectDistribution = model[inputName].Output; e.Parameters[inputName] = objectDistribution; } var result = e.Evaluate() as List<object>; if (result == null) throw new Exception(""); Output = new Distribution(GetDoubleArray(result)); }
public abstract void Solve(Model model);