## **Gardeners Green Thumb Decision Support System** (GGD-DDS)

An open source rule engine, GGD engine and complex event processing (CEP) engine for Java™ and the JVM Platform.

Drools is a business rule management system with a forward-chaining and backward-chaining inference based rules engine, allowing fast and reliable evaluation of rules and complex event processing. 
A rule engine is also a fundamental building block to create an expert system which, in artificial intelligence, is a computer system that emulates the decision-making ability of a human expert.

Putting all of this together, a decision support system is designed with the help of drools library which is used in the project.
The service of decision support system is inferring knowledge from the available data of the greenhouse, the user input, and historical data what a user/the gardener should do. 
The inferred knowledge derived from the algorithm are presented to the gardener where an action is taken. 
These actions can be presented as goals where each goal is offered to other services of the system (partners). 
 The approach of the DSS is based on three eu.hsrw.ias.ggd.MainExe concepts:

###**Facts Knowledgesession,and Knowledgebase**

***Facts are nothing but plain old java objects (POJO) that represents the data which serves as input for rules.***

***Knowledgesession :This component holds all the resources required for firing rule. 
Here, all facts are inserted into the single session, and then matching rules are fired.***

***KnowledgeBase is an interface which manages a collection of knowledge definitions like rules.
Knowledge packages are created by grouping knowledge definition.***

Since the creation of Knowledge packages is very expensive, KnowledgeBase stores and reuse them. 
Knowledge Sessions are created from KnowledgeBase, which consumes less memory. 
KnowledgeBase keeps track of each Knowledge Session, so that updates to knowledge base can be applied to all the session at run time. 
Another advantage of KnowledgeBase is that, it is completely serializable. 
We can restore serializable object of KnowledgeBase rather creating a new one.
In the following case StatefulKnowledgeSession are used. 
So facts are inserted first and stored to KnowledgeSession where it is latter on provided to Knowledgebase. 


###**Rules (General structure, if premises then consequence)**
1. Rules are given explicitly by the expert. The list of rules created for this project are:
   1. Battery
   2. Dielectric Permittivity 
   3. Precipitation
   4. Soil Conductivity
   5. Soil Moisture
   6. Soil Temperature
   7. Temperature
2. One particular rule can be fired or multiple rules can be fired at the same time.

###**Goals (Rule Outcome)**
1. Goals are active rules which are able to change the value of the fact.  
2. Goals can be activated and deactivated based on the user preferences


### **Build**
1. Go to Build and build project in order to index all the dependecies required.
2. Run the *MainExe.java* which is part of the src/main/java/eu.hsrw.ias.ggd package

### **Usage**
You can reuse the project by changing the UserCredentials.java file located on the Credentials package.
It is possible to create new rules tailored to the needs of the use case scenario.
### **Examples**
For each sensor mentioned in the list of rules(src/main/resources/rules) an example is given. 
You may change the values based on the needs of the expert/user.

### **Dependencies**
org.drools version 7.48

org.slf4j version 1.7.30

com.google.code.gson 2.8.6
