The principle compiler PrincipleWriter is thoroughly described in
Jochen Setz' BSc. Thesis (References). Also be sure to check out
the example principles in PrincipleWriter/Examples
, and the
grammars suffixed PW
(Grammars) which use them.
Basically, PW makes writing principles much easier. You can write down your principles in a simple first-order logic, and PW compiles them into efficient principle implementations for the XDK.
This is how it works, in a nutshell. An example is the climbing principle:
defprinciple "principle.climbingPW" { dims {D1 D2} constraints { forall V: forall V1: dom(V V1 D1) => dom(V V1 D2) } }
What you do is to define the name of the principle
(principle.climbingPW
), the dimensions over which it should
abstract (D1
and D2
), and then a set of constraints.
Then you go into the directory PrincipleWriter
, and call the
compiler as follows:1
pw.exe -p Examples/climbingPW.ul
This compiles the principle, and puts the principle definition functor
ClimbingPW.oz
into Solver/Principles
and the constraint
functor also called ClimbingPW.oz
into
Solver/Principles/Lib
.
To use the principle, it has to be integrated into the XDK. You can do this
using the perl script addprinciple
:
addprinciple ClimbingPW ClimbingPW
or by adding it manually as follows:
ozmake
makefileSolver/Principles/makefile.oz
Solver/Principles/Principles.oz
, and also to the list
Principles
on top ofSolver/Principles/Principles.oz
.
Solver/Principles/principles.xml
. Here, for each new principle,
you add a line like the following for the graph principle:
ozmake
makefileSolver/Principles/Lib/makefile.oz
ozmake
makefile makefile.oz
in
order to include it in the ozmake
package created for the XDK.
To finalize the integration of the new principle, call ozmake
from the XDK main directory (where e.g. xdk.exe
resides in).
...and off you go :)