public override void SyncInput(ConfigurationWithChannelData eStep, List <Configuration> list) { //List<Configuration> returnList = new List<Configuration>(); for (int i = 0; i < Processes.Count; i++) { Process process = Processes[i]; List <Configuration> list1 = new List <Configuration>(); process.SyncInput(eStep, list1); if (list1.Count > 0) { List <Dictionary <string, int> > nextProcessCounters = Common.Classes.Ultility.Ultility.ProcessCounterDecrement(Common.Classes.Ultility.Ultility.CutNumber, ProcessesCounter, process.ProcessID, 1); for (int j = 0; j < list1.Count; j++) { Configuration step = list1[j]; foreach (Dictionary <string, int> ints in nextProcessCounters) { List <Process> newProcess = new List <Process>(Processes); Dictionary <string, int> listInstance = new Dictionary <string, int>(ints); AddOneProcess(newProcess, step.Process, listInstance); IndexInterleaveAbstract interleave = new IndexInterleaveAbstract(newProcess, listInstance); step.Process = interleave; list.Add(step); } } } } //return returnList; }
private static void AddOneProcess(List <Process> processes, Process newProcess, Dictionary <string, int> counter) { if (newProcess is IndexInterleave) { IndexInterleave index = newProcess as IndexInterleave; foreach (Process processe in index.Processes) { string tmp = processe.ProcessID; if (!counter.ContainsKey(tmp)) { counter.Add(tmp, 1); processes.Add(processe); } else { counter[tmp] = Common.Classes.Ultility.Ultility.ProcessCounterIncrement(Common.Classes.Ultility.Ultility.CutNumber, counter[tmp], 1); } } } else if (newProcess is IndexInterleaveAbstract) { IndexInterleaveAbstract index = newProcess as IndexInterleaveAbstract; foreach (Process processe in index.Processes) { string tmp = processe.ProcessID; if (!counter.ContainsKey(tmp)) { counter.Add(tmp, index.ProcessesCounter[tmp]); processes.Add(processe); } else { counter[tmp] = Common.Classes.Ultility.Ultility.ProcessCounterIncrement(Common.Classes.Ultility.Ultility.CutNumber, counter[tmp], index.ProcessesCounter[tmp]); } } } else { string tmp = newProcess.ProcessID; if (!counter.ContainsKey(tmp)) { counter.Add(tmp, 1); processes.Add(newProcess); } else { counter[tmp] = Common.Classes.Ultility.Ultility.ProcessCounterIncrement(Common.Classes.Ultility.Ultility.CutNumber, counter[tmp], 1); } } }
public override void SyncOutput(Valuation GlobalEnv, List <ConfigurationWithChannelData> list) { //List<ConfigurationWithChannelData> returnList = new List<ConfigurationWithChannelData>(); for (int i = 0; i < Processes.Count; i++) { Process process = Processes[i]; List <ConfigurationWithChannelData> list1 = new List <ConfigurationWithChannelData>(); process.SyncOutput(GlobalEnv, list1); if (list1.Count > 0) { List <Dictionary <string, int> > nextProcessCounters = Common.Classes.Ultility.Ultility.ProcessCounterDecrement(Common.Classes.Ultility.Ultility.CutNumber, ProcessesCounter, process.ProcessID, 1); for (int j = 0; j < list1.Count; j++) { Configuration step = list1[j]; foreach (Dictionary <string, int> ints in nextProcessCounters) { List <Process> newProcess = new List <Process>(Processes); Dictionary <string, int> listInstance = new Dictionary <string, int>(ints); AddOneProcess(newProcess, step.Process, listInstance); IndexInterleaveAbstract interleave = new IndexInterleaveAbstract(newProcess, listInstance); ConfigurationWithChannelData newStep = new ConfigurationWithChannelData(interleave, step.Event, step.DisplayName, step.GlobalEnv, step.IsDataOperation, list1[j].ChannelName, list1[j].Expressions); newStep.IsAtomic = step.IsAtomic; list.Add(newStep); } } } } //return returnList; }
public override Process ClearConstant(Dictionary<string, Expression> constMapping) { List<Process> newProceses = new List<Process>(); if (Specification.IsParsing) { if (Processes == null) { return new IndexInterleave(IndexedProcessDefinition.ClearConstant(constMapping)); } foreach (Process procese in Processes) { newProceses.Add(procese.ClearConstant(constMapping)); } return new IndexInterleave(newProceses); } List<Process> newnewProcesses = Processes; if(Processes == null) { //return new IndexInterleave(IndexedProcessDefinition.GetIndexedProcesses(constMapping)); newnewProcesses = IndexedProcessDefinition.GetIndexedProcesses(constMapping); } int size = newnewProcesses.Count; Dictionary<string, int> processCounters = new Dictionary<string, int>(size); for (int i = 0; i < size; i++) { Process newProc = newnewProcesses[i].ClearConstant(constMapping); if (newProc is IndexInterleave) { List<Process> processes = (newProc as IndexInterleave).Processes; foreach (var processe in processes) { string tmp = processe.ProcessID; if (!processCounters.ContainsKey(tmp)) { newProceses.Add(processe); processCounters.Add(tmp, 1); } else { processCounters[tmp] = processCounters[tmp] + 1; } } } else if (newProc is IndexInterleaveAbstract) { IndexInterleaveAbstract intAbs = newProc as IndexInterleaveAbstract; foreach (var processe in intAbs.Processes) { string tmp = processe.ProcessID; if (!processCounters.ContainsKey(tmp)) { newProceses.Add(processe); processCounters.Add(tmp, intAbs.ProcessesActualSize[tmp]); } else { processCounters[tmp] = processCounters[tmp] + intAbs.ProcessesCounter[tmp]; } } } else { if (!processCounters.ContainsKey(newProc.ProcessID)) { newProceses.Add(newProc); processCounters.Add(newProc.ProcessID, 1); } else { processCounters[newProc.ProcessID] = processCounters[newProc.ProcessID] + 1; } } } foreach (KeyValuePair<string, int> pair in processCounters) { if (pair.Value > 1 || pair.Value == -1) { IndexInterleaveAbstract toReturn = new IndexInterleaveAbstract(newProceses, processCounters); toReturn.ProcessesActualSize = new Dictionary<string, int>(processCounters); return toReturn; } } return new IndexInterleave(newProceses); }
public override Process ClearConstant(Dictionary <string, Expression> constMapping) { List <Process> newProceses = new List <Process>(); if (Specification.IsParsing) { if (Processes == null) { return(new IndexInterleave(IndexedProcessDefinition.ClearConstant(constMapping))); } foreach (Process procese in Processes) { newProceses.Add(procese.ClearConstant(constMapping)); } return(new IndexInterleave(newProceses)); } List <Process> newnewProcesses = Processes; if (Processes == null) { //return new IndexInterleave(IndexedProcessDefinition.GetIndexedProcesses(constMapping)); newnewProcesses = IndexedProcessDefinition.GetIndexedProcesses(constMapping); } int size = newnewProcesses.Count; Dictionary <string, int> processCounters = new Dictionary <string, int>(size); for (int i = 0; i < size; i++) { Process newProc = newnewProcesses[i].ClearConstant(constMapping); if (newProc is IndexInterleave) { List <Process> processes = (newProc as IndexInterleave).Processes; foreach (var processe in processes) { string tmp = processe.ProcessID; if (!processCounters.ContainsKey(tmp)) { newProceses.Add(processe); processCounters.Add(tmp, 1); } else { processCounters[tmp] = processCounters[tmp] + 1; } } } else if (newProc is IndexInterleaveAbstract) { IndexInterleaveAbstract intAbs = newProc as IndexInterleaveAbstract; foreach (var processe in intAbs.Processes) { string tmp = processe.ProcessID; if (!processCounters.ContainsKey(tmp)) { newProceses.Add(processe); processCounters.Add(tmp, intAbs.ProcessesActualSize[tmp]); } else { processCounters[tmp] = processCounters[tmp] + intAbs.ProcessesCounter[tmp]; } } } else { if (!processCounters.ContainsKey(newProc.ProcessID)) { newProceses.Add(newProc); processCounters.Add(newProc.ProcessID, 1); } else { processCounters[newProc.ProcessID] = processCounters[newProc.ProcessID] + 1; } } } foreach (KeyValuePair <string, int> pair in processCounters) { if (pair.Value > 1 || pair.Value == -1) { IndexInterleaveAbstract toReturn = new IndexInterleaveAbstract(newProceses, processCounters); toReturn.ProcessesActualSize = new Dictionary <string, int>(processCounters); return(toReturn); } } return(new IndexInterleave(newProceses)); }
public override Process ClearConstant(Dictionary<string, Expression> constMapping) { int size = Processes.Count; List<Process> newProceses = new List<Process>(size); Dictionary<string, int> processCounters = new Dictionary<string, int>(size); IndexInterleaveAbstract interleaveAbstract = null; if (Specification.IsParsing) { if (ProcessesCounter == null) { return new IndexInterleaveAbstract(Processes[0].ClearConstant(constMapping), RangeExpression.ClearConstant(constMapping)); } for (int i = 0; i < Processes.Count; i++) { int outer = ProcessesCounter[Processes[i].ProcessID]; Process newProc = Processes[i].ClearConstant(constMapping); string temp = newProc.ProcessID; if (!processCounters.ContainsKey(temp)) { newProceses.Add(newProc); processCounters.Add(temp, outer); } else { if (processCounters[temp] != -1) { processCounters[temp] = processCounters[temp] + outer; } } } interleaveAbstract = new IndexInterleaveAbstract(newProceses, processCounters); interleaveAbstract.ProcessesActualSize = new Dictionary<string, int>(processCounters); return interleaveAbstract; } //clear constant must be side effect free Dictionary<string, int> newProcessesCounter = ProcessesCounter; // Dictionary<string, int> newProcessesActualSize = ProcessesActualSize; if (ProcessesCounter == null) { Expression val = RangeExpression.ClearConstant(constMapping); size = (EvaluatorDenotational.Evaluate(val, null) as IntConstant).Value; if (size == 0) { return new Skip(); } else if (size < 0) { throw new ParsingException("Negative range " + size + " for parameterized interleave: " + RangeExpression, 0, 0, RangeExpression.ToString()); } newProcessesCounter = new Dictionary<string, int>(); newProcessesCounter.Add(Processes[0].ProcessID, size); } for (int i = 0; i < Processes.Count; i++) { int outer = newProcessesCounter[Processes[i].ProcessID]; Process newProc = Processes[i].ClearConstant(constMapping); if (newProc is IndexInterleave) { List<Process> processes = (newProc as IndexInterleave).Processes; for (int j = 0; j < processes.Count; j++) { string temp = processes[j].ProcessID; if (!processCounters.ContainsKey(temp)) { processCounters.Add(temp, outer); newProceses.Add(processes[j]); } else { if (processCounters[temp] != -1) { processCounters[temp] = processCounters[temp] + outer; } } } } else if (newProc is IndexInterleaveAbstract) { IndexInterleaveAbstract intAbs = newProc as IndexInterleaveAbstract; for (int j = 0; j < intAbs.Processes.Count; j++) { string temp = intAbs.Processes[j].ProcessID; int inner = intAbs.ProcessesCounter[temp]; if (!processCounters.ContainsKey(temp)) { newProceses.Add(intAbs.Processes[j]); if (outer != -1 && inner != -1) { processCounters.Add(temp, inner * outer); } else { processCounters.Add(temp, -1); } } else { if (processCounters[temp] != -1) { if (inner == -1 || outer == -1) { processCounters.Add(temp,-1); } else { processCounters[temp] = processCounters[temp] + outer*inner; } } } } } else { string temp = newProc.ProcessID; if (!processCounters.ContainsKey(temp)) { newProceses.Add(newProc); processCounters.Add(temp, outer); } else { if (processCounters[temp] != -1) { processCounters[temp] = processCounters[temp] + outer; } } } } interleaveAbstract = new IndexInterleaveAbstract(newProceses, processCounters); interleaveAbstract.ProcessesActualSize = new Dictionary<string, int>(processCounters); return interleaveAbstract; }
public override void SyncOutput(Valuation GlobalEnv, List<ConfigurationWithChannelData> list) { //List<ConfigurationWithChannelData> returnList = new List<ConfigurationWithChannelData>(); for (int i = 0; i < Processes.Count; i++) { Process process = Processes[i]; List<ConfigurationWithChannelData> list1 = new List<ConfigurationWithChannelData>(); process.SyncOutput(GlobalEnv, list1); if (list1.Count > 0) { List<Dictionary<string, int>> nextProcessCounters = Common.Classes.Ultility.Ultility.ProcessCounterDecrement(Common.Classes.Ultility.Ultility.CutNumber, ProcessesCounter, process.ProcessID, 1); for (int j = 0; j < list1.Count; j++) { Configuration step = list1[j]; foreach (Dictionary<string, int> ints in nextProcessCounters) { List<Process> newProcess = new List<Process>(Processes); Dictionary<string, int> listInstance = new Dictionary<string, int>(ints); AddOneProcess(newProcess, step.Process, listInstance); IndexInterleaveAbstract interleave = new IndexInterleaveAbstract(newProcess, listInstance); ConfigurationWithChannelData newStep = new ConfigurationWithChannelData(interleave, step.Event, step.DisplayName, step.GlobalEnv, step.IsDataOperation, list1[j].ChannelName, list1[j].Expressions); newStep.IsAtomic = step.IsAtomic; list.Add(newStep); } } } } //return returnList; }
public override void SyncInput(ConfigurationWithChannelData eStep, List<Configuration> list) { //List<Configuration> returnList = new List<Configuration>(); for (int i = 0; i < Processes.Count; i++) { Process process = Processes[i]; List<Configuration> list1 = new List<Configuration>(); process.SyncInput(eStep, list1); if (list1.Count > 0) { List<Dictionary<string, int>> nextProcessCounters = Common.Classes.Ultility.Ultility.ProcessCounterDecrement(Common.Classes.Ultility.Ultility.CutNumber, ProcessesCounter, process.ProcessID, 1); for (int j = 0; j < list1.Count; j++) { Configuration step = list1[j]; foreach (Dictionary<string, int> ints in nextProcessCounters) { List<Process> newProcess = new List<Process>(Processes); Dictionary<string, int> listInstance = new Dictionary<string, int>(ints); AddOneProcess(newProcess, step.Process, listInstance); IndexInterleaveAbstract interleave = new IndexInterleaveAbstract(newProcess, listInstance); step.Process = interleave; list.Add(step); } } } } //return returnList; }
public override void MoveOneStep(Valuation GlobalEnv, List<Configuration> list) { System.Diagnostics.Debug.Assert(list.Count == 0); int TerminationCount = 0; bool hasAtomicTermination = false; List<Dictionary<string, int>> nextProcessCounters = null; for (int i = 0; i < Processes.Count; i++) { Process process = Processes[i]; List<Configuration> list1 = new List<Configuration>(); process.MoveOneStep(GlobalEnv, list1); bool hasTermination = false; if (list1.Count> 0) { nextProcessCounters = Common.Classes.Ultility.Ultility.ProcessCounterDecrement(Common.Classes.Ultility.Ultility.CutNumber, ProcessesCounter, process.ProcessID, 1); } for (int j = 0; j < list1.Count; j++) { Configuration step = list1[j]; if (step.Event == Constants.TERMINATION) { hasTermination = true; if (step.IsAtomic) { hasAtomicTermination = true; } } else { foreach (Dictionary<string, int> ints in nextProcessCounters) { Dictionary<string, int> listInstance = new Dictionary<string, int>(ints); List<Process> newProcess = new List<Process>(Processes); AddOneProcess(newProcess, step.Process, listInstance); IndexInterleaveAbstract interleave = new IndexInterleaveAbstract(newProcess, listInstance); Configuration newStep = new Configuration(interleave, step.Event, step.DisplayName, step.GlobalEnv, step.IsDataOperation); newStep.IsAtomic = step.IsAtomic; if (AssertionBase.CalculateParticipatingProcess) { newStep.ParticipatingProcesses = new string[] { process.ProcessID }; } list.Add(newStep); } } } if (hasTermination) { TerminationCount++; } //to check whether there are synchoronous channel input/output if (Specification.HasSyncrhonousChannel) { SynchronousChannelInputOutput(list, i, GlobalEnv, null); } } if (TerminationCount == Processes.Count) { Configuration temp = new Configuration(new Stop(), Constants.TERMINATION, null, GlobalEnv, false); if(hasAtomicTermination) { temp.IsAtomic = true; } if (AssertionBase.CalculateParticipatingProcess) { temp.ParticipatingProcesses = new string[Processes.Count]; for (int i = 0; i < Processes.Count; i++) { temp.ParticipatingProcesses[i] = i.ToString(); } } list.Add(temp); } //return returnList; }
public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list) { System.Diagnostics.Debug.Assert(list.Count == 0); int TerminationCount = 0; bool hasAtomicTermination = false; List <Dictionary <string, int> > nextProcessCounters = null; for (int i = 0; i < Processes.Count; i++) { Process process = Processes[i]; List <Configuration> list1 = new List <Configuration>(); process.MoveOneStep(GlobalEnv, list1); bool hasTermination = false; if (list1.Count > 0) { nextProcessCounters = Common.Classes.Ultility.Ultility.ProcessCounterDecrement(Common.Classes.Ultility.Ultility.CutNumber, ProcessesCounter, process.ProcessID, 1); } for (int j = 0; j < list1.Count; j++) { Configuration step = list1[j]; if (step.Event == Constants.TERMINATION) { hasTermination = true; if (step.IsAtomic) { hasAtomicTermination = true; } } else { foreach (Dictionary <string, int> ints in nextProcessCounters) { Dictionary <string, int> listInstance = new Dictionary <string, int>(ints); List <Process> newProcess = new List <Process>(Processes); AddOneProcess(newProcess, step.Process, listInstance); IndexInterleaveAbstract interleave = new IndexInterleaveAbstract(newProcess, listInstance); Configuration newStep = new Configuration(interleave, step.Event, step.DisplayName, step.GlobalEnv, step.IsDataOperation); newStep.IsAtomic = step.IsAtomic; if (AssertionBase.CalculateParticipatingProcess) { newStep.ParticipatingProcesses = new string[] { process.ProcessID }; } list.Add(newStep); } } } if (hasTermination) { TerminationCount++; } //to check whether there are synchoronous channel input/output if (Specification.HasSyncrhonousChannel) { SynchronousChannelInputOutput(list, i, GlobalEnv, null); } } if (TerminationCount == Processes.Count) { Configuration temp = new Configuration(new Stop(), Constants.TERMINATION, null, GlobalEnv, false); if (hasAtomicTermination) { temp.IsAtomic = true; } if (AssertionBase.CalculateParticipatingProcess) { temp.ParticipatingProcesses = new string[Processes.Count]; for (int i = 0; i < Processes.Count; i++) { temp.ParticipatingProcesses[i] = i.ToString(); } } list.Add(temp); } //return returnList; }
public override Process ClearConstant(Dictionary <string, Expression> constMapping) { int size = Processes.Count; List <Process> newProceses = new List <Process>(size); Dictionary <string, int> processCounters = new Dictionary <string, int>(size); IndexInterleaveAbstract interleaveAbstract = null; if (Specification.IsParsing) { if (ProcessesCounter == null) { return(new IndexInterleaveAbstract(Processes[0].ClearConstant(constMapping), RangeExpression.ClearConstant(constMapping))); } for (int i = 0; i < Processes.Count; i++) { int outer = ProcessesCounter[Processes[i].ProcessID]; Process newProc = Processes[i].ClearConstant(constMapping); string temp = newProc.ProcessID; if (!processCounters.ContainsKey(temp)) { newProceses.Add(newProc); processCounters.Add(temp, outer); } else { if (processCounters[temp] != -1) { processCounters[temp] = processCounters[temp] + outer; } } } interleaveAbstract = new IndexInterleaveAbstract(newProceses, processCounters); interleaveAbstract.ProcessesActualSize = new Dictionary <string, int>(processCounters); return(interleaveAbstract); } //clear constant must be side effect free Dictionary <string, int> newProcessesCounter = ProcessesCounter; // Dictionary<string, int> newProcessesActualSize = ProcessesActualSize; if (ProcessesCounter == null) { Expression val = RangeExpression.ClearConstant(constMapping); size = (EvaluatorDenotational.Evaluate(val, null) as IntConstant).Value; if (size == 0) { return(new Skip()); } else if (size < 0) { throw new ParsingException("Negative range " + size + " for parameterized interleave: " + RangeExpression, 0, 0, RangeExpression.ToString()); } newProcessesCounter = new Dictionary <string, int>(); newProcessesCounter.Add(Processes[0].ProcessID, size); } for (int i = 0; i < Processes.Count; i++) { int outer = newProcessesCounter[Processes[i].ProcessID]; Process newProc = Processes[i].ClearConstant(constMapping); if (newProc is IndexInterleave) { List <Process> processes = (newProc as IndexInterleave).Processes; for (int j = 0; j < processes.Count; j++) { string temp = processes[j].ProcessID; if (!processCounters.ContainsKey(temp)) { processCounters.Add(temp, outer); newProceses.Add(processes[j]); } else { if (processCounters[temp] != -1) { processCounters[temp] = processCounters[temp] + outer; } } } } else if (newProc is IndexInterleaveAbstract) { IndexInterleaveAbstract intAbs = newProc as IndexInterleaveAbstract; for (int j = 0; j < intAbs.Processes.Count; j++) { string temp = intAbs.Processes[j].ProcessID; int inner = intAbs.ProcessesCounter[temp]; if (!processCounters.ContainsKey(temp)) { newProceses.Add(intAbs.Processes[j]); if (outer != -1 && inner != -1) { processCounters.Add(temp, inner * outer); } else { processCounters.Add(temp, -1); } } else { if (processCounters[temp] != -1) { if (inner == -1 || outer == -1) { processCounters.Add(temp, -1); } else { processCounters[temp] = processCounters[temp] + outer * inner; } } } } } else { string temp = newProc.ProcessID; if (!processCounters.ContainsKey(temp)) { newProceses.Add(newProc); processCounters.Add(temp, outer); } else { if (processCounters[temp] != -1) { processCounters[temp] = processCounters[temp] + outer; } } } } interleaveAbstract = new IndexInterleaveAbstract(newProceses, processCounters); interleaveAbstract.ProcessesActualSize = new Dictionary <string, int>(processCounters); return(interleaveAbstract); }