public PNTransition ClearConstant(List <PNPlace> newPNPlaces, Dictionary <string, Expression> constMapping, bool checkSelect) { ParallelDefinition[] newSelects = null; if (checkSelect && Selects != null) { newSelects = new ParallelDefinition[Selects.Length]; for (int i = 0; i < Selects.Length; i++) { newSelects[i] = newSelects[i].ClearConstant(constMapping); } } PNPlace newFrom = null, newTo = null; foreach (PNPlace PNPlace in newPNPlaces) { if (PNPlace.Name == FromPNPlace.Name) { newFrom = PNPlace; } if (PNPlace.Name == ToPNPlace.Name) { newTo = PNPlace; } } return(new PNTransition(Event.ClearConstant(constMapping), newSelects, GuardCondition == null ? GuardCondition : GuardCondition.ClearConstant(constMapping), ProgramBlock == null ? ProgramBlock : ProgramBlock.ClearConstant(constMapping), newFrom, newTo)); }
public List <Process> GetIndexedProcesses(Dictionary <string, Expression> constMapping) { List <ParallelDefinition> newDefinitions = new List <ParallelDefinition>(); foreach (ParallelDefinition definition in Definitions) { ParallelDefinition newPD = definition.ClearConstant(constMapping); newDefinitions.Add(newPD); } List <Process> processes = new List <Process>(16); foreach (ParallelDefinition pd in newDefinitions) { pd.DomainValues.Sort(); } List <List <Expression> > list = new List <List <Expression> >(); foreach (int v in newDefinitions[0].DomainValues) { List <Expression> l = new List <Expression>(newDefinitions.Count); l.Add(new IntConstant(v)); list.Add(l); } for (int i = 1; i < newDefinitions.Count; i++) { List <List <Expression> > newList = new List <List <Expression> >(); List <int> domain = newDefinitions[i].DomainValues; for (int j = 0; j < list.Count; j++) { foreach (int i1 in domain) { List <Expression> cList = new List <Expression>(list[j]); cList.Add(new IntConstant(i1)); newList.Add(cList); } } list = newList; } foreach (List <Expression> constants in list) { Dictionary <string, Expression> constMappingNew = new Dictionary <string, Expression>(constMapping); //Dictionary<string, Expression> constMappingNew = new Dictionary<string, Expression>(); for (int i = 0; i < constants.Count; i++) { Expression constant = constants[i]; if (constMappingNew.ContainsKey(newDefinitions[i].Parameter)) { constMappingNew[newDefinitions[i].Parameter] = constant; } else { constMappingNew.Add(newDefinitions[i].Parameter, constant); } } Process newProcess = Process.ClearConstant(constMappingNew); processes.Add(newProcess); } return(processes); }
public List <Transition> ClearConstantExtended(List <State> newStates, Dictionary <string, Expression> constMapping) { List <Transition> transitions = new List <Transition>(); if (Selects == null) { transitions.Add(ClearConstant(newStates, constMapping, false)); } else { List <ParallelDefinition> newDefinitions = new List <ParallelDefinition>(); foreach (ParallelDefinition definition in Selects) { ParallelDefinition newPD = definition.ClearConstant(constMapping); newDefinitions.Add(newPD); } foreach (ParallelDefinition pd in newDefinitions) { pd.DomainValues.Sort(); } List <List <Expression> > list = new List <List <Expression> >(); foreach (int v in newDefinitions[0].DomainValues) { List <Expression> l = new List <Expression>(newDefinitions.Count); l.Add(new IntConstant(v)); list.Add(l); } for (int i = 1; i < newDefinitions.Count; i++) { List <List <Expression> > newList = new List <List <Expression> >(); List <int> domain = newDefinitions[i].DomainValues; for (int j = 0; j < list.Count; j++) { foreach (int i1 in domain) { List <Expression> cList = new List <Expression>(list[j]); cList.Add(new IntConstant(i1)); newList.Add(cList); } } list = newList; } foreach (List <Expression> constants in list) { Dictionary <string, Expression> constMappingNew = new Dictionary <string, Expression>(constMapping); for (int i = 0; i < constants.Count; i++) { Expression constant = constants[i]; constMappingNew.Add(newDefinitions[i].Parameter, constant); } Transition newProcess = ClearConstant(newStates, constMappingNew, false); transitions.Add(newProcess); } } return(transitions); }
public List <DefinitionRef> GetIndexedDefRef(Dictionary <string, Expression> constMapping) { if (ContainedDefRefs == null) { return(null); } List <ParallelDefinition> newDefinitions = new List <ParallelDefinition>(); foreach (ParallelDefinition definition in Definitions) { ParallelDefinition newPD = definition.ClearConstant(constMapping); newDefinitions.Add(newPD); } List <DefinitionRef> processes = new List <DefinitionRef>(16); foreach (ParallelDefinition pd in newDefinitions) { pd.DomainValues.Sort(); } List <List <Expression> > list = new List <List <Expression> >(); foreach (int v in newDefinitions[0].DomainValues) { List <Expression> l = new List <Expression>(newDefinitions.Count); l.Add(new IntConstant(v)); list.Add(l); } for (int i = 1; i < newDefinitions.Count; i++) { List <List <Expression> > newList = new List <List <Expression> >(); List <int> domain = newDefinitions[i].DomainValues; for (int j = 0; j < list.Count; j++) { foreach (int i1 in domain) { List <Expression> cList = new List <Expression>(list[j]); cList.Add(new IntConstant(i1)); newList.Add(cList); } } list = newList; } foreach (List <Expression> constants in list) { //Dictionary<string, Expression> constMappingNew = new Dictionary<string, Expression>(constMapping); Dictionary <string, Expression> constMappingNew = new Dictionary <string, Expression>(); for (int i = 0; i < constants.Count; i++) { Expression constant = constants[i]; constMappingNew.Add(newDefinitions[i].Parameter, constant); } foreach (DefinitionRef containedDefRef in ContainedDefRefs) { DefinitionRef newProcess = containedDefRef.ClearConstant(constMappingNew) as DefinitionRef; processes.Add(newProcess); } } return(processes); }