Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:15:33+00:00 2026-06-05T07:15:33+00:00

When we write a Colored Petri Net (CP-Net), can we use java code in

  • 0

When we write a Colored Petri Net (CP-Net), can we use java code in the declaration section like the following example in PNML, or we have to consider a standard in this part also?
the following example is an XML representation, but can we use the same way to represent it in pnml? if no,can you help me how can we do so?
thanks,

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<pnml>
  <net id="n1">
    <import>
      <text>import java.util.Iterator;</text>
    </import>
    <declaration>
      <text>int x = 1;

    public String left(int i) {
        String s = "";
        switch (i) {
            case 1:
                s = new String("b");
                break;
            case 2:
                s = new String("c");
                break;
            case 3:
                s = new String("d");
                break;
            case 4:
                s = new String("e");
                break;
            case 5:
                s = new String("f");
                break;
        }
        return s;
    }

    public String right(int i) {
        String s = "";
        switch (i) {
            case 1:
                s = new String("a");
                break;
            case 2:
                s = new String("b");
                break;
            case 3:
                s = new String("c");
                break;
            case 4:
                s = new String("d");
                break;
            case 5:
                s = new String("e");
                break;
        }
        return s;
    }

    public TokenSet lr(int i) {
        TokenSet tk = new TokenSet(new Token(right(i)));
        tk.add(new Token(left(i)));
        return tk;
    }</text>
    </declaration>
    <place id="p3">
      <graphics>
        <position x="475" y="325"/>
      </graphics>
      <name>
        <text>free forks</text>
        <graphics>
          <offset x="70" y="0"/>
        </graphics>
      </name>
      <initialMarking>
        <text>"a"</text>
        <text>"b"</text>
        <text>"c"</text>
        <text>"d"</text>
        <text>"e"</text>
      </initialMarking>
    </place>
    <place id="p2">
      <graphics>
        <position x="325" y="335"/>
      </graphics>
      <name>
        <text>eat</text>
        <graphics>
          <offset x="50" y="-10"/>
        </graphics>
      </name>
    </place>
    <place id="p1">
      <graphics>
        <position x="325" y="125"/>
      </graphics>
      <name>
        <text>think</text>
        <graphics>
          <offset x="60" y="-10"/>
        </graphics>
      </name>
      <initialMarking>
        <text>1</text>
        <text>2</text>
        <text>3</text>
        <text>4</text>
        <text>5</text>
      </initialMarking>
    </place>
    <arc id="o15" source="t5" target="p3">
      <expression>
        <text>lr(x)</text>
      </expression>
      <graphics>
        <position x="331" y="440"/>
        <position x="454" y="341"/>
      </graphics>
    </arc>
    <arc id="o7" source="t5" target="p1">
      <expression>
        <text>x</text>
      </expression>
      <graphics>
        <position x="325" y="450"/>
        <position x="325" y="515"/>
        <position x="185" y="515"/>
        <position x="185" y="75"/>
        <position x="325" y="75"/>
        <position x="325" y="99"/>
      </graphics>
    </arc>
    <arc id="o9" source="t4" target="p2">
      <expression>
        <text>x</text>
      </expression>
      <graphics>
        <position x="325" y="230"/>
        <position x="325" y="309"/>
      </graphics>
    </arc>
    <arc id="i17" source="p2" target="t5">
      <expression>
        <text>getTokenSet().size()&gt;0</text>
      </expression>
      <expression>
        <text>x = (Integer) (getTokenSet().get(0)).getObject()</text>
      </expression>
      <graphics>
        <position x="325" y="361"/>
        <position x="325" y="440"/>
      </graphics>
    </arc>
    <arc id="i11" source="p3" target="t4">
      <expression>
        <text>getTokenSet().size()&gt;0</text>
      </expression>
      <expression>
        <text>lr(x)</text>
      </expression>
      <graphics>
        <position x="453" y="310"/>
        <position x="332" y="230"/>
      </graphics>
    </arc>
    <arc id="i13" source="p1" target="t4">
      <expression>
        <text>getTokenSet().size()&gt;0</text>
      </expression>
      <expression>
        <text>x</text>
      </expression>
      <graphics>
        <position x="325" y="151"/>
        <position x="325" y="220"/>
      </graphics>
    </arc>
    <transition id="t4">
      <graphics>
        <position x="325" y="225"/>
      </graphics>
      <name>
        <text>take forks</text>
        <graphics>
          <offset x="-70" y="0"/>
        </graphics>
      </name>
      <guard>
        <text>boolean found = false;
            Iterator it = p1.getTokens().iterator();
            while (!found &amp;&amp; it.hasNext()) {
                Token token = (Token) it.next();
                int i = (Integer) token.getObject();
                if (p3.getTokens().containsAll(lr(i))) {
                    x = i;
                    found = true;
                }
            }
            return found;</text>
      </guard>
    </transition>
    <transition id="t5">
      <graphics>
        <position x="325" y="445"/>
      </graphics>
      <name>
        <text>put down forks</text>
        <graphics>
          <offset x="-70" y="0"/>
        </graphics>
      </name>
      <guard>
        <text>return true;</text>
      </guard>
    </transition>
  </net>
</pnml>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:15:34+00:00Added an answer on June 5, 2026 at 7:15 am

    I think I found the solution, We can’t use the same way, we can use languages like MathML (a subset of MathML) to consider the standard.
    http://www.pnml.org/papers/forte06.pdf

    Thanks for all comments..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to decode a colored QR code in Java with ZXing library.
How can I write colored text to the console with C++? That is, how
I write daemon which use for DB SQLAlchemy. Database MySQL. If daemon idle long
i write this code , it make a slideUp for me now I need
If I have a line like this ContentRepository.Update(existing); that goes into datastore repository to
I'm trying to write a new emacs mode for a new template c-like language,
I have an Image. On the bottom portion of the image, I would like
I had to write a method that does the following: There is a DataSet
I can't seem to find a control that will display text colored with ANSI
I have a powershell script that gives some status output via write-output . I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.