Turing machine problem

305 views
Skip to first unread message

mobao

unread,
Apr 9, 2015, 8:37:58 AM4/9/15
to neto...@googlegroups.com
Hi,

I am using the Turing-machine module, and encountered some problems.
Using edit-config --config /home/mobao/netopeer/transAPI/turing/examples/0n1n-config.xml running command, we assumed we've got the right answer, since we could  get the result as shown below:

<turing-machine xmlns="http://example.net/turing-machine">
    <transition-function>
      <delta>
        <label>1</label>
        <input>
          <state>0</state>
          <symbol>0</symbol>
        </input>
        <output>
          <state>1</state>
          <symbol/>
          <head-move>right</head-move>
        </output>
      </delta>
      ...
    </transition-function>
    <state>0</state>
    <head-position>0</head-position>
    <tape>
      <cell>
        <coord>0</coord>
        <symbol>1</symbol>
      </cell>
      ...
    </tape>
</turing-machine>

Then, after executing the user-rpc command with the content <run xmlns="http://example.net/turing-machine"/> we cannot see any changes through get command. The values of <state> and <head-position> remain 0. It seems that the turing machine has not been executed at all.

My quesiton is that when we installed the Netopeer-server, does the actual turing-machine has already been installed together? Or we need to download a separate turing-machine program to finish the work?

Michal Vasko

unread,
Apr 9, 2015, 9:18:48 AM4/9/15
to neto...@googlegroups.com
Hi,

the provided examples include only the transition function of a Turing machine. To execute it on an input, you need to call the initialize RPC first, with the tape content you want. Afterwards call run and you should see the Turing machine do something. To make sure, subscribe to notifications and you will receive one after the machine stops the execution.

To answer your last quiestions, the Turing machine module has to be installed separately, but you obviously have done it, otherwise you would not even be able to set the example transition function of the machine, not to mention the run RPC. But in "netopeer/transAPI/turing" there is everything needed for the simulation.

Regards,
Michal

mobao

unread,
Apr 10, 2015, 12:32:36 AM4/10/15
to neto...@googlegroups.com
Hi Michal,

Thank you for taking the time to answer my quesiton.
Followed your suggetion, I got the result as below:
Step 1: 
netopeer-cli>user-rpc 
  <initialize xmlns="http://example.net/turing-machine">
    <tape-content>ABC</tape-content>
  </initialize>
Result OK

Step 2
netopeer-cli>get --filter
  <turing-machine xmlns="http://example.net/turing-machine">
    <transition-function>
      ...
    </transition-function>
    <state>0</state>
    <head-position>0</head-position>
    <tape>
      <cell>
        <coord>0</coord>
        <symbol>A</symbol>
      </cell>
      <cell>
        <coord>1</coord>
        <symbol>B</symbol>
      </cell>
      <cell>
        <coord>2</coord>
        <symbol>C</symbol>
      </cell>
    </tape>
  </turing-machine>

I assumed the RPC initialize works well. 

Step 3: 
netopeer-cli>user-rpc 
Result OK

It looks like I have started the machine, but I can't feel what have happend? Everything is changeless by using get command (as I said before: <state> and <head-position> remain 0). 

------------------------------------------------------
Two question I need your help:
1. Did I worked correct? Does the RPC run just only reply the result "OK"?
2. I want to study the turing-machine transAPI module, but I can not find the source code of turing-machine in path /netopeer/transAPI/turing/ (I think the file turing-machine.c is not the source code of the original turing-machine, it just a callback function.). I think it's important for me to understand the relationship between the device and transAPI.

Best Regards,
Mobao

Michal Vasko

unread,
Apr 10, 2015, 3:36:33 AM4/10/15
to neto...@googlegroups.com
Hi Mobao,

first, I'll walk you through what happened in your case. You called initialize and set the tape content to "ABC". You then checked the state data and saw that the tape content is correct. Calling run started the simulation. Now, I don't know how much do you know about Turing machines, but I must assume that it isn't much. Very generally and briefly, the transition function is used to move the head (basically a pointer) on the tape, while changing states and generating some output. The computation is finished if an accepting state is reached or no transition rule can be applied on the current state. At this point the module generates a notification, which I suggest you subscribe to using CLI "subscribe".

Having said that, I can now explain what happened. Your head was initially at "A", quite naturally. So the Turing machine tried to use the transition function to move to another state. If you look through it, the example one you used, you will see that all the symbols it can work with are 0s and 1s. Hence, no rule could be applied and the simulation immediately finished, state and head position were left at 0.

To answer your questions, 1. Yes, like I explained, everything happened the way it should have. 2. In the turing-machine.c actually is all the specific functionality of this module, all the source code. Everything else is handled internally in libnetconf in the transAPI. To understand how to implement transAPI modules, look here (the first thing you should have done). Please, try to read it carefully and it would be best if you also tried to implement a simple module yourself to fully understand how it works. You can also check the other two transAPI modules, cfgsystem and cfginterfaces (in "netopeer/transAPI/"), which are fully functional, but quite complex. Only afterwards, if you still find yourself unable to understand something, feel free to ask again, but everything I have just written you could have discovered on your own.

Regards,
Michal

MoBao

unread,
Apr 14, 2015, 9:45:58 AM4/14/15
to neto...@googlegroups.com
Hi Michal,

Follow your advice, I did below works: 
1. Changed the tape-content from "ABCD" to "1010" by using user-rpc initialize
2. Sent edit-config invert-config.xml to the server.
3. With subscribe function. 
After did these, when I use run command, I got the notification simultaneously. And then, I found the tape cell were transformed into "0101" by using get command. I could be sure that it is the correct and whole turing-machine test.
Thank you very much!

Now, I'm studying the transAPI tutorial and turing-machine.c file, in order to make clear of the confuse about inter-operate between device and yang model. 

Best regards,
Mobao
Reply all
Reply to author
Forward
0 new messages