Tuesday, March 25, 2014

Crossing the Time Stream

Crossing the time stream occurs in episodic storytelling when a plot device is introduced that should have far-reaching implications, but is not routinely used after its introduction, even in situations where it would be an ideal solution for the problems faced by the heroes or villains. The most common example is time travel that allows the past to be changed and there is no more egregious crosser of the time stream than Star Trek.

The time stream was first crossed in the original series, but it wasn't until the subsequent movie and TV series that its frequent use snowballed into huge continuity issues. Star Trek II, III, and IV illustrate the problems caused by crossing the time stream. In The Wrath of Khan, Spock and numerous other crew members of the Enterprise and Reliant are killed. In The Search for Spock, Kirk steals the enterprise and in the ensuing adventure Spock is resurrected, but Kirk’s son is murdered and the Enterprise destroyed. In The Voyage Home, Kirk and crew travel back in time using their captured Klingon warbird in order to retrieve whales to save Earth’s future.

Wait, what? You can travel back in time to solve problems?

Uhmm, OK. Hey Kirk, how about this plan? After you’ve kill Khan in the present, why not just travel back in time and kill him in the past instead. Show up the day after you marooned him on Ceti Alpha V and launch a photon torpedo at him from orbit. Khan’s wrath will be incinerated with thermonuclear fury and since no one from Star Fleet has bothered to check on him for the last fifteen years, there's minimal impact to the timeline.

Spock doesn't have to die; your son doesn't have to die; your crew members don't have to die; the Enterprise doesn't have to be destroyed; and you can avoid a court martial for stealing a starship.

Let’s assume, however, that there’s a Federation Temporal Prime Directive and Kirk is only willing to violate it if the Earth is about to be destroyed by an alien space probe that communicates using catastrophic power-draining planetary weather changes and/or whalesong.

That would fill one plot hole, but there’s an adage that says “when time travel is outlawed, only outlaws will use time travel.” In other words, if the Federation has qualms about changing the timeline, most of its enemies would not.

Take the Borg for example. In First Contact they traveled back in time to assimilate Earth and almost succeeded, but that pesky Picard followed them through their temporal vortex and thwarted their plans. If only they could learn to adapt, they’d try it again and travel back in time somewhere the Federation fleet couldn’t observe them before heading toward Earth.

And surely after discovering the secret to time travel, at least one clever Klingon, Romulan, or Cardassian would come to the realization that if you travel back far enough in time, you can easily defeat your enemies with a starship. If there’s one thing that I learned from the Star Trek reboot, it’s that a U.S deep sea drilling platform sent back in time could have defeated the entire British navy in the War of 1812.

There are numerous other examples in the long history of Star Trek where crossing the time stream involves something other than time travel. How It Should Have Ended lampooned the use of transwarp beaming and magic blood in the most recent movie, Star Trek Into Darkness:



I thoroughly enjoyed the movie, but after 35 years of watching Star Trek I suppose I’ve been conditioned to accept that its depiction of technology in the science fiction genre follows fewer coherent and consistent rules than the depiction of magic in a typical series from the fantasy genre.

It really is a lost opportunity. When the franchise was rebooted, the creative team could have cast aside decades of continuity baggage. Instead they crossed the time stream right from the start to live on the side where nothing makes sense if you think about it.

Monday, March 17, 2014

Manners and Waltz Benchmarks

The two most widely used benchmarks for rule-based systems are Manners and Waltz. Daniel Selman nicely summarizes the major issues with these benchmarks in The Good, The Bad, and the Ugly - Rule Engine Benchmarks.

CLIPS didn’t implement the optimizations needed to run these benchmarks efficiently until version 6.30, so it compared unfavorably to other engines when these were the only metrics used for comparing performance.

As the following graphs show, the performance of CLIPS 6.30 is orders of magnitude faster than CLIPS 6.24 for the larger data sets used by these benchmarks.

In particular, hashing the memory nodes and optimizations for handling large numbers of activations caused the dramatic improvement in the benchmark results.

How did these optimizations improve the performance of a real world application? I benchmarked some of the larger sample data sets for a production system I developed that’s run hundreds of thousands of time a month. The system consists of hundreds of rules and the amount of data processed can range up to ten thousand or more facts.

Each of the samples showed improvement, but not nearly as dramatic as Manners or Waltz:

A process is created and the rules loaded each time the system is run, so a more accurate picture of the total processing time would include the time to load the rules:

There’s nothing wrong with modest improvements, but if your expectations of performance were based on Manners and Waltz, you’d surely be disappointed.

That’s not to say there weren’t performance benefits of the 6.30 optimizations in real world situations. Occasionally, I’d write one or more rules that were efficient for a small data set, but acceptance testing did not include a large data set. The system would run fine until a sufficiently large data set with the appropriate types of facts was submitted, at which point the process would display non-optimized Manners/Waltz behavior (i.e. it would appear to hang).

When using CLIPS 6.24, I rewrote the offending rules to be more efficient for large data sets. With 6.30, since the system is more tolerant of inefficient rules, these situations occur less frequently and are easier to correct.

CLIPS versions of the Manners and Waltz benchmarks are available here and here.

Tuesday, March 4, 2014

Playing the Nazi Card

There was a political group handing out literature by the post office when I picked up my mail the other week. They used these signs to attract attention:



I was reminded of Lewis Black’s thoughtful rant on Nazi Tourette’s:


When I’m Earth Overlord, my subjects will be free to criticize my enlightened rule without fear of reprisal.

The only exception will be for those who compare me or my governance to Hitler and the Nazis. Those people and anyone even remotely related to them will just disappear.

Now that’s something the Nazis would do, but the Volk will have to be content referring to such acts as evil.

At least there won’t be idiots loitering outside the post office.