Overview


What is it all about ?

A couple of weeks ago I decided to have a look at JavaScript to determine to what extent it is as good as many news writers claim it is. I soon discovered that although JavaScript is actually quite bad, it will probably be with us more a long time whether we like it or not! In other words, Ze Ma Yesh.

Since I am involved with the construction of web sites and HTML documents, I decided to have a closer look at JavaScript. This immediately led to the idea of creating a page in WORMS where I could practice my JavaScript.

So this is what this page is all about: it is a place where I shall practice my JavaScript.

As you can see from the table of contents, I plan to learn JavaScript by developing a number of OR applications relevant to our undergraduate OR program. Hopefully, when I complete this project at the end of this year our next year OR students will find some of the applications useful in their coursework.

Those of you who never heard about JavaScript might be interested to know that it is a simplified interactive version of Java which is the hotest stuff on the Internet these days. On-line reference material on JavaScript can be found here.

To quickly see how hot it really is, play a bit with the following control panel and try to figure out on your own what is going on. If you can't, take off your sunglasses.

restore

If you want to restore the table of contents to its former glory simply click what you are supposed to click.

If you are a Mac user you'll be delighted to learn that the text should not be covered by the background color. It is a bug that is causing this effect!

The big thing about JavaScript is that its code (called script) is incorporated into the HTML script and is thus executed on your machine. For example, consider this cute little thing:

Enter an arithmetic expression here (eg: 1 + 3):
When ready click this button ***:
Collect the result here:

*** Win16 users:
Due to a JavaScript bug, your system will probalbly crash if you attempt to compute the result!!!

Here is the HTML-JavaScript script used to produce this entire toy:

<center><table border=1 cellpadding=5><form> <tr><td>Enter an arithmetic expression here (eg: 1 + 3):</td> <td><input type="text" size=15></td></tr> <tr><td>When ready click this button <font color="red">**</font>:</td> <td><input type="button" name="Compute" value="Compute" onclick="this.form.elements[2].value = eval(this.form.elements[0].value)"></td></tr> <tr><td>Collect the result here:</td> <td><input type="text" name="result" size=15></td></tr> </table></form></center><p> So far so good!

At this stage you may ask yourself: what does this have to do with Operations Research?

Good question, mate!

But before I address this issue we have to deal with a very important practical fact of life:

Living with Bugs!

Although I make deliberate efforts to produce bug-free scripts, I am afraid that this is almost an impossible mission. The level of success depends very much on your subjectuve definition of what constitutes a bug. So let me tell you a couple of facts of life.

First, you should be aware of the fact that although there has been much publicity about the device-independent features of Java, I strongly suggest that you should not count on it. In particular, codes that seem to work well on Netscape 2.01 for the Mac enjoy crashing themselves on Netscape 2.01 for Windows 3.1. When you read the fine print provided by Netscape you learn that some features do depend on your hardware and/or operating system. I shall spare you the details here, but feel free to contact me for more information on this mater. Perhaps the term device-independent is supposed to indicate that Netscape will crash on any platform!!!

To the best of our knowledge here in Melbourne, the details of your WWW Navigator are as follows:

Code Name
Name
Version

Second, there is also the problem of soft bugs , namely things that are legally not classified as bugs, but which are nevertheless as buggy as the real thing, and perhpas worse. For example, it is really frustrating that "tables (i.e. matrices)" are not supported explicitely by JavaScript. This leads to early mental fatigue on the part of the user and consequently increase the capacity to produce real bugs.

In view of this I decided to include a Bugs Corner section in this page. I'll appreciate it very much if you report to me bugs that you have met in these pages.

An OR Perspective

What is there then for OR in this business? The short answer is simply "a lot!". At this stage you'll have to have to take my word for it, but I do hope that as we progress in this project you'll see the light! The bottom line is this: the technology that enables JavaScript to play color games also provides a lot of scope for serious OR work.

Of course, in view of the fact that I am just begining to learn the language, do not expect me to illustrate to you right here and now the serious stuff. What I can do though is show you something very simple but with a bit of OR flavour, say:

The Pivot Machine

User's Manual

Let M denote the n by m matrix under consideration, and let r and c denote the pivot-row and pivot-column, respectively. Also let mi,j denote the (i,j)th entry of M. Then, a pivot operation on mr,c produces a matrix M' of the same shape as M whose elements are as follows:

m'i,j  = { mi,j / mr,c   , i = r

mi,j - (mi,c / mr,c)mr,j  , i != r
Procedure:

Step # 1: Fill in the entries of the matrix in the Pivot Machine

Step # 2: Select the pivot-row using the button on the right-hand side of the matrix in the Pivot Machine:

Step # 3: Select the pivot-column using the button at the bottom of the matrix in the Pivot Machine:

Step # 4: Press the PIVOT button on the Pivot Machine.

Step # 5: Cross your fingers and/or pray, and/or do anything useful to convince the Elements to carry out the procedure without a major disaster.

Step #6: Read the Progress Report.

Self-Service Pivot Machine

Progress Report

Give it a try!

I have not yet tackled the error trapping issue so feel free to crash the system! I assume that the user is mature enough to handle the input successfully. I realise that this is an extremely naive assumption, but at present JavaScript does not offer good error trapping facilities! unfortunately, this is not an execuse, it is a fact of life.
Obviously, you can develop your own error trapping facilities on the fly but this goes beyond the scope of this small project.

Great Expectations

OK. What's next?

Well, I plan to continue with this project and learn more about JavaScript. You have to appreciate the fact that this is just a sort of hobby for me at the moment, more specifically I do it mainly for relaxation, and I need this a lot these days because the birds, snails, caterpillars and possums in my garden are driving me crazy!

My plan is to tackle first the issue of input: How do we input data to OR/MS models? My preliminary conclusion is that JavaScript is not bad in this department, except that more should be done to support multidimensional objects (forms and tables in particular!).

With regard to writing OR/MS codes, don't expect anything exciting! It is not there and I am not sure if it will ever come!

These lukewarm comments raise the question: What then is all this excitement in the media about ? Well, the thing is that at present JavaScript is the only programming environment that naive users can use to interact with Netscape. In particular, your code will (hopefully) be device and operating system independent. In my case, I write and test my scripts on a PowerMac knowing full well that most visitors to this site are Windows persons. As I indicated at the outset, although the "device independent" dream is not perfect, it is certainly workable.

I now must say somethig about frames. Generally speaking, I think that this feature of Netscape is a move in the right direction, in fact an unavoidable step forward. However, at this early stage it is difficult to take full advantage of the basic concept because the support given to it by Netscape 2.0 is very limited.

So although it is premature at this stage to exploit the full potential power of the basic concept behind frames, I decided to incorporate it as an important ingredient in this project. I hope that the kids in Netscape will soon upgrade the support for this important and potentially useful concept.

Why do I tell you all of this? Because I want to make sure that you appreciate the state of the art (actually lack of it) in this area. I strongly recommend that you visit Netscape's home page for guidance concerning frames and related matters.

Finally, I do plan to keep my eyes open with regard to new developments in this dynamic area and update this place accordingly.


Updates

Here I shall document updates to this work. Since I plan to work on is hobby mostly during weekends, I suspect that the updates will be a weekly affair. Here is the first one:

March 24, 1996:
Added input form for the distance matrix for the shortest path problem.PowerMac users will be delighted to hear that this code tends to create spectacular system crashes on the Power Mac 7100/66 (System 7.1.2).! The same code seems to coexist peacefully with Windows!!!!

March 25, 1996:
Added two sections (Functional Equation and Algorithms) to the Shortest Path Problem.

March 27, 1996:
Added a short blurb on the Critical Path Problem

March 29, 1996:
Added a short blurb on the The Simplex Method

March 31, 1996:
Added some Simplex codes! Have a look at the interactive forms in the Simplex Method document! The document is becomeing a bit long so I shall soon split it into several parts for the convenience of our overseas visitors.


How to join in !

All you have to do to join this exciting project is either learn JavaScript by developing simple interactive codes with some OR/MS flavour, or (if you are already a JavaScript expert) contribute something more sophisticated. In either case, I shall link your site to this place and that's it.

When you are ready send me the URL of your page and I'll link you to this place. It is that simple!

And if you want to leave a note to the general public concerning this project use our Notice Board. Needless to say, do not hesitate to contact me with regard to any aspect of the project.

Important Remark
You are welcome to contribute applications that are already listed in the table of contents. It will be very interesting to see how different persons will come up with different models for the same problem or method.