QSIM + CLISP HOWTO

This page presents a way to make QSIM work under CLISP on Windows or Linux. The process is divided into these steps:
  1. Download and patch sources, run CLISP
    1. on Windows
    2. on Linux
  2. Compile QSIM
  3. Try to get something out of it

Download and patch sources, run CLISP

Windows

Firstly you have to install CLISP. All you have to do is download the Windows binaries from here (something like clisp-2.35-win32.zip should be there) and unzip them somewhere. I'll use "<CLISP-DIR>" to refer to the directory containing CLISP.
Now you can choose exactly one of the following:
  1. Download original QSIM sources (preferrably version 4.0-alpha-4), unpack them to some <QSIM-DIR> (if you have problems unpacking the file, 7-zip can help) and patch them yourself with this python script. You'll need Python installed in some <PYTHON-DIR> to do this. Save the script to <QSIM-DIR>, run command-line, change directory to <QSIM-DIR> and execute this command:
    <PYTHON-DIR>\python clisp-patch-windows-0.1.py --no-pretend
  2. Alternatively you can download already-patched sources and unpack them to some <QSIM-DIR>. But that would be too easy, wouldn't it? There's one place in the sources you'll have to manually edit. Namely in the file
    <QSIM-DIR>\start-nq-no-defsystem.lisp
    you have to replace the uncommented
    (defvar *qsim-root* "c:\\qsim")
    with
    (defvar *qsim-root* "<QSIM-DIR-WITH-TWO-BACKSLASHES-INSTEAD-OF-ONE-AND-NO-TRAILING-BACKSLASH>")
    where <QSIM-DIR-WITH-TWO-BACKSLASHES-INSTEAD-OF-ONE-AND-NO-TRAILING-BACKSLASH> is exactly what you think it is :o)
To run CLISP, run command-line, change directory to <QSIM-DIR> and execute the following command:
<CLISP-DIR>\clisp.exe
Now you're ready to continue with the next step

Linux

Firstly you have to install CLISP. You can find packages for various Linux distributions here. In the following I'll assume, that CLISP is installed correctly.
Now you can choose exactly one of the following:
  1. Download original QSIM sources (preferrably version 4.0-alpha-4) and unpack them by executing the following command in some <QSIM-DIR>:
    zcat qsim4.0-alpha-4.tar.Z | tar -xvf -
    Then download this python script to <QSIM-DIR>. You'll also need Python installed to execute the following command:
    ./clisp-patch-linux-0.1.py --no-pretend
  2. Alternatively you can download already-patched sources and unpack them to some <QSIM-DIR>. But that would be too easy, wouldn't it? There's one place in the sources you'll have to manually edit. Namely in the file
    <QSIM-DIR>/start-nq-no-defsystem.lisp
    you have to replace
    (defvar *qsim-root* "/opt/qsim")
    with
    (defvar *qsim-root* "<QSIM-DIR-WITH-NO-TRAILING-SLASH>")
    where <QSIM-DIR-WITH-NO-TRAILING-SLASH> is exactly what you think it is :o)
Now run CLISP in <QSIM-DIR> by executing:
clisp
Now you're ready to continue with the next step

Compile QSIM

So by now you should CLISP command-line in front of you:
[1]>
Execute the following commands:
[1]> (load "start-nq-no-defsystem.lisp")
;; Loading file start-nq-no-defsystem.lisp ...
...blah blah...
;; Loaded file start-nq-no-defsystem.lisp
T
[2]> (compile-qsim)
...lots of messages and warnings...
[3]> (in-package :qsim)
#<PACKAGE QSIM>
QSIM[4]>
QSIM has been successfully compiled and loaded :o) Next time you use it, you'll only need to load it. That can be achieved by substituting the "(compile-qsim)" command with "(load-qsim)". Time to continue with the next step

Try to get something out of it

The following text is a bit linux-oriented, but under windows the commands are identical, so I won't write the same thing twice...
So now that QSIM is loaded, you can try to run a simulation of some example models. You could start with BATHTUB (yeah, UMÝVADLO RULEZ :o). The source file with QDE for this example is
<QSIM-DIR>/nq/source/examples/bathtub.lisp
and to run it you have to do the following:
QSIM[4]> (q)


  QSIM-MENU 

     Choices:

           1:    Introduction
           2:    Modeling
           3:    Comparative Statics
           4:    Simulation
           5:    Using the Behavior Tree
           6:    Example Models
           7:    Distribution and WWW Page
           8:    What's New with QSIM
           9:    Old Example Menu

           B:    Backup One Level
           Q:    Quit All Menus

           Selection: 6


  EXAMPLES-MENU 

     Choices:

           1:    Tanks
           2:    Springs
           3:    Balls
           4:    Controllers
           5:    Medical
           6:    Interesting Systems

           B:    Backup One Level
           Q:    Quit All Menus

           Selection: 1


  TANKS 

     Choices:

           1:    U-TUBE
           2:    BATHTUB
           3:    CASCADED-TANKS
           4:    CASCADED-TANKS-IGN-TEST
           5:    CASCADED-TANKS-NNL-TEST
           6:    TWO-TANKS
           7:    TWO-TANKS-IGN-TEST
           8:    TWO-STAGE-BATHTUB

           B:    Backup One Level
           Q:    Quit All Menus

           Selection: 2


EXAMPLE FILE: <QSIM-DIR>/nq/source/examples/bathtub.lisp

;; Loading file <QSIM-DIR>/nq/source/examples/bathtub.lisp ...
;; Loaded file <QSIM-DIR>/nq/source/examples/bathtub.lisp

  M-25 

     Choices:

           1:    FILL-FROM-EMPTY

           B:    Backup One Level
           Q:    Quit All Menus

           Selection: 1

Run time: ?.??? seconds to initialize S-0.
Run time: ?.??? seconds to simulate 4 states.
Qualitative time plots.  Enter T=beh Tree, N=Next beh (1 of 3), beh number, O=Other commands, K=Symbol Key, CH=Change Output Routing, E=QSIM Extensions, Q=Quit:
Now QSIM is ready to present the simulation results for all behaviours in the behaviour tree. But before you type any commands, plase read the following notes:
  1. If you're on Windows, it isn't possible to display graphs directly because it just isn't implemented. The only thing you can do is:
    Qualitative time plots.  Enter T=beh Tree, N=Next beh (1 of 3), beh number, O=Other commands, K=Symbol Key, CH=Change Output Routing, E=QSIM Extensions, Q=Quit:CH
    Select Option: (Q to Quit)  S=Screen, F=New File, B=Screen and File, N=Nowhere: F
    
    Filename: bathtub.ps
    
    
    Qualitative time plots.  Enter T=beh Tree, N=Next beh (1 of 3), beh number, O=Other commands, K=Symbol Key, CH=Change Output Routing, E=QSIM Extensions, Q=Quit:N
    
    Qualitative time plots.  Enter T=beh Tree, N=Next beh (2 of 3), beh number, O=Other commands, K=Symbol Key, CH=Change Output Routing, E=QSIM Extensions, Q=Quit:N
    
    Qualitative time plots.  Enter T=beh Tree, N=Next beh (3 of 3), beh number, O=Other commands, K=Symbol Key, CH=Change Output Routing, E=QSIM Extensions, Q=Quit:N
    
    Qualitative time plots.  Enter T=beh Tree, N=Next beh (1 of 3), beh number, O=Other commands, K=Symbol Key, CH=Change Output Routing, E=QSIM Extensions, Q=Quit:
    and view the file bathtub.ps (found in in <QSIM-DIR>) in a postscript viewer. Ghostscript + GSview can handle them quite well, but viewing is a bit destructive - you can't return to pages already viewed without restarting GSView :o)
  2. On Linux the previous method can be used too, but kghostview can only display the first page of the file, so you must either generate 3 files or use a different viewer (e.g. gsview, ghostview, gv).
  3. With X Windows it's even easier. You can keep the default Output Routing (Screen) and just type "N". A window with graphs should popup.
You can quit CLISP by typing "(user::exit)" or by typing "(in-package :user)" and "(exit)". And that's all from me. Hope it works. Enjoy :o)