Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ocpa/algo/conformance/alignments/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ def create_all_transitions(ocpn: ObjectCentricPetriNet,
signature_in[in_arc.source.object_type] += 1

# add signature to transition
model_move = UndefinedModelMove(model_move=transition.name, objects=None, silent=transition.silent)
set_properties_of_transition(new_transition, TransitionSignature(transition.name, signature_in,
model_move = UndefinedModelMove(model_move=transition.label, objects=None, silent=transition.silent)
set_properties_of_transition(new_transition, TransitionSignature(transition.label, signature_in,
signature_in, model_move))
# trans_prop = get_properties_of_transition(new_transition)
# #print(f"Transitions property: {get_properties_of_transition(new_transition)}")
Expand Down Expand Up @@ -381,8 +381,8 @@ def preprocessing_dejure_net(ocel: OCEL, indirect_id, ocpn):
card_signature_in.setdefault(in_arc.source.object_type, 0)
card_signature_in[in_arc.source.object_type] += 1

model_move = UndefinedModelMove(model_move=transition.name, objects=None, silent=transition.silent)
set_properties_of_transition(transition, TransitionSignature(transition.name, card_signature_in,
model_move = UndefinedModelMove(model_move=transition.label, objects=None, silent=transition.silent)
set_properties_of_transition(transition, TransitionSignature(transition.label, card_signature_in,
card_signature_in, model_move))
continue

Expand Down
72 changes: 48 additions & 24 deletions ocpa/objects/oc_petri_net/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,27 @@ def __hash__(self):
def __deepcopy__(self, memodict={}):
if id(self) in memodict:
return memodict[id(self)]
new_place = ObjectCentricPetriNet.Place(
self.name, self.object_type)

name = getattr(self, "name", None)
object_type = getattr(self, "object_type", None)
initial = getattr(self, "initial", False)
final = getattr(self, "final", False)

# copy initial and final flags as well
new_place = self.__class__(name, object_type, initial=initial, final=final)
# copy properties if they exist
if hasattr(self, 'properties'):
try:
setattr(new_place, 'properties', deepcopy(getattr(self, 'properties'), memo=memodict))
except Exception:
setattr(new_place, 'properties', getattr(self, 'properties'))
memodict[id(self)] = new_place
for arc in self.in_arcs:
new_arc = deepcopy(arc, memo=memodict)
new_place.in_arcs.add(new_arc)
for arc in self.out_arcs:
new_arc = deepcopy(arc, memo=memodict)
new_place.out_arcs.add(new_arc)

# Init in_arcs and out_arcs if they do not exist
# No longer attach arcs during deepcopy of place,
# do it when deepcopying the arcs instead to remove duplicated arcs
if not hasattr(new_place, "in_arcs"): new_place.in_arcs = set()
if not hasattr(new_place, "out_arcs"): new_place.out_arcs = set()
return new_place

object_type = property(__get_object_type)
Expand Down Expand Up @@ -186,15 +198,20 @@ def __hash__(self):
def __deepcopy__(self, memodict={}):
if id(self) in memodict:
return memodict[id(self)]
new_trans = ObjectCentricPetriNet.Transition(
self.name, self.label, properties=self.properties)

name = getattr(self, "name", None)
label = getattr(self, "label", None)
properties = getattr(self, "properties", None)
silent = getattr(self, "silent", False)

# copy silent flag as well
new_trans = self.__class__(name, label, properties=properties, silent=silent)
memodict[id(self)] = new_trans
for arc in self.in_arcs:
new_arc = deepcopy(arc, memo=memodict)
new_trans.in_arcs.add(new_arc)
for arc in self.out_arcs:
new_arc = deepcopy(arc, memo=memodict)
new_trans.out_arcs.add(new_arc)

# No longer attach arcs during deepcopy of transition,
# do it when deepcopying the arcs instead to remove duplicated arcs
if not hasattr(new_trans, "in_arcs"): new_trans.in_arcs = set()
if not hasattr(new_trans, "out_arcs"): new_trans.out_arcs = set()
return new_trans

def to_dict(self):
Expand Down Expand Up @@ -272,15 +289,22 @@ def __eq__(self, other):
def __deepcopy__(self, memodict={}):
if id(self) in memodict:
return memodict[id(self)]
new_source = memodict[id(self.source)] if id(self.source) in memodict else deepcopy(self.source,
memo=memodict)
new_target = memodict[id(self.target)] if id(self.target) in memodict else deepcopy(self.target,
memo=memodict)
memodict[id(self.source)] = new_source
memodict[id(self.target)] = new_target
new_arc = ObjectCentricPetriNet.Arc(
new_source, new_target, weight=self.weight, properties=self.properties)

new_source = deepcopy(getattr(self, "source", None), memo=memodict)
new_target = deepcopy(getattr(self, "target", None), memo=memodict)

weight = getattr(self, "weight", 1)
variable = getattr(self, "variable", False)
properties = getattr(self, "properties", None)

new_arc = self.__class__(new_source, new_target, weight=weight, variable=variable, properties=properties)
memodict[id(self)] = new_arc

# Attach the new arc to the new source and target
if hasattr(new_source, "out_arcs"):
new_source.out_arcs.add(new_arc)
if hasattr(new_target, "in_arcs"):
new_target.in_arcs.add(new_arc)
return new_arc

def to_dict(self):
Expand Down