private void AlgorithmFinal(AbstractNetworkContainer containerToChange) { Int32[] final = new Int32[containerToChange.Size]; for (int i = 0; i < final.Length; ++i) { final[i] = containerToChange.GetActiveStatus(i) ? 1 : 0; } for (int i = 0; i < containerToChange.GetActiveStatuses().Count; ++i) { if (!containerToChange.GetActiveStatus(i)) { continue; } if (Rand.NextDouble() < lambda) { Int32 index = RandomNeighbourToActivate(containerToChange, true, i); if (index != -1) { ++final[index]; } } if (Rand.NextDouble() < mu) { --final[i]; } } for (int i = 0; i < final.Count(); ++i) { // TODO get k as parameter containerToChange.SetActiveStatus(i, final[i] > 0); } }
public void Calculate(AlgorithmType t) { InitializeProcessToRun(t); Debug.Assert(processToRun != null); AbstractNetworkContainer containerToChange = (AbstractNetworkContainer)container.Clone(); Double timeStep = 0; Double currentTracingStep = tracingStepIncrement, currentActiveNodesCount = containerToChange.GetActiveNodesCount(); Trajectory.Add(timeStep, currentActiveNodesCount / containerToChange.Size); if (visualMode) { Byte[] bits = new Byte[containerToChange.GetActiveStatuses().Length + 1]; containerToChange.GetActiveStatuses().CopyTo(bits, 0); BitArray arr = new BitArray(bits); ActivesInformation.Add(arr); } while (timeStep <= stepCount && currentActiveNodesCount != 0) { processToRun(containerToChange); currentActiveNodesCount = containerToChange.GetActiveNodesCount(); Trajectory.Add(++timeStep, currentActiveNodesCount / containerToChange.Size); if (visualMode) { Byte[] bits = new Byte[containerToChange.GetActiveStatuses().Length + 1]; containerToChange.GetActiveStatuses().CopyTo(bits, 0); BitArray arr = new BitArray(bits); ActivesInformation.Add(arr); } network.UpdateStatus(NetworkStatus.StepCompleted); // TODO closed Trace /*if (TraceCurrentStep(timeStep, currentTracingStep, "ActivationAlgorithm_1")) * { * currentTracingStep += TracingStepIncrement; * network.UpdateStatus(NetworkStatus.StepCompleted); * }*/ } Debug.Assert(timeStep > stepCount || !containerToChange.DoesActiveNodeExist()); }