Generating Prime Implicants - Analysis and Improvements
A python implemenation of the Quine algorithm is provided (PyQMC.py). It includes a profile statement to measure CPU times and number of function calls. A shell script (make_gnuplot.sh) processes the profile results and displays it through gnuplot.
The idea is to see the limitations of the given code and to improve it. The achieved gain has to be demonstrated by comparing the results for different scenarios.
It is not intended that the whole code is reworked or understood in detail. Instead, interface documentation should be sufficient to reuse existing functions and only dig into those parts, where it is really needed.
- Hands on training of Linux/Unix
- Use of command line tools
- Concepts of automation
- Limitations and improvements of the Quine algorithm
The functions have been written in Python. Functions exist for creating random on-sets of Boolean functions. These are called by "make_onsets.py" and the on-sets are piped into "*.tt"-files. Each line contains the onset for one function.
"run_qmc.py" reads all onset files and performs QMC. The CPU time is measured by an profiler and again redirected to a textfile. Command line tools filter to data of interest and prepare vizualization. The CPU times for the basic implementation are written to a tabular seperated value file "basic.dat". This can easily be plotted by gnuplot or further processed by other tools.
- Analyse the performance of the given code.
Display typical runtimes of the QMC algorithm as function of number of variables.
- Worst Case simulation.
What is the worst case? Write a function to generate the corresponding truth table.
Display typical runtimes (from 1.) and the worst case runtimes into the same graph.
- Improve the qmc-function by sorting and grouping.
Measure the additional overhead and compare the performance gains.
Visualize the improvement.
- Implement the resolution method.
Visualize the improvement.
- Implement a prime cover selection method.
- Linux (Well, not really. The files can easily be modified to work on other systems.)
- gnuplot (Not really. Any program for post processing can be used.)
- Save the tar-ball to your working directory.
- Unpack it with "tar xvf name_of_tar_ball.tar"
or "tar xvfz name_of_tar_ball.tar.gz"
- Enter "bash" to change console
- Enter the directory and set the variable $PYTHONPATH
export PYTHONPATH=`working directory can be get with "pwd"`
check through: echo $PYTHONPATH
- See what files exsist with ls -R
- Start interactive Python ("python") and import the module PyQMC.py
>>>import src.PyQMC as PyQMC
- See what functions already exist:
>>> import src.BooleanOperations as BO
- Exit python with ctrl-D
- Type "make" and follow the instructions. Let the programm run and understand how the different software interacts. After this, start with the tasks.
- After make onsets, see the changes with ls -R. You can inspect the new files with any text viewer (vi, kwrite, cat, less)
- Continue as mentioned in tasks ...
- Command interface that allows also some scripting.
- Different shells have different syntax (bash, ksh, csh).
- Very picky on correct syntax, especially white spaces.
- Getting help
- man commands
- Some essential commands (use the internet for more):
- cd - change directory
- cp - copy file
- cp -r copy directory
- ls - show the content of directory (ls -lrt, ls -R)
- mv - move something
- mkdir - create a directory
- Very useful for large projects or repetitive tasks. Targets (object files) are rebuilt if a dependency (source file) has been modified.
- Requieres tabs and not whitespaces.
- Weird syntax.
- Dependency structure
- Scripting language with a lot of side packages
- Can be run as interactive shell (just type python) or with a file as argument.
- Only pointers; can be delecate for lists and default arguments.
- Indentation levels (set your editor to replace tabulars by 4 spaces.
- Getting help
- help( something )
- Functions you might want to use:
- range(5) yields [0,1,2,3,4]
- sorted( [1, 3, 2] ) or inplace sort mylist.sort()
|cat||concatenate a file or input||view files|
|diff||see differences in ASCII files (tkdiff for graphics)|
|echo||print a text line|
|gnuplot||Function and data plotting|
|grep, egrep||search for (regular) expressions in files|
|paste/cut||add/get columns to/from an ASCII file|
|pipe (|)||redirect the input/output of programs|
|redirect (>, >>)||redirect output to file (overwrite or append)|
|sed||powerful string replacement|
|longer list at e.g. ss64.com/bash/|
Download this tarball.