Coupling LON-CAPA with MAXIMA was a challenge, since MAXIMA was originally
designed to be run interactively, so, unfortunately, the command line
option "-s port" of
MAXIMA does not establish a server port to which you can connect. For
scalablity reasons, though, it is prohibitive
to start a new MAXIMA process for every evaluation of an expression.
We also had problems with different LISP versions - the one we used is
Maxima 5.9.2.99rc1 http://maxima.sourceforge.net
Using Lisp SBCL 0.9.10
i.e, the Steel Bank Common Lisp.
The
following code might be helpful as a starting point for other projects
in which
you would like to connect to running MAXIMA processes - of course
you would need to remove the LON-CAPAisms:
- Server script lonmaxima - this server
script generates a configurable number of server processes that listen
to
a UNIX socket. Each of these processes is connected
to a running MAXIMA process.
[www@phy1 Apache]$ ps aux |grep maxima
www 14721 0.0 0.5 9420 5460 ? S 11:14 0:00 lonmaxima: Parent process, sleeping Sat Mar 11 11:14:41 2006
www 14722 0.0 0.5 9420 5508 ? S 11:14 0:00 lonmaxima: Accepting connections Sat Mar 11 11:23:09 2006
www 14723 0.0 2.2 885900 23348 pts/1 S 11:14 0:00 sbcl --core /usr/local/lib/maxima/5.9.2.99rc1/binary-sbcl/maxima.core --noinform --end-runtime-options --eval (cl-user::run) --end-toplevel-options
www 14724 0.0 0.5 9420 5508 ? S 11:14 0:00 lonmaxima: Accepting connections Sat Mar 11 11:19:59 2006
www 14725 0.0 0.5 9420 5508 ? S 11:14 0:00 lonmaxima: Accepting connections Sat Mar 11 11:23:51 2006
www 14726 0.0 2.2 885900 23204 pts/4 S 11:14 0:00 sbcl --core /usr/local/lib/maxima/5.9.2.99rc1/binary-sbcl/maxima.core --noinform --end-runtime-options --eval (cl-user::run) --end-toplevel-options
www 14727 0.0 0.5 9420 5508 ? S 11:14 0:00 lonmaxima: Accepting connections Sat Mar 11 11:22:35 2006
www 14736 0.0 2.2 885900 23304 pts/5 S 11:14 0:00 sbcl --core /usr/local/lib/maxima/5.9.2.99rc1/binary-sbcl/maxima.core --noinform --end-runtime-options --eval (cl-user::run) --end-toplevel-options
www 14739 0.0 0.5 9420 5508 ? S 11:14 0:00 lonmaxima: Accepting connections Sat Mar 11 11:24:57 2006
www 14742 0.0 2.2 885900 23304 pts/6 S 11:14 0:00 sbcl --core /usr/local/lib/maxima/5.9.2.99rc1/binary-sbcl/maxima.core --noinform --end-runtime-options --eval (cl-user::run) --end-toplevel-options
www 14775 0.0 2.2 885900 23112 pts/7 S 11:14 0:00 sbcl --core /usr/local/lib/maxima/5.9.2.99rc1/binary-sbcl/maxima.core --noinform --end-runtime-options --eval (cl-user::run) --end-toplevel-options
www 15172 0.0 0.0 5620 612 pts/8 S 11:52 0:00 grep maxima
[www@phy1 Apache]$
- Client library lonmaxima.pm -
some small routines to connect to the MAXIMA server. Example:
use Apache::lonmaxima();
...
my $socket=&Apache::lonmaxima::connect();
$r->print(
&Apache::lonmaxima::compareterms($socket,'a*x**2','x*a*x')."<br />".
&Apache::lonmaxima::compareterms($socket,'sin(x)**2','cos(x)**2')."<br />".
&Apache::lonmaxima::compareterms($socket,'sin(x)**2+cos(x)**2','1')."<br />"
);
&Apache::lonmaxima::disconnect($socket);
- gives you
true
false
true