HeaRTDroid

HeaRTDroid is a rule-based inference engine both for Android mobile devices, and desktop solutions

User Tools

Site Tools


start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
start [2019/04/10 06:54]
127.0.0.1 external edit
start [2019/04/10 07:05]
admin [HeaRTDroid]
Line 1: Line 1:
-====== Uncertain and incomplete knowledge modelling for mediation in mobile context-aware systems ​====== +{{ :​pub:​software:​heartdroid:​heart-logo-no-borders.png?​150|}} 
-  +====== ​HeaRTDroid ​====== 
-===== About ===== +HeaRTDroid is a rule-based inference engine both for **Android mobile devices, and desktop solutions** that is based on [[http://ai.ia.agh.edu.pl/wiki/hekate:​heart|HeaRT]] inference engine. It is distributed under the GNU General Public License. 
-{{ ::logo-big.png?​200|}} +It can be downloaded from [[https://bitbucket.org/sbobek/heartdroid/​downloads/​|Bitbucket]]
-The main objective of this project ​is to propose ​//methods for knowledge modelling and mediation// in mobile context-aware systems, to support a user in adapting ​the system to his or her personal preferences and habits, and to improve management of //uncertain and incomplete// knowledge. ​+
  
-In particular, data gathered by participants of this project will be used to+Key features are
-  ​- Develop methods ​that will allow the system to adapt to the user personal preferences ​and habits in dynamic environments by combining machine learning approach ​with rule-based systems. +  ​* Inference support for **XTT2 rule representation** ​that is based on the **Attributive Logic with Set Values** ​and its textual representation called **[[pub:​software:​heartdroid:​tutorials:​hmr_quickstart|HMR+]]** 
-  ​- Improve knowledge ​management ​methods for imperfect or incomplete context by modelling dynamics of uncertainty with modified certainty factors algebraand probabilistic ​methods. +  * Pure Java implementation that allows for **integration ​with any Java code**, including **[[pub:​software:​heartdroid:​tutorials:​android_quickstart|Android applications]]** 
-  ​- Develop mechanisms ​and protocols for mediation that will allow to model and execute dialogue between the user and other system components to improve intelligibility of the system and provide support for better uncertainty resolution.+  * Integration with [[http://​awareframework.com|AWARE framework]] in a form of **[[pub:​software:​heartdroid:​tutorials:​aware_quickstart|HeaRTDroid Plug-In]]** 
 +  * **[[pub:​software:​heartdroid:​tutorials:​callbacks|Callbacks mechanism]]** ​based on Java reflection, that allows for easy integration with other systems 
 +  ​* **[[pub:​software:​heartdroid:​tutorials:​uncertainty_cf|Uncertainty]]** ​management ​mechanism based on modified certainty factors algebra and probabilistic ​approach 
 +  ​* Capturing dynamics with **[[pub:​software:​heartdroid:​tutorials:​statistics|statistical functions]]** ​and **[[pub:​software:​heartdroid:​tutorials:​tbo|time parametrised operators]]** 
 +  * **[[pub:​software:​heartdroid:​tutorials:​inference_config|Different inference modes]]** ​and real time **reasoning triggers** 
 +  * Interactive commandline shell **[[.:​pub:​software:​heartdroid:​tutorials:​haquna|HaQuNa]]** 
 +  * Under development:​ **Server mode** with TCP/IP protocol ​and REST API.
  
-If you are interested, join our team or participate in the project by installing AWARE application on your mobile device, and help us build databse of context! 
-===== Participate ===== 
-If you are an android user, and willing in participating in the project, install the [[http://​www.awareframework.com|AWARE Client]] application on your mobile phone or tablet and help us gathering contextual information. 
  
-Follow the instructions below.+===== QuickStart =====
  
-==== Install and setup ====+==== Running the inference ​==== 
 +The example below is available in the ''​StandardReasoningDemo.java''​ in the examples package: {{:​pub:​software:​heartdroid:​examples.zip|}}. 
 +To run the examples you have to have the latest version of [[pub:​software:​heartdroid:​downloads:​start|HeaRTDroid library]]. 
 +It shows how to perform reasoning using Java API. 
 +For interactive commandline shell tutorial see [[pub:​software:​heartdroid:​tutorials:​haquna|HaQuNa]].
  
-<WRAP center round important 60%> +=== Creating the model === 
-AWARE application has not yet been uploaded to Google Play, hence you may get a warning while installing it, that it is from unknown source. Just hit //Settings// and check //Unknown Sources// box to allow install AWARE applicationLater you can disable this option. +The HeaRTDroid inference engine uses [[http://ai.ia.agh.edu.pl/wiki/hekate:​hmr|HMR]] models. These can be created with the visual editor called HWEd. Please refer to [[.:#​creating_your_own_model|Creating your own model]] for details how to create the [[http://ai.ia.agh.edu.pl/wiki/​hekate:​xtt2|XTT2]] model.
-</WRAP>+
  
-  ​Download ​the latest version ​of [[http://​www.awareframework.com/awareframework.apk|AWARE]] +For the purpose of the tutorial you can use the XTT2 model given here: {{:​pub:​software:​heartdroid:​threat-monitor.hmr|}} 
-  - Open the application ​and select ​the QR code icon in the upper right corner\\ {{:join-study.png?​250|}} +The model was used for context-aware filtering threats from the Social Threat Monitor system created as a part of the [[http://​www.indect-project.eu/|Indect]] project. You can find more about the model and the system ​in the paper[[http://link.springer.com/​article/​10.1007%2Fs11042-014-2060-9|Mobile Context-based Framework for Threat Monitoring in Urban Environment with Social Threat Monitor.]]
-  ​Scan the following QR code by simply pointing the camera on the QR code below: \\ {{:​qrcode.png|}} +
-  ​You will be asked to join the study of the name KnowMe. Agree to that, and... that's all :) Any time you wish to turn off the data collecting just reopen the Aware and tap on "Quit study"​. You can later join the experiment by scanning the QR code again.+
  
-====What we are recording==== +The visualisation ​of the ''​threat-monitor.hmr''​ model is presented below:
-{{ :​aware-mobile.png?​250|}} +
-    * {{::​ic_launcher_plugins.png?​32|Aware Plugins}} ​ **Google Activity Recognition** – recognises users’ mode of transportation using Google Play Services API: still, on foot, in vehicle, on bicycle, unknown or tilting (moving ​the phone around randomly). +
-    * {{::​ic_launcher_plugins.png?​32|Aware Plugins}} **Google Fused Location** – provides location tracking with less than 1% battery impact per hour, using the default settings. **We only record locations that you are already sharing with other applications,​ like Facebook, Google, etc. The application does not initiate location tracking itself.** +
-    * {{::​ic_launcher_plugins.png?​32|Aware Plugins}} **Weather** ​retrieve the weather information at the current locationRetrieval every 30 minutes by default.  +
-    * {{::​ic_launcher_aware.png?​32|Aware sensors}} **Mobile ESM** - this will allow us sending you messages via MQTT server. This sensor does not actually gather any information except for that messages. +
-    * {{::​ic_launcher_aware.png?​32|Aware sensors}} **Battery** - this will allow us to make the context-aware application less energy consuming. You can read about our preliminary approach in [[http://​ieeexplore.ieee.org/​xpls/​abs_all.jsp?​arnumber=6644136&​tag=1|Learning sensors usage patterns in mobile context-aware systems]].  +
-    * {{::​ic_launcher_aware.png?​32|Aware sensors}} **Network** - this will gather information about network usage, how much data you send, when you use internet connection. This will not gather information about the your browsing history. **Check both //Network events// and //Network traffic//​**. +
-    * {{::​ic_launcher_aware.png?​32|Aware sensors}} **Screen** - this will tell us when your screen ​is locked and unlocked. We will use this to make your device more aware of who is using it and what are his or her habits. +
-    * {{::​ic_launcher_aware.png?​32|Aware sensors}} **Wifi** - this will allow us to improve localization based on WiFi access points nearby +
-    * {{::​ic_launcher_aware.png?​32|Aware sensors}} **Applications** - this will gather information about applications you use. This will **not** store any information like passwords, browser history, or anything you type in using your keyboard. Just a name of application you use.+
  
 +{{:​pub:​software:​heartdroid:​threat-monitor.png?​700|}}
  
-====Get your data==== +=== Loading a model to HeaRTDroid=== 
-Simply write me an [[szymon.bobek@agh.edu.pl|e-mail]] if you want to get access to your data, or have any question about the project!+First, you need to get the HeaRTDroid inference engine.  
 +  - You can download the latest version in a form of JAR file, that can be added to your Java project from: or [[.:​downloads:​start|Download section]] or from [[https://​bitbucket.org/​sbobek/​heartdroid/​downloads|Bitbucket]] 
 +  - You can download ​the source code with a command line: <code bash>hg clone https://​bitbucket.org/​sbobek/​heartdroid/</​code>​
  
-<WRAP center round tip 60%> +After that you can create an ''​XTT2Model''​ object and load the ''​HMR''​ file to it: 
-The data are transferred to us only when you have WiFi connection, so no GSM transfer will be used by the application. +<code java> 
-</WRAP>+try { 
 +    //Loading a file with a model 
 +    XTTModel model = null; 
 +    SourceFile hmr_threat_monitor =  
 +        new SourceFile("​./​heartdroid/​src/​main/​resources/​threat-monitor.pl"​);​ 
 +    HMRParser parser = new HMRParser();​
  
-<WRAP center round info 60%+    //Parsing the file with the model 
-More about available sensors and data they are gathering can be found on the [[http://www.awareframework.com|AWARE framework website]]+    parser.parse(hmr_threat_monitor);​ 
-</WRAP>+    model = parser.getModel();​ 
 +     
 +    //Printing all the types within the model 
 +    LinkedList<Typetypes = model.getTypes();​ 
 +    ​for(Type t : types){ 
 +        System.out.println("​Type id: "​+t.getId());​ 
 +        System.out.println("​Type name: "​+t.getName());​ 
 +        System.out.println("​Type base: "​+t.getBase());​ 
 +        System.out.println("​Type length: "​+t.getLength());​ 
 +        System.out.println("​Type scale: "​+t.getPrecision());​ 
 +        System.out.println("​desc:​ "​+t.getDescription());​ 
 +         
 +        for(Value v: t.getDomain().getValues()){ 
 +            System.out.println("​Value:​ "​+v);​ 
 +        } 
 +        System.out.println("​=========================="​);​ 
 +    } 
 +     
 +    //Printing all the attributes within the model 
 +    LinkedList<​Attribute>​ atts = model.getAttributes();​ 
 +    for(Attribute attatts){ 
 +        System.out.println("​Att Id: "​+att.getId());​ 
 +        System.out.println("​Att name: "​+att.getName());​ 
 +        System.out.println("​Att typeName: "​+att.getTypeId());​ 
 +        System.out.println("​Att abbrev: "​+att.getAbbreviation());​ 
 +        System.out.println("​Att comm: "​+att.getComm());​ 
 +        System.out.println("​Att desc: "​+att.getDescription());​ 
 +        System.out.println("​Att class: "​+att.getXTTClass());​ 
 +        System.out.println("​=========================="​);​ 
 +    } 
 +     
 +    ​//Printing all the tables and rules within the model 
 +    LinkedList<​Table>​ tables = model.getTables();​ 
 +    for(Table t : tables){ 
 +      System.out.println("​Table id:"​+t.getId());​ 
 +      ​System.out.println("​Table name:"​+t.getName());​ 
 +      LinkedList<heart.xtt.Attribute>​ cond = t.getPrecondition();​ 
 +      for(heart.xtt.Attribute a : cond){ 
 +          System.out.println("​schm Cond: "​+a.getName());​ 
 +      } 
 +      LinkedList<​heart.xtt.Attribute>​ concl = t.getConclusion();​ 
 +      for(heart.xtt.Attribute a : concl){ 
 +          System.out.println("​schm Conclusion: "​+a.getName());​ 
 +      } 
 +       
 +      System.out.println("​RULES FOR TABLE "​+t.getName());​ 
 +       
 +      for(Rule r : t.getRules()){ 
 +          System.out.print("​Rule id: "​+r.getId()+ ":​\n\tIF "); 
 +          for(Formulae f : r.getConditions()){ 
 +              System.out.print(f.getAttribute().getName()+"​ "​+f.getOp()+"​ "​+f.getValue()+",​ "); 
 +          } 
 +           
 +          System.out.println("​THEN "); 
 +           
 +          for(Decision d: r.getDecisions()){ 
 +              System.out.print("​\t"​+d.getAttribute().getName()+"​is set to "); 
 +               
 +              ExpressionInterface e = d.getDecision();​ 
 +              System.out.print(e);​ 
 +          } 
 +          System.out.println();​ 
 +           
 +      } 
 +      System.out.println();​ 
 +      System.out.println("​============================="​);​ 
 +       
 +       
 +    }       
 +       
 +} catch (Exception allExceptions){ 
 +  ​// Simplified for the purpose of the example 
 +}    
 +</code> 
 +=== Creating a new state ===
  
 +Once the model is loaded, you can set the initial state for the system. ​
 +The state is a set of initial values for the selected attributes. ​
 +The state usually will be dynamically set by the context-aware application.
  
-===== Join us ===== +<code java>
-{{ :​hands.png?​200|}} +
-If you are a programmer, a web developer, or just an enthusiast who would like to learn more about machine learning, data mining, android programming and much more - write us an [[szymon.bobek@agh.edu.pl|e-mail]] an join us!+
  
-In exchange ​for you work we can offer you (beside your own satisfaction): +// Creating StateElements objects, one for each attribute 
-  * Help in applying for study abroad in Erasmus+ program ​(see [[http://geist.agh.edu.pl/​pub:​students:​erasmus|more]]). +StateElement hourE = new StateElement(); 
-  * Certificate of your participation in the project +StateElement dayE = new StateElement(); 
-  * Possibility of including your work as major part of your master thesisor bachelor thesis+StateElement locationE = new StateElement();​ 
 +StateElement activityE = new StateElement();​ 
 +       
 +// Setting the values of the state elements ​  
 +hourE.setAttributeName("​hour"​);​ 
 +hourE.setValue(new SimpleNumeric(16d));​ 
 +       
 +dayE.setAttributeName("​day"​)
 +dayE.setValue(new SimpleSymbolic("​mon",​1));​ 
 +       
 +locationE.setAttributeName("​location"​);​ 
 +locationE.setValue(new SimpleSymbolic("​work")); 
 +       
 +activityE.setAttributeName("​activity"​);​ 
 +activityE.setValue(new SimpleSymbolic("​walking"​));​ 
 +       
 +     
 +//​Creating ​XTTState object that agregates all the StateElements ​  
 +State XTTstate = new State(); 
 +XTTstate.addStateElement(hourE);​ 
 +XTTstate.addStateElement(dayE);​ 
 +XTTstate.addStateElement(locationE);​ 
 +XTTstate.addStateElement(activityE);​ 
 +    
 +// Printing current state (it should be null for all attributes 
 +// the state will be set later). The state can be set before inference 
 +// by calling HeaRT.getWm().setCurrentState(...) ​      
 +System.out.println("​Printing current state"​);​ 
 +State current = HeaRT.getWm().getCurrentState(model);​ 
 +for(StateElement se : current){ 
 +    System.out.println("​Attribute "​+se.getAttributeName()+"​ = "​+se.getValue());​ 
 +
 +</​code>​
  
 +=== Running the inference ===
  
-<WRAP center round info 60%> +After the initial state is set, the inference can be run.
-If you are interested in working with [[http://​geist.agh.edu.pl|us]]but not necessarily in the topic of mobile context-aware systems, [[http://​geist.agh.edu.pl/​pub:​students:​spring_of_code:​start|read more]] about our initiative called **GEIST Season of Code**. +
-</​WRAP>​+
  
  
-===== Privacy ===== +<code java> 
-{{ ::padlock-med.png?100|}+try{ 
-Storing your contextual data on our server is safe+// Fixed order inference ​-- we give all tables names  
-  * All data is completely anonymous ​(identified by the device ID, which is known only to you). +// in an order in which they should be fired 
-  * All data is private and is not available to anyone from outside ​the [[http://geist.agh.edu.pl|GEIST]] team+HeaRT.fixedOrderInference(model,​  
-  * All data will be only used in research purposes+    new String[]{"​DayTime","​Today","​Actions","​Threats"​}, 
-  * We do not store any confidential data like passwordstext messageswebsites history, or anything you type using your keyboard+    new Configuration.Builder() 
-  * You can always delete your data or ask us to give you insight into it.+        ​.setInitialState(XTTstate) 
 +        ​.build()); 
 +         
 +// Data driven inference -- we give only the starting tables names.  
 +// The algorithm crawls the table network and fires only the necessary tables 
 +HeaRT.dataDrivenInference(model,​  
 +    new String[]{"​DayTime","​Today"​},​ 
 +    new Configuration.Builder() 
 +        ​.setInitialState(XTTstate) 
 +        .build());​ 
 +         
 +// Goal inference -- we only give the table which produces the attribute value 
 +// that we are interested ​in.  
 +// The algorithm crawls the table network and fires only the necessary tables. 
 +HeaRT.goalDrivenInference(model 
 +    new String[]{"​Threats"​}, 
 +    new Configuration.Builder() 
 +        .setInitialState(XTTstate) 
 +        .build());
  
 +}catch(UnsupportedOperationException e){
 +   ​e.printStackTrace();​
 +} catch (AttributeNotRegisteredException e) {
 +   ​e.printStackTrace();​
 +}
 +
 +
 +System.out.println("​Printing current state (after inference"​);​
 +current = HeaRT.getWm().getCurrentState(model);​
 +for(StateElement se : current){
 +   ​System.out.println("​Attribute "​+se.getAttributeName()+"​ = "​+se.getValue());​
 +}
 +</​code>​
 +==== Creating your own model ====
 +The model is created with HMR+ notation.
 +To learn more about this, go to the [[pub:​software:​heartdroid:​tutorials:​hmr_quickstart|HMR language quickstart]] tutorial.
 +You can use HWEd online web editor for this purpose: [[http://​glados.kis.agh.edu.pl/​hwed/​|HWEd web editor]]
 +If you want to use it on your server, please visit [[https://​bitbucket.org/​sbobek/​hwed|HWEd website]] for more details on how to do this.
start.txt · Last modified: 2022/10/24 19:29 by admin