Skip to content

Everything required for exercise 3 in the FS24 Web-based Autonomous Systems course

Notifications You must be signed in to change notification settings

HSG-WAS-SS24/exercise-3

Repository files navigation

Exercise 3: Web Ontologies and Knowledge Graphs

This repository contains:

  • A partial implementation of a Web ontology for the domain of Agriculture based on the SAMOD methodology.
  • A partial implementation of a JaCaMo application, in which autonomous agents are able to query a knowledge graph to retrieve knowledge about the world — and to use that knowledge to manage a farm.

Table of Contents

Project structure

├── SAMOD // the only directory required for Tasks 2.1 and 2.2
│   └── agriculture-domain 
│       ├── README.md // the description of the Motivating Scenario, including the Competency Questions and the preliminary Glossary of terms
│       ├── tbox.ttl // the preliminary TBox that implements the description of the terms in the glossary
│       ├── abox.ttl // the preliminary ABox that implements the description of the first 3 competency questions
│       └── queries  
│           ├── insert // queries for populating a knowledge graph based on the ABox
│           └── select // queries for testing the knowledge graph based on the competency questions
│ // the rest are required for Task 2.3
├── mockserver
│   └── tractors.json // the configuration file for the mockserver that mocks the HTTP APIs of farm tractors 
├── src
│   ├── agt
│   │   ├── irrigator.asl // agent program of the agent that irrigates the soil
│   │   └── moisture_detector.asl // agent program of the agent that detects the moisture level of soil
│   └── env
│       ├── farm
│       │   └── FarmKG.java // artifact that can be used for querying a GraphDB repository
│       └── wot
│           └── ThingArtifact.java // artifact that can be used for interacting with W3C Web of Things (WoT) Things
├── task.jcm // the configuration file of the JaCaMo application for Task 2.3
└── wot-td-java // library for the W3C Web of Things (WoT) Thing Description (TD)

Task 2

Task 2.1

  • Extend the Glossary of terms to define new terms that are required for describing the Motivating scenario and for defining its Competency questions
  • Update the TBox to formally define your new terms in an ontology. You can import the TBox in Protege to work on top of the base ontology

Task 2.2

  • Update the ABox to complete the formal description of the motivating scenario
    • TIPS:
      • Use the new terms that you defined in your TBox
      • Currently, the ABox implements the description of the motivating scenario that is required for solving the first 3 competency questions
  • Setup your GraphDB repository for testing your ABox and TBox:
    • Import your TBox file in your repository: Import > RDF > Upload RDF files
    • Insert your ABox statements in your repository by creating and executing SPARQL INSERT queries
    • Create and execute in your repository SPARQL SELECT queries that formalize the competency questions
      • TIP: The queries/select directory contains example SELECT queries that formalize the first 3 competency questions

Task 2.3

  • Modify the template to use your GraphDB credentials and repository name in the Java class FarmKG, and the agent programs moisture_detector.asl, irrigator.asl
  • Complete the methods of the Java class FarmKG that enable autonomous agents to query your GraphDB repository through a JaCaMo application:
    • queryFarmSections()
    • querySectionCoordinates()
    • queryCropOfSection()
    • queryRequiredMoisture()
  • TIPS:
    • Use your SPARQL SELECT queries from Task 2.2 that formalize the competency questions q4, q5, q6, and q7.
    • The class FarmKG contains the full implementation of the example methods queryFarm() and queryThing()

How to run the project

1. Run the mockserver that mocks the tractors' HTTP APIs

Run MockServer with Docker:

docker run -v "$(pwd)"/mockserver/tractors.json:/tmp/mockserver/tractors.json -e MOCKSERVER_INITIALIZATION_JSON_PATH=/tmp/mockserver/tractors.json -d --rm --name      mockserver -p 1080:1080 mockserver/mockserver

The above command will run a Docker container in the background and will print the container ID. To stop a container run: docker stop <CONTAINER_ID>. You can use this Postman collection to inspect the behavior of the tractors' mockserver.

2. Run the JaCaMo application

You can run the project directly in Visual Studio Code or from the command line with Gradle 8.6.

  • In VSCode: Click on the Gradle Side Bar elephant icon, and navigate through GRADLE PROJECTS > exercise-3 > Tasks > jacamo > task.
  • On MacOS and Linux run the following command:
./gradlew task
  • On Windows run the following command:
gradle.bat task

About

Everything required for exercise 3 in the FS24 Web-based Autonomous Systems course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages