Giter Club home page Giter Club logo

feup-plog's Introduction

feup-plog

Univeristy Subject - Logic Programming (Programa莽茫o em L贸gica)

Faculty of Engeneering of University of Porto

2017/2018

With the colaboration of Daniel Silva

Logic Programming in PROLOG

Check the solved Class Exercises and solved Exams and Tests

TP1 - LYNGK Board Game - Report


TP2- Teacher Hour Allocation - Constraints (Finite Domain) - Paper

We developed a PROLOG file (main.pl) that can be run to find a solution for the problem specified in data.pl using sicstus constraint engine for Finite Domains (:- use_module(library(clpfd)).).

interface.py

This file, essentially, does everything. It generates json versions of problems with solution, converts them to Prolog to feed our open-mouthed slow-eater solver, and executes them. It is also able to output the results to a .csv file for later interpretation. To see everything it can do, call python interface.py -h:

usage: interface.py [-h] [-g] [-p] [-e] [-tt] [-ht] [-nr] [-nf] [-md] [-jf] [-pf] [-cf] [-r] [-d] [-t] [-ra]

Python generator, parser, executer and analyser for problems concerning the teacher hours assignment

optional arguments:
  -h, --help            show this help message and exit

actions:
  -g, --generate        Generate a JSON file (-jf) with a solvale problem
  -p, --parse           Parse from a JSON file into a Prolog file(-jf to -pf)
  -e, --execute         Execute the main.pl file with a custom Prolog data file (-pf, -cf)
  -tt, --test           Run all the json files inside data/
  -ht, --hardcode-test  Run the hardcoded tests

generation arguments:
  -nr , --number-rounds Number of rounds for the generator (default is 1)
  -nf , --number-fields Number of fields for the generator (default is 1)
  -md , --max-diff      Max Diff value for the generator (default is 0)

custom filenames:
  -jf , --json-file     The name of the json file to be used (generation, parsing)
  -pf , --prolog-file   The name of the prolog file to be used (parsing, execution)
  -cf , --csv-file      The name of the csv file to save the results (not specified = no output)

behaviour customization:
  -r, --remove          Remove the generated files
  -d, --debug           Run the prolog code in debug mode (only for executing)
  -t, --tabled          Makes the output form JSON to Prolog be tabled for easy reading
  -ra, --randomize      randomize the number of effective hours, instead of using all available (for generator)

Some example of cool commands are:

  • python interface.py -g -jf data/example.json (generates a problem with the default values in JSON)
  • python interface.py -g -jf data/example.json -nr 10 (same but using 10 rounds instead of 1, much harder for the solver)
  • python interface.py -p -jf data/example.json -pf src/data_example.pl (converts JSON to the predicates used by the solver) if -pf is not specified, src/data.pl is used
  • python interface.py -e -pf src/data_exemple.pl -d -cf temp.csv (executs the solver with the given data file, in debuf mode(-d) and writes the results (backtracks, heurisric, walltime, ...) to temp.csv and also on the console)
  • python interface.py -pge -jf data/everything.json -pf src/data_exemple.pl -cf temp.csv -d -nr 10 -nf 5 -md 4 (generates, parses and executes a new problem with 10 rounds, 5 fields of expertise and a maxDiff of 4)

feup-plog's People

Contributors

dannyps avatar msramalho avatar

Stargazers

 avatar  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.