public void InitAll(SRMData data, EMConf emconf, IMessage msg) { foreach (HErlangEMSRM model in allmodels) { EM em = new EM(model, emconf, msg); em.Initialize(data); maxmodel = model; } }
public HErlangAll(int ndim) : base(ndim + "-HyperErlang SRGM", 2 * ndim) { this.ndim = ndim; maxconf = new EMConf(); allmodels = new List <HErlangEMSRM>(); int[] list = new int[ndim]; MakeShape(0, list, 1, ndim); maxmodel = allmodels[0]; }
public void FitAll(SRMData data, EMConf emconf, IMessage msg) { maxllf = double.MinValue; foreach (HErlangEMSRM model in allmodels) { EM em = new EM(model, emconf, msg); em.Fit(data); if (emconf.Llf > maxllf) { maxllf = emconf.Llf; maxmodel = model; maxconf.Set(emconf); } } emconf.Set(maxconf); }
private void MakeShape(int m, int[] list, int u, int res) { if (u > res) { return; } for (int i = u; i < res; i++) { list[m] = i; MakeShape(m + 1, list, i, res - i); } list[m] = res; int[] shape = new int[m + 1]; Array.Copy(list, shape, m + 1); HErlangEMSRM model = new HErlangEMSRM(new HErlangParam(shape)); allmodels.Add(model); list[m] = 0; }
public static void Test_herl() { double[] time = { 2, 1, 2, 3, 2, 1 }; int[] num = { 0, 1, 1, 0, 2, 0 }; int[] type = { 0, 0, 0, 0, 0, 0 }; SRMData data = new SRMData(); data.SetData(time, num, type); int nm = 4; SRM[] models = new SRMBase[nm]; models[0] = new HErlang.HErlangEMSRM(new HErlang.HErlangParam(new int[] { 1, 1 })); models[1] = new HErlang.HErlangEMSRM(new HErlang.HErlangParam(new int[] { 1, 2 })); models[2] = new HErlang.HErlangEMSRM(new HErlang.HErlangParam(new int[] { 1, 1, 1 })); models[3] = new HErlang.HErlangEMSRM(new HErlang.HErlangParam(new int[] { 1, 2, 5 })); EMConf[] emconf = new EMConf[nm]; EM[] em = new EM[nm]; for (int i = 0; i < nm; i++) { emconf[i] = new EMConf(); em[i] = new EM(models[i], emconf[i], new MODELS.SRMConsoleMessage(models[i], emconf[i])); } for (int i = 0; i < nm; i++) { emconf[i].Progress = 1; emconf[i].StopCond = StopCondition.LLF; em[i].Initialize(data); em[i].Fit(data); Console.WriteLine(emconf[i].Status); Result result = models[i].Calc(data); print_result(result); } }