> order, final boolean sameTransitionCutOff) {
// by comparing the hashmaps we check simultaneously if they have the same marking (set of keys of the map)
if (sameTransitionCutOff && !getTransition().equals(companionCandidate.getTransition())) {
return false;
}
if (order.compare(companionCandidate, this) >= 0) {
return false;
}
if (!companionCandidate.getPlaceCorelationMap().equals(getPlaceCorelationMap())) {
return false;
}
setCompanion(companionCandidate);
return true;
}
/**
* #Backfolding
*
* Map m such that for each {@link Condition} c in the local configuration of this {@link Event} the map contains
* the pair (c.getPlace(),bp.getCoRelatedPlaces(c)). p> TODO Find a nice name for this map or find a view that is
* easy to understand
*/
public void computePlaceCorelationMap(final BranchingProcess bp) {
for (final Condition c : getConditionMark()) {
mPlaceCorelationMap.put(c.getPlace(), bp.computeCoRelatedPlaces(c));
}
}
/**
* set this.companion to e, or, if e is a cut-off event itself to the companion of e.
*/
public void setCompanion(final Event event) {
assert mCompanion == null;
if (event.getCompanion() == null) {
mCompanion = event;
event.makeCompanionOf(this);
} else {
setCompanion(event.getCompanion());
}
}
public void makeCompanionOf(final Event event) {
mIsCompanion = true;
mIsCompanionToCutoffEventsSet.add(event);
}
public boolean isCompanion() {
return mIsCompanion;
}
public Set> getCutoffEventsThisIsCompanionTo() {
return mIsCompanionToCutoffEventsSet;
}
/**
* @return {@code true} iff the event is a cutoff event. requires, that
* {@link #checkCutOffSetCompanion(Event, Comparator)} was called.
*
* In the implementation of the construction of the unfolding, it is called after being added to a the
* Branchinprocess.
* @see BranchingProcess#isCutoffEvent(Event, Comparator)
*/
public boolean isCutoffEvent() {
return mCompanion != null;
}
/**
* @return The size of the local configuration, that is the number of ancestor events.
*/
public int getAncestors() {
return mLocalConfiguration.size();
}
public Configuration getLocalConfiguration() {
return mLocalConfiguration;
}
public boolean conditionMarkContains(final Condition c) {
return mConditionMark.contains(c);
}
public Event getCompanion() {
return mCompanion;
}
public Transition getTransition() {
return mTransition;
}
public int getSerialNumber() {
return mSerialNumber;
}
public int getTotalOrderId() {
return mTransition.getTotalOrderId();
}
@Override
public String toString() {
if (mSerialNumber == 0) {
return "Dummy event whose successors are the initial conditions of the branching process";
} else {
return mSerialNumber + ":" + +mLocalConfiguration.size() + "A:" + getTransition().toString();
}
}
@Override
public int hashCode() {
return mHashCode;
}
@Override
public boolean equals(final Object obj) {
// We intentionally use reference equality here:
// - An efficient equality check is crucial for unfolding performance; comparing sets of conditions is too slow.
// - The unfolding should never create two instances representing "equal" events.
return this == obj;
}
}