modelverse_interface.tex 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. \chapter{Modelverse Interface}
  2. \section{Browser}
  3. As the Modelverse uses ordinary XML/HTTP requests, it is possible to easily transfer data through normal web clients, such as internet browsers.
  4. Since these clients are not built with the Modelverse in mind, users will have to use the raw API of the Modelverse Kernel (\textit{i.e.}, using \texttt{set\_input} and \texttt{get\_output}).
  5. \section{Serialized Graph}
  6. The most efficient, though also most low-level, way of transferring a model to the Modelverse, is through the serialisation of a graph structure.
  7. This graph, following a very minimal description format, will subsequently be merged into the current Modelverse graph.
  8. After serialization, the entry point to the graph is returned.
  9. This approach is very efficient, as it constitutes a single call to the Modelverse with the complete graph.
  10. All serialization and deserialization will happen in pure Python code (thus not explicitly modelled!), so basically everything is possible.
  11. The problem with this approach is that the interface needs to know the internal representation of models inside of the Modelverse.
  12. All connections need to be made manually, and the serialization format also needs to be known.
  13. It is therefore not recommended to use this interface, unless no other option is possible (\textit{i.e.}, during bootstrapping).
  14. \section{HUTN for Action Language}
  15. The more elegant way of sending action code to the Modelverse, is by using the explicitly modelled constructors.
  16. These constructors are simple action code that was previously loaded inside the Modelverse, which interprets the requests send to it as creation requests.
  17. While this is much less efficient, models can be created on-the-fly (without first creating the complete graph in the interface), and follows a standardized interface.
  18. Future changes to the internal representation of models will not affect these calls, as the actual creation of the model happens in the Modelverse itself.
  19. Users need thus only know Table~\ref{table:constructors}, which contains a list of all understood construction requests.
  20. Apart from hiding basic complexity (the names of the links), it also has simple requests to make more difficult constructs, such as function declarations or function calls.
  21. Furthermore, all complexity is hidden from the user, as all identifiers are kept in the Modelverse.
  22. Only those identifiers that need to be passed (\textit{i.e.}, variable declarations), will be provided to the interface.
  23. This is the recommended interface to use when transferring models to the Modelverse.
  24. \begin{table}
  25. \begin{tabular}{l|l l}
  26. instruction & parameter & type \\
  27. \hline
  28. if & condition & instruction \\
  29. & then & instruction \\
  30. & else? & instruction \\
  31. & next? & instruction \\
  32. \hline
  33. while & condition & instruction \\
  34. & body & instruction \\
  35. & next? & instruction \\
  36. \hline
  37. access & lvalue & instruction \\
  38. \hline
  39. resolve & variable & variable \\
  40. \hline
  41. assign & lvalue & instruction \\
  42. & rvalue & instruction \\
  43. & next? & instruction \\
  44. \hline
  45. call & function & instruction \\
  46. & nrParams & integer \\
  47. & name\# & string \\
  48. & value\# & instruction \\
  49. & next? & instruction \\
  50. \hline
  51. return & value? & instruction \\
  52. \hline
  53. const & value & anything \\
  54. \hline
  55. declare & variable! & variable \\
  56. \hline
  57. global & variable! & variable \\
  58. \hline
  59. output & value & instruction \\
  60. & next? & instruction \\
  61. \hline
  62. input & & \\
  63. \hline
  64. deref & link & string \\
  65. \hline
  66. funcdef & variable & variable \\
  67. & nrParams & integer \\
  68. & name\# & string \\
  69. & formal!\# & variable \\
  70. & body & instruction \\
  71. & next? & instruction \\
  72. \hline
  73. break & & \\
  74. \hline
  75. continue & & \\
  76. \hline
  77. \end{tabular}
  78. \caption{List of constructor keywords and parameters they take (in order). Questionmark after a parameter means that you first need to pass true/false for whether or not the element exists. Exclamation mark indicates that this is output at this place. A hash means that it occurs as often as previously specified.}
  79. \end{table}
  80. \section{HUTN for Models}