Code Monkey home page Code Monkey logo

helper-scripts's Introduction

helper-scripts

This repository encompasses Python scripts I developed during the writing of my bachelor thesis. All scripts require Python 3.x.

create-csv.py

This script can be used to extract benchmark results and create CSV files. More information can be found here.

golog-to-asp.py

A Golog to ASP/Dot translator (requires Graphviz). Example for usage:

python3 golog-to-asp.py "[move(X,D){robot(X), direction(D)}|wait(R){robot(R)}]*;#~battery_low(R){robot(R)} & [robot_on_target(R,T){robot(R), target(T)} + robot_loading(R){robot(R)}]#?"

This creates files gst.lp and gst.dot.png that represent the entered Golog program.

pretty-print.py

Creates tabular clingo output for better readability. An ASP program must output occurs/2 and holds/2 predicates through

#show occurs/2.
#show holds/2.

Example output:

RESULTS FOR example.lp
Models: 4

Time (Total):         0.008s
Time (Solving):       0.000s (0.00% of Total Time)
Time (Grounding):     0.008s (100.00% of Total Time)

+==================================================================+
|                            ANSWER: 1                             |
+------+------------------------------+----------------------------+
| TIME | OCCURS                       | HOLDS                      |
+------+------------------------------+----------------------------+
|    0 | a                            | e                          |
|      |                              | f                          |
|      |                              | g                          |
|      |                              | h                          |
+------+------------------------------+----------------------------+
|    1 | b                            | e                          |
|      |                              | h                          |
+------+------------------------------+----------------------------+
|    2 | b                            | g                          |
|      |                              | h                          |
+------+------------------------------+----------------------------+
|    3 | b                            | f                          |
|      |                              | g                          |
+------+------------------------------+----------------------------+
|    4 | b                            | g                          |
|      |                              | h                          |
+------+------------------------------+----------------------------+
|    5 |                              | e                          |
|      |                              | g                          |
|      |                              | h                          |
+======+==============================+============================+

To create readable output download the .py file and pipe the clingo output to it:

clingo [MY_PROG].lp [NUM_OF_RESULTS] --outf=2 | python3 pretty-print.py

Notice the --outf=2 option which tells clingo to output a JSON string. This option is necessary for the pretty printer to work properly. It then generates a file named results.txt as per default. If you prefer command line output change line 275 to:

pretty_printer.print_to_shell()

helper-scripts's People

Contributors

webastronaut avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.