public FunctionTests() { FAI.ClearInstance(); FAI.Instance.ProvideBuiltins(new NumberBuiltinProvider()); env = new Global(); FAI.Instance.InterpretLines(env, @" using std/math "); }
public void SetObservationSet(FAI.Bayesian.IObservationSet observations) { if (observations == null) { xSetName.Text = "(none)"; } else { xSetName.Text = observations.Name; } // Update the list of observations. const int maxToShow = 100; xStackPanelObservations.Children.Clear(); if (observations != null) { foreach (var observation in observations.Take(maxToShow)) { TextBlock tb = new TextBlock(); tb.Text = ObservationToString(observation); xStackPanelObservations.Children.Add(tb); tb.FontFamily = new FontFamily("Consolas"); tb.FontSize = 10; } if (observations.Size.Value > maxToShow) { TextBlock tb = new TextBlock(); tb.Text = "..."; xStackPanelObservations.Children.Add(tb); tb.FontFamily = new FontFamily("Consolas"); tb.FontSize = 10; } } }
public void Dispose() { FAI.ClearInstance(); }
public BinaryOpTests() { FAI.ClearInstance(); env = new Global(); FAI.Instance.InterpretLines(env, "x = 10"); }
public UnionTests() { FAI.ClearInstance(); env = new Global(); }
/// <summary> /// 2062 新增一条预测记录 /// </summary> /// <param name="result"></param> /// <param name="param"></param> public static void Admin_AIItemAdd(ReturnModel result, AdminParamsM param) { if (IsLogin(result, param.Token)) { if (string.IsNullOrEmpty(param.Content)) { result.code = RespCodeConfig.ServerError; result.msg = "内容为空"; return; } if (param.Type == "edit") { //编辑 FAI model = JsonConvert.DeserializeObject <FAI>(param.Content); FAI obj = ibll.FAI.Single(a => a.ID == model.ID); if (obj != null) { obj.Cate = model.Cate; obj.CateType = model.CateType; obj.Status = model.Status; obj.TurnType = model.TurnType; obj.DT = model.DT; obj.NPrice = model.NPrice; obj.Remark = model.Remark; obj.ResultClose = model.ResultClose; obj.ResultLow = model.ResultLow; obj.ResultHight = model.ResultHight; obj.IsPublish = model.IsPublish; obj.IsAbandon = model.IsAbandon; ibll.FAI.Update(obj, new string[] { "Cate", "CateType", "Status", "TurnType", "IsPublish", "DT", "NPrice", "Remark", "ResultClose", "ResultLow", "ResultHight", "IsAbandon" }); int n = ibll.SaveChanges(); if (n > 0) { result.code = RespCodeConfig.Normal; result.data = "保存成功"; } else { result.code = RespCodeConfig.ServerError; result.data = "保存失败"; } } } else if (param.Type == "add") { //新增 FAI model = JsonConvert.DeserializeObject <FAI>(param.Content); if (model.AValue > 0 && model.Star > 0 && model.NPrice > 0) { model.ReviseLV = (model.AValue * 100) / model.NPrice; model.ReviseStar = model.ReviseLV * model.Star; model.IsAbandon = model.ReviseLV < (decimal)0.9; model.AddDate = DateTime.Now; ibll.FAI.Add(model); int n = ibll.SaveChanges(); if (n > 0) { result.code = RespCodeConfig.Normal; result.data = "保存成功"; } else { result.code = RespCodeConfig.ServerError; result.data = "保存失败"; } } else { result.code = RespCodeConfig.ArgumentExp; result.data = "数据有误"; } } } }
public void SetInferenceResults( IDictionary<string, DiscreteDistribution> results, int scenarioId, FAI.Bayesian.Observation evidence) { if (scenarioId <= 0) { throw new ArgumentOutOfRangeException("ScenarioId"); } if (results != null && results.Count != 0) { foreach (var node in _nodes) { FRandomVariable variable = (FRandomVariable)node.Tag; DiscreteDistribution distribution; // See if this variable has a result in the incoming results. if (results.TryGetValue(variable.Name, out distribution)) { bool isEvidence = evidence.TryValueForVariable(variable.Name) != null; var slices = distribution .Masses .OrderBy(p => p.Key) .Select(p => p.Value) .ToArray(); node.SetSlices(slices, scenarioId, isEvidence); } } } else { foreach (var node in _nodes) { FRandomVariable variable = (FRandomVariable)node.Tag; bool isEvidence = evidence != null && evidence.TryValueForVariable(variable.Name) != null; node.SetSlices(new double[0], scenarioId, isEvidence); } } }
public WhereTests() { FAI.ClearInstance(); env = new Global(); }