Commit 06e3dc3d by David Bremner

Update manual for initial release

Mainly replace the examples section to go with the new scripts
parent 3540047a
......@@ -4,7 +4,8 @@
\usepackage{amsthm}
\usepackage{amssymb}
\bibliographystyle{ieeetr}
\title{Sparktope User Reference}
\date{2016-12-27}
\usepackage{fullpage}
\usepackage{listings}
\lstdefinelanguage{sparks}%
......@@ -27,6 +28,7 @@
\begin{document}
\maketitle
\lstset{language=sparks,frame=single}
\section{Parameters}
......@@ -57,7 +59,8 @@ in them. There is no fixed limit on identifier length.
input array x[3] # input array of 3 bits, indexed 0..2
input array x[n] # input array; n is a parameter. indexed 0..n-1
input array x[n] # input array; n is a parameter.
# indexed 0..n-1
input matrix A[m,n] # input matrix (2D array of bits)
\end{lstlisting}
......@@ -422,88 +425,48 @@ controlling the original G.i constraints)
\section{Sample Session}
\begin{verbatim}
$ racket ../../stage1/stage1.rkt pm.spk > pm.asm
$ cat 250.param
n=6
word_size=3
time_bound=250
$ pypy ../../stage2/stage2.py --output=lp pm.asm 250.param > pm.prelp
$ python ../../tools/dat2json k6.dat > k6.json
$ python ../../stage3/stage3.py pm.prelp k6.json > pm.lp
$ glpsol --lp pm.lp
GLPSOL: GLPK LP/MIP Solver, v4.55
Parameter(s) specified in the command line:
--lp pm.lp
Reading problem data from 'pm.lp'...
1142312 rows, 172397 columns, 4284604 non-zeros
1314440 lines were read
GLPK Simplex Optimizer, v4.55
1142312 rows, 172397 columns, 4284604 non-zeros
Preprocessing...
5320 rows, 2610 columns, 10640 non-zeros
Scaling...
A: min|aij| = 1.000e+00 max|aij| = 1.000e+00 ratio = 1.000e+00
Problem data seem to be well scaled
Constructing initial basis...
Size of triangular part is 5320
* 0: obj = 1.000000000e+00 infeas = 0.000e+00 (0)
* 500: obj = 1.000000000e+00 infeas = 0.000e+00 (0)
* 1000: obj = 1.000000000e+00 infeas = 0.000e+00 (0)
* 1500: obj = 1.000000000e+00 infeas = 0.000e+00 (0)
* 2000: obj = 5.000000000e+00 infeas = 0.000e+00 (0)
* 2500: obj = 1.900000000e+01 infeas = 0.000e+00 (0)
* 2610: obj = 3.100000000e+01 infeas = 0.000e+00 (0)
OPTIMAL LP SOLUTION FOUND
Time used: 1.5 secs
Memory used: 856.5 Mb (898080596 bytes)
$ cplex
Welcome to IBM(R) ILOG(R) CPLEX(R) Interactive Optimizer 12.6.1.0
with Simplex, Mixed Integer & Barrier Optimizers
Copyright IBM Corp. 1988, 2014. All Rights Reserved.
Type 'help' for a list of available commands.
Type 'help' followed by a command name for more
information on commands.
CPLEX> read pm.lp
Warning, line 1245404: Name '_ot#8#1' does not exist.
Warning, line 1245405: Name '_ot#8#2' does not exist.
3241 name warnings not printed.
Problem 'pm.lp' read.
Read time = 2.42 sec. (117.88 ticks)
CPLEX> optimize
Parallel mode: deterministic, using up to 8 threads for concurrent optimization.
Tried aggregator 1 time.
LP Presolve eliminated 1142312 rows and 169136 columns.
All rows and columns eliminated.
Presolve time = 1.21 sec. (540.21 ticks)
>
Dual simplex - Optimal: Objective = -6.8719476733e+11
Solution time = 2.16 sec. Iterations = 0 (0)
Deterministic time = 863.47 ticks (399.89 ticks/sec)
CPLEX> write 250.xml sol
Solution written to file '250.xml'.
CPLEX> quit
$ ../../tools/cplexsol2txt 250.xml > 250.txt
$ ../../tools/plotlog 250.txt > 250.pdf
\end{verbatim}
\section{Tracing}
The following sample sparks code reads in an array into the first row of a matrix,
then copies and negates that to successive rows of the matrix.
The output is a particular bit in the resulting matrix.
\begin{lstlisting}
input array in[$n$]
output bool w
int i
int j
int k
matrix A[$n$,$n$]
for i<- 0,$n$ do
A[0,i] <- in[i]
done
for i<- 1,$n$ do
A[i,i]<-1
for j<-0,$n$ do
k <- dec(i)
A[i,j] <- !A[k,j]
done
done
return w @ A[$n$,$n$]
\end{lstlisting}
The following session can be reproduced by executing \texttt{make} in the \texttt{examples}
subdirectory
\begin{verbatim}
$ racket ../../stage1/stage1.rkt -t trace.json foo.spk > foo.asm
# as above, generate foo.txt from {cplex}sol2txt
$ ../../tools/tracelog foo.txt trace.json > foo.tsv
# foo.tsv can be read by a human, or
$ ../../tools/beamer-animate foo.spk foo.tsv > foo.tex
$ pdflatex foo.tex
\end{verbatim}
\bibliography{manual}
# Run stages 1 and 2 of the compiler, generating a polytope that
# can run any $7$-bit input.
% ./bin/buildpoly -s matrix-for.sym matrix-for.spk \
matrix-for.param > matrix-for.lp
# Run stage 3, adding an objective function, then solve lp
../bin/runpoly matrix-for.lp matrix-for.dat > matrix-for.out
# Use the symbols file generated by stage1 to plot sparks
# source lines instead of asm
../bin/plotlog -y 20 -s matrix-for.sym matrix-for.out > matrix-for.pdf
\end{verbatim}
\bibliography{manual}
\end{document}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment