Getting Started: Running Lens

This page explains how to get Lens running once you have it properly installed. If you still need to install Lens, read this instead.

Setting Up The Environment

Once it is installed, you will need to set a few environment variables before Lens will run.
  1. First make sure that you have the HOSTTYPE environment variable set to something reasonable. This should be done by default if your computer is properly configured. To check the value of the variable, do:
        echo $HOSTTYPE
    The variable should be set to i586 for recent versions of Linux and i686 for Cygwin under Windows.
  2. You then need to set the LENSDIR environment variable to the absolute path name of your main Lens directory. Depending on your shell, this can be done with one of the following:
        bash:  export LENSDIR=<your Lens directory>
        tcsh:  setenv LENSDIR <your Lens directory>

    You should put this line in your ~/.bash_profile file so it will be set whenever you log in.

    When using Cygwin on Windows, you may need to set the LENSDIR using the full windows path name, such as

        export LENSDIR=C:/cygwin/home/Owner/Lens
    rather than the unix-style path name
        export LENSDIR=/home/Owner/Lens
  3. If you are using Unix and Lens is using shared libraries (there will be *.so files in your Bin/$HOSTTYPE/ directory) you must add this directory to your LD_LIBRARY_PATH. Do this or the equivalent:
  4. You will probably want to add Lens to your executable search path. You can do this with something like:
        export PATH=${PATH}:${LENSDIR}/Bin/${HOSTTYPE}

    or you may prefer to put a symbolic link to Lens in your ~/bin directory as follows:

        cd ~/bin
        ln -s ${LENSDIR}/Bin/${HOSTTYPE}/*lens .
  5. If you're going to be running Lens on a Unix machine in anything but batch mode, you must have the DISPLAY environment variable set to your current display.


Here is the reduced-thought version for those of you using bash. Just put this in your .bash_profile, replacing "<your Lens directory>" with the absolute path to your Lens directory:
    export LENSDIR=<your Lens directory>
    export PATH=${PATH}:${LENSDIR}/Bin/${HOSTTYPE}

After adding that to the .bash_profile, do source ~/.bash_profile before you go on.

Using Lens

When fully compiled, the Lens directory contains two different executables: lens and alens. lens is the basic compilation that handles most algorithms. alens includes delta-bar-delta and quick-prop as well. lens uses a smaller structure for each link, but does not support the fancier algorithms. It will run somewhat faster than alens for large networks.

The usage specification for Lens is as follows:

    lens [-console | -nogui | -batch] [<script-file> | <command>]*

Lens recognizes only three command line flags, each of which may be abbreviated to its first character. Ordinarily the main display window will be opened automatically on startup and the current shell will be used for command input. If the first argument is -nogui, the Main Window will not appear. However, it can be opened later with the view command. Therefore, a valid DISPLAY environment variable must be set before running the program and the machine hosting the display must allow the display to be accessed (see the Unix xhost command) if no flag or -nogui is used.

The -console flag will open a graphical shell to be used in place of the current terminal. This has a nicer interface than the basic shell, allowing such things as file-name and command completion with the tab key and history traversal with the arrow keys.

The -batch flag runs Lens in a permanently non-graphical mode which does not require an accessible display. This is useful when running batch jobs which must persist even when the current X window session is terminated. This cannot be used in conjunction with the other flags.

Under Windows, Lens must use a console if it is not in batch mode, so the -c flag has no effect. You may encounter problems running Lens in batch mode under Windows, so you may prefer using -nogui instead.

If Lens is given additional arguments, they will be interpreted either as script files or as commands. If the argument is the name of a readable file, it will be sourced. Otherwise, the argument will be executed as a command. If arguments are supplied for the command, the command and its arguments should be enclosed in a set of quotes to group them together. Lens will use the .tclIndex file to locate and auto-load the initial (and all subsequent) commands. Therefore, it may not be necessary to source a script file before running a command.


This starts with a console but no graphical window, sources the file "buildNet.in", and then runs the command "train 1000 -r 100":

    % lens -n -c buildNet.in "train 1000 -r 100"

This runs the command "doItAllBaby" assuming this command is found in the .tclIndex somewhere in the auto_path:

    % lens doItAllBaby

This runs in batch mode and sources the file "buildNet.in" even if buildNet.in happens to be a valid command:

    % lens -b buildNet.in
This executes the command "buildNet.in" even if that is also the name of a file:
    % lens "eval buildNet.in"

If a script file named .lensrc exists in your home directory, ~/, it will be executed during the boot process. This can be used for customizing the appearance of the graphical displays, setting the command auto-load path, setting command aliases or defining new procedures.

Lens Mailing List

To keep abreast of changes to the latest version of Lens (which happen every few months), you will want to be on the mailing list. I try to keep the message rate on this list pretty low. To join, send mail (from the account where you want to receive the mail) to listar@tedlab.mit.edu with this in the subject:
    subscribe lens-users

Douglas Rohde
Last modified: Sat Nov 11 13:57:22 EST 2000