⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classification.java

📁 Petri网分析工具PIPE is open-source
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/** * Classification Module * @author James D Bloom 2003-03-12 * @author Maxim Gready 2004 * * This module was severly broken in the 2003 release. It should now be * producing correct results but is still being fixed up. *   */package pipe.modules.classification;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.ArrayList;import java.util.Arrays;import javax.swing.BoxLayout;import javax.swing.JDialog;import pipe.dataLayer.DataLayer;import pipe.dataLayer.Place;import pipe.dataLayer.Transition;import pipe.gui.CreateGui;import pipe.gui.widgets.ButtonBar;import pipe.gui.widgets.PetriNetChooserPanel;import pipe.gui.widgets.ResultsHTMLPane;import pipe.modules.Module;/** Classification class implements petri net classification */public class Classification implements Module {  private static final String MODULE_NAME = "Classification";  private PetriNetChooserPanel sourceFilePanel;  private ResultsHTMLPane results;    public void run(DataLayer pnmlData) {    // Build interface    JDialog guiDialog = new JDialog(CreateGui.getApp(),MODULE_NAME,true);        // 1 Set layout    Container contentPane=guiDialog.getContentPane();    contentPane.setLayout(new BoxLayout(contentPane,BoxLayout.PAGE_AXIS));        // 2 Add file browser    contentPane.add(sourceFilePanel=new PetriNetChooserPanel("Source net",pnmlData));        // 3 Add results pane    contentPane.add(results=new ResultsHTMLPane());        // 4 Add button    contentPane.add(new ButtonBar("Classify",classifyButtonClick));    // 5 Make window fit contents' preferred size    guiDialog.pack();        // 6 Move window to the middle of the screen    guiDialog.setLocationRelativeTo(null);        guiDialog.setVisible(true);  }  public String getName() {    return MODULE_NAME;  }    /**	 * Classify button click handler	 */  ActionListener classifyButtonClick=new ActionListener() {    public void actionPerformed(ActionEvent arg0) {      DataLayer sourceDataLayer=sourceFilePanel.getDataLayer();      String s="<h2>Petri net classification results</h2>";      if(sourceDataLayer==null) return;      if(!sourceDataLayer.getPetriNetObjects().hasNext()) s+="No Petri net objects defined!";      else s+=ResultsHTMLPane.makeTable(new String[]{                "State Machine"           ,""+stateMachine(sourceDataLayer),                "Marked Graph"            ,""+markedGraph(sourceDataLayer),                "Free Choice Net"         ,""+freeChoiceNet(sourceDataLayer),                "Extended Free Choice Net",""+extendedFreeChoiceNet(sourceDataLayer),                "Simple Net"              ,""+simpleNet(sourceDataLayer),                "Extended Simple Net"     ,""+extendedSimpleNet(sourceDataLayer)                              },2,false,true,false,true);      results.setText(s);    }  };    /**   * State machine detection   * @return <i>true</i> iff all transitions have at most one input or output   * SM iff &forall; t &isin; T: |&bull;t| = |t&bull;| &#8804; 1   * <pre>   * P - T - P   * P - T - P   true (one input/output each)   *   * P - T - P   *       \     false (>1 output)   *         P   *   * P - T - P   *   /         false (>1 input)   * P   * </pre>   * @author Maxim Gready after James D Bloom   */  protected boolean stateMachine(DataLayer pnmlData){    Transition[] transitions=pnmlData.getTransitions();    if (transitions!=null)      for (int transitionNo=0; transitionNo<transitions.length; transitionNo++)        if ((countTransitionInputs(pnmlData,transitionNo)>1)||(countTransitionOutputs(pnmlData,transitionNo)>1))          return false;    return true;  }  /**   * Marked graph detection   * @return true iff all places have at most one input or output   * MG iff &forall; p &isin; P: |&bull;p| = |t&bull;| &#8804; 1   * <pre>   * T - P - T   * T - P - T   true (one input/output each)   *   * T - P - T   *       \     false (>1 output)   *         T   *   * T - P - T   *   /         false (>1 input)   * T   * </pre>   * @author Maxim Gready after James D Bloom   */  protected boolean markedGraph(DataLayer pnmlData){    Place[] places=pnmlData.getPlaces();    if (places!=null)      for (int placeNo=0; placeNo<places.length; placeNo++)        if ((countPlaceInputs(pnmlData,placeNo)>1)||(countPlaceOutputs(pnmlData,placeNo)>1))          return false;    return true;  }  /**   * Free choice net detection   * @return true iff no places' outputs go to the same transition, unless those places both have only one output   * FC-net iff &forall; p, p&prime; &isin; P: p &#x2260; p&prime; &#x21d2; (p&bull;&#x2229;p&prime;&bull; = 0 or |p&bull;| = |p&prime;&bull;| &#8804; 1)   * <pre>   * P - T   * P - T       true (no common outputs)   *   \   *     T   *   * P - T   *   /         true (common outputs but both have only one output)   * P   *   * P - T   *   X   * P - T       false (common outputs, both have >1 output)   *   * P - T   *   /   * P - T       false (common outputs but one has >1 output)   * </pre>   * @author Maxim Gready after James D Bloom   */  protected boolean freeChoiceNet(DataLayer pnmlData){    Place[] places=pnmlData.getPlaces();    int[] fps1,fps2; // forwards place sets for p and p'    if (places!=null)      for (int placeNo=0; placeNo<places.length; placeNo++)        for (int placeDashNo=placeNo+1; placeDashNo<places.length;placeDashNo++) {          fps1=forwardsPlaceSet(pnmlData,placeNo);          fps2=forwardsPlaceSet(pnmlData,placeDashNo);          if (intersectionBetweenSets(fps1,fps2) && ((fps1.length>1) || (fps2.length>1))) {            return false;          }        }    return true;  }  /**   * Extended free choice net detection   * @return true iff no places' outputs go to the same transition, unless both places outputs are identical   * EFC-net iff &forall; p, p&prime; &isin; P: p &#x2260; p&prime; &#x21d2; (p&bull;&#x2229;p&prime;&bull; = 0 or p&bull; = p&prime;&bull;)   * <pre>   * P - T   * P - T       Yes (no common outputs)   *   \   *     T   *   * P - T   *   /   * P - T       No (common outputs, outputs not identical)   *   * P - T   *   X   * P - T       Yes (common outputs identical) *** only addition to normal free choice net   *   * P - T       Yes (common outputs identical)   *   /   * P   * </pre>   * @author Maxim Gready after James D Bloom   */  protected boolean extendedFreeChoiceNet(DataLayer pnmlData){    Place[] places=pnmlData.getPlaces();    int[] fps1,fps2; // forwards place sets for p and p'    if (places!=null)      for (int placeNo=0; placeNo<places.length; placeNo++)        for (int placeDashNo=placeNo+1; placeDashNo<places.length;placeDashNo++) {          fps1=forwardsPlaceSet(pnmlData,placeNo);          fps2=forwardsPlaceSet(pnmlData,placeDashNo);          if (intersectionBetweenSets(fps1,fps2) && !Arrays.equals(fps1,fps2)) {            return false;          }        }    return true;  }  /**   * Simple net (SPL-net) detection   * @return true iff no places' outputs go to the same transition, unless one of the places only has one output   * SPL-net iff &forall; p, p&prime; &isin; P: p &#x2260; p&prime; &#x21d2; (p&bull;&#x2229;p&prime;&bull; = 0 or |p&bull;| &#8804; 1 or |p&prime;&bull;| &#8804; 1)   * <pre>   * P - T   * P - T       true (no common outputs)   *   \   *     T   *   * P - T   *   /         true (common outputs, both only have one)   * P   *   * P - T   *   /         true (common outputs, one place has only one)   * P - T   *   * P - T   *   X         false (common outputs, neither has only one)   * P - T   *   * P - T   *   \   *     T       false (common outputs, neither has only one)   *   /   * P - T   * </pre>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -