{"id":604,"date":"2022-04-05T14:43:30","date_gmt":"2022-04-05T13:43:30","guid":{"rendered":"http:\/\/perf.unime.it\/magnet\/?page_id=604"},"modified":"2022-04-20T07:49:22","modified_gmt":"2022-04-20T06:49:22","slug":"markovian-agents-deployment","status":"publish","type":"page","link":"http:\/\/perf.unime.it\/magnet\/?page_id=604","title":{"rendered":"Markovian agents deployment"},"content":{"rendered":"\n<pre id=\"NewAgent\" class=\"wp-block-code\" style=\"font-size:18px\"><code><strong>Error m3am_NewAgent(M3AM *model, const char *agent_label, const char *class_label, Point *coordinates, Density csi);<\/strong><\/code><\/pre>\n\n\n\n<p id=\"block-3ae5ddf5-7ee2-44ab-bbc3-0b998f3bdf1e\"><code>m3am_NewAgent<\/code> creates an agent, whose name is <code>agent_label<\/code>, belonging to the class <code>class_label<\/code> in the model referenced by <code>model<\/code>; multiple agents are located in position <code>coordinates<\/code> with density <code>csi<\/code>. Parameter <code>coordinates<\/code> is assumed to be an array whose dimensions are the space dimension declared when the model is created with <code>m3am_NewModel<\/code>. <code>csi<\/code> must be a non negative value, otherwise an error code is returned. If either <code>class_label<\/code> class or <code>message_label<\/code> message are not defined an error code is returned. Two Markovian agents with the same name cannot exist in the same model; creating a Markovian agent with an already used name returns an error code.<br>Returned values are as in the following:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>NOERR<\/td><td>no error<\/td><\/tr><tr><td>EORANGE<\/td><td>density value is out of range<\/td><\/tr><tr><td>ENOOP<\/td><td>already defined Markovian agent name<\/td><\/tr><tr><td>ENOMEM<\/td><td>memory allocation error<\/td><\/tr><tr><td>ENOCL<\/td><td>class name does not exist<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p id=\"AddPer\"> <br><\/p>\n\n\n\n<pre id=\"block-a30384ee-79d5-4f49-aa92-713b3a5d385c\" class=\"wp-block-code\" style=\"font-size:18px\"><code><strong>Error m3am_AddPer(M3AM *model, const char *msg, const char *rx, const char *tx, NumStates r, NumStates c, double val);<\/strong><\/code><\/pre>\n\n\n\n<p id=\"block-5df296dd-8d07-4508-813d-591e6afba91d\"><code>m3am_AddPer<\/code> is the main tool for setting the values of the perception functions into the model <code>model<\/code>. A perception function per message can be defined by assigning probability <code>val<\/code> to perceive a message <code>msg<\/code> by the agent <code>rx<\/code> in the state <code>r<\/code> when the agent <code>tx<\/code> <em>transmits<\/em> it leaving the state <code>c<\/code>. Message must be previously defined in the class of agent <code>tx<\/code> with <code>m3am_NewMSG<\/code> and generated with <code><a href=\"http:\/\/perf.unime.it\/magnet\/wp-admin\/post.php?post=604&amp;action=edit#MsgGenP\">m3am_AddMsgGenProb<\/a><\/code>; the state c of transmitting agent is the state <code>r<\/code> as defined in <code><a href=\"http:\/\/perf.unime.it\/magnet\/wp-admin\/post.php?post=604&amp;action=edit#MsgGenP\">m3m_addMsgGenProb<\/a><\/code>. Both transmitting and receiving agents names must be defined, <code>val<\/code> must be a correct probability value, and <code>r<\/code> and <code>c<\/code> must be valid states.<br>Returned values are as in the following:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>NOERR<\/td><td>no error<\/td><\/tr><tr><td>ENOPR<\/td><td>not correct probability value<\/td><\/tr><tr><td>ENOMA<\/td><td>agent not found<\/td><\/tr><tr><td>ENOMES<\/td><td>message name does not exist<\/td><\/tr><tr><td>EORANGE<\/td><td>state index out of range<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p id=\"ClassIterator\"> <br><\/p>\n\n\n\n<p><br>It is useful to scan <em>messages<\/em> and <em>agent classes<\/em> one by one when perceptions functions are built. The following functions are provided to this purpose.<\/p>\n\n\n\n<pre id=\"block-c60fef2e-8184-402c-aef9-9db1d721863f\" class=\"wp-block-code\" style=\"font-size:18px\"><code><strong>Class m3am_ClassIterator(M3AM *model);<\/strong><\/code><\/pre>\n\n\n\n<p><code>m3am_ClassIterator<\/code> returns a reference to the first agent class object in the set of agent classes defined with <code>m3am_NewClass<\/code> in the model <code>model<\/code>.<\/p>\n\n\n\n<p id=\"NextClass\"><br><\/p>\n\n\n\n<pre id=\"block-b15d8a5e-433d-48f3-b3b2-3895c013fe4e\" class=\"wp-block-code\" style=\"font-size:18px\"><code><strong>Class m3am_NextClass(Class cl);<\/strong><\/code><\/pre>\n\n\n\n<p><code>m3am_nextClass<\/code> returns a new not visited agent class from the nearest call to <code>m3am_ClassIterator<\/code>. Note that repeated call to <code>m3am_nextClass<\/code> iterates over the set of agent classes until all of them have been visited. A NULL value is returned when all the agent classes have been visited.<\/p>\n\n\n\n<p id=\"ClassIs\"><br><\/p>\n\n\n\n<pre id=\"block-5d3fbc77-a554-4063-8472-e7c8df0b811e\" class=\"wp-block-code\" style=\"font-size:18px\"><code><strong>short m3am_ClassIs(Class cl, const char *class_label);<\/strong><\/code><\/pre>\n\n\n\n<p><code>m3am_ClassIs<\/code> evaluates to 1 if the agent class <code>cl<\/code> is named <code>class_label<\/code>, otherwise it evaluate to 0. <code>m3am_ClassIs<\/code> can be used to check the name of an agent class referenced by iterator.<\/p>\n\n\n\n<p id=\"ClassIsValid\"><br><\/p>\n\n\n\n<pre id=\"block-1995ffa0-c178-4220-a011-354b0331c0ce\" class=\"wp-block-code\" style=\"font-size:18px\"><code><strong>short m3am_ClassIsValid(Class cl)<\/strong><\/code><\/pre>\n\n\n\n<p id=\"block-d1166450-c3a6-489f-bda9-7c029715ccde\"><code>m3am_ClassIsValid<\/code> evaluates to 1 if cl references a correct agent class, otherwise it evaluates to 0.<\/p>\n\n\n\n<p id=\"block-c64a3ab4-cf6a-4994-b7e0-d310f940d12f\">The following C source code visits all the agent classes defined in the model myModel, previously defined and populated with agent classes, looking for the class named &#8220;myClass&#8221;:<\/p>\n\n\n\n<pre id=\"block-1c55433d-d249-4710-948a-cca844e02461\" class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><code><br>myModel=m3am_NewModel(\"My_Markovian_Agent_model\", 2);<br>  .<br>  .<br>  .<br>Class c=m3am_ClassIterator( myModel );<br>while( m3am_ClassIsValid( c ) ) {<br>     if ( m3am_ClassIs( c, \"myClass\") )<br>           printf( \"The class agent has been found);<br>     c = m3am_nextClass( c );<br>}<br>\ufeff<\/code><\/pre>\n\n\n\n<p id=\"MessageIterator\"><br><\/p>\n\n\n\n<pre id=\"block-ab93c5b6-9a4d-4be8-87d1-338e62cd97c0\" class=\"wp-block-code\" style=\"font-size:18px\"><code><strong>Message m3am_MessageIterator(M3AM *model);<\/strong><\/code><\/pre>\n\n\n\n<p><code>m3am_MessageIterator<\/code> returns a reference to the first message object in the set of messages defined with <code>m3am_NewMessage<\/code> in the model <code>model<\/code>.<\/p>\n\n\n\n<p id=\"NextMessage\"><br><\/p>\n\n\n\n<pre id=\"block-f5037278-7ce1-4371-afdd-a3b76f1aff05\" class=\"wp-block-code\" style=\"font-size:18px\"><code><strong>Message m3am_NextMessage(Message msg);<\/strong><\/code><\/pre>\n\n\n\n<p><code>m3am_nextMessage<\/code> returns a new not visited message from the nearest call to <code>m3am_MessageIterator<\/code>. Note that repeated calls to <code>m3am_nextMessage<\/code> iterates over the set of messages until all messages have been visited. A NULL value is returned when all the messages have been visited.<\/p>\n\n\n\n<p id=\"MessageIs\"><br><\/p>\n\n\n\n<pre id=\"block-43281252-b9de-441e-848a-2d66465cb039\" class=\"wp-block-code\" style=\"font-size:18px\"><code><strong>int m3am_MessageIs( Message msg, const char *message_label);<\/strong><\/code><\/pre>\n\n\n\n<p><code>m3am_MessageIs<\/code> evaluates to 1 if the message <code>msg<\/code> is named <code>message_label<\/code>, otherwise it evaluate to 0. <code>m3am_MessageIs<\/code> can be used to check the name of a message referenced by iterator.<\/p>\n\n\n\n<p id=\"MsgIsValid\"><br><\/p>\n\n\n\n<pre id=\"block-80b3d459-a005-42ac-8e9c-a28e26d08d60\" class=\"wp-block-code\" style=\"font-size:18px\"><code><strong>short m3am_MsgIsValid(Message msg);<\/strong><\/code><\/pre>\n\n\n\n<p id=\"block-022e8903-d680-4fd8-961f-4f7224417de1\"><code>m3am_MsgIsValid<\/code> evaluates to 1 if <code>msg<\/code> references a correct message, otherwise it evaluates to 0.<\/p>\n\n\n\n<p id=\"block-69b7d8c1-a5c4-4268-92f5-92a3a7e40f19\">The following C source code visits all the messages defined in the model myModel, previously populated with messages, looking for the message named &#8220;myMessage&#8221;:<\/p>\n\n\n\n<pre id=\"block-4103762a-5029-4f54-b020-183a9ba3f63c\" class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><code><br>myModel=m3am_NewModel(\"My_Markovian_Agent_model\", 2);<br>  .<br>  .<br>  .<br>Message m=m3am_MessageIterator( myModel );<br>while( m3am_MsgIsValid( m ) ) {<br>     if ( m3am_MessageIs( c, \"myMessage\") )<br>           printf( \"The message has been found);<br>     c = m3am_nextMessage( c );<br>}<br>\ufeff<\/code><\/pre>\n\n\n\n<p><br><\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-a89b3969 wp-block-buttons-is-layout-flex\">\n\n\n\n\n<div class=\"wp-block-button is-style-fill\"><a class=\"wp-block-button__link has-white-color has-cyan-bluish-gray-background-color has-text-color has-background\" href=\"http:\/\/perf.unime.it\/magnet\/?page_id=596\" style=\"border-radius:25px\">Prev<\/a><\/div>\n\n\n\n\n\n<div class=\"wp-block-button is-style-fill\"><a class=\"wp-block-button__link has-white-color has-cyan-bluish-gray-background-color has-text-color has-background\" href=\"http:\/\/perf.unime.it\/magnet\/?page_id=607\" style=\"border-radius:25px\">Next<\/a><\/div>\n\n\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>m3am_NewAgent creates an agent, whose name is agent_label, belonging to the class class_label in the model referenced by model; multiple agents are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-604","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=\/wp\/v2\/pages\/604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=604"}],"version-history":[{"count":29,"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=\/wp\/v2\/pages\/604\/revisions"}],"predecessor-version":[{"id":786,"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=\/wp\/v2\/pages\/604\/revisions\/786"}],"wp:attachment":[{"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}