It i possible to run inference process in one of four modes:
All of these modes can be run:
All information about the inference process, and states are displayed on the console.
To run heart from a Linus console run a bash script heart located in heart directory. The script can take 4 parameters:
heart somefile.pl
After that, SWI-Prolog will be run, and file given as a parameter will be consulted.
heart somefile.pl [table1,table2,table3]
. After that swi prolog will consult somefile.pl file, and then fire table1, table2 and table3 in DDI mode. If there were callbacks written they also will be fired.
heart somefile.pl [table3] gdi
After that SWI-Prolog will consult somefile.pl file, and run GDI inference, treating table3 as a goal table.
heart somefile.pl [table3] gdi state1
After that SWI-Prolog will run inference in GDI mode treating table3 as a goal table and taking attributes values from state1.
xschm table1 : [A] ==> [B]. xschm table2 : [B] ==> [C].
xschm table1 : [A] ==> [B]. xschm table2 : [B] ==> [C].
Works exactly like a gox/3, but instead of taking values of attributes from a given state, callbacks for in attributes are fired and data is acquired form the user.
There are two ways of tracking system;s work:
Debugging is a simple mechanism that writes information about current interpreter's activity to the Prolog console. A level of debugging process (a level of details and amount of information that will be displayed) can be dynamically changed from the Prolog console.
Tracking a trajectory of an inference process allows to see which rules, or tables were fired during inference process, and how did that affect system's state.
Sets the debug level
Displays message on the Prolog's console if the level given as a parameter is less or equal the level set by the debug_set_flag/1 predicate. This predicate is a development one, not used by an end-user.
Sets the trajectory mode.
Saves Current system's state if the Mode parameter equals trajectory mode set by the trajectory_set_mode/1 parameter. This predicate is a development one, not used by an end-user.
All information about an inference trajectory can be found in xtraj/1 predicate, that is automatically added to the knowledge base after inference process. xtraj/1 predicate is build as follows
xtraj %STRING% : %LIST%.
Therea are three ways of verifying models in HEaRT:
DCG is located in DCG.pl file, and it is not loaded by default by HeaRT interpreter. To use it, DCG.pl file has to be consulted by the Prolog interpreter.
Logical Verification is included in HeaRT, and all predicates offered by this plugin is available immediately after consulting main interpreter file. All information about verification process are stored in xhalv/1 predicates.
Export to TEX is included in HeaRT and is available immediately after consulting main interpreter file.
Checks if a File is a valid HMR file. As a result user gets information if the File is valid printed on the Prolog console.
Checks currently loaded model for subsumtions. Versification's reports are printed out to the Prolog's console respectively to the vreport flag that can be set by the set_vreport_flag/1. The higher the flag, the more detailed information are printed out.
All information about verification process are saved in the xhalv/1 predicate not matter what is a value of the vreport flag. Last performed verification report can be obtained by the get_current_vreport/1 predicate. ID (or name) of the xhlav/1 record can be retrieved using vid/1 fact.
Works exactly the same way as vsubsume/1, but checks the model for completeness.
Works exactly the same way as vsubsume/1, but checks the model for contradictions within the given table.
Works exactly the same way as vsubsume/1, but checks if there are rules that can be reduced to one rule.
Exports currently loaded model to TEX file given as a parameter. Generated file is a complete TEX file, that can be directly compile by any TEX compiler.
HeaRT can be run in a server mode. This mode disables a console (only information about the server work is displayed), and enables remote access to the server via TCP/IP Protocol.
Before using server mode a storage folder has to be set up. To set the folder where all models will be stored, a modification of storage_dir/1 fact is required. The fact is located in heart-io.pl file. The fact stores full path to the storage area, where all models should be stored.
Runs a server.
The protocol HOWTO is located in Protocol HOWTO.
[true,[heart,hello,1.0,5,[]]]
[true, [[modelname1,username1],[modelname2,username1], [ modelname3,username2]]]
If there is no models in the storage area following answer is returned:
[true,[]]
. If there are errors during reading a model list, following message is returned:
[false,]
[false,'Error occured while reading a model list']</code>
[model, get, hml, +modelname, +username, [[atrs], [tpes], [tbl,t]]].
get the all the attributes and types and one table with id t
in HML format. The Heart accepts only:
[model, get, hmr, +modelname, +username, [[all]]]
As a result client gets following answer:
[true,'MODEL']
where MODEL is the requested model or part of it.
If there is no requested model or user, follwing answer is sent:
[false, 'Model or username does not exist.']
[true,true]
If there is no such file
[true,false]
is sent back. If there is an error during this procedure, following error message is sent to the client:
[false,'Error while checking file existence']
[true]
is returned. In case of an error following error message is sent to the client:
[false,'Error message.']
[true]
is returned. In case of an error, following error message is sent back to the client
[false,'Error while deleting model.']
[[attribute_name1, value],[attribute_name2, value] ... ]
If the inference process succeed, the following answer is sent back to the client:
[true,system_state, system_trajectory]
The system_state is final state of the system defined as statedef. The system trajectory is a list of rules that were fired in the form of
[schema_name,rule_id,schema_name, rule_id, ...]
If there is an error during this procedure, the following error message will be sent back to the user:
[false,'Error occurred while running model']
[true,[[INPUT_ATTRIBUTES],[OUTPUT_ATTRIBUTES]]]
[[attribute_name1, value],[attribute_name2, value] ... ]
The statename is a Prolog string.
[true]
. In case of an error, the following message is sent back:
[false,'Error while deleting model.']
[ [report],[report], ... ]
Where report is one xhalv/1 record. The list contains all reports generated by the verification process.
In case of an error, following message is sent back to the client:
[false,'Error while verifying']
Character + means, that this parameter is obligatory. Format like this +{ddi | gdi | tdi | foi} means, that you must specify one of these parameters.
All protocol's commands have to be valid Prolog's lists followed by a dot. If the command that is is sent to the server, is not a list followed by a dot, following command will be sent back to the client:
[false,'Timeout. Bad or incomplete command.']
If a valid Prolog's list is sent to the server, but it's not recognized by it, following message will be sent back to the user:
[false, 'Command not supported.']
[model,add,hml,'MyName','Username','xtype [ name: week_days, base: symbolic, ordered: yes, domain: [moday,tuesday], desc: \'This is only one definition\'].'].
[model,get,hmr, 'MyName','Username', [[all]]].
As a result following message should be returned:
[true, [xtype[name:week_days, base:symbolic, ordered:yes, domain:[moday, tuesday], desc:'This is only one definition'].]]
[model,get,hml, 'MyName','Username', [[atrs], [tpes]]]
att_1
, att_2
and all the callbacks in the hmr format: [model,get,hmr, 'MyName','Username', [[clbs], [atr, atr_1], [atr, atr_2]]]
[model,getlist].
Folling answer can be returned:
[true, [[hqedmodel0, PHP], [temostat, PHP], [Termostat2, PHP], [therm-rt, PHP], [MyName, Username], [Termostat1, XTTd]]]
[model,remove, 'MyName','Username'].
[model,run,'temostat','PHP',ddi, [ms,dt], s1].
This command will run a Data-Driven inference from state s1 on the model temostat belonging to PHP user. Following return message can be sent by the server:
[true, [[day, 3.0], [hour, 3.0], [month, [2.0]], [season, 3.0], [today, 1.0], [operation, 2.0], [thermostat_settings, 16.0]], [ms, 4, dt, 1, th, 3, os, 7]]
Instead of state name, clinet can send a full state definition over the protocol:
[model,run,'MyName','Username',ddi, [ms,dt,th,os], [ [day,monday], [hour,13], [month, january] ] ].
[model,verify, vreduce, temostat,'PHP',os].
Following answer was sent by the server:
[true, [[4, 'In os rule: 4 can be joined with rule 8'], [8, 'In os rule: 8 can be joined with rule 4']]]
Here you can downloads source code of all integration libraries and read how to use them in you project.
Download JHeroic (version 1.0.1): jheroic.zip
When you download file with JHeroic library there will be file called “make”. Using it you can build jar archive and then you can add it to your project. If you would like to compile this library manualy you have to:
Compile all source java files
javac *.java
Create JHeroic folder and move all class files to it
mkdir JHeroic mv *.class JHeroic
Create jar from class files stored in JHeroic folder and MainClass
jar cfm JHeroic.jar MainClass JHeroic/
Now you can remove all class files and use jar instead
rm -r JHeroic
Download YHeroic (version 1.0.1): yheroic.zip
After downloading YHeroic library you can compy YHeroic.py file to you Python project. To include this library to it you must import it
import string, sys, YHeroic
Then you can create a new instance of YHeroic object and call evey methods from library
myLib = YHeroic.YHeroic('localhost',20044)
An example of Python script using YHeroic you can download here: yheroic-main.zip
Download PHeroic (version 1.0.1): pheroic.zip
After download library you can copy it to your web page and include to other php script
include_once('PHeroic.php');
Now you can create PHeroic object
$pheroic = new PHeroic("localhost",20044);
and run any method from library
$modelsList = $pheroic->getModelList();
Download callbackslibrary.zip. It is a NetBeans project that contains a set of default components for acquiring data from a user. The components are:
Code is organized in following packages:
To fire one of the following GUI callbacks from Prolog, you have to copy the catalog structure to the folder where your HMR file is located, and then add xcall definition in your HMR file:
xcall callback_name: [AttName] >>> (jpl_new('skeleton.RequestInterface',[],T), jpl_call(T,request,['callbacks.input.CALLBAC_NAME',PARAMETERS],Answer), atom_to_term(Answer,Answer2,_), alsv_new_val(AttName,Answer2)).
where
xcall ask_numeric_GUI : [AttName] >>> (jpl_new('skeleton.RequestInterface',[],T), alsv_domain(AttName,[Min to Max],numeric), concat_atom(['[',AttName,',',Min,',',Max,']'],Parameters), jpl_call(T,request,['callbacks.input.SliderFetcher',Parameters],Answer), atom_to_term(Answer,Answer2,_), alsv_new_val(AttName,Answer2)).
xcall ask_GUI : [AttName] >>> (jpl_new('skeleton.RequestInterface',[],T), alsv_domain(AttName,Domain,_), Params = [AttName|Domain], term_to_atom(Params, AtomParams), jpl_call(T,request,['callbacks.input.ComboBoxFetcher',AtomParams],Answer), atom_to_term(Answer,Answer2,_), alsv_new_val(AttName,Answer2)).