/// <summary> /// Creates Synchronous net from the Petri net itself /// </summary> /// <param name="pNet">Petri net</param> /// <param name="modelMoveCost">Model move cost</param> public SynchronousProductNet(IPetriNet pNet, int modelMoveCost = 1) { StartPlaces.Add(pNet.StartPlace); EndPlaces.Add(pNet.EndPlace); Places = pNet.Places; PlacesToTransitions = Places.ToDictionary(p => p, p => new List <int>()); InitTransitionsFromPNet(pNet, modelMoveCost, true); }
/// <param name="tNet">Petri net of the trace</param> /// <param name="pNet">Petri net of the model</param> /// <param name="traceMoveCost">Trace move cost</param> /// <param name="modelMoveCost">Model move cost</param> public SynchronousProductNet(IPetriNet tNet, IPetriNet pNet, int traceMoveCost = 1, int modelMoveCost = 1) { StartPlaces.Add(tNet.StartPlace); StartPlaces.Add(pNet.StartPlace); EndPlaces.Add(tNet.EndPlace); EndPlaces.Add(pNet.EndPlace); Places.AddRange(tNet.Places.Union(pNet.Places)); PlacesToTransitions = Places.ToDictionary(p => p, p => new List <int>()); InitTransitionsFromPNet(tNet, traceMoveCost, false); InitTransitionsFromPNet(pNet, modelMoveCost, true); //Add transitions for synchronous move as cost 0 + addition to make all costs positive foreach (var t1 in tNet.Transitions) { foreach (var t2 in pNet.Transitions) { if (!t1.Activity.Equals(t2.Activity)) { continue; } var transition = new Transition($"({t1.Id},{t2.Id})", t1.Activity); transition.InputPlaces.AddRange(t1.InputPlaces.Union(t2.InputPlaces)); transition.OutputPlaces.AddRange(t1.OutputPlaces.Union(t2.OutputPlaces)); var syncTransition = new STransition(transition, 0); foreach (var place in transition.InputPlaces) { PlacesToTransitions[place].Add(Transitions.Count); } Transitions.Add(syncTransition); } } }