{"id":149,"date":"2020-01-14T18:11:23","date_gmt":"2020-01-14T17:11:23","guid":{"rendered":"http:\/\/perf.unime.it\/magnet\/?page_id=149"},"modified":"2022-04-06T15:45:55","modified_gmt":"2022-04-06T14:45:55","slug":"api_documentation","status":"publish","type":"page","link":"http:\/\/perf.unime.it\/magnet\/?page_id=149","title":{"rendered":"API Documentation (ver. 0.9.9)"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Create a New Model<\/h4>\n\n\n\n<p>Use NewModel() to create and initialize a new model. This is the first step in the model description. <\/p>\n\n\n\n<p>The function will return a pointer to the newly created model, and this pointer will be used throughout the model description source file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">M3AM *NewModel(const char *label, SpaceDim dimensions);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Create a New Class<\/h4>\n\n\n\n<p>Use NewClass() to create a new &#8220;Class&#8221; object identified by a label, with a predefined number of states.<\/p>\n\n\n\n<p>The function will take care to update the data structures (particularly linking this object with the M3AM model pointer.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error NewClass(M3AM *model, char *label, NumStates states);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Create a New Agent<\/h4>\n\n\n\n<p>Use NewAgent() to create a new agent object, identified by a label. Set the agent class by passing its label as function parameter.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error NewAgent(M3AM *model, const char *agent_label, const char *class_label, Point *coordinates, Density csi);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Initial Agent State Probabilities<\/h4>\n\n\n\n<p>Add the initial probabilities of an agent identified by its label with AddInitProb(). It change the probability of a specified state.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error AddInitProb(M3AM *model, const char *class_label, NumStates i, double prob);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Add Self-Loop Rate<\/h4>\n\n\n\n<p>Use AddSelfLoop() to add a new self-loop rate for a given agent class.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error AddSelfLoop(M3AM *model, const char *class_label, NumStates i, double val);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Add Local Transition Rate<\/h4>\n\n\n\n<p>Use AddLocTr() to add a new local transition rate to a given agent class, identified by its label.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error AddLocTr(M3AM *model, const char *class_label, NumStates r, NumStates c, double val);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Create a New Message Type<\/h4>\n\n\n\n<p>Use NewMSG() to add a new message type to the model, identifying it with a label.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error NewMSG(M3AM *model, const char *message_label);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Add Message Type to Class<\/h4>\n\n\n\n<p>Use AddMsgToCl() to link a message type to a specific agent class.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error AddMsgToCl(M3AM *model, const char *clabel, const char *mlabel);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Add Message Generation Probability<\/h4>\n\n\n\n<p>Use AddMsgGenProb() to set a message generation probability for specified message and  agent class.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error AddMsgGenProb(M3AM *model, const char *class_label, const char *message_label, NumStates r, NumStates c, double val);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Add Message Acceptance Probability<\/h4>\n\n\n\n<p>Use AddMsgAccProb() to set a message acceptance probability for specified message and agent class.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error AddMsgAccProb(M3AM *model, const char *class_label, const char *message_label, NumStates r, NumStates c, double val);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Add a Message Perception Probability<\/h4>\n\n\n\n<p>Use AddPer() to update the messages perception values, with a new probability for given message and transmitting and receiving agents.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error AddPer(M3AM *model, Message msg, const char *rx, const char *tx, NumStates r, NumStates c, double val);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Class Iterator<\/h4>\n\n\n\n<p>Use the following functions to initialize and use a class iterator<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Class ClassIterator(M3AM *model);<br>Class NextClass(Class cl);<br>short ClassIsValid(Class cl);<br>short ClassIs(Class cl, const char *class_label);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Message Iterator<\/h4>\n\n\n\n<p>As for the classes, it&#8217;s possible to define and use message iterators<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Message MessageIterator(M3AM *model);<br>Message NextMessage(Message msg);<br>short MsgIsValid(Message msg);<br>int MessageIs( Message msg, const char *message_label);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Analysis<\/h4>\n\n\n\n<p>Set the parameter of the analysis<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Params SetSimParams(Time t_start, Time t_end, Step dt, Tolerance epslon, int iterations, int threads_number)<\/pre>\n\n\n\n<p>and launch the analysis with<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error AnalyzeModel(Params analysis_parameters, M3AM model, OUT_Mode output_mode);<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Create a New Model Use NewModel() to create and initialize a new model. This is the first step in the model description. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-149","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=\/wp\/v2\/pages\/149","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\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=149"}],"version-history":[{"count":7,"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=\/wp\/v2\/pages\/149\/revisions"}],"predecessor-version":[{"id":703,"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=\/wp\/v2\/pages\/149\/revisions\/703"}],"wp:attachment":[{"href":"http:\/\/perf.unime.it\/magnet\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}