Tuesday, July 01, 2008

PLT Scheme on Vista

First off, I'd like to thank Eli Barzilay from the PLT team for helping track down these Vista 'features' that, together with a PLaneT 'feature', are causing my PLT Scheme problems on Vista. We also found the reason for long PLaneT download times on PLT Scheme V4.0 in the process.

This particular problem started when I tried to upgrade to PLT Scheme V4.0.1. After uninstalling PLT Scheme V4.0 (and making sure the uninstall completely removed the C:\Program Files\PLT directory) and installing V4.0.1, I would get the error "collects\srfi\compiled\provider_ss.zo::0: read (compiled): code compiled for version 4.0, not 4.0.1". I reported this on the bug tracker (http://bugs.plt-scheme.org/query/?cmd=view&pr=9554) where you can read the e-mail thread on the problem.

The Vista 'feature' that is biting us is called "UAC virtualization services" and is described in this article on the National Instruments Developer Site. (I'm sure there are many other such explainations that could be referenced.) It's a good read and goes into details that I will only summarize here. In short, if a user application attempts to modify protected portions of the file system (like C:\Program Files), the UAC virtualization service silently redirects the access to an unprotected, site-specific area (like C:\Users\doug\AppData\Local\VirtualStore\Program Files). Subsequent reads of affected files will use the copy in the virtual store. The problem is that install and uninstall (and probably some other application specific programs) don't know about the virtual store and files stay persistant across uninstall/install boundaries.

This was coupled with the current PLaneT 'feature' (http://bugs.plt-scheme.org/query/gnatsweb.pl?debug=&database=default&cmd=view+audit-trail&cmd=view&pr=9555) that compiles PLaneT packages with errortrace (i.e., debugging) when the initial require is from within DrScheme - it doesn't seem to happen from within MzScheme. In my case, when I would require the science collection (for example) from within DrScheme, it would download the collection and compile it and all referenced collections with errortrace turned on. This would recompile the referenced PLT Scheme collections (in C:\Program Files\PLT\collects) and the compiled files were put in the virtual store. This works okay until the uninstall of V4.0 and install of V4.0.1 where the compiled files in the virtual store (from V4.0) were seen instead of the newly installed files (from V4.0.1).

In any case, you can read the e-mail thread in the bug list for the details of how we finally tracked the problem down.

There are some work arounds that can be used until the PLT Scheme team figures out the best way to 'play nice' with Vista - although it would be nice if Vista played nice with legacy applications, but don't hold your breath for that.
  1. When you do an uninstall, check to see if C:\Users\<user>\AppData\Local\VirtualStore\PLT exists. If it does, delete it also. This will remove the user modified files that might exist - even if they didn't realize they had modified any. [Note that the location of the virtual store may be different, so you might want to do a search for 'PLT' and include system and hidden files in the search. Also, if there are multiple users, they may be multiple virtual stores.]
  2. For the initial load of PLaneT collections where you don't want errortrace turned on, do the initial require from MzScheme. For example, start up MzScheme from the command prompt and type "(require (planet "science.ss" ("williams" "science.plt")))" to load the science collection. This should work for any collection.
I will be 'upgrading' by laptop from Vista to XP and at least the first problem will go away. I would still recommend doing the initial require for PLaneT packages from MzScheme. I still have my Vista machine at home and will be dealing with some of these issues in an on-going basis.

Labels:

Thursday, June 26, 2008

Progress Updating to PLT Scheme V4.0

Now that PLT Scheme is official released, I am updating the science, simulation, and inference collections to be compatible with the new version. These changes are incompatible with pre-V4.0 versions of PLT Scheme and will be stored in the PLaneT 4.x repository. Anyone using pre-V4.0 code should continue to use the versions in the PLaneT 3xx repository. V4.0 compatible versions of the science collection (Version 3.0) and simulation collection (Version 3.0) have been released already. I am now working on the V4.0 version of the inference collection (Version 2.0) and expect to release it this weekend.

There were several rather simple global changes that occurred in all of the code. For example, using the new #lang construct for all modules, using modules for all examples, hash table name changes, changes to require constructs, some contract changes (in particular union/c becomes or/c), and define-struct syntactic changes.

Some other changes were more difficult. The changes to keywords and keyword parameters required individual attention to each specific usage. Fortunately, much of my usage of keyword parameters is in macros and those still work the same in V4.0. I often use keywords as special values (e.g. #:now). These used to self evaluate, but now require quoting. Fortunately, these don't occur in user code. The other major problem is with mutable lists. These also have to be looked at on an individual bases. In some cases, I reverted to immutable lists (e.g. when using reverse! to reorder a constructed list being returned from a function) and in other cases I converted them to explicit mutable lists. It can be a chore to track down all of the references in a large body of code.

One big remaining issue is converting the documentation over to use Scribble. Unfortunately, the existing HTML documentation for PLaneT packages is not made available in the new Help Desk. [I honestly think that they should retain the ability for developers to distribute HTML documentation for PLaneT packages.]

PLT Scheme Science Collection: The science collection was rather straightforward to convert since I had kept the older versions compatible with both 372 and 399 (the V4.0 pre-release). Version 2.9 is the last pre-V4.0 compatible version and Version 3.0 is the new V4.0 compatible version.

PLT Scheme Simulation Collection: The simulation collection was more complicated to convert since it mutates lists in the implementation of the event list and variable histories (and probably a few others that I don't remember). I also had some problems with keywords since I had implemented my own keyword parameter scheme before it was added into PLT Scheme. Version 2.2 is the last pre-V4.0 compatible version and Version 3.0 is the new V4.0 compatible version.

PLT Scheme Inference Collection: The inference collection makes extensive use of list mutation and I am still tracking down and fixing them on an individual basis. I expect to have the V4.0 compatible version out this weekend.

If anybody runs into any problems with any of these packages, please let me know.

Labels:

Saturday, May 27, 2006

PLT Scheme Projects

This blog is about my various open source PLT Scheme projects. There are three major Scheme projects I am currently working on. Two of these - PLT Scheme Science Collection and PLT Scheme Simulation Collection - have already been released. The third - PLT Scheme Inference Collection - is currently under development.
I had developed a knowledge-based simulation capability in Symbolics Common Lisp back in the late 1980s. I moved on to more traditional simulation technologies in my professional career and the work was largely forgotten. In the 1990s as PCs made their way into the classroom, I began using Scheme for teaching AI. However, at the time I didn't consider Scheme to be suitable for production quality software.
A few years ago, I came across PLT Scheme that seemed to meet my needs: it had an integrated development environment, it supported modern programming paradigms (e.g. object oriented programming, graphical user interfaces, exception handling, and modules), it was reasonably efficient, and it was portable across Windows and Linux, which are my two main platforms. Eventually I decided to resurrect my knowledge-based simulation work in PLT Scheme.
It was obvious that a simple port of the original Common Lisp code was not the best approach to the problem. I decomposed the problem into three basic components: the underlying mathematical and analysis capability, the simulation engine, and the inference engine. These became the science collection, simulation collection, and inference collection.
As I began developing the science collection, I noticed that much of what I needed was in the GNU Scientific Library (GSL). So, I decided that I would use the structure, and algorithms to the extent practical, of the GSL for the science collection. Version 1.0 of the PLT Scheme Science Collection was released via PLaneT in October 2004.
The simulation collection is a complete rewrite from the Common Lisp code. One of the advantages of Scheme is the availability of continuations, which are ideally suited for the implementation of a process-based simulation engine. I also decided to add a continuous simulation capability to the simulation engine. Version 1.0 of the PLT Scheme Simulation Collection was released in August 2005.
With my background in Artificial Intelligence, I was somewhat surprised at myself for leaving the inference collection as the last of the three to be implemented; particularly since I already have a Scheme version of a naive inference engine written. But, it made sense that way. It also turns out that the inference collection is a complete rewrite of the Common Lisp (and earlier Scheme) code. I plan on releasing Version 1.0 of the PLT Scheme Inference Collection during the summer of 2006.
I also have some Scheme programs that I have used in teaching AI classes over the years. Over time, I will convert these to PLT Scheme and make them available. The only one I have converted so far is a collection for defining state space problems and solving them using a graph search algorithm.

Labels: , , ,