@PluginVariant(
      requiredParameterLabels = {0, 1, 2},
      variantLabel = "PerformanceDetailsSettings")
  // @UITopiaVariant(affiliation = "Department of Computer Science University of Pisa", author =
  // "R.Guanciale,G.Spagnolo et al.", email = "*****@*****.**", pack =
  // "PetriNetReplayAnalysis")
  public TotalPerformanceResult getPerformanceDetails(
      PluginContext context, XLog log, Petrinet net, ReplayFitnessSetting setting) {

    Marking marking;

    try {
      InitialMarkingConnection connection =
          context
              .getConnectionManager()
              .getFirstConnection(InitialMarkingConnection.class, context, net);
      marking = connection.getObjectWithRole(InitialMarkingConnection.MARKING);
    } catch (ConnectionCannotBeObtained ex) {
      context.log("Petri net lacks initial marking");
      context.getFutureResult(0).cancel(true);
      return null;
    }

    map = null;
    return getPerformanceDetails(
        context, log, net, setting, marking, XLogInfoImpl.STANDARD_CLASSIFIER);
  }
Пример #2
0
  @Plugin(
      name = "Generate serialization updating object",
      level = PluginLevel.Local,
      parameterLabels = {},
      returnLabels = {"Test object"},
      returnTypes = {RefObject.class},
      userAccessible = true)
  @UITopiaVariant(
      affiliation = UITopiaVariant.EHV,
      author = "B.F. van Dongen",
      email = "*****@*****.**")
  public static Object testUpdating(PluginContext context) throws InterruptedException {
    String s = "Test object " + i++;
    context.getFutureResult(0).setLabel(s);

    RefObject o = new RefObject(null, s);

    ProvidedObjectID id =
        context.getProvidedObjectManager().createProvidedObject("Updating test object", o, context);
    int n = 15;
    context.getProgress().setMaximum(n);
    for (int j = 0; j < n; j++) {
      s = "Test object " + i++;
      try {
        o = new RefObject(new RefObject(o.ref, "Reference to o"), s);
        context.getProvidedObjectManager().changeProvidedObjectObject(id, o);
      } catch (ProvidedObjectDeletedException e) {
        break;
      }
      Thread.sleep(3000);
      context.getProgress().inc();
    }
    s = "Test object " + i++;
    return new RefObject(o, s);
  }
  @Plugin(
      name = "Add End Artificial Events",
      parameterLabels = {"Log"},
      returnLabels = {"Altered log"},
      returnTypes = {XLog.class},
      userAccessible = true,
      help = "Adds an artificial  end task to every trace in the log file")
  @UITopiaVariant(
      affiliation = "Department of Computer Science University of Pisa",
      author = "R.Guanciale,G.Spagnolo et al.",
      email = "*****@*****.**",
      pack = "PetriNetReplayAnalysis")
  public XLog addEvents(PluginContext context, XLog oldLog) {

    context.getFutureResult(0).setLabel(XConceptExtension.instance().extractName(oldLog));

    context.getProgress().setMinimum(0);
    context.getProgress().setMaximum(oldLog.size());
    context.getProgress().setIndeterminate(false);
    context.getProgress().setValue(0);

    XAttributeMap logattlist = copyAttMap(oldLog.getAttributes());
    XLog newLog = new XLogImpl(logattlist);
    for (int i = 0; i < oldLog.size(); i++) {
      XTrace oldTrace = oldLog.get(i);
      XTrace newTrace = new XTraceImpl(copyAttMap(oldTrace.getAttributes()));
      for (int j = 0; j < oldTrace.size(); j++) {
        XEvent oldEvent = oldTrace.get(j);
        XEvent newEvent = new XEventImpl(copyAttMap(oldEvent.getAttributes()));
        newTrace.add(newEvent);
      }

      Date time = new Date();
      try {
        time =
            ((XAttributeTimestampImpl)
                    oldTrace.get(oldTrace.size() - 1).getAttributes().get("time:timestamp"))
                .getValue();
        time.setTime(time.getTime() + 1);
      } catch (Exception ex) {
      }

      newTrace.add(makeEvent("ArtificialEnd", time));

      newLog.add(newTrace);
      context.getProgress().inc();
    }
    return newLog;
  }
Пример #4
0
  @Plugin(
      name = "Remove edgepoints",
      parameterLabels = {"graph"},
      returnLabels = {},
      returnTypes = {},
      userAccessible = true,
      mostSignificantResult = -1)
  @UITopiaVariant(
      affiliation = UITopiaVariant.EHV,
      author = "B.F. van Dongen",
      email = "*****@*****.**")
  @SuppressWarnings("rawtypes")
  public static void removeEdgePoints(PluginContext context, Object graph)
      throws ConnectionCannotBeObtained {
    GraphLayoutConnection conn =
        context
            .getConnectionManager()
            .getFirstConnection(GraphLayoutConnection.class, context, graph);

    if (graph instanceof DirectedGraph) {
      DirectedGraph<?, ?> g = (DirectedGraph) graph;
      for (DirectedGraphEdge edge : g.getEdges()) {
        conn.setEdgePoints(edge, new ArrayList<Point2D>(0));
      }

      conn.updated();
    } else if (graph instanceof UndirectedGraph) {
      UndirectedGraph<?, ?> g = (UndirectedGraph) graph;
      for (UndirectedGraphEdge edge : g.getEdges()) {
        conn.setEdgePoints(edge, new ArrayList<Point2D>(0));
      }

      conn.updated();
    }
  }
Пример #5
0
 @Plugin(
     name = "Generate referencing test object",
     level = PluginLevel.Local,
     parameterLabels = {"References Object"},
     returnLabels = {"Test object"},
     returnTypes = {RefObject.class},
     userAccessible = true)
 @UITopiaVariant(
     affiliation = UITopiaVariant.EHV,
     author = "B.F. van Dongen",
     email = "*****@*****.**")
 public static Object testSerialization(PluginContext context, final RefObject toReference) {
   final String s = "Test object " + i++;
   context.getFutureResult(0).setLabel(s + " referencing: " + toReference.toString());
   return new RefObject(toReference, s);
 }
  @PluginVariant(
      requiredParameterLabels = {0, 1, 2, 3},
      variantLabel = "PerformanceDetailsSettingsWithMarking")
  // @Plugin(name = "PerformanceDetailsSettingsWithMarking", returnLabels = { "Performance Total" },
  // returnTypes = { TotalPerformanceResult.class }, parameterLabels = {}, userAccessible = true)
  // @UITopiaVariant(affiliation = "Department of Computer Science University of Pisa", author =
  // "R.Guanciale,G.Spagnolo et al.", email = "*****@*****.**", pack =
  // "PetriNetReplayAnalysis")
  public TotalPerformanceResult getPerformanceDetails(
      PluginContext context,
      XLog log,
      Petrinet net,
      ReplayFitnessSetting setting,
      Marking marking,
      XEventClassifier classif) {

    TotalPerformanceResult performance = new TotalPerformanceResult();

    XEventClasses classes = getEventClasses(log, classif);
    if (map == null) {
      // Map<Transition, XEventClass>
      map = getMapping(classes, net);
    }

    context
        .getConnectionManager()
        .addConnection(new LogPetrinetConnectionImpl(log, classes, net, map));

    PetrinetSemantics semantics = PetrinetSemanticsFactory.regularPetrinetSemantics(Petrinet.class);

    Replayer<ReplayFitnessCost> replayer =
        new Replayer<ReplayFitnessCost>(
            context, net, semantics, map, ReplayFitnessCost.addOperator);

    int replayedTraces = 0;
    context.getProgress().setMinimum(0);
    context.getProgress().setMaximum(log.size());
    for (XTrace trace : log) {
      List<XEventClass> list = getList(trace, classes);
      try {
        System.out.println("Replay :" + replayedTraces);
        List<Transition> sequence;

        sequence = replayer.replayTrace(marking, list, setting);
        if (sequence != null) {
          sequence = sortHiddenTransection(net, sequence, map);
          String tracename = getTraceName(trace);
          updatePerformance(net, marking, sequence, semantics, trace, performance, map, tracename);
          replayedTraces++;
          context.getProgress().inc();
          System.out.println("Replayed");
        }

      } catch (Exception ex) {
        System.out.println("Failed");
        context.log("Replay of trace " + trace + " failed: " + ex.getMessage());
      }
    }

    context.log(
        "(based on a successful replay of "
            + replayedTraces
            + " out of "
            + log.size()
            + " traces)");

    ReplayAnalysisConnection connection = new ReplayAnalysisConnection(performance, log, net);
    context.getConnectionManager().addConnection(connection);

    return performance;
  }
  @Plugin(
      name = "Show Transition System",
      returnLabels = {"Visualization for Transition System"},
      returnTypes = {JComponent.class},
      parameterLabels = {"Transition System"},
      userAccessible = false)
  @Visualizer
  public JComponent visualize(PluginContext context, TransitionSystem ts) {
    /** Will hold the weights, start states, and accept states. */
    DirectedGraphElementWeights weights = new DirectedGraphElementWeights();
    StartStateSet starts = new StartStateSet();
    AcceptStateSet accepts = new AcceptStateSet();

    /** 1. Tries to get connected transition weights from the framework. */
    ConnectionManager cm = context.getConnectionManager();
    try {
      //			System.out.println("Checking for connection");
      TransitionSystemConnection tsc =
          cm.getFirstConnection(TransitionSystemConnection.class, context, ts);
      //			System.out.println("Checked for connection: " + settings);
      if (tsc.hasWeights()) {
        weights = tsc.getObjectWithRole(TransitionSystemConnection.WEIGHTS);
      }
      starts = tsc.getObjectWithRole(TransitionSystemConnection.STARTIDS);
      accepts = tsc.getObjectWithRole(TransitionSystemConnection.ACCEPTIDS);

    } catch (ConnectionCannotBeObtained e) {
      /** No connected transition weights found, no problem. */
    }

    /** 2. Based on the connected objects found: updates visualization. */
    if (!weights.isEmpty()) {
      /**
       * Set the line widths according to the weights. To avoid getting ridiculous line widths:
       * linewidth=ln(weight).
       */
      for (State state : ts.getNodes()) {
        state
            .getAttributeMap()
            .put(
                AttributeMap.LINEWIDTH,
                new Float(1 + Math.log(Math.E) * Math.log(weights.get(state.getIdentifier(), 1))));
      }
      for (Transition trans : ts.getEdges()) {
        trans
            .getAttributeMap()
            .put(
                AttributeMap.LINEWIDTH,
                new Float(
                    1
                        + Math.log(Math.E)
                            * Math.log(
                                weights.get(
                                    trans.getSource().getIdentifier(),
                                    trans.getTarget().getIdentifier(),
                                    trans.getIdentifier(),
                                    1))));
      }
    }
    if (!starts.isEmpty() || !accepts.isEmpty()) {
      for (State state : ts.getNodes()) {

        /** Note that, in fact, the set of start states is the the set of start state ids. */
        if (starts.contains(state.getIdentifier())) {
          /** This state is a start state. */
          state.getAttributeMap().put(AttributeMap.DASHPATTERN, INITIAL_DASH_PATTERN);
        }
        if (accepts.contains(state.getIdentifier())) {
          /** This state is an accept state. */
          state.setAccepting(true);
        }
      }
    }

    mainPanel = ProMJGraphVisualizer.instance().visualizeGraph(context, ts);
    return mainPanel;
  }